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:
parent
eb364317cb
commit
1e1495a507
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user