[Haskell-cafe] mutually recursive modules

Henning Thielemann iakd0 at clusterf.urz.uni-halle.de
Fri Sep 24 08:17:16 EDT 2004

On Fri, 24 Sep 2004, Malcolm Wallace wrote:

> Hugs doesn't support mutually-recursive modules at all.  Ghc and nhc98
> support them only if you hand-write a .hi-boot file to bootstrap the
> compilation.  I would guess that better support from the mainstream
> implementations is unlikely, because it would be a large amount of
> effort for a situation which occurs only very rarely, and for which
> there is a relatively easy workaround.

Namely? The only workaround I know of is putting all type declarations and
functions that depend on each other into one module, import them in the
modules they logically belong to and document that the objects should be
imported from the redirecting modules rather than from the modules they
are defined in.
 I know of two projects where different tasks had to be merged into one
module because of the lack of mutually recursive imports, namely
functionalMetaPost and Haskore.
 It's interesting how other languages solve this problem. In Modula-3 it
is solved by explicit module interfaces and partial revelation. One can
define type T in module A and type T in module B very abstractly as
pointers to something and the complete data structures (which may contain
references to either interface) are usually revealed in the
implementations of the modules. I'm curious how Oberon solves it, because
it doesn't need explicit interfaces but derives them from the
implementation files. Probably one can say that Oberon extracts something
like a .hiboot file from every module file automatically. Why can't GHC
and Hugs go this way?

More information about the Haskell-Cafe mailing list