[Haskell] [Proposal] Data type declarations are implicitly moduled

2007-02-07 Thread Chris Moline
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 
___
Haskell mailing list
Haskell@haskell.org
http://www.haskell.org/mailman/listinfo/haskell


Re: [Haskell] Re: Data.Set whishes

2004-02-26 Thread Chris Moline
Alastair Reid <[EMAIL PROTECTED]> wrote:
> Haskell's module system provides a way for a module to merge multiple
> modules into one but provides no way to eliminate any ambiguities this
> may create.  If we want to be able to use names like 'create' instead
> of 'createFont', we need to change the module system.  The obvious fix
> would have some of the flavour of the ML module system where a module
> can export a structured list of names instead of exporting a flat list
> of names.

i'm not familiar with ml's module system so i don't know if my
suggestion is the same or similar, but could a good solution be to allow
modules to be exported as qualified modules? for example

module Graphics (
  module Font qualified,
  module Color qualified,
  module Window qualified,
  ...
) where ...

chris moline
___
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell