<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi,</p>
<p><br>
</p>
<p>> length' 1:2:3:[]</p>
<p>is equivalent to:</p>
<p><br>
</p>
<p>> (length' 1):2:3:[]</p>
<p>hence the error.<br>
</p>
<p><br>
</p>
<p>Try:<br>
</p>
<p>> length' (1:2:3:[])</p>
<p><br>
</p>
<p>Sylvain<br>
</p>
<br>
<div class="moz-cite-prefix">On 12/11/2016 21:20, Lawrence Wickert
wrote:<br>
</div>
<blockquote
cite="mid:CO1PR14MB10168FDC114706981643775EEEBA0@CO1PR14MB1016.namprd14.prod.outlook.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;"
dir="ltr">
<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: <a class="moz-txt-link-freetext" href="http://www.haskell.org/ghc/">http://www.haskell.org/ghc/</a> :? 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>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Beginners mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
</blockquote>
<br>
</body>
</html>