Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- type ForbidOp = ForbidT 'PSOp
- type family ContainsT p t where ...
- class ForbidManyT (ForbidT p t) '[p] t => ForbidT p t
- type ForbidContract = ForbidT 'PSContract
- type ForbidTicket = ForbidT 'PSTicket
- type ForbidBigMap = ForbidT 'PSBigMap
- type ForbidNestedBigMaps = ForbidT 'PSNestedBigMaps
- type ForbidNonComparable = ForbidT 'PSNonComparable
- data TPredicateSym
- 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 TPredicateSymTypeName p where ...
- type family ForbidTErrorMsg p t where ...
- type ForbidManyT c ps = ForbidManyT' c ps ps
- type ForbidSaplingState = ForbidT 'PSSaplingState
- class ForbidManySuperC ps t => ForbidManyT' c ps' ps t where
- type ForbidManySuperC ps t :: Constraint
- class a ~ 'False => DelayedContainsTCheck c ps' p t a
- 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 family PSOpSym0 :: TPredicateSym where ...
- type family PSContractSym0 :: TPredicateSym where ...
- type family PSTicketSym0 :: TPredicateSym where ...
- type family PSBigMapSym0 :: TPredicateSym where ...
- type family PSNestedBigMapsSym0 :: TPredicateSym where ...
- type family PSSaplingStateSym0 :: TPredicateSym where ...
- type family PSNonComparableSym0 :: TPredicateSym where ...
Documentation
type family ContainsT p t where ... Source #
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 ForbidContract Source #
= ForbidT 'PSContract | Convenience synonym |
type ForbidTicket Source #
type ForbidBigMap Source #
type ForbidNestedBigMaps Source #
= ForbidT 'PSNestedBigMaps | Convenience synonym |
type ForbidNonComparable Source #
= ForbidT 'PSNonComparable | Convenience synonym |
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
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 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" |
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 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.
type ForbidSaplingState Source #
= ForbidT 'PSSaplingState | Convenience synonym |
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 # | |
(ForbidManyT' c ps' ps t, DelayedContainsTCheck c ps' p t (ContainsT p t)) => ForbidManyT' c ps' (p ': ps) t Source # | |
Defined in Morley.Michelson.Typed.Scope.Internal.ForbidT type ForbidManySuperC (p ': ps) t Source # |
class a ~ 'False => DelayedContainsTCheck c ps' p t a Source #
This is a horrible hack designed to delay GHC's test for equality of ContainsT ... with False. Unfortunately, due to the use of incoherence, more type signatures will be required downstream. But the impact seems somewhat minimal in practice.
Instances
DelayedContainsTCheck (c :: k1) (ps' :: k2) (p :: k3) (t :: k4) 'False Source # | |
(WhenStuck t (TypeError (ForbidManyTStuckErr c ps' t) :: Constraint), FailWhen a (ForbidTErrorMsg p t)) => DelayedContainsTCheck (c :: Constraint) (ps' :: [TPredicateSym]) (p :: TPredicateSym) (t :: T) a Source # | |
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 family PSContractSym0 :: TPredicateSym where ... Source #
type family PSTicketSym0 :: TPredicateSym where ... Source #
type family PSBigMapSym0 :: TPredicateSym where ... Source #
type family PSNestedBigMapsSym0 :: TPredicateSym where ... Source #
type family PSSaplingStateSym0 :: TPredicateSym where ... Source #
type family PSNonComparableSym0 :: TPredicateSym where ... Source #