diff options
Diffstat (limited to 'stdlib/source/library/lux/control/continuation.lux')
-rw-r--r-- | stdlib/source/library/lux/control/continuation.lux | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/stdlib/source/library/lux/control/continuation.lux b/stdlib/source/library/lux/control/continuation.lux index e9b702f55..9a65c9d3e 100644 --- a/stdlib/source/library/lux/control/continuation.lux +++ b/stdlib/source/library/lux/control/continuation.lux @@ -14,21 +14,17 @@ ["." code]]]]) (type: .public (Cont i o) - {#.doc "Continuations."} (-> (-> i o) o)) -(def: .public (continue next cont) - {#.doc "Continues a continuation thunk."} +(def: .public (continued next cont) (All [i o] (-> (-> i o) (Cont i o) o)) (cont next)) -(def: .public (result cont) - {#.doc "Forces a continuation thunk to be evaluated."} +(def: .public result (All [a] (-> (Cont a a) a)) - (cont function.identity)) + (..continued function.identity)) -(def: .public (call/cc f) - {#.doc "Call with current continuation."} +(def: .public (with_current f) (All [a b z] (-> (-> (-> a (Cont b z)) (Cont a z)) @@ -38,8 +34,6 @@ k))) (syntax: .public (pending [expr <code>.any]) - {#.doc (example "Turns any expression into a function that is pending a continuation." - (pending (some_function some_input)))} (with_identifiers [g!_ g!k] (in (list (` (.function ((~ g!_) (~ g!k)) ((~ g!k) (~ expr)))))))) @@ -61,7 +55,8 @@ (All [o] (Functor (All [i] (Cont i o)))) (def: (map f fv) - (function (_ k) (fv (function.compose k f))))) + (function (_ k) + (fv (function.composite k f))))) (implementation: .public apply (All [o] (Apply (All [i] (Cont i o)))) @@ -84,7 +79,7 @@ (def: (join ffa) (function (_ k) - (ffa (continue k))))) + (ffa (continued k))))) (def: .public (portal init) (All [i o z] @@ -92,9 +87,10 @@ (Cont [(-> i (Cont o z)) i] z))) - (call/cc (function (_ k) - (do ..monad - [.let [nexus (function (nexus val) - (k [nexus val]))] - _ (k [nexus init])] - (in (undefined)))))) + (with_current + (function (_ k) + (do ..monad + [.let [nexus (function (nexus val) + (k [nexus val]))] + _ (k [nexus init])] + (in (undefined)))))) |