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
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})