Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
A collection of type families and other type-level machinery for working with Michelson types.
Synopsis
- type family IsPair (pair :: T) :: Bool where ...
- type family CombedPairLeafCount (t :: T) :: Peano where ...
- type family CombedPairNodeCount (t :: T) :: Peano where ...
- type family CombedPairLeafCountIsAtLeast (n :: Peano) (t :: T) :: Bool where ...
- type family CombedPairNodeIndexIsValid (nodeIndex :: Peano) (pair :: T) :: Bool where ...
Right-combed pairs
type family CombedPairLeafCount (t :: T) :: Peano where ... Source #
Returns the number of leaves in a right-combed pair.
CombedPairLeafCount ('TPair 'TInt ('TPair 'TString 'TUnit)) ~ ToPeano 3
If the pair contains sub-trees to the left, they will not be accounted for.
E.g. the length of pair w (pair x y) z
is 3.
CombedPairLeafCount ('TPair _ ('TPair y z)) = 'S (CombedPairLeafCount ('TPair y z)) | |
CombedPairLeafCount ('TPair _ _) = ToPeano 2 |
type family CombedPairNodeCount (t :: T) :: Peano where ... Source #
Returns the number of nodes in a right-combed pair.
CombedPairNodeCount ('TPair _ ('TPair y z)) = 'S ('S (CombedPairNodeCount ('TPair y z))) | |
CombedPairNodeCount ('TPair _ _) = ToPeano 3 |
type family CombedPairLeafCountIsAtLeast (n :: Peano) (t :: T) :: Bool where ... Source #
Checks whether a pair contains at least n
elements.
CombedPairLeafCountIsAtLeast ('S ('S 'Z)) ('TPair _ _) = 'True | |
CombedPairLeafCountIsAtLeast ('S n) ('TPair _ y) = CombedPairLeafCountIsAtLeast n y | |
CombedPairLeafCountIsAtLeast ('S _) _ = 'False |
type family CombedPairNodeIndexIsValid (nodeIndex :: Peano) (pair :: T) :: Bool where ... Source #
For a given node index i
, this type family checks whether
a pair has at least i+1
nodes.
Note that the index 0 is always valid, even if the input type is not a pair.
CombedPairNodeIndexIsValid 'Z _ = 'True | |
CombedPairNodeIndexIsValid ('S 'Z) ('TPair _ _) = 'True | |
CombedPairNodeIndexIsValid ('S ('S nodeIndex')) ('TPair _ right) = CombedPairNodeIndexIsValid nodeIndex' right | |
CombedPairNodeIndexIsValid _ _ = 'False |