title: Haskell still can't deduce type equality
body: <p>This question is a follow up on the question <a href="https://stackoverflow.com/questions/14734702/haskell-cant-deduce-type-equality">Haskell can't deduce type equality</a>.
  I have tried implementing a basic polynomial approximator using the Trainable type described in my previous question with the following code:</p>
  
  <pre><code>module MachineLearning.Polynomial
         (polynomial,
          polynomialTrf
         ) where
  import MachineLearning.Training
  import MachineLearning.Utils
  
  polynomialTrf :: Floating n =&gt; [n] -&gt; n -&gt; n
  polynomialTrf coeff var = helper 0 coeff var 0 where
    helper _ [] var acc = acc
    helper 0 (c:cs) var acc = helper 1 cs var c 
    helper deg (c:cs) var acc = helper (deg+1) cs var (acc+(c*(var^deg)))
  
  polynomialCost :: Floating n =&gt; n -&gt; n -&gt; [n] -&gt; n
  polynomialCost var target coeff = sqcost (polynomialTrf coeff var) target
  
  polynomialSV :: (Floating n) =&gt; Trainable n n
  polynomialSV = Trainable polynomialTrf polynomialCost
  </code></pre>
  
  <p>Here <code>sqcost</code> is just <code>sqcost a b = (a-b) ^ 2</code>. I get the following error message from the compiler:</p>
  
  <pre><code>src/MachineLearning/Polynomial.hs:18:26:
      Could not deduce (n1 ~ n)
      from the context (Floating n)
        bound by the type signature for
                   polynomialSV :: Floating n =&gt; Trainable n n
        at src/MachineLearning/Polynomial.hs:18:1-53
      or from (Floating n1)
        bound by a type expected by the context:
                   Floating n1 =&gt; [n1] -&gt; n -&gt; n
        at src/MachineLearning/Polynomial.hs:18:16-53
        `n1' is a rigid type variable bound by
             a type expected by the context: Floating n1 =&gt; [n1] -&gt; n -&gt; n
             at src/MachineLearning/Polynomial.hs:18:16
        `n' is a rigid type variable bound by
            the type signature for polynomialSV :: Floating n =&gt; Trainable n n
            at src/MachineLearning/Polynomial.hs:18:1
      Expected type: [n] -&gt; n1 -&gt; n1
        Actual type: [n] -&gt; n -&gt; n
      In the first argument of `Trainable', namely `polynomialTrf'
      In the expression: Trainable polynomialTrf polynomialCost
  
  src/MachineLearning/Polynomial.hs:18:40:
      Could not deduce (n ~ n1)
      from the context (Floating n)
        bound by the type signature for
                   polynomialSV :: Floating n =&gt; Trainable n n
        at src/MachineLearning/Polynomial.hs:18:1-53
      or from (Floating n1)
        bound by a type expected by the context:
                   Floating n1 =&gt; n -&gt; n -&gt; [n1] -&gt; n1
        at src/MachineLearning/Polynomial.hs:18:16-53
        `n' is a rigid type variable bound by
            the type signature for polynomialSV :: Floating n =&gt; Trainable n n
            at src/MachineLearning/Polynomial.hs:18:1
        `n1' is a rigid type variable bound by
             a type expected by the context: Floating n1 =&gt; n -&gt; n -&gt; [n1] -&gt; n1
             at src/MachineLearning/Polynomial.hs:18:16
      Expected type: n -&gt; n -&gt; [n1] -&gt; n1
        Actual type: n -&gt; n -&gt; [n] -&gt; n
      In the second argument of `Trainable', namely `polynomialCost'
      In the expression: Trainable polynomialTrf polynomialCost
  </code></pre>
  
  <p>My question is where is the problem coming from? How can I solve it? For me it feels clear the those two types are equal, so there is the possibility that I misunderstand something in the type system.</p>