Seems like a good time to mention the Maybe monad looks like it would be a good fit here.<br><br>score :: String -> String -> Maybe String<br>score s [] = Nothing<br>score s g =<br> if valid 4 g<br> then let s1 = "Golds "<br>
s2 = show (gold s g)<br> s3 = ", Silvers "<br> s4 = show (silver s g)<br> in Just (s1 ++ s2 ++ s3 ++ s4)<br> else Just "Bad Guess"<br><br clear="all">-R. Kyle Murphy<br>
--<br>Curiosity was framed, Ignorance killed the cat.<br>
<br><br><div class="gmail_quote">On Tue, Mar 9, 2010 at 17:42, Brent Yorgey <span dir="ltr"><<a href="mailto:byorgey@seas.upenn.edu">byorgey@seas.upenn.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Tue, Mar 09, 2010 at 08:42:44PM +0100, Sebastian Hungerecker wrote:<br>
> On 09.03.2010 20:04, boblettoj wrote:<br>
>> score :: String -> String -> String<br>
>> score [s] [] = false<br>
>> score [s] [g] =<br>
>> if valid 4 g<br>
>> then (s1 ++ s2 ++ s3 ++ s4) where<br>
>> s1 = "Golds "<br>
>> s2 = show (gold s g)<br>
>> s3 = ", Silvers "<br>
>> s4 = show (silver s g)<br>
>> else "Bad Guess"<br>
>><br>
><br>
> Apart from the parse error there is also a type error<br>
> in your code:<br>
> When the second argument is empty, you return false<br>
> although you declared the function to return a String,<br>
> not a boolean.<br>
<br>
</div>Not quite; data Bool = True | False, and the code uses a lowercase 'f'<br>
'false'. Perhaps 'false' is defined as a String somewhere else? A bit<br>
odd, perhaps, but not necessarily a type error.<br>
<font color="#888888"><br>
-Brent<br>
</font><div><div></div><div class="h5">_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>