Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data TPredicateSym
- type ForbidManyTStuckErr c ps t = ((('Text "Can't check if type" :$$: 'ShowType t) :$$: (('Text "contains " :<>: TPredicateSymTypeNames ps) :<>: 'Text ". Perhaps you need to add")) :$$: 'ShowType c) :$$: 'Text "constraint? You can also try adding a type annotation."
- type family TPredicateSymTypeNames ps where ...
- type ForbidManyT c ps = ForbidManyT' c ps ps
- class ForbidManySuperC ps t => ForbidManyT' c ps' ps t where
- type ForbidManySuperC ps t :: Constraint
- type ForbidNonComparable = ForbidT 'PSNonComparable
- type ForbidNestedBigMaps = ForbidT 'PSNestedBigMaps
- type ForbidBigMap = ForbidT 'PSBigMap
- type ForbidSaplingState = ForbidT 'PSSaplingState
- type ForbidTicket = ForbidT 'PSTicket
- type ForbidContract = ForbidT 'PSContract
- type ForbidOp = ForbidT 'PSOp
- class ForbidManyT (ForbidT p t) '[p] t => ForbidT p t
- type family ForbidTErrorMsg p t where ...
- type family ContainsT p t where ...
- type family TPredicateSymTypeName p where ...
- data SingTPredicateSym :: TPredicateSym -> Type where
- SPSOp :: SingTPredicateSym ('PSOp :: TPredicateSym)
- SPSContract :: SingTPredicateSym ('PSContract :: TPredicateSym)
- SPSTicket :: SingTPredicateSym ('PSTicket :: TPredicateSym)
- SPSBigMap :: SingTPredicateSym ('PSBigMap :: TPredicateSym)
- SPSNestedBigMaps :: SingTPredicateSym ('PSNestedBigMaps :: TPredicateSym)
- SPSSaplingState :: SingTPredicateSym ('PSSaplingState :: TPredicateSym)
- SPSNonComparable :: SingTPredicateSym ('PSNonComparable :: TPredicateSym)
- type family PSNonComparableSym0 :: TPredicateSym where ...
- type family PSSaplingStateSym0 :: TPredicateSym where ...
- type family PSNestedBigMapsSym0 :: TPredicateSym where ...
- type family PSBigMapSym0 :: TPredicateSym where ...
- type family PSTicketSym0 :: TPredicateSym where ...
- type family PSContractSym0 :: TPredicateSym where ...
- type family PSOpSym0 :: TPredicateSym where ...
Documentation
data TPredicateSym Source #
Type-level symbol for type predicates used in ContainsT
PSOp | Contains |
PSContract | Contains |
PSTicket | Contains |
PSBigMap | Contains |
PSNestedBigMaps | Contains |
PSSaplingState | Contains |
PSNonComparable | Contains non-comparable types |
Instances
type ForbidManyTStuckErr c ps t = ((('Text "Can't check if type" :$$: 'ShowType t) :$$: (('Text "contains " :<>: TPredicateSymTypeNames ps) :<>: 'Text ". Perhaps you need to add")) :$$: 'ShowType c) :$$: 'Text "constraint? You can also try adding a type annotation." Source #
type family TPredicateSymTypeNames ps where ... Source #
Given a list of TPredicateSym
, pretty-print a list of corresponding type
names. Uses TPredicateSymTypeName
for a single type, separates the last two
types with or
, others with ,
.
Doesn't do the oxford comma, because it's rather tricky to implement, and compilation types aren't great already.
TPredicateSymTypeNames '[] = 'Text "" | |
TPredicateSymTypeNames '[p] = 'Text (TPredicateSymTypeName p) | |
TPredicateSymTypeNames '[p, q] = ('Text (TPredicateSymTypeName p) :<>: 'Text " or ") :<>: 'Text (TPredicateSymTypeName q) | |
TPredicateSymTypeNames (p ': ps) = ('Text (TPredicateSymTypeName p) :<>: 'Text ", ") :<>: TPredicateSymTypeNames ps |
type ForbidManyT c ps = ForbidManyT' c ps ps Source #
Abstracts multiple ForbidT
constraints. Accepts a constraint that will be
suggested in an error message in case ContainsT
gets stuck. This is used with
scope constraints in Morley.Michelson.Typed.Scope.Internal.Scopes.
class ForbidManySuperC ps t => ForbidManyT' c ps' ps t Source #
Class abstracting multiple ForbidT
constraints.
This version accepts a custom error message displayed if ContainsT
gets stuck.
You likely want to use ForbidManyT
, which sets this message.
It's a class and not a recursive type family because recursive type families take noticeably longer to compile.
type ForbidManySuperC ps t :: Constraint Source #
Instances
ForbidManyT' c ps' ('[] :: [TPredicateSym]) t Source # | |
Defined in Morley.Michelson.Typed.Scope.Internal.ForbidT type ForbidManySuperC '[] t Source # | |
(IfStuck (ContainsT p t) (DelayError (ForbidManyTStuckErr c ps' t) :: Constraint) (Pure (ForbidManyT' c ps' ps t)), FailWhen (ContainsT p t) (ForbidTErrorMsg p t)) => ForbidManyT' c ps' (p ': ps) t Source # | |
Defined in Morley.Michelson.Typed.Scope.Internal.ForbidT type ForbidManySuperC (p ': ps) t Source # |
type ForbidNonComparable Source #
= ForbidT 'PSNonComparable | Convenience synonym |
type ForbidNestedBigMaps Source #
= ForbidT 'PSNestedBigMaps | Convenience synonym |
type ForbidBigMap Source #
type ForbidSaplingState Source #
= ForbidT 'PSSaplingState | Convenience synonym |
type ForbidTicket Source #
type ForbidContract Source #
= ForbidT 'PSContract | Convenience synonym |
class ForbidManyT (ForbidT p t) '[p] t => ForbidT p t Source #
Constraint for classes forbidding type presence based on predicate defined
by TPredicateSym
.
Not just a type alias in order to be able to partially apply it (e.g. in
Each
).
Reports errors when a type does not satisfy predicate:
>>>
() :: ForbidT PSOp TOperation => ()
... ... Type `operation` found in ... 'TOperation ... is not allowed in this scope ...>>>
() :: ForbidT PSContract (TContract TUnit) => ()
... ... Type `contract` found in ... 'TContract 'TUnit ... is not allowed in this scope ...>>>
() :: ForbidT PSTicket (TTicket TUnit) => ()
... ... Type `ticket` found in ... 'TTicket 'TUnit ... is not allowed in this scope ...>>>
() :: ForbidT PSBigMap (TBigMap TUnit TUnit) => ()
... ... Type `big_map` found in ... 'TBigMap 'TUnit 'TUnit ... is not allowed in this scope ...>>>
() :: ForbidT PSSaplingState (TSaplingState Z) => ()
... ... Type `sapling_state` found in ... 'TSaplingState 'Z ... is not allowed in this scope ...>>>
() :: ForbidT PSNestedBigMaps (TBigMap TUnit (TBigMap TUnit TUnit)) => ()
... ... Nested `big_map`s found in ... 'TBigMap 'TUnit ('TBigMap 'TUnit 'TUnit) ... are not allowed ...
When the type is ambiguous or polymorphic, suggests adding the corresponding constraint:
>>>
(const () :: ForbidOp t => f t -> ()) undefined
... ... Can't check if type ... t0 ... contains `operation`. Perhaps you need to add ... ForbidT 'PSOp t0 ... constraint? You can also try adding a type annotation. ...
This constraint implies ContainsT ~ False
:
>>>
:{
foo :: ForbidT p t => ContainsT p t :~: False foo = Refl :}
Instances
type family ForbidTErrorMsg p t where ... Source #
ForbidTErrorMsg 'PSNestedBigMaps t = ('Text "Nested `big_map`s found in" :$$: 'ShowType t) :$$: 'Text "are not allowed" | |
ForbidTErrorMsg 'PSNonComparable t = ('Text "Non-comparable type" :$$: 'ShowType t) :$$: 'Text "is not allowed in this scope" | |
ForbidTErrorMsg p t = ((('Text "Type " :<>: 'Text (TPredicateSymTypeName p)) :<>: 'Text " found in") :$$: 'ShowType t) :$$: 'Text "is not allowed in this scope" |
type family ContainsT p t where ... Source #
type family TPredicateSymTypeName p where ... Source #
TPredicateSymTypeName 'PSOp = "`operation`" | |
TPredicateSymTypeName 'PSContract = "`contract`" | |
TPredicateSymTypeName 'PSTicket = "`ticket`" | |
TPredicateSymTypeName 'PSBigMap = "`big_map`" | |
TPredicateSymTypeName 'PSNestedBigMaps = "nested `big_map`s" | |
TPredicateSymTypeName 'PSSaplingState = "`sapling_state`" | |
TPredicateSymTypeName 'PSNonComparable = "non-comparable types" |
data SingTPredicateSym :: TPredicateSym -> Type where Source #
Instances
TestCoercion SingTPredicateSym Source # | |
Defined in Morley.Michelson.Typed.Scope.Internal.ForbidT testCoercion :: forall (a :: k) (b :: k). SingTPredicateSym a -> SingTPredicateSym b -> Maybe (Coercion a b) # | |
TestEquality SingTPredicateSym Source # | |
Defined in Morley.Michelson.Typed.Scope.Internal.ForbidT testEquality :: forall (a :: k) (b :: k). SingTPredicateSym a -> SingTPredicateSym b -> Maybe (a :~: b) # |
type family PSNonComparableSym0 :: TPredicateSym where ... Source #
type family PSSaplingStateSym0 :: TPredicateSym where ... Source #
type family PSNestedBigMapsSym0 :: TPredicateSym where ... Source #
type family PSBigMapSym0 :: TPredicateSym where ... Source #
type family PSTicketSym0 :: TPredicateSym where ... Source #
type family PSContractSym0 :: TPredicateSym where ... Source #