multirec-alt-deriver-0.1.3: Alternative multirec instances deriver

Generics.MultiRec.TH.Alt

Description

Example usage:

import Generics.MultiRec
import Generics.MultiRec.TH.Alt
import Data.Tree

data TheFam :: (* -> *) where
              TreeIntPrf   :: TheFam   (Tree Int)
              ForestIntPrf :: TheFam (Forest Int)

$(deriveEverything
  (DerivOptions {
   familyTypes = [ 
        ( [t| Tree   Int |], "TreeIntPrf"   ),
        ( [t| Forest Int |], "ForestIntPrf" ) ],
   indexGadtName = "TheFam",
   constructorNameModifier = defaultConstructorNameModifier,
   patternFunctorName = "ThePF",
   verbose = True,
   sumMode = Balanced
  )
 )

type instance PF TheFam = ThePF

Synopsis

Documentation

data DerivOptions Source

Constructors

DerivOptions 

Fields

familyTypes :: [(TypeQ, String)]

A list of:

 (type (quoted), name of the proof for this type (i.e. the name of the constructor of the family GADT))

E.g.

 data FooFam a where
      FooPrf    :: FooFam Foo
      BarStrPrf :: FooFam (Bar String)

 ... DerivOptions { 
       familyTypes = 
        [ ( [t| Foo        |], "FooPrf"   ) ], 
          ( [t| Bar String |], "BarStrPrf") ] ] 
 ... 
 }  

This defines our mutually recursive family. The types must resolve to datatypes or newtypes of kind * (type synonyms will be expanded).

indexGadtName :: String

Name of the family GADT (this type has to be generated manually because TH doesn't support GADTs yet)

constructorNameModifier :: String -> String -> String

Scheme for producing names for the empty types corresponding to constructors. The first arg is the name of the type (as given in familyTypes), the second arg is the name of the constructor (builtins will be called: NIL, CONS, TUPLE2, TUPLE3 ...)

patternFunctorName :: String

Name of the pattern functor (PF) to generate

verbose :: Bool

Print various informational messges?

sumMode :: SumMode

The shape for trees of :+:s

data SumMode Source

Constructors

RightNested

e.g. a :+: (b :+: (c :+: d))

Balanced

e.g. (a :+: b) :+: (c :+: d)

defaultConstructorNameModifier :: String -> String -> StringSource

Makes names like CTOR_Either_Left, CTOR_Either_Right etc.

deriveEverything :: DerivOptions -> Q [Dec]Source

Main function.