overzealous defaulting?

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Tue Aug 24 06:55:37 EDT 2004


John Meacham <john at repetae.net> writes:

> module A where
> import B
> a = 32 + b
> default (Integer)
> 
> module B where
> import A
> b = 32 + a
> default (Int)
> 
> 
> so, what types do 'a' and 'b' get?
> ghc sort of sidesteps the issues with the hi-boot files, so they will
> get whatever is declared in those, but what is the correct thing that
> should happen in a fully recursive module supporting haskell compiler?

My guess is that technically the program is ambiguous: both a and b
could be either Int or Integer, and in the absence of .hi-boot file
there is not enough information available to the compiler to choose
one over the other.  Ideally, the ambiguity should be reported as an
error to be fixed by the user.

It isn't so terribly different from the (show . read) ambiguity,
in that it can easily be resolved by adding a type signature.

Regards,
    Malcolm


More information about the Glasgow-haskell-users mailing list