|
Subject: [Proposal] Data type declarations are implicitly moduled Newsgroups: gmane.comp.lang.haskell.general Date: 2007-02-07 09:12:38 GMT (2 years, 21 weeks, 2 days, 2 hours and 9 minutes ago) 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 print Dir.Left print Arrived.Left 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 as D deriving Show 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 http://mail.yahoo.com |
|
|