aboutsummaryrefslogtreecommitdiffstats
path: root/src/Utils.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils.hs')
-rw-r--r--src/Utils.hs17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/Utils.hs b/src/Utils.hs
index 1e9afc5..6354a87 100644
--- a/src/Utils.hs
+++ b/src/Utils.hs
@@ -2,7 +2,7 @@
module Utils where
import Control.Monad.Except
-import Control.Monad.Reader
+import Control.Monad.State
import qualified Data.Map as M
import qualified Data.List as L
import qualified Data.Char as C
@@ -22,10 +22,17 @@ data Config = Config {
configUseREPL :: Bool
}
-type LContext a = ReaderT Config (ExceptT LException IO) a
+type Env = M.Map String AST
+
+data LState = LState {
+ stateConfig :: Config,
+ stateEnv :: Env
+}
-runL :: Config -> LContext a -> IO (Either LException a)
-runL config lc = runExceptT $ runReaderT lc config
+type LContext a = StateT LState (ExceptT LException IO) a
+
+runL :: LState -> LContext a -> IO (Either LException (a, LState))
+runL s lc = runExceptT $ (flip runStateT) s lc
data Token = Token {
tokenContent :: String,
@@ -40,8 +47,6 @@ instance (Eq Token) where
instance (Show Token) where
show token = show $ tokenContent token
-type Env = M.Map String AST
-
type LFunction = (Env -> AST -> LContext AST)
data ASTNode