Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- class (SingI t, RecSuperC Comparable t, ForbidNonComparable t) => Comparable t
- type family RecSuperC c t where ...
- type ComparabilityImplies t = (ForbidOp t, ForbidNestedBigMaps t, ForbidTicket t, ForbidSaplingState t, ForbidBigMap t, ForbidContract t, ForbidNonComparable t)
- data Comparability t where
- CanBeCompared :: (Comparable t, ComparabilityImplies t) => Comparability t
- CannotBeCompared :: ContainsT 'PSNonComparable t ~ 'True => Comparability t
- comparableImplies :: forall t proxy. ForbidNonComparable t => proxy t -> Dict (ComparabilityImplies t)
- checkComparability :: Sing t -> Comparability t
- comparabilityPresence :: Sing t -> Maybe (Dict (Comparable t))
Documentation
class (SingI t, RecSuperC Comparable t, ForbidNonComparable t) => Comparable t Source #
Instances
(SingI t, RecSuperC Comparable t, ForbidNonComparable t) => Comparable t Source # | |
SingI t => CheckScope (Comparable t) Source # | |
Defined in Morley.Michelson.Typed.Scope.Internal.CheckScope checkScope :: Either BadTypeForScope (Dict (Comparable t)) Source # |
type ComparabilityImplies t = (ForbidOp t, ForbidNestedBigMaps t, ForbidTicket t, ForbidSaplingState t, ForbidBigMap t, ForbidContract t, ForbidNonComparable t) Source #
Constraints implied by Comparable
. This is a little expensive to carry as
the superclass of Comparable
, hence these can be brought into scope on
demand using comparableImplies
.
data Comparability t where Source #
CanBeCompared :: (Comparable t, ComparabilityImplies t) => Comparability t | |
CannotBeCompared :: ContainsT 'PSNonComparable t ~ 'True => Comparability t |
Instances
Show (Comparability t) Source # | |
Defined in Morley.Michelson.Typed.Scope.Internal.Comparable showsPrec :: Int -> Comparability t -> ShowS # show :: Comparability t -> String # showList :: [Comparability t] -> ShowS # |
comparableImplies :: forall t proxy. ForbidNonComparable t => proxy t -> Dict (ComparabilityImplies t) Source #
Produce ComparabilityImplies
on demand. Carrying it as Comparable
superclasses turns out to be a little expensive, considering we can produce
evidence on demand in O(1).
checkComparability :: Sing t -> Comparability t Source #
Check if type is comparable or not at runtime. This traverses the
singleton, so it has a considerable runtime cost. If you just need to convince
GHC, you may be looking for comparableImplies
, or perhaps
withDeMorganScope
.
>>>
checkComparability STOperation
CannotBeCompared>>>
checkComparability STAddress
CanBeCompared
comparabilityPresence :: Sing t -> Maybe (Dict (Comparable t)) Source #
Check if type is comparable or not at runtime. This is a Dict
version of
checkComparability
, so the same caveats apply.
>>>
comparabilityPresence STOperation
Nothing>>>
comparabilityPresence STAddress
Just Dict