traverse-with-class-0.2.0.3: Generic applicative traversals

Safe HaskellNone
LanguageHaskell2010

Data.Generics.Traversable.TH

Description

For the generated instances you'll typically need the following extensions:

{-# LANGUAGE TemplateHaskell, MultiParamTypeClasses, FlexibleInstances, ConstraintKinds, UndecidableInstances #-}

Synopsis

Documentation

deriveGTraversable :: Name -> Q [Dec] Source

Example usage:

data MyType = MyType

deriveGTraversable ''MyType

It tries to create the necessary instance constraints, but is not very smart about it For tricky types, it may fail or produce an overconstrained instance. In that case, write the instance declaration yourself and use gtraverseExpr to derive the implementation:

data MyType a = MyType

instance GTraversable (MyType a) where
  gtraverse = $(gtraverseExpr ''MyType)

gtraverseExpr :: Name -> Q Exp Source

Return a lambda expression which implements gtraverse for the given data type.