defaults

Simon Marlow simonmar at microsoft.com
Tue Jan 16 08:54:39 EST 2007


haskell-prime-bounces at haskell.org wrote:
> Simon Marlow <simonmar at microsoft.com> wrote:
>
>> Is your proposal supposed to be backwards compatible with Haskell 98
>> for programs that don't have default declarations?
>
> Yes, it is supposed to be backwards compatible.
>
>> If so, then I offer a counter example:
>>     toRational pi
>> will default pi to Double in Haskell 98, but will be an error under
>> your proposal, because the two constraints (Real and Floating)
>> disagree on the default.
>
> Well spotted.  So there are some expressions that are
> defaulted in H'98
> but would not pass type-checking with my proposal.
>
>   (1) Are examples like this common?  I am guessing not.  You mention
>       Enum/Fractional combinations, but arguably Float and
> Double do not
>       belong in Enum anyway.
>
>   (2) The new rule is conservative - it does not silently change the
>       semantics, but it does reject more programs.  Such programs are
>       easily fixed by adding a type signature.
>
> If these two points are valid, then I think the slight loss
> of backward compatibility is acceptable?

I don't know whether this is an acceptable loss of backwards compatibility, perhaps it is.  But I spotted the problem because it looks (to me) like the current Haskell 98 rule is designed specifically to handle cases like this.

Would you mind updating the wiki page?  I don't think it's too clear on the need for constraint simplification before applying your defaulting rules either.

Cheers,
        Simon


More information about the Haskell-prime mailing list