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.

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to