This seems very, very wrong.&nbsp; The missing instance(s) might be left out because of some good reason (e.g. if you have implemented sets with list and not provided Ord).<br><br><div class="gmail_quote">On Nov 21, 2007 12:59 AM, Duncan Coutts &lt;
<a href="mailto:duncan.coutts@worc.ox.ac.uk">duncan.coutts@worc.ox.ac.uk</a>&gt; 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">
On Tue, 2007-11-20 at 19:18 -0500, Alex Jacobson wrote:<br>&gt; When you want automated deriving of show/read etc., you need all the<br>&gt; components of your type also to be instances of show/read but you won&#39;t<br>&gt; want to *require* them to be automatically generated verions.
<br>&gt;<br>&gt; Standalone deriving does the wrong thing here. &nbsp;Standalone deriving<br>&gt; should not cause an overlapping instance error if someone derives an<br>&gt; instance manually. &nbsp;Instead, the manually derived instance should be
<br>&gt; treated as more specific and win out.<br>&gt;<br>&gt; The other part of this problem is that you can&#39;t do automatic recursive<br>&gt; deriving and this results in a ridiculous amount of boilerplate. &nbsp;I know<br>
&gt; some people have a theory that they want to avoid accidentally creating<br>&gt; instances for things that shouldn&#39;t have them, but the solution to that<br>&gt; is probably to add some declaration for types that prohibits automatic
<br>&gt; deriving for those types. &nbsp;The 99% case is that automatic deriving is ok.<br>&gt;<br>&gt; Proposed syntax:<br>&gt;<br>&gt; &nbsp; &nbsp;derive instance Show T recursively<br>&gt; &nbsp; &nbsp;data T = T no-deriving (Ord,Eq)<br><br></div>
I would expect that if the data constructor for T is not exported then<br>standalone deriving should not work. However this appears not to be the<br>case which breaks module abstraction.<br><br>Foo.hs:<br>module Foo ( T, t ) where
<br>data T = T<br>t = T<br><br>Bar.hs:<br>import Foo<br>deriving instance Eq T<br><br>$ ghci Bar.hs -XStandaloneDeriving<br>[1 of 2] Compiling Bar &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;( Bar.hs, interpreted )<br>[2 of 2] Compiling Main &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ( 
Baz.hs, interpreted )<br>Ok, modules loaded: Bar, Main.<br>*Main&gt; t == t<br>True<br><br>You could write that Eq instance by hand since they do not have access<br>to the T constructor, then StandaloneDeriving should not be able to so
<br>either. I think it&#39;s a design flaw in standalone deriving.<br><br>Does anyone else agree? Should we file a bug report?<br><br>Duncan<br>_______________________________________________<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></blockquote></div><br>