<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p></p>
<div>Hello all,</div>
<div><br>
</div>
<div>I am a rank beginner to functional languages. Working through Lipovaca's book, up to Chapter 3.</div>
<div><br>
</div>
<div>Ok, setup this function in editor and compiled:</div>
<div><br>
</div>
<div>length' :: (Num b) => [a] -> b </div>
<div>length' [] = 0 </div>
<div>length' (_:xs) = 1 + length' xs</div>
<div><br>
</div>
<div><br>
</div>
<div>skippy@skippy:~$ ghci</div>
<div>GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help</div>
<div>Prelude> :l baby</div>
<div>[1 of 1] Compiling Main ( baby.hs, interpreted )</div>
<div>Ok, modules loaded: Main.</div>
<div>*Main> length' [1,2,3]</div>
<div>3</div>
<div>*Main> 1:2:3:[]</div>
<div>[1,2,3]</div>
<div>*Main> length' 1:2:3:[]</div>
<div><br>
</div>
<div><interactive>:5:9:</div>
<div> Could not deduce (Num [a0]) arising from the literal ‘1’</div>
<div> from the context (Num a)</div>
<div> bound by the inferred type of it :: Num a => [a]</div>
<div> at <interactive>:5:1-16</div>
<div> The type variable ‘a0’ is ambiguous</div>
<div> In the first argument of ‘length'’, namely ‘1’</div>
<div> In the first argument of ‘(:)’, namely ‘length' 1’</div>
<div> In the expression: length' 1 : 2 : 3 : []</div>
<div>*Main> </div>
<div><br>
</div>
<div><br>
</div>
<div>Obviously, there is something I don't understand about the apparent non-equivalence of the lists [1,2,3] and 1:2:3:[]I am guessing that the solution is contained in that error message but I can't quite decipher it. </div>
<div><br>
</div>
<div>Thanks for any help.</div>
<div><br>
</div>
<br>
<p></p>
</div>
</body>
</html>