Joe English:

> I was thinking of the example from the Haskell Report:
> 
>     let { len = genericLength xs } in (len, len)
> 
> which, without the MR, computes 'len' twice.
> Operationally I expect that in "let x = f y in ... x ... x",
> 'f y' is only evaluated once, no matter what type it is.

If the types are distinct, then a recomputation _is_ necessary.
The MR does nothing to solve this, it just fails to typecheck the
program fragment.

To be candid, though, I'm not much concerned with what's done with
let-bound definitions;  what really vexes me are top level instances.


> Also John Hughes' warning that:
> 
> > * When converting Haskell 1.x to Haskell 2, many := would need to be 
inserted.
> >   Failure to do so could make programs much less efficient.
> 
> That's why I'd prefer to keep call-by-need the default
> and use new syntax for call-by-name/overloading.

This is a case of backwards compatibility with a bad feature, IMO.
In any even, if the old programs passed the 1.x MR, then a Haskell
2 compiler ought to be able to produce recomputation-free code at
least as a special case.


> > This way bizarre type errors remain the default, and compilers
> > will signal an error _somewhere else_ in the program when you
> > bump into the MR, if my experience is anything to go by.

> Could you provide an example?  Every instance of the MR
> I've been able to come up with winds up giving an error message
> right at the definition that would need to have a ~ or an
> explicit type signature added.

In every example I've come up with (and I come up with them a lot
more often than I'd care to), if you have a MR'd definition that's
applied at two different types, you simply get an error at one
of the two instances, which doesn't mention anything about the
definition, nor about the use of the MR.  This is technically
correct, it just doesn't take into account the 'difference of opinion'
that's implicitly occurring between me and the type-checker about
what the type of that function actually _is_...

If that's too vague, I'll mail-bomb you with as many examples as
you wish, of whatever length and fiendishness of debugging you wish. ;-)

Cheers,
Alex.


Reply via email to