
13 Nov
2007
13 Nov
'07
10:29 p.m.
I wonder, is there an equivalent of the 'type' keyword for constructors? An example: -- create a pseudo-C pointer type -- which can point to a value or a -- null. type Pointer a = Maybe a -- int a = 3; -- int *pa = &a; ampersand :: t -> Pointer t ampersand a = Just a -- int b = *pa. star :: Pointer a -> a star (Just a) = a -- note this function behaves -- in an 'authentic' fashion ;-) To really complete the illusion it would be nice to replace the names Just and Nothing with PointerTo and Null. Then the constructors would really mean something. Is there a solution? -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net