[Haskell-beginners] let expression
Daniel Fischer
daniel.is.fischer at web.de
Wed Feb 10 15:32:16 EST 2010
Am Mittwoch 10 Februar 2010 21:16:31 schrieb John Moore:
> Hi All,
> Trying to get this to work, keeps telling me there a parse
> error on right in the let expression. Can anyone see where the problem
> is and be able to explain it to me.
>
> evalStep d (Let n e1 e2)
> = case e1 of
> (Val a) -> case e2 of
> (Val b)-> Val (Let e1 e2)
> left -> Let e1 (evalStep d e2)
> right -> Let (evalStep d e1) e2
Here?
Indentation. The patterns for the inner case-expression must be indented
further than those for the outer (and all patterns in one case-expression
must be indented to the same level).
>
>
> evaluate :: Dict-> [Expression] -> Expression -> IO()
> evaluate d(x:xs) e = do
> putStrLn (show e)
> putStrLn "Do another step (y/n) or rollback (r)? :"
> c <- getLine
> case c of
> "y" -> let e'= (evalStep d e)in evaluate d (e:x:xs) e'-- build up
> history
>
> "r" -> case (x:xs) of
> (x:xs)-> evaluate d xs x
> []-> do { putStrLn "Empty"
> ;evaluate d(x:xs) e
> }
> "n" -> putStrLn $ "Ok you said no :" ++ c
>
>
> John
More information about the Beginners
mailing list