diff options
author | Eduardo Julián | 2021-07-14 14:44:53 -0400 |
---|---|---|
committer | GitHub | 2021-07-14 14:44:53 -0400 |
commit | 89ca40f2f101b2b38187eab5cf905371cd47eb57 (patch) | |
tree | f05fd1677a70988c6b39c07e52d031d86eff28f1 /stdlib/source/lux/control/continuation.lux | |
parent | 2431e767a09894c2f685911ba7f1ba0b7de2a165 (diff) | |
parent | 8252bdb938a0284dd12e7365b4eb84b5357bacac (diff) |
Merge pull request #58 from LuxLang/hierarchy_normalization
Hierarchy normalization
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/control/continuation.lux | 99 |
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)))))) |