aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source')
-rw-r--r--stdlib/source/lux/function/cont.lux34
1 files changed, 24 insertions, 10 deletions
diff --git a/stdlib/source/lux/function/cont.lux b/stdlib/source/lux/function/cont.lux
index 9074f59f0..911e66995 100644
--- a/stdlib/source/lux/function/cont.lux
+++ b/stdlib/source/lux/function/cont.lux
@@ -22,16 +22,6 @@
(All [a] (-> (Cont a a) a))
(cont id))
-(def: #export (call/cc f)
- {#;doc "Call with current continuation."}
- (All [a b z]
- (-> (-> (-> a (Cont b z))
- (Cont a z))
- (Cont a z)))
- (lambda [k]
- (f (lambda [a] (lambda [_] (k a)))
- k)))
-
(struct: #export Functor<Cont> (All [o] (Functor (All [i] (Cont i o))))
(def: (map f fv)
(lambda [k] (fv (. k f)))))
@@ -55,6 +45,16 @@
(lambda [k]
(ffa (continue k)))))
+(def: #export (call/cc f)
+ {#;doc "Call with current continuation."}
+ (All [a b z]
+ (-> (-> (-> a (Cont b z))
+ (Cont a z))
+ (Cont a z)))
+ (lambda [k]
+ (f (lambda [a] (lambda [_] (k a)))
+ k)))
+
(syntax: #export (pending expr)
{#;doc (doc "Turns any expression into a function that is pending a continuation."
(pending (some-computation some-input)))}
@@ -73,3 +73,17 @@
(k [nexus val]))]
_ (k [nexus init])]
(wrap (undefined))))))
+
+(def: #export (reset scope)
+ (All [i o] (-> (Cont i i) (Cont i o)))
+ (lambda [k]
+ (k (run scope))))
+
+(def: #export (static f)
+ (All [a]
+ (-> (-> (-> a (Cont a a))
+ (Cont a a))
+ (Cont a a)))
+ (lambda [oc]
+ (f (lambda [a] (lambda [ic] (ic (oc a))))
+ id)))