Deriving extensions with multiparameter types

Viewed 89

I have an Ast type constructor, parameterized by the identifier type. Using the DeriveFunctor, DeriveFoldable and DeriveTraversable extensions it is possible to automatically create the appropriate instances.

Now I find it useful to introduce more type parameters but unfortunately the above method doesn't scale. Ideally I would like to be able to wrap my Ast type in selection types which would allow me to fmap to the appropriate type parameters. Is there some way to achieve a similar effect without having to define the instances myself?

edit:

Here is a small example of what the original Ast looked like:

Ast id = Ast (FuncDef id)
    deriving (Show, Functor, Foldable, Traversable)

FuncDef id = FuncDef id [Fparam id] (Block id)
    deriving (Show, Functor, Foldable, Traversable)

Block id = Block [Stmt id]
    deriving (Show, Functor, Foldable, Traversable)

..
1 Answers
Related