
18 Mar
2011
18 Mar
'11
6:58 a.m.
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.