diff options
Diffstat (limited to 'stdlib/source')
-rw-r--r-- | stdlib/source/lux/concurrency/atom.lux | 4 | ||||
-rw-r--r-- | stdlib/source/lux/concurrency/promise.lux | 24 | ||||
-rw-r--r-- | stdlib/source/lux/control/applicative.lux | 17 | ||||
-rw-r--r-- | stdlib/source/lux/data/coll/array.lux | 26 | ||||
-rw-r--r-- | stdlib/source/lux/data/coll/dict.lux | 26 | ||||
-rw-r--r-- | stdlib/source/lux/data/coll/list.lux | 4 | ||||
-rw-r--r-- | stdlib/source/lux/data/coll/sequence.lux | 45 | ||||
-rw-r--r-- | stdlib/source/lux/data/number.lux | 78 | ||||
-rw-r--r-- | stdlib/source/lux/data/text.lux | 9 | ||||
-rw-r--r-- | stdlib/source/lux/lang/type.lux | 2 | ||||
-rw-r--r-- | stdlib/source/lux/macro/syntax.lux | 19 | ||||
-rw-r--r-- | stdlib/source/lux/math.lux | 15 | ||||
-rw-r--r-- | stdlib/source/lux/type/opaque.lux | 42 |
13 files changed, 200 insertions, 111 deletions
diff --git a/stdlib/source/lux/concurrency/atom.lux b/stdlib/source/lux/concurrency/atom.lux index 2837d6177..f2e1cc14e 100644 --- a/stdlib/source/lux/concurrency/atom.lux +++ b/stdlib/source/lux/concurrency/atom.lux @@ -13,7 +13,7 @@ (def: #export (read atom) (All [a] (-> (Atom a) (IO a))) - (io ("lux atom get" atom))) + (io ("lux atom read" atom))) (def: #export (compare-and-swap current new atom) {#;doc "Only mutates an atom if you can present it's current value. @@ -29,7 +29,7 @@ The retries will be done with the new values of the atom, as they show up."} (All [a] (-> (-> a a) (Atom a) (IO Unit))) - (io (let [old ("lux atom get" atom)] + (io (let [old ("lux atom read" atom)] (if ("lux atom compare-and-swap" atom old (f old)) [] (io;run (update f atom)))))) diff --git a/stdlib/source/lux/concurrency/promise.lux b/stdlib/source/lux/concurrency/promise.lux index 75bcc52fd..9baaded11 100644 --- a/stdlib/source/lux/concurrency/promise.lux +++ b/stdlib/source/lux/concurrency/promise.lux @@ -89,7 +89,9 @@ (struct: #export _ (F;Functor Promise) (def: (map f fa) - (let [fb (promise ($ +1))] + (let [fb (promise ($ +1)) + ## fb (promise' #;None) + ] (exec (await (function [a] (resolve (f a) fb)) fa) fb)))) @@ -102,7 +104,9 @@ #observers (list)})) (def: (apply ff fa) - (let [fb (promise ($ +1))] + (let [fb (promise ($ +1)) + ## fb (promise' #;None) + ] (exec (await (function [f] (io (await (function [a] (resolve (f a) fb)) fa))) @@ -114,7 +118,9 @@ (def: applicative Applicative<Promise>) (def: (join mma) - (let [ma (promise ($ +0))] + (let [ma (promise ($ +0)) + ## ma (promise' #;None) + ] (exec (await (function [ma'] (io (await (function [a'] (resolve a' ma)) ma'))) @@ -132,7 +138,9 @@ (def: #export (alt left right) {#;doc "Heterogeneous alternative combinator."} (All [a b] (-> (Promise a) (Promise b) (Promise (| a b)))) - (let [a|b (promise (Either ($ +0) ($ +1)))] + (let [a|b (promise (| ($ +0) ($ +1))) + ## a|b (promise' #;None) + ] (with-expansions [<sides> (do-template [<promise> <tag>] [(await (function [value] (resolve (<tag> value) a|b)) @@ -147,7 +155,9 @@ (def: #export (either left right) {#;doc "Homogeneous alternative combinator."} (All [a] (-> (Promise a) (Promise a) (Promise a))) - (let [left||right (promise ($ +0))] + (let [left||right (promise ($ +0)) + ## left||right (promise' #;None) + ] (`` (exec (~~ (do-template [<promise>] [(await (function [value] (resolve value left||right)) <promise>)] @@ -159,7 +169,9 @@ (def: #export (future computation) {#;doc "Runs an I/O computation on its own process and returns an Promise that will eventually host its result."} (All [a] (-> (IO a) (Promise a))) - (let [!out (promise ($ +0))] + (let [!out (promise ($ +0)) + ## !out (promise' #;None) + ] (exec ("lux process future" (io (io;run (resolve (io;run computation) !out)))) !out))) diff --git a/stdlib/source/lux/control/applicative.lux b/stdlib/source/lux/control/applicative.lux index 187950aa9..d2b505941 100644 --- a/stdlib/source/lux/control/applicative.lux +++ b/stdlib/source/lux/control/applicative.lux @@ -1,10 +1,10 @@ (;module: lux - (.. ["F" functor])) + (.. [functor #+ Functor])) (sig: #export (Applicative f) {#;doc "Applicative functors."} - (: (F;Functor f) + (: (Functor f) functor) (: (All [a] (-> a (f a))) @@ -16,15 +16,20 @@ (struct: #export (compose Applicative<F> Applicative<G>) {#;doc "Applicative functor composition."} (All [F G] (-> (Applicative F) (Applicative G) (Applicative (All [a] (F (G a)))))) - (def: functor (F;compose (get@ #functor Applicative<F>) - (get@ #functor Applicative<G>))) + + (def: functor (functor;compose (get@ #functor Applicative<F>) + (get@ #functor Applicative<G>))) (def: wrap (|>. (:: Applicative<G> wrap) (:: Applicative<F> wrap))) (def: (apply fgf fgx) + ## (let [fgf' (:: Applicative<F> apply + ## (:: Applicative<F> wrap (:: Applicative<G> apply)) + ## fgf)] + ## (:: Applicative<F> apply fgf' fgx)) (let [applyF (:: Applicative<F> apply) applyG (:: Applicative<G> apply)] ($_ applyF (:: Applicative<F> wrap applyG) fgf - fgx))) - ) + fgx)) + )) diff --git a/stdlib/source/lux/data/coll/array.lux b/stdlib/source/lux/data/coll/array.lux index 2dbf07803..c697e5681 100644 --- a/stdlib/source/lux/data/coll/array.lux +++ b/stdlib/source/lux/data/coll/array.lux @@ -78,7 +78,19 @@ xs' (delete idx xs'))))) xs - (list;indices (size xs)))) + (list;indices (size xs))) + ## (list/fold (function [idx xs'] + ## (case (read idx xs) + ## #;None + ## xs' + + ## (#;Some x) + ## (if (p x) + ## xs' + ## (delete idx xs')))) + ## xs + ## (list;indices (size xs))) + ) (def: #export (find p xs) (All [a] @@ -195,7 +207,17 @@ (#;Some x) (write idx (f x) mb)))) (new arr-size) - (list;n.range +0 (n.dec arr-size))))))) + (list;n.range +0 (n.dec arr-size))) + ## (list/fold (function [idx mb] + ## (case (read idx ma) + ## #;None + ## mb + + ## (#;Some x) + ## (write idx (f x) mb))) + ## (new arr-size) + ## (list;n.range +0 (n.dec arr-size))) + )))) (struct: #export _ (Fold Array) (def: (fold f init xs) diff --git a/stdlib/source/lux/data/coll/dict.lux b/stdlib/source/lux/data/coll/dict.lux index d5528dc09..cee6a83fc 100644 --- a/stdlib/source/lux/data/coll/dict.lux +++ b/stdlib/source/lux/data/coll/dict.lux @@ -120,7 +120,8 @@ (def: (insert! idx value old-array) (All [a] (-> Index a (Array a) (Array a))) (let [old-size (array;size old-array)] - (|> (: (Array ($ +0)) + (|> ## (array;new (n.inc old-size)) + (: (Array ($ +0)) (array;new (n.inc old-size))) (array;copy idx +0 old-array +0) (array;write idx value) @@ -233,8 +234,10 @@ (array;write insertion-idx (#;Left sub-node) base)]]) ))) [+0 [clean-bitmap + ## (array;new (n.dec h-size)) (: (Base ($ +0) ($ +1)) - (array;new (n.dec h-size)))]] + (array;new (n.dec h-size))) + ]] (list;indices (array;size h-array))))) ## When #Base nodes grow too large, they're promoted to #Hierarchy to @@ -264,8 +267,10 @@ (undefined))] default)) [+0 + ## (array;new hierarchy-nodes-size) (: (Array (Node ($ +0) ($ +1))) - (array;new hierarchy-nodes-size))] + (array;new hierarchy-nodes-size)) + ] hierarchy-indices))) ## All empty nodes look the same (a #Base node with clean bitmap is @@ -287,13 +292,20 @@ ## a sub-node. If impossible, I introduced a new singleton sub-node. (#Hierarchy _size hierarchy) (let [idx (level-index level hash) + ## [_size' sub-node] (case (array;read idx hierarchy) + ## (#;Some sub-node) + ## [_size sub-node] + + ## _ + ## [(n.inc _size) empty]) [_size' sub-node] (: [Nat (Node ($ +0) ($ +1))] (case (array;read idx hierarchy) (#;Some sub-node) [_size sub-node] _ - [(n.inc _size) empty]))] + [(n.inc _size) empty])) + ] (#Hierarchy _size' (update! idx (put' (level-up level) hash key val Hash<k> sub-node) hierarchy))) @@ -327,7 +339,8 @@ ## the same, a new ## #Collisions node ## is added. - (#Collisions hash (|> (: (Array [($ +0) ($ +1)]) + (#Collisions hash (|> ## (array;new +2) + (: (Array [($ +0) ($ +1)]) (array;new +2)) (array;write +0 [key' val']) (array;write +1 [key val]))) @@ -373,7 +386,8 @@ ## If the hashes are not equal, I create a new #Base node that ## contains the old #Collisions node, plus the new KV-pair. (|> (#Base (bit-position level _hash) - (|> (: (Base ($ +0) ($ +1)) + (|> ## (array;new +1) + (: (Base ($ +0) ($ +1)) (array;new +1)) (array;write +0 (#;Left node)))) (put' level hash key val Hash<k>))) diff --git a/stdlib/source/lux/data/coll/list.lux b/stdlib/source/lux/data/coll/list.lux index 4d4090835..d7bbe0161 100644 --- a/stdlib/source/lux/data/coll/list.lux +++ b/stdlib/source/lux/data/coll/list.lux @@ -483,7 +483,9 @@ (do Monad<M> [lMla MlMla lla (: (($ +0) (List (List ($ +1)))) - (M;seq @ lMla))] + (M;seq @ lMla)) + ## lla (M;seq @ lMla) + ] (wrap (concat lla))))) (def: #export (lift Monad<M>) diff --git a/stdlib/source/lux/data/coll/sequence.lux b/stdlib/source/lux/data/coll/sequence.lux index f85558c5e..f76c824a7 100644 --- a/stdlib/source/lux/data/coll/sequence.lux +++ b/stdlib/source/lux/data/coll/sequence.lux @@ -74,14 +74,16 @@ (All [a] (-> Level (Base a) (Node a))) (if (n.= +0 level) (#Base tail) - (|> (: (Hierarchy ($ +0)) + (|> ## (new-hierarchy []) + (: (Hierarchy ($ +0)) (new-hierarchy [])) (array;write +0 (new-path (level-down level) tail)) #Hierarchy))) (def: (new-tail singleton) (All [a] (-> a (Base a))) - (|> (: (Base ($ +0)) + (|> ## (array;new +1) + (: (Base ($ +0)) (array;new +1)) (array;write +0 singleton))) @@ -110,7 +112,8 @@ (def: (expand-tail val tail) (All [a] (-> a (Base a) (Base a))) (let [tail-size (array;size tail)] - (|> (: (Base ($ +0)) + (|> ## (array;new (n.inc tail-size)) + (: (Base ($ +0)) (array;new (n.inc tail-size))) (array;copy tail-size +0 tail +0) (array;write tail-size val) @@ -208,7 +211,8 @@ ## If so, a brand-new root must be established, that is ## 1-level taller. (|> vec - (set@ #root (|> (: (Hierarchy ($ +0)) + (set@ #root (|> ## (new-hierarchy []) + (: (Hierarchy ($ +0)) (new-hierarchy [])) (array;write +0 (#Hierarchy (get@ #root vec))) (array;write +1 (new-path (get@ #level vec) (get@ #tail vec))))) @@ -259,8 +263,10 @@ (n.< vec-size idx)) (if (n.>= (tail-off vec-size) idx) (|> vec + ## (update@ #tail (|>. array;clone (array;write (branch-idx idx) val))) (update@ #tail (: (-> (Base ($ +0)) (Base ($ +0))) - (|>. array;clone (array;write (branch-idx idx) val))))) + (|>. array;clone (array;write (branch-idx idx) val)))) + ) (|> vec (update@ #root (put' (get@ #level vec) idx val)))) vec))) @@ -294,7 +300,26 @@ (maybe;assume (do maybe;Monad<Maybe> [new-tail (base-for (n.- +2 vec-size) vec) - #let [[level' root'] (: [Level (Hierarchy ($ +0))] + #let [## [level' root'] (let [init-level (get@ #level vec)] + ## (loop [level init-level + ## root (maybe;default (new-hierarchy []) + ## (pop-tail vec-size init-level (get@ #root vec))) + ## ## root (: (Hierarchy ($ +0)) + ## ## (maybe;default (new-hierarchy []) + ## ## (pop-tail vec-size init-level (get@ #root vec)))) + ## ] + ## (if (n.> branching-exponent level) + ## (case [(array;read +1 root) (array;read +0 root)] + ## [#;None (#;Some (#Hierarchy sub-node))] + ## (recur (level-down level) sub-node) + + ## ## [#;None (#;Some (#Base _))] + ## ## (undefined) + + ## _ + ## [level root]) + ## [level root]))) + [level' root'] (: [Level (Hierarchy ($ +0))] (let [init-level (get@ #level vec)] (loop [level init-level root (: (Hierarchy ($ +0)) @@ -310,7 +335,8 @@ _ [level root]) - [level root]))))]] + [level root])))) + ]] (wrap (|> vec (update@ #size n.dec) (set@ #level level') @@ -326,6 +352,7 @@ (def: #export (from-list list) (All [a] (-> (List a) (Sequence a))) (list/fold add + ## empty (: (Sequence ($ +0)) empty) list)) @@ -353,7 +380,9 @@ [(#Hierarchy h1) (#Hierarchy h2)] (:: (array;Eq<Array> (Eq<Node> Eq<a>)) = h1 h2) - ))) + + _ + false))) (struct: #export (Eq<Sequence> Eq<a>) (All [a] (-> (Eq a) (Eq (Sequence a)))) (def: (= v1 v2) diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux index 5b8e1946d..446e1e152 100644 --- a/stdlib/source/lux/data/number.lux +++ b/stdlib/source/lux/data/number.lux @@ -8,7 +8,7 @@ enum interval codec) - (data ["E" error] + (data ["e" error] [maybe] [bit]))) @@ -162,10 +162,10 @@ (def: (decode input) (case (<decoder> [input]) (#;Some value) - (#E;Success value) + (#e;Success value) #;None - (#E;Error <error>))))] + (#e;Error <error>))))] [Frac "lux frac encode" "lux frac decode" "Could not decode Frac"] ) @@ -199,16 +199,16 @@ (let [digit (maybe;assume (get-char input idx))] (case ("lux text index" <char-set> digit +0) #;None - (#E;Error ("lux text concat" <error> repr)) + (#e;Error ("lux text concat" <error> repr)) (#;Some index) (recur (n.inc idx) (|> output (n.* <base>) (n.+ index))))) - (#E;Success output)))) + (#e;Success output)))) _ - (#E;Error ("lux text concat" <error> repr))) - (#E;Error ("lux text concat" <error> repr))))))] + (#e;Error ("lux text concat" <error> repr))) + (#e;Error ("lux text concat" <error> repr))))))] [Binary@Codec<Text,Nat> +2 "01" "Invalid binary syntax for Nat: "] [Octal@Codec<Text,Nat> +8 "01234567" "Invalid octal syntax for Nat: "] @@ -250,13 +250,13 @@ (let [digit (maybe;assume (get-char input idx))] (case ("lux text index" <char-set> digit +0) #;None - (#E;Error <error>) + (#e;Error <error>) (#;Some index) (recur (n.inc idx) (|> output (i.* <base>) (i.+ (:! Int index)))))) - (#E;Success (i.* sign output))))) - (#E;Error <error>)))))] + (#e;Success (i.* sign output))))) + (#e;Error <error>)))))] [Binary@Codec<Text,Int> 2 "01" "Invalid binary syntax for Int: "] [Octal@Codec<Text,Int> 8 "01234567" "Invalid octal syntax for Int: "] @@ -289,12 +289,12 @@ (case ("lux text char" repr +0) (^multi (^ (#;Some (char "."))) [(:: <nat> decode ("lux text concat" "+" (de-prefix repr))) - (#;Some output)]) - (#E;Success (:! Deg output)) + (#e;Success output)]) + (#e;Success (:! Deg output)) _ - (#E;Error ("lux text concat" <error> repr))) - (#E;Error ("lux text concat" <error> repr))))))] + (#e;Error ("lux text concat" <error> repr))) + (#e;Error ("lux text concat" <error> repr))))))] [Binary@Codec<Text,Deg> Binary@Codec<Text,Nat> +1 "Invalid binary syntax: "] [Octal@Codec<Text,Deg> Octal@Codec<Text,Nat> +3 "Invalid octal syntax: "] @@ -327,7 +327,7 @@ decimal-part (maybe;assume ("lux text clip" repr (n.inc split-index) ("lux text size" repr)))] (case [(:: <int> decode whole-part) (:: <int> decode decimal-part)] - (^multi [(#;Some whole) (#;Some decimal)] + (^multi [(#e;Success whole) (#e;Success decimal)] (i.>= 0 decimal)) (let [sign (if (i.< 0 whole) -1.0 @@ -340,19 +340,19 @@ (f.* <base> output)))) adjusted-decimal (|> decimal int-to-frac (f./ div-power)) dec-deg (case (:: Hex@Codec<Text,Deg> decode ("lux text concat" "." decimal-part)) - (#E;Success dec-deg) + (#e;Success dec-deg) dec-deg - (#E;Error error) + (#e;Error error) (error! error))] - (#E;Success (f.+ (int-to-frac whole) + (#e;Success (f.+ (int-to-frac whole) (f.* sign adjusted-decimal)))) _ - (#E;Error ("lux text concat" <error> repr)))) + (#e;Error ("lux text concat" <error> repr)))) _ - (#E;Error ("lux text concat" <error> repr)))))] + (#e;Error ("lux text concat" <error> repr)))))] [Binary@Codec<Text,Frac> Binary@Codec<Text,Int> 2.0 "01" "Invalid binary syntax: "] ) @@ -524,14 +524,14 @@ ("lux text concat" (<to> whole-part)) ("lux text concat" (if (f.= -1.0 sign) "-" "")))] (case (:: Binary@Codec<Text,Frac> decode as-binary) - (#E;Error _) - (#E;Error ("lux text concat" <error> repr)) + (#e;Error _) + (#e;Error ("lux text concat" <error> repr)) output output)) _ - (#E;Error ("lux text concat" <error> repr))))))] + (#e;Error ("lux text concat" <error> repr))))))] [Octal@Codec<Text,Frac> "Invalid octaladecimal syntax: " binary-to-octal octal-to-binary] [Hex@Codec<Text,Frac> "Invalid hexadecimal syntax: " binary-to-hex hex-to-binary] @@ -543,26 +543,26 @@ (case tokens (#;Cons [meta (#;Text repr)] #;Nil) (case (:: <nat> decode repr) - (#E;Success value) - (#E;Success [state (list [meta (#;Nat value)])]) + (#e;Success value) + (#e;Success [state (list [meta (#;Nat value)])]) - (^multi (#E;Error _) - [(:: <int> decode repr) (#E;Success value)]) - (#E;Success [state (list [meta (#;Int value)])]) + (^multi (#e;Error _) + [(:: <int> decode repr) (#e;Success value)]) + (#e;Success [state (list [meta (#;Int value)])]) - (^multi (#E;Error _) - [(:: <deg> decode repr) (#E;Success value)]) - (#E;Success [state (list [meta (#;Deg value)])]) + (^multi (#e;Error _) + [(:: <deg> decode repr) (#e;Success value)]) + (#e;Success [state (list [meta (#;Deg value)])]) - (^multi (#E;Error _) - [(:: <frac> decode repr) (#E;Success value)]) - (#E;Success [state (list [meta (#;Frac value)])]) + (^multi (#e;Error _) + [(:: <frac> decode repr) (#e;Success value)]) + (#e;Success [state (list [meta (#;Frac value)])]) _ - (#E;Error <error>)) + (#e;Error <error>)) _ - (#E;Error <error>)))] + (#e;Error <error>)))] [bin Binary@Codec<Text,Nat> Binary@Codec<Text,Int> Binary@Codec<Text,Deg> Binary@Codec<Text,Frac> "Invalid binary syntax." @@ -757,11 +757,11 @@ (recur (digits-sub! power digits) (n.inc idx) (bit;set (n.- idx (n.dec bit;width)) output)))) - (#E;Success (:! Deg output)))) + (#e;Success (:! Deg output)))) #;None - (#E;Error ("lux text concat" "Wrong syntax for Deg: " input))) - (#E;Error ("lux text concat" "Wrong syntax for Deg: " input)))) + (#e;Error ("lux text concat" "Wrong syntax for Deg: " input))) + (#e;Error ("lux text concat" "Wrong syntax for Deg: " input)))) )) (def: (log2 input) diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux index 0611e6e79..fe57508cc 100644 --- a/stdlib/source/lux/data/text.lux +++ b/stdlib/source/lux/data/text.lux @@ -20,7 +20,12 @@ (def: #export (contains? sub text) (-> Text Text Bool) - ("lux text contains?" text sub)) + (case ("lux text index" text sub +0) + (#;Some _) + true + + _ + false)) (do-template [<name> <proc>] [(def: #export (<name> input) @@ -213,7 +218,7 @@ (def: #export (from-code code) (-> Nat Text) - ("lux nat to-char" code)) + ("lux nat char" code)) (def: #export (space? char) {#;doc "Checks whether the character is white-space."} diff --git a/stdlib/source/lux/lang/type.lux b/stdlib/source/lux/lang/type.lux index 974561605..d4a3d7d1b 100644 --- a/stdlib/source/lux/lang/type.lux +++ b/stdlib/source/lux/lang/type.lux @@ -30,7 +30,7 @@ (<tag> env def) _ - type)) + (<tag> (list/map (beta-reduce env) old-env) def))) ([#;UnivQ] [#;ExQ]) diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux index 917b7e094..0f2777ed8 100644 --- a/stdlib/source/lux/macro/syntax.lux +++ b/stdlib/source/lux/macro/syntax.lux @@ -228,15 +228,16 @@ (with-brackets (spaced (list/map constructor-arg$ constructor-args))) (with-brackets (spaced (list/map (method-def$ id) methods))))))] (wrap (list (` ((~ (code;text def-code)))))))))} - (let [[exported? tokens] (case tokens - (^ (list& [_ (#;Tag ["" "hidden"])] tokens')) - [(#;Some #;Left) tokens'] + (let [[exported? tokens] (: [(Maybe (Either Unit Unit)) (List Code)] + (case tokens + (^ (list& [_ (#;Tag ["" "hidden"])] tokens')) + [(#;Some #;Left) tokens'] - (^ (list& [_ (#;Tag ["" "export"])] tokens')) - [(#;Some #;Right) tokens'] + (^ (list& [_ (#;Tag ["" "export"])] tokens')) + [(#;Some #;Right) tokens'] - _ - [#;None tokens]) + _ + [#;None tokens])) ?parts (: (Maybe [Text (List Code) Code Code]) (case tokens (^ (list [_ (#;Form (list& [_ (#;Symbol ["" name])] args))] @@ -270,10 +271,10 @@ #let [g!state (code;symbol ["" "*compiler*"]) error-msg (code;text (text/compose "Wrong syntax for " name)) export-ast (: (List Code) (case exported? - (#;Some #E;Error) + (#;Some #;Left) (list (' #hidden)) - (#;Some #E;Success) + (#;Some #;Right) (list (' #export)) _ diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux index d1671537d..700bc9919 100644 --- a/stdlib/source/lux/math.lux +++ b/stdlib/source/lux/math.lux @@ -9,20 +9,17 @@ [code]))) ## [Values] -(do-template [<name> <value>] +(do-template [<name> <value> <doc>] [(def: #export <name> + {#;doc <doc>} Frac - (<value>))] + <value>)] - [e "lux math e"] - [pi "lux math pi"] + [e 2.7182818284590452354 "The base of the natural logarithm."] + [pi 3.14159265358979323846 "The ratio of a circle's circumference to its diameter."] + [tau 6.28318530717958647692 "The ratio of a circle's circumference to its radius."] ) -(def: #export tau - {#;doc "The same as 2*PI."} - Frac - 6.28318530717958647692) - (do-template [<name> <method>] [(def: #export (<name> input) (-> Frac Frac) diff --git a/stdlib/source/lux/type/opaque.lux b/stdlib/source/lux/type/opaque.lux index 3b50fcbc2..636acd6e2 100644 --- a/stdlib/source/lux/type/opaque.lux +++ b/stdlib/source/lux/type/opaque.lux @@ -68,28 +68,30 @@ this-module (|> this-module (update@ #;defs (put down-cast (: Def [Macro macro-anns - (function [tokens] - (case tokens - (^ (list value)) - (wrap (list (` ((: (All [(~@ type-varsC)] - (-> (~ representation-declaration) (~ opaque-declaration))) - (|>. :!!)) - (~ value))))) - - _ - (macro;fail ($_ text/compose "Wrong syntax for " down-cast))))]))) + (: Macro + (function [tokens] + (case tokens + (^ (list value)) + (wrap (list (` ((: (All [(~@ type-varsC)] + (-> (~ representation-declaration) (~ opaque-declaration))) + (|>. :!!)) + (~ value))))) + + _ + (macro;fail ($_ text/compose "Wrong syntax for " down-cast)))))]))) (update@ #;defs (put up-cast (: Def [Macro macro-anns - (function [tokens] - (case tokens - (^ (list value)) - (wrap (list (` ((: (All [(~@ type-varsC)] - (-> (~ opaque-declaration) (~ representation-declaration))) - (|>. :!!)) - (~ value))))) - - _ - (macro;fail ($_ text/compose "Wrong syntax for " up-cast))))]))))]] + (: Macro + (function [tokens] + (case tokens + (^ (list value)) + (wrap (list (` ((: (All [(~@ type-varsC)] + (-> (~ opaque-declaration) (~ representation-declaration))) + (|>. :!!)) + (~ value))))) + + _ + (macro;fail ($_ text/compose "Wrong syntax for " up-cast)))))]))))]] (function [compiler] (#E;Success [(update@ #;modules (put this-module-name this-module) compiler) []])))) |