[Haskell-cafe] Renaming constructors for readability
Dougal Stanton
ithika at gmail.com
Tue Nov 13 17:29:35 EST 2007
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 at dougalstanton.net // http://www.dougalstanton.net
More information about the Haskell-Cafe
mailing list