]> ruin.nu Git - proglang.git/commitdiff
liftM
authorMichael Andreen <harv@ruin.nu>
Wed, 15 Mar 2006 13:46:06 +0000 (13:46 +0000)
committerMichael Andreen <harv@ruin.nu>
Wed, 15 Mar 2006 13:46:06 +0000 (13:46 +0000)
Interpret.hs

index 5e18d88b07046182de7c51ed0866d1e18c82691d..652e9793aaf2db2ca81bd396db3ef426e0d9d2ba 100644 (file)
@@ -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})