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

S. Doaitse Swierstra doaitse at cs.uu.nl
Tue Mar 9 14:28:29 EST 2010


On 9 mrt 2010, at 20:04, boblettoj wrote:

> 
> Hi, i am getting an error when trying to compile this part of my program, its
> my first time using haskell and as lovely as it is it didn't give me very
> much to go on in the error message!
> 
> <code>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"</code>

If you want to keep the definitions local to the expression you should write

     then let s1 = ..
              s2 = ...
              ...
          in (s1++s2++s3++s4)
     else ...

Doaitse


> 
> when i try to compile it says: test.hs 63:29: parse error on input 'where'
> (its the line beginning with 'then')
> Anybody got any ideas whats going on?
> thanks!
> -- 
> View this message in context: http://old.nabble.com/First-time-haskell---parse-error%21-tp27839657p27839657.html
> Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.
> 
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list