[Haskell-cafe] First time haskell - parse error!

Sebastian Hungerecker sepp2k at googlemail.com
Tue Mar 9 14:42:44 EST 2010


On 09.03.2010 20:04, boblettoj wrote:
> score :: String ->  String ->  String
> score [s] [] = false
> score [s] [g] =
> 	if valid 4 g
> 	then (s1 ++ s2 ++ s3 ++ s4) where
> 		s1 = "Golds "
> 		s2 = show (gold s g)
> 		s3 = ", Silvers "
> 		s4 = show (silver s g)
> 	else "Bad Guess"
>    

Apart from the parse error there is also a type error
in your code:
When the second argument is empty, you return false
although you declared the function to return a String,
not a boolean.

Also you require the first argument to be a string containing
exactly one character and the second argument to be a string
containing zero or one characters.
I'm not quite sure that's what you intend. If it is, you should
consider changing the function so that it takes a Char and a
Maybe Char, instead of two strings.

HTH,
Sebastian


More information about the Haskell-Cafe mailing list