product-profunctors-0.6.3.1: product-profunctors

Safe HaskellNone
LanguageHaskell98

Data.Profunctor.Product.TH

Description

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

xTuple :: ([Pat] -> Pat) -> ([Exp] -> Exp) -> (Name, Int) -> Dec Source

o :: Exp -> Exp -> Exp Source

appEAll :: Exp -> [Exp] -> Exp Source