From b26780b539d69ae193ff766dfd0c9ea6b4c0a48f Mon Sep 17 00:00:00 2001 From: Patrick Thomson Date: Fri, 16 Mar 2018 16:00:49 -0400 Subject: [PATCH] add `localize` --- src/Control/Abstract/Evaluator.hs | 3 +++ src/Control/Abstract/Value.hs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Control/Abstract/Evaluator.hs b/src/Control/Abstract/Evaluator.hs index 108d7691e..719aeac24 100644 --- a/src/Control/Abstract/Evaluator.hs +++ b/src/Control/Abstract/Evaluator.hs @@ -73,6 +73,9 @@ class Monad m => MonadEnvironment value m | m -> value where addr <- lookupLocalEnv name maybe (pure Nothing) (fmap Just . with) addr +localize :: MonadEnvironment value m => m a -> m a +localize = localEnv id + -- | Update the global environment. -- TODO: RENAME ME BECAUSE MY NAME IS A LIE modifyGlobalEnv :: MonadEnvironment value m => (EnvironmentFor value -> EnvironmentFor value) -> m () diff --git a/src/Control/Abstract/Value.hs b/src/Control/Abstract/Value.hs index 75fcf6338..d815113f8 100644 --- a/src/Control/Abstract/Value.hs +++ b/src/Control/Abstract/Value.hs @@ -109,7 +109,7 @@ forLoop :: (MonadEnvironment value m, MonadValue value m) -> m value -- ^ Body -> m value forLoop initial cond step body = - localEnv id (initial *> while cond (body *> step)) + localize (initial *> while cond (body *> step)) -- | The fundamental looping primitive, built on top of ifthenelse. while :: MonadValue value m