diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/control/maybe.lux | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index 2d9b56039..74b5f06d2 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -96,7 +96,8 @@ (implementation: .public (with monad) (All [M] (-> (Monad M) (Monad (All [a] (M (Maybe a)))))) - (def: &functor (functor.compose (get@ #monad.&functor monad) ..functor)) + (def: &functor + (functor.composite (get@ #monad.&functor monad) ..functor)) (def: in (|>> (\ ..monad in) (\ monad in))) @@ -110,22 +111,11 @@ (#.Some Mma) Mma)))) -(def: .public (lift monad) - {#.doc (example "Wraps a monadic value with Maybe machinery.")} +(def: .public (lifted monad) (All [M a] (-> (Monad M) (-> (M a) (M (Maybe a))))) (\ monad map (\ ..monad in))) (macro: .public (else tokens state) - {#.doc (example "Allows you to provide a default value that will be used" - "if a (Maybe x) value turns out to be #.None." - "Note: the expression for the default value will not be computed if the base computation succeeds." - (else +20 (#.Some +10)) - "=>" - +10 - -------------------------- - (else +20 #.None) - "=>" - +20)} (case tokens (^ (.list else maybe)) (let [g!temp (: Code [location.dummy (#.Identifier ["" ""])])] @@ -139,10 +129,7 @@ _ (#.Left "Wrong syntax for else"))) -(def: .public assume - {#.doc (example "Assumes that a Maybe value is a #.Some and yields its value." - "Raises/throws a runtime error otherwise." - "WARNING: Use with caution.")} +(def: .public trusted (All [a] (-> (Maybe a) a)) (|>> (..else (undefined)))) @@ -156,11 +143,6 @@ (#.Item value #.End))) (macro: .public (when tokens state) - {#.doc (example "Can be used as a guard in (co)monadic be/do expressions." - (do monad - [value (do_something 1 2 3) - ..when (passes_test? value)] - (do_something_else 4 5 6)))} (case tokens (^ (.list test then)) (#.Right [state (.list (` (.if (~ test) |