diff --git a/src/Control/Abstract/Value.hs b/src/Control/Abstract/Value.hs index b26de11a4..9018a8370 100644 --- a/src/Control/Abstract/Value.hs +++ b/src/Control/Abstract/Value.hs @@ -111,44 +111,22 @@ while :: Member (While value) effects while (Evaluator cond) (Evaluator body) = send (While cond body) -- | Do-while loop, built on top of while. -doWhile :: (AbstractValue address value effects, Member (Boolean value) effects) - => Evaluator address value effects value - -> Evaluator address value effects value - -> Evaluator address value effects value -doWhile body cond = undefined +doWhile :: Member (While value) effects + => Evaluator address value effects value + -> Evaluator address value effects value + -> Evaluator address value effects value +doWhile body cond = body *> while cond body -- | C-style for loops. -forLoop :: ( AbstractValue address value effects - , Member (Boolean value) effects - , Member (While value) effects - , Member (Env address) effects - ) - => Evaluator address value effects value -- ^ Initial statement - -> Evaluator address value effects value -- ^ Condition - -> Evaluator address value effects value -- ^ Increment/stepper - -> Evaluator address value effects value -- ^ Body - -> Evaluator address value effects value +forLoop :: (Member (While value) effects, Member (Env address) effects) + => Evaluator address value effects value -- ^ Initial statement + -> Evaluator address value effects value -- ^ Condition + -> Evaluator address value effects value -- ^ Increment/stepper + -> Evaluator address value effects value -- ^ Body + -> Evaluator address value effects value forLoop initial cond step body = locally (initial *> while cond (body *> step)) --- -- | The fundamental looping primitive, built on top of 'ifthenelse'. --- while :: (AbstractValue address value effects, Member (Boolean value) effects) --- => Evaluator address value effects value --- -> Evaluator address value effects value --- -> Evaluator address value effects value --- while cond body = loop $ \ continue -> do --- this <- cond --- ifthenelse this (body *> continue) (pure unit) --- --- -- | Do-while loop, built on top of while. --- doWhile :: (AbstractValue address value effects, Member (Boolean value) effects) --- => Evaluator address value effects value --- -> Evaluator address value effects value --- -> Evaluator address value effects value --- doWhile body cond = loop $ \ continue -> body *> do --- this <- cond --- ifthenelse this continue (pure unit) - data While value m result where While :: m value -> m value -> While value m value