[Haskell-cafe] Data constructor synonyms

Andres Loeh andres.loeh at googlemail.com
Fri Mar 18 14:44:11 CET 2011


>>  Remember that constructors are functions, except that you can't
>>  pattern match against them.
>
> ..
>
>>  The downside is that you can't pattern-match against these functions.
>
> The thing is that I need pattern matching, just functions won't do.

It's "only" a preprocessor, but Conor's "she" allows pattern synonyms:

http://personal.cis.strath.ac.uk/~conor/pub/she

> Anyway, a new question arose.  If I have already declared a type, can I add new constructors to it from other modules?

Again, not within Haskell itself. "she" also has a feature that allows
something like this. There are various other techniques or proposals.
For example:

http://www.cs.ru.nl/~wouters/Publications/DataTypesALaCarte.pdf
http://people.cs.uu.nl/andres/OpenDatatypes.html

Cheers,
  Andres



More information about the Haskell-Cafe mailing list