recursive modules in Haskell
Iavor S. Diatchki
diatchki@cse.ogi.edu
Wed, 12 Mar 2003 11:12:57 -0800
hi,
Elke Kasimir wrote:
> No Problem at all for Haskell, but a problem for certain
> often-used Haskell compilers and interpreters...
>
> Factoring out "the common part" does not work in examples like
> above, so the only way is to collapse everything, and to reduce
> class constraints as much as is possible - something which hurts
> deep inside! That the problems appear step-by-step in the course
> of implementation or even debugging, adds to the pain.
>
> So I have put onto my personal Haskell whish-list
> that certain compilers and interpreters shall either ultimately
> converged against the language they intend to
> support, or else provide some suitable alternative. Thinking in
> the first direction, a precompiler appears before my inner eye which
> is able to collapse mutually dependent modules into one bigger module.
> Even if this led to incorrect line numbers in error messages and the like,
> I would definitely use such a precompiler. A step in the second direction
> was a slight modification of Haskell such that instance declaration and instance
> implementation can be provided in separate modules.
there is no need to use such hacks. it is not dificult to add suport
for mutually recursive modules to an implementation directly.
unfortunatley none of the working haskell implementations support
recursive modules, i guess they are probably not considered important
enough. and the haskell report does not say how they should work (ergh
why?), but if you are interested you can take a look at "A formal
specification for the Haskel 98 module system" a paper we wrote to
remedy this situation.
in the mean time you can work around the problem in GHC, by using the
hi-boot files take a look at the documentation "How to compile mutually
recursive modules".
bye
iavor
--
==================================================
| Iavor S. Diatchki, Ph.D. student |
| Department of Computer Science and Engineering |
| School of OGI at OHSU |
| http://www.cse.ogi.edu/~diatchki |
==================================================