cubix-0.1.0.0: A framework for multi-language transformation
Safe HaskellNone
LanguageHaskell2010

Cubix.Language.Parametric.Derive

Synopsis

Documentation

deriveAll :: [Name] -> Q [Dec] Source #

Derives instances of the following for each type in the list:

HFunctor, HTraversable, HFoldable, EqHF, ShowHF, OrdHF, DynCase

Additonally, it will create smart constructors for the data type

createSortInclusionInfer :: Name -> Name -> Q [Dec] Source #

This is separated from createSortInclusionType because of phase limitations. This needs to refer to the smart constructor, and deriving a smart constructor needs to reify the type name.

sumToNames :: Name -> Q [Name] Source #

Takes something like "type Sig = '[ Add, Mul, Var]" and gives [''Add, ''Mul, ''Var]

makeDefaultInstances :: [Type] -> Name -> Name -> Exp -> [Dec] Source #

Used for creating default cases for Untrans instances. There are two default untranslate cases (identity for shared functors, error for unshared), so we need more advanced typeclass machinery to have both defaults. This caused GHC -O2 to go quadratic, and once caused a 64 GB server to run out of memory compiling. So, we use TH instead for the error cases.

Update: Maybe the 64 GB thing was something else (it's still happening at link time), but we still have pretty conclusive tests showing that our pattern of doing this with pure typeclass machinery was making GHC go quadratic, and then switching to TH has substantially improved compilation times