<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Thanks <br>
<br>
Can I just say Main = <br>
I will google to look how to make a safeLast.<br>
<br>
Roelof<br>
<br>
<br>
<br>
Alexey Shmalko schreef op 12-5-2015 om 8:46:<br>
</div>
<blockquote
cite="mid:CAFC2PC4hogypq=VTCOUmRAGALv21Da4Rd9x94DGRKs3ejC_OWQ@mail.gmail.com"
type="cite">
<div dir="ltr">last' [] = error "last' on empty list"<br>
<br>
Otherwise, you should wrap the result in Maybe to make your
function work as safeLast.
<div><br>
</div>
<div>Oh... GHC's exception seems to say you haven't defined
`main` in your module.</div>
</div>
<br>
<div class="gmail_quote">On Tue, May 12, 2015 at 9:42 AM Roelof
Wobben <<a moz-do-not-send="true"
href="mailto:r.wobben@home.nl">r.wobben@home.nl</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
<div>Mike Meyer schreef op 12-5-2015 om 8:39:<br>
</div>
</div>
<div bgcolor="#FFFFFF" text="#000000">
<blockquote 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"
target="_blank">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></fieldset>
<br>
<pre>_______________________________________________
Beginners mailing list
<a moz-do-not-send="true" href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a>
<a moz-do-not-send="true" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
</blockquote>
<br>
</div>
<div bgcolor="#FFFFFF" text="#000000"> Thanks, <br>
<br>
I did change it to this : <br>
</div>
<div bgcolor="#FFFFFF" text="#000000"> <br>
-- | Main entry point to the application.<br>
module Main where<br>
<br>
-- | The main entry point.<br>
last' :: [a] -> a <br>
</div>
<div bgcolor="#FFFFFF" text="#000000"> last' [x] = x <br>
</div>
<div bgcolor="#FFFFFF" text="#000000"> last' (x:xs) = last xs<br>
<br>
</div>
<div bgcolor="#FFFFFF" text="#000000"> 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’</div>
<div bgcolor="#FFFFFF" text="#000000"><br>
<br>
Roelof<br>
<br>
<br>
<br>
<hr
style="border:none;color:#909090;background-color:#b0b0b0;min-height:1px;width:99%">
<table style="border-collapse:collapse;border:none">
<tbody>
<tr>
<td style="border:none;padding:0px 15px 0px 8px"> <a
moz-do-not-send="true"
href="http://www.avast.com/" target="_blank"> <img
moz-do-not-send="true"
src="http://static.avast.com/emails/avast-mail-stamp.png"
alt="Avast logo" border="0"> </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 moz-do-not-send="true"
href="http://www.avast.com/" target="_blank">www.avast.com</a>
</p>
</td>
</tr>
</tbody>
</table>
<br>
</div>
_______________________________________________<br>
Beginners mailing list<br>
<a moz-do-not-send="true" href="mailto:Beginners@haskell.org"
target="_blank">Beginners@haskell.org</a><br>
<a moz-do-not-send="true"
href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners"
target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
</blockquote>
</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>
<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>