recursive modules in Haskell

Iavor S. Diatchki diatchki@cse.ogi.edu
Wed, 19 Mar 2003 09:23:39 -0800


hi,

Alastair Reid wrote:
> Simon Peyton-Jones <simonpj@microsoft.com> writes:
> 
>>Nothing deep.  GHC is just a fairly big thing and one of its
>>assumptions is that it is compiling one module at a time.  There'd
>>be quite a bit of chuffing around to remove this assumption.
>>Nothing fundamental, but real work.
that's reasonable.  incidently i think (but am not 100% on this) that 
one can still do most of the work one module at a time.  it seems that 
only type checking needs to happen one strongly connected module 
component at a time.


> The other big problem is that, in the worst case, you need to
> typecheck the entire program (however many modules that may be) at
> once.  If your program happens to be GHC, Lolita or one of the other
> big Haskell programs, this might be prohibitively expensive.
you only need to type check one strongly connected component of modules 
at a time.  of course it could be the case that your whole program is 
one big strongly connected component, but that is not that easy to 
achieve.  along those lines - it is of course possible to write a 
program where all *functions* are mutually recursive, but we don't 
usually do that.

in fact it is very likely that most nontrivial programs have at least 
two SCCs as it is not usual to import the Main module in other moudles. 
and of course, most of the time modules don't need to be recusrive and 
then each module is in a SCC of its own.  i very much doubt that GHC has 
more than a few modules per SCC, but perhaps one of the simons can give 
us a more definitive answer on that.

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               |
==================================================