<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
I would like to know why I'm getting a particular compile time error
message.<br>
<br>
In this program, I am specifying a function type on <i>combs'</i> in
the where clause:<br>
<br>
--------<br>
<tt>module Main where<br>
<br>
import List (delete)<br>
<br>
combs :: Eq a =&gt; [a] -&gt; Int -&gt; [[a]]<br>
combs l 1 = map (\x -&gt; [x]) l<br>
combs l n = foldl combs' [] l<br>
&nbsp;&nbsp;&nbsp; where combs' :: Eq a =&gt; [[a]] -&gt; a -&gt; [[a]]<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; combs' acc x = let sl = delete x l in (map (\i -&gt; x:i) $
combs sl (n-1)) ++ acc<br>
<br>
main = do<br>
&nbsp; print $ combs ["a","b","c","d"] 3</tt><br>
--------<br>
<br>
I get this error message from GHC 6.8.3:<br>
<br>
<tt>cafe1.hs:9:43:<br>
&nbsp;&nbsp;&nbsp; Couldn't match expected type `a1' against inferred type `a'<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; `a1' is a rigid type variable bound by<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the type signature for `combs'' at cafe1.hs:8:23<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; `a' is a rigid type variable bound by<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the type signature for `combs' at cafe1.hs:5:12<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Expected type: [a1]<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Inferred type: [a]<br>
&nbsp;&nbsp;&nbsp; In the second argument of `delete', namely `l'<br>
&nbsp;&nbsp;&nbsp; In the expression: delete x l<br>
<br>
</tt>I don't understand why I'm seeing this.&nbsp; The type <i>a</i> is the
same type in <i>combs</i> and <i>combs'</i>.&nbsp; I realize I can remove
the type specification from <i>combs'</i>, and the code will compile.&nbsp;
However, I'd like to get a better understanding of why GHC objects to
this.<br>
<br>
Thank you,<br>
Rob.<br>
<br>
</body>
</html>