separate compilation [was Re: Global variables?]

Andrew J Bromage
Thu, 6 Feb 2003 14:20:13 +1100

G'day all.

On Wed, Feb 05, 2003 at 08:05:56PM -0600, Jon Cast wrote:

> I'm not sure I follow this.  If you change the type of a value exported
> from a given module, that's a public change, no?  And if you don't, why
> should re-compilation be needed?

Consider this:

module A where

import B

{- use B.b -}

module B (b) where

import C

b = C.c

module C (c) where

c :: Int

Changing the type of c requires recompiling module A.

You would expect that changing c's type forces a recompilation of B,
since you changed C's public interface.  However, this also changes B's
public interface even though you did not touch the text of module B.
The reason is that B's public interface is partly based on modules
which it _privately_ imports, even if it does not re-export any symbols
from those modules.

One fix is to require all exported symbols to have explicit type
declarations.  Since this is good practice anyway, I would be in
favour of making it a language requirement in Haskell 2.

Andrew Bromage