title: Haskell - Cannot infer instance
body: <p>I have written the following predicate (Lines 94-99)</p>
  
  <pre><code>diffFreqMatrix :: Fractional a =&gt; [[Rating a]] -&gt; [a]
  diffFreqMatrix (x:xs) =  diffFreqMatrixH (x:xs) (matrixPairs (length x))
  diffFreqMatrixH _ [] = []
  diffFreqMatrixH x ((a,b):ys) = [(diffFreqMatrixH2 x a b 0 0)] ++ diffFreqMatrixH x ys
  diffFreqMatrixH2 [] _ _ x y = x / y
  diffFreqMatrixH2 (x:xs) a b summ num = if (((x!!a) /= NoRating) &amp;&amp; ((x!!b) /= NoRating)) then  diffFreqMatrixH2 xs a b (summ + ((x!!a) - (x!!b))) (num + 1) else diffFreqMatrixH2 xs a b summ num
  </code></pre>
  
  <p>supposedly it calculates an average I want but i'm getting this error</p>
  
  <pre><code>ERROR file:.\project.hs:98 - Cannot infer instance
  *** Instance   : Fractional (Rating a)
  *** Expression : diffFreqMatrixH2
  </code></pre>
  
  <p>Helpers im using in case u want to take a look</p>
  
  <pre><code>matrixPairs :: Num a =&gt; a -&gt; [(a,a)]
  matrixPairs 0 = []
  matrixPairs c = matrixPairsH 0 0 (c-1)
  matrixPairsH a b c = [(a,b)] ++ if ((b == c) &amp;&amp; (a == c)) then [] else if (b == c) then (if (a==c) then [] else matrixPairsH (a+1) 0 c ) else matrixPairsH a (b+1) c
  
  
  differeneRatings :: Fractional a =&gt; Rating a -&gt; Rating a -&gt; a
  differeneRatings NoRating (R a) = 0
  differeneRatings (R a) NoRating = 0
  differeneRatings NoRating NoRating = 0
  differeneRatings  (R a) (R b) = a - b
  </code></pre>