On 11/1/06, <b class="gmail_sendername">Malcolm Wallace</b> <<a href="mailto:Malcolm.Wallace@cs.york.ac.uk">Malcolm.Wallace@cs.york.ac.uk</a>> wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
"Brian Smith" <<a href="mailto:brianlsmith@gmail.com">brianlsmith@gmail.com</a>> writes:<br><br>> > <a href="http://haskell.org/haskellwiki/GHC/StandAloneDeriving">http://haskell.org/haskellwiki/GHC/StandAloneDeriving
</a><br>><br>> Basically, the syntax<br>> for instances and derived instances would be identical, but derived<br>> instances would just omit the "where" clause, while non-derived instances<br>> would need the "where" clause.
<br><br>This is a really _bad_ idea for readability. In a year's time, when<br>this discussion is forgotten, who would be able to tell at a glance the<br>deep and real semantic difference between the following two instance
<br>decls?<br><br> instance Num (Bar z) where<br>and<br> instance Num (Bar z)<br><br>The former declares that _no_ methods are defined (except for defaults),<br>and the latter, with your proposal, that _all_ methods are defined. The
<br>real killer is that both of these decls are already valid in Haskell'98,<br>but they mean the _same_ thing (the former, if you were wondering).<br><br>This is a sure recipe for introducing new and subtle bugs into existing
<br>bug-free programs.</blockquote><div><br>Malcolm, thank you for pointing that out. To be honest, I had not read this sentence of the report (section 4.3.2 of <a href="http://haskell.org/onlinereport/decls.html">http://haskell.org/onlinereport/decls.html
</a>):<br><br>"If no binding is given for some class method then the
corresponding default class method
in the <tt>class</tt> declaration is used (if
present); if such a default does
not exist then the class method of this instance
is bound to <tt>undefined</tt>
and no compile-time error results."<br><br>Personally, I think that the part after the semicolon is the part that leads to subtle bugs, not Brian H's proposal. Why is this not considered a compile-time error? There was a previous mention of it on the list [1] but there was no explanation given. I think it would be better if the report stated this instead:
<br><br>"If no binding is given for some class method then the
corresponding default class method
in the <tt>class</tt> declaration is used (if
present); if such a default does
not exist then a compile-time error results."<br><br>[1] <a href="http://www.haskell.org/pipermail/haskell/2003-May/011899.html">http://www.haskell.org/pipermail/haskell/2003-May/011899.html</a><br><br>- Brian<br></div>
</div>