<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Mike Meyer schreef op 12-5-2015 om
8:39:<br>
</div>
<blockquote
cite="mid:CAD=7U2BysWEPxrO_=mck1WGxyS7c9CfxFPtVLWQ0oYkM=3NoYA@mail.gmail.com"
type="cite">
<p dir="ltr">On May 12, 2015 1:32 AM, "Roelof Wobben" <<a
moz-do-not-send="true" href="mailto:r.wobben@home.nl">r.wobben@home.nl</a>>
wrote:<br>
><br>
> Hello, <br>
><br>
> To practice recursion I try to make some functions of Data
list myself on the recursive way.<br>
><br>
> First I will try last.<br>
><br>
> So I did this : <br>
><br>
> -- | Main entry point to the application.<br>
> module Main where<br>
><br>
> -- | The main entry point.<br>
> last' :: [a] -> a <br>
> last' [] = [] <br>
> last' (x:xs) = last xs<br>
><br>
><br>
> but now I see this error message : <br>
><br>
> src/Main.hs@6:12-6:14<br>
> Couldn't match expected type<br>
> a<br>
> with actual type<br>
> [t0]<br>
> a<br>
> is a rigid type variable bound by the type signature for
last' :: [a] -> a at
/home/app/isolation-runner-work/projects/112712/session.207/src/src/Main.hs:5:10
Relevant bindings include last' :: [a] -> a (bound at
/home/app/isolation-runner-work/projects/112712/session.207/src/src/Main.hs:6:1)
…<br>
><br>
> I my oponion I have said that the input is a array and the
output a string, </p>
<p dir="ltr">Except for saying list instead of array, I'd agree
with that. But when you write last' [] = [], the output is [],
which does not have the expected type of strong. So the actual
type is a list.</p>
<p dir="ltr">You need to return a string.</p>
<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>
Thanks, <br>
<br>
I did change it to this : <br>
<br>
-- | Main entry point to the application.<br>
module Main where<br>
<br>
-- | The main entry point.<br>
last' :: [a] -> a <br>
last' [x] = x <br>
last' (x:xs) = last xs<br>
<br>
So I have to look at another way to say if there is a empty list
then there is no answer. <br>
And when I run it i see this error message : <br>
<br>
GHC threw an exception : Not in scope: ‘Main.main’<br>
<br>
Roelof<br>
<br>
<br /><br />
<hr style='border:none; color:#909090; background-color:#B0B0B0; height: 1px; width: 99%;' />
<table style='border-collapse:collapse;border:none;'>
<tr>
<td style='border:none;padding:0px 15px 0px 8px'>
<a href="http://www.avast.com/">
<img border=0 src="http://static.avast.com/emails/avast-mail-stamp.png" alt="Avast logo" />
</a>
</td>
<td>
<p style='color:#3d4d5a; font-family:"Calibri","Verdana","Arial","Helvetica"; font-size:12pt;'>
Dit e-mailbericht is gecontroleerd op virussen met Avast antivirussoftware.
<br><a href="http://www.avast.com/">www.avast.com</a>
</p>
</td>
</tr>
</table>
<br />
</body>
</html>