| Copyright | (c) Sjoerd Visscher 2020 |
|---|---|
| Maintainer | sjoerd@w3future.com |
| Stability | experimental |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.DeriveLiftedInstances.Internal
Contents
Description
Synopsis
- data Derivator = Derivator {}
- varExp :: Name -> Q Exp
- varPat :: Name -> Q Pat
- 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
- tvName :: TyVarBndr -> 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 -> Int meth3 :: Maybe [a] -> 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 v0 v1 = (($op "meth2" meth2) `$ap` ($var fold0 v0)) `$ap` ($var fold1 v1)
where
fold0 _ f = f
fold1 map f = [| $map $f |]
meth3 v2 = $res (($op "meth2" meth2) `$ap` ($var fold2 v2))
where
fold2 map f = [| $map ($map $f) |]
Constructors
| Derivator | |
Fields
| |
Helper for showing infix expressions
Constructors
| 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 Methods 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 #