diff options
Diffstat (limited to 'src/Environment.hs')
-rw-r--r-- | src/Environment.hs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Environment.hs b/src/Environment.hs index 7b3f365..4c444b6 100644 --- a/src/Environment.hs +++ b/src/Environment.hs | |||
@@ -8,7 +8,8 @@ module Environment ( Env | |||
8 | , IOResult | 8 | , IOResult |
9 | ) where | 9 | ) where |
10 | 10 | ||
11 | import Control.Monad (liftM, mapM) | 11 | import Control.Applicative ((<$>)) |
12 | import Control.Monad (mapM) | ||
12 | import Control.Monad.Except | 13 | import Control.Monad.Except |
13 | import Data.IORef | 14 | import Data.IORef |
14 | import Data.Maybe (isJust) | 15 | import Data.Maybe (isJust) |
@@ -44,7 +45,7 @@ setVar :: Env -> String -> Expr -> IOResult () | |||
44 | setVar env var val = do | 45 | setVar env var val = do |
45 | ptr <- liftIO $ readIORef env | 46 | ptr <- liftIO $ readIORef env |
46 | maybe (throwError $ UnboundVariable var) | 47 | maybe (throwError $ UnboundVariable var) |
47 | (liftIO . (flip writeIORef val)) | 48 | (liftIO . flip writeIORef val) |
48 | $ lookup var ptr | 49 | $ lookup var ptr |
49 | 50 | ||
50 | defineVar :: Env -> String -> Expr -> IOResult () | 51 | defineVar :: Env -> String -> Expr -> IOResult () |
@@ -65,5 +66,5 @@ makeBind (var, val) = do | |||
65 | manyBindings :: Env -> [(String, Expr)] -> IO Env | 66 | manyBindings :: Env -> [(String, Expr)] -> IO Env |
66 | manyBindings env binds = do | 67 | manyBindings env binds = do |
67 | ptr <- readIORef env | 68 | ptr <- readIORef env |
68 | extendedEnv <- liftM (++ ptr) $ mapM makeBind binds | 69 | extendedEnv <- (++ ptr) <$> mapM makeBind binds |
69 | newIORef extendedEnv | 70 | newIORef extendedEnv |