Records in Haskell

Isaac Dupree ml at isaac.cedarswampstudios.org
Wed Jan 18 18:10:36 CET 2012


On 01/17/2012 03:59 AM, Yitzchak Gale wrote:
> and whenever E imports M qualified without an
> import list, as in:
>
> import qualified M as Q
>
> then the following implied imports would be
> added to E:
>
> import qualified M.T as Q.T
> import qualified M.S as Q.S

Rather, those should be added whether or not M is imported qualified. 
For example, this is valid Haskell98:

import Numeric as Flumeric
main = print (Flumeric.showFloat 3.2 "")

I like the spirit of this proposal.  Does it have the ability yet to 
make packages with large APIs easier to use?

e.g.
http://code.haskell.org/gtk2hs/gtk/demo/graphic/Drawing.hs

The long lists of import statements can get much worse.
The existing remedies (e.g. re-export all the library's identifiers from 
one module) lose some of the benefits (to readability of code that uses 
the library) of having a module system.

What if export lists like
   module M (module M.X) where import M.X
perhaps...
   module M (module [qualified] M.X [as X]) where import M.X
could trigger similar behavior in importers as nested modules could.
What if in
   module M(....)
   import .X
the "import .X" was sugar for "import M.X as X" (or "as" something else 
if you wrote an "as" clause explicitly).


I think module system improvements like you propose could be a good idea 
(in general, rather than as a particularly good way to do records, and 
it shouldn't hold up the type-based records proposal ^_^).

~Isaac



More information about the Glasgow-haskell-users mailing list