<div dir="ltr">Maybe I don&#39;t fully understand what you are trying to achieve, but I don&#39;t think what you are trying to do makes sense. <span style="font-family:arial,sans-serif;font-size:13px">infixLevel and </span><span style="font-family:arial,sans-serif;font-size:13px">symbolToConstructor </span><span style="font-family:arial,sans-serif;font-size:13px">will have different implementations for each instance of Foo, and </span><span style="font-family:arial,sans-serif;font-size:13px">the compiler cannot possibly know which implementations you mean. If the implementation of </span><span style="font-family:arial,sans-serif;font-size:13px">symbolToInfixLevel is independent of the implementations of </span><span style="font-family:arial,sans-serif;font-size:13px">infixLevel and </span><span style="font-family:arial,sans-serif;font-size:13px">symbolToConstructor then it shouldn&#39;t need them in its definition.</span><div>

<span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Peter</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br>

</span></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 21 August 2013 17:39, TP <span dir="ltr">&lt;<a href="mailto:paratribulations@free.fr" target="_blank">paratribulations@free.fr</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have a simple test case containing a typeclass Foo with one type variable<br>
a. The goal is to write once and for all a function symbolToInfixLevel<br>
function that combines two other functions defined in the typeclass:<br>
<br>
-----------------------<br>
class Foo a where<br>
<br>
    symbolToConstructor :: String -&gt; ( a -&gt; a -&gt; a )<br>
    infixLevel :: a -&gt; Int<br>
<br>
    symbolToInfixLevel :: String -&gt; Int<br>
    symbolToInfixLevel s = infixLevel $ (symbolToConstructor s) undefined<br>
undefined<br>
-----------------------<br>
<br>
This yields an error because there is no &quot;a&quot; in the type signature for<br>
symbolToInfixLevel:<br>
<br>
$ runghc test_typeclass_without_typevariable.hs<br>
test_typeclass_without_typevariable.hs:1:1:<br>
    The class method `symbolToInfixLevel&#39;<br>
    mentions none of the type variables of the class Foo a<br>
    When checking the class method: symbolToInfixLevel :: String -&gt; Int<br>
    In the class declaration for `Foo&#39;<br>
<br>
Now, if I define symbolToInfixLevel out of the typeclass:<br>
<br>
-----------------------<br>
class Foo a where<br>
<br>
    symbolToConstructor :: String -&gt; ( a -&gt; a -&gt; a )<br>
    infixLevel :: a -&gt; Int<br>
<br>
symbolToInfixLevel :: String -&gt; Int<br>
symbolToInfixLevel s = infixLevel $ (symbolToConstructor s) undefined<br>
undefined<br>
-----------------------<br>
<br>
Now, I obtain:<br>
<br>
$ runghc test_typeclass_without_typevariable.hs<br>
test_typeclass_without_typevariable.hs:7:24:<br>
    No instance for (Foo a0) arising from a use of `infixLevel&#39;<br>
    In the expression: infixLevel<br>
    In the expression:<br>
      infixLevel $ (symbolToConstructor s) undefined undefined<br>
    In an equation for `symbolToInfixLevel&#39;:<br>
        symbolToInfixLevel s<br>
          = infixLevel $ (symbolToConstructor s) undefined undefined<br>
<br>
How to get rid from this situation?<br>
<br>
Thanks in advance,<br>
<br>
TP<br>
<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br></div>