From cb8a1222c04cc596cfae2e85e8c9f3216ed61273 Mon Sep 17 00:00:00 2001 From: joshvera Date: Fri, 2 Nov 2018 16:17:32 -0400 Subject: [PATCH] forLoop in terms of withLexicalScopeAndFrame --- src/Control/Abstract/Value.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Control/Abstract/Value.hs b/src/Control/Abstract/Value.hs index faf5e7c11..1f2514a6b 100644 --- a/src/Control/Abstract/Value.hs +++ b/src/Control/Abstract/Value.hs @@ -163,14 +163,24 @@ doWhile :: (Member (While value) sig, Carrier sig m) doWhile body cond = body *> while cond body -- | C-style for loops. -forLoop :: (Member (While value) sig, Member (Env address) sig, Carrier sig m) +forLoop :: ( Carrier sig m + , Member (Allocator address) sig + , Member (Reader ModuleInfo) sig + , Member (Reader Span) sig + , Member (Resumable (BaseError (HeapError address))) sig + , Member (Resumable (BaseError (ScopeError address))) sig + , Member (State (Heap address address value)) sig + , Member (State (ScopeGraph address)) sig + , Member (While value) sig + , Member Fresh sig + , Ord address + ) => Evaluator term address value m value -- ^ Initial statement -> Evaluator term address value m value -- ^ Condition -> Evaluator term address value m value -- ^ Increment/stepper -> Evaluator term address value m value -- ^ Body -> Evaluator term address value m value -forLoop initial cond step body = - locally (initial *> while cond (body *> step)) +forLoop initial cond step body = initial *> while cond ((withLexicalScopeAndFrame body) *> step) data While value m k = While (m value) (m value) (value -> k)