Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Tree a
- data Forest a = Forest [Tree a]
- data Cata a b = Cata {}
- tree :: Cata a b -> Tree a -> b
- forest :: Cata a b -> Forest a -> b
- data TupleLimit
- nest :: TupleLimit -> [a] -> Forest a
- mkTupleE :: forall a. (a -> Q Exp) -> Forest a -> Q Exp
- mkTupleT :: forall a. (a -> Q Type) -> Forest a -> Q Type
- mkTupleP :: forall a. (a -> Q Pat) -> Forest a -> Q Pat
Trees and forests
Trees with values at the leaves
Catamorphisms
Dealing with ghc
's tuple size limit
data TupleLimit Source #
Maximum number of elements in a tuple
DefaultGhcTupleLimit | Default maximum number of elements in a tuple in ghc (62) |
MaxTupleElems Int | Explicit specified liit |
nest :: TupleLimit -> [a] -> Forest a Source #
Observe ghc
's tuple length
Haskell has a limit of 62 fields per tuple. Here we take an arbitrary list and turn it into a nested tuple that preserves this limit.
Example: if we reduce the limit to 2
, we get the following nestings,
for lengths [1..10]
:
A (A, A) ((A, A), A) ((A, A), (A, A)) (((A, A), (A, A)), A) (((A, A), (A, A)), (A, A)) (((A, A), (A, A)), ((A, A), A)) (((A, A), (A, A)), ((A, A), (A, A))) ((((A, A), (A, A)), ((A, A), (A, A))), A) ((((A, A), (A, A)), ((A, A), (A, A))), (A, A))