Compiling mutually recursive modules involving instances

José Romildo Malaquias [email protected]
Thu, 26 Oct 2000 08:24:45 -0200


On Thu, Oct 26, 2000 at 01:50:30AM -0700, Simon Peyton-Jones wrote:
> The best thing to do is never to put an instance
> declaration in an hi-boot file.   I don't think you ever really
> need to.   In contrast, mutual recursion of type declarations
> is often unavoidable.

I believe I can redesign the module structures in my project
so that the instances will not need to be put in a hi-boot
file. The body of some methods in these instances uses some
names (type names and function names, possibly with infix
status) defined in a module where the corresponding class
__and__ a relevant set of its instances should be visible.
Logicaly the instances do not belong to the same module as
their class and the user of my library should be able to
add new modules (with new instances of the class) to the
system without the need to modify the source of the module
containing the class definition.

Particularly I am having a great difficult in find a good
module design for my library, which is should be able to be
extended by its user. I am missing some important features
for that, like extensible data types and functions support
in the language. By now I am basing it on the extensible
union types shown in "Monad Transformers and Modular
Interpreters", by Mark Jones and others. When I progress
in that I would make some comments.

> The manual should really say this

The manual also says a new, better, higher level way for
dealing with mutually recursive modules is in the works.
Is there any chance it will be ready for the next release?

> | From: José Romildo Malaquias [mailto:[email protected]]
> | 
> | I am having difficulties in  compiling mutually recursive
> | modules involving classes and instances in GHC 4.08.1.
> | Basicaly I am not finding how to write a .hi-boot where
> | I want to put classes and instances.
> | 
> | Consider a program with 3 modules: M1, M2 and Main. The
> | sources are attached to the message. What should go
> | into M2.hi-boot? Would anyone write M2.hi-boot for me
> | so that I can learn it.

Regards,

Romildo
-- 
Prof. José Romildo Malaquias <[email protected]>
Departamento de Computação
Universidade Federal de Ouro Preto
Brasil