Copyright | (c) Sjoerd Visscher 2020 |
---|---|
Maintainer | sjoerd@w3future.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data Derivator = Derivator {}
- varExp :: Name -> Q Exp
- idDeriv :: Derivator
- deriveInstance :: Derivator -> Q Type -> Q [Dec]
- deriveInstance' :: Derivator -> Cxt -> Name -> Type -> Q [Dec]
- buildOperation :: Derivator -> Name -> Type -> Q Exp -> Q ([Name], Exp)
- buildArgument :: Name -> Type -> Q Exp -> Q Exp -> Q Exp
- isVar :: Name -> Type -> Bool
- hasVar :: Name -> Type -> Bool
- className :: Type -> Name
- contains :: Data d => Name -> d -> Bool
- data ShowsPrec
- showAp :: ShowsPrec -> ShowsPrec -> ShowsPrec
- showDeriv :: Derivator
- isOperator :: String -> Bool
Documentation
To write your own Derivator
you need to show how each part of a method gets lifted.
For example, when deriving an instance for type a
of the following methods:
meth0 :: a meth1 :: Int -> a meth2 :: a -> Either Bool a -> Sum Int meth3 :: Maybe [a] -> IO a
the resulting template haskell declarations are (pseudo code):
meth0 = $res ($op "meth0" meth0) meth1 a = $res (($op "meth1" meth1) `$ap` ($arg Int a)) meth2 ($inp v0) ($inp v1) = $cst (($op "meth2" meth2) `$ap` ($var (iterate
0) v0)) `$ap` ($var (iterate
1) v1) meth3 ($inp v2) = $eff (($op "meth2" meth2) `$ap` ($var (iterate
2) v2))
Derivator | |
|
Helper for showing infix expressions
ShowsPrec (Int -> String -> String) | |
ShowOp2 Fixity (Int -> String -> String) | |
ShowOp1 Fixity (Int -> String -> String) |
Instances
Bounded ShowsPrec Source # | |
Floating ShowsPrec Source # | |
Defined in Data.DeriveLiftedInstances exp :: ShowsPrec -> ShowsPrec # log :: ShowsPrec -> ShowsPrec # sqrt :: ShowsPrec -> ShowsPrec # (**) :: ShowsPrec -> ShowsPrec -> ShowsPrec # logBase :: ShowsPrec -> ShowsPrec -> ShowsPrec # sin :: ShowsPrec -> ShowsPrec # cos :: ShowsPrec -> ShowsPrec # tan :: ShowsPrec -> ShowsPrec # asin :: ShowsPrec -> ShowsPrec # acos :: ShowsPrec -> ShowsPrec # atan :: ShowsPrec -> ShowsPrec # sinh :: ShowsPrec -> ShowsPrec # cosh :: ShowsPrec -> ShowsPrec # tanh :: ShowsPrec -> ShowsPrec # asinh :: ShowsPrec -> ShowsPrec # acosh :: ShowsPrec -> ShowsPrec # atanh :: ShowsPrec -> ShowsPrec # log1p :: ShowsPrec -> ShowsPrec # expm1 :: ShowsPrec -> ShowsPrec # | |
Fractional ShowsPrec Source # | |
Num ShowsPrec Source # | |
Defined in Data.DeriveLiftedInstances | |
Show ShowsPrec Source # | |
Semigroup ShowsPrec Source # | |
Monoid ShowsPrec Source # | |
isOperator :: String -> Bool Source #