
John Hughes wrote:
On Sun, 30 Jun 2002, Jon Cast wrote:
Mark Carroll wrote:
On Sat, 29 Jun 2002, Samuel E. Moelius III wrote: (snip)
Here's another not-exactly-what-you-wanted solution. :)
(snip)
Do any of the experimental extensions to Haskell allow a what-he-wanted solution? I couldn't arrange one in H98 without something having an infinitely-recursive type signature.
That's because the problem requires an infinitely-recursive type.
(snip)
It isn't particularly hard to implement this. Haskell typecheckers use unification to match types up; the only difference is that a graph unification algorithm would be needed instead. Such algorithms exist --- the only real difference is you have to remember what you're unifying to avoid falling into a loop when unifying graphs with cycles.
The idea of adding this to Haskell has been proposed several times, but never implemented. And the reason for THAT is that it would make type errors significantly harder to understand.
(snip)
Yes, but the dreaded Monomorphism Restriction was added for the same reason, wasn't it? Haskell allows us to get around the M.R. by using explicit type signatures where required. It seems to me that we could allow recursive types in the same way -- simply require a type signature for toplevel objects with recursive types. Is there a reason why this wouldn't work? Regards, Matt Harden