Safe Haskell | None |
---|---|
Language | Haskell98 |
If you have a data declaration which is a polymorphic product, for example
data Foo a b c = Foo a b c
or
data Foo a b c = Foo { foo :: a, bar :: b, baz :: c }
then you can use Template Haskell to automatically derive the
product-profunctor Default
instances and product-profunctor
"adaptor" with the following import and splice:
$(makeAdaptorAndInstance "pFoo" ''Foo)
- The adaptor for a type Foo is by convention called pFoo, but in practice you can call it anything.
The instance generated will be
instance (ProductProfunctor p, Default p a a', Default p b b', Default p c c') => Default p (Foo a b c) (Foo a' b' c')
and pFoo will have the type
pFoo :: ProductProfunctor p => Foo (p a a') (p b b') (p c c') -> p (Foo a b c) (Foo a' b' c')
Documentation
varNameOfBinder :: TyVarBndr -> Name Source
data MakeRecordT Source
MakeRecordT | |
|
makeRecordData :: MakeRecordT -> Q [Dec] Source
makeRecord :: MakeRecordT -> Q [Dec] Source
tupleAdaptors :: Int -> Name Source
mkTyVarsuffix :: String -> String -> TyVarBndr Source
mkTySuffix :: String -> String -> Type Source
mkVarTsuffix :: String -> String -> Type Source