Yes! Sorry, I forgot a bit:<br>Binary types are automatically made instances of Binarizable/Unbinarizable (that&#39;s my line 16):<br><br>instance (Binary a) =&gt; Binarizable a a where<br>  toBinary = id<br><br>instance (Binary a, Monad m) =&gt; Unbinarizable a a m where<br>
  fromBinary = return<br><br><br>To me, the functional dependency in:<br>class (Binary b) =&gt; Binarizable a b | a -&gt; b<br>meant that for each a, there only one type b that can match.<br><br>That&#39;s what I want: for every Binary type &#39;a&#39;, the matching Binary is also &#39;a&#39;<br>
And for GameObject, the sole matching type is String.<br>In other words, GameObject implies String.<br>I would have undestood the error if GameObject was also an instance of Binary (then the two instances would match), but it&#39;s not the case...<br>
<br>Is my FunDep wrong?<br><br>I done this especially because I didn&#39;t wanted to declare each type one by one instance of Binarizable,<br>Haskell type system normally enables me to automatically define a Binary as an instance of Binarizable.<br>
<br><div class="gmail_quote">2010/4/17 Daniel Fischer <span dir="ltr">&lt;<a href="mailto:daniel.is.fischer@web.de">daniel.is.fischer@web.de</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Am Samstag 17 April 2010 19:14:02 schrieb Limestraël:<br>
&gt; Hello,<br>
<div class="im">&gt;<br>
&gt; Well, here comes the trouble:<br>
&gt; GameStructs.hs:16:9:<br>
&gt;     Functional dependencies conflict between instance declarations:<br>
&gt;       instance (Binary a) =&gt; Binarizable a a<br>
&gt;         -- Defined at MagBots/GameStructs.hs:16:9-37<br>
&gt;       instance Binarizable GameObject String<br>
&gt;         -- Defined at MagBots/GameStructs.hs:38:9-37<br>
&gt;<br>
&gt; GameStructs.hs:19:9:<br>
&gt;     Functional dependencies conflict between instance declarations:<br>
&gt;       instance (Binary a, Monad m) =&gt; Unbinarizable a a m<br>
&gt;         -- Defined at MagBots/GameStructs.hs:19:9-50<br>
&gt;       instance (MonadReader [GameObject] m) =&gt;<br>
&gt;                Unbinarizable GameObject String m<br>
&gt;         -- Defined at MagBots/GameStructs.hs:41:9-73<br>
&gt;<br>
&gt; I don&#39;t see why the functional dependencies conflict, since GameObject<br>
&gt; is not an instance of Binary...<br>
<br>
</div>Somebody somewhere might write such an instance.<br>
But more fundamentally:<br>
<br>
GHC doesn&#39;t look at the constraints for instance selection, so your<br>
instance in line 16 looks like<br>
<br>
instance Binarizable a a where ..., oh, and by the way, a must be an<br>
instance of Binary, otherwise please refuse to compile<br>
<br>
to the compiler. The FunDep then says in each instance (and you&#39;d need at<br>
least OverlappingInstances to declare more) a and b are the same type.<br>
instance Binarizable GameObject String violates that FunDep.<br>
(Analogous for Unbinarizable.)<br>
<br>
I think removing the<br>
<br>
instance Binary a =&gt; ...<br>
<br>
and declaring an instance for the types you need manually is the easiest<br>
solution.<br>
</blockquote></div><br>