recursive modules in Haskell

Elke Kasimir elke@espresto.com
Wed, 12 Mar 2003 19:08:15 +0100 (CET)


Hi all!

I've just got one of the rare chances to do a somewhat
bigger piece of software development in Haskell. After having set
up a design (with much use of multi-parameter-classes)
I was very excited.  However, to extent that implementation 
proceeded I had to recognize many unforeseen implementation
dependencies between instance. A standard situation is:

file A.hs:

instance Foo A
  f :: -- implementation requires A and B to be
          an instance of Foo 

file B.hs:
 
instance Foo B
 f :: -- implementation requires A and B to be
          an instance of Foo

The mutual dependencies increase if one uses class constraints to enforce
semantic wellformedness, that is if one writes

given Bar A => class Foo A

whenever this makes sense from the view of the application logic - as I did.

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.  

Elke. 

--  
Elke Kasimir                             EsPresto AG
-----------------------------------------------------------------
- Software Development-                Breite Str. 30-31 
Tel/Fax: +49-30-90 226-750/-760   10178 Berlin/Germany