<div dir="ltr">Make a dummy main function,<div><br></div><div><font face="monospace, monospace"> main = return ()</font></div><div><br></div><div>And load this file in ghci to use you definition of last. The other option is to not make this module the Main module.</div><div>Then also, you can load it in ghci.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 12 May 2015 at 12:18, Roelof Wobben <span dir="ltr"><<a href="mailto:r.wobben@home.nl" target="_blank">r.wobben@home.nl</a>></span> 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>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><div><div class="h5">
<blockquote 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 href="mailto:r.wobben@home.nl" target="_blank">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 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 href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a>
<a 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 href="http://www.avast.com/" target="_blank"> <img 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 href="http://www.avast.com/" target="_blank">www.avast.com</a>
</p>
</td>
</tr>
</tbody>
</table>
<br>
</div>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a 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></fieldset>
<br>
<pre>_______________________________________________
Beginners mailing list
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a>
<a 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>
<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 href="http://www.avast.com/" target="_blank">
<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/" target="_blank">www.avast.com</a>
</p>
</td>
</tr>
</tbody></table>
<br>
</div></div></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>Regards</div><div dir="ltr"><div><br></div><div>Sumit Sahrawat</div></div></div></div></div></div></div>
</div>