From 25fa5a79243a50bcf0dd8670c5435f152b732488 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Wed, 15 Mar 2006 13:46:06 +0000 Subject: [PATCH] liftM --- Interpret.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Interpret.hs b/Interpret.hs index 5e18d88..652e979 100644 --- a/Interpret.hs +++ b/Interpret.hs @@ -65,9 +65,9 @@ eval (EFunc i as) = do in modify (\s -> s{variables=[m]}) (mapM_ execute ss >> (fail $ "Function "++show i++" didn't return anything.")) `catchError` (\_ ->return ()) --Only errors thrown in ErrorT can be caught here, runtime errors pass through, so no need to check the error - state' <- get + v <- liftM ret get put state - return $ ret state' + return v --Stricter evaluation of the input getNumber :: IO String @@ -143,8 +143,8 @@ execute (SDeclD t i) = execute $ SDecl t i $ case t of TBool -> EBool False execute (SDecl t i e) =do v <- eval e - state <- get - let (m:ms) = variables state in modify (\s -> s{variables=insert i v m:ms }) + (m:ms) <- liftM variables get + modify (\s -> s{variables=insert i v m:ms }) execute (SReturn e) = do v <- eval e modify (\s -> s{ret=v}) -- 2.39.2