Ok, now I will try asking the right question (previous try wasn&#39;t actually an example of the problem I&#39;m having)<br><br>Here&#39;s the code:<br><br><span style="font-family: courier new,monospace;">data Test = Test</span><br style="font-family: courier new,monospace;">


<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">data Test2 = Test2</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">class MyClass a where</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">    getChild :: MyClass b =&gt; a -&gt; b</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">instance MyClass Test where</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">    getChild a = Test2</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">instance MyClass Test2 where</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">    getChild a = Test</span><br><br>On HUGS I get:<br><br><span style="font-family: courier new,monospace;">Error occurred</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">ERROR line 9 - Inferred type is not general enough</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">*** Expression    : getChild</span><br style="font-family: courier new,monospace;">


<span style="font-family: courier new,monospace;">*** Expected type : (MyClass Test, MyClass a) =&gt; Test -&gt; a</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">*** Inferred type : (MyClass Test, MyClass Test2) =&gt; Test -&gt; Test2</span><br>


<br>So, what&#39;s the problem with always returning a particular instance of MyClass? I just want to constrain it to be an instance of MyClass, nothing more.<br><br>thanks,<br><br>David<br><br><br>2009/12/18 David Gordon &lt;<a href="mailto:david.robert.gordon@googlemail.com" target="_blank">david.robert.gordon@googlemail.com</a>&gt;<br>

&gt;<br>&gt; Hi Folks,<br>&gt; Total newbie here. I don&#39;t know if I am having a syntactic problem or a conceptual problem.<br>
&gt; This code:<br>&gt; data Test = Test<br>&gt; data Test2 = Test2<br>&gt; class MyClass a where<br>&gt;     getChild :: (MyClass b) =&gt; a -&gt; b<br>&gt; instance MyClass Test where<br>&gt;     getChild = Test2<br>&gt; instance MyClass Test2 where<br>


&gt;     getChild = Test<br>&gt; results in:<br>&gt; [1 of 1] Compiling Main             ( test.hs, interpreted )<br>&gt; test.hs:10:15:<br>&gt;     Couldn&#39;t match expected type `Test -&gt; b&#39;<br>&gt;            against inferred type `Test2&#39;<br>


&gt;     In the expression: Test2<br>&gt;     In the definition of `getChild&#39;: getChild = Test2<br>&gt;     In the instance declaration for `MyClass Test&#39;<br>&gt; test.hs:13:15:<br>&gt;     Couldn&#39;t match expected type `Test2 -&gt; b&#39;<br>


&gt;            against inferred type `Test&#39;<br>&gt;     In the expression: Test<br>&gt;     In the definition of `getChild&#39;: getChild = Test<br>&gt;     In the instance declaration for `MyClass Test2&#39;<br>&gt; Failed, modules loaded: none.<br>


&gt; Is this a reasonable thing to try and do in Haskell? If not, I have a lot more questions... ;)<br>&gt; many thanks,<br>&gt; David<br>&gt;<br><br>