large-records-0.1.0.0: Efficient compilation for large records, linear in the size of the record
Safe HaskellNone
LanguageHaskell2010

Data.Record.TH.CodeGen.Tree

Synopsis

Trees and forests

data Tree a Source #

Trees with values at the leaves

Constructors

Leaf a 
Branch (Forest a) 

Instances

Instances details
Show a => Show (Tree a) Source # 
Instance details

Defined in Data.Record.TH.CodeGen.Tree

Methods

showsPrec :: Int -> Tree a -> ShowS #

show :: Tree a -> String #

showList :: [Tree a] -> ShowS #

data Forest a Source #

Constructors

Forest [Tree a] 

Instances

Instances details
Show a => Show (Forest a) Source # 
Instance details

Defined in Data.Record.TH.CodeGen.Tree

Methods

showsPrec :: Int -> Forest a -> ShowS #

show :: Forest a -> String #

showList :: [Forest a] -> ShowS #

Catamorphisms

data Cata a b Source #

Constructors

Cata 

Fields

tree :: Cata a b -> Tree a -> b Source #

forest :: Cata a b -> Forest a -> b Source #

Dealing with ghc's tuple size limit

data TupleLimit Source #

Maximum number of elements in a tuple

Constructors

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))

mkTupleE :: forall a. (a -> Q Exp) -> Forest a -> Q Exp Source #

Construct tuple expression

mkTupleT :: forall a. (a -> Q Type) -> Forest a -> Q Type Source #

Construct tuple type

mkTupleP :: forall a. (a -> Q Pat) -> Forest a -> Q Pat Source #

Construct tuple pattern