aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/control/continuation.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/control/continuation.lux99
1 files changed, 0 insertions, 99 deletions
diff --git a/stdlib/source/lux/control/continuation.lux b/stdlib/source/lux/control/continuation.lux
deleted file mode 100644
index 03a9607ce..000000000
--- a/stdlib/source/lux/control/continuation.lux
+++ /dev/null
@@ -1,99 +0,0 @@
-(.module:
- [lux #*
- [abstract
- [functor (#+ Functor)]
- [apply (#+ Apply)]
- [monad (#+ Monad do)]]
- [control
- ["." function]
- [parser
- ["s" code]]]
- [macro (#+ with_gensyms)
- [syntax (#+ syntax:)]
- ["." code]]])
-
-(type: #export (Cont i o)
- {#.doc "Continuations."}
- (-> (-> i o) o))
-
-(def: #export (continue next cont)
- {#.doc "Continues a continuation thunk."}
- (All [i o] (-> (-> i o) (Cont i o) o))
- (cont next))
-
-(def: #export (run cont)
- {#.doc "Forces a continuation thunk to be evaluated."}
- (All [a] (-> (Cont a a) a))
- (cont function.identity))
-
-(def: #export (call/cc f)
- {#.doc "Call with current continuation."}
- (All [a b z]
- (-> (-> (-> a (Cont b z))
- (Cont a z))
- (Cont a z)))
- (function (_ k)
- (f (function (_ a) (function (_ _) (k a)))
- k)))
-
-(syntax: #export (pending expr)
- {#.doc (doc "Turns any expression into a function that is pending a continuation."
- (pending (some_function some_input)))}
- (with_gensyms [g!_ g!k]
- (wrap (list (` (.function ((~ g!_) (~ g!k)) ((~ g!k) (~ expr))))))))
-
-(def: #export (reset scope)
- (All [i o] (-> (Cont i i) (Cont i o)))
- (function (_ k)
- (k (run scope))))
-
-(def: #export (shift f)
- (All [a]
- (-> (-> (-> a (Cont a a))
- (Cont a a))
- (Cont a a)))
- (function (_ oc)
- (f (function (_ a) (function (_ ic) (ic (oc a))))
- function.identity)))
-
-(implementation: #export functor
- (All [o] (Functor (All [i] (Cont i o))))
-
- (def: (map f fv)
- (function (_ k) (fv (function.compose k f)))))
-
-(implementation: #export apply
- (All [o] (Apply (All [i] (Cont i o))))
-
- (def: &functor ..functor)
-
- (def: (apply ff fv)
- (function (_ k)
- (|> (k (f v))
- (function (_ v)) fv
- (function (_ f)) ff))))
-
-(implementation: #export monad
- (All [o] (Monad (All [i] (Cont i o))))
-
- (def: &functor ..functor)
-
- (def: (wrap value)
- (function (_ k) (k value)))
-
- (def: (join ffa)
- (function (_ k)
- (ffa (continue k)))))
-
-(def: #export (portal init)
- (All [i o z]
- (-> i
- (Cont [(-> i (Cont o z))
- i]
- z)))
- (call/cc (function (_ k)
- (do ..monad
- [#let [nexus (function (nexus val)
- (k [nexus val]))]
- _ (k [nexus init])]
- (wrap (undefined))))))