[Haskell-cafe] Data constructor synonyms

Grigory Sarnitskiy sargrigory at ya.ru
Fri Mar 18 11:58:36 CET 2011

Hello! Assume I have a type MyType with the constructor GeneralConstructor:

data MyType = GeneralConstructor [Double]

but I also want to have a separate name for special case of this constructor:

SpecialConstructor Double

so SpecialConstructor a = GeneralConstructor (a:[]) that is

SpecialConstructor 5 was exactly the same as GeneralConstructor [5].

And for example instead of writing GeneralConstructor [0] I would like to use constructor Zero. It's all just for convenience.

How can I achieve this? Well, of course I always can use sed to replace SpecialConstructor 5 with  GeneralConstructor [5] in program sources, but it's not convenient.

More information about the Haskell-Cafe mailing list