[Haskell] [Proposal] Data type declarations are implicitly moduled
evilantleredthing at yahoo.ca
Wed Feb 7 04:12:38 EST 2007
Hi, I'm not sure if something like this has been
proposed already but I thought I'd bring it up.
The idea is to allow multiple data declarations to
share constructors by having them be implicitly
declared inside a module. So, for example,
data Dir = Left | Right deriving Show
data Arrived = Arrived | Left deriving Show
main = do
will work just fine.
Nothing is required by this proposal that isn't
already done (with the exception of adding syntactic
support to the compiler of course). The above can be
accomplished today by simply putting Dir and Arrived
into their own modules and then importing them.
There is a question of do we provide some means of
abbreviating these implicit module names. If this is
considered desirable, one way of accomplishing this is
to add an as-clause to the data declaration syntax,
which will function similary to where-clauses and
deriving syntax. Ex,
data Dir = Left | Right
This will effectively be the same as declaring Dir in
its own module and then importing it using as syntax.
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
More information about the Haskell