[Haskell-cafe] Re: Use of abbreviations in Haskell

Achim Schneider barsoap at web.de
Sat Jan 3 00:46:05 EST 2009

Derek Elkins <derek.a.elkins at gmail.com> wrote:

>     module Attribute where
>         data Attribute = Attribute {
>             key :: QualifiedName,
>             value :: String
>           }

Assuming that the above definition is inside a file called Foo/Bar.hs
and, syntactically, inside a "module Foo where", I think a sane way to
search for the module Foo.Bar.Attribute is

a) Foo.Bar.Attribute.hs
b) Foo/Bar.Attribute.hs
c) Foo/Bar/Attribute.hs
d) Foo.Bar.hs:Attribute
e) Foo/Bar.hs:Attribute

...I guess you see a pattern emerging. It's not entirely unlike public
inner java classes[1]

The reason that the Main module is an exception to the naming/placement
rules is that it's _always_ the root of the search tree, which is only
confusing if you insist on being confused by it[2].

Furthermore, if you 

import Foo.Bar

, you get Attribute.(..) imported by default, _except_ if you also do

import [qualified] Foo.Bar.Attribute [as A]

This fixes both the insanity of having thousands of three-line modules
in thousands of files (which noone wants to manage) and source
directories consisting of more directories than files.

[1]uhmm... can inner classes be public? I think I never tried...
[2]like javac chooses to be.

(c) this sig last receiving data processing entity. Inspect headers
for copyright history. All rights reserved. Copying, hiring, renting,
performance and/or quoting of this signature prohibited.

More information about the Haskell-Cafe mailing list