Safe Haskell | Safe |
---|---|
Language | Haskell98 |
Synopsis
- makeBaseFunctor :: Name -> DecsQ
- makeBaseFunctorWith :: BaseRules -> Name -> DecsQ
- data BaseRules
- baseRules :: BaseRules
- baseRulesType :: Functor f => ((Name -> Name) -> f (Name -> Name)) -> BaseRules -> f BaseRules
- baseRulesCon :: Functor f => ((Name -> Name) -> f (Name -> Name)) -> BaseRules -> f BaseRules
- baseRulesField :: Functor f => ((Name -> Name) -> f (Name -> Name)) -> BaseRules -> f BaseRules
Documentation
makeBaseFunctor :: Name -> DecsQ Source #
Build base functor with a sensible default configuration.
e.g.
data Expr a
= Lit a
| Add (Expr a) (Expr a)
| Expr a :* [Expr a]
deriving (Show)
makeBaseFunctor
''Expr
will create
data ExprF a x = LitF a | AddF x x | x :*$ [x] deriving (Functor
,Foldable
,Traversable
) type instanceBase
(Expr a) = ExprF a instanceRecursive
(Expr a) whereproject
(Lit x) = LitF xproject
(Add x y) = AddF x yproject
(x :* y) = x :*$ y instanceCorecursive
(Expr a) whereembed
(LitF x) = Lit xembed
(AddF x y) = Add x yembed
(x :*$ y) = x :* y
makeBaseFunctor
=makeBaseFunctorWith
baseRules
Notes:
makeBaseFunctor
works properly only with ADTs.
Existentials and GADTs aren't supported,
as we don't try to do better than
GHC's DeriveFunctor.
makeBaseFunctorWith :: BaseRules -> Name -> DecsQ Source #
Build base functor with a custom configuration.
baseRules :: BaseRules Source #
Default BaseRules
: append F
or $
to data type, constructors and field names.
baseRulesType :: Functor f => ((Name -> Name) -> f (Name -> Name)) -> BaseRules -> f BaseRules Source #
How to name the base functor type.
Default is to append F
or $
.