
18 Mar
2011
18 Mar
'11
7:22 a.m.
Remember that constructors are functions, except that you can't pattern match against them.
data MyType = GeneralConstructor [Double]
-- GeneralConstructor :: [Double] -> MyType
Note the lower case character, just a plain function:
specialConstructor :: Double -> MyType specialConstructor a = GeneralConstructor (a:[])
zero :: MyType zero = GeneralConstructor [0]
The downside is that you can't pattern-match against these functions.