traverse-with-class-0.1.1: Generic applicative traversals

Safe HaskellNone



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

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



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 ExpSource

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