I had it pretty well worked out for single parameter type classes, but I couldn't see any nice extension to multiple parameters.<br><br><div class="gmail_quote">On Dec 11, 2007 5:30 PM, Simon Peyton-Jones <<a href="mailto:simonpj@microsoft.com">
simonpj@microsoft.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d">| If it really would work ok we should get it fully specified and
<br>| implemented so we can fix the most obvious class hierarchy problems in a<br>| nice backwards compatible way. Things are only supposed to be candidates<br>| for Haskell' if they're already implemented.<br><br>
</div>Getting it fully specified is the first thing.<br><br>Personally I am not keen about<br><br>a) coupling it to explicit import/export (independently-desirable though such a change might be)<br><br>b) having instance declarations silently spring into existence
<br><br><br>Concerning (b) here's a suggestion. As now, require that every instance requires an instance declaration. So, in the main example of <a href="http://haskell.org/haskellwiki/Class_system_extension_proposal" target="_blank">
http://haskell.org/haskellwiki/Class_system_extension_proposal</a>, for a new data type T you'd write<br> instance Monad T where<br> return = ...<br> (>>=) = ...<br><br> instance Functor T
<br> instance Applicative T<br><br>The instance declaration for (Functor T) works just as usual (no explicit method, so use the default method) except for one thing: how the default method is found. The change is this:
<br> Given "instance C T where ...", for any method 'm' not<br> defined by "...":<br> for every class D of which C is a superclass<br> where there is an instance for (D T)<br>
see if the instance gives a binding for 'm'<br> If this search finds exactly one binding, use it,<br> otherwise behave as now<br><br>This formulation reduces the problem to a more manageable one: a search for the default method.
<br><br>I'm not sure what is supposed to happen if the instance is for something more complicated (T a, say, or multi-parameter type class) but I bet you could work it out.<br><br>All these instances would need to be in the same module:
<br> - you can't define Functor T without Monad T, because you<br> want to pick up the monad-specific default method<br> - you can't define Monad T without Functor T, because<br> the latter is a superclass of the former
<br><br>It still sounds a bit complicated.<br><font color="#888888"><br>Simon<br></font><div><div></div><div class="Wj3C7c">_______________________________________________<br>Glasgow-haskell-users mailing list<br><a href="mailto:Glasgow-haskell-users@haskell.org">
Glasgow-haskell-users@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br></div></div></blockquote>
</div><br>