diff options
Diffstat (limited to 'stdlib/source/library/lux/control/function/mixin.lux')
-rw-r--r-- | stdlib/source/library/lux/control/function/mixin.lux | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/stdlib/source/library/lux/control/function/mixin.lux b/stdlib/source/library/lux/control/function/mixin.lux index 8c3443339..8248b2055 100644 --- a/stdlib/source/library/lux/control/function/mixin.lux +++ b/stdlib/source/library/lux/control/function/mixin.lux @@ -10,19 +10,23 @@ [monad (#+ Monad do)]]]]) (type: #export (Mixin i o) + {#.doc (doc "A function which can be mixed with others to inherit their behavior.")} (-> (-> i o) (-> i o) (-> i o))) (def: #export (mixin f) + {#.doc (doc "Given a mixin, produces a normal function.")} (All [i o] (-> (Mixin i o) (-> i o))) (function (mix input) ((f mix mix) input))) (def: #export nothing + {#.doc (doc "A mixin that does nothing and just delegates work to the next mixin.")} Mixin (function (_ delegate recur) delegate)) (def: #export (inherit parent child) + {#.doc (doc "Produces a new mixin, where the behavior of the child can make use of the behavior of the parent.")} (All [i o] (-> (Mixin i o) (Mixin i o) (Mixin i o))) (function (_ delegate recur) (parent (child delegate recur) recur))) @@ -34,6 +38,7 @@ (def: compose ..inherit)) (def: #export (advice when then) + {#.doc (doc "Only apply then mixin when the input meets some criterion.")} (All [i o] (-> (Predicate i) (Mixin i o) (Mixin i o))) (function (_ delegate recur input) (if (when input) @@ -41,6 +46,7 @@ (delegate input)))) (def: #export (before monad action) + {#.doc (doc "Executes an action before doing the main work.")} (All [! i o] (-> (Monad !) (-> i (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) (do monad @@ -48,6 +54,7 @@ (delegate input)))) (def: #export (after monad action) + {#.doc (doc "Executes an action after doing the main work.")} (All [! i o] (-> (Monad !) (-> i o (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) (do monad @@ -56,9 +63,11 @@ (wrap output)))) (type: #export (Recursive i o) + {#.doc (doc "An indirectly recursive function.")} (-> (-> i o) (-> i o))) -(def: #export (from_recursive recursive) +(def: #export (of_recursive recursive) + {#.doc (doc "Transform an indirectly recursive function into a mixin.")} (All [i o] (-> (Recursive i o) (Mixin i o))) (function (_ delegate recur) (recursive recur))) |