1
1
mirror of https://github.com/github/semantic.git synced 2024-12-30 02:14:20 +03:00

Use while to define forLoop.

This commit is contained in:
Rob Rix 2018-03-13 16:10:20 -04:00
parent eb364317cb
commit 1e1495a507

View File

@ -86,12 +86,7 @@ forLoop :: MonadValue term value m
forLoop initial cond step body = do
void initial
env <- getGlobalEnv
localEnv (mappend env) (fix $ \ loop -> do
cond' <- cond
ifthenelse cond' (do
void body
void step
loop) unit)
localEnv (mappend env) (while cond (body *> step))
-- | The fundamental looping primitive, built on top of ifthenelse.
while :: MonadValue term value m => m value -> m value -> m value