[Haskell-beginners] Comfortable handling of module hierarchies
kdamodar2000 at gmail.com
Sun Sep 16 12:37:41 CEST 2012
Do you know any document pointing out the rationale behind this decision
about modules taken by the Haskell designers?
On Sat, Sep 15, 2012 at 9:30 PM, Karl Voelker <ktvoelker at gmail.com> wrote:
> On Fri, Sep 14, 2012 at 6:23 PM, Christopher Howard
> <christopher.howard at frigidcode.com> wrote:
> > import qualified Plant as P
> > P.Fruit.Raspberry.jam
> Short answer: P.Fruit.Raspberry.jam would work if you said:
> import qualified Plant.Fruit.Raspberry as P.Fruit.Raspberry
> Long answer:
> You can't have exactly what you want because the Haskell module
> namespace isn't exactly heirarchical. Here's an excerpt from the
> Haskell 98 report :
> "The name-space for modules themselves is flat, with each module being
> associated with a unique module name (which are Haskell identifiers
> beginning with a capital letter; i.e. modid)."
> Notice that this doesn't allow for dots in module names. A
> commonly-provided language extension allowed dots in module names, and
> compilers took these dots as a signal to look for a module's source at
> a particular place in the directory tree, but the semantics of the
> language didn't have a heirarchy of modules.
> Things haven't changed much in Haskell 2010, other than the existing
> use of dots being formalized :
> "Module names can be thought of as being arranged in a hierarchy in
> which appending a new component creates a child of the original module
> name. For example, the module Control.Monad.ST is a child of the
> Control.Monad sub-hierarchy. This is purely a convention, however, and
> not part of the language definition; in this report a modid is treated
> as a single identifier occupying a flat namespace."
> In your code snippet, P.Fruit.Raspberry doesn't work because although
> P refers to the same module as Plant, there isn't anything "inside" P
> (or Plant) called Fruit.Raspberry.
>  http://www.haskell.org/onlinereport/modules.html
> Beginners mailing list
> Beginners at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners