diff options
Diffstat (limited to 'stdlib/source/lux/data/maybe.lux')
-rw-r--r-- | stdlib/source/lux/data/maybe.lux | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/stdlib/source/lux/data/maybe.lux b/stdlib/source/lux/data/maybe.lux index 3c247eea3..02d109981 100644 --- a/stdlib/source/lux/data/maybe.lux +++ b/stdlib/source/lux/data/maybe.lux @@ -1,4 +1,4 @@ -(;module: +(.module: lux (lux (control ["m" monoid] ["F" functor] @@ -8,52 +8,52 @@ ## [Types] ## (type: (Maybe a) -## #;None -## (#;Some a)) +## #.None +## (#.Some a)) ## [Structures] -(struct: #export Monoid<Maybe> (All [a] (m;Monoid (Maybe a))) - (def: identity #;None) +(struct: #export Monoid<Maybe> (All [a] (m.Monoid (Maybe a))) + (def: identity #.None) (def: (compose xs ys) (case xs - #;None ys - (#;Some x) (#;Some x)))) + #.None ys + (#.Some x) (#.Some x)))) -(struct: #export _ (F;Functor Maybe) +(struct: #export _ (F.Functor Maybe) (def: (map f ma) (case ma - #;None #;None - (#;Some a) (#;Some (f a))))) + #.None #.None + (#.Some a) (#.Some (f a))))) -(struct: #export _ (A;Applicative Maybe) +(struct: #export _ (A.Applicative Maybe) (def: functor Functor<Maybe>) (def: (wrap x) - (#;Some x)) + (#.Some x)) (def: (apply ff fa) (case [ff fa] - [(#;Some f) (#;Some a)] - (#;Some (f a)) + [(#.Some f) (#.Some a)] + (#.Some (f a)) _ - #;None))) + #.None))) (struct: #export _ (Monad Maybe) (def: applicative Applicative<Maybe>) (def: (join mma) (case mma - #;None #;None - (#;Some xs) xs))) + #.None #.None + (#.Some xs) xs))) (struct: #export (Eq<Maybe> Eq<a>) (All [a] (-> (Eq a) (Eq (Maybe a)))) (def: (= mx my) (case [mx my] - [#;None #;None] + [#.None #.None] true - [(#;Some x) (#;Some y)] + [(#.Some x) (#.Some y)] (:: Eq<a> = x y) _ @@ -61,40 +61,40 @@ (struct: #export (MaybeT Monad<M>) (All [M] (-> (Monad M) (Monad (All [a] (M (Maybe a)))))) - (def: applicative (A;compose (get@ #monad;applicative Monad<M>) Applicative<Maybe>)) + (def: applicative (A.compose (get@ #monad.applicative Monad<M>) Applicative<Maybe>)) (def: (join MmMma) (do Monad<M> [mMma MmMma] (case mMma - #;None - (wrap #;None) + #.None + (wrap #.None) - (#;Some Mma) + (#.Some Mma) Mma)))) (def: #export (lift Monad<M>) (All [M a] (-> (Monad M) (-> (M a) (M (Maybe a))))) - (monad;lift Monad<M> (:: Monad<Maybe> wrap))) + (monad.lift Monad<M> (:: Monad<Maybe> wrap))) (macro: #export (default tokens state) - {#;doc "## Allows you to provide a default value that will be used - ## if a (Maybe x) value turns out to be #;None. - (default 20 (#;Some 10)) => 10 + {#.doc "## Allows you to provide a default value that will be used + ## if a (Maybe x) value turns out to be #.None. + (default 20 (#.Some 10)) => 10 - (default 20 #;None) => 20"} + (default 20 #.None) => 20"} (case tokens (^ (list else maybe)) - (let [g!temp (: Code [dummy-cursor (#;Symbol ["" ""])]) + (let [g!temp (: Code [dummy-cursor (#.Symbol ["" ""])]) code (` (case (~ maybe) - (#;Some (~ g!temp)) + (#.Some (~ g!temp)) (~ g!temp) - #;None + #.None (~ else)))] - (#;Right [state (list code)])) + (#.Right [state (list code)])) _ - (#;Left "Wrong syntax for default"))) + (#.Left "Wrong syntax for default"))) (def: #export assume (All [a] (-> (Maybe a) a)) |