aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-08-13 20:34:35 +0100
committerJuan J. Martinez <jjm@usebox.net>2022-08-13 20:34:35 +0100
commit8c392eb76c143ea7667fe8529e697ac4777b567f (patch)
tree9be871db7c552f2fbf6d6448af5eb69cb2b6891f
parentf9069e14e80eb2c8b134a0297fa17b81742c8a03 (diff)
downloadmicro-lang-hs-8c392eb76c143ea7667fe8529e697ac4777b567f.tar.gz
micro-lang-hs-8c392eb76c143ea7667fe8529e697ac4777b567f.zip
Use as-pattern
-rw-r--r--src/Env.hs5
1 files changed, 1 insertions, 4 deletions
diff --git a/src/Env.hs b/src/Env.hs
index 1b98e9f..380addc 100644
--- a/src/Env.hs
+++ b/src/Env.hs
@@ -44,12 +44,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 m parent) (id, typ, pos) = case getSym env id of
+addSym env@(Env m parent) sym@(id, typ, pos) = case getSym env id of
Nothing -> Env (Map.insert id sym m) parent
Just s -> Env (Map.singleton id sym) $ Just env
- where
- env = (Env m parent)
- sym = (id, typ, pos)
-- | @addEnv e@ adds a new local environment using @e@ as parent.
addEnv :: Env -> Env