aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/control/state.lux16
1 files changed, 16 insertions, 0 deletions
diff --git a/stdlib/source/lux/control/state.lux b/stdlib/source/lux/control/state.lux
index 9ee12e93d..37135ac06 100644
--- a/stdlib/source/lux/control/state.lux
+++ b/stdlib/source/lux/control/state.lux
@@ -122,3 +122,19 @@
(do Monad<M>
[a ma]
(wrap [state a]))))
+
+(def: #export (while condition body)
+ (All [s] (-> (State s Bool) (State s Unit) (State s Unit)))
+ (do Monad<State>
+ [execute? condition]
+ (if execute?
+ (do @
+ [_ body]
+ (while condition body))
+ (wrap []))))
+
+(def: #export (do-while condition body)
+ (All [s] (-> (State s Bool) (State s Unit) (State s Unit)))
+ (do Monad<State>
+ [_ body]
+ (while condition body)))