aboutsummaryrefslogtreecommitdiff
path: root/src/Micro/Env.hs
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-12-20 19:53:05 +0000
committerJuan J. Martinez <jjm@usebox.net>2023-12-20 19:53:05 +0000
commitc7cc8467ca1835c8f96ccb5be7c976a26d262433 (patch)
tree007845bfd68c97ce88056912942617424c2f93a8 /src/Micro/Env.hs
parent9ebeada35c00160b19161928be74e44093686985 (diff)
downloadmicro-lang-hs-c7cc8467ca1835c8f96ccb5be7c976a26d262433.tar.gz
micro-lang-hs-c7cc8467ca1835c8f96ccb5be7c976a26d262433.zip
Updated to use GHC 9.4.x and floating dependencies
Diffstat (limited to 'src/Micro/Env.hs')
-rw-r--r--src/Micro/Env.hs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/Micro/Env.hs b/src/Micro/Env.hs
index 731f19a..b788214 100644
--- a/src/Micro/Env.hs
+++ b/src/Micro/Env.hs
@@ -1,8 +1,8 @@
module Micro.Env where
-import qualified Data.Map as Map
+import Data.Map qualified as Map
import Data.Maybe (isJust)
-import qualified Micro.Ast as A
+import Micro.Ast qualified as A
import Micro.Error
import Text.Parsec (SourcePos)
@@ -56,9 +56,9 @@ existsSyml env sym = isJust $ getSyml env sym
-- environment. It will create a new enviroment if the symbol already exists
-- (shadowing).
addSym :: Env -> Sym -> Env
-addSym env@(Env m parent) sym = case getSym env (symId sym) of
- Nothing -> Env (Map.insert (symId sym) sym m) parent
- Just _ -> Env (Map.singleton (symId sym) sym) $ Just env
+addSym env@(Env m parent) sym = case getSym env sym.symId of
+ Nothing -> Env (Map.insert sym.symId sym m) parent
+ Just _ -> Env (Map.singleton sym.symId sym) $ Just env
-- | @addEnv e@ adds a new local environment using @e@ as parent.
addEnv :: Env -> Env
@@ -67,6 +67,6 @@ addEnv env = Env Map.empty $ Just env
-- | @addSymUniq e s@ adds a local symbol @s@ to the enviroment @e@ if it
-- doesn't exist.
addSymUniq :: Env -> Sym -> Either Error Env
-addSymUniq ev sym = case getSyml ev (symId sym) of
+addSymUniq ev sym = case getSyml ev sym.symId of
Nothing -> Right $ addSym ev sym
- Just other -> Left $ Error AlreadyDefined ("\"" ++ symId sym ++ "\" already defined in " ++ show (symPos other)) $ symPos sym
+ Just other -> Left $ Error AlreadyDefined ("\"" ++ sym.symId ++ "\" already defined in " ++ show other.symPos) sym.symPos