I need to generate code for the function signature with type class constraints, for example:
fun :: (Ord a) => a -> a
I'm using the following signature constructor:
SigD Name Type
So, I need to generate a type. My best guess is to use the following constructor:
ForallT [TyVarBndr] Cxt Type
It corresponds to the following declaration (as seen at Temaplate Haskell documentation):
forall <vars>. <ctxt> => <type>
But Cxt
is just a synonym for the list of Type
's, and I can't find an appropriate constructor of Type
for generating a type class constraint. What should I do to generate code for a type class constraint?