[Haskell-cafe] 2 modules in one file
gale at sefer.org
Wed Aug 27 11:11:37 EDT 2008
>> Is it allowed to write two
>> different modules in a single
That would be a really nice feature, especially
since modules are Haskell's only encapsulation
tool. You want it to be a lightweight as possible.
Malcolm Wallace wrote:
> Some compilers permit it (e.g. Freja), most do not (e.g. ghc). The
> Language Report makes no specification for the mapping between module
> sources and the files that contain them.
The Hierarchical Module Namespace Extension addendum to the
Haskell 98 Report
recommends, but does not require, a Java-like mapping between
hierarchical module names and and the filesystem.
In particular, compilers complying with that recommendation
require there to be only one module per file. Most compilers
In my opinion, that is a bad policy. It is fine as a simple default for
small projects, even though it's a bit ugly and ad hoc. (For example -
what does this mean on platforms whose filesystem is not
But for large and complex projects, this policy really complicates
the task of the project manager who wants to be able to
present various views of the source to teams working on
different subprojects, while juggling the version control
in an intelligent way. Directory tree structure is sometimes
the perfect tool for that, but Haskell has stolen it away.
It would be nice if compilers would offer, as an optional alternative,
a system of locating modules based on manifest files.
That would then allow multiple modules per source file.
More information about the Haskell-Cafe