[Haskell-cafe] Is Template Haskell a suitable macro language?
Jacques Carette
carette at mcmaster.ca
Tue Apr 24 11:58:52 EDT 2007
Magnus Jonsson wrote:
> I have the same problem too when using Haskell. The more I try to
> enforce static guarantees the more I get lots of datatypes that are
> similar except for one or two constructors. The best way I have found
> to avoid this is to simply give up on some of the static guarantees
> and just use one datatype that contains all the constructors. Less
> static guarantees but also less needless type coaxing between 90%
> similar types. I haven't tried using macros.
In Ocaml, you can frequently use polymorphic variants to get the same
effect.
Which means that if you are willing to do enough type-class-hackery, it
should, in principle, be possible to do the same in Haskell. But it
sure isn't as convenient!
This all points to some clear need for more ``flavours'' of polymorphism
being needed (in Haskell), to be able to express *in the type system*
what TH allows you to say "outside".
Jacques
More information about the Haskell-Cafe
mailing list