diff options
1076 files changed, 11657 insertions, 11673 deletions
@@ -138,7 +138,7 @@ There is also the special **^or** macro, which introduces *or patterns*: {#Sunday}))) ... Returns TRUE if it's either Saturday OR Sunday. -(def: (weekend? day) +(def (weekend? day) (-> Weekday Bit) (case day (^or {#Saturday} diff --git a/documentation/book/the_lux_programming_language/appendix_c.md b/documentation/book/the_lux_programming_language/appendix_c.md index 38580fee8..a2c0953cb 100644 --- a/documentation/book/the_lux_programming_language/appendix_c.md +++ b/documentation/book/the_lux_programming_language/appendix_c.md @@ -62,7 +62,7 @@ The possibilities are endless when it comes to the refinement you can do, and wh ```clojure ... Allows you to simultaneously bind and de-structure a value. -(def: (hash (^@ set [element_hash _])) +(def (hash (^@ set [element_hash _])) (list#mix (function (_ elem acc) (n.+ (# element_hash hash elem) acc)) 0 @@ -74,7 +74,7 @@ The possibilities are endless when it comes to the refinement you can do, and wh ```clojure ... Same as the "open" macro, but meant to be used as a pattern-matching macro for generating local bindings. ... Can optionally take an aliasing text for the generated local bindings. -(def: .public (range (^open "[0]") from to) +(def .public (range (^open "[0]") from to) (All (_ a) (-> (Enum a) a a (List a))) (range' <= succ from to)) ``` @@ -95,7 +95,7 @@ It's excellent when taking structures as function arguments, or when opening str {#Friday} {#Saturday})) -(def: (weekend? day) +(def (weekend? day) (-> Day Bit) (case day (^or {#Saturday} {#Sunday}) @@ -111,7 +111,7 @@ It's a real time-saver. ```clojure ... It's similar to do-template, but meant to be used during pattern-matching. -(def: (beta_reduce env type) +(def (beta_reduce env type) (-> (List Type) Type Type) (case type {.#Primitive name params} diff --git a/documentation/book/the_lux_programming_language/appendix_e.md b/documentation/book/the_lux_programming_language/appendix_e.md index 4ce648625..b31ec03d0 100644 --- a/documentation/book/the_lux_programming_language/appendix_e.md +++ b/documentation/book/the_lux_programming_language/appendix_e.md @@ -93,7 +93,7 @@ Here are some examples from the `library/lux/ffi` module, where I have some type {#ProtectedP} {#DefaultP})) -(def: privacy_modifier^ +(def privacy_modifier^ (Parser Privacy) (let [(^open "[0]") <>.monad] ($_ <>.or @@ -121,7 +121,7 @@ Here's an example of `<>.and` in action: [Text (Type Value)]) ... From library/lux/ffi -(def: (argument^ type_vars) +(def (argument^ type_vars) (-> (List (Type Var)) (Parser Argument)) (<code>.tuple (<>.and <code>.local_symbol (..type^ type_vars)))) diff --git a/documentation/book/the_lux_programming_language/chapter_10.md b/documentation/book/the_lux_programming_language/chapter_10.md index d2937a83b..6c86c9671 100644 --- a/documentation/book/the_lux_programming_language/chapter_10.md +++ b/documentation/book/the_lux_programming_language/chapter_10.md @@ -130,7 +130,7 @@ The beautiful thing is that `(' (you can use the "'" #macro [to generate {arbitr ... Hygienic quasi-quotation as a macro. ... Unquote (~) and unquote-splice (~+) must also be used as forms. ... All unprefixed symbols will receive their parent module's prefix if imported; otherwise will receive the prefix of the module on which the quasi-quote is being used. -(` (def: (~ name) +(` (def (~ name) (function ((~ name) (~+ args)) (~ body)))) ``` @@ -154,7 +154,7 @@ With these tools, you can introduce a lot of complexity and customization into y ```clojure ... Unhygienic quasi-quotation as a macro. ... Unquote (~) and unquote-splice (~+) must also be used as forms. -(`' (def: (~ name) +(`' (def (~ name) (function ((~ name) (~+ args)) (~ body)))) ``` diff --git a/documentation/book/the_lux_programming_language/chapter_11.md b/documentation/book/the_lux_programming_language/chapter_11.md index e3e73d97a..56115b830 100644 --- a/documentation/book/the_lux_programming_language/chapter_11.md +++ b/documentation/book/the_lux_programming_language/chapter_11.md @@ -104,7 +104,7 @@ Here is an example: {#Unary Code Infix} {#Binary Infix Code Infix}))) -(def: literal +(def literal (Parser Code) ($_ <>.either (<>#each code.bit <code>.bit) @@ -115,7 +115,7 @@ Here is an example: (<>#each code.text <code>.text) (<>#each code.symbol <code>.symbol))) -(def: expression +(def expression (Parser Infix) (<| <>.rec (function (_ expression)) ($_ <>.or @@ -139,7 +139,7 @@ And here are some examples of syntax macros: ```clojure ... Also from library/lux/math/infix. -(def: (prefix infix) +(def (prefix infix) (-> Infix Code) (case infix {#Const value} diff --git a/documentation/book/the_lux_programming_language/chapter_14.md b/documentation/book/the_lux_programming_language/chapter_14.md index 5552c3347..2fd53c5bb 100644 --- a/documentation/book/the_lux_programming_language/chapter_14.md +++ b/documentation/book/the_lux_programming_language/chapter_14.md @@ -51,7 +51,7 @@ The result is that, through the `do` macro, you can implement complex concurrent If you're curious about how that looks, take a peek: ```clojure -(def: .public (and left right) +(def .public (and left right) (All (_ a b) (-> (Async a) (Async b) (Async [a b]))) (do monad [a left diff --git a/documentation/book/the_lux_programming_language/chapter_16.md b/documentation/book/the_lux_programming_language/chapter_16.md index d5ece9f9b..be5456dbf 100644 --- a/documentation/book/the_lux_programming_language/chapter_16.md +++ b/documentation/book/the_lux_programming_language/chapter_16.md @@ -100,11 +100,11 @@ To know how tests work, let's take a look at one of those modules. [\\library ["[0]" /]]) -(def: (injection value) +(def (injection value) (Injection /.Stack) (/.top value /.empty)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Stack]) diff --git a/documentation/book/the_lux_programming_language/chapter_17.md b/documentation/book/the_lux_programming_language/chapter_17.md index 73ece8cb5..e13693d89 100644 --- a/documentation/book/the_lux_programming_language/chapter_17.md +++ b/documentation/book/the_lux_programming_language/chapter_17.md @@ -100,7 +100,7 @@ And the other is meant for when the changes are so massive, you might as well ju First, let's go with the smaller mechanism: ```clojure -(def: js "JavaScript") +(def js "JavaScript") (for ["JVM" (do jvm stuff) ..js (do js stuff)] @@ -129,7 +129,7 @@ The module `library/lux/target` contains constants with the names of currently s To give you an example of `for` in action, here is a definition from the `library/lux/data/text` module: ```clojure -(def: .public (replaced pattern replacement template) +(def .public (replaced pattern replacement template) (-> Text Text Text Text) (for [@.old (:as Text diff --git a/documentation/book/the_lux_programming_language/chapter_4.md b/documentation/book/the_lux_programming_language/chapter_4.md index ebb58a78e..5dfa20328 100644 --- a/documentation/book/the_lux_programming_language/chapter_4.md +++ b/documentation/book/the_lux_programming_language/chapter_4.md @@ -52,7 +52,7 @@ How do we use the `plus_two` function without having to inline its definition (l Well, we just need to define it! ```clojure -(def: plus_two +(def plus_two (: (-> Nat Nat) (function (_ x) (++ (++ x))))) @@ -61,13 +61,13 @@ Well, we just need to define it! Or, alternatively: ```clojure -(def: plus_two +(def plus_two (-> Nat Nat) (function (_ x) (++ (++ x)))) ``` -Notice how the `def:` macro can take the type of its value before the value itself, so we don't need to wrap it in the type-annotation `:` macro. +Notice how the `def` macro can take the type of its value before the value itself, so we don't need to wrap it in the type-annotation `:` macro. Now, we can use the square function more conveniently. @@ -78,15 +78,15 @@ Now, we can use the square function more conveniently. Nice! -Also, I forgot to mention another form of the `def:` macro which is even more convenient: +Also, I forgot to mention another form of the `def` macro which is even more convenient: ```clojure -(def: (plus_two x) +(def (plus_two x) (-> Nat Nat) (++ (++ x))) ``` -The `def:` macro is very versatile, and it allows us to define constants and functions. +The `def` macro is very versatile, and it allows us to define constants and functions. If you omit the type, the compiler will try to infer it for you, and you will get an error if there are any ambiguities. @@ -103,13 +103,13 @@ Functions, of course, can take more than one argument, and you can even refer to Check this one out: ```clojure -(def: (factorial' acc n) +(def (factorial' acc n) (-> Nat Nat Nat) (if (n.= 0 n) acc (factorial' (n.* n acc) (-- n)))) -(def: (factorial n) +(def (factorial n) (-> Nat Nat) (factorial' 1 n)) ``` @@ -155,7 +155,7 @@ This means that if a function takes N arguments, and you give it M arguments, wh That means, our factorial function could have been implemented like this: ```clojure -(def: factorial +(def factorial (-> Nat Nat) (factorial' 1)) ``` @@ -163,7 +163,7 @@ That means, our factorial function could have been implemented like this: Or, to make it shorter: ```clojure -(def: factorial (factorial' 1)) +(def factorial (factorial' 1)) ``` Nice, huh? diff --git a/documentation/book/the_lux_programming_language/chapter_5.md b/documentation/book/the_lux_programming_language/chapter_5.md index a7d09016a..fe36dc46d 100644 --- a/documentation/book/the_lux_programming_language/chapter_5.md +++ b/documentation/book/the_lux_programming_language/chapter_5.md @@ -100,7 +100,7 @@ We can see its power by looking at some examples. For instance, the `factorial'` function you saw in the previous chapter could have been written like this: ```clojure -(def: (factorial' acc n) +(def (factorial' acc n) (-> Nat Nat Nat) (case n 0 acc @@ -121,7 +121,7 @@ The _"default"_ branch works because we're binding the value of `n` onto a varia However, since it is binding a variable, that means we could have used `_` instead of `n` during our calculations; like this: ```clojure -(def: (factorial' acc n) +(def (factorial' acc n) (-> Nat Nat Nat) (case n 0 acc @@ -221,7 +221,7 @@ Recursion is nothing more than the capacity for a function to call itself (often It's not hard to see how this mechanism can be used to loop in any way you want, and we've already seen examples of recursion in action. ```clojure -(def: (factorial' acc n) +(def (factorial' acc n) (-> Nat Nat Nat) (if (n.= 0 n) acc @@ -241,7 +241,7 @@ Our example `factorial'` function has its recursive call in the _tail position_ This alternative doesn't: ```clojure -(def: (factorial' acc n) +(def (factorial' acc n) (-> Nat Nat Nat) (if (n.= 0 n) acc @@ -269,7 +269,7 @@ Lux also offers a macro that gives you a slightly similar experience to those ki To see it in action, let's rewrite (once more!) our `factorial` function: ```clojure -(def: (factorial n) +(def (factorial n) (-> Nat Nat) (loop [acc 1 n n] @@ -346,7 +346,7 @@ Well, we haven't really seen that in action yet. It's time to put that theory into practice... with an example: ```clojure -(def: (iterate_list f list) +(def (iterate_list f list) (All (_ a b) (-> (-> a b) (List a) (List b))) (case list {.#End} diff --git a/documentation/book/the_lux_programming_language/chapter_7.md b/documentation/book/the_lux_programming_language/chapter_7.md index bf888680f..53bc97890 100644 --- a/documentation/book/the_lux_programming_language/chapter_7.md +++ b/documentation/book/the_lux_programming_language/chapter_7.md @@ -102,9 +102,9 @@ Let's take a look at how you make one: (implementation: .public order (Order Frac) - (def: &equivalence ..equivalence) + (def &equivalence ..equivalence) - (def: < ..<)) + (def < ..<)) ``` This implementation comes from `library/lux/math/number/frac`. @@ -120,10 +120,10 @@ Here is another example, from the `library/lux/data/collection/list` module: (All (_ a) (Monoid (List a))) - (def: identity + (def identity {.#End}) - (def: (compose xs ys) + (def (compose xs ys) (case xs {.#End} ys {.#Item x xs'} {.#Item x (compose xs' ys)}))) @@ -166,8 +166,8 @@ Let's check them out. (open library/lux/math/number/int.order "i::[0]") ... Will generate: -(def: .private i::= (# library/lux/math/number/int.order =)) -(def: .private i::< (# library/lux/math/number/int.order <)) +(def .private i::= (# library/lux/math/number/int.order =)) +(def .private i::< (# library/lux/math/number/int.order <)) ``` The `open:` macro serves as a directive that creates private/un-exported definitions in your module for every member of a particular implementation. @@ -206,7 +206,7 @@ I can't emphasize enough that _implementations_ are values. And to exemplify it for you, here's a function from the `library/lux/abstract/monad` module that takes in an implementation (among other things) and uses it within its code: ```clojure -(def: .public (each monad f xs) +(def .public (each monad f xs) (All (_ M a b) (-> (Monad M) (-> a (M b)) (List a) (M (List b)))) (case xs diff --git a/documentation/book/the_lux_programming_language/chapter_8.md b/documentation/book/the_lux_programming_language/chapter_8.md index 5f15eced5..8c262b355 100644 --- a/documentation/book/the_lux_programming_language/chapter_8.md +++ b/documentation/book/the_lux_programming_language/chapter_8.md @@ -76,7 +76,7 @@ Here is its `Functor` implementation. (implementation: .public functor (Functor Maybe) - (def: (each f ma) + (def (each f ma) (case ma {.#None} {.#None} {.#Some a} {.#Some (f a)}))) @@ -107,7 +107,7 @@ Turns out, that's just the `Functor` implementation from `library/lux/data/colle (implementation: .public functor (Functor List) - (def: (each f ma) + (def (each f ma) (case ma {.#End} {.#End} {.#Item a ma'} {.#Item (f a) (each f ma')}))) @@ -175,7 +175,7 @@ Here are the relevant `Functor` and `Monad` implementations: (implementation: .public functor (Functor Try) - (def: (each f ma) + (def (each f ma) (case ma {#Failure msg} {#Failure msg} @@ -186,12 +186,12 @@ Here are the relevant `Functor` and `Monad` implementations: (implementation: .public monad (Monad Try) - (def: &functor ..functor) + (def &functor ..functor) - (def: (in a) + (def (in a) {#Success a}) - (def: (join mma) + (def (join mma) (case mma {#Failure msg} {#Failure msg} @@ -235,7 +235,7 @@ Not really. It's just the `Monad` for `List`: (implementation: .public functor (Functor List) - (def: (each f ma) + (def (each f ma) (case ma {.#End} {.#End} @@ -246,7 +246,7 @@ Not really. It's just the `Monad` for `List`: (implementation: .public mix (Mix List) - (def: (mix f init xs) + (def (mix f init xs) (case xs {.#End} init @@ -257,10 +257,10 @@ Not really. It's just the `Monad` for `List`: (implementation: .public monoid (All (_ a) (Monoid (List a))) - (def: identity + (def identity {.#End}) - (def: (composite xs ys) + (def (composite xs ys) (case xs {.#End} ys @@ -273,12 +273,12 @@ Not really. It's just the `Monad` for `List`: (implementation: .public monad (Monad List) - (def: &functor ..functor) + (def &functor ..functor) - (def: (in a) + (def (in a) {.#Item a {.#End}}) - (def: (conjoint list_of_lists) + (def (conjoint list_of_lists) (mix composite identity (reversed list_of_lists)))) diff --git a/documentation/specification/Syntax.md b/documentation/specification/Syntax.md index aa107d9cf..bddc7ec1b 100644 --- a/documentation/specification/Syntax.md +++ b/documentation/specification/Syntax.md @@ -124,7 +124,7 @@ For example: * `(this #is "a" valid.form)` * `(+ 123 456)` -* `(def: my-constant +3.14)` +* `(def my-constant +3.14)` # Tuple @@ -136,7 +136,7 @@ For example: * `[this #is "a" valid.form]` * `[+ 123 456]` -* `[def: my-constant +3.14]` +* `[def my-constant +3.14]` # Record @@ -148,7 +148,7 @@ For example: * `{this #is "a" valid.form}` * `{+ [123 456]}` -* `{def: {my-constant +3.14}}` +* `{def {my-constant +3.14}}` Because pairs of syntax tokens are expected, _the number of elements in a record must always be an **even** number_. diff --git a/licentia/source/program/licentia.lux b/licentia/source/program/licentia.lux index 213024c2d..11819681d 100644 --- a/licentia/source/program/licentia.lux +++ b/licentia/source/program/licentia.lux @@ -49,10 +49,10 @@ "[1]::[0]" (trim [] java/lang/String)) -(def: default_output_file +(def default_output_file "LICENSE.txt") -(def: (success_message output) +(def (success_message output) (-> file.Path Text) (format "Your license has been made!" text.new_line "Check the file " output ".")) diff --git a/licentia/source/program/licentia/document.lux b/licentia/source/program/licentia/document.lux index 42c692fb7..eb35929f4 100644 --- a/licentia/source/program/licentia/document.lux +++ b/licentia/source/program/licentia/document.lux @@ -7,29 +7,29 @@ [collection ["[0]" list (.open: "[1]#[0]" functor)]]]]]) -(def: .public (quote text) +(def .public (quote text) (-> Text Text) (format text.double_quote text text.double_quote)) -(def: .public (block content) +(def .public (block content) (-> Text Text) (format content text.new_line text.new_line)) -(def: .public (plural singular) +(def .public (plural singular) (-> Text Text) (format singular "(s)")) -(def: .public (sentence content) +(def .public (sentence content) (-> Text Text) (format content ".")) -(def: .public paragraph +(def .public paragraph (-> (List Text) Text) (|>> (list#each ..sentence) (text.interposed text.new_line))) (with_template [<name> <word>] - [(def: .public <name> + [(def .public <name> (-> (List Text) Text) ... https://en.wikipedia.org/wiki/Serial_comma (text.interposed (format ", " <word> " ")))] @@ -44,7 +44,7 @@ [#title Text #content Text])) -(def: .public (section value) +(def .public (section value) (-> Section Text) (format (..block (the #title value)) (the #content value))) diff --git a/licentia/source/program/licentia/input.lux b/licentia/source/program/licentia/input.lux index ca72241e7..b11f1a576 100644 --- a/licentia/source/program/licentia/input.lux +++ b/licentia/source/program/licentia/input.lux @@ -29,7 +29,7 @@ ["[0]" time (.only Period)] ["[0]" copyright]]]) -(def: identification +(def identification (Parser Identification) (<json>.object (all <>.and @@ -44,7 +44,7 @@ (exception.report "Amount" (%.int amount))) -(def: amount +(def amount (Parser Nat) (do <>.monad [amountF <json>.number @@ -61,7 +61,7 @@ "Start" (%.nat (the time.#start period)) "End" (%.nat (the time.#end period)))) -(def: period +(def period (Parser (Period Nat)) (<json>.object (do <>.monad @@ -73,14 +73,14 @@ (n.<= end start))] (wrap period)))) -(def: copyright_holder +(def copyright_holder (Parser copyright.Holder) (<json>.object (all <>.and (<json>.field "name" <json>.string) (<json>.field "period" ..period)))) -(def: termination +(def termination (Parser Termination) (<json>.object (all <>.and @@ -88,21 +88,21 @@ (<json>.field "termination period" ..amount) (<json>.field "grace period" ..amount)))) -(def: liability +(def liability (Parser Liability) (<json>.object (all <>.and (<json>.field "can accept?" <json>.boolean) (<json>.field "disclaim high risk?" <json>.boolean)))) -(def: distribution +(def distribution (Parser Distribution) (<json>.object (all <>.and (<json>.field "can re-license?" <json>.boolean) (<json>.field "can multi-license?" <json>.boolean)))) -(def: commercial +(def commercial (Parser Commercial) (<json>.object (all <>.and @@ -110,7 +110,7 @@ (<json>.field "require contributor credit?" <json>.boolean) (<json>.field "allow contributor endorsement?" <json>.boolean)))) -(def: extension +(def extension (Parser Extension) (<json>.object (all <>.and @@ -119,22 +119,22 @@ (<json>.field "notification period" (<json>.nullable ..period)) (<json>.field "must describe modifications?" <json>.boolean)))) -(def: entity +(def entity (Parser Entity) <json>.string) -(def: black_list +(def black_list (Parser Black_List) (<json>.object (all <>.and (<json>.field "justification" (<json>.nullable <json>.string)) (<json>.field "entities" (<json>.array (<>.many ..entity)))))) -(def: url +(def url (Parser URL) <json>.string) -(def: attribution +(def attribution (Parser Attribution) (<json>.object (all <>.and @@ -143,14 +143,14 @@ (<json>.field "url" ..url) (<json>.field "image" (<json>.nullable ..url))))) -(def: addendum +(def addendum (Parser Addendum) (<json>.object (all <>.and (<json>.field "commons clause?" <json>.boolean) ))) -(def: .public license +(def .public license (Parser License) (<json>.object (all <>.and diff --git a/licentia/source/program/licentia/license/addendum.lux b/licentia/source/program/licentia/license/addendum.lux index b443da0f4..ff3154c43 100644 --- a/licentia/source/program/licentia/license/addendum.lux +++ b/licentia/source/program/licentia/license/addendum.lux @@ -9,13 +9,13 @@ ["$" document]]]) ... https://commonsclause.com/ -(def: .public commons_clause +(def .public commons_clause Text (format ($.block "The Software is provided to you by the Licensor under the License, as defined below, subject to the following condition.") ($.block "Without limiting other conditions in the License, the grant of rights under the License will not include, and the License does not grant to you, the right to Sell the Software.") ($.block "For purposes of the foregoing, “Sell” means practicing any or all of the rights granted to you under the License to provide to third parties, for a fee or other consideration (including without limitation fees for hosting or consulting/ support services related to the Software), a product or service whose value derives, entirely or substantially, from the functionality of the Software. Any license notice or attribution required by the License must also include this Commons Clause License Condition notice."))) -(def: .public (output value) +(def .public (output value) (-> Addendum Text) (`` (format (~~ (with_template [<title> <condition> <content>] [(if <condition> diff --git a/licentia/source/program/licentia/license/assurance.lux b/licentia/source/program/licentia/license/assurance.lux index ddd0b1b61..71d28d670 100644 --- a/licentia/source/program/licentia/license/assurance.lux +++ b/licentia/source/program/licentia/license/assurance.lux @@ -9,14 +9,14 @@ [// ["$" document]]]) -(def: .public representation +(def .public representation ($.sentence (format "Each " _.contributor " represents that the " _.contributor " believes its " ($.plural _.contribution) " are its original creation(s) or it has sufficient rights to grant the rights to its " ($.plural _.contribution) " conveyed by " _.license))) -(def: .public fair_use +(def .public fair_use (let [copyright_doctrines (is (List Text) (list "fair use" "fair dealing" diff --git a/licentia/source/program/licentia/license/black_list.lux b/licentia/source/program/licentia/license/black_list.lux index a83ef0c23..2c579ce2f 100644 --- a/licentia/source/program/licentia/license/black_list.lux +++ b/licentia/source/program/licentia/license/black_list.lux @@ -13,11 +13,11 @@ [// ["$" document]]]) -(def: .public entity +(def .public entity (-> Entity Text) %.text) -(def: .public (black_list black_list) +(def .public (black_list black_list) (-> Black_List Text) (let [scope (format "The rights granted under " _.license) effect "shall not be granted to the following entities, or any subsidiary thereof" diff --git a/licentia/source/program/licentia/license/commercial.lux b/licentia/source/program/licentia/license/commercial.lux index 8aa43c531..aeab29d02 100644 --- a/licentia/source/program/licentia/license/commercial.lux +++ b/licentia/source/program/licentia/license/commercial.lux @@ -9,7 +9,7 @@ [// ["$" document]]]) -(def: .public cannot_sell +(def .public cannot_sell (let [preamble (format "Without limiting other conditions in " _.license) direct_condition (format "the grant of rights under " _.license " will not include, and does not grant to " _.recipient @@ -19,11 +19,11 @@ ", " direct_condition ", " derivative_condition)))) -(def: .public require_contributor_attribution +(def .public require_contributor_attribution ($.sentence (format "All advertising materials mentioning features or use of " _.licensed_work " must include an acknowledgement of the authorship of every " _.contributor))) -(def: .public disallow_contributor_endorsement +(def .public disallow_contributor_endorsement (let [subject (format "The name of no " _.contributor) capability "endorse or promote products" source (format "any " _.extension) diff --git a/licentia/source/program/licentia/license/definition.lux b/licentia/source/program/licentia/license/definition.lux index f094e291e..13da5bf69 100644 --- a/licentia/source/program/licentia/license/definition.lux +++ b/licentia/source/program/licentia/license/definition.lux @@ -12,10 +12,10 @@ [#term Text #meaning Text])) -(def: not_a_contribution_notice +(def not_a_contribution_notice (format text.double_quote "Not a Contribution" text.double_quote)) -(def: .public patent_rights +(def .public patent_rights (List Text) (list "make" "have made" @@ -25,7 +25,7 @@ "import" "transfer")) -(def: commercial_services +(def commercial_services (List Text) (let [services (is (-> Text Text) (function (_ type) @@ -34,7 +34,7 @@ (services "consulting") (services "support")))) -(def: individual_capacities +(def individual_capacities (List Text) (list "officer" "employee" @@ -42,11 +42,11 @@ "independent contractor" "agent of a corporation, business or organization (commercial or non-commercial)")) -(def: covered_work_description +(def covered_work_description "work of authorship") (with_template [<name> <term> <meaning>] - [(def: .public <name> + [(def .public <name> Definition [#term <term> #meaning <meaning>])] @@ -215,7 +215,7 @@ ($.paragraph (list "a mechanism generally accepted in the software development community for the electronic transfer of data, such as download from an FTP server or web site, where such mechanism is publicly accessible"))] ) -(def: .public all +(def .public all (List Definition) (list license licensable diff --git a/licentia/source/program/licentia/license/distribution.lux b/licentia/source/program/licentia/license/distribution.lux index 0281d2ae6..1a388b664 100644 --- a/licentia/source/program/licentia/license/distribution.lux +++ b/licentia/source/program/licentia/license/distribution.lux @@ -11,7 +11,7 @@ [// ["$" document]]]) -(def: notices +(def notices (List Text) (let [notices (is (-> Text Text) (function (_ what) @@ -24,7 +24,7 @@ (notices "limitation of liability") (notices "other")))) -(def: .public source_code_form +(def .public source_code_form (let [on_license_propagation (let [coverage (format "All distribution of " _.licensed_work " in " _.source_code_form) with_contributions (format "including any " ($.plural _.contribution) " that " _.recipient @@ -62,7 +62,7 @@ on_notice_retention on_additional_notices)))) -(def: .public object_form +(def .public object_form (let [on_responsibility (let [condition (format "If " _.recipient " distributes " _.licensed_work " in " _.object_form) @@ -79,7 +79,7 @@ ($.paragraph (list on_responsibility on_licensing)))) -(def: .public allow_re_licensing +(def .public allow_re_licensing (let [can_license (format _.recipient " may create and distribute an " _.extension " under terms " _.recipient @@ -89,7 +89,7 @@ " for the " _.licensed_work)] (format can_license ", " "provided that " requirement))) -(def: .public allow_multi_licensing +(def .public allow_multi_licensing (let [condition (format "the " _.extension " is a combination of " _.licensed_work " with a work governed by one or more " ($.plural _.secondary_license)) permission (let [relicensing (format _.license " permits " _.recipient @@ -102,7 +102,7 @@ (format relicensing ", " distribution))] (format "If " condition ", " permission))) -(def: .public (extension distribution) +(def .public (extension distribution) (-> Distribution Text) ($.paragraph (all list#composite (if (the //.#can_re_license? distribution) diff --git a/licentia/source/program/licentia/license/extension.lux b/licentia/source/program/licentia/license/extension.lux index 0c9362a2b..cb2a3bddf 100644 --- a/licentia/source/program/licentia/license/extension.lux +++ b/licentia/source/program/licentia/license/extension.lux @@ -11,7 +11,7 @@ [// ["$" document]]]) -(def: .public sharing_requirement +(def .public sharing_requirement (List Text) (let [on_extension (let [constraint (let [because "In consideration of, and as an express condition to, " source (format "the licenses granted to " _.recipient @@ -51,7 +51,7 @@ on_license_propagation on_license_protection))) -(def: .public license_conflict_resolution +(def .public license_conflict_resolution (List Text) (let [on_other_licenses (let [circumstance (format "Where any portion of an " _.extension " created by " _.recipient) @@ -71,7 +71,7 @@ on_licensor_judgement on_licensor_discretion))) -(def: .public distinctness_requirement +(def .public distinctness_requirement ($.paragraph (list (format "Any " _.extension " " _.recipient " does make and " _.deploy @@ -79,14 +79,14 @@ " that the " _.extension " is by " _.recipient)))) -(def: news_sources +(def news_sources (List Text) (list "news groups" "mailing lists" "weblogs" "other sites")) -(def: .public (notification_requirement [start end]) +(def .public (notification_requirement [start end]) (-> (Period Months) Text) (let [on_availability (format _.recipient " must notify the software community of the availability of the " _.source_code_form @@ -129,7 +129,7 @@ on_changes on_accesibility)))) -(def: .public description_requirement +(def .public description_requirement Text (let [on_duty (let [basic (format _.recipient " must cause any " _.modification diff --git a/licentia/source/program/licentia/license/grant.lux b/licentia/source/program/licentia/license/grant.lux index 40f256aef..729d9fd5c 100644 --- a/licentia/source/program/licentia/license/grant.lux +++ b/licentia/source/program/licentia/license/grant.lux @@ -13,12 +13,12 @@ [// ["$" document]]]) -(def: grant_header +(def grant_header (format "Subject to the terms and conditions of " _.license ", each " _.contributor " hereby grants to " _.recipient)) -(def: .public grant_characteristics +(def .public grant_characteristics (List Text) (list "perpetual" "world-wide" @@ -27,7 +27,7 @@ "royalty-free" "irrevocable")) -(def: .public copyright_grant_rights +(def .public copyright_grant_rights (List Text) (list "use" "reproduce" @@ -38,7 +38,7 @@ "sublicense" "distribute")) -(def: .public copyright +(def .public copyright ($.sentence (format grant_header " a " ($.and ..grant_characteristics) " copyright license to " ($.or ..copyright_grant_rights) " " _.licensed_work @@ -46,7 +46,7 @@ " in a " _.source_code_form " or an " _.object_form))) -(def: .public (patent retaliation?) +(def .public (patent retaliation?) (-> Bit Text) (let [grant (format grant_header " a " ($.and ..grant_characteristics) " patent license to " ($.or definition.patent_rights) " " @@ -68,16 +68,16 @@ (list retaliation_clause) (list)))))) -(def: .public date +(def .public date ($.sentence (format "The licenses granted in " _.license " with respect to any " _.contribution " become effective for each " _.contribution " on the date the " _.contributor " first distributes such " _.contribution))) -(def: restoration_scope "an ongoing basis") +(def restoration_scope "an ongoing basis") -(def: .public (grant_restoration_clause termination_period) +(def .public (grant_restoration_clause termination_period) (-> Days Text) (let [restoration_condition (format _.recipient " becomes compliant") restored_grants (format "the rights granted under " _.license @@ -93,7 +93,7 @@ ", unless and until " invalidation_condition ", and on " ..restoration_scope ", if " complaint_period_condition))) -(def: .public (grace_period_clause grace_period) +(def .public (grace_period_clause grace_period) (-> Days Text) (let [the_grants (format "grants to " _.recipient " from a particular " _.contributor) automatic_restoration_conditions (let [notification (format "such " _.contributor @@ -112,7 +112,7 @@ " are reinstated on " ..restoration_scope " if " automatic_restoration_conditions))) -(def: .public (termination termination_period grace_period) +(def .public (termination termination_period grace_period) (-> Days Days Text) (let [on_violation_of_terms (let [what (format "The rights granted under " _.license) when (format _.recipient " fails to comply with any of its terms")] @@ -121,7 +121,7 @@ (..grant_restoration_clause termination_period) (..grace_period_clause grace_period))))) -(def: .public no_retroactive_termination +(def .public no_retroactive_termination (let [situation "In the event of termination" coverage "all end user license agreements" exclusions "(excluding licenses to distributors and resellers)" diff --git a/licentia/source/program/licentia/license/liability.lux b/licentia/source/program/licentia/license/liability.lux index 10dfab0c2..3f7c62340 100644 --- a/licentia/source/program/licentia/license/liability.lux +++ b/licentia/source/program/licentia/license/liability.lux @@ -9,26 +9,26 @@ [// ["$" document]]]) -(def: warranty_communications +(def warranty_communications (List Text) (list "expressed" "implied" "statutory")) -(def: work_disclamers +(def work_disclamers (List Text) (list "free of defects" "merchantable" "fit for a particular purpose" "non-infringing")) -(def: fixes +(def fixes (List Text) (list "servicing" "repair" "correction")) -(def: .public warranty +(def .public warranty (let [on_basics (let [applicability_escape "Unless required by applicable law or agreed to in writing" work_provisioning (format _.licensor " provides " _.licensed_work @@ -60,7 +60,7 @@ on_importance on_authorization)))) -(def: damage_types +(def damage_types (List Text) (list "direct" "indirect" @@ -68,7 +68,7 @@ "incidental" "consequential")) -(def: damage_consequences +(def damage_consequences (List Text) (list "lost profits" "loss of goodwill" @@ -76,7 +76,7 @@ "computer failure or malfunction" "any and all other commercial damages or losses")) -(def: .public limitation +(def .public limitation (let [on_limit (let [exclusion "Under no circumstances and under no legal theory" examples "whether tort (including negligence), contract, or otherwise" applicable_law_exception "unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing" @@ -92,7 +92,7 @@ on_death_exception on_jurisdictions)))) -(def: .public litigation +(def .public litigation (let [on_jurisdiction (format "Any litigation relating to " _.license " may be brought only in the courts of a jurisdiction where the defendant maintains its principal place of business") on_laws "Such litigation shall be governed by laws of that jurisdiction, without reference to its conflict-of-law provisions" on_claims "Nothing in this section shall prevent a party’s ability to bring cross-claims or counter-claims"] @@ -100,7 +100,7 @@ on_laws on_claims)))) -(def: liability_obligations +(def liability_obligations (List Text) (list "support" "warranty" @@ -108,7 +108,7 @@ "other liability obligations" (format "rights consistent with " _.license))) -(def: .public can_accept +(def .public can_accept (let [on_acceptance_of_liability (let [condition (format "While redistributing " _.licensed_work " or " ($.plural _.extension) " thereof") right (format _.recipient " may choose to offer, and charge a fee for, acceptance of " ($.and/or ..liability_obligations))] (format condition ", " right)) @@ -130,7 +130,7 @@ ($.paragraph (list on_acceptance_of_liability on_responsibility)))) -(def: .public disclaim_high_risk +(def .public disclaim_high_risk (let [on_work (let [intentions (is (List Text) (list "designed" "manufactured" diff --git a/licentia/source/program/licentia/license/limitation.lux b/licentia/source/program/licentia/license/limitation.lux index 9429874e8..741ebbb61 100644 --- a/licentia/source/program/licentia/license/limitation.lux +++ b/licentia/source/program/licentia/license/limitation.lux @@ -9,7 +9,7 @@ [// ["$" document]]]) -(def: .public acceptance +(def .public acceptance (let [abilities (is (List Text) (list "use" "copy" @@ -47,7 +47,7 @@ prohibition_due_to_non_agreement prohibition_due_to_impossibility)))) -(def: .public grant +(def .public grant ($.paragraph (list (format "The licenses granted in this document are the only rights granted under " _.license) (format "No additional rights or licenses will be implied from the distribution or licensing of " _.licensed_work " under " _.license) @@ -55,7 +55,7 @@ " for any code that the " _.contributor " has removed from " _.licensed_work)))) -(def: identifiers +(def identifiers (List Text) (list "trade names" "trademarks" @@ -63,13 +63,13 @@ "product names" "logos")) -(def: .public trademark +(def .public trademark ($.paragraph (list (format _.license " does not grant any permission to use the " ($.or ..identifiers) " of any " _.contributor "; except as required for reasonable and customary use in describing the origin of " _.licensed_work)))) -(def: .public secondary_licenses +(def .public secondary_licenses ($.paragraph (list (format "No " _.contributor " makes additional grants as a result of a choice by " _.recipient " to distribute " _.licensed_work diff --git a/licentia/source/program/licentia/license/miscellaneous.lux b/licentia/source/program/licentia/license/miscellaneous.lux index 8e5dcf0b3..18041be49 100644 --- a/licentia/source/program/licentia/license/miscellaneous.lux +++ b/licentia/source/program/licentia/license/miscellaneous.lux @@ -9,10 +9,10 @@ [// ["$" document]]]) -(def: .public entire_agreement +(def .public entire_agreement ($.paragraph (list (format _.license " constitutes the entire agreement between the parties with respect to the subject matter hereof")))) -(def: .public relationship_of_parties +(def .public relationship_of_parties (let [legal_associations (is (List Text) (list "an agency" "a partnership" @@ -31,7 +31,7 @@ " will not represent to the contrary, whether " ($.or forms_of_representation))] ($.paragraph (list (format disclaimer " " scope ", and " constraint))))) -(def: .public independent_development +(def .public independent_development (let [actions (is (List Text) (list "acquire" "license" @@ -54,7 +54,7 @@ " that " _.recipient " may " ($.or actions)))))) -(def: .public not_waiver +(def .public not_waiver (let [culprits (format _.licensor " or any " _.contributor) duty (format "enforce any provision of " _.license) effect "a waiver of future enforcement of that or any other provision"] @@ -62,14 +62,14 @@ " to " duty " will not be deemed " effect))))) -(def: .public severability +(def .public severability (let [on_reformation (format "If any provision of " _.license " is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable") on_contributor_protection (format "Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe " _.license " against a " _.contributor)] ($.paragraph (list on_reformation on_contributor_protection)))) -(def: .public export_restrictions +(def .public export_restrictions (let [limiter "applicable laws and regulations" limited (is (List Text) (list "downloading" @@ -87,7 +87,7 @@ ($.paragraph (list on_circumstances on_acceptance_of_responsibility)))) -(def: .public new_versions +(def .public new_versions (let [on_publishing (let [when ", from time to time," what (format "revised versions of " _.license)] (format _.licensor " may publish" when " " what)) diff --git a/licentia/source/program/licentia/license/notice.lux b/licentia/source/program/licentia/license/notice.lux index ed336e6f6..67b0c3f41 100644 --- a/licentia/source/program/licentia/license/notice.lux +++ b/licentia/source/program/licentia/license/notice.lux @@ -16,10 +16,10 @@ [// ["$" document]]]) -(def: .public end_of_license +(def .public end_of_license ($.sentence "END OF TERMS AND CONDITIONS")) -(def: .public (copyright_holder holder) +(def .public (copyright_holder holder) (-> //copyright.Holder Text) (let [(open "[0]") (the //copyright.#period holder) single_year? (n.= start end) @@ -28,7 +28,7 @@ (format (%.nat start) "-" (%.nat end)))] (format "Copyright (C) " period_section " " (the //copyright.#name holder)))) -(def: .public copyright +(def .public copyright (-> (List //copyright.Holder) Text) (|>> (list#each ..copyright_holder) (text.interposed text.new_line))) diff --git a/licentia/source/program/licentia/license/submission.lux b/licentia/source/program/licentia/license/submission.lux index ff4f12008..48245707e 100644 --- a/licentia/source/program/licentia/license/submission.lux +++ b/licentia/source/program/licentia/license/submission.lux @@ -9,7 +9,7 @@ [// ["$" document]]]) -(def: .public contribution +(def .public contribution (let [on-submissions (let [exception (format "Unless " _.recipient " explicitly states otherwise") general-case (format "any intentional " _.submission " of a " _.contribution " for inclusion in " _.licensed_work diff --git a/licentia/source/program/licentia/license/term.lux b/licentia/source/program/licentia/license/term.lux index 55aee7bae..c1925b02c 100644 --- a/licentia/source/program/licentia/license/term.lux +++ b/licentia/source/program/licentia/license/term.lux @@ -5,7 +5,7 @@ ["[1][0]" definition]]) (with_template [<term> <definition>] - [(def: .public <term> + [(def .public <term> Text (the //definition.#term <definition>))] diff --git a/licentia/source/program/licentia/output.lux b/licentia/source/program/licentia/output.lux index 9494d1428..d36a6d900 100644 --- a/licentia/source/program/licentia/output.lux +++ b/licentia/source/program/licentia/output.lux @@ -36,16 +36,16 @@ ["[0]" addendum]] ["$" document]]) -(def: .public (definition value) +(def .public (definition value) (-> Definition Text) (format ($.quote (the definition.#term value)) ": " (the definition.#meaning value))) -(def: .public (identification value) +(def .public (identification value) (-> Identification Text) (format (the license.#name value) text.new_line (the license.#version value))) -(def: .public (grant termination) +(def .public (grant termination) (-> Termination Text) (`` (format (~~ (with_template [<title> <content>] [($.block ($.section [#$.title <title> @@ -67,7 +67,7 @@ ["No Retroactive Effect of Termination" grant.no_retroactive_termination]))))) -(def: .public limitation +(def .public limitation Text (`` (format (~~ (with_template [<title> <content>] [($.block ($.section [#$.title <title> @@ -82,7 +82,7 @@ [(format "Limitations on " ($.plural _.secondary_license)) limitation.secondary_licenses]))))) -(def: .public assurance +(def .public assurance Text (`` (format (~~ (with_template [<title> <content>] [($.block ($.section [#$.title <title> @@ -94,7 +94,7 @@ ["Fair Use" assurance.fair_use]))))) -(def: .public (liability value) +(def .public (liability value) (-> Liability Text) (`` (format (~~ (with_template [<title> <condition> <content>] [(if <condition> @@ -122,7 +122,7 @@ (the license.#disclaim_high_risk? value) liability.disclaim_high_risk]))))) -(def: .public (distribution distribution) +(def .public (distribution distribution) (-> Distribution Text) (`` (format (~~ (with_template [<title> <condition> <content>] [(if <condition> @@ -143,7 +143,7 @@ (the license.#can_multi_license? distribution)) (distribution.extension distribution)]))))) -(def: .public (commercial value) +(def .public (commercial value) (-> Commercial Text) (`` (format (~~ (with_template [<title> <condition> <content>] [(if <condition> @@ -164,7 +164,7 @@ commercial.disallow_contributor_endorsement] ))))) -(def: .public (extension value) +(def .public (extension value) (-> Extension Text) (let [[show? document] (case (the license.#notification_period value) {.#Some period} @@ -191,7 +191,7 @@ [(the license.#must_describe_modifications? value) (format "Description of " ($.plural _.modification)) extension.description_requirement])))))) -(def: .public (attribution value) +(def .public (attribution value) (-> Attribution Text) (let [copyright_notice (format "Attribution Copyright Notice: " (the license.#copyright_notice value)) phrase (case (the license.#phrase value) @@ -212,7 +212,7 @@ url image))) -(def: .public (miscellaneous identified?) +(def .public (miscellaneous identified?) (-> Bit Text) (`` (format (~~ (with_template [<title> <condition> <content>] [(if <condition> @@ -249,9 +249,9 @@ miscellaneous.new_versions] ))))) -(def: black_list_spacing (format text.new_line text.new_line)) +(def black_list_spacing (format text.new_line text.new_line)) -(def: .public (license value) +(def .public (license value) (-> License Text) (let [identification (|> value (the license.#identification) diff --git a/licentia/source/test/licentia.lux b/licentia/source/test/licentia.lux index a76149e42..c063260ae 100644 --- a/licentia/source/test/licentia.lux +++ b/licentia/source/test/licentia.lux @@ -44,7 +44,7 @@ ["[0]" black_list] ["[0]" addendum]]]) -(def: period +(def period (Random (Period Nat)) (do [! random.monad] [start (random.filter (|>> (n.= n#top) not) @@ -56,45 +56,45 @@ (wrap [time.#start start time.#end end]))) -(def: copyright_holder +(def copyright_holder (Random copyright.Holder) (all random.and (random.ascii 10) ..period)) -(def: identification +(def identification (Random Identification) (all random.and (random.ascii 10) (random.ascii 10))) -(def: termination +(def termination (Random Termination) (all random.and random.bit random.nat random.nat)) -(def: liability +(def liability (Random Liability) (all random.and random.bit random.bit)) -(def: distribution +(def distribution (Random Distribution) (all random.and random.bit random.bit)) -(def: commercial +(def commercial (Random Commercial) (all random.and random.bit random.bit random.bit)) -(def: extension +(def extension (Random Extension) (all random.and random.bit @@ -102,28 +102,28 @@ (random.maybe ..period) random.bit)) -(def: entity +(def entity (Random Entity) (random.ascii 10)) -(def: (variable_list max_size gen_element) +(def (variable_list max_size gen_element) (All (_ a) (-> Nat (Random a) (Random (List a)))) (do [! random.monad] [amount (at ! each (n.% (n.max 1 max_size)) random.nat)] (random.list amount gen_element))) -(def: black_list +(def black_list (Random Black_List) (all random.and (random.maybe (random.ascii 10)) (variable_list 10 ..entity))) -(def: url +(def url (Random URL) (random.ascii 10)) -(def: attribution +(def attribution (Random Attribution) (all random.and (random.ascii 10) @@ -131,13 +131,13 @@ ..url (random.maybe ..url))) -(def: addendum +(def addendum (Random Addendum) (all random.and random.bit )) -(def: license +(def license (Random License) (all random.and (random.list 2 ..copyright_holder) @@ -155,7 +155,7 @@ (type: (Concern a) (-> (-> Text Bit) a Test)) -(def: (about_grant present? termination) +(def (about_grant present? termination) (Concern Termination) (all _.and (_.property "Copyright grant is present." @@ -175,7 +175,7 @@ (present? grant.no_retroactive_termination)) )) -(def: (about_liability present? liability) +(def (about_liability present? liability) (Concern Liability) (all _.and (_.property "Warranty liability disclaimer is present." @@ -192,7 +192,7 @@ (present? liability.disclaim_high_risk))) )) -(def: (about_distribution present? distribution) +(def (about_distribution present? distribution) (Concern Distribution) (all _.and (_.property "Conditions for source-code distribution are present." @@ -203,7 +203,7 @@ (present? (distribution.extension distribution))) )) -(def: (about_commercial present? commercial) +(def (about_commercial present? commercial) (Concern Commercial) (all _.and (_.property "Non-commercial clause is present." @@ -217,7 +217,7 @@ (present? commercial.disallow_contributor_endorsement))) )) -(def: (about_extension present? extension) +(def (about_extension present? extension) (Concern Extension) (all _.and (_.property "The license is viral." @@ -239,7 +239,7 @@ (present? extension.description_requirement))) )) -(def: (about_attribution present? attribution) +(def (about_attribution present? attribution) (Concern Attribution) (all _.and (_.property "The attribution copyright notice is present." @@ -258,7 +258,7 @@ (maybe.default true))) )) -(def: (about_miscellaneous present?) +(def (about_miscellaneous present?) (-> (-> Text Bit) Test) (all _.and (_.property "License constitutes the entire agreement." @@ -275,7 +275,7 @@ (present? miscellaneous.export_restrictions)) )) -(def: (about_addendum present? value) +(def (about_addendum present? value) (Concern Addendum) (all _.and (_.property "Commons clause" @@ -283,7 +283,7 @@ (present? addendum.commons_clause))) )) -(def: test +(def test Test (do random.monad [license ..license diff --git a/lux-cl/source/program.lux b/lux-cl/source/program.lux index d61caab05..03791e037 100644 --- a/lux-cl/source/program.lux +++ b/lux-cl/source/program.lux @@ -162,12 +162,12 @@ [cannot_apply_a_non_function] ) -(def: host_bit +(def host_bit (-> Bit org/armedbear/lisp/LispObject) (|>> (pipe.case #0 (org/armedbear/lisp/Nil::NIL) #1 (org/armedbear/lisp/Symbol::T)))) -(def: (host_value value) +(def (host_value value) (-> Any org/armedbear/lisp/LispObject) (let [to_sub (is (-> Any org/armedbear/lisp/LispObject) (function (_ sub_value) @@ -223,7 +223,7 @@ (type: (Reader a) (-> a (Try Any))) -(def: (read_variant read host_object) +(def (read_variant read host_object) (-> (Reader org/armedbear/lisp/LispObject) (Reader org/armedbear/lisp/Cons)) (do try.monad [tag (read (org/armedbear/lisp/LispObject::NTH +0 host_object)) @@ -237,7 +237,7 @@ (is Any synthesis.unit)) value]))) -(def: (read_tuple read host_object) +(def (read_tuple read host_object) (-> (Reader org/armedbear/lisp/LispObject) (Reader org/armedbear/lisp/SimpleVector)) (let [size (.nat (org/armedbear/lisp/LispObject::length host_object))] (loop (again [idx 0 @@ -252,7 +252,7 @@ (again (++ idx) (array.write! idx (as Any member) output))) {try.#Success output})))) -(def: (read host_object) +(def (read host_object) (Reader org/armedbear/lisp/LispObject) (`` (<| (~~ (with_template [<class> <post_processing>] [(case (ffi.is <class> host_object) @@ -281,18 +281,18 @@ (exception.throw ..unknown_kind_of_object (as java/lang/Object host_object)) ))) -(def: ensure_macro +(def ensure_macro (-> Macro (Maybe org/armedbear/lisp/Closure)) (|>> (as java/lang/Object) (ffi.is org/armedbear/lisp/Closure))) -(def: (call_macro inputs lux macro) +(def (call_macro inputs lux macro) (-> (List Code) Lux org/armedbear/lisp/Closure (Try (Try [Lux (List Code)]))) (do try.monad [raw_output (org/armedbear/lisp/LispObject::execute (..host_value inputs) (..host_value lux) macro)] (as (Try (Try [Lux (List Code)])) (..read raw_output)))) -(def: (expander macro inputs lux) +(def (expander macro inputs lux) Expander (case (ensure_macro macro) {.#Some macro} @@ -301,7 +301,7 @@ {.#None} (exception.throw ..cannot_apply_a_non_function (as java/lang/Object macro)))) -(def: host +(def host (IO (Host (_.Expression Any) (_.Expression Any))) (io (let [_ (org/armedbear/lisp/Interpreter::createInstance) interpreter (org/armedbear/lisp/Interpreter::getInstance) @@ -312,13 +312,13 @@ (read host_value))))] (is (Host (_.Expression Any) (_.Expression Any)) (structure - (def: (evaluate! context code) + (def (evaluate! context code) (run! code)) - (def: (execute! input) + (def (execute! input) (org/armedbear/lisp/Interpreter::eval (_.code input) interpreter)) - (def: (define! context input) + (def (define! context input) (let [global (reference.artifact context) @global (_.var global)] (do try.monad @@ -327,19 +327,19 @@ value (run! @global)] (wrap [global value definition])))) - (def: (ingest context content) + (def (ingest context content) (|> content (at encoding.utf8 decoded) try.trusted (as (_.Expression Any)))) - (def: (re_learn context content) + (def (re_learn context content) (run! content)) - (def: (re_load context content) + (def (re_load context content) (do try.monad [_ (run! content)] (run! (_.var (reference.artifact context))))) ))))) -(def: platform +(def platform (IO (Platform [_.Tag Register] (_.Expression Any) (_.Expression Any))) (do io.monad [host ..host] @@ -349,7 +349,7 @@ platform.#runtime runtime.generate platform.#write (|>> _.code (at encoding.utf8 encoded))]))) -(def: get_ecl_cli_inputs +(def get_ecl_cli_inputs (let [@idx (_.var "i")] (_.call/* (_.var "loop") (list (_.var "for") @idx @@ -357,7 +357,7 @@ (_.var "below") (_.call/* (_.var "si:argc") (list)) (_.var "collect") (_.call/* (_.var "si:argv") (list @idx)))))) -(def: (program context program) +(def (program context program) (Program (_.Expression Any) (_.Expression Any)) (let [raw_inputs (_.progn (list (_.conditional+ (list "clisp") (_.var "ext:*args*")) (_.conditional+ (list "sbcl") (_.var "sb-ext:*posix-argv*")) @@ -371,7 +371,7 @@ (_.call/2 [(runtime.lux//program_args raw_inputs) _.nil] program))) (for @.old - (def: extender + (def extender Extender ... TODO: Stop relying on coercions ASAP. (<| (as Extender) @@ -390,21 +390,21 @@ {try.#Failure "TODO: Extender"}))) @.common_lisp - (def: (extender handler) + (def (extender handler) Extender (as_expected handler))) -(def: (declare_success! _) +(def (declare_success! _) (-> Any (Promise Any)) (promise.future (at world/program.default exit +0))) -(def: (then pre post) +(def (then pre post) (-> (_.Expression Any) (_.Expression Any) (_.Expression Any)) (_.manual (format (_.code pre) text.new_line (_.code post)))) -(def: (scope body) +(def (scope body) (-> (_.Expression Any) (_.Expression Any)) (let [@program (_.var "lux_program")] (all ..then diff --git a/lux-js/source/program.lux b/lux-js/source/program.lux index 52f5d49ef..ad1f53ba3 100644 --- a/lux-js/source/program.lux +++ b/lux-js/source/program.lux @@ -158,13 +158,13 @@ "Member" member "Object" (debug.inspection object))) - (def: jvm_int + (def jvm_int (-> (I64 Any) java/lang/Integer) (|>> .int ffi.as_long java/lang/Long::intValue)) - (def: (js_int value) + (def (js_int value) (-> Int org/openjdk/nashorn/api/scripting/JSObject) (<| (ffi.is org/openjdk/nashorn/api/scripting/JSObject) (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [IntValue] @@ -189,7 +189,7 @@ (ffi.is java/lang/Object (ffi.as_long value))])))) ))) - (def: (::toString js_object) + (def (::toString js_object) (-> Any org/openjdk/nashorn/api/scripting/JSObject) (<| (ffi.is org/openjdk/nashorn/api/scripting/JSObject) (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [] @@ -207,7 +207,7 @@ (ffi.is java/lang/Object))) ))) - (def: (::slice js_object value) + (def (::slice js_object value) (-> (-> java/lang/Object org/openjdk/nashorn/api/scripting/JSObject) (Array java/lang/Object) org/openjdk/nashorn/api/scripting/JSObject) (<| (ffi.is org/openjdk/nashorn/api/scripting/JSObject) (ffi.object [] org/openjdk/nashorn/api/scripting/AbstractJSObject [] @@ -231,7 +231,7 @@ (ffi.is java/lang/Object))) ))) - (def: (js_structure value) + (def (js_structure value) (-> (Array java/lang/Object) org/openjdk/nashorn/api/scripting/JSObject) (let [js_object (is (-> java/lang/Object org/openjdk/nashorn/api/scripting/JSObject) (function (_ sub_value) @@ -323,7 +323,7 @@ {.#None} "???"))) - (def: (i32 half i64) + (def (i32 half i64) (-> Text org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe Int)) (|> i64 (org/openjdk/nashorn/api/scripting/JSObject::getMember [(ffi.as_string half)]) @@ -331,7 +331,7 @@ maybe#conjoint (maybe#each (|>> java/lang/Number::longValue ffi.of_long)))) - (def: (check_int js_object) + (def (check_int js_object) (-> org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe Int)) (case [(..i32 runtime.i64_high_field js_object) @@ -345,7 +345,7 @@ _ {.#None})) - (def: (check_variant lux_object js_object) + (def (check_variant lux_object js_object) (-> (-> java/lang/Object (Try Any)) org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe Any)) @@ -362,7 +362,7 @@ _ {.#None})) - (def: (check_tuple lux_object js_object) + (def (check_tuple lux_object js_object) (-> (-> java/lang/Object (Try Any)) org/openjdk/nashorn/api/scripting/ScriptObjectMirror (Maybe (Array java/lang/Object))) @@ -391,7 +391,7 @@ {.#Some output}))) {.#None})) - (def: (lux_object js_object) + (def (lux_object js_object) (-> java/lang/Object (Try Any)) (`` (<| (if (ffi.null? js_object) (exception.except ..null_has_no_lux_representation [{.#None}])) @@ -446,7 +446,7 @@ {try.#Success js_object} ))) - (def: (ensure_function function) + (def (ensure_function function) (-> Any (Maybe org/openjdk/nashorn/api/scripting/JSObject)) (do maybe.monad [function (|> function @@ -461,7 +461,7 @@ (these)) (for @.jvm - (these (def: (call_macro inputs lux macro) + (these (def (call_macro inputs lux macro) (-> (List Code) Lux org/openjdk/nashorn/api/scripting/JSObject (Try (Try [Lux (List Code)]))) (let [to_js (is (-> Any java/lang/Object) (|>> (as (Array java/lang/Object)) js_structure (as java/lang/Object)))] @@ -477,7 +477,7 @@ (exception.report "Object" (ffi.of_string (java/lang/Object::toString object)))) - (def: (expander macro inputs lux) + (def (expander macro inputs lux) Expander (case (..ensure_function macro) {.#Some macro} @@ -496,13 +496,13 @@ ) @.js - (def: (expander macro inputs lux) + (def (expander macro inputs lux) Expander {try.#Success ((as Macro' macro) inputs lux)}) ) (for @.jvm - (these (def: (evaluate! interpreter alias input) + (these (def (evaluate! interpreter alias input) (-> javax/script/ScriptEngine unit.ID _.Expression (Try Any)) (do try.monad [?output (javax/script/ScriptEngine::eval (ffi.as_string (_.code input)) interpreter)] @@ -513,13 +513,13 @@ {.#None} (exception.except ..null_has_no_lux_representation [{.#Some input}])))) - (def: (execute! interpreter input) + (def (execute! interpreter input) (-> javax/script/ScriptEngine _.Statement (Try Any)) (do try.monad [?output (javax/script/ScriptEngine::eval (ffi.as_string (_.code input)) interpreter)] (in []))) - (def: (define! interpreter context custom input) + (def (define! interpreter context custom input) (-> javax/script/ScriptEngine unit.ID (Maybe Text) _.Expression (Try [Text Any _.Statement])) (let [global (maybe.else (reference.artifact context) custom) @@ -530,30 +530,30 @@ value (evaluate! interpreter context @global)] (in [global value definition])))) - (def: host + (def host (IO (Host _.Expression _.Statement)) (io (let [interpreter (javax/script/ScriptEngineFactory::getScriptEngine (org/openjdk/nashorn/api/scripting/NashornScriptEngineFactory::new))] (is (Host _.Expression _.Statement) (implementation - (def: (evaluate alias [_ input]) (..evaluate! interpreter alias input)) - (def: execute (..execute! interpreter)) - (def: (define context custom [_ input]) (..define! interpreter context custom input)) + (def (evaluate alias [_ input]) (..evaluate! interpreter alias input)) + (def execute (..execute! interpreter)) + (def (define context custom [_ input]) (..define! interpreter context custom input)) - (def: (ingest context content) + (def (ingest context content) (|> content (at utf8.codec decoded) try.trusted (as _.Statement))) - (def: (re_learn context custom content) + (def (re_learn context custom content) (..execute! interpreter content)) - (def: (re_load context custom content) + (def (re_load context custom content) (do try.monad [_ (..execute! interpreter content)] (..evaluate! interpreter context (_.var (reference.artifact context)))))))))) ) @.js - (these (def: (eval code) + (these (def (eval code) (-> Text (Try (Maybe Any))) ... Note: I have to call "eval" this way ... in order to avoid a quirk of calling eval in Node @@ -563,7 +563,7 @@ {.#None} {.#Some return})))) - (def: (evaluate! alias input) + (def (evaluate! alias input) (-> unit.ID _.Expression (Try Any)) (do try.monad [?output (..eval (_.code input))] @@ -574,13 +574,13 @@ {.#None} (exception.except ..null_has_no_lux_representation [{.#Some input}])))) - (def: (execute! input) + (def (execute! input) (-> _.Statement (Try Any)) (do try.monad [?output (..eval (_.code input))] (in []))) - (def: (define! context custom input) + (def (define! context custom input) (-> unit.ID (Maybe Text) _.Expression (Try [Text Any _.Statement])) (let [global (maybe.else (reference.artifact context) custom) @@ -591,27 +591,27 @@ value (..evaluate! context @global)] (in [global value definition])))) - (def: host + (def host (IO (Host _.Expression _.Statement)) (io (is (Host _.Expression _.Statement) (implementation - (def: (evaluate alias [_ input]) (..evaluate! alias input)) - (def: execute ..execute!) - (def: (define context custom [_ input]) (..define! context custom input)) + (def (evaluate alias [_ input]) (..evaluate! alias input)) + (def execute ..execute!) + (def (define context custom [_ input]) (..define! context custom input)) - (def: (ingest context content) + (def (ingest context content) (|> content (at utf8.codec decoded) try.trusted (as _.Statement))) - (def: (re_learn context custom content) + (def (re_learn context custom content) (..execute! content)) - (def: (re_load context custom content) + (def (re_load context custom content) (do try.monad [_ (..execute! content)] (..evaluate! context (_.var (reference.artifact context))))))))) )) -(def: (phase_wrapper archive) +(def (phase_wrapper archive) (-> Archive (runtime.Operation phase.Wrapper)) (do phase.monad [] @@ -627,7 +627,7 @@ @.js (|>>)))))) -(def: platform +(def platform (IO (Platform [Register Text] _.Expression _.Statement)) (do io.monad [host ..host] @@ -642,7 +642,7 @@ platform.#phase_wrapper ..phase_wrapper platform.#write (|>> _.code (at utf8.codec encoded))]))) -(def: (program context program) +(def (program context program) (Program _.Expression _.Statement) (let [@process (_.var "process") on_node_js? (|> @process @@ -660,7 +660,7 @@ (_.string ""))))) (for @.jvm - (def: (extender phase_wrapper) + (def (extender phase_wrapper) (-> phase.Wrapper Extender) ... TODO: Stop relying on coercions ASAP. (<| (as Extender) @@ -690,20 +690,20 @@ (lux_object (as java/lang/Object output))))) @.js - (def: (extender phase_wrapper handler) + (def (extender phase_wrapper handler) (-> phase.Wrapper Extender) (as_expected handler))) -(def: (declare_success! _) +(def (declare_success! _) (-> Any (Async Any)) (async.future (at world/program.default exit +0))) -(def: (scope body) +(def (scope body) (-> _.Statement _.Statement) (_.statement (_.apply (_.closure (list) body) (list)))) -(def: (lux_compiler it) +(def (lux_compiler it) (-> Any platform.Custom) (undefined)) diff --git a/lux-jvm/source/program.lux b/lux-jvm/source/program.lux index ff268327f..32c508c59 100644 --- a/lux-jvm/source/program.lux +++ b/lux-jvm/source/program.lux @@ -72,17 +72,17 @@ "[1]::[0]" (getClass [] (java/lang/Class java/lang/Object))) -(def: _object_class +(def _object_class (java/lang/Class java/lang/Object) (ffi.class_for java/lang/Object)) -(def: _apply2_args +(def _apply2_args (Array (java/lang/Class java/lang/Object)) (|> (ffi.array (java/lang/Class java/lang/Object) 2) (ffi.write! 0 _object_class) (ffi.write! 1 _object_class))) -(def: _apply5_args +(def _apply5_args (Array (java/lang/Class java/lang/Object)) (|> (ffi.array (java/lang/Class java/lang/Object) 5) (ffi.write! 0 _object_class) @@ -91,7 +91,7 @@ (ffi.write! 3 _object_class) (ffi.write! 4 _object_class))) -(def: .public (expander macro inputs lux) +(def .public (expander macro inputs lux) Expander (do try.monad [apply_method (|> macro @@ -106,11 +106,11 @@ (ffi.write! 1 (as java/lang/Object lux))) apply_method)))) -(def: (phase_wrapper archive) +(def (phase_wrapper archive) (-> Archive (Operation Anchor (Bytecode Any) Definition phase.Wrapper)) (at phase.monad in (|>>))) -(def: .public platform +(def .public platform (IO [java/lang/ClassLoader /runtime.Host (Platform Anchor (Bytecode Any) Definition)]) @@ -127,7 +127,7 @@ platform.#phase_wrapper ..phase_wrapper platform.#write product.right]]))) -(def: (extender phase_wrapper) +(def (extender phase_wrapper) (-> phase.Wrapper extension.Extender) ... TODO: Stop relying on coercions ASAP. (<| (as extension.Extender) @@ -156,11 +156,11 @@ (ffi.write! 4 (as java/lang/Object state))) method)))) -(def: (declare_success! _) +(def (declare_success! _) (-> Any (Async Any)) (async.future (at world/program.default exit +0))) -(def: (lux_compiler it) +(def (lux_compiler it) (-> Any platform.Custom) (as_expected it)) diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux index 7a2f2712e..152d4d3e5 100644 --- a/lux-lua/source/program.lux +++ b/lux-lua/source/program.lux @@ -182,7 +182,7 @@ (type: Translator (-> java/lang/Object (Try Any))) - (def: (read_variant read host_object) + (def (read_variant read host_object) (-> Translator net/sandius/rembulan/impl/DefaultTable (Try Any)) (case [(net/sandius/rembulan/Table::get_key (as java/lang/Object runtime.variant_tag_field) host_object) (net/sandius/rembulan/Table::get_key (as java/lang/Object runtime.variant_flag_field) host_object) @@ -203,7 +203,7 @@ _ (exception.except ..unknown_kind_of_object [(as java/lang/Object host_object)]))) - (def: (read_tuple read host_object) + (def (read_tuple read host_object) (-> Translator net/sandius/rembulan/impl/DefaultTable (Try Any)) (let [init_num_keys (.nat (ffi.of_long (net/sandius/rembulan/Table::rawlen host_object)))] (loop (again [num_keys init_num_keys @@ -226,7 +226,7 @@ (exception: .public nil_has_no_lux_representation) - (def: (read host_object) + (def (read host_object) Translator (`` (<| (if (ffi.null? host_object) (exception.except ..nil_has_no_lux_representation [])) @@ -258,37 +258,37 @@ (exception.except ..unknown_kind_of_object [host_object]) ))) - (def: (return ec value) + (def (return ec value) (-> net/sandius/rembulan/runtime/ExecutionContext Any Any) (|> ec net/sandius/rembulan/runtime/ExecutionContext::getReturnBuffer (net/sandius/rembulan/runtime/ReturnBuffer::setTo (as java/lang/Object value)))) - (def: (function/* arity) + (def (function/* arity) (-> Nat Code) (` (.-> (~+ (list.repeated arity (` .Any))) .Any))) - (def: input/* + (def input/* (-> Nat (List Code)) (|>> list.indices (list#each (|>> %.nat (format "input/") code.local)))) - (def: declaration/* + (def declaration/* (-> Nat (List Code)) (|>> ..input/* (list#each (function (_ $input) (list $input (' java/lang/Object)))) list#conjoint)) - (def: read/* + (def read/* (-> Nat (List Code)) (|>> ..input/* (list#each (function (_ $input) (list $input (` (..read (~ $input)))))) list#conjoint)) - (def: (apply/* to_host self parameters abstraction) + (def (apply/* to_host self parameters abstraction) (-> (-> Any java/lang/Object) net/sandius/rembulan/runtime/LuaFunction (List java/lang/Object) Any Any) (<| try.trusted (do [! try.monad] @@ -319,7 +319,7 @@ input/+) ))))))) - (def: (lua_function to_host lux_function) + (def (lua_function to_host lux_function) (-> (-> Any java/lang/Object) Any net/sandius/rembulan/runtime/LuaFunction) (<| (as net/sandius/rembulan/runtime/LuaFunction) (`` (`` (ffi.object [] net/sandius/rembulan/runtime/LuaFunction [LuxValue] @@ -370,7 +370,7 @@ (ffi.import library/lux/Function "[1]::[0]") - (def: (lux_structure to_host value) + (def (lux_structure to_host value) (-> (-> Any java/lang/Object) (Array java/lang/Object) LuxValue) (<| (ffi.is LuxValue) (ffi.object [] net/sandius/rembulan/impl/DefaultTable [LuxValue] @@ -449,7 +449,7 @@ (exception.report "Non-function" (ffi.of_string (java/lang/Object::toString object)))) - (def: ensure_function + (def ensure_function (-> Macro (Maybe net/sandius/rembulan/runtime/LuaFunction)) (|>> (as java/lang/Object) (ffi.as net/sandius/rembulan/runtime/LuaFunction))) @@ -458,7 +458,7 @@ [net/sandius/rembulan/StateContext net/sandius/rembulan/exec/DirectCallExecutor]) - (def: (call_macro to_host [state_context executor] inputs lux macro) + (def (call_macro to_host [state_context executor] inputs lux macro) (-> (-> Any java/lang/Object) Baggage (List Code) Lux net/sandius/rembulan/runtime/LuaFunction (Try Any)) (do try.monad [.let [inputs (is (ffi.type [java/lang/Object]) @@ -476,7 +476,7 @@ (as java/lang/Object) ..read))) - (def: (expander to_host baggage macro inputs lux) + (def (expander to_host baggage macro inputs lux) (-> (-> Any java/lang/Object) Baggage Expander) (case (..ensure_function macro) {.#Some macro} @@ -495,7 +495,7 @@ @.jvm (these <jvm>) @.lua - (def: (expander macro inputs lux) + (def (expander macro inputs lux) Expander {try.#Success ((as Macro' macro) inputs lux)}))) @@ -513,7 +513,7 @@ (_.bit_shr (_.int <shift>)) (_.bit_and (!int <and>)) (_.bit_or (!int <or>)))])] - (these (def: rembulan//char + (these (def rembulan//char (let [$buffer (_.var "buffer") $k (_.var "k") $v (_.var "v") @@ -562,7 +562,7 @@ (_.return (_.apply (list $buffer (_.string "")) (_.var "table.concat"))) )))) - ... (def: rembulan//str_rel_to_abs + ... (def rembulan//str_rel_to_abs ... (let [$string (_.var "string") ... $args (_.var "args") ... $k (_.var "k") @@ -582,7 +582,7 @@ ... (_.return (_.apply (list $args) (_.var "table.unpack"))) ... )))) - ... (def: rembulan//decode + ... (def rembulan//decode ... (let [$string (_.var "string") ... $start (_.var "start") ... $b1 (_.var "b1") @@ -619,7 +619,7 @@ ... )) ... )))) - ... (def: rembulan//codes + ... (def rembulan//codes ... (let [$string (_.var "string") ... $i (_.var "i") ... $start (_.var "start") @@ -641,7 +641,7 @@ ... )))) ... )))) - ... (def: rembulan//len + ... (def rembulan//len ... (let [$string (_.var "string") ... $start (_.var "start") ... $end (_.var "_end") @@ -666,11 +666,11 @@ ... (_.return $size) ... )))) - ... (def: rembulan//charpattern + ... (def rembulan//charpattern ... (_.set (list (_.var "utf8.charpattern")) ... (_.string "[%z\x01-\x7F\xC2-\xF4][\x80-\xBF]*"))) - (def: rembulan_prelude + (def rembulan_prelude _.Statement (all _.then (_.function (_.var "os.time") (list) @@ -685,7 +685,7 @@ ... ..rembulan//charpattern ))))) - (def: host + (def host (IO [Baggage (Host _.Expression _.Statement)]) (io (let [runtime_env (net/sandius/rembulan/env/RuntimeEnvironments::system) std_lib (net/sandius/rembulan/lib/StandardLibrary::in runtime_env) @@ -711,12 +711,12 @@ [[state_context executor] (is (Host _.Expression _.Statement) (implementation - (def: (evaluate context [_ code]) + (def (evaluate context [_ code]) (run! (_.return code))) - (def: execute run!) + (def execute run!) - (def: (define context custom [_ input]) + (def (define context custom [_ input]) (let [global (maybe.else (reference.artifact context) custom) @global (_.var global) @@ -726,23 +726,23 @@ value (run! (_.return @global))] (in [global value definition])))) - (def: (ingest context content) + (def (ingest context content) (|> content (at utf8.codec decoded) try.trusted (as _.Statement))) - (def: (re_learn context custom content) + (def (re_learn context custom content) (run! content)) - (def: (re_load context custom content) + (def (re_load context custom content) (do try.monad [_ (run! content)] (run! (_.return (_.var (reference.artifact context))))))))]))))] (for @.old (these <jvm>) @.jvm (these <jvm>) @.lua (these (ffi.import (load [ffi.String] "try" ffi.Function)) - (def: host + (def host (IO (Host _.Expression _.Statement)) (io (let [run! (is (-> _.Statement (Try Any)) (function (_ code) @@ -754,12 +754,12 @@ output)}))))] (is (Host _.Expression _.Statement) (implementation - (def: (evaluate! context [_ code]) + (def (evaluate! context [_ code]) (run! (_.return code))) - (def: execute! run!) + (def execute! run!) - (def: (define! context custom [_ input]) + (def (define! context custom [_ input]) (let [global (maybe.else (reference.artifact context) custom) @global (_.var global)] @@ -769,18 +769,18 @@ value (run! (_.return @global))] (in [global value definition])))) - (def: (ingest context content) + (def (ingest context content) (|> content (at utf8.codec decoded) try.trusted (as _.Statement))) - (def: (re_learn context custom content) + (def (re_learn context custom content) (run! content)) - (def: (re_load context custom content) + (def (re_load context custom content) (do try.monad [_ (run! content)] (run! (_.return (_.var (reference.artifact context)))))))))))))) -(with_expansions [<jvm> (these (def: (to_host it) +(with_expansions [<jvm> (these (def (to_host it) (-> Any java/lang/Object) (`` (<| (~~ (with_template [<jvm> <lua>] [(case (ffi.as <jvm> (as java/lang/Object it)) @@ -795,7 +795,7 @@ )) (as java/lang/Object it)))) - (def: (extender [state_context executor] phase_wrapper) + (def (extender [state_context executor] phase_wrapper) (-> Baggage (-> phase.Wrapper Extender)) ... TODO: Stop relying on coercions ASAP. (<| (as Extender) @@ -829,11 +829,11 @@ @.jvm (these <jvm>) @.lua - (def: (extender phase_wrapper handler) + (def (extender phase_wrapper handler) (-> phase.Wrapper Extender) (as_expected handler)))) -(def: (phase_wrapper archive) +(def (phase_wrapper archive) (-> Archive (runtime.Operation phase.Wrapper)) (do phase.monad [] @@ -842,7 +842,7 @@ @.jvm (..lua_function ..to_host) @.lua (|>>)))))) -(with_expansions [<jvm> (def: platform +(with_expansions [<jvm> (def platform (IO [Baggage (Platform [Register _.Label] _.Expression _.Statement)]) (do io.monad [[baggage host] ..host] @@ -855,7 +855,7 @@ platform.#write (|>> _.code (at utf8.codec encoded))]])))] (for @.old <jvm> @.jvm <jvm> - @.lua (def: platform + @.lua (def platform (IO (Platform [Register _.Label] _.Expression _.Statement)) (do io.monad [host ..host] @@ -866,18 +866,18 @@ platform.#phase_wrapper ..phase_wrapper platform.#write (|>> _.code (at utf8.codec encoded))]))))) -(def: (program context program) +(def (program context program) (Program _.Expression _.Statement) (let [$program (_.var (reference.artifact context))] (_.statement (_.apply (list (runtime.lux//program_args (_.var "arg")) runtime.unit) program)))) -(def: (declare_success! _) +(def (declare_success! _) (-> Any (Async Any)) (async.future (at world/program.default exit +0))) -(def: (lux_compiler it) +(def (lux_compiler it) (-> Any platform.Custom) (undefined)) diff --git a/lux-mode/lux-mode.el b/lux-mode/lux-mode.el index bd14c16a2..c4ebcf170 100644 --- a/lux-mode/lux-mode.el +++ b/lux-mode/lux-mode.el @@ -395,7 +395,7 @@ Called by `imenu--generic-function'." (function-definition (altRE "function" "|>>" "<<|")) (remember (altRE "remember" "to_do" "fix_me")) (definition (altRE "\\.using" - "def:" "type:" "program:" "inline:" + "def" "inlined" "type:" "program:" "macro" "syntax" "exception:" "analysis" "synthesis" "generation" "directive"))) @@ -583,6 +583,8 @@ This function also returns nil meaning don't specify the indentation." ("template" 'defun) ("polytypic" 'defun) + ("def" 'defun) + ("inlined" 'defun) ("primitive" 'defun) ("analysis" 'defun) ("synthesis" 'defun) diff --git a/lux-php/source/program.lux b/lux-php/source/program.lux index 1e117c033..a1c6db4b7 100644 --- a/lux-php/source/program.lux +++ b/lux-php/source/program.lux @@ -185,7 +185,7 @@ "Class" (java/lang/Object::toString (java/lang/Object::getClass object)) "Object" (java/lang/Object::toString object))) -(def: (value_wrapper lux_structure value) +(def (value_wrapper lux_structure value) (-> (-> (Array java/lang/Object) php/runtime/Memory) java/lang/Object php/runtime/Memory) (<| (if (ffi.null? value) (php/runtime/memory/NullMemory::INSTANCE)) @@ -224,10 +224,10 @@ (undefined) )) -(def: unit +(def unit (php/runtime/memory/StringMemory::new "")) -(def: (lux_structure value) +(def (lux_structure value) (-> (Array java/lang/Object) php/runtime/Memory) (`` (ffi.object [] php/runtime/Memory [program/StructureValue] @@ -307,7 +307,7 @@ (undefined))) ))) -(def: (read_tuple read host_object) +(def (read_tuple read host_object) (-> Reader php/runtime/memory/ArrayMemory (Try Any)) (let [size (|> host_object php/runtime/memory/ArrayMemory::size @@ -334,16 +334,16 @@ error))) {try.#Success output})))) -(def: variant_tag_field +(def variant_tag_field (php/runtime/memory/StringMemory::new runtime.variant_tag_field)) -(def: variant_value_field +(def variant_value_field (php/runtime/memory/StringMemory::new runtime.variant_value_field)) -(def: variant_flag_field +(def variant_flag_field (php/runtime/memory/StringMemory::new runtime.variant_flag_field)) -(def: (read_variant read host_object) +(def (read_variant read host_object) (-> Reader php/runtime/memory/ArrayMemory (Try Any)) (case [(|> host_object (php/runtime/memory/ArrayMemory::get ..variant_tag_field) @@ -374,10 +374,10 @@ (exception: .public nulll_has_no_lux_representation) -(def: tuple_size_field +(def tuple_size_field (php/runtime/memory/StringMemory::new runtime.tuple_size_field)) -(def: (read host_object) +(def (read host_object) Reader (`` (<| (~~ (with_template [<class> <constant>] [(case (ffi.as <class> host_object) @@ -428,16 +428,16 @@ "[1]::[0]" (new [])) -(def: (ensure_macro macro) +(def (ensure_macro macro) (-> Macro (Maybe php/runtime/memory/ObjectMemory)) (|> macro (as java/lang/Object) (ffi.as php/runtime/memory/ObjectMemory))) -(def: interpreter +(def interpreter (org/develnext/jphp/scripting/JPHPScriptEngine::new)) -(def: default_environment +(def default_environment php/runtime/env/Environment (|> ..interpreter java/lang/Object::getClass @@ -446,7 +446,7 @@ (java/lang/reflect/Field::get ..interpreter) (as php/runtime/env/Environment))) -(def: (call_macro inputs lux macro) +(def (call_macro inputs lux macro) (-> (List Code) Lux php/runtime/memory/ObjectMemory (Try (Try [Lux (List Code)]))) (<| as_expected (do try.monad @@ -459,7 +459,7 @@ (php/runtime/memory/ObjectMemory::value macro)))] (..read (as java/lang/Object output))))) -(def: (expander macro inputs lux) +(def (expander macro inputs lux) Expander (case (ensure_macro macro) {.#Some macro} @@ -468,7 +468,7 @@ {.#None} (exception.throw ..cannot_apply_a_non_function (as java/lang/Object macro)))) -(def: host +(def host (IO (Host _.Expression _.Statement)) (io (let [run! (is (-> (_.Code Any) (Try Any)) (function (_ code) @@ -477,12 +477,12 @@ (..read output))))] (is (Host _.Expression _.Statement) (structure - (def: (evaluate! context code) + (def (evaluate! context code) (run! (_.return code))) - (def: execute! run!) + (def execute! run!) - (def: (define! context input) + (def (define! context input) (let [global (reference.artifact context) @global (_.global global)] (do try.monad @@ -491,18 +491,18 @@ value (run! (_.return @global))] (wrap [global value definition])))) - (def: (ingest context content) + (def (ingest context content) (|> content (at utf8.codec decoded) try.trusted (as _.Statement))) - (def: (re_learn context content) + (def (re_learn context content) (run! content)) - (def: (re_load context content) + (def (re_load context content) (do try.monad [_ (run! content)] (run! (_.return (_.var (reference.artifact context))))))))))) -(def: platform +(def platform (IO (Platform [Nat _.Label] _.Expression _.Statement)) (do io.monad [host ..host] @@ -512,14 +512,14 @@ platform.#runtime runtime.generate platform.#write (|>> _.code (at utf8.codec encoded))]))) -(def: (program context program) +(def (program context program) (Program _.Expression _.Statement) (_.; (_.apply/2 program [(runtime.lux//program_args _.command_line_arguments) _.null]))) (for @.old - (def: extender + (def extender Extender ... TODO: Stop relying on coercions ASAP. (<| (as Extender) @@ -550,11 +550,11 @@ (..read output)))) @.php - (def: (extender handler) + (def (extender handler) Extender (as_expected handler))) -(def: (declare_success! _) +(def (declare_success! _) (-> Any (Promise Any)) (promise.future (at world/program.default exit +0))) diff --git a/lux-python/source/program.lux b/lux-python/source/program.lux index ecb78d6f4..11720f39f 100644 --- a/lux-python/source/program.lux +++ b/lux-python/source/program.lux @@ -146,7 +146,7 @@ (type: Translator (-> org/python/core/PyObject (Try Any))) - (def: (read_tuple read host_object) + (def (read_tuple read host_object) (-> Translator Translator) (let [size (|> host_object org/python/core/PyObject::__len__ ffi.of_int .nat)] (loop (again [idx 0 @@ -170,7 +170,7 @@ (exception.report "Object" (ffi.of_string (java/lang/Object::toString object)))) - (def: (read_variant read host_object) + (def (read_variant read host_object) (-> Translator Translator) (case [(org/python/core/PyObject::__getitem__ (ffi.as_int +0) host_object) (org/python/core/PyObject::__getitem__ (ffi.as_int +1) host_object) @@ -206,7 +206,7 @@ "[1]::[0]" (value [] java/lang/Object)) - (def: (read host_object) + (def (read host_object) Translator (`` (<| (~~ (with_template [<class> <processing>] [(case (ffi.as <class> (as <class> host_object)) @@ -243,16 +243,16 @@ ... (exception.except ..unknown_kind_of_object [(as java/lang/Object host_object)]) {try.#Success host_object}))) - (def: (function/? arity) + (def (function/? arity) (-> Nat Code) (` (.-> (~+ (list.repeated arity (` .Any))) .Any))) - (def: (inputs/? arity) + (def (inputs/? arity) (-> Nat (List Text)) (|> (list.indices arity) (list#each (|>> %.nat (format "input/"))))) - (def: (pseudo_function to_host it) + (def (pseudo_function to_host it) (-> (-> Any org/python/core/PyObject) Any org/python/core/PyObject) (<| (as org/python/core/PyObject) (ffi.object [] org/python/core/PyObject [LuxValue] @@ -293,14 +293,14 @@ (~~ (static.literals code.local (inputs/? 8)))) input/+)))))))))))) - (def: object_class + (def object_class (java/lang/Class java/lang/Object) (java/lang/Object::getClass (java/lang/Object::new))) (import library/lux/Function "[1]::[0]") - (def: (to_host|array to_host it) + (def (to_host|array to_host it) (-> (-> Any org/python/core/PyObject) Any org/python/core/PyObject) (as org/python/core/PyObject (ffi.object [] org/python/core/PyArray [LuxValue] @@ -335,7 +335,7 @@ (pyget "super" [index'])))) ))) - (def: (to_host it) + (def (to_host it) (-> Any org/python/core/PyObject) (`` (<| (~~ (with_template [<jvm> <python>] [(case (ffi.as <jvm> (as java/lang/Object it)) @@ -358,7 +358,7 @@ @.jvm (these <jvm>) @.python (these))) -(with_expansions [<jvm> (these (def: (call_macro inputs lux macro) +(with_expansions [<jvm> (these (def (call_macro inputs lux macro) (-> (List Code) Lux org/python/core/PyFunction (Try (Try [Lux (List Code)]))) (|> macro (org/python/core/PyFunction::__call__ (|> (ffi.array org/python/core/PyObject 2) @@ -368,7 +368,7 @@ try#conjoint as_expected)) - (def: python_function! + (def python_function! (-> Any (Maybe org/python/core/PyFunction)) (|>> (as java/lang/Object) (ffi.as org/python/core/PyFunction))) @@ -378,7 +378,7 @@ "Object" (ffi.of_string (java/lang/Object::toString object)) "Class" (ffi.of_string (java/lang/Class::getName (java/lang/Object::getClass object))))) - (def: (expander macro inputs lux) + (def (expander macro inputs lux) Expander (case (python_function! macro) {.#Some macro} @@ -398,11 +398,11 @@ @.jvm (these <jvm>) @.python - (def: (expander macro inputs lux) + (def (expander macro inputs lux) Expander {try.#Success ((as Macro' macro) inputs lux)}))) -(with_expansions [<jvm> (def: host +(with_expansions [<jvm> (def host (IO (Host (_.Expression Any) (_.Statement Any))) (io (let [interpreter (org/python/util/PythonInterpreter::new) evaluate! (is (-> unit.ID [(Maybe unit.ID) (_.Expression Any)] (Try Any)) @@ -422,9 +422,9 @@ output)))] (is (Host (_.Expression Any) (_.Statement Any)) (implementation - (def: evaluate evaluate!) - (def: execute execute!) - (def: (define context custom [@def input]) + (def evaluate evaluate!) + (def execute execute!) + (def (define context custom [@def input]) (let [global (maybe.else (reference.artifact context) custom) @global (_.var global)] @@ -434,16 +434,16 @@ value (evaluate! context [@def @global])] (in [global value definition])))) - (def: (ingest context content) + (def (ingest context content) (|> content (at utf8.codec decoded) try.trusted (as (_.Statement Any)))) - (def: (re_learn context custom content) + (def (re_learn context custom content) (execute! content)) - (def: (re_load context custom content) + (def (re_load context custom content) (do try.monad [_ (execute! content)] (evaluate! context [{.#None} (_.var (reference.artifact context))]))))))))] @@ -454,7 +454,7 @@ (these (import (dict [] ffi.Dict)) (import (eval [ffi.String ffi.Dict] "try" Any)) - (def: host + (def host (IO (Host (_.Expression Any) (_.Statement Any))) (io (is (Host (_.Expression Any) (_.Statement Any)) (let [globals (..dict []) @@ -474,22 +474,22 @@ value (evaluate! context @global)] (in [global value definition])))))] (implementation - (def: evaluate! evaluate!) - (def: execute! execute!) - (def: define! define!) + (def evaluate! evaluate!) + (def execute! execute!) + (def define! define!) - (def: (ingest context content) + (def (ingest context content) (|> content (at utf8.codec decoded) try.trusted (as (_.Statement Any)))) - (def: (re_learn context content) + (def (re_learn context content) (execute! content)) - (def: (re_load context content) + (def (re_load context content) (do try.monad [_ (execute! content)] (evaluate! context (_.var (reference.artifact context))))))))))))) -(with_expansions [<jvm> (these (def: (extender phase_wrapper) +(with_expansions [<jvm> (these (def (extender phase_wrapper) (-> phase.Wrapper Extender) ... TODO: Stop relying on coercions ASAP. (<| (as Extender) @@ -517,17 +517,17 @@ @.jvm (these <jvm>) @.python - (def: (extender phase_wrapper handler) + (def (extender phase_wrapper handler) (-> phase.Wrapper Extender) (as_expected handler)))) -(def: (phase_wrapper archive) +(def (phase_wrapper archive) (-> Archive (runtime.Operation phase.Wrapper)) (|> (..pseudo_function ..to_host) (as phase.Wrapper) phase#in)) -(def: platform +(def platform (IO (Platform Register (_.Expression Any) (_.Statement Any))) (do io.monad [host ..host] @@ -538,7 +538,7 @@ platform.#phase_wrapper ..phase_wrapper platform.#write (|>> _.code (at utf8.codec encoded))]))) -(def: (program context program) +(def (program context program) (Program (_.Expression Any) (_.Statement Any)) (all _.then (_.import "sys") @@ -551,11 +551,11 @@ _.none) program))))) -(def: (declare_success! _) +(def (declare_success! _) (-> Any (Async Any)) (async.future (at world/program.default exit +0))) -(def: (scope body) +(def (scope body) (-> (_.Statement Any) (_.Statement Any)) (let [@program (_.var "lux_program") ; _.statement @@ -572,7 +572,7 @@ (; (_.apply (list) @program)) )))) -(def: (lux_compiler it) +(def (lux_compiler it) (-> Any platform.Custom) (undefined)) diff --git a/lux-r/source/program.lux b/lux-r/source/program.lux index 4a85f2c0c..1a7dbe7f4 100644 --- a/lux-r/source/program.lux +++ b/lux-r/source/program.lux @@ -181,16 +181,16 @@ [cannot_apply_a_non_function] ) -... (def: host_bit +... (def host_bit ... (-> Bit org/armedbear/lisp/LispObject) ... (|>> (pipe.case #0 (org/armedbear/lisp/Nil::NIL) ... #1 (org/armedbear/lisp/Symbol::T)))) -(def: %%code +(def %%code (syntax (_ [term <code>.any]) (wrap (list (code.text (%.code term)))))) -(def: (host_value value) +(def (host_value value) (-> Any org/renjin/sexp/SEXP) (let [... to_sub (is (-> Any org/armedbear/lisp/LispObject) ... (function (_ sub_value) @@ -356,7 +356,7 @@ (type: (Reader a) (-> a (Try Any))) -(def: (read_variant read host_object) +(def (read_variant read host_object) (-> (Reader java/lang/Object) (Reader org/renjin/sexp/ListVector)) (do try.monad [tag (|> host_object @@ -378,7 +378,7 @@ (is Any synthesis.unit)) value]))) -(def: (read_i64 host_object) +(def (read_i64 host_object) (Reader org/renjin/sexp/ListVector) (case [(|> host_object (org/renjin/sexp/ListVector::get_field runtime.i64_high_field) @@ -393,7 +393,7 @@ _ {try.#Failure ""})) -(def: (read_tuple read host_object) +(def (read_tuple read host_object) (-> (Reader java/lang/Object) (Reader org/renjin/sexp/ListVector)) (let [size (.nat (org/renjin/sexp/ListVector::length host_object))] (loop (again [idx 0 @@ -407,7 +407,7 @@ (again (++ idx) (array.write! idx (as Any member) output))) {try.#Success output})))) -(def: (field_class field host_object) +(def (field_class field host_object) (-> Text org/renjin/sexp/ListVector Text) (|> host_object (org/renjin/sexp/ListVector::get_field field) @@ -415,7 +415,7 @@ java/lang/Object::toString (as Text))) -(def: (read host_object) +(def (read host_object) (Reader java/lang/Object) (exec ... ("lux io log" (exception.construct ..unknown_kind_of_object [host_object])) @@ -454,11 +454,11 @@ (exception.throw ..unknown_kind_of_object [host_object]) )))) -(def: ensure_macro +(def ensure_macro (-> Macro (Maybe org/renjin/sexp/Closure)) (|>> (as java/lang/Object) (ffi.as org/renjin/sexp/Closure))) -(def: (call_macro interpreter inputs lux macro) +(def (call_macro interpreter inputs lux macro) (-> org/renjin/script/RenjinScriptEngine (List Code) Lux org/renjin/sexp/Closure (Try (Try [Lux (List Code)]))) (let [_ ("lux io log" "@call_macro 0") r_inputs (is org/renjin/sexp/PairList @@ -487,7 +487,7 @@ (as (Try (Try [Lux (List Code)])) (..read (as java/lang/Object raw_output)))))) -(def: (expander interpreter macro inputs lux) +(def (expander interpreter macro inputs lux) (-> org/renjin/script/RenjinScriptEngine Expander) (case (ensure_macro macro) {.#Some macro} @@ -496,7 +496,7 @@ {.#None} (exception.throw ..cannot_apply_a_non_function [(as java/lang/Object macro)]))) -(def: host +(def host (IO [org/renjin/script/RenjinScriptEngine (Host _.Expression _.Expression)]) (io (let [interpreter (|> (org/renjin/script/RenjinScriptEngineFactory::new) @@ -509,17 +509,17 @@ [(as org/renjin/script/RenjinScriptEngine interpreter) (is (Host _.Expression _.Expression) (structure - (def: (evaluate! context code) + (def (evaluate! context code) (exec ("lux io log" "@evaluate!") (run! code))) - (def: (execute! input) + (def (execute! input) (exec ("lux io log" "@execute!") ... ("lux io log" (_.code input)) (javax/script/ScriptEngine::eval (_.code input) interpreter))) - (def: (define! context input) + (def (define! context input) (let [global (reference.artifact context) $global (_.var global)] (do try.monad @@ -533,19 +533,19 @@ #let [_ ("lux io log" "@define! 2")]] (wrap [global value definition])))) - (def: (ingest context content) + (def (ingest context content) (|> content (at utf8.codec decoded) try.trusted (as _.Expression))) - (def: (re_learn context content) + (def (re_learn context content) (run! content)) - (def: (re_load context content) + (def (re_load context content) (do try.monad [_ (run! content)] (run! (_.var (reference.artifact context))))) ))]))) -(def: platform +(def platform (IO [org/renjin/script/RenjinScriptEngine (Platform _.SVar _.Expression _.Expression)]) (do io.monad @@ -557,12 +557,12 @@ platform.#runtime runtime.generate platform.#write (|>> _.code (at utf8.codec encoded))]]))) -(def: (program context program) +(def (program context program) (Program _.Expression _.Expression) (_.apply/2 program [(runtime.lux::program_args (_.commandArgs/0 [])) _.null])) (for @.old - (def: extender + (def extender Extender ... TODO: Stop relying on coercions ASAP. (<| (as Extender) @@ -581,15 +581,15 @@ {try.#Failure "TODO: Extender"}))) @.r - (def: (extender handler) + (def (extender handler) Extender (as_expected handler))) -(def: (declare_success! _) +(def (declare_success! _) (-> Any (Promise Any)) (promise.future (at world/program.default exit +0))) -(def: (scope body) +(def (scope body) (-> _.Expression _.Expression) (let [$program (_.var "lux_program")] (all _.then diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index 83a565329..41f03bb56 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -151,21 +151,21 @@ (getProvider [] org/jruby/embed/internal/LocalContextProvider)) ... TODO; Figure out a way to not need "interpreter" to be a global variable. -(def: interpreter +(def interpreter (org/jruby/embed/ScriptingContainer::new)) -(def: !ruby_runtime +(def !ruby_runtime (template (!ruby_runtime) [(|> ..interpreter org/jruby/embed/ScriptingContainer::getProvider org/jruby/embed/internal/LocalContextProvider::getRuntime)])) -(def: !ruby_thread_context +(def !ruby_thread_context (template (!ruby_thread_context) [(|> (!ruby_runtime) org/jruby/Ruby::getCurrentContext)])) -(def: initial_ruby_runtime +(def initial_ruby_runtime (!ruby_runtime)) (import org/jruby/java/proxies/JavaProxy @@ -231,7 +231,7 @@ (type: Translator (-> java/lang/Object (Try Any))) -(def: (read_tuple read host_object) +(def (read_tuple read host_object) (-> Translator (org/jruby/RubyArray org/jruby/runtime/builtin/IRubyObject) (Try Any)) (let [size (.nat (ffi.of_int (org/jruby/RubyArray::getLength host_object)))] (loop (again [idx 0 @@ -256,7 +256,7 @@ "Class" (ffi.of_string (java/lang/Object::toString (java/lang/Object::getClass object))) "Object" (ffi.of_string (java/lang/Object::toString object)))) -(def: (read_variant read host_object) +(def (read_variant read host_object) (-> Translator org/jruby/RubyHash (Try Any)) (case [(org/jruby/RubyHash::get (ffi.as_string runtime.variant_tag_field) host_object) (org/jruby/RubyHash::get (ffi.as_string runtime.variant_flag_field) host_object) @@ -282,7 +282,7 @@ (exception: .public nil_has_no_lux_representation) -(def: (read host_object) +(def (read host_object) Translator (`` (<| (if (ffi.null? host_object) (exception.except ..nil_has_no_lux_representation [])) @@ -310,16 +310,16 @@ {try.#Success host_object} ))) -(def: ruby_nil +(def ruby_nil org/jruby/runtime/builtin/IRubyObject (org/jruby/Ruby::getNil ..initial_ruby_runtime)) -(def: lux_unit +(def lux_unit org/jruby/runtime/builtin/IRubyObject (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (org/jruby/RubyString::newInternalFromJavaExternal ..initial_ruby_runtime (ffi.as_string "")))) -(def: (wrapped_lux_value useful_object_class lux_structure) +(def (wrapped_lux_value useful_object_class lux_structure) (-> (-> (-> java/lang/Object org/jruby/runtime/builtin/IRubyObject) (Array java/lang/Object) org/jruby/RubyClass) @@ -370,7 +370,7 @@ (exception.report "Arity" (%.nat arity))) -(def: (::call useful_object_class lux_structure value) +(def (::call useful_object_class lux_structure value) (-> (-> (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (Array java/lang/Object) org/jruby/RubyClass) @@ -438,7 +438,7 @@ (exception.except ..invalid_arity [arity]))] (in (wrapped_lux_value (as_expected useful_object_class) lux_structure output))))))))) -(def: (::access useful_object_class lux_structure value) +(def (::access useful_object_class lux_structure value) (-> (-> (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (Array java/lang/Object) org/jruby/RubyClass) @@ -519,7 +519,7 @@ {.#None}) (panic! (exception.error ..invalid_index [(ffi.is java/lang/Object member)])))))))) -(def: (::= value) +(def (::= value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] @@ -551,7 +551,7 @@ {try.#Failure error} false)))))) -(def: (::length value) +(def (::length value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] @@ -577,7 +577,7 @@ (org/jruby/RubyFixnum::new ..initial_ruby_runtime) (ffi.is org/jruby/runtime/builtin/IRubyObject)))))) -(def: (::to_s value) +(def (::to_s value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] @@ -606,7 +606,7 @@ (exception.report "Method" (%.text method))) -(def: (::respond_to? value) +(def (::respond_to? value) (-> (Array java/lang/Object) org/jruby/internal/runtime/methods/DynamicMethod) (<| (ffi.is org/jruby/internal/runtime/methods/DynamicMethod) (ffi.object [] org/jruby/internal/runtime/methods/DynamicMethod [] @@ -652,7 +652,7 @@ (exception.report "Method" (%.text method))) -(def: (useful_object_class lux_structure value) +(def (useful_object_class lux_structure value) (-> (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (Array java/lang/Object) org/jruby/RubyClass) @@ -685,7 +685,7 @@ method (panic! (exception.error ..unknown_method [method]))))))) -(def: (lux_structure value) +(def (lux_structure value) (-> (Array java/lang/Object) org/jruby/runtime/builtin/IRubyObject) (<| (ffi.is org/jruby/runtime/builtin/IRubyObject) (org/jruby/java/proxies/JavaProxy::new ..initial_ruby_runtime @@ -696,17 +696,17 @@ (exception.report "Non-function" (ffi.of_string (java/lang/Object::toString object)))) -(def: macro! +(def macro! (-> Macro (Maybe org/jruby/RubyProc)) (|>> (as java/lang/Object) (ffi.as org/jruby/RubyProc))) -(def: to_host +(def to_host (-> Any org/jruby/runtime/builtin/IRubyObject) (|>> (as (Array java/lang/Object)) ..lux_structure)) -(def: (call_macro inputs lux macro) +(def (call_macro inputs lux macro) (-> (List Code) Lux org/jruby/RubyProc (Try (Try [Lux (List Code)]))) (as_expected (do try.monad @@ -717,7 +717,7 @@ macro)] (..read (ffi.is java/lang/Object expansion))))) -(def: (expander macro inputs lux) +(def (expander macro inputs lux) Expander (case (macro! macro) {.#Some macro} @@ -734,7 +734,7 @@ {.#None} (exception.except ..cannot_apply_a_non_function [(as java/lang/Object macro)]))) -(def: host +(def host (IO (Host _.Expression _.Statement)) (io (let [run! (is (-> (_.Code Any) (Try Any)) (function (_ code) @@ -744,12 +744,12 @@ output)))))] (is (Host _.Expression _.Statement) (implementation - (def: (evaluate context [_ code]) + (def (evaluate context [_ code]) (run! code)) - (def: execute run!) + (def execute run!) - (def: (define context custom [_ input]) + (def (define context custom [_ input]) (let [global (maybe.else (reference.artifact context) custom) @global (_.global global)] @@ -758,16 +758,16 @@ value (run! definition)] (in [global value definition])))) - (def: (ingest context content) + (def (ingest context content) (|> content (at utf8.codec decoded) try.trusted (as _.Statement))) - (def: (re_learn context custom content) + (def (re_learn context custom content) (run! content)) - (def: (re_load context custom content) + (def (re_load context custom content) (do try.monad [_ (run! content)] (run! (_.global (reference.artifact context)))))))))) @@ -778,21 +778,21 @@ "Partial Application" (%.nat (list.size partial_application)) "Arity" (%.nat (list.size arity)))) - (def: proc_type + (def proc_type org/jruby/runtime/Block$Type (|> (org/jruby/runtime/Block::NULL_BLOCK) (org/jruby/runtime/Block::type))) - (def: phase_block_signature + (def phase_block_signature org/jruby/runtime/Signature (org/jruby/runtime/Signature::THREE_ARGUMENTS)) - (def: dummy_static_scope + (def dummy_static_scope org/jruby/parser/StaticScope (|> (org/jruby/parser/StaticScopeFactory::new (!ruby_runtime)) (org/jruby/parser/StaticScopeFactory::getDummyScope))) - (def: phase_block_body + (def phase_block_body org/jruby/runtime/BlockBody (<| (ffi.is org/jruby/runtime/BlockBody) (ffi.object [] org/jruby/runtime/BlockBody [] @@ -834,7 +834,7 @@ (undefined)) ))) - (def: (host_phase partial_application phase) + (def (host_phase partial_application phase) (All (_ s i o) (-> (List Any) (Phase [extension.Bundle s] i o) org/jruby/RubyProc)) @@ -917,7 +917,7 @@ (exception.except ..invaid_phase_application [partial_application inputs])))))] (org/jruby/RubyProc::newProc (!ruby_runtime) block ..proc_type))) - (def: (extender phase_wrapper) + (def (extender phase_wrapper) (-> phase.Wrapper Extender) ... TODO: Stop relying on coercions ASAP. (<| (as Extender) @@ -945,18 +945,18 @@ (..read (ffi.is java/lang/Object output)))))) @.ruby - (def: (extender phase_wrapper handler) + (def (extender phase_wrapper handler) (-> phase.Wrapper Extender) (as_expected handler))) -(def: (phase_wrapper archive) +(def (phase_wrapper archive) (-> Archive (runtime.Operation phase.Wrapper)) (<| phase#in (as phase.Wrapper) (for @.jvm (..host_phase (list)) @.ruby (|>>)))) -(def: platform +(def platform (IO (Platform Register _.Expression _.Statement)) (do io.monad [host ..host] @@ -967,7 +967,7 @@ platform.#phase_wrapper ..phase_wrapper platform.#write (|>> _.code (at utf8.codec encoded))]))) -(def: (program context program) +(def (program context program) (Program _.Expression _.Statement) (let [normal_runtime? (_.do "const_defined?" (list (_.string (_.code _.command_line_arguments))) @@ -980,11 +980,11 @@ _.nil) program)))) -(def: (declare_success! _) +(def (declare_success! _) (-> Any (Async Any)) (async.future (at world/program.default exit +0))) -(def: (lux_compiler it) +(def (lux_compiler it) (-> Any platform.Custom) (undefined)) diff --git a/lux-scheme/source/program.lux b/lux-scheme/source/program.lux index c0145adf7..3a013afeb 100644 --- a/lux-scheme/source/program.lux +++ b/lux-scheme/source/program.lux @@ -137,7 +137,7 @@ "[1]::[0]" ("static" getR7rsInstance [] kawa/standard/Scheme)) -(def: (variant? value) +(def (variant? value) (-> Any Bit) (case (ffi.as [java/lang/Object] (as java/lang/Object value)) {.#Some array} @@ -171,7 +171,7 @@ [TupleValue] ) -(def: (variant_value lux_value cdr? value) +(def (variant_value lux_value cdr? value) (-> (-> java/lang/Object java/lang/Object) Bit (Array java/lang/Object) gnu/lists/Pair) (ffi.object [] gnu/lists/Pair [program/VariantValue] [] @@ -202,7 +202,7 @@ lux_value) (variant_value lux_value true value))))) -(def: (tuple_value lux_value value) +(def (tuple_value lux_value value) (-> (-> java/lang/Object java/lang/Object) (Array java/lang/Object) gnu/lists/FVector) (ffi.object [] gnu/lists/SimpleVector [program/TupleValue gnu/lists/GVector] [] @@ -246,7 +246,7 @@ "Class" (java/lang/Object::toString (java/lang/Object::getClass object)) "Object" (java/lang/Object::toString object))) -(def: (lux_value value) +(def (lux_value value) (-> java/lang/Object java/lang/Object) (<| (case (ffi.as [java/lang/Object] value) {.#Some value} @@ -261,7 +261,7 @@ (type: (Reader a) (-> a (Try Any))) -(def: (variant tag flag value) +(def (variant tag flag value) (-> Nat Bit Any Any) [(java/lang/Long::intValue (as java/lang/Long tag)) (is Any @@ -270,7 +270,7 @@ (ffi.null))) value]) -(def: (read_variant read host_object) +(def (read_variant read host_object) (-> (Reader java/lang/Object) (Reader gnu/lists/Pair)) (do try.monad [tag (read (gnu/lists/Pair::getCar host_object)) @@ -284,7 +284,7 @@ value (read (gnu/lists/Pair::getCdr host_object))] (wrap (..variant (as Nat tag) flag value)))) -(def: (read_tuple read host_object) +(def (read_tuple read host_object) (-> (Reader java/lang/Object) (Reader (gnu/lists/FVector java/lang/Object))) (let [size (.nat (gnu/lists/FVector::getBufferLength host_object))] (loop (again [idx 0 @@ -299,7 +299,7 @@ (again (++ idx) (array.write! idx (is Any lux_value) output))) {try.#Success output})))) -(def: (read host_object) +(def (read host_object) (Reader java/lang/Object) (`` (<| (~~ (with_template [<class>] [(case (ffi.as <class> host_object) @@ -342,11 +342,11 @@ ... else (exception.throw ..unknown_kind_of_host_object host_object)))) -(def: ensure_macro +(def ensure_macro (-> Macro (Maybe gnu/mapping/Procedure)) (|>> (as java/lang/Object) (ffi.as gnu/mapping/Procedure))) -(def: (expander macro inputs lux) +(def (expander macro inputs lux) Expander (case (..ensure_macro macro) {.#Some macro} @@ -364,7 +364,7 @@ {.#None} (exception.throw ..cannot_apply_a_non_function (as java/lang/Object macro)))) -(def: host +(def host (IO (Host _.Expression _.Expression)) (io (let [interpreter (kawa/standard/Scheme::getR7rsInstance) run! (is (-> (_.Code Any) (Try Any)) @@ -374,13 +374,13 @@ (read output))))] (is (Host _.Expression _.Expression) (structure - (def: (evaluate! context code) + (def (evaluate! context code) (run! code)) - (def: (execute! input) + (def (execute! input) (gnu/expr/Language::eval (_.code input) interpreter)) - (def: (define! context input) + (def (define! context input) (let [global (reference.artifact context) @global (_.var global)] (do try.monad @@ -389,19 +389,19 @@ value (run! @global)] (wrap [global value definition])))) - (def: (ingest context content) + (def (ingest context content) (|> content (at encoding.utf8 decoded) try.trusted (as _.Expression))) - (def: (re_learn context content) + (def (re_learn context content) (run! content)) - (def: (re_load context content) + (def (re_load context content) (do try.monad [_ (run! content)] (run! (_.var (reference.artifact context))))) ))))) -(def: platform +(def platform (IO (Platform _.Var _.Expression _.Expression)) (do io.monad [host ..host] @@ -411,7 +411,7 @@ platform.#runtime runtime.generate platform.#write (|>> _.code (at encoding.utf8 encoded))]))) -(def: (program context program) +(def (program context program) (Program _.Expression _.Expression) (_.apply/2 program ... TODO: Figure out how to always get the command-line @@ -421,7 +421,7 @@ _.nil)) (for @.old - (def: extender + (def extender Extender ... TODO: Stop relying on coercions ASAP. (<| (as Extender) @@ -446,11 +446,11 @@ (..read output)))) @.scheme - (def: (extender handler) + (def (extender handler) Extender (as_expected handler))) -(def: (declare_success! _) +(def (declare_success! _) (-> Any (Promise Any)) (promise.future (at world/program.default exit +0))) diff --git a/stdlib/source/documentation/lux.lux b/stdlib/source/documentation/lux.lux index 1d675d339..e8906c6c0 100644 --- a/stdlib/source/documentation/lux.lux +++ b/stdlib/source/documentation/lux.lux @@ -39,7 +39,7 @@ ["[1][0]" type] ["[1][0]" world]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" @@ -146,7 +146,7 @@ (format "Throws away any code given to it." \n "Great for commenting-out code, while retaining syntax high-lighting and formatting in your text editor.") [(comment - (def: (this will not) + (def (this will not) (Be Defined) (because it will be (commented out))))]) @@ -239,14 +239,14 @@ (format "Hygienic quasi-quotation as a macro." \n "Unquote (~) and unquote-splice (~+) must also be used as forms." \n "All unprefixed macros will receive their parent module's prefix if imported; otherwise will receive the prefix of the module on which the quasi-quote is being used.") - [(` (def: (~ name) + [(` (def (~ name) (function ((~' _) (~+ args)) (~ body))))]) (documentation /.`' (format "Unhygienic quasi-quotation as a macro." \n "Unquote (~) and unquote-splice (~+) must also be used as forms.") - [(`' (def: (~ name) + [(`' (def (~ name) (function (_ (~+ args)) (~ body))))]) @@ -282,7 +282,7 @@ "" ["By specifying a pattern (with holes), and the input data to fill those holes, repeats the pattern as many times as necessary." (with_template [<name> <diff>] - [(def: .public <name> + [(def .public <name> (-> Int Int) (+ <diff>))] @@ -379,7 +379,7 @@ ... {#Saturday} ... {#Sunday})) - ... (def: (weekend? day) + ... (def (weekend? day) ... (-> Weekday Bit) ... (case day ... (^or {#Saturday} {#Sunday}) @@ -408,26 +408,26 @@ 0 1 _ (* n (factorial (-- n))))))]) - (documentation /.def: + (documentation /.def "Defines global constants/functions." - [(def: branching_exponent + [(def branching_exponent Int +5)] ["The type is optional." - (def: branching_exponent + (def branching_exponent +5)] - [(def: (pair_list pair) + [(def (pair_list pair) (-> [Code Code] (List Code)) (let [[left right] pair] (list left right)))] ["Can pattern-match on the inputs to functions." - (def: (pair_list [left right]) + (def (pair_list [left right]) (-> [Code Code] (List Code)) (list left right))]) (documentation /.macro "Macro-definition macro." - [(def: .public symbol + [(def .public symbol (macro (_ tokens) (case tokens (^with_template [<tag>] @@ -464,9 +464,9 @@ "Express a value that implements an interface." [(is (Order Int) (implementation - (def: equivalence + (def equivalence equivalence) - (def: (< reference subject) + (def (< reference subject) (< reference subject)) ))]) @@ -521,7 +521,7 @@ (documentation /.open (format "Same as the 'open' macro, but meant to be used as a pattern-matching macro for generating local bindings." \n "Takes an 'alias' text for the generated local bindings.") - [(def: .public (range enum from to) + [(def .public (range enum from to) (All (_ a) (-> (Enum a) a a (List a))) (let [(open "[0]") enum] (loop (again [end to @@ -554,8 +554,8 @@ "Opens a implementation and generates a definition for each of its members (including nested members)." [(open: "i:[0]" order) "=>" - (def: i:= (at order =)) - (def: i:< (at order <))]) + (def i:= (at order =)) + (def i:< (at order <))]) (documentation /.|>> "Similar to the piping macro, but rather than taking an initial object to work on, creates a function for taking it." @@ -624,7 +624,7 @@ ... (documentation /.^template ... "It's similar to template, but meant to be used during pattern-matching." - ... [(def: (reduced env type) + ... [(def (reduced env type) ... (-> (List Type) Type Type) ... (case type ... {.#Primitive name params} @@ -684,7 +684,7 @@ (format "Controlled macro-expansion." \n "Bind an arbitraty number of Code nodes resulting from macro-expansion to local bindings." \n "Wherever a binding appears, the bound Code nodes will be spliced in there.") - [(def: test + [(def test Test (with_expansions [<tests> (with_template [<function> <parameter> <expected>] @@ -712,8 +712,8 @@ \n "* Rev" \n "* Frac" \n "* Text") - [(def: my_nat 123) - (def: my_text "456") + [(def my_nat 123) + (def my_text "456") (and (case [my_nat my_text] (pattern (static [..my_nat ..my_text])) true @@ -757,7 +757,7 @@ (format "WARNING: Please stay away from this macro; it's very likely to be removed in a future version of Lux." "Allows you to refer to the type-variables in a polymorphic function's type, by their index.") ["In the example below, 0 corresponds to the 'a' variable." - (def: .public (of_list list) + (def .public (of_list list) (All (_ a) (-> (List a) (Sequence a))) (list#mix add (is (Sequence (parameter 0)) @@ -776,7 +776,7 @@ ... (documentation /.^let ... "Allows you to simultaneously bind and de-structure a value." - ... [(def: (hash (^let set [member_hash _])) + ... [(def (hash (^let set [member_hash _])) ... (list#mix (function (_ elem acc) ... (+ acc ... (at member_hash hash elem))) @@ -799,7 +799,7 @@ (format "Meant to be used as a stand-in for functions with undefined implementations." \n "Undefined expressions will type-check against everything, so they make good dummy implementations." \n "However, if an undefined expression is ever evaluated, it will raise a runtime error.") - [(def: (square x) + [(def (square x) (-> Int Int) (undefined))]) @@ -816,7 +816,7 @@ (documentation /.template (format "Define macros in the style of with_template." \n "For simple macros that do not need any fancy features.") - [(def: square + [(def square (template (square x) (* x x)))]) @@ -839,7 +839,7 @@ (documentation /.for (format "Selects the appropriate code for a given target-platform when compiling Lux to it." \n "Look-up the available targets in library/lux/target.") - [(def: js + [(def js "JavaScript") (for "JVM" (do jvm stuff) diff --git a/stdlib/source/documentation/lux/abstract.lux b/stdlib/source/documentation/lux/abstract.lux index ea29bec24..f970c8ea4 100644 --- a/stdlib/source/documentation/lux/abstract.lux +++ b/stdlib/source/documentation/lux/abstract.lux @@ -22,7 +22,7 @@ ["[1][0]" order] ["[1][0]" predicate]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (list.together (list /apply.documentation diff --git a/stdlib/source/documentation/lux/abstract/apply.lux b/stdlib/source/documentation/lux/abstract/apply.lux index 7f18dbdc2..80028da18 100644 --- a/stdlib/source/documentation/lux/abstract/apply.lux +++ b/stdlib/source/documentation/lux/abstract/apply.lux @@ -1,20 +1,17 @@ (.using [library [lux - ["$" documentation (.only documentation:)]]] + ["$" documentation (.only documentation)]]] [\\library ["[0]" /]]) -(documentation: (/.Apply f) - "Applicative functors.") - -(documentation: /.composite - "Applicative functor composition.") - -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" - [..Apply - ..composite] + [(documentation (/.Apply f) + "Applicative functors.") + + (documentation /.composite + "Applicative functor composition.")] [])) diff --git a/stdlib/source/documentation/lux/abstract/codec.lux b/stdlib/source/documentation/lux/abstract/codec.lux index 630e0e504..c6c97876d 100644 --- a/stdlib/source/documentation/lux/abstract/codec.lux +++ b/stdlib/source/documentation/lux/abstract/codec.lux @@ -1,25 +1,22 @@ (.using [library [lux - ["$" documentation (.only documentation:)]]] + ["$" documentation (.only documentation)]]] [\\library ["[0]" /]]) -(documentation: (/.Codec medium value) - "A way to move back-and-forth between a type and an alternative representation for it.") - -(documentation: /.composite - "Codec composition." - [(is (Codec c a) - (composite (is (Codec c b) - cb_codec) - (is (Codec b a) - ba_codec)))]) - -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" - [..Codec - ..composite] + [(documentation (/.Codec medium value) + "A way to move back-and-forth between a type and an alternative representation for it.") + + (documentation /.composite + "Codec composition." + [(is (Codec c a) + (composite (is (Codec c b) + cb_codec) + (is (Codec b a) + ba_codec)))])] [])) diff --git a/stdlib/source/documentation/lux/abstract/comonad.lux b/stdlib/source/documentation/lux/abstract/comonad.lux index d37ba5d68..e634ad2b2 100644 --- a/stdlib/source/documentation/lux/abstract/comonad.lux +++ b/stdlib/source/documentation/lux/abstract/comonad.lux @@ -1,7 +1,7 @@ (.using [library [lux - ["$" documentation (.only documentation:)] + ["$" documentation (.only documentation)] [data [text (.only \n) ["%" \\format (.only format)]]]]] @@ -10,21 +10,18 @@ ["[0]" / ["[1][0]" cofree]]) -(documentation: (/.CoMonad !) - (format "Co-monads are the opposite/complement to monads." - \n "Co-monadic structures are often infinite in size and built upon lazily-evaluated functions.")) - -(documentation: /.be - "A co-monadic parallel to the 'do' macro." - [(let [square (function (_ n) (* n n))] - (be comonad - [inputs (iterate ++ +2)] - (square (out inputs))))]) - -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" - [..CoMonad - ..be] + [(documentation (/.CoMonad !) + (format "Co-monads are the opposite/complement to monads." + \n "Co-monadic structures are often infinite in size and built upon lazily-evaluated functions.")) + + (documentation /.be + "A co-monadic parallel to the 'do' macro." + [(let [square (function (_ n) (* n n))] + (be comonad + [inputs (iterate ++ +2)] + (square (out inputs))))])] [/cofree.documentation])) diff --git a/stdlib/source/documentation/lux/abstract/comonad/cofree.lux b/stdlib/source/documentation/lux/abstract/comonad/cofree.lux index 644357230..739431ae4 100644 --- a/stdlib/source/documentation/lux/abstract/comonad/cofree.lux +++ b/stdlib/source/documentation/lux/abstract/comonad/cofree.lux @@ -1,18 +1,16 @@ (.using [library [lux - ["$" documentation (.only documentation:)]]] + ["$" documentation (.only documentation)]]] [\\library ["[0]" /]]) -(documentation: (/.CoFree ! it) - "The CoFree CoMonad.") - -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" - [..CoFree + [(documentation (/.CoFree ! it) + "The CoFree CoMonad.") ($.default /.functor) ($.default /.comonad)] [])) diff --git a/stdlib/source/documentation/lux/abstract/enum.lux b/stdlib/source/documentation/lux/abstract/enum.lux index 225a36a1e..53a1d2dd8 100644 --- a/stdlib/source/documentation/lux/abstract/enum.lux +++ b/stdlib/source/documentation/lux/abstract/enum.lux @@ -1,21 +1,18 @@ (.using [library [lux - ["$" documentation (.only documentation:)]]] + ["$" documentation (.only documentation)]]] [\\library ["[0]" /]]) -(documentation: (/.Enum it) - "Enumerable types, with a notion of moving forward and backwards through a type's instances.") - -(documentation: /.range - "An inclusive [from, to] range of values." - [(range enum from to)]) - -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" - [..Enum - ..range] + [(documentation (/.Enum it) + "Enumerable types, with a notion of moving forward and backwards through a type's instances.") + + (documentation /.range + "An inclusive [from, to] range of values." + [(range enum from to)])] [])) diff --git a/stdlib/source/documentation/lux/abstract/equivalence.lux b/stdlib/source/documentation/lux/abstract/equivalence.lux index 254626d62..87be00b09 100644 --- a/stdlib/source/documentation/lux/abstract/equivalence.lux +++ b/stdlib/source/documentation/lux/abstract/equivalence.lux @@ -1,25 +1,23 @@ (.using [library [lux - ["$" documentation (.only documentation:)] + ["$" documentation (.only documentation)] [data [text (.only \n) ["%" \\format (.only format)]]]]] [\\library ["[0]" /]]) -(documentation: (/.Equivalence it) - "Equivalence for a type's instances.") - -(documentation: /.rec - "A recursive equivalence combinator." - [(rec recursive_equivalence)]) - -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" - [..Equivalence - ..rec + [(documentation (/.Equivalence it) + "Equivalence for a type's instances.") + + (documentation /.rec + "A recursive equivalence combinator." + [(rec recursive_equivalence)]) + ($.default /.functor)] [])) diff --git a/stdlib/source/documentation/lux/abstract/functor.lux b/stdlib/source/documentation/lux/abstract/functor.lux index 05c9cef0d..9c817c6a3 100644 --- a/stdlib/source/documentation/lux/abstract/functor.lux +++ b/stdlib/source/documentation/lux/abstract/functor.lux @@ -19,7 +19,7 @@ (documentation: /.composite "Functor composition.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/abstract/functor/contravariant.lux b/stdlib/source/documentation/lux/abstract/functor/contravariant.lux index 72c873f4c..39d52f679 100644 --- a/stdlib/source/documentation/lux/abstract/functor/contravariant.lux +++ b/stdlib/source/documentation/lux/abstract/functor/contravariant.lux @@ -1,16 +1,14 @@ (.using [library [lux - ["$" documentation (.only documentation:)]]] + ["$" documentation (.only documentation)]]] [\\library ["[0]" /]]) -(documentation: (/.Functor !) - "The contravariant functor.") - -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" - [..Functor] + [(documentation (/.Functor !) + "The contravariant functor.")] [])) diff --git a/stdlib/source/documentation/lux/abstract/hash.lux b/stdlib/source/documentation/lux/abstract/hash.lux index af7584ead..98b73f40f 100644 --- a/stdlib/source/documentation/lux/abstract/hash.lux +++ b/stdlib/source/documentation/lux/abstract/hash.lux @@ -11,7 +11,7 @@ (documentation: (/.Hash it) "A way to produce hash-codes for a type's instances.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/abstract/interval.lux b/stdlib/source/documentation/lux/abstract/interval.lux index 4e7db1093..88d50e897 100644 --- a/stdlib/source/documentation/lux/abstract/interval.lux +++ b/stdlib/source/documentation/lux/abstract/interval.lux @@ -30,7 +30,7 @@ (documentation: /.meets? "Whether an interval meets another one on its bottom/lower side.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/abstract/mix.lux b/stdlib/source/documentation/lux/abstract/mix.lux index 83767d6af..da8fb5738 100644 --- a/stdlib/source/documentation/lux/abstract/mix.lux +++ b/stdlib/source/documentation/lux/abstract/mix.lux @@ -15,7 +15,7 @@ "Mix a mixable structure using the monoid's identity as the initial value." [(with_monoid monoid mix value)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/abstract/monad.lux b/stdlib/source/documentation/lux/abstract/monad.lux index e5a40d680..f883137fa 100644 --- a/stdlib/source/documentation/lux/abstract/monad.lux +++ b/stdlib/source/documentation/lux/abstract/monad.lux @@ -41,7 +41,7 @@ "Mix a list with a monadic function." [(mix monad function initial_value items)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/abstract/monad/free.lux b/stdlib/source/documentation/lux/abstract/monad/free.lux index fc97271f6..6174c73d3 100644 --- a/stdlib/source/documentation/lux/abstract/monad/free.lux +++ b/stdlib/source/documentation/lux/abstract/monad/free.lux @@ -8,7 +8,7 @@ (documentation: (/.Free ! it) "The Free Monad.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/abstract/monoid.lux b/stdlib/source/documentation/lux/abstract/monoid.lux index e34a18ac5..804dc2d95 100644 --- a/stdlib/source/documentation/lux/abstract/monoid.lux +++ b/stdlib/source/documentation/lux/abstract/monoid.lux @@ -12,7 +12,7 @@ (format "A way to compose values." \n "Includes an identity value which does not alter any other value when combined with.")) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/abstract/order.lux b/stdlib/source/documentation/lux/abstract/order.lux index fcd311241..19271b940 100644 --- a/stdlib/source/documentation/lux/abstract/order.lux +++ b/stdlib/source/documentation/lux/abstract/order.lux @@ -32,7 +32,7 @@ (documentation: /.max "Maximum.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/abstract/predicate.lux b/stdlib/source/documentation/lux/abstract/predicate.lux index e321be043..321df427f 100644 --- a/stdlib/source/documentation/lux/abstract/predicate.lux +++ b/stdlib/source/documentation/lux/abstract/predicate.lux @@ -32,7 +32,7 @@ (documentation: /.rec "Ties the knot for a recursive predicate.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control.lux b/stdlib/source/documentation/lux/control.lux index 917a99bcf..d88a8169f 100644 --- a/stdlib/source/documentation/lux/control.lux +++ b/stdlib/source/documentation/lux/control.lux @@ -28,7 +28,7 @@ ["[1][0]" writer] ]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (list.together (list /concatenative.documentation diff --git a/stdlib/source/documentation/lux/control/concatenative.lux b/stdlib/source/documentation/lux/control/concatenative.lux index 7fa084004..3beae22cb 100644 --- a/stdlib/source/documentation/lux/control/concatenative.lux +++ b/stdlib/source/documentation/lux/control/concatenative.lux @@ -187,7 +187,7 @@ (documentation: /.? "Choose the top value when #0 and the second-to-top when #1.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/concurrency.lux b/stdlib/source/documentation/lux/control/concurrency.lux index 820841408..5dc85c5cd 100644 --- a/stdlib/source/documentation/lux/control/concurrency.lux +++ b/stdlib/source/documentation/lux/control/concurrency.lux @@ -16,7 +16,7 @@ ["[1][0]" stm] ["[1][0]" thread]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (list.together (list /actor.documentation diff --git a/stdlib/source/documentation/lux/control/concurrency/actor.lux b/stdlib/source/documentation/lux/control/concurrency/actor.lux index 96211d7ba..4a25c2f77 100644 --- a/stdlib/source/documentation/lux/control/concurrency/actor.lux +++ b/stdlib/source/documentation/lux/control/concurrency/actor.lux @@ -52,7 +52,7 @@ \n "flowing through the channel into mail the actor can process." \n "Can stop observing the channel by executing the Stop value.")) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "The actor model of concurrency." diff --git a/stdlib/source/documentation/lux/control/concurrency/async.lux b/stdlib/source/documentation/lux/control/concurrency/async.lux index ab064d322..e5aa49b2e 100644 --- a/stdlib/source/documentation/lux/control/concurrency/async.lux +++ b/stdlib/source/documentation/lux/control/concurrency/async.lux @@ -71,7 +71,7 @@ "Wait for an async to be resolved within the specified amount of milli-seconds." [(within milli_seconds async)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/concurrency/atom.lux b/stdlib/source/documentation/lux/control/concurrency/atom.lux index 03ed4c603..a18adabcf 100644 --- a/stdlib/source/documentation/lux/control/concurrency/atom.lux +++ b/stdlib/source/documentation/lux/control/concurrency/atom.lux @@ -26,7 +26,7 @@ (format "Writes the given value to an atom." \n "If it fails to write it (because some other process wrote to it first), it will retry until it succeeds.")) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/concurrency/frp.lux b/stdlib/source/documentation/lux/control/concurrency/frp.lux index a2cd11b36..5365585a3 100644 --- a/stdlib/source/documentation/lux/control/concurrency/frp.lux +++ b/stdlib/source/documentation/lux/control/concurrency/frp.lux @@ -40,7 +40,7 @@ "Transforms the given list into a channel with the same elements." [(sequential milli_seconds values)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/concurrency/semaphore.lux b/stdlib/source/documentation/lux/control/concurrency/semaphore.lux index 74b441df0..c825074c7 100644 --- a/stdlib/source/documentation/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/documentation/lux/control/concurrency/semaphore.lux @@ -49,7 +49,7 @@ (documentation: /.block! "Wait on a barrier until all processes have arrived and met the barrier's limit.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/concurrency/stm.lux b/stdlib/source/documentation/lux/control/concurrency/stm.lux index ee362e0c5..60c1eb06e 100644 --- a/stdlib/source/documentation/lux/control/concurrency/stm.lux +++ b/stdlib/source/documentation/lux/control/concurrency/stm.lux @@ -34,7 +34,7 @@ \n "For this reason, it's important to note that transactions must be free from side-effects, such as I/O.") [(commit! procedure)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/concurrency/thread.lux b/stdlib/source/documentation/lux/control/concurrency/thread.lux index 3d32de720..e856ee64b 100644 --- a/stdlib/source/documentation/lux/control/concurrency/thread.lux +++ b/stdlib/source/documentation/lux/control/concurrency/thread.lux @@ -17,7 +17,7 @@ "Executes an I/O procedure after some milli-seconds." [(schedule! milli_seconds action)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/continuation.lux b/stdlib/source/documentation/lux/control/continuation.lux index 77308f7b8..f7b729cd8 100644 --- a/stdlib/source/documentation/lux/control/continuation.lux +++ b/stdlib/source/documentation/lux/control/continuation.lux @@ -35,7 +35,7 @@ "Turns any expression into a function that is pending a continuation." [(pending (some_function some_input))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/exception.lux b/stdlib/source/documentation/lux/control/exception.lux index bfc5cb7b3..240cc8267 100644 --- a/stdlib/source/documentation/lux/control/exception.lux +++ b/stdlib/source/documentation/lux/control/exception.lux @@ -61,7 +61,7 @@ "If a computation fails, prepends the exception to the error." [(with exception message computation)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Pure-Lux exception-handling functionality." diff --git a/stdlib/source/documentation/lux/control/function.lux b/stdlib/source/documentation/lux/control/function.lux index d6a406a40..c681ad77a 100644 --- a/stdlib/source/documentation/lux/control/function.lux +++ b/stdlib/source/documentation/lux/control/function.lux @@ -40,7 +40,7 @@ "Simple 1-argument function application." [(on input function)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/function/contract.lux b/stdlib/source/documentation/lux/control/function/contract.lux index 036f1ac8c..f7586f66f 100644 --- a/stdlib/source/documentation/lux/control/function/contract.lux +++ b/stdlib/source/documentation/lux/control/function/contract.lux @@ -25,7 +25,7 @@ [(post i.even? (i.+ +2 +2))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/function/memo.lux b/stdlib/source/documentation/lux/control/function/memo.lux index 90a43fede..1b24efe3a 100644 --- a/stdlib/source/documentation/lux/control/function/memo.lux +++ b/stdlib/source/documentation/lux/control/function/memo.lux @@ -24,7 +24,7 @@ \n "This is useful as a test control when measuring the effect of using memoization.") [(none hash memo)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/function/mixin.lux b/stdlib/source/documentation/lux/control/function/mixin.lux index c0024dac4..6ad2e8657 100644 --- a/stdlib/source/documentation/lux/control/function/mixin.lux +++ b/stdlib/source/documentation/lux/control/function/mixin.lux @@ -43,7 +43,7 @@ "Transform an indirectly recursive function into a mixin." [(of_recursive recursive)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/function/mutual.lux b/stdlib/source/documentation/lux/control/function/mutual.lux index 010178e9f..f8f19255e 100644 --- a/stdlib/source/documentation/lux/control/function/mutual.lux +++ b/stdlib/source/documentation/lux/control/function/mutual.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except let def:) + [lux (.except let def) ["$" documentation (.only documentation:)] [data [text (.only \n) @@ -26,9 +26,9 @@ (and (even? 4) (odd? 5)))]) -(documentation: /.def: +(documentation: /.def "Globally-defined mutually-recursive functions." - [(def: + [(def [.public (even? number) (-> Nat Bit) (case number @@ -41,10 +41,10 @@ 0 false _ (even? (-- number)))])]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" [..let - ..def:] + ..def] [])) diff --git a/stdlib/source/documentation/lux/control/io.lux b/stdlib/source/documentation/lux/control/io.lux index 12cd8e918..afd9ad60d 100644 --- a/stdlib/source/documentation/lux/control/io.lux +++ b/stdlib/source/documentation/lux/control/io.lux @@ -23,7 +23,7 @@ (documentation: /.run! "A way to execute IO computations and perform their side-effects.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "A method for abstracting I/O and effectful computations to make it safe while writing pure functional code." diff --git a/stdlib/source/documentation/lux/control/lazy.lux b/stdlib/source/documentation/lux/control/lazy.lux index f360be55f..d54b67d99 100644 --- a/stdlib/source/documentation/lux/control/lazy.lux +++ b/stdlib/source/documentation/lux/control/lazy.lux @@ -18,7 +18,7 @@ "Specifies a lazy value by providing the expression that computes it." [(lazy eager_computation)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/maybe.lux b/stdlib/source/documentation/lux/control/maybe.lux index ea19c8ef9..f8f5754a1 100644 --- a/stdlib/source/documentation/lux/control/maybe.lux +++ b/stdlib/source/documentation/lux/control/maybe.lux @@ -38,7 +38,7 @@ .when (passes_test? value)] (do_something_else 4 5 6))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/parser.lux b/stdlib/source/documentation/lux/control/parser.lux index dc03628bf..44d3fc8f9 100644 --- a/stdlib/source/documentation/lux/control/parser.lux +++ b/stdlib/source/documentation/lux/control/parser.lux @@ -131,7 +131,7 @@ "Decode the output of a parser using a codec." [(codec codec parser)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/parser/analysis.lux b/stdlib/source/documentation/lux/control/parser/analysis.lux index 3e718fbb6..dbabe20a9 100644 --- a/stdlib/source/documentation/lux/control/parser/analysis.lux +++ b/stdlib/source/documentation/lux/control/parser/analysis.lux @@ -47,7 +47,7 @@ "Parses only within the context of a tuple's contents." [(tuple parser)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/parser/binary.lux b/stdlib/source/documentation/lux/control/parser/binary.lux index bab961505..b4b17d0f5 100644 --- a/stdlib/source/documentation/lux/control/parser/binary.lux +++ b/stdlib/source/documentation/lux/control/parser/binary.lux @@ -80,7 +80,7 @@ "" [(set hash value)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/parser/cli.lux b/stdlib/source/documentation/lux/control/parser/cli.lux index 2fd3b326e..bb301507e 100644 --- a/stdlib/source/documentation/lux/control/parser/cli.lux +++ b/stdlib/source/documentation/lux/control/parser/cli.lux @@ -43,7 +43,7 @@ "Parses a parameter that can have either a short or a long name." [(parameter [short long] value)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/parser/code.lux b/stdlib/source/documentation/lux/control/parser/code.lux index e6ce57d82..aee121e73 100644 --- a/stdlib/source/documentation/lux/control/parser/code.lux +++ b/stdlib/source/documentation/lux/control/parser/code.lux @@ -74,7 +74,7 @@ (documentation: /.next "Yields the next Code token without consuming it from the input stream.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/parser/environment.lux b/stdlib/source/documentation/lux/control/parser/environment.lux index 57e3a2f3d..a7f49a386 100644 --- a/stdlib/source/documentation/lux/control/parser/environment.lux +++ b/stdlib/source/documentation/lux/control/parser/environment.lux @@ -31,7 +31,7 @@ \n "Does not check whether all environment variables were parsed, since they're usually an open set.") [(result parser environment)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/parser/json.lux b/stdlib/source/documentation/lux/control/parser/json.lux index bc328bf75..5ef5a2a31 100644 --- a/stdlib/source/documentation/lux/control/parser/json.lux +++ b/stdlib/source/documentation/lux/control/parser/json.lux @@ -63,7 +63,7 @@ (documentation: /.dictionary "Parses a dictionary-like JSON object.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/parser/synthesis.lux b/stdlib/source/documentation/lux/control/parser/synthesis.lux index 14c2c0281..010515394 100644 --- a/stdlib/source/documentation/lux/control/parser/synthesis.lux +++ b/stdlib/source/documentation/lux/control/parser/synthesis.lux @@ -54,7 +54,7 @@ "Parses the initial values and the body of a loop." [(loop init_parsers iteration_parser)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/parser/text.lux b/stdlib/source/documentation/lux/control/parser/text.lux index e78663df3..3cd6e24de 100644 --- a/stdlib/source/documentation/lux/control/parser/text.lux +++ b/stdlib/source/documentation/lux/control/parser/text.lux @@ -153,7 +153,7 @@ "Embeds a text parser into an arbitrary parser that yields text." [(then structured text)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/parser/tree.lux b/stdlib/source/documentation/lux/control/parser/tree.lux index 721c10101..75c2b1674 100644 --- a/stdlib/source/documentation/lux/control/parser/tree.lux +++ b/stdlib/source/documentation/lux/control/parser/tree.lux @@ -44,7 +44,7 @@ [/.start "Move to the root node."] ) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/parser/type.lux b/stdlib/source/documentation/lux/control/parser/type.lux index 547c2df0a..b7cb421e6 100644 --- a/stdlib/source/documentation/lux/control/parser/type.lux +++ b/stdlib/source/documentation/lux/control/parser/type.lux @@ -88,7 +88,7 @@ "" [(recursive poly)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ (format "Parsing of Lux types." diff --git a/stdlib/source/documentation/lux/control/parser/xml.lux b/stdlib/source/documentation/lux/control/parser/xml.lux index 4f6957788..fbfa711f4 100644 --- a/stdlib/source/documentation/lux/control/parser/xml.lux +++ b/stdlib/source/documentation/lux/control/parser/xml.lux @@ -39,7 +39,7 @@ "Applies the parser somewhere among the remaining inputs; instead of demanding that the parser succeeds against the immediate inputs." [(somewhere parser)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/pipe.lux b/stdlib/source/documentation/lux/control/pipe.lux index 70b3e50c0..3d80b5ade 100644 --- a/stdlib/source/documentation/lux/control/pipe.lux +++ b/stdlib/source/documentation/lux/control/pipe.lux @@ -101,7 +101,7 @@ +9 "nine" _ "???"))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Composable extensions to the piping macros (|> and <|) that enhance them with various abilities." diff --git a/stdlib/source/documentation/lux/control/reader.lux b/stdlib/source/documentation/lux/control/reader.lux index 83bf3a768..907fb33c2 100644 --- a/stdlib/source/documentation/lux/control/reader.lux +++ b/stdlib/source/documentation/lux/control/reader.lux @@ -31,7 +31,7 @@ (documentation: /.lifted "Lift monadic values to the Reader wrapper.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/region.lux b/stdlib/source/documentation/lux/control/region.lux index 26e9f2332..9d9824fa9 100644 --- a/stdlib/source/documentation/lux/control/region.lux +++ b/stdlib/source/documentation/lux/control/region.lux @@ -34,7 +34,7 @@ "Lift an effectful computation into a region-based computation." [(lifted monad operation)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/remember.lux b/stdlib/source/documentation/lux/control/remember.lux index df879c0ce..dd71c07b7 100644 --- a/stdlib/source/documentation/lux/control/remember.lux +++ b/stdlib/source/documentation/lux/control/remember.lux @@ -37,7 +37,7 @@ "Improve the performace." (some (complicated (computation 123))))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/security.lux b/stdlib/source/documentation/lux/control/security.lux index 61842bc88..74a30b278 100644 --- a/stdlib/source/documentation/lux/control/security.lux +++ b/stdlib/source/documentation/lux/control/security.lux @@ -11,7 +11,7 @@ ["[1][0]" capability] ["[1][0]" policy]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (list.together (list /policy.documentation diff --git a/stdlib/source/documentation/lux/control/security/capability.lux b/stdlib/source/documentation/lux/control/security/capability.lux index a392fa250..06d06bde3 100644 --- a/stdlib/source/documentation/lux/control/security/capability.lux +++ b/stdlib/source/documentation/lux/control/security/capability.lux @@ -33,7 +33,7 @@ "Converts a synchronous I/O-based capability into an asynchronous capability." [(async capability)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/security/policy.lux b/stdlib/source/documentation/lux/control/security/policy.lux index 6e8d5ec93..86ab3fced 100644 --- a/stdlib/source/documentation/lux/control/security/policy.lux +++ b/stdlib/source/documentation/lux/control/security/policy.lux @@ -44,15 +44,15 @@ (is (-> (Password %) Text) unsafe))) - (def: (policy _) + (def (policy _) (Ex (_ %) (-> Any (Policy %))) (with_policy (is (Context Privacy Policy) (function (_ (open "%::.")) (implementation - (def: (password value) + (def (password value) (%::can_upgrade value)) - (def: (unsafe password) + (def (unsafe password) (%::can_downgrade password)))))))] [(with_policy context)]) @@ -64,7 +64,7 @@ (format "A security context for safety." \n "Safe data is data coming from outside the program which can be trusted to be properly formatted and lacking injections.")) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/state.lux b/stdlib/source/documentation/lux/control/state.lux index ab9cf3d5f..564deb012 100644 --- a/stdlib/source/documentation/lux/control/state.lux +++ b/stdlib/source/documentation/lux/control/state.lux @@ -59,7 +59,7 @@ "Lift monadic values to the +State wrapper." [(lifted monad ma)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/thread.lux b/stdlib/source/documentation/lux/control/thread.lux index bc4062c10..1af1a0293 100644 --- a/stdlib/source/documentation/lux/control/thread.lux +++ b/stdlib/source/documentation/lux/control/thread.lux @@ -39,7 +39,7 @@ "Update a box's value by applying a function to it." [(update! f box)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/try.lux b/stdlib/source/documentation/lux/control/try.lux index f1f2cb0dc..9320a2d3b 100644 --- a/stdlib/source/documentation/lux/control/try.lux +++ b/stdlib/source/documentation/lux/control/try.lux @@ -44,7 +44,7 @@ [(= "foo" (else "foo" {/.#Failure "KABOOM!"}))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/control/writer.lux b/stdlib/source/documentation/lux/control/writer.lux index cb546cb51..f692d626f 100644 --- a/stdlib/source/documentation/lux/control/writer.lux +++ b/stdlib/source/documentation/lux/control/writer.lux @@ -25,7 +25,7 @@ "Wraps a monadic value with Writer machinery." [(lifted monoid monad)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data.lux b/stdlib/source/documentation/lux/data.lux index 908891b19..965b68a5a 100644 --- a/stdlib/source/documentation/lux/data.lux +++ b/stdlib/source/documentation/lux/data.lux @@ -18,7 +18,7 @@ ["[1][0]" sum] ["[1][0]" text]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (list.together (list /binary.documentation diff --git a/stdlib/source/documentation/lux/data/binary.lux b/stdlib/source/documentation/lux/data/binary.lux index f1b5b2f18..11939678d 100644 --- a/stdlib/source/documentation/lux/data/binary.lux +++ b/stdlib/source/documentation/lux/data/binary.lux @@ -65,7 +65,7 @@ "Yields a binary BLOB with at most the specified number of bytes removed." [(after bytes binary)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/bit.lux b/stdlib/source/documentation/lux/data/bit.lux index 08412b9d9..d235f4dbe 100644 --- a/stdlib/source/documentation/lux/data/bit.lux +++ b/stdlib/source/documentation/lux/data/bit.lux @@ -14,7 +14,7 @@ (format "Generates the complement of a predicate." \n "That is a predicate that returns the oposite of the original predicate.")) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection.lux b/stdlib/source/documentation/lux/data/collection.lux index 4cd97968d..5c83211a1 100644 --- a/stdlib/source/documentation/lux/data/collection.lux +++ b/stdlib/source/documentation/lux/data/collection.lux @@ -19,7 +19,7 @@ ["[1][0]" set] ["[1][0]" tree]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (list.together (list /array.documentation diff --git a/stdlib/source/documentation/lux/data/collection/array.lux b/stdlib/source/documentation/lux/data/collection/array.lux index ee54af7e1..40ae33059 100644 --- a/stdlib/source/documentation/lux/data/collection/array.lux +++ b/stdlib/source/documentation/lux/data/collection/array.lux @@ -88,7 +88,7 @@ [(list {.#None} array) (list {.#Some default} array)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/bits.lux b/stdlib/source/documentation/lux/data/collection/bits.lux index 7a5862da3..1dadf4ad6 100644 --- a/stdlib/source/documentation/lux/data/collection/bits.lux +++ b/stdlib/source/documentation/lux/data/collection/bits.lux @@ -37,7 +37,7 @@ "" [(not input)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/dictionary.lux b/stdlib/source/documentation/lux/data/collection/dictionary.lux index f3bdae2de..efa3a49ce 100644 --- a/stdlib/source/documentation/lux/data/collection/dictionary.lux +++ b/stdlib/source/documentation/lux/data/collection/dictionary.lux @@ -75,7 +75,7 @@ "A sub-dictionary, with only the specified keys." [(sub keys dict)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/dictionary/ordered.lux b/stdlib/source/documentation/lux/data/collection/dictionary/ordered.lux index 8cd086024..339bbb6b4 100644 --- a/stdlib/source/documentation/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/documentation/lux/data/collection/dictionary/ordered.lux @@ -57,7 +57,7 @@ "" [(of_list order list)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/dictionary/plist.lux b/stdlib/source/documentation/lux/data/collection/dictionary/plist.lux index 83856e697..7ece01888 100644 --- a/stdlib/source/documentation/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/documentation/lux/data/collection/dictionary/plist.lux @@ -38,7 +38,7 @@ "" [(lacks key properties)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/list.lux b/stdlib/source/documentation/lux/data/collection/list.lux index 438278685..62b316db8 100644 --- a/stdlib/source/documentation/lux/data/collection/list.lux +++ b/stdlib/source/documentation/lux/data/collection/list.lux @@ -104,15 +104,15 @@ (documentation: /.zipped "Create list zippers with the specified number of input lists." - [(def: zipped_2 (zipped 2)) - (def: zipped_3 (zipped 3)) + [(def zipped_2 (zipped 2)) + (def zipped_3 (zipped 3)) (zipped_3 xs ys zs) ((zipped 3) xs ys zs)]) (documentation: /.zipped_with "Create list zippers with the specified number of input lists." - [(def: zipped_with_2 (zipped_with 2)) - (def: zipped_with_3 (zipped_with 3)) + [(def zipped_with_2 (zipped_with 2)) + (def zipped_with_3 (zipped_with 3)) (zipped_with_2 + xs ys) ((zipped_with 2) + xs ys)]) @@ -147,7 +147,7 @@ .when (passes_test? value)] (do_something_else 4 5 6))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/queue.lux b/stdlib/source/documentation/lux/data/collection/queue.lux index 159ea8f33..6385fb451 100644 --- a/stdlib/source/documentation/lux/data/collection/queue.lux +++ b/stdlib/source/documentation/lux/data/collection/queue.lux @@ -42,7 +42,7 @@ "" [(end val queue)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/queue/priority.lux b/stdlib/source/documentation/lux/data/collection/queue/priority.lux index 0a1384ac4..2e24d32eb 100644 --- a/stdlib/source/documentation/lux/data/collection/queue/priority.lux +++ b/stdlib/source/documentation/lux/data/collection/queue/priority.lux @@ -22,7 +22,7 @@ "" [(end priority value queue)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/sequence.lux b/stdlib/source/documentation/lux/data/collection/sequence.lux index 8961d114c..66f3955af 100644 --- a/stdlib/source/documentation/lux/data/collection/sequence.lux +++ b/stdlib/source/documentation/lux/data/collection/sequence.lux @@ -54,7 +54,7 @@ [(is (Sequence Nat) (sequence 12 34 56 78 90))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/set.lux b/stdlib/source/documentation/lux/data/collection/set.lux index fd87feaa3..4e64b2ec6 100644 --- a/stdlib/source/documentation/lux/data/collection/set.lux +++ b/stdlib/source/documentation/lux/data/collection/set.lux @@ -36,7 +36,7 @@ "" [(super? sub super)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/set/multi.lux b/stdlib/source/documentation/lux/data/collection/set/multi.lux index 6a9cdc1ed..20f750d8a 100644 --- a/stdlib/source/documentation/lux/data/collection/set/multi.lux +++ b/stdlib/source/documentation/lux/data/collection/set/multi.lux @@ -43,7 +43,7 @@ (documentation: /.super? "Is 'subject' a super-set of 'reference'?") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/set/ordered.lux b/stdlib/source/documentation/lux/data/collection/set/ordered.lux index 22222e4c5..47dbc2e08 100644 --- a/stdlib/source/documentation/lux/data/collection/set/ordered.lux +++ b/stdlib/source/documentation/lux/data/collection/set/ordered.lux @@ -40,7 +40,7 @@ "Is 'super' a super-set of 'sub'?" [(super? sub super)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/stack.lux b/stdlib/source/documentation/lux/data/collection/stack.lux index 542fe3c49..ceb9b09d7 100644 --- a/stdlib/source/documentation/lux/data/collection/stack.lux +++ b/stdlib/source/documentation/lux/data/collection/stack.lux @@ -28,7 +28,7 @@ "" [(top value stack)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/stream.lux b/stdlib/source/documentation/lux/data/collection/stream.lux index 172018407..7623c806c 100644 --- a/stdlib/source/documentation/lux/data/collection/stream.lux +++ b/stdlib/source/documentation/lux/data/collection/stream.lux @@ -49,7 +49,7 @@ [(let [(pattern x y z _tail) (some_stream_func +1 +2 +3)] (func x y z))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/tree.lux b/stdlib/source/documentation/lux/data/collection/tree.lux index bc798d523..c34d4b8e9 100644 --- a/stdlib/source/documentation/lux/data/collection/tree.lux +++ b/stdlib/source/documentation/lux/data/collection/tree.lux @@ -39,7 +39,7 @@ 56 {} 78 {90 {}}}))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/tree/finger.lux b/stdlib/source/documentation/lux/data/collection/tree/finger.lux index b87de0cfd..de79adfec 100644 --- a/stdlib/source/documentation/lux/data/collection/tree/finger.lux +++ b/stdlib/source/documentation/lux/data/collection/tree/finger.lux @@ -43,7 +43,7 @@ "Verifies that a value exists which meets the predicate." [(exists? predicate tree)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/collection/tree/zipper.lux b/stdlib/source/documentation/lux/data/collection/tree/zipper.lux index 63a52b5f8..24cdd66d6 100644 --- a/stdlib/source/documentation/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/documentation/lux/data/collection/tree/zipper.lux @@ -32,7 +32,7 @@ "" [(adopt value zipper)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/color.lux b/stdlib/source/documentation/lux/data/color.lux index f68e4ed89..e15945e44 100644 --- a/stdlib/source/documentation/lux/data/color.lux +++ b/stdlib/source/documentation/lux/data/color.lux @@ -40,7 +40,7 @@ "" [(interpolated ratio end start)]) -(def: palette_documentation +(def palette_documentation (syntax (_ [[_ name] <code>.symbol]) (in (list (code.text (format "A " (text.replaced "_" "-" name) " palette.")))))) @@ -80,7 +80,7 @@ [/.tetradic] ) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/color/named.lux b/stdlib/source/documentation/lux/data/color/named.lux index 37b6b93a4..960f00f4d 100644 --- a/stdlib/source/documentation/lux/data/color/named.lux +++ b/stdlib/source/documentation/lux/data/color/named.lux @@ -170,7 +170,7 @@ [/.yellow_green] ) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/format.lux b/stdlib/source/documentation/lux/data/format.lux index 645502ef2..a67936e66 100644 --- a/stdlib/source/documentation/lux/data/format.lux +++ b/stdlib/source/documentation/lux/data/format.lux @@ -13,7 +13,7 @@ ["[1][0]" tar] ["[1][0]" xml]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (list.together (list /binary.documentation diff --git a/stdlib/source/documentation/lux/data/format/binary.lux b/stdlib/source/documentation/lux/data/format/binary.lux index 9d313aab0..311dd602d 100644 --- a/stdlib/source/documentation/lux/data/format/binary.lux +++ b/stdlib/source/documentation/lux/data/format/binary.lux @@ -45,7 +45,7 @@ "Writes at most 'size' bytes of an input binary blob." [(segment size)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/format/json.lux b/stdlib/source/documentation/lux/data/format/json.lux index fb843637b..8d90c1735 100644 --- a/stdlib/source/documentation/lux/data/format/json.lux +++ b/stdlib/source/documentation/lux/data/format/json.lux @@ -48,7 +48,7 @@ [/.object_field "objects"] ) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ (format "Functionality for reading and writing values in the JSON format." diff --git a/stdlib/source/documentation/lux/data/format/tar.lux b/stdlib/source/documentation/lux/data/format/tar.lux index 82f3d37dd..6a25ed15f 100644 --- a/stdlib/source/documentation/lux/data/format/tar.lux +++ b/stdlib/source/documentation/lux/data/format/tar.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/format/xml.lux b/stdlib/source/documentation/lux/data/format/xml.lux index e3240d85a..ab00554ce 100644 --- a/stdlib/source/documentation/lux/data/format/xml.lux +++ b/stdlib/source/documentation/lux/data/format/xml.lux @@ -20,7 +20,7 @@ (documentation: /.attribute "The text format of a XML attribute.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/identity.lux b/stdlib/source/documentation/lux/data/identity.lux index c6eb4922b..efc58cdcf 100644 --- a/stdlib/source/documentation/lux/data/identity.lux +++ b/stdlib/source/documentation/lux/data/identity.lux @@ -13,7 +13,7 @@ (documentation: (/.Identity it) "A value, as is, without any extra structure super-imposed on it.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/product.lux b/stdlib/source/documentation/lux/data/product.lux index d599f3706..33df94c59 100644 --- a/stdlib/source/documentation/lux/data/product.lux +++ b/stdlib/source/documentation/lux/data/product.lux @@ -36,7 +36,7 @@ "Yields a pair by applying both functions to a single value." [(forked f g)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Functionality for working with tuples (particularly 2-tuples/pairs)." diff --git a/stdlib/source/documentation/lux/data/sum.lux b/stdlib/source/documentation/lux/data/sum.lux index dd398e250..9d38d8230 100644 --- a/stdlib/source/documentation/lux/data/sum.lux +++ b/stdlib/source/documentation/lux/data/sum.lux @@ -24,7 +24,7 @@ "Applies functions to both sides of a 2-variant." [(then on_left on_right)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Functionality for working with variants (particularly 2-variants)." diff --git a/stdlib/source/documentation/lux/data/text.lux b/stdlib/source/documentation/lux/data/text.lux index 41ba31e83..a13b2839a 100644 --- a/stdlib/source/documentation/lux/data/text.lux +++ b/stdlib/source/documentation/lux/data/text.lux @@ -107,7 +107,7 @@ "Checks whether the character is white-space." [(space? char)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/text/buffer.lux b/stdlib/source/documentation/lux/data/text/buffer.lux index 6fa90504b..79722d05b 100644 --- a/stdlib/source/documentation/lux/data/text/buffer.lux +++ b/stdlib/source/documentation/lux/data/text/buffer.lux @@ -13,7 +13,7 @@ (documentation: /.Buffer "Immutable text buffer for efficient text concatenation.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/text/encoding.lux b/stdlib/source/documentation/lux/data/text/encoding.lux index 0cda057b4..e4c624a05 100644 --- a/stdlib/source/documentation/lux/data/text/encoding.lux +++ b/stdlib/source/documentation/lux/data/text/encoding.lux @@ -164,7 +164,7 @@ [/.koi8_u] ) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/text/encoding/utf8.lux b/stdlib/source/documentation/lux/data/text/encoding/utf8.lux index 9727adac3..e9aed460d 100644 --- a/stdlib/source/documentation/lux/data/text/encoding/utf8.lux +++ b/stdlib/source/documentation/lux/data/text/encoding/utf8.lux @@ -13,7 +13,7 @@ (documentation: /.codec "A codec for binary encoding of text as UTF-8.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/text/escape.lux b/stdlib/source/documentation/lux/data/text/escape.lux index dd56ccf4b..112aa7b25 100644 --- a/stdlib/source/documentation/lux/data/text/escape.lux +++ b/stdlib/source/documentation/lux/data/text/escape.lux @@ -26,7 +26,7 @@ (format "Line 1" \n "Line 2")]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/text/format.lux b/stdlib/source/documentation/lux/data/text/format.lux index 53f70bac3..97d12c1fa 100644 --- a/stdlib/source/documentation/lux/data/text/format.lux +++ b/stdlib/source/documentation/lux/data/text/format.lux @@ -14,7 +14,7 @@ "Text interpolation." [(format "Static part " (text static) " does not match URI: " uri)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/text/regex.lux b/stdlib/source/documentation/lux/data/text/regex.lux index 718a76ca1..5f95326a4 100644 --- a/stdlib/source/documentation/lux/data/text/regex.lux +++ b/stdlib/source/documentation/lux/data/text/regex.lux @@ -69,7 +69,7 @@ _ do_something_else)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/text/unicode.lux b/stdlib/source/documentation/lux/data/text/unicode.lux index ab47ca744..5e4aff2e1 100644 --- a/stdlib/source/documentation/lux/data/text/unicode.lux +++ b/stdlib/source/documentation/lux/data/text/unicode.lux @@ -11,7 +11,7 @@ ["[1][0]" block] ["[1][0]" set]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (list.together (list /block.documentation diff --git a/stdlib/source/documentation/lux/data/text/unicode/block.lux b/stdlib/source/documentation/lux/data/text/unicode/block.lux index bcf101d5c..3bce030f0 100644 --- a/stdlib/source/documentation/lux/data/text/unicode/block.lux +++ b/stdlib/source/documentation/lux/data/text/unicode/block.lux @@ -141,7 +141,7 @@ [/.lower_case] ) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/data/text/unicode/set.lux b/stdlib/source/documentation/lux/data/text/unicode/set.lux index 53de02b6b..1ebb9bdd3 100644 --- a/stdlib/source/documentation/lux/data/text/unicode/set.lux +++ b/stdlib/source/documentation/lux/data/text/unicode/set.lux @@ -18,7 +18,7 @@ "" [(member? set character)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/debug.lux b/stdlib/source/documentation/lux/debug.lux index e8f5527c0..91fc034f9 100644 --- a/stdlib/source/documentation/lux/debug.lux +++ b/stdlib/source/documentation/lux/debug.lux @@ -21,7 +21,7 @@ (documentation: /.private "Allows access to un-exported definitions in other modules." ["Module A" - (def: .private (secret_definition input) + (def .private (secret_definition input) (-> ??? ???) (foo (bar (baz input)))) "Module B" @@ -64,7 +64,7 @@ "baz: +789.0" []]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/documentation.lux b/stdlib/source/documentation/lux/documentation.lux index ccc18909a..683b259b2 100644 --- a/stdlib/source/documentation/lux/documentation.lux +++ b/stdlib/source/documentation/lux/documentation.lux @@ -35,7 +35,7 @@ (/.default /.documentation)] []))]) -(.def: .public documentation +(.def .public documentation (.List /.Module) (/.module /._ "" diff --git a/stdlib/source/documentation/lux/extension.lux b/stdlib/source/documentation/lux/extension.lux index 9b27ebc33..3a88c9a83 100644 --- a/stdlib/source/documentation/lux/extension.lux +++ b/stdlib/source/documentation/lux/extension.lux @@ -51,7 +51,7 @@ [.let [_ (debug.log! (format "Successfully installed directive " (%.text self) "!"))]] (in directive.no_requirements)))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/ffi.js.lux b/stdlib/source/documentation/lux/ffi.js.lux index 83ba87089..2e6003722 100644 --- a/stdlib/source/documentation/lux/ffi.js.lux +++ b/stdlib/source/documentation/lux/ffi.js.lux @@ -50,7 +50,7 @@ (closure [left right] (do_something (as Foo left) (as Bar right))))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/ffi.jvm.lux b/stdlib/source/documentation/lux/ffi.jvm.lux index 71e0c95a9..265b1bd35 100644 --- a/stdlib/source/documentation/lux/ffi.jvm.lux +++ b/stdlib/source/documentation/lux/ffi.jvm.lux @@ -254,7 +254,7 @@ (is java/lang/String ???))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/ffi.lua.lux b/stdlib/source/documentation/lux/ffi.lua.lux index 37cdf1c6a..bd38a77b5 100644 --- a/stdlib/source/documentation/lux/ffi.lua.lux +++ b/stdlib/source/documentation/lux/ffi.lua.lux @@ -21,7 +21,7 @@ (closure [left right] (do_something (as Foo left) (as Bar right))))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/ffi.old.lux b/stdlib/source/documentation/lux/ffi.old.lux index 99f6a6c5b..a1771a53f 100644 --- a/stdlib/source/documentation/lux/ffi.old.lux +++ b/stdlib/source/documentation/lux/ffi.old.lux @@ -212,7 +212,7 @@ [(is .Type (type java/lang/String))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/ffi.py.lux b/stdlib/source/documentation/lux/ffi.py.lux index b4549abc2..99fb157ed 100644 --- a/stdlib/source/documentation/lux/ffi.py.lux +++ b/stdlib/source/documentation/lux/ffi.py.lux @@ -42,7 +42,7 @@ (do_something (as Foo left) (as Bar right))))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/ffi.rb.lux b/stdlib/source/documentation/lux/ffi.rb.lux index 578a9211f..75e5229a4 100644 --- a/stdlib/source/documentation/lux/ffi.rb.lux +++ b/stdlib/source/documentation/lux/ffi.rb.lux @@ -31,7 +31,7 @@ (flush [] "io" "try" "?" Any) (close [] "io" "try" "?" Any))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/locale.lux b/stdlib/source/documentation/lux/locale.lux index e0958143f..b4990b991 100644 --- a/stdlib/source/documentation/lux/locale.lux +++ b/stdlib/source/documentation/lux/locale.lux @@ -20,7 +20,7 @@ "" [(locale language territory encoding)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/locale/language.lux b/stdlib/source/documentation/lux/locale/language.lux index d47b66d8c..1de51a886 100644 --- a/stdlib/source/documentation/lux/locale/language.lux +++ b/stdlib/source/documentation/lux/locale/language.lux @@ -13,14 +13,14 @@ (documentation: /.Language "An ISO 639 language.") -(def: items/~ +(def items/~ (list.together (list ($.default /.uncoded) ($.default /.multiple) ($.default /.undetermined) ($.default /.not_applicable)))) -(def: items/a +(def items/a (list.together (list ($.default /.afar) ($.default /.abkhazian) @@ -62,7 +62,7 @@ ($.default /.aymara) ($.default /.azerbaijani)))) -(def: items/b +(def items/b (list.together (list ($.default /.banda) ($.default /.bamileke) @@ -96,7 +96,7 @@ ($.default /.blin) ($.default /.bilin)))) -(def: items/c +(def items/c (list.together (list ($.default /.caddo) ($.default /.central_american_indian) @@ -139,7 +139,7 @@ ($.default /.cushitic) ($.default /.welsh)))) -(def: items/d +(def items/d (list.together (list ($.default /.dakota) ($.default /.danish) @@ -160,7 +160,7 @@ ($.default /.dyula) ($.default /.dzongkha)))) -(def: items/e +(def items/e (list.together (list ($.default /.efik) ($.default /.egyptian) @@ -175,7 +175,7 @@ ($.default /.ewe) ($.default /.ewondo)))) -(def: items/f +(def items/f (list.together (list ($.default /.fang) ($.default /.faroese) @@ -195,7 +195,7 @@ ($.default /.fulah) ($.default /.friulian)))) -(def: items/g +(def items/g (list.together (list ($.default /.ga) ($.default /.gayo) @@ -221,7 +221,7 @@ ($.default /.gujarati) ($.default /.gwich'in)))) -(def: items/h +(def items/h (list.together (list ($.default /.haida) ($.default /.haitian) @@ -241,7 +241,7 @@ ($.default /.hupa) ($.default /.armenian)))) -(def: items/i +(def items/i (list.together (list ($.default /.iban) ($.default /.igbo) @@ -263,7 +263,7 @@ ($.default /.icelandic) ($.default /.italian)))) -(def: items/j +(def items/j (list.together (list ($.default /.javanese) ($.default /.lojban) @@ -271,7 +271,7 @@ ($.default /.judeo_persian) ($.default /.judeo_arabic)))) -(def: items/k +(def items/k (list.together (list ($.default /.kara_kalpak) ($.default /.kabyle) @@ -312,7 +312,7 @@ ($.default /.kurdish) ($.default /.kutenai)))) -(def: items/l +(def items/l (list.together (list ($.default /.ladino) ($.default /.lahnda) @@ -335,7 +335,7 @@ ($.default /.luo) ($.default /.lushai)))) -(def: items/m +(def items/m (list.together (list ($.default /.madurese) ($.default /.magahi) @@ -374,7 +374,7 @@ ($.default /.mayan) ($.default /.erzya)))) -(def: items/n +(def items/n (list.together (list ($.default /.nahuatl) ($.default /.north_american_indian) @@ -414,7 +414,7 @@ ($.default /.nyoro) ($.default /.nzima)))) -(def: items/o +(def items/o (list.together (list ($.default /.occitan) ($.default /.provencal) @@ -426,7 +426,7 @@ ($.default /.ottoman_turkish) ($.default /.otomian)))) -(def: items/p +(def items/p (list.together (list ($.default /.papuan) ($.default /.pangasinan) @@ -447,11 +447,11 @@ ($.default /.old_provencal) ($.default /.pashto)))) -(def: items/q +(def items/q (list.together (list ($.default /.quechua)))) -(def: items/r +(def items/r (list.together (list ($.default /.rajasthani) ($.default /.rapanui) @@ -469,7 +469,7 @@ ($.default /.macedo_romanian) ($.default /.russian)))) -(def: items/s +(def items/s (list.together (list ($.default /.sandawe) ($.default /.sango) @@ -526,7 +526,7 @@ ($.default /.classical_syriac) ($.default /.syriac)))) -(def: items/t +(def items/t (list.together (list ($.default /.tahitian) ($.default /.tai) @@ -561,7 +561,7 @@ ($.default /.twi) ($.default /.tuvinian)))) -(def: items/u +(def items/u (list.together (list ($.default /.udmurt) ($.default /.ugaritic) @@ -571,7 +571,7 @@ ($.default /.urdu) ($.default /.uzbek)))) -(def: items/v +(def items/v (list.together (list ($.default /.vai) ($.default /.venda) @@ -579,7 +579,7 @@ ($.default /.volapük) ($.default /.votic)))) -(def: items/w +(def items/w (list.together (list ($.default /.wakashan) ($.default /.walamo) @@ -589,13 +589,13 @@ ($.default /.walloon) ($.default /.wolof)))) -(def: items/x +(def items/x (list.together (list ($.default /.kalmyk) ($.default /.oirat) ($.default /.xhosa)))) -(def: items/y +(def items/y (list.together (list ($.default /.yao) ($.default /.yapese) @@ -603,7 +603,7 @@ ($.default /.yoruba) ($.default /.yupik)))) -(def: items/z +(def items/z (list.together (list ($.default /.zapotec) ($.default /.blissymbols) @@ -621,7 +621,7 @@ ($.default /.kirmanjki) ($.default /.zazaki)))) -(.def: .public documentation +(.def .public documentation (.List $.Module) (`` ($.module /._ "" diff --git a/stdlib/source/documentation/lux/locale/territory.lux b/stdlib/source/documentation/lux/locale/territory.lux index 4240d134d..187d9c5e7 100644 --- a/stdlib/source/documentation/lux/locale/territory.lux +++ b/stdlib/source/documentation/lux/locale/territory.lux @@ -13,7 +13,7 @@ (documentation: /.Territory "An ISO 3166 territory.") -(def: items/ab +(def items/ab (list.together (list ($.default /.afghanistan) ($.default /.aland_islands) @@ -57,7 +57,7 @@ ($.default /.burkina_faso) ($.default /.burundi)))) -(def: items/cd +(def items/cd (list.together (list ($.default /.cape_verde) ($.default /.cambodia) @@ -87,7 +87,7 @@ ($.default /.dominica) ($.default /.dominican_republic)))) -(def: items/efg +(def items/efg (list.together (list ($.default /.ecuador) ($.default /.egypt) @@ -122,7 +122,7 @@ ($.default /.guinea_bissau) ($.default /.guyana)))) -(def: items/hijkl +(def items/hijkl (list.together (list ($.default /.haiti) ($.default /.heard_island) @@ -161,7 +161,7 @@ ($.default /.lithuania) ($.default /.luxembourg)))) -(def: items/mno +(def items/mno (list.together (list ($.default /.macau) ($.default /.macedonia) @@ -201,7 +201,7 @@ ($.default /.norway) ($.default /.oman)))) -(def: items/pqrs +(def items/pqrs (list.together (list ($.default /.pakistan) ($.default /.palau) @@ -261,7 +261,7 @@ ($.default /.switzerland) ($.default /.syria)))) -(def: items/tuvwxyz +(def items/tuvwxyz (list.together (list ($.default /.taiwan) ($.default /.tajikistan) @@ -300,7 +300,7 @@ ($.default /.zambia) ($.default /.zimbabwe)))) -(.def: .public documentation +(.def .public documentation (.List $.Module) (`` ($.module /._ "" diff --git a/stdlib/source/documentation/lux/macro.lux b/stdlib/source/documentation/lux/macro.lux index 318540278..0df20d2b7 100644 --- a/stdlib/source/documentation/lux/macro.lux +++ b/stdlib/source/documentation/lux/macro.lux @@ -39,7 +39,7 @@ (documentation: /.with_symbols "Creates new symbols and offers them to the body expression." - [(def: synchronized + [(def synchronized (syntax (_ [lock any body any]) (with_symbols [g!lock g!body g!_] @@ -58,11 +58,11 @@ \n "You can either use the resulting code, or omit them." \n "By omitting them, this macro produces nothing (just like the lux.comment macro).") [(log_single_expansion! - (def: (foo bar baz) + (def (foo bar baz) (-> Int Int Int) (int.+ bar baz))) (log_single_expansion! "omit" - (def: (foo bar baz) + (def (foo bar baz) (-> Int Int Int) (int.+ bar baz)))]) @@ -71,11 +71,11 @@ \n "You can either use the resulting code, or omit them." \n "By omitting them, this macro produces nothing (just like the lux.comment macro).") [(log_expansion! - (def: (foo bar baz) + (def (foo bar baz) (-> Int Int Int) (int.+ bar baz))) (log_expansion! "omit" - (def: (foo bar baz) + (def (foo bar baz) (-> Int Int Int) (int.+ bar baz)))]) @@ -84,15 +84,15 @@ \n "You can either use the resulting code, or omit them." \n "By omitting them, this macro produces nothing (just like the lux.comment macro).") [(log_full_expansion! - (def: (foo bar baz) + (def (foo bar baz) (-> Int Int Int) (int.+ bar baz))) (log_full_expansion! "omit" - (def: (foo bar baz) + (def (foo bar baz) (-> Int Int Int) (int.+ bar baz)))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/macro/code.lux b/stdlib/source/documentation/lux/macro/code.lux index e1a0f8058..7a4e26199 100644 --- a/stdlib/source/documentation/lux/macro/code.lux +++ b/stdlib/source/documentation/lux/macro/code.lux @@ -17,7 +17,7 @@ "" [(replaced original substitute ast)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/macro/local.lux b/stdlib/source/documentation/lux/macro/local.lux index dafb8f498..f171af782 100644 --- a/stdlib/source/documentation/lux/macro/local.lux +++ b/stdlib/source/documentation/lux/macro/local.lux @@ -17,7 +17,7 @@ \n "NOTE: Always use this code once to clean-up..") [(push macros)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/macro/syntax.lux b/stdlib/source/documentation/lux/macro/syntax.lux index 191b929d2..828ede9eb 100644 --- a/stdlib/source/documentation/lux/macro/syntax.lux +++ b/stdlib/source/documentation/lux/macro/syntax.lux @@ -23,7 +23,7 @@ \n "The inputs to the macro can be parsed in complex ways through the use of syntax parsers." \n "The macro body is also (implicitly) run in the Meta monad, to save some typing." \n "Also, the compiler state can be accessed through a special binding.") - [(def: .public object + [(def .public object (syntax (_ lux_state [.let [imports (class_imports lux_state)] .let [class_vars (list)] super (opt (super_class_decl^ imports class_vars)) @@ -37,7 +37,7 @@ (with_brackets (spaced (list#each (method_def$ id) methods))))))] (in (list (` ((~ (code.text def_code)))))))))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/macro/syntax/check.lux b/stdlib/source/documentation/lux/macro/syntax/check.lux index 38785fefd..7a2f630c6 100644 --- a/stdlib/source/documentation/lux/macro/syntax/check.lux +++ b/stdlib/source/documentation/lux/macro/syntax/check.lux @@ -13,7 +13,7 @@ (documentation: /.Check "A type annotation for an expression.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/macro/syntax/declaration.lux b/stdlib/source/documentation/lux/macro/syntax/declaration.lux index f649cbb6c..91e3e232c 100644 --- a/stdlib/source/documentation/lux/macro/syntax/declaration.lux +++ b/stdlib/source/documentation/lux/macro/syntax/declaration.lux @@ -19,7 +19,7 @@ quux (foo bar baz)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/macro/syntax/definition.lux b/stdlib/source/documentation/lux/macro/syntax/definition.lux index aad057c03..08706e55c 100644 --- a/stdlib/source/documentation/lux/macro/syntax/definition.lux +++ b/stdlib/source/documentation/lux/macro/syntax/definition.lux @@ -21,7 +21,7 @@ "Only works for typed definitions." [(typed compiler)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/macro/syntax/export.lux b/stdlib/source/documentation/lux/macro/syntax/export.lux index c5bd4ad1d..b0cfb422c 100644 --- a/stdlib/source/documentation/lux/macro/syntax/export.lux +++ b/stdlib/source/documentation/lux/macro/syntax/export.lux @@ -14,7 +14,7 @@ "" [(parser un_exported)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Syntax for marking a definition as an export." diff --git a/stdlib/source/documentation/lux/macro/syntax/input.lux b/stdlib/source/documentation/lux/macro/syntax/input.lux index 13ee20488..3362c356a 100644 --- a/stdlib/source/documentation/lux/macro/syntax/input.lux +++ b/stdlib/source/documentation/lux/macro/syntax/input.lux @@ -16,7 +16,7 @@ (documentation: /.parser "Parser for the common typed-argument syntax used by many macros.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/macro/syntax/type/variable.lux b/stdlib/source/documentation/lux/macro/syntax/type/variable.lux index 6de691019..3b12b4970 100644 --- a/stdlib/source/documentation/lux/macro/syntax/type/variable.lux +++ b/stdlib/source/documentation/lux/macro/syntax/type/variable.lux @@ -16,7 +16,7 @@ (documentation: /.parser "Parser for the common type variable/parameter used by many macros.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/macro/template.lux b/stdlib/source/documentation/lux/macro/template.lux index 0a0191099..1054515f1 100644 --- a/stdlib/source/documentation/lux/macro/template.lux +++ b/stdlib/source/documentation/lux/macro/template.lux @@ -53,11 +53,11 @@ "Lexically-bound templates." [(let [(!square <root>) [(* <root> <root>)]] - (def: (square root) + (def (square root) (-> Nat Nat) (!square root)))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Utilities commonly used while templating." diff --git a/stdlib/source/documentation/lux/math.lux b/stdlib/source/documentation/lux/math.lux index fe8e075b2..36251af9b 100644 --- a/stdlib/source/documentation/lux/math.lux +++ b/stdlib/source/documentation/lux/math.lux @@ -17,7 +17,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/math/infix.lux b/stdlib/source/documentation/lux/math/infix.lux index f0f2302fc..e2c1f0706 100644 --- a/stdlib/source/documentation/lux/math/infix.lux +++ b/stdlib/source/documentation/lux/math/infix.lux @@ -38,7 +38,7 @@ "=>" (gcd 450 (* 3 9))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/math/logic.lux b/stdlib/source/documentation/lux/math/logic.lux index bf76966ca..d850565dd 100644 --- a/stdlib/source/documentation/lux/math/logic.lux +++ b/stdlib/source/documentation/lux/math/logic.lux @@ -11,7 +11,7 @@ ["[1][0]" continuous] ["[1][0]" fuzzy]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (all list#composite /continuous.documentation diff --git a/stdlib/source/documentation/lux/math/logic/continuous.lux b/stdlib/source/documentation/lux/math/logic/continuous.lux index a9cffa38b..3a5edbb3f 100644 --- a/stdlib/source/documentation/lux/math/logic/continuous.lux +++ b/stdlib/source/documentation/lux/math/logic/continuous.lux @@ -14,7 +14,7 @@ "" [(implies consequent antecedent)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ (format "Continuous logic using Rev values." diff --git a/stdlib/source/documentation/lux/math/logic/fuzzy.lux b/stdlib/source/documentation/lux/math/logic/fuzzy.lux index 38abc15e7..7698285e7 100644 --- a/stdlib/source/documentation/lux/math/logic/fuzzy.lux +++ b/stdlib/source/documentation/lux/math/logic/fuzzy.lux @@ -45,7 +45,7 @@ "" [(cut treshold set)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Fuzzy logic, implemented on top of the Rev type." diff --git a/stdlib/source/documentation/lux/math/modular.lux b/stdlib/source/documentation/lux/math/modular.lux index d05597f38..4d6be1904 100644 --- a/stdlib/source/documentation/lux/math/modular.lux +++ b/stdlib/source/documentation/lux/math/modular.lux @@ -21,7 +21,7 @@ "" [(adapter reference subject)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/math/modulus.lux b/stdlib/source/documentation/lux/math/modulus.lux index a1496c4d1..bdf5c1552 100644 --- a/stdlib/source/documentation/lux/math/modulus.lux +++ b/stdlib/source/documentation/lux/math/modulus.lux @@ -25,7 +25,7 @@ ["Failure!" (literal 0)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/math/number.lux b/stdlib/source/documentation/lux/math/number.lux index 2920e4f44..c8c1804b8 100644 --- a/stdlib/source/documentation/lux/math/number.lux +++ b/stdlib/source/documentation/lux/math/number.lux @@ -33,7 +33,7 @@ [/.hex "hexadecimal" (hex "deadBEEF") (hex "dead,BEEF")] ) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/math/number/complex.lux b/stdlib/source/documentation/lux/math/number/complex.lux index 86757d1f3..14e598384 100644 --- a/stdlib/source/documentation/lux/math/number/complex.lux +++ b/stdlib/source/documentation/lux/math/number/complex.lux @@ -19,7 +19,7 @@ ["The imaginary part can be omitted if it's +0.0." (complex real)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Complex arithmetic." diff --git a/stdlib/source/documentation/lux/math/number/frac.lux b/stdlib/source/documentation/lux/math/number/frac.lux index 80c7543c0..ca9f8eda0 100644 --- a/stdlib/source/documentation/lux/math/number/frac.lux +++ b/stdlib/source/documentation/lux/math/number/frac.lux @@ -95,7 +95,7 @@ "" [(log_by base it)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/math/number/i16.lux b/stdlib/source/documentation/lux/math/number/i16.lux index 9f5c6d51f..a57c0763c 100644 --- a/stdlib/source/documentation/lux/math/number/i16.lux +++ b/stdlib/source/documentation/lux/math/number/i16.lux @@ -13,7 +13,7 @@ (documentation: /.I16 "A 16-bit integer.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/math/number/i32.lux b/stdlib/source/documentation/lux/math/number/i32.lux index ff8550c4f..8c6449332 100644 --- a/stdlib/source/documentation/lux/math/number/i32.lux +++ b/stdlib/source/documentation/lux/math/number/i32.lux @@ -13,7 +13,7 @@ (documentation: /.I32 "A 32-bit integer.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/math/number/i64.lux b/stdlib/source/documentation/lux/math/number/i64.lux index bfd9f7bc8..a37f45f3c 100644 --- a/stdlib/source/documentation/lux/math/number/i64.lux +++ b/stdlib/source/documentation/lux/math/number/i64.lux @@ -71,7 +71,7 @@ "Given a width in the interval (0,64), yields an implementation for integers of that width." [(sub width)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/math/number/i8.lux b/stdlib/source/documentation/lux/math/number/i8.lux index 96995abed..12990d0cd 100644 --- a/stdlib/source/documentation/lux/math/number/i8.lux +++ b/stdlib/source/documentation/lux/math/number/i8.lux @@ -13,7 +13,7 @@ (documentation: /.I8 "A 8-bit integer.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/math/number/int.lux b/stdlib/source/documentation/lux/math/number/int.lux index 8e3e737f9..3a92c5b59 100644 --- a/stdlib/source/documentation/lux/math/number/int.lux +++ b/stdlib/source/documentation/lux/math/number/int.lux @@ -77,7 +77,7 @@ "Signed/arithmetic bitwise right-shift." [(right_shifted parameter subject)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/math/number/nat.lux b/stdlib/source/documentation/lux/math/number/nat.lux index 04da382fa..b2069e97d 100644 --- a/stdlib/source/documentation/lux/math/number/nat.lux +++ b/stdlib/source/documentation/lux/math/number/nat.lux @@ -41,7 +41,7 @@ (documentation: /.lcm "Least Common Multiple.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/math/number/ratio.lux b/stdlib/source/documentation/lux/math/number/ratio.lux index f74bf908d..2b5a80908 100644 --- a/stdlib/source/documentation/lux/math/number/ratio.lux +++ b/stdlib/source/documentation/lux/math/number/ratio.lux @@ -19,7 +19,7 @@ ["The denominator can be omitted if it is 1." (ratio numerator)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Rational numbers." diff --git a/stdlib/source/documentation/lux/math/number/rev.lux b/stdlib/source/documentation/lux/math/number/rev.lux index 67d9a74a6..53f534a92 100644 --- a/stdlib/source/documentation/lux/math/number/rev.lux +++ b/stdlib/source/documentation/lux/math/number/rev.lux @@ -62,7 +62,7 @@ "Rev(olution) reciprocal of a Nat(ural)." [(reciprocal numerator)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/math/random.lux b/stdlib/source/documentation/lux/math/random.lux index 2a76a9395..b20f61853 100644 --- a/stdlib/source/documentation/lux/math/random.lux +++ b/stdlib/source/documentation/lux/math/random.lux @@ -78,7 +78,7 @@ (documentation: /.split_mix_64 "An implementation of the SplitMix64 algorithm.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Pseudo-random number generation (PRNG) algorithms." diff --git a/stdlib/source/documentation/lux/meta.lux b/stdlib/source/documentation/lux/meta.lux index 76d2e02c7..038576f0d 100644 --- a/stdlib/source/documentation/lux/meta.lux +++ b/stdlib/source/documentation/lux/meta.lux @@ -153,7 +153,7 @@ "" [(eval type code)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Functions for extracting information from the state of the compiler." diff --git a/stdlib/source/documentation/lux/meta/location.lux b/stdlib/source/documentation/lux/meta/location.lux index 05c46e5a8..3a46da914 100644 --- a/stdlib/source/documentation/lux/meta/location.lux +++ b/stdlib/source/documentation/lux/meta/location.lux @@ -18,7 +18,7 @@ "" [(with location error)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/meta/symbol.lux b/stdlib/source/documentation/lux/meta/symbol.lux index 167295b35..1f43f3bc2 100644 --- a/stdlib/source/documentation/lux/meta/symbol.lux +++ b/stdlib/source/documentation/lux/meta/symbol.lux @@ -16,7 +16,7 @@ (documentation: /.short "The short part of a symbol.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/program.lux b/stdlib/source/documentation/lux/program.lux index fd7a1aa9a..ba3248150 100644 --- a/stdlib/source/documentation/lux/program.lux +++ b/stdlib/source/documentation/lux/program.lux @@ -25,7 +25,7 @@ [data (initialize program with config)] (do_something_with data)))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/static.lux b/stdlib/source/documentation/lux/static.lux index ce5778831..340ce505a 100644 --- a/stdlib/source/documentation/lux/static.lux +++ b/stdlib/source/documentation/lux/static.lux @@ -50,7 +50,7 @@ (is (Random ???) (random data generator)))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target.lux b/stdlib/source/documentation/lux/target.lux index 80110f427..57de0714a 100644 --- a/stdlib/source/documentation/lux/target.lux +++ b/stdlib/source/documentation/lux/target.lux @@ -20,7 +20,7 @@ (format "The name/ID of a platform targetted by a Lux compiler." \n "This information can be used to generate code targetting specific platforms, and to make programs cross-platform.")) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/js.lux b/stdlib/source/documentation/lux/target/js.lux index bb18ca694..97e7e1f46 100644 --- a/stdlib/source/documentation/lux/target/js.lux +++ b/stdlib/source/documentation/lux/target/js.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/jvm.lux b/stdlib/source/documentation/lux/target/jvm.lux index 6736fa255..4f0bde18a 100644 --- a/stdlib/source/documentation/lux/target/jvm.lux +++ b/stdlib/source/documentation/lux/target/jvm.lux @@ -12,7 +12,7 @@ ["[0]" / ["[1][0]" type]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/jvm/type.lux b/stdlib/source/documentation/lux/target/jvm/type.lux index d71e945e4..ca6ebf997 100644 --- a/stdlib/source/documentation/lux/target/jvm/type.lux +++ b/stdlib/source/documentation/lux/target/jvm/type.lux @@ -19,7 +19,7 @@ ["[1][0]" reflection] ["[1][0]" signature]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/jvm/type/alias.lux b/stdlib/source/documentation/lux/target/jvm/type/alias.lux index 8331296ba..94499cbd9 100644 --- a/stdlib/source/documentation/lux/target/jvm/type/alias.lux +++ b/stdlib/source/documentation/lux/target/jvm/type/alias.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/jvm/type/box.lux b/stdlib/source/documentation/lux/target/jvm/type/box.lux index f50af3403..c3caaf93a 100644 --- a/stdlib/source/documentation/lux/target/jvm/type/box.lux +++ b/stdlib/source/documentation/lux/target/jvm/type/box.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/jvm/type/category.lux b/stdlib/source/documentation/lux/target/jvm/type/category.lux index b40c83fb2..01e125b85 100644 --- a/stdlib/source/documentation/lux/target/jvm/type/category.lux +++ b/stdlib/source/documentation/lux/target/jvm/type/category.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/jvm/type/descriptor.lux b/stdlib/source/documentation/lux/target/jvm/type/descriptor.lux index 3aef9988a..6d81713a6 100644 --- a/stdlib/source/documentation/lux/target/jvm/type/descriptor.lux +++ b/stdlib/source/documentation/lux/target/jvm/type/descriptor.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/jvm/type/lux.lux b/stdlib/source/documentation/lux/target/jvm/type/lux.lux index c5d35237e..156d9757b 100644 --- a/stdlib/source/documentation/lux/target/jvm/type/lux.lux +++ b/stdlib/source/documentation/lux/target/jvm/type/lux.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/jvm/type/parser.lux b/stdlib/source/documentation/lux/target/jvm/type/parser.lux index bb8b8f823..d92da573a 100644 --- a/stdlib/source/documentation/lux/target/jvm/type/parser.lux +++ b/stdlib/source/documentation/lux/target/jvm/type/parser.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/jvm/type/reflection.lux b/stdlib/source/documentation/lux/target/jvm/type/reflection.lux index fea87d9e4..44439aa2d 100644 --- a/stdlib/source/documentation/lux/target/jvm/type/reflection.lux +++ b/stdlib/source/documentation/lux/target/jvm/type/reflection.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/jvm/type/signature.lux b/stdlib/source/documentation/lux/target/jvm/type/signature.lux index 47004cd58..f5cdaaf85 100644 --- a/stdlib/source/documentation/lux/target/jvm/type/signature.lux +++ b/stdlib/source/documentation/lux/target/jvm/type/signature.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/lua.lux b/stdlib/source/documentation/lux/target/lua.lux index ea7505684..ce850522c 100644 --- a/stdlib/source/documentation/lux/target/lua.lux +++ b/stdlib/source/documentation/lux/target/lua.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/python.lux b/stdlib/source/documentation/lux/target/python.lux index 7bfd72284..3fa6f0a6a 100644 --- a/stdlib/source/documentation/lux/target/python.lux +++ b/stdlib/source/documentation/lux/target/python.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/target/ruby.lux b/stdlib/source/documentation/lux/target/ruby.lux index 1a8752cc5..0422b06f0 100644 --- a/stdlib/source/documentation/lux/target/ruby.lux +++ b/stdlib/source/documentation/lux/target/ruby.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/test.lux b/stdlib/source/documentation/lux/test.lux index 535deb2a8..f6064a13c 100644 --- a/stdlib/source/documentation/lux/test.lux +++ b/stdlib/source/documentation/lux/test.lux @@ -100,7 +100,7 @@ "Executes multiple tests in parallel (if the host platform supports it) to take advantage of multiple cores." [(in_parallel tests)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Tools for unit & property-based/generative testing." diff --git a/stdlib/source/documentation/lux/time.lux b/stdlib/source/documentation/lux/time.lux index dbec1208c..8e38a8ee9 100644 --- a/stdlib/source/documentation/lux/time.lux +++ b/stdlib/source/documentation/lux/time.lux @@ -55,7 +55,7 @@ (format "Based on ISO 8601." \n "For example: 21:14:51.827")) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/time/date.lux b/stdlib/source/documentation/lux/time/date.lux index 56727b114..7c79001e0 100644 --- a/stdlib/source/documentation/lux/time/date.lux +++ b/stdlib/source/documentation/lux/time/date.lux @@ -24,7 +24,7 @@ (format "Based on ISO 8601." \n "For example: 2017-01-15")) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/time/day.lux b/stdlib/source/documentation/lux/time/day.lux index 5d9a5191a..dad5e72d3 100644 --- a/stdlib/source/documentation/lux/time/day.lux +++ b/stdlib/source/documentation/lux/time/day.lux @@ -19,7 +19,7 @@ (documentation: /.week "All the days, ordered by when they come in a week.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/time/duration.lux b/stdlib/source/documentation/lux/time/duration.lux index bdff85dfa..e55d85bcf 100644 --- a/stdlib/source/documentation/lux/time/duration.lux +++ b/stdlib/source/documentation/lux/time/duration.lux @@ -20,7 +20,7 @@ "" [(difference from to)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/time/instant.lux b/stdlib/source/documentation/lux/time/instant.lux index 742d4de59..431722137 100644 --- a/stdlib/source/documentation/lux/time/instant.lux +++ b/stdlib/source/documentation/lux/time/instant.lux @@ -46,7 +46,7 @@ "" [(of_date_time date time)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/time/month.lux b/stdlib/source/documentation/lux/time/month.lux index a8a04a2c1..8012bf0a4 100644 --- a/stdlib/source/documentation/lux/time/month.lux +++ b/stdlib/source/documentation/lux/time/month.lux @@ -27,7 +27,7 @@ (documentation: /.year "All the months, ordered by when they come in a year.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/time/year.lux b/stdlib/source/documentation/lux/time/year.lux index 7c138c422..ae9b14fb2 100644 --- a/stdlib/source/documentation/lux/time/year.lux +++ b/stdlib/source/documentation/lux/time/year.lux @@ -36,7 +36,7 @@ (format "Based on ISO 8601." \n "For example: 2017")) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/tool.lux b/stdlib/source/documentation/lux/tool.lux index c29d10467..347781dc6 100644 --- a/stdlib/source/documentation/lux/tool.lux +++ b/stdlib/source/documentation/lux/tool.lux @@ -17,7 +17,7 @@ ["[1][0]" generation] ["[1][0]" synthesis]]]]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (list.together (list /phase.documentation diff --git a/stdlib/source/documentation/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/documentation/lux/tool/compiler/language/lux/analysis.lux index a227efcaf..40b8c3673 100644 --- a/stdlib/source/documentation/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/documentation/lux/tool/compiler/language/lux/analysis.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/tool/compiler/language/lux/directive.lux b/stdlib/source/documentation/lux/tool/compiler/language/lux/directive.lux index 0b7ea6e61..52533cbb9 100644 --- a/stdlib/source/documentation/lux/tool/compiler/language/lux/directive.lux +++ b/stdlib/source/documentation/lux/tool/compiler/language/lux/directive.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/tool/compiler/language/lux/generation.lux b/stdlib/source/documentation/lux/tool/compiler/language/lux/generation.lux index 1582f45d7..e318c61e7 100644 --- a/stdlib/source/documentation/lux/tool/compiler/language/lux/generation.lux +++ b/stdlib/source/documentation/lux/tool/compiler/language/lux/generation.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/documentation/lux/tool/compiler/language/lux/synthesis.lux index 20ff65682..a831b31d4 100644 --- a/stdlib/source/documentation/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/documentation/lux/tool/compiler/language/lux/synthesis.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/tool/compiler/phase.lux b/stdlib/source/documentation/lux/tool/compiler/phase.lux index fbe76ea4c..a91acdeb0 100644 --- a/stdlib/source/documentation/lux/tool/compiler/phase.lux +++ b/stdlib/source/documentation/lux/tool/compiler/phase.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/type.lux b/stdlib/source/documentation/lux/type.lux index 3c913198a..c05db6d1e 100644 --- a/stdlib/source/documentation/lux/type.lux +++ b/stdlib/source/documentation/lux/type.lux @@ -153,7 +153,7 @@ [(let [side (Either Int Frac)] (List [side side]))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Basic functionality for working with types." diff --git a/stdlib/source/documentation/lux/type/check.lux b/stdlib/source/documentation/lux/type/check.lux index c0bef5b1b..e65a1ccd6 100644 --- a/stdlib/source/documentation/lux/type/check.lux +++ b/stdlib/source/documentation/lux/type/check.lux @@ -64,7 +64,7 @@ "Resolves every bound type-variable to yield a new type that is as resolved as possible." [(clean inputT)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "Type-checking functionality." diff --git a/stdlib/source/documentation/lux/type/dynamic.lux b/stdlib/source/documentation/lux/type/dynamic.lux index 613fb0167..511642334 100644 --- a/stdlib/source/documentation/lux/type/dynamic.lux +++ b/stdlib/source/documentation/lux/type/dynamic.lux @@ -26,7 +26,7 @@ [(is (try.Try Nat) (static Nat (dynamic 123)))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/type/implicit.lux b/stdlib/source/documentation/lux/type/implicit.lux index 95cafb20a..869295b0e 100644 --- a/stdlib/source/documentation/lux/type/implicit.lux +++ b/stdlib/source/documentation/lux/type/implicit.lux @@ -50,7 +50,7 @@ (n.= (at n.multiplication composite left right) (a/an composite left right))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/type/poly.lux b/stdlib/source/documentation/lux/type/poly.lux index 92183f398..5bcc6ceb2 100644 --- a/stdlib/source/documentation/lux/type/poly.lux +++ b/stdlib/source/documentation/lux/type/poly.lux @@ -21,7 +21,7 @@ "" [(code env type)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/type/primitive.lux b/stdlib/source/documentation/lux/type/primitive.lux index cbb9ac7bf..d8d651188 100644 --- a/stdlib/source/documentation/lux/type/primitive.lux +++ b/stdlib/source/documentation/lux/type/primitive.lux @@ -41,36 +41,36 @@ [(primitive String Text - (def: (string value) + (def (string value) (-> Text String) (abstraction value)) - (def: (text value) + (def (text value) (-> String Text) (representation value)))] ["Type-parameters are optional." (primitive (Duplicate a) [a a] - (def: (duplicate value) + (def (duplicate value) (All (_ a) (-> a (Duplicate a))) (abstraction [value value])))] ["Definitions can be nested." (primitive (Single a) a - (def: (single value) + (def (single value) (All (_ a) (-> a (Single a))) (abstraction value)) (primitive (Double a) [a a] - (def: (double value) + (def (double value) (All (_ a) (-> a (Double a))) (abstraction [value value])) - (def: (single' value) + (def (single' value) (All (_ a) (-> a (Single a))) (abstraction Single [value value])) @@ -89,12 +89,12 @@ (primitive Expression Any) (primitive Statement Any) - (def: (+ x y) + (def (+ x y) (-> (JavaScript Expression) (JavaScript Expression) (JavaScript Expression)) (abstraction (format "(" (representation x) "+" (representation y) ")"))) - (def: (while test body) + (def (while test body) (-> (JavaScript Expression) (JavaScript Statement) (JavaScript Statement)) (abstraction (format "while(" (representation test) ") {" @@ -109,15 +109,15 @@ (primitive Expression Any) (primitive Statement Any) - (def: (statement expression) + (def (statement expression) (-> (JavaScript Expression) (JavaScript Statement)) (transmutation expression)) - (def: (statement' expression) + (def (statement' expression) (-> (JavaScript Expression) (JavaScript Statement)) (transmutation JavaScript expression)))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/type/quotient.lux b/stdlib/source/documentation/lux/type/quotient.lux index ffa3075ff..573d9bdfd 100644 --- a/stdlib/source/documentation/lux/type/quotient.lux +++ b/stdlib/source/documentation/lux/type/quotient.lux @@ -27,17 +27,17 @@ (documentation: /.type "The Quotient type associated with a Class type." - [(def: even + [(def even (class even?)) - (def: Even + (def Even Type (type even)) (is Even (quotient even 123))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/type/refinement.lux b/stdlib/source/documentation/lux/type/refinement.lux index ddeee3c95..b663e9f41 100644 --- a/stdlib/source/documentation/lux/type/refinement.lux +++ b/stdlib/source/documentation/lux/type/refinement.lux @@ -38,17 +38,17 @@ (documentation: /.type "The Refined type associated with a Refiner type." - [(def: even + [(def even (refiner even?)) - (def: Even + (def Even Type (type even)) (is (Maybe Even) (even 123))]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/type/resource.lux b/stdlib/source/documentation/lux/type/resource.lux index 439fbbbce..1fbd8997e 100644 --- a/stdlib/source/documentation/lux/type/resource.lux +++ b/stdlib/source/documentation/lux/type/resource.lux @@ -91,7 +91,7 @@ [/.un_group] ) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/type/unit.lux b/stdlib/source/documentation/lux/type/unit.lux index fd518779f..fafcdf14a 100644 --- a/stdlib/source/documentation/lux/type/unit.lux +++ b/stdlib/source/documentation/lux/type/unit.lux @@ -31,11 +31,11 @@ (documentation: /.unit (format "Define a unit of measurement." \n "Both the name of the type, and the name of the Unit implementation must be specified.") - [(def: feet (unit []))]) + [(def feet (unit []))]) (documentation: /.scale "Define a scale of magnitude." - [(def: bajillion (scale [1 1,234,567,890]))]) + [(def bajillion (scale [1 1,234,567,890]))]) (documentation: /.re_scaled "" @@ -66,7 +66,7 @@ [/.second] ) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/type/variance.lux b/stdlib/source/documentation/lux/type/variance.lux index 6501ab999..4a504d3dd 100644 --- a/stdlib/source/documentation/lux/type/variance.lux +++ b/stdlib/source/documentation/lux/type/variance.lux @@ -22,7 +22,7 @@ (documentation: (/.In it) "A constraint for invariant types.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/world.lux b/stdlib/source/documentation/lux/world.lux index afbd6447b..46a62d977 100644 --- a/stdlib/source/documentation/lux/world.lux +++ b/stdlib/source/documentation/lux/world.lux @@ -21,7 +21,7 @@ ["[1][0]" program] ["[1][0]" shell]]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (all list#composite /console.documentation diff --git a/stdlib/source/documentation/lux/world/console.lux b/stdlib/source/documentation/lux/world/console.lux index d601e2012..909f6b665 100644 --- a/stdlib/source/documentation/lux/world/console.lux +++ b/stdlib/source/documentation/lux/world/console.lux @@ -29,7 +29,7 @@ "" [(mock mock init)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (`` (`` ($.module /._ "" diff --git a/stdlib/source/documentation/lux/world/file.lux b/stdlib/source/documentation/lux/world/file.lux index 6dacba4eb..b3c4d4a58 100644 --- a/stdlib/source/documentation/lux/world/file.lux +++ b/stdlib/source/documentation/lux/world/file.lux @@ -52,7 +52,7 @@ "Creates a new file with the given content if-and-only-if the file does not already exist." [(make_file monad fs content path)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (`` (`` ($.module /._ "" diff --git a/stdlib/source/documentation/lux/world/file/watch.lux b/stdlib/source/documentation/lux/world/file/watch.lux index c25efe7fc..405f88b90 100644 --- a/stdlib/source/documentation/lux/world/file/watch.lux +++ b/stdlib/source/documentation/lux/world/file/watch.lux @@ -38,7 +38,7 @@ "The default watcher for the default file-system.")) (these)) -(.def: .public documentation +(.def .public documentation (.List $.Module) (`` (`` ($.module /._ "" diff --git a/stdlib/source/documentation/lux/world/input/keyboard.lux b/stdlib/source/documentation/lux/world/input/keyboard.lux index a5c4fc1da..3a691b94b 100644 --- a/stdlib/source/documentation/lux/world/input/keyboard.lux +++ b/stdlib/source/documentation/lux/world/input/keyboard.lux @@ -19,7 +19,7 @@ (documentation: /.Press "A key-press for a key.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/world/net.lux b/stdlib/source/documentation/lux/world/net.lux index b0f152785..5cc8b9773 100644 --- a/stdlib/source/documentation/lux/world/net.lux +++ b/stdlib/source/documentation/lux/world/net.lux @@ -23,7 +23,7 @@ (documentation: /.URL "A Uniform Resource Locator.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/world/net/http/client.lux b/stdlib/source/documentation/lux/world/net/http/client.lux index 866adba7d..653285514 100644 --- a/stdlib/source/documentation/lux/world/net/http/client.lux +++ b/stdlib/source/documentation/lux/world/net/http/client.lux @@ -32,7 +32,7 @@ [/.trace] ) -(.def: .public documentation +(.def .public documentation (.List $.Module) (`` (`` ($.module /._ "" diff --git a/stdlib/source/documentation/lux/world/net/http/status.lux b/stdlib/source/documentation/lux/world/net/http/status.lux index 9a6e18691..a320efe02 100644 --- a/stdlib/source/documentation/lux/world/net/http/status.lux +++ b/stdlib/source/documentation/lux/world/net/http/status.lux @@ -93,7 +93,7 @@ [/.network_authentication_required] ) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/world/net/uri.lux b/stdlib/source/documentation/lux/world/net/uri.lux index ccaafada9..955eec57c 100644 --- a/stdlib/source/documentation/lux/world/net/uri.lux +++ b/stdlib/source/documentation/lux/world/net/uri.lux @@ -15,7 +15,7 @@ (documentation: /.separator "A separator for the pieces of a URI.") -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/world/output/video/resolution.lux b/stdlib/source/documentation/lux/world/output/video/resolution.lux index 66c3a8dff..39dcfdba5 100644 --- a/stdlib/source/documentation/lux/world/output/video/resolution.lux +++ b/stdlib/source/documentation/lux/world/output/video/resolution.lux @@ -43,7 +43,7 @@ [/.uhd_4k] ) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/world/program.lux b/stdlib/source/documentation/lux/world/program.lux index 0d7ab4d1a..52235985e 100644 --- a/stdlib/source/documentation/lux/world/program.lux +++ b/stdlib/source/documentation/lux/world/program.lux @@ -24,7 +24,7 @@ "" [(mock environment home directory)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) ($.module /._ "" diff --git a/stdlib/source/documentation/lux/world/shell.lux b/stdlib/source/documentation/lux/world/shell.lux index f0e7fbfe2..a38d28158 100644 --- a/stdlib/source/documentation/lux/world/shell.lux +++ b/stdlib/source/documentation/lux/world/shell.lux @@ -36,7 +36,7 @@ "" [(mock mock init)]) -(.def: .public documentation +(.def .public documentation (.List $.Module) (`` (`` ($.module /._ "" diff --git a/stdlib/source/experiment/compiler.lux b/stdlib/source/experiment/compiler.lux index 99acd4249..4f9e58377 100644 --- a/stdlib/source/experiment/compiler.lux +++ b/stdlib/source/experiment/compiler.lux @@ -6,7 +6,7 @@ [tool ["[0]" compiler (.only Custom)]]]]) -(def: .public (dummy parameters) +(def .public (dummy parameters) (Custom Nat [] []) {try.#Success [0 (function (_ input) diff --git a/stdlib/source/format/lux/data/binary.lux b/stdlib/source/format/lux/data/binary.lux index a0b96a581..ed497dd3f 100644 --- a/stdlib/source/format/lux/data/binary.lux +++ b/stdlib/source/format/lux/data/binary.lux @@ -33,7 +33,7 @@ ["</>" \\parser (.only Offset Size Parser)]) (with_template [<name> <extension> <post>] - [(def: <name> + [(def <name> (template (<name> <parameter> <subject>) [(<post> (<extension> (.int <parameter>) (.int <subject>)))]))] @@ -42,7 +42,7 @@ [n#* "lux i64 *" .nat] ) -(def: mask +(def mask (-> Size (I64 Any)) (|>> (n#* i64.bits_per_byte) i64.mask)) @@ -52,33 +52,33 @@ (type: .public Specification [Size Mutation]) -(def: .public no_op +(def .public no_op Specification [0 function.identity]) -(def: .public (instance [size mutation]) +(def .public (instance [size mutation]) (-> Specification Binary) (|> size \\unsafe.empty [0] mutation product.right)) -(def: .public monoid +(def .public monoid (Monoid Specification) (implementation - (def: identity + (def identity ..no_op) - (def: (composite [sizeL mutL] [sizeR mutR]) + (def (composite [sizeL mutL] [sizeR mutR]) [(n#+ sizeL sizeR) (|>> mutL mutR)]))) (type: .public (Writer a) (-> a Specification)) -(def: .public (result writer value) +(def .public (result writer value) (All (_ a) (-> (Writer a) a Binary)) (..instance (writer value))) (with_template [<name> <size> <write>] - [(def: .public <name> + [(def .public <name> (Writer (I64 Any)) (function (_ value) [<size> @@ -92,7 +92,7 @@ [bits_64 </>.size_64 \\unsafe.has_64!] ) -(def: .public (or left right) +(def .public (or left right) (All (_ l r) (-> (Writer l) (Writer r) (Writer (Or l r)))) (function (_ altV) (case altV @@ -109,37 +109,37 @@ [1 .#Right right]) ))) -(def: .public (and pre post) +(def .public (and pre post) (All (_ a b) (-> (Writer a) (Writer b) (Writer [a b]))) (function (_ [preV postV]) (at ..monoid composite (pre preV) (post postV)))) -(def: .public (rec body) +(def .public (rec body) (All (_ a) (-> (-> (Writer a) (Writer a)) (Writer a))) (function (again value) (body again value))) -(def: .public any +(def .public any (Writer Any) (function.constant ..no_op)) -(def: .public bit +(def .public bit (Writer Bit) (|>> (pipe.case #0 0 #1 1) ..bits_8)) (with_template [<name> <type>] - [(def: .public <name> (Writer <type>) ..bits_64)] + [(def .public <name> (Writer <type>) ..bits_64)] [nat Nat] [int Int] [rev Rev] ) -(def: .public frac +(def .public frac (Writer Frac) (|>> frac.bits ..bits_64)) -(def: .public (segment size) +(def .public (segment size) (-> Nat (Writer Binary)) (function (_ value) [size @@ -152,7 +152,7 @@ binary)])])) (with_template [<name> <bits> <size> <write>] - [(def: .public <name> + [(def .public <name> (Writer Binary) (let [mask (..mask <size>)] (function (_ value) @@ -172,7 +172,7 @@ ) (with_template [<name> <binary>] - [(def: .public <name> + [(def .public <name> (Writer Text) (|>> (at utf8.codec encoded) <binary>))] @@ -182,10 +182,10 @@ [utf8_64 ..binary_64] ) -(def: .public text ..utf8_64) +(def .public text ..utf8_64) (with_template [<name> <size> <write>] - [(def: .public (<name> valueW) + [(def .public (<name> valueW) (All (_ v) (-> (Writer v) (Writer (Sequence v)))) (function (_ value) (let [original_count (sequence.size value) @@ -214,25 +214,25 @@ [sequence_64 </>.size_64 \\unsafe.has_64!] ) -(def: .public maybe +(def .public maybe (All (_ a) (-> (Writer a) (Writer (Maybe a)))) (..or ..any)) -(def: .public (list value) +(def .public (list value) (All (_ a) (-> (Writer a) (Writer (List a)))) (..rec (|>> (..and value) (..or ..any)))) -(def: .public (set value) +(def .public (set value) (All (_ a) (-> (Writer a) (Writer (Set a)))) (|>> set.list (..list value))) -(def: .public symbol +(def .public symbol (Writer Symbol) (..and ..text ..text)) -(def: .public type +(def .public type (Writer Type) (..rec (function (_ again) @@ -263,11 +263,11 @@ [10 .#Named (..and ..symbol again)]) )))))) -(def: .public location +(def .public location (Writer Location) (all ..and ..text ..nat ..nat)) -(def: .public code +(def .public code (Writer Code) (..rec (function (_ again) diff --git a/stdlib/source/format/lux/data/text.lux b/stdlib/source/format/lux/data/text.lux index 606cace14..e5b3a005c 100644 --- a/stdlib/source/format/lux/data/text.lux +++ b/stdlib/source/format/lux/data/text.lux @@ -42,18 +42,18 @@ (type: .public (Format a) (-> a Text)) -(def: .public functor +(def .public functor (contravariant.Functor Format) (implementation - (def: (each f fb) + (def (each f fb) (|>> f fb)))) -(def: .public format +(def .public format (syntax (_ [fragments (<>.many <code>.any)]) (in (.list (` (all "lux text concat" (~+ fragments))))))) (with_template [<name> <type> <formatter>] - [(def: .public <name> + [(def .public <name> (Format <type>) <formatter>)] @@ -83,7 +83,7 @@ (with_template [<type> <format>,<codec>] [(`` (with_template [<format> <codec>] - [(def: .public <format> + [(def .public <format> (Format <type>) (at <codec> encoded))] @@ -111,18 +111,18 @@ [frac_16 frac.hex]]] ) -(def: .public (mod modular) +(def .public (mod modular) (All (_ m) (Format (modular.Mod m))) (let [codec (modular.codec (modular.modulus modular))] (at codec encoded modular))) -(def: .public (list formatter) +(def .public (list formatter) (All (_ a) (-> (Format a) (Format (List a)))) (|>> (list#each (|>> formatter (format " "))) text.together (text.enclosed ["(list" ")"]))) -(def: .public (maybe format) +(def .public (maybe format) (All (_ a) (-> (Format a) (Format (Maybe a)))) (function (_ value) (case value diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index 483362c7d..28507c829 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -823,7 +823,7 @@ {#End}}}))) #0) -("lux def" def:'' +("lux def" def'' ("lux macro" (function'' [tokens] ({{#Item [export_policy @@ -840,7 +840,7 @@ {#End}]}) _ - (failure "Wrong syntax for def:''")} + (failure "Wrong syntax for def''")} tokens))) #0) @@ -856,580 +856,580 @@ tokens))) #1) -(def:'' .public comment - Macro - (macro (_ tokens) - (meta#in {#End}))) +(def'' .public comment + Macro + (macro (_ tokens) + (meta#in {#End}))) -(def:'' .private $' - Macro - (macro (_ tokens) - ({{#Item x {#End}} - (meta#in tokens) +(def'' .private $' + Macro + (macro (_ tokens) + ({{#Item x {#End}} + (meta#in tokens) - {#Item x {#Item y xs}} - (meta#in {#Item (form$ {#Item (symbol$ [..prelude "$'"]) - {#Item (variant$ {#Item (symbol$ [..prelude "#Apply"]) - {#Item y {#Item x {#End}}}}) - xs}}) - {#End}}) + {#Item x {#Item y xs}} + (meta#in {#Item (form$ {#Item (symbol$ [..prelude "$'"]) + {#Item (variant$ {#Item (symbol$ [..prelude "#Apply"]) + {#Item y {#Item x {#End}}}}) + xs}}) + {#End}}) - _ - (failure "Wrong syntax for $'")} - tokens))) - -(def:'' .private (list#mix f init xs) - ... (All (_ a b) (-> (-> b a a) a (List b) a)) - {#UnivQ {#End} {#UnivQ {#End} {#Function {#Function {#Parameter 1} - {#Function {#Parameter 3} - {#Parameter 3}}} - {#Function {#Parameter 3} - {#Function ($' List {#Parameter 1}) - {#Parameter 3}}}}}} - ({{#End} - init + _ + (failure "Wrong syntax for $'")} + tokens))) + +(def'' .private (list#mix f init xs) + ... (All (_ a b) (-> (-> b a a) a (List b) a)) + {#UnivQ {#End} {#UnivQ {#End} {#Function {#Function {#Parameter 1} + {#Function {#Parameter 3} + {#Parameter 3}}} + {#Function {#Parameter 3} + {#Function ($' List {#Parameter 1}) + {#Parameter 3}}}}}} + ({{#End} + init + + {#Item x xs'} + (list#mix f (f x init) xs')} + xs)) + +(def'' .private (list#reversed list) + {#UnivQ {#End} + {#Function ($' List {#Parameter 1}) ($' List {#Parameter 1})}} + (list#mix ("lux type check" {#UnivQ {#End} + {#Function {#Parameter 1} {#Function ($' List {#Parameter 1}) ($' List {#Parameter 1})}}} + (function'' [head tail] {#Item head tail})) + {#End} + list)) + +(def'' .private (list#each f xs) + {#UnivQ {#End} + {#UnivQ {#End} + {#Function {#Function {#Parameter 3} {#Parameter 1}} + {#Function ($' List {#Parameter 3}) + ($' List {#Parameter 1})}}}} + (list#mix (function'' [head tail] {#Item (f head) tail}) + {#End} + (list#reversed xs))) + +(def'' .private Replacement_Environment + Type + ($' List {#Product Text Code})) - {#Item x xs'} - (list#mix f (f x init) xs')} - xs)) +(def'' .private (replacement_environment xs ys) + {#Function ($' List Text) {#Function ($' List Code) Replacement_Environment}} + ({[{#Item x xs'} {#Item y ys'}] + {#Item [x y] (replacement_environment xs' ys')} -(def:'' .private (list#reversed list) - {#UnivQ {#End} - {#Function ($' List {#Parameter 1}) ($' List {#Parameter 1})}} - (list#mix ("lux type check" {#UnivQ {#End} - {#Function {#Parameter 1} {#Function ($' List {#Parameter 1}) ($' List {#Parameter 1})}}} - (function'' [head tail] {#Item head tail})) - {#End} - list)) - -(def:'' .private (list#each f xs) - {#UnivQ {#End} - {#UnivQ {#End} - {#Function {#Function {#Parameter 3} {#Parameter 1}} - {#Function ($' List {#Parameter 3}) - ($' List {#Parameter 1})}}}} - (list#mix (function'' [head tail] {#Item (f head) tail}) - {#End} - (list#reversed xs))) + _ + {#End}} + [xs ys])) -(def:'' .private Replacement_Environment - Type - ($' List {#Product Text Code})) +(def'' .private (text#= reference sample) + {#Function Text {#Function Text Bit}} + ("lux text =" reference sample)) -(def:'' .private (replacement_environment xs ys) - {#Function ($' List Text) {#Function ($' List Code) Replacement_Environment}} - ({[{#Item x xs'} {#Item y ys'}] - {#Item [x y] (replacement_environment xs' ys')} +(def'' .private (replacement for environment) + {#Function Text {#Function Replacement_Environment ($' Maybe Code)}} + ({{#End} + {#None} - _ - {#End}} - [xs ys])) + {#Item [k v] environment'} + ({[#1] {#Some v} + [#0] (replacement for environment')} + (text#= k for))} + environment)) -(def:'' .private (text#= reference sample) - {#Function Text {#Function Text Bit}} - ("lux text =" reference sample)) +(def'' .private (with_replacements reps syntax) + {#Function Replacement_Environment {#Function Code Code}} + ({[_ {#Symbol "" name}] + ({{#Some replacement} + replacement -(def:'' .private (replacement for environment) - {#Function Text {#Function Replacement_Environment ($' Maybe Code)}} - ({{#End} - {#None} + {#None} + syntax} + (..replacement name reps)) - {#Item [k v] environment'} - ({[#1] {#Some v} - [#0] (replacement for environment')} - (text#= k for))} - environment)) + [meta {#Form parts}] + [meta {#Form (list#each (with_replacements reps) parts)}] -(def:'' .private (with_replacements reps syntax) - {#Function Replacement_Environment {#Function Code Code}} - ({[_ {#Symbol "" name}] - ({{#Some replacement} - replacement + [meta {#Variant members}] + [meta {#Variant (list#each (with_replacements reps) members)}] - {#None} - syntax} - (..replacement name reps)) + [meta {#Tuple members}] + [meta {#Tuple (list#each (with_replacements reps) members)}] + + _ + syntax} + syntax)) + +(def'' .private (n/* param subject) + {#Function Nat {#Function Nat Nat}} + ("lux type as" Nat + ("lux i64 *" + ("lux type as" Int param) + ("lux type as" Int subject)))) + +(def'' .private (list#size list) + {#UnivQ {#End} + {#Function ($' List {#Parameter 1}) Nat}} + (list#mix (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list)) + +(def'' .private (let$ binding value body) + {#Function Code {#Function Code {#Function Code Code}}} + (form$ {#Item (variant$ {#Item binding {#Item body {#End}}}) + {#Item value {#End}}})) + +(def'' .private |#End| + Code + (variant$ {#Item (symbol$ [..prelude "#End"]) {#End}})) + +(def'' .private (|#Item| head tail) + {#Function Code {#Function Code Code}} + (variant$ {#Item (symbol$ [..prelude "#Item"]) + {#Item head + {#Item tail + {#End}}}})) + +(def'' .private (UnivQ$ body) + {#Function Code Code} + (variant$ {#Item (symbol$ [..prelude "#UnivQ"]) {#Item ..|#End| {#Item body {#End}}}})) + +(def'' .private (ExQ$ body) + {#Function Code Code} + (variant$ {#Item (symbol$ [..prelude "#ExQ"]) {#Item ..|#End| {#Item body {#End}}}})) + +(def'' .private quantification_level + Text + ("lux text concat" double_quote + ("lux text concat" "quantification_level" + double_quote))) + +(def'' .private quantified + {#Function Code Code} + (let$ (local$ ..quantification_level) (nat$ 0))) + +(def'' .private (quantified_type_parameter idx) + {#Function Nat Code} + (variant$ {#Item (symbol$ [..prelude "#Parameter"]) + {#Item (form$ {#Item (text$ "lux i64 +") + {#Item (local$ ..quantification_level) + {#Item (nat$ idx) + {#End}}}}) + {#End}}})) + +(def'' .private (next_level depth) + {#Function Nat Nat} + ("lux i64 +" 2 depth)) + +(def'' .private (self_id? id) + {#Function Nat Bit} + ("lux i64 =" id ("lux type as" Nat + ("lux i64 *" +2 + ("lux i64 /" +2 + ("lux type as" Int + id)))))) + +(def'' .public (__adjusted_quantified_type__ permission depth type) + {#Function Nat {#Function Nat {#Function Type Type}}} + ({0 + ({... Jackpot! + {#Parameter id} + ({id' + ({[#0] {#Parameter id'} + [#1] {#Parameter ("lux i64 -" 2 id')}} + (self_id? id))} + ("lux i64 -" ("lux i64 -" depth id) 0)) + + ... Recur + {#Primitive name parameters} + {#Primitive name (list#each (__adjusted_quantified_type__ permission depth) + parameters)} + + {#Sum left right} + {#Sum (__adjusted_quantified_type__ permission depth left) + (__adjusted_quantified_type__ permission depth right)} + + {#Product left right} + {#Product (__adjusted_quantified_type__ permission depth left) + (__adjusted_quantified_type__ permission depth right)} + + {#Function input output} + {#Function (__adjusted_quantified_type__ permission depth input) + (__adjusted_quantified_type__ permission depth output)} + + {#UnivQ environment body} + {#UnivQ environment + (__adjusted_quantified_type__ permission (next_level depth) body)} + + {#ExQ environment body} + {#ExQ environment + (__adjusted_quantified_type__ permission (next_level depth) body)} + + {#Apply parameter function} + {#Apply (__adjusted_quantified_type__ permission depth parameter) + (__adjusted_quantified_type__ permission depth function)} - [meta {#Form parts}] - [meta {#Form (list#each (with_replacements reps) parts)}] + ... Leave these alone. + {#Named name anonymous} type + {#Var id} type + {#Ex id} type} + type) - [meta {#Variant members}] - [meta {#Variant (list#each (with_replacements reps) members)}] + _ + type} + permission)) + +(def'' .private (with_correct_quantification body) + {#Function Code Code} + (form$ {#Item (symbol$ [prelude "__adjusted_quantified_type__"]) + {#Item (local$ ..quantification_level) + {#Item (nat$ 0) + {#Item body + {#End}}}}})) + +(def'' .private (with_quantification depth body) + {#Function Nat {#Function Code Code}} + ({g!level + (let$ g!level + (form$ {#Item (text$ "lux i64 +") + {#Item g!level + {#Item (nat$ ("lux type as" Nat + ("lux i64 *" +2 + ("lux type as" Int + depth)))) + {#End}}}}) + body)} + (local$ ..quantification_level))) + +(def'' .private (initialized_quantification? lux) + {#Function Lux Bit} + ({[..#info _ ..#source _ ..#current_module _ ..#modules _ + ..#scopes scopes ..#type_context _ ..#host _ + ..#seed _ ..#expected _ ..#location _ ..#extensions _ + ..#scope_type_vars _ ..#eval _] + (list#mix (function'' [scope verdict] + ({[#1] #1 + _ ({[..#name _ ..#inner _ ..#captured _ + ..#locals [..#counter _ + ..#mappings locals]] + (list#mix (function'' [local verdict] + ({[local _] + ({[#1] #1 + _ ("lux text =" ..quantification_level local)} + verdict)} + local)) + #0 + locals)} + scope)} + verdict)) + #0 + scopes)} + lux)) + +(def'' .public All + Macro + (macro (_ tokens lux) + ({{#Item [_ {#Form {#Item self_name args}}] + {#Item body {#End}}} + {#Right [lux + {#Item ({raw + ({[#1] raw + [#0] (..quantified raw)} + (initialized_quantification? lux))} + ({{#End} + body + + {#Item head tail} + (with_correct_quantification + (let$ self_name (quantified_type_parameter 0) + ({[_ raw] + raw} + (list#mix (function'' [parameter offset,body'] + ({[offset body'] + [("lux i64 +" 2 offset) + (let$ parameter (quantified_type_parameter ("lux i64 +" offset 1)) + (UnivQ$ body'))]} + offset,body')) + [0 (with_quantification (list#size args) + body)] + args))))} + args)) + {#End}}]} + + _ + {#Left "Wrong syntax for All"}} + tokens))) + +(def'' .public Ex + Macro + (macro (_ tokens lux) + ({{#Item [_ {#Form {#Item self_name args}}] + {#Item body {#End}}} + {#Right [lux + {#Item ({raw + ({[#1] raw + [#0] (..quantified raw)} + (initialized_quantification? lux))} + ({{#End} + body + + {#Item head tail} + (with_correct_quantification + (let$ self_name (quantified_type_parameter 0) + ({[_ raw] + raw} + (list#mix (function'' [parameter offset,body'] + ({[offset body'] + [("lux i64 +" 2 offset) + (let$ parameter (quantified_type_parameter ("lux i64 +" offset 1)) + (ExQ$ body'))]} + offset,body')) + [0 (with_quantification (list#size args) + body)] + args))))} + args)) + {#End}}]} + + _ + {#Left "Wrong syntax for Ex"}} + tokens))) + +(def'' .public -> + Macro + (macro (_ tokens) + ({{#Item output inputs} + (meta#in {#Item (list#mix ("lux type check" {#Function Code {#Function Code Code}} + (function'' [i o] (variant$ {#Item (symbol$ [..prelude "#Function"]) {#Item i {#Item o {#End}}}}))) + output + inputs) + {#End}}) + + _ + (failure "Wrong syntax for ->")} + (list#reversed tokens)))) - [meta {#Tuple members}] - [meta {#Tuple (list#each (with_replacements reps) members)}] - - _ - syntax} - syntax)) - -(def:'' .private (n/* param subject) - {#Function Nat {#Function Nat Nat}} - ("lux type as" Nat - ("lux i64 *" - ("lux type as" Int param) - ("lux type as" Int subject)))) - -(def:'' .private (list#size list) - {#UnivQ {#End} - {#Function ($' List {#Parameter 1}) Nat}} - (list#mix (function'' [_ acc] ("lux i64 +" 1 acc)) 0 list)) - -(def:'' .private (let$ binding value body) - {#Function Code {#Function Code {#Function Code Code}}} - (form$ {#Item (variant$ {#Item binding {#Item body {#End}}}) - {#Item value {#End}}})) - -(def:'' .private |#End| - Code - (variant$ {#Item (symbol$ [..prelude "#End"]) {#End}})) - -(def:'' .private (|#Item| head tail) - {#Function Code {#Function Code Code}} - (variant$ {#Item (symbol$ [..prelude "#Item"]) - {#Item head - {#Item tail - {#End}}}})) - -(def:'' .private (UnivQ$ body) - {#Function Code Code} - (variant$ {#Item (symbol$ [..prelude "#UnivQ"]) {#Item ..|#End| {#Item body {#End}}}})) - -(def:'' .private (ExQ$ body) - {#Function Code Code} - (variant$ {#Item (symbol$ [..prelude "#ExQ"]) {#Item ..|#End| {#Item body {#End}}}})) - -(def:'' .private quantification_level - Text - ("lux text concat" double_quote - ("lux text concat" "quantification_level" - double_quote))) - -(def:'' .private quantified - {#Function Code Code} - (let$ (local$ ..quantification_level) (nat$ 0))) - -(def:'' .private (quantified_type_parameter idx) - {#Function Nat Code} - (variant$ {#Item (symbol$ [..prelude "#Parameter"]) - {#Item (form$ {#Item (text$ "lux i64 +") - {#Item (local$ ..quantification_level) - {#Item (nat$ idx) - {#End}}}}) - {#End}}})) - -(def:'' .private (next_level depth) - {#Function Nat Nat} - ("lux i64 +" 2 depth)) - -(def:'' .private (self_id? id) - {#Function Nat Bit} - ("lux i64 =" id ("lux type as" Nat - ("lux i64 *" +2 - ("lux i64 /" +2 - ("lux type as" Int - id)))))) - -(def:'' .public (__adjusted_quantified_type__ permission depth type) - {#Function Nat {#Function Nat {#Function Type Type}}} - ({0 - ({... Jackpot! - {#Parameter id} - ({id' - ({[#0] {#Parameter id'} - [#1] {#Parameter ("lux i64 -" 2 id')}} - (self_id? id))} - ("lux i64 -" ("lux i64 -" depth id) 0)) - - ... Recur - {#Primitive name parameters} - {#Primitive name (list#each (__adjusted_quantified_type__ permission depth) - parameters)} - - {#Sum left right} - {#Sum (__adjusted_quantified_type__ permission depth left) - (__adjusted_quantified_type__ permission depth right)} - - {#Product left right} - {#Product (__adjusted_quantified_type__ permission depth left) - (__adjusted_quantified_type__ permission depth right)} - - {#Function input output} - {#Function (__adjusted_quantified_type__ permission depth input) - (__adjusted_quantified_type__ permission depth output)} - - {#UnivQ environment body} - {#UnivQ environment - (__adjusted_quantified_type__ permission (next_level depth) body)} - - {#ExQ environment body} - {#ExQ environment - (__adjusted_quantified_type__ permission (next_level depth) body)} - - {#Apply parameter function} - {#Apply (__adjusted_quantified_type__ permission depth parameter) - (__adjusted_quantified_type__ permission depth function)} +(def'' .public list + Macro + (macro (_ xs) + (meta#in {#Item (list#mix |#Item| |#End| (list#reversed xs)) + {#End}}))) - ... Leave these alone. - {#Named name anonymous} type - {#Var id} type - {#Ex id} type} - type) +(def'' .private partial_list + Macro + (macro (_ xs) + ({{#Item last init} + (meta#in (list (list#mix |#Item| last init))) - _ - type} - permission)) - -(def:'' .private (with_correct_quantification body) - {#Function Code Code} - (form$ {#Item (symbol$ [prelude "__adjusted_quantified_type__"]) - {#Item (local$ ..quantification_level) - {#Item (nat$ 0) - {#Item body - {#End}}}}})) - -(def:'' .private (with_quantification depth body) - {#Function Nat {#Function Code Code}} - ({g!level - (let$ g!level - (form$ {#Item (text$ "lux i64 +") - {#Item g!level - {#Item (nat$ ("lux type as" Nat - ("lux i64 *" +2 - ("lux type as" Int - depth)))) - {#End}}}}) - body)} - (local$ ..quantification_level))) - -(def:'' .private (initialized_quantification? lux) - {#Function Lux Bit} - ({[..#info _ ..#source _ ..#current_module _ ..#modules _ - ..#scopes scopes ..#type_context _ ..#host _ - ..#seed _ ..#expected _ ..#location _ ..#extensions _ - ..#scope_type_vars _ ..#eval _] - (list#mix (function'' [scope verdict] - ({[#1] #1 - _ ({[..#name _ ..#inner _ ..#captured _ - ..#locals [..#counter _ - ..#mappings locals]] - (list#mix (function'' [local verdict] - ({[local _] - ({[#1] #1 - _ ("lux text =" ..quantification_level local)} - verdict)} - local)) - #0 - locals)} - scope)} - verdict)) - #0 - scopes)} - lux)) - -(def:'' .public All - Macro - (macro (_ tokens lux) - ({{#Item [_ {#Form {#Item self_name args}}] - {#Item body {#End}}} - {#Right [lux - {#Item ({raw - ({[#1] raw - [#0] (..quantified raw)} - (initialized_quantification? lux))} - ({{#End} - body - - {#Item head tail} - (with_correct_quantification - (let$ self_name (quantified_type_parameter 0) - ({[_ raw] - raw} - (list#mix (function'' [parameter offset,body'] - ({[offset body'] - [("lux i64 +" 2 offset) - (let$ parameter (quantified_type_parameter ("lux i64 +" offset 1)) - (UnivQ$ body'))]} - offset,body')) - [0 (with_quantification (list#size args) - body)] - args))))} - args)) - {#End}}]} - - _ - {#Left "Wrong syntax for All"}} - tokens))) + _ + (failure "Wrong syntax for partial_list")} + (list#reversed xs)))) -(def:'' .public Ex - Macro - (macro (_ tokens lux) - ({{#Item [_ {#Form {#Item self_name args}}] - {#Item body {#End}}} - {#Right [lux - {#Item ({raw - ({[#1] raw - [#0] (..quantified raw)} - (initialized_quantification? lux))} - ({{#End} - body - - {#Item head tail} - (with_correct_quantification - (let$ self_name (quantified_type_parameter 0) - ({[_ raw] - raw} - (list#mix (function'' [parameter offset,body'] - ({[offset body'] - [("lux i64 +" 2 offset) - (let$ parameter (quantified_type_parameter ("lux i64 +" offset 1)) - (ExQ$ body'))]} - offset,body')) - [0 (with_quantification (list#size args) - body)] - args))))} - args)) - {#End}}]} - - _ - {#Left "Wrong syntax for Ex"}} - tokens))) +(def'' .public Union + Macro + (macro (_ tokens) + ({{#End} + (meta#in (list (symbol$ [..prelude "Nothing"]))) -(def:'' .public -> - Macro - (macro (_ tokens) - ({{#Item output inputs} - (meta#in {#Item (list#mix ("lux type check" {#Function Code {#Function Code Code}} - (function'' [i o] (variant$ {#Item (symbol$ [..prelude "#Function"]) {#Item i {#Item o {#End}}}}))) - output - inputs) - {#End}}) - - _ - (failure "Wrong syntax for ->")} - (list#reversed tokens)))) + {#Item last prevs} + (meta#in (list (list#mix (function'' [left right] (variant$ (list (symbol$ [..prelude "#Sum"]) left right))) + last + prevs)))} + (list#reversed tokens)))) -(def:'' .public list - Macro - (macro (_ xs) - (meta#in {#Item (list#mix |#Item| |#End| (list#reversed xs)) - {#End}}))) +(def'' .public Tuple + Macro + (macro (_ tokens) + ({{#End} + (meta#in (list (symbol$ [..prelude "Any"]))) -(def:'' .private partial_list - Macro - (macro (_ xs) - ({{#Item last init} - (meta#in (list (list#mix |#Item| last init))) + {#Item last prevs} + (meta#in (list (list#mix (function'' [left right] (variant$ (list (symbol$ [..prelude "#Product"]) left right))) + last + prevs)))} + (list#reversed tokens)))) - _ - (failure "Wrong syntax for partial_list")} - (list#reversed xs)))) +(def'' .private function' + Macro + (macro (_ tokens) + (let'' [name tokens'] ({{#Item [[_ {#Symbol ["" name]}] tokens']} + [name tokens'] -(def:'' .public Union - Macro - (macro (_ tokens) - ({{#End} - (meta#in (list (symbol$ [..prelude "Nothing"]))) + _ + ["" tokens]} + tokens) + ({{#Item [[_ {#Tuple args}] {#Item [body {#End}]}]} + ({{#End} + (failure "function' requires a non-empty arguments tuple.") + + {#Item [harg targs]} + (meta#in (list (form$ (list (tuple$ (list (local$ name) + harg)) + (list#mix (function'' [arg body'] + (form$ (list (tuple$ (list (local$ "") + arg)) + body'))) + body + (list#reversed targs))))))} + args) - {#Item last prevs} - (meta#in (list (list#mix (function'' [left right] (variant$ (list (symbol$ [..prelude "#Sum"]) left right))) - last - prevs)))} - (list#reversed tokens)))) + _ + (failure "Wrong syntax for function'")} + tokens')))) + +(def'' .private def''' + Macro + (macro (_ tokens) + ({{#Item [export_policy + {#Item [[_ {#Form {#Item [name args]}}] + {#Item [type {#Item [body {#End}]}]}]}]} + (meta#in (list (form$ (list (text$ "lux def") + name + (form$ (list (text$ "lux type check") + type + (form$ (list (symbol$ [..prelude "function'"]) + name + (tuple$ args) + body)))) + export_policy)))) + + {#Item [export_policy {#Item [name {#Item [type {#Item [body {#End}]}]}]}]} + (meta#in (list (form$ (list (text$ "lux def") + name + (form$ (list (text$ "lux type check") + type + body)) + export_policy)))) -(def:'' .public Tuple - Macro - (macro (_ tokens) - ({{#End} - (meta#in (list (symbol$ [..prelude "Any"]))) + _ + (failure "Wrong syntax for def'''")} + tokens))) - {#Item last prevs} - (meta#in (list (list#mix (function'' [left right] (variant$ (list (symbol$ [..prelude "#Product"]) left right))) - last - prevs)))} - (list#reversed tokens)))) +(def''' .public Or + Macro + ..Union) -(def:'' .private function' +(def''' .public And Macro - (macro (_ tokens) - (let'' [name tokens'] ({{#Item [[_ {#Symbol ["" name]}] tokens']} - [name tokens'] + ..Tuple) - _ - ["" tokens]} - tokens) - ({{#Item [[_ {#Tuple args}] {#Item [body {#End}]}]} - ({{#End} - (failure "function' requires a non-empty arguments tuple.") - - {#Item [harg targs]} - (meta#in (list (form$ (list (tuple$ (list (local$ name) - harg)) - (list#mix (function'' [arg body'] - (form$ (list (tuple$ (list (local$ "") - arg)) - body'))) - body - (list#reversed targs))))))} - args) +(def''' .private (pairs xs) + (All (_ a) (-> ($' List a) ($' Maybe ($' List (Tuple a a))))) + ({{#Item x {#Item y xs'}} + ({{#Some tail} + {#Some {#Item [x y] tail}} + + {#None} + {#None}} + (pairs xs')) - _ - (failure "Wrong syntax for function'")} - tokens')))) + {#End} + {#Some {#End}} -(def:'' .private def:''' - Macro - (macro (_ tokens) - ({{#Item [export_policy - {#Item [[_ {#Form {#Item [name args]}}] - {#Item [type {#Item [body {#End}]}]}]}]} - (meta#in (list (form$ (list (text$ "lux def") - name - (form$ (list (text$ "lux type check") - type - (form$ (list (symbol$ [..prelude "function'"]) - name - (tuple$ args) - body)))) - export_policy)))) - - {#Item [export_policy {#Item [name {#Item [type {#Item [body {#End}]}]}]}]} - (meta#in (list (form$ (list (text$ "lux def") - name - (form$ (list (text$ "lux type check") - type - body)) - export_policy)))) + _ + {#None}} + xs)) - _ - (failure "Wrong syntax for def:'''")} - tokens))) - -(def:''' .public Or - Macro - ..Union) - -(def:''' .public And - Macro - ..Tuple) - -(def:''' .private (pairs xs) - (All (_ a) (-> ($' List a) ($' Maybe ($' List (Tuple a a))))) - ({{#Item x {#Item y xs'}} - ({{#Some tail} - {#Some {#Item [x y] tail}} +(def'' .private let' + Macro + (macro (_ tokens) + ({{#Item [_ {#Tuple bindings}] {#Item body {#End}}} + ({{#Some bindings} + (meta#in (list (list#mix ("lux type check" (-> (Tuple Code Code) Code + Code) + (function' [binding body] + ({[label value] + (form$ (list (variant$ (list label body)) value))} + binding))) + body + (list#reversed bindings)))) {#None} - {#None}} - (pairs xs')) - - {#End} - {#Some {#End}} + (failure "Wrong syntax for let'")} + (pairs bindings)) _ - {#None}} - xs)) - -(def:'' .private let' - Macro - (macro (_ tokens) - ({{#Item [_ {#Tuple bindings}] {#Item body {#End}}} - ({{#Some bindings} - (meta#in (list (list#mix ("lux type check" (-> (Tuple Code Code) Code - Code) - (function' [binding body] - ({[label value] - (form$ (list (variant$ (list label body)) value))} - binding))) - body - (list#reversed bindings)))) - - {#None} - (failure "Wrong syntax for let'")} - (pairs bindings)) + (failure "Wrong syntax for let'")} + tokens))) - _ - (failure "Wrong syntax for let'")} - tokens))) +(def''' .private (any? p xs) + (All (_ a) + (-> (-> a Bit) ($' List a) Bit)) + ({{#End} + #0 -(def:''' .private (any? p xs) - (All (_ a) - (-> (-> a Bit) ($' List a) Bit)) - ({{#End} - #0 + {#Item x xs'} + ({[#1] #1 + [#0] (any? p xs')} + (p x))} + xs)) - {#Item x xs'} - ({[#1] #1 - [#0] (any? p xs')} - (p x))} - xs)) +(def''' .private (with_location content) + (-> Code Code) + (tuple$ (list (tuple$ (list (text$ "") (nat$ 0) (nat$ 0))) + content))) -(def:''' .private (with_location content) - (-> Code Code) - (tuple$ (list (tuple$ (list (text$ "") (nat$ 0) (nat$ 0))) - content))) +(def''' .private (untemplated_list tokens) + (-> ($' List Code) Code) + ({{#End} + |#End| -(def:''' .private (untemplated_list tokens) - (-> ($' List Code) Code) - ({{#End} - |#End| + {#Item token tokens'} + (|#Item| token (untemplated_list tokens'))} + tokens)) - {#Item token tokens'} - (|#Item| token (untemplated_list tokens'))} - tokens)) +(def''' .private (list#composite xs ys) + (All (_ a) (-> ($' List a) ($' List a) ($' List a))) + (list#mix (function' [head tail] {#Item head tail}) + ys + (list#reversed xs))) -(def:''' .private (list#composite xs ys) - (All (_ a) (-> ($' List a) ($' List a) ($' List a))) - (list#mix (function' [head tail] {#Item head tail}) - ys - (list#reversed xs))) +(def''' .private (right_associativity op a1 a2) + (-> Code Code Code Code) + ({[_ {#Form parts}] + (form$ (list#composite parts (list a1 a2))) -(def:''' .private (right_associativity op a1 a2) - (-> Code Code Code Code) - ({[_ {#Form parts}] - (form$ (list#composite parts (list a1 a2))) + _ + (form$ (list op a1 a2))} + op)) + +(def''' .private (function#flipped func) + (All (_ a b c) + (-> (-> a b c) (-> b a c))) + (function' [right left] + (func left right))) + +(def'' .public left + Macro + (macro (_ tokens) + ({{#Item op tokens'} + ({{#Item first nexts} + (meta#in (list (list#mix (function#flipped (right_associativity op)) first nexts))) + _ + (failure "Wrong syntax for left")} + tokens') + _ - (form$ (list op a1 a2))} - op)) - -(def:''' .private (function#flipped func) - (All (_ a b c) - (-> (-> a b c) (-> b a c))) - (function' [right left] - (func left right))) + (failure "Wrong syntax for left")} + tokens))) -(def:'' .public left - Macro - (macro (_ tokens) - ({{#Item op tokens'} - ({{#Item first nexts} - (meta#in (list (list#mix (function#flipped (right_associativity op)) first nexts))) - - _ - (failure "Wrong syntax for left")} - tokens') - - _ - (failure "Wrong syntax for left")} - tokens))) +(def'' .public right + Macro + (macro (_ tokens) + ({{#Item op tokens'} + ({{#Item last prevs} + (meta#in (list (list#mix (right_associativity op) last prevs))) -(def:'' .public right - Macro - (macro (_ tokens) - ({{#Item op tokens'} - ({{#Item last prevs} - (meta#in (list (list#mix (right_associativity op) last prevs))) - - _ - (failure "Wrong syntax for right")} - (list#reversed tokens')) - - _ - (failure "Wrong syntax for right")} - tokens))) + _ + (failure "Wrong syntax for right")} + (list#reversed tokens')) + + _ + (failure "Wrong syntax for right")} + tokens))) -(def:''' .public all Macro ..right) +(def''' .public all Macro ..right) ... (type: (Monad m) ... (Interface @@ -1449,1499 +1449,1499 @@ ["#in" "#then"] #0) -(def:''' .private maybe#monad - ($' Monad Maybe) - [#in - (function' [x] {#Some x}) - - #then - (function' [f ma] - ({{#None} {#None} - {#Some a} (f a)} - ma))]) - -(def:''' .private meta#monad - ($' Monad Meta) - [#in - (function' [x] - (function' [state] - {#Right state x})) - - #then - (function' [f ma] - (function' [state] - ({{#Left msg} - {#Left msg} +(def''' .private maybe#monad + ($' Monad Maybe) + [#in + (function' [x] {#Some x}) + + #then + (function' [f ma] + ({{#None} {#None} + {#Some a} (f a)} + ma))]) + +(def''' .private meta#monad + ($' Monad Meta) + [#in + (function' [x] + (function' [state] + {#Right state x})) + + #then + (function' [f ma] + (function' [state] + ({{#Left msg} + {#Left msg} + + {#Right [state' a]} + (f a state')} + (ma state))))]) + +(def'' .private do + Macro + (macro (_ tokens) + ({{#Item monad {#Item [_ {#Tuple bindings}] {#Item body {#End}}}} + ({{#Some bindings} + (let' [g!in (local$ "in") + g!then (local$ " then ") + body' (list#mix ("lux type check" (-> (Tuple Code Code) Code Code) + (function' [binding body'] + (let' [[var value] binding] + ({[_ {#Symbol [module short]}] + ({"" + (form$ (list g!then + (form$ (list (tuple$ (list (local$ "") var)) body')) + value)) + + _ + (form$ (list var value body'))} + module) + + + _ + (form$ (list g!then + (form$ (list (tuple$ (list (local$ "") var)) body')) + value))} + var)))) + body + (list#reversed bindings))] + (meta#in (list (form$ (list (variant$ (list (tuple$ (list g!in g!then)) + body')) + monad))))) + + {#None} + (failure "Wrong syntax for do")} + (pairs bindings)) - {#Right [state' a]} - (f a state')} - (ma state))))]) + _ + (failure "Wrong syntax for do")} + tokens))) + +(def''' .private (monad#each m f xs) + (All (_ m a b) + (-> ($' Monad m) + (-> a ($' m b)) + ($' List a) + ($' m ($' List b)))) + (let' [[..#in in ..#then _] m] + ({{#End} + (in {#End}) + + {#Item x xs'} + (do m + [y (f x) + ys (monad#each m f xs')] + (in {#Item y ys}))} + xs))) + +(def''' .private (monad#mix m f y xs) + (All (_ m a b) + (-> ($' Monad m) + (-> a b ($' m b)) + b + ($' List a) + ($' m b))) + (let' [[..#in in ..#then _] m] + ({{#End} + (in y) + + {#Item x xs'} + (do m + [y' (f x y)] + (monad#mix m f y' xs'))} + xs))) + +(def'' .public if + Macro + (macro (_ tokens) + ({{#Item test {#Item then {#Item else {#End}}}} + (meta#in (list (form$ (list (variant$ (list (bit$ #1) then + (bit$ #0) else)) + test)))) -(def:'' .private do - Macro - (macro (_ tokens) - ({{#Item monad {#Item [_ {#Tuple bindings}] {#Item body {#End}}}} - ({{#Some bindings} - (let' [g!in (local$ "in") - g!then (local$ " then ") - body' (list#mix ("lux type check" (-> (Tuple Code Code) Code Code) - (function' [binding body'] - (let' [[var value] binding] - ({[_ {#Symbol [module short]}] - ({"" - (form$ (list g!then - (form$ (list (tuple$ (list (local$ "") var)) body')) - value)) - - _ - (form$ (list var value body'))} - module) - + _ + (failure "Wrong syntax for if")} + tokens))) - _ - (form$ (list g!then - (form$ (list (tuple$ (list (local$ "") var)) body')) - value))} - var)))) - body - (list#reversed bindings))] - (meta#in (list (form$ (list (variant$ (list (tuple$ (list g!in g!then)) - body')) - monad))))) - - {#None} - (failure "Wrong syntax for do")} - (pairs bindings)) +(def''' .private PList + Type + (All (_ a) ($' List (Tuple Text a)))) + +(def''' .private (plist#value k plist) + (All (_ a) + (-> Text ($' PList a) ($' Maybe a))) + ({{#Item [[k' v] plist']} + (if (text#= k k') + {#Some v} + (plist#value k plist')) + + {#End} + {#None}} + plist)) + +(def''' .private (plist#with k v plist) + (All (_ a) + (-> Text a ($' PList a) ($' PList a))) + ({{#Item [k' v'] plist'} + (if (text#= k k') + (partial_list [k v] plist') + (partial_list [k' v'] (plist#with k v plist'))) + + {#End} + (list [k v])} + plist)) + +(def''' .private (global_symbol full_name state) + (-> Symbol ($' Meta Symbol)) + (let' [[module name] full_name + [..#info info ..#source source ..#current_module _ ..#modules modules + ..#scopes scopes ..#type_context types ..#host host + ..#seed seed ..#expected expected ..#location location ..#extensions extensions + ..#scope_type_vars scope_type_vars ..#eval _eval] state] + ({{#Some [..#module_hash _ ..#module_aliases _ ..#definitions definitions ..#imports _ ..#module_state _]} + ({{#Some constant} + ({{#Definition _} {#Right [state full_name]} + {#Tag _} {#Right [state full_name]} + {#Slot _} {#Right [state full_name]} + {#Type _} {#Right [state full_name]} + + {#Alias real_name} + {#Right [state real_name]}} + constant) - _ - (failure "Wrong syntax for do")} - tokens))) - -(def:''' .private (monad#each m f xs) - (All (_ m a b) - (-> ($' Monad m) - (-> a ($' m b)) - ($' List a) - ($' m ($' List b)))) - (let' [[..#in in ..#then _] m] - ({{#End} - (in {#End}) - - {#Item x xs'} - (do m - [y (f x) - ys (monad#each m f xs')] - (in {#Item y ys}))} - xs))) - -(def:''' .private (monad#mix m f y xs) - (All (_ m a b) - (-> ($' Monad m) - (-> a b ($' m b)) - b - ($' List a) - ($' m b))) - (let' [[..#in in ..#then _] m] - ({{#End} - (in y) + {#None} + {#Left (all text#composite "Unknown definition: " (symbol#encoded full_name))}} + (plist#value name definitions)) + + {#None} + {#Left (all text#composite "Unknown module: " module " @ " (symbol#encoded full_name))}} + (plist#value module modules)))) + +(def''' .private (:List<Code> expression) + (-> Code Code) + (let' [type (variant$ (list (symbol$ [..prelude "#Apply"]) + (symbol$ [..prelude "Code"]) + (symbol$ [..prelude "List"])))] + (form$ (list (text$ "lux type check") type expression)))) + +(def''' .private (spliced replace? untemplated elems) + (-> Bit (-> Code ($' Meta Code)) ($' List Code) ($' Meta Code)) + ({[#1] ({{#End} + (meta#in |#End|) - {#Item x xs'} - (do m - [y' (f x y)] - (monad#mix m f y' xs'))} - xs))) + {#Item lastI inits} + (do meta#monad + [lastO ({[_ {#Form {#Item [[_ {#Symbol ["" "~+"]}] {#Item [spliced {#End}]}]}}] + (in (:List<Code> spliced)) -(def:'' .public if - Macro - (macro (_ tokens) - ({{#Item test {#Item then {#Item else {#End}}}} - (meta#in (list (form$ (list (variant$ (list (bit$ #1) then - (bit$ #0) else)) - test)))) + _ + (do meta#monad + [lastO (untemplated lastI)] + (in (:List<Code> (|#Item| lastO |#End|))))} + lastI)] + (monad#mix meta#monad + (function' [leftI rightO] + ({[_ {#Form {#Item [[_ {#Symbol ["" "~+"]}] {#Item [spliced {#End}]}]}}] + (let' [g!in-module (form$ (list (text$ "lux in-module") + (text$ ..prelude) + (symbol$ [..prelude "list#composite"])))] + (in (form$ (list g!in-module (:List<Code> spliced) rightO)))) + + _ + (do meta#monad + [leftO (untemplated leftI)] + (in (|#Item| leftO rightO)))} + leftI)) + lastO + inits))} + (list#reversed elems)) + [#0] (do meta#monad + [=elems (monad#each meta#monad untemplated elems)] + (in (untemplated_list =elems)))} + replace?)) + +(def''' .private (untemplated_text value) + (-> Text Code) + (with_location (variant$ (list (symbol$ [..prelude "#Text"]) (text$ value))))) + +(def''' .private (untemplated replace? subst token) + (-> Bit Text Code ($' Meta Code)) + ({[_ [_ {#Bit value}]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Bit"]) (bit$ value))))) + + [_ [_ {#Nat value}]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Nat"]) (nat$ value))))) + + [_ [_ {#Int value}]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Int"]) (int$ value))))) + + [_ [_ {#Rev value}]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Rev"]) (rev$ value))))) + + [_ [_ {#Frac value}]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Frac"]) (frac$ value))))) - _ - (failure "Wrong syntax for if")} - tokens))) + [_ [_ {#Text value}]] + (meta#in (untemplated_text value)) -(def:''' .private PList - Type - (All (_ a) ($' List (Tuple Text a)))) + [#1 [_ {#Symbol [module name]}]] + (do meta#monad + [real_name ({"" + (if (text#= "" subst) + (in [module name]) + (global_symbol [subst name])) -(def:''' .private (plist#value k plist) - (All (_ a) - (-> Text ($' PList a) ($' Maybe a))) - ({{#Item [[k' v] plist']} - (if (text#= k k') - {#Some v} - (plist#value k plist')) + _ + (in [module name])} + module) + .let' [[module name] real_name]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Symbol"]) (tuple$ (list (text$ module) (text$ name)))))))) - {#End} - {#None}} - plist)) + [#0 [_ {#Symbol [module name]}]] + (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Symbol"]) (tuple$ (list (text$ module) (text$ name))))))) -(def:''' .private (plist#with k v plist) - (All (_ a) - (-> Text a ($' PList a) ($' PList a))) - ({{#Item [k' v'] plist'} - (if (text#= k k') - (partial_list [k v] plist') - (partial_list [k' v'] (plist#with k v plist'))) + [#1 [_ {#Form {#Item [[_ {#Symbol ["" "~"]}] {#Item [unquoted {#End}]}]}}]] + (meta#in (form$ (list (text$ "lux type check") + (symbol$ [..prelude "Code"]) + unquoted))) - {#End} - (list [k v])} - plist)) - -(def:''' .private (global_symbol full_name state) - (-> Symbol ($' Meta Symbol)) - (let' [[module name] full_name - [..#info info ..#source source ..#current_module _ ..#modules modules - ..#scopes scopes ..#type_context types ..#host host - ..#seed seed ..#expected expected ..#location location ..#extensions extensions - ..#scope_type_vars scope_type_vars ..#eval _eval] state] - ({{#Some [..#module_hash _ ..#module_aliases _ ..#definitions definitions ..#imports _ ..#module_state _]} - ({{#Some constant} - ({{#Definition _} {#Right [state full_name]} - {#Tag _} {#Right [state full_name]} - {#Slot _} {#Right [state full_name]} - {#Type _} {#Right [state full_name]} - - {#Alias real_name} - {#Right [state real_name]}} - constant) - - {#None} - {#Left (all text#composite "Unknown definition: " (symbol#encoded full_name))}} - (plist#value name definitions)) - - {#None} - {#Left (all text#composite "Unknown module: " module " @ " (symbol#encoded full_name))}} - (plist#value module modules)))) - -(def:''' .private (:List<Code> expression) - (-> Code Code) - (let' [type (variant$ (list (symbol$ [..prelude "#Apply"]) - (symbol$ [..prelude "Code"]) - (symbol$ [..prelude "List"])))] - (form$ (list (text$ "lux type check") type expression)))) - -(def:''' .private (spliced replace? untemplated elems) - (-> Bit (-> Code ($' Meta Code)) ($' List Code) ($' Meta Code)) - ({[#1] ({{#End} - (meta#in |#End|) - - {#Item lastI inits} - (do meta#monad - [lastO ({[_ {#Form {#Item [[_ {#Symbol ["" "~+"]}] {#Item [spliced {#End}]}]}}] - (in (:List<Code> spliced)) + [#1 [_ {#Form {#Item [[_ {#Symbol ["" "~!"]}] {#Item [dependent {#End}]}]}}]] + (do meta#monad + [independent (untemplated replace? subst dependent)] + (in (with_location (variant$ (list (symbol$ [..prelude "#Form"]) + (untemplated_list (list (untemplated_text "lux in-module") + (untemplated_text subst) + independent))))))) - _ - (do meta#monad - [lastO (untemplated lastI)] - (in (:List<Code> (|#Item| lastO |#End|))))} - lastI)] - (monad#mix meta#monad - (function' [leftI rightO] - ({[_ {#Form {#Item [[_ {#Symbol ["" "~+"]}] {#Item [spliced {#End}]}]}}] - (let' [g!in-module (form$ (list (text$ "lux in-module") - (text$ ..prelude) - (symbol$ [..prelude "list#composite"])))] - (in (form$ (list g!in-module (:List<Code> spliced) rightO)))) - - _ - (do meta#monad - [leftO (untemplated leftI)] - (in (|#Item| leftO rightO)))} - leftI)) - lastO - inits))} - (list#reversed elems)) - [#0] (do meta#monad - [=elems (monad#each meta#monad untemplated elems)] - (in (untemplated_list =elems)))} - replace?)) - -(def:''' .private (untemplated_text value) - (-> Text Code) - (with_location (variant$ (list (symbol$ [..prelude "#Text"]) (text$ value))))) - -(def:''' .private (untemplated replace? subst token) - (-> Bit Text Code ($' Meta Code)) - ({[_ [_ {#Bit value}]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Bit"]) (bit$ value))))) - - [_ [_ {#Nat value}]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Nat"]) (nat$ value))))) - - [_ [_ {#Int value}]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Int"]) (int$ value))))) - - [_ [_ {#Rev value}]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Rev"]) (rev$ value))))) - - [_ [_ {#Frac value}]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Frac"]) (frac$ value))))) + [#1 [_ {#Form {#Item [[_ {#Symbol ["" "~'"]}] {#Item [keep_quoted {#End}]}]}}]] + (untemplated #0 subst keep_quoted) - [_ [_ {#Text value}]] - (meta#in (untemplated_text value)) + [_ [meta {#Form elems}]] + (do meta#monad + [output (spliced replace? (untemplated replace? subst) elems) + .let' [[_ output'] (with_location (variant$ (list (symbol$ [..prelude "#Form"]) output)))]] + (in [meta output'])) - [#1 [_ {#Symbol [module name]}]] - (do meta#monad - [real_name ({"" - (if (text#= "" subst) - (in [module name]) - (global_symbol [subst name])) + [_ [meta {#Variant elems}]] + (do meta#monad + [output (spliced replace? (untemplated replace? subst) elems) + .let' [[_ output'] (with_location (variant$ (list (symbol$ [..prelude "#Variant"]) output)))]] + (in [meta output'])) - _ - (in [module name])} - module) - .let' [[module name] real_name]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Symbol"]) (tuple$ (list (text$ module) (text$ name)))))))) + [_ [meta {#Tuple elems}]] + (do meta#monad + [output (spliced replace? (untemplated replace? subst) elems) + .let' [[_ output'] (with_location (variant$ (list (symbol$ [..prelude "#Tuple"]) output)))]] + (in [meta output']))} + [replace? token])) - [#0 [_ {#Symbol [module name]}]] - (meta#in (with_location (variant$ (list (symbol$ [..prelude "#Symbol"]) (tuple$ (list (text$ module) (text$ name))))))) +(def'' .public Primitive + Macro + (macro (_ tokens) + ({{#Item [_ {#Text class_name}] {#End}} + (meta#in (list (variant$ (list (symbol$ [..prelude "#Primitive"]) (text$ class_name) |#End|)))) - [#1 [_ {#Form {#Item [[_ {#Symbol ["" "~"]}] {#Item [unquoted {#End}]}]}}]] - (meta#in (form$ (list (text$ "lux type check") - (symbol$ [..prelude "Code"]) - unquoted))) + {#Item [_ {#Text class_name}] {#Item [_ {#Tuple params}] {#End}}} + (meta#in (list (variant$ (list (symbol$ [..prelude "#Primitive"]) (text$ class_name) (untemplated_list params))))) - [#1 [_ {#Form {#Item [[_ {#Symbol ["" "~!"]}] {#Item [dependent {#End}]}]}}]] + _ + (failure "Wrong syntax for Primitive")} + tokens))) + +(def'' .private (current_module_name state) + ($' Meta Text) + ({[..#info info ..#source source ..#current_module current_module ..#modules modules + ..#scopes scopes ..#type_context types ..#host host + ..#seed seed ..#expected expected ..#location location ..#extensions extensions + ..#scope_type_vars scope_type_vars ..#eval _eval] + ({{#Some module_name} + {#Right [state module_name]} + + _ + {#Left "Cannot get the module name without a module!"}} + current_module)} + state)) + +(def'' .public ` + Macro + (macro (_ tokens) + ({{#Item template {#End}} (do meta#monad - [independent (untemplated replace? subst dependent)] - (in (with_location (variant$ (list (symbol$ [..prelude "#Form"]) - (untemplated_list (list (untemplated_text "lux in-module") - (untemplated_text subst) - independent))))))) + [current_module current_module_name + =template (untemplated #1 current_module template)] + (in (list (form$ (list (text$ "lux type check") + (symbol$ [..prelude "Code"]) + =template))))) - [#1 [_ {#Form {#Item [[_ {#Symbol ["" "~'"]}] {#Item [keep_quoted {#End}]}]}}]] - (untemplated #0 subst keep_quoted) + _ + (failure "Wrong syntax for `")} + tokens))) - [_ [meta {#Form elems}]] +(def'' .public `' + Macro + (macro (_ tokens) + ({{#Item template {#End}} (do meta#monad - [output (spliced replace? (untemplated replace? subst) elems) - .let' [[_ output'] (with_location (variant$ (list (symbol$ [..prelude "#Form"]) output)))]] - (in [meta output'])) + [=template (untemplated #1 "" template)] + (in (list (form$ (list (text$ "lux type check") (symbol$ [..prelude "Code"]) =template))))) - [_ [meta {#Variant elems}]] - (do meta#monad - [output (spliced replace? (untemplated replace? subst) elems) - .let' [[_ output'] (with_location (variant$ (list (symbol$ [..prelude "#Variant"]) output)))]] - (in [meta output'])) + _ + (failure "Wrong syntax for `")} + tokens))) - [_ [meta {#Tuple elems}]] +(def'' .public ' + Macro + (macro (_ tokens) + ({{#Item template {#End}} (do meta#monad - [output (spliced replace? (untemplated replace? subst) elems) - .let' [[_ output'] (with_location (variant$ (list (symbol$ [..prelude "#Tuple"]) output)))]] - (in [meta output']))} - [replace? token])) + [=template (untemplated #0 "" template)] + (in (list (form$ (list (text$ "lux type check") (symbol$ [..prelude "Code"]) =template))))) -(def:'' .public Primitive - Macro - (macro (_ tokens) - ({{#Item [_ {#Text class_name}] {#End}} - (meta#in (list (variant$ (list (symbol$ [..prelude "#Primitive"]) (text$ class_name) |#End|)))) - - {#Item [_ {#Text class_name}] {#Item [_ {#Tuple params}] {#End}}} - (meta#in (list (variant$ (list (symbol$ [..prelude "#Primitive"]) (text$ class_name) (untemplated_list params))))) + _ + (failure "Wrong syntax for '")} + tokens))) - _ - (failure "Wrong syntax for Primitive")} - tokens))) +(def'' .public |> + Macro + (macro (_ tokens) + ({{#Item [init apps]} + (meta#in (list (list#mix ("lux type check" (-> Code Code Code) + (function' [app acc] + ({[_ {#Variant parts}] + (variant$ (list#composite parts (list acc))) -(def:'' .private (current_module_name state) - ($' Meta Text) - ({[..#info info ..#source source ..#current_module current_module ..#modules modules - ..#scopes scopes ..#type_context types ..#host host - ..#seed seed ..#expected expected ..#location location ..#extensions extensions - ..#scope_type_vars scope_type_vars ..#eval _eval] - ({{#Some module_name} - {#Right [state module_name]} + [_ {#Tuple parts}] + (tuple$ (list#composite parts (list acc))) - _ - {#Left "Cannot get the module name without a module!"}} - current_module)} - state)) + [_ {#Form parts}] + (form$ (list#composite parts (list acc))) -(def:'' .public ` - Macro - (macro (_ tokens) - ({{#Item template {#End}} - (do meta#monad - [current_module current_module_name - =template (untemplated #1 current_module template)] - (in (list (form$ (list (text$ "lux type check") - (symbol$ [..prelude "Code"]) - =template))))) + _ + (` ((~ app) (~ acc)))} + app))) + init + apps))) - _ - (failure "Wrong syntax for `")} - tokens))) + _ + (failure "Wrong syntax for |>")} + tokens))) -(def:'' .public `' - Macro - (macro (_ tokens) - ({{#Item template {#End}} - (do meta#monad - [=template (untemplated #1 "" template)] - (in (list (form$ (list (text$ "lux type check") (symbol$ [..prelude "Code"]) =template))))) +(def'' .public <| + Macro + (macro (_ tokens) + ({{#Item [init apps]} + (meta#in (list (list#mix ("lux type check" (-> Code Code Code) + (function' [app acc] + ({[_ {#Variant parts}] + (variant$ (list#composite parts (list acc))) - _ - (failure "Wrong syntax for `")} - tokens))) + [_ {#Tuple parts}] + (tuple$ (list#composite parts (list acc))) -(def:'' .public ' - Macro - (macro (_ tokens) - ({{#Item template {#End}} - (do meta#monad - [=template (untemplated #0 "" template)] - (in (list (form$ (list (text$ "lux type check") (symbol$ [..prelude "Code"]) =template))))) + [_ {#Form parts}] + (form$ (list#composite parts (list acc))) - _ - (failure "Wrong syntax for '")} - tokens))) + _ + (` ((~ app) (~ acc)))} + app))) + init + apps))) -(def:'' .public |> - Macro - (macro (_ tokens) - ({{#Item [init apps]} - (meta#in (list (list#mix ("lux type check" (-> Code Code Code) - (function' [app acc] - ({[_ {#Variant parts}] - (variant$ (list#composite parts (list acc))) + _ + (failure "Wrong syntax for <|")} + (list#reversed tokens)))) - [_ {#Tuple parts}] - (tuple$ (list#composite parts (list acc))) +(def''' .private (function#composite f g) + (All (_ a b c) + (-> (-> b c) (-> a b) (-> a c))) + (function' [x] (f (g x)))) - [_ {#Form parts}] - (form$ (list#composite parts (list acc))) +(def''' .private (symbol_name x) + (-> Code ($' Maybe Symbol)) + ({[_ {#Symbol sname}] + {#Some sname} - _ - (` ((~ app) (~ acc)))} - app))) - init - apps))) + _ + {#None}} + x)) - _ - (failure "Wrong syntax for |>")} - tokens))) +(def''' .private (symbol_short x) + (-> Code ($' Maybe Text)) + ({[_ {#Symbol "" sname}] + {#Some sname} -(def:'' .public <| - Macro - (macro (_ tokens) - ({{#Item [init apps]} - (meta#in (list (list#mix ("lux type check" (-> Code Code Code) - (function' [app acc] - ({[_ {#Variant parts}] - (variant$ (list#composite parts (list acc))) + _ + {#None}} + x)) - [_ {#Tuple parts}] - (tuple$ (list#composite parts (list acc))) +(def''' .private (tuple_list tuple) + (-> Code ($' Maybe ($' List Code))) + ({[_ {#Tuple members}] + {#Some members} - [_ {#Form parts}] - (form$ (list#composite parts (list acc))) + _ + {#None}} + tuple)) - _ - (` ((~ app) (~ acc)))} - app))) - init - apps))) +(def''' .private (realized_template env template) + (-> Replacement_Environment Code Code) + ({[_ {#Symbol "" sname}] + ({{#Some subst} + subst _ - (failure "Wrong syntax for <|")} - (list#reversed tokens)))) - -(def:''' .private (function#composite f g) - (All (_ a b c) - (-> (-> b c) (-> a b) (-> a c))) - (function' [x] (f (g x)))) + template} + (..replacement sname env)) -(def:''' .private (symbol_name x) - (-> Code ($' Maybe Symbol)) - ({[_ {#Symbol sname}] - {#Some sname} + [meta {#Form elems}] + [meta {#Form (list#each (realized_template env) elems)}] - _ - {#None}} - x)) - -(def:''' .private (symbol_short x) - (-> Code ($' Maybe Text)) - ({[_ {#Symbol "" sname}] - {#Some sname} + [meta {#Tuple elems}] + [meta {#Tuple (list#each (realized_template env) elems)}] - _ - {#None}} - x)) + [meta {#Variant elems}] + [meta {#Variant (list#each (realized_template env) elems)}] -(def:''' .private (tuple_list tuple) - (-> Code ($' Maybe ($' List Code))) - ({[_ {#Tuple members}] - {#Some members} - - _ - {#None}} - tuple)) - -(def:''' .private (realized_template env template) - (-> Replacement_Environment Code Code) - ({[_ {#Symbol "" sname}] - ({{#Some subst} - subst + _ + template} + template)) + +(def''' .private (every? p xs) + (All (_ a) + (-> (-> a Bit) ($' List a) Bit)) + (list#mix (function' [_2 _1] (if _1 (p _2) #0)) #1 xs)) + +(def''' .private (high_bits value) + (-> ($' I64 Any) I64) + ("lux i64 right-shift" 32 value)) + +(def''' .private low_mask + I64 + (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))) + +(def''' .private (low_bits value) + (-> ($' I64 Any) I64) + ("lux i64 and" low_mask value)) + +(def''' .private (n/< reference sample) + (-> Nat Nat Bit) + (let' [referenceH (high_bits reference) + sampleH (high_bits sample)] + (if ("lux i64 <" referenceH sampleH) + #1 + (if ("lux i64 =" referenceH sampleH) + ("lux i64 <" + (low_bits reference) + (low_bits sample)) + #0)))) + +(def''' .private (list#conjoint xs) + (All (_ a) + (-> ($' List ($' List a)) ($' List a))) + (list#mix list#composite {#End} (list#reversed xs))) + +(def'' .public with_template + Macro + (macro (_ tokens) + ({{#Item [[_ {#Tuple bindings}] {#Item [[_ {#Tuple templates}] data]}]} + ({[{#Some bindings'} {#Some data'}] + (let' [apply ("lux type check" (-> Replacement_Environment ($' List Code)) + (function' [env] (list#each (realized_template env) templates))) + num_bindings (list#size bindings')] + (if (every? (function' [size] ("lux i64 =" num_bindings size)) + (list#each list#size data')) + (|> data' + (list#each (function#composite apply (replacement_environment bindings'))) + list#conjoint + meta#in) + (failure (..wrong_syntax_error [..prelude "with_template"])))) _ - template} - (..replacement sname env)) + (failure (..wrong_syntax_error [..prelude "with_template"]))} + [(monad#each maybe#monad symbol_short bindings) + (monad#each maybe#monad tuple_list data)]) - [meta {#Form elems}] - [meta {#Form (list#each (realized_template env) elems)}] + _ + (failure (..wrong_syntax_error [..prelude "with_template"]))} + tokens))) + +(def''' .private (n// param subject) + (-> Nat Nat Nat) + (if ("lux i64 <" +0 ("lux type as" Int param)) + (if (n/< param subject) + 0 + 1) + (let' [quotient (|> subject + ("lux i64 right-shift" 1) + ("lux i64 /" ("lux type as" Int param)) + ("lux i64 left-shift" 1)) + flat ("lux i64 *" + ("lux type as" Int param) + ("lux type as" Int quotient)) + remainder ("lux i64 -" flat subject)] + (if (n/< param remainder) + quotient + ("lux i64 +" 1 quotient))))) + +(def''' .private (n/% param subject) + (-> Nat Nat Nat) + (let' [flat ("lux i64 *" + ("lux type as" Int param) + ("lux type as" Int (n// param subject)))] + ("lux i64 -" flat subject))) + +(def''' .private (n/min left right) + (-> Nat Nat Nat) + (if (n/< right left) + left + right)) + +(def''' .private (bit#encoded x) + (-> Bit Text) + (if x "#1" "#0")) + +(def''' .private (digit::format digit) + (-> Nat Text) + ({[0] "0" + [1] "1" [2] "2" [3] "3" + [4] "4" [5] "5" [6] "6" + [7] "7" [8] "8" [9] "9" + _ ("lux io error" "@digit::format Undefined behavior.")} + digit)) + +(def''' .private (nat#encoded value) + (-> Nat Text) + ({[0] "0" + _ (let' [loop ("lux type check" (-> Nat Text Text) + (function' again [input output] + (if ("lux i64 =" 0 input) + output + (again (n// 10 input) + (text#composite (|> input (n/% 10) digit::format) + output)))))] + (loop value ""))} + value)) + +(def''' .private (int#abs value) + (-> Int Int) + (if ("lux i64 <" +0 value) + ("lux i64 *" -1 value) + value)) - [meta {#Tuple elems}] - [meta {#Tuple (list#each (realized_template env) elems)}] +(def''' .private (int#encoded value) + (-> Int Text) + (if ("lux i64 =" +0 value) + "+0" + (let' [sign (if ("lux i64 <" value +0) + "+" + "-")] + (("lux type check" (-> Int Text Text) + (function' again [input output] + (if ("lux i64 =" +0 input) + (text#composite sign output) + (again ("lux i64 /" +10 input) + (text#composite (|> input ("lux i64 %" +10) ("lux type as" Nat) digit::format) + output))))) + (|> value ("lux i64 /" +10) int#abs) + (|> value ("lux i64 %" +10) int#abs ("lux type as" Nat) digit::format))))) + +(def''' .private (frac#encoded x) + (-> Frac Text) + ("lux f64 encode" x)) + +(def''' .public (not x) + (-> Bit Bit) + (if x #0 #1)) + +(def''' .private (macro_type? type) + (-> Type Bit) + ({{#Named ["library/lux" "Macro"] {#Primitive "#Macro" {#End}}} + #1 - [meta {#Variant elems}] - [meta {#Variant (list#each (realized_template env) elems)}] + _ + #0} + type)) + +(def''' .private (named_macro' modules current_module module name) + (-> ($' List (Tuple Text Module)) + Text Text Text + ($' Maybe Macro)) + (do maybe#monad + [$module (plist#value module modules) + gdef (let' [[..#module_hash _ ..#module_aliases _ ..#definitions bindings ..#imports _ ..#module_state _] ("lux type check" Module $module)] + (plist#value name bindings))] + ({{#Alias [r_module r_name]} + (named_macro' modules current_module r_module r_name) + + {#Definition [exported? def_type def_value]} + (if (macro_type? def_type) + (if exported? + {#Some ("lux type as" Macro def_value)} + (if (text#= module current_module) + {#Some ("lux type as" Macro def_value)} + {#None})) + {#None}) + + {#Type [exported? type labels]} + {#None} - _ - template} - template)) - -(def:''' .private (every? p xs) - (All (_ a) - (-> (-> a Bit) ($' List a) Bit)) - (list#mix (function' [_2 _1] (if _1 (p _2) #0)) #1 xs)) - -(def:''' .private (high_bits value) - (-> ($' I64 Any) I64) - ("lux i64 right-shift" 32 value)) - -(def:''' .private low_mask - I64 - (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))) - -(def:''' .private (low_bits value) - (-> ($' I64 Any) I64) - ("lux i64 and" low_mask value)) - -(def:''' .private (n/< reference sample) - (-> Nat Nat Bit) - (let' [referenceH (high_bits reference) - sampleH (high_bits sample)] - (if ("lux i64 <" referenceH sampleH) - #1 - (if ("lux i64 =" referenceH sampleH) - ("lux i64 <" - (low_bits reference) - (low_bits sample)) - #0)))) - -(def:''' .private (list#conjoint xs) - (All (_ a) - (-> ($' List ($' List a)) ($' List a))) - (list#mix list#composite {#End} (list#reversed xs))) - -(def:'' .public with_template - Macro - (macro (_ tokens) - ({{#Item [[_ {#Tuple bindings}] {#Item [[_ {#Tuple templates}] data]}]} - ({[{#Some bindings'} {#Some data'}] - (let' [apply ("lux type check" (-> Replacement_Environment ($' List Code)) - (function' [env] (list#each (realized_template env) templates))) - num_bindings (list#size bindings')] - (if (every? (function' [size] ("lux i64 =" num_bindings size)) - (list#each list#size data')) - (|> data' - (list#each (function#composite apply (replacement_environment bindings'))) - list#conjoint - meta#in) - (failure (..wrong_syntax_error [..prelude "with_template"])))) + {#Tag _} + {#None} - _ - (failure (..wrong_syntax_error [..prelude "with_template"]))} - [(monad#each maybe#monad symbol_short bindings) - (monad#each maybe#monad tuple_list data)]) + {#Slot _} + {#None}} + ("lux type check" Global gdef)))) - _ - (failure (..wrong_syntax_error [..prelude "with_template"]))} - tokens))) - -(def:''' .private (n// param subject) - (-> Nat Nat Nat) - (if ("lux i64 <" +0 ("lux type as" Int param)) - (if (n/< param subject) - 0 - 1) - (let' [quotient (|> subject - ("lux i64 right-shift" 1) - ("lux i64 /" ("lux type as" Int param)) - ("lux i64 left-shift" 1)) - flat ("lux i64 *" - ("lux type as" Int param) - ("lux type as" Int quotient)) - remainder ("lux i64 -" flat subject)] - (if (n/< param remainder) - quotient - ("lux i64 +" 1 quotient))))) - -(def:''' .private (n/% param subject) - (-> Nat Nat Nat) - (let' [flat ("lux i64 *" - ("lux type as" Int param) - ("lux type as" Int (n// param subject)))] - ("lux i64 -" flat subject))) - -(def:''' .private (n/min left right) - (-> Nat Nat Nat) - (if (n/< right left) - left - right)) - -(def:''' .private (bit#encoded x) - (-> Bit Text) - (if x "#1" "#0")) - -(def:''' .private (digit::format digit) - (-> Nat Text) - ({[0] "0" - [1] "1" [2] "2" [3] "3" - [4] "4" [5] "5" [6] "6" - [7] "7" [8] "8" [9] "9" - _ ("lux io error" "@digit::format Undefined behavior.")} - digit)) - -(def:''' .private (nat#encoded value) - (-> Nat Text) - ({[0] "0" - _ (let' [loop ("lux type check" (-> Nat Text Text) - (function' again [input output] - (if ("lux i64 =" 0 input) - output - (again (n// 10 input) - (text#composite (|> input (n/% 10) digit::format) - output)))))] - (loop value ""))} - value)) +(def''' .private (normal name) + (-> Symbol ($' Meta Symbol)) + ({["" name] + (do meta#monad + [module_name ..current_module_name] + (in [module_name name])) -(def:''' .private (int#abs value) - (-> Int Int) - (if ("lux i64 <" +0 value) - ("lux i64 *" -1 value) - value)) - -(def:''' .private (int#encoded value) - (-> Int Text) - (if ("lux i64 =" +0 value) - "+0" - (let' [sign (if ("lux i64 <" value +0) - "+" - "-")] - (("lux type check" (-> Int Text Text) - (function' again [input output] - (if ("lux i64 =" +0 input) - (text#composite sign output) - (again ("lux i64 /" +10 input) - (text#composite (|> input ("lux i64 %" +10) ("lux type as" Nat) digit::format) - output))))) - (|> value ("lux i64 /" +10) int#abs) - (|> value ("lux i64 %" +10) int#abs ("lux type as" Nat) digit::format))))) - -(def:''' .private (frac#encoded x) - (-> Frac Text) - ("lux f64 encode" x)) - -(def:''' .public (not x) - (-> Bit Bit) - (if x #0 #1)) - -(def:''' .private (macro_type? type) - (-> Type Bit) - ({{#Named ["library/lux" "Macro"] {#Primitive "#Macro" {#End}}} - #1 + _ + (meta#in name)} + name)) - _ - #0} - type)) +(def''' .private (named_macro full_name) + (-> Symbol ($' Meta ($' Maybe Macro))) + (do meta#monad + [current_module current_module_name] + (let' [[module name] full_name] + (function' [state] + ({[..#info info ..#source source ..#current_module _ ..#modules modules + ..#scopes scopes ..#type_context types ..#host host + ..#seed seed ..#expected expected + ..#location location ..#extensions extensions + ..#scope_type_vars scope_type_vars ..#eval _eval] + {#Right state (named_macro' modules current_module module name)}} + state))))) + +(def''' .private (macro? name) + (-> Symbol ($' Meta Bit)) + (do meta#monad + [name (normal name) + output (named_macro name)] + (in ({{#Some _} #1 + {#None} #0} + output)))) + +(def''' .private (list#interposed sep xs) + (All (_ a) + (-> a ($' List a) ($' List a))) + ({{#End} + xs -(def:''' .private (named_macro' modules current_module module name) - (-> ($' List (Tuple Text Module)) - Text Text Text - ($' Maybe Macro)) - (do maybe#monad - [$module (plist#value module modules) - gdef (let' [[..#module_hash _ ..#module_aliases _ ..#definitions bindings ..#imports _ ..#module_state _] ("lux type check" Module $module)] - (plist#value name bindings))] - ({{#Alias [r_module r_name]} - (named_macro' modules current_module r_module r_name) - - {#Definition [exported? def_type def_value]} - (if (macro_type? def_type) - (if exported? - {#Some ("lux type as" Macro def_value)} - (if (text#= module current_module) - {#Some ("lux type as" Macro def_value)} - {#None})) - {#None}) - - {#Type [exported? type labels]} - {#None} + {#Item [x {#End}]} + xs - {#Tag _} - {#None} + {#Item [x xs']} + (partial_list x sep (list#interposed sep xs'))} + xs)) - {#Slot _} - {#None}} - ("lux type check" Global gdef)))) +(def''' .private (single_expansion token) + (-> Code ($' Meta ($' List Code))) + ({[_ {#Form {#Item [_ {#Symbol name}] args}}] + (do meta#monad + [name' (normal name) + ?macro (named_macro name')] + ({{#Some macro} + (("lux type as" Macro' macro) args) + + {#None} + (in (list token))} + ?macro)) -(def:''' .private (normal name) - (-> Symbol ($' Meta Symbol)) - ({["" name] - (do meta#monad - [module_name ..current_module_name] - (in [module_name name])) + _ + (meta#in (list token))} + token)) - _ - (meta#in name)} - name)) - -(def:''' .private (named_macro full_name) - (-> Symbol ($' Meta ($' Maybe Macro))) - (do meta#monad - [current_module current_module_name] - (let' [[module name] full_name] - (function' [state] - ({[..#info info ..#source source ..#current_module _ ..#modules modules - ..#scopes scopes ..#type_context types ..#host host - ..#seed seed ..#expected expected - ..#location location ..#extensions extensions - ..#scope_type_vars scope_type_vars ..#eval _eval] - {#Right state (named_macro' modules current_module module name)}} - state))))) - -(def:''' .private (macro? name) - (-> Symbol ($' Meta Bit)) - (do meta#monad - [name (normal name) - output (named_macro name)] - (in ({{#Some _} #1 - {#None} #0} - output)))) - -(def:''' .private (list#interposed sep xs) - (All (_ a) - (-> a ($' List a) ($' List a))) - ({{#End} - xs +(def''' .private (expansion token) + (-> Code ($' Meta ($' List Code))) + ({[_ {#Form {#Item [_ {#Symbol name}] args}}] + (do meta#monad + [name' (normal name) + ?macro (named_macro name')] + ({{#Some macro} + (do meta#monad + [top_level_expansion (("lux type as" Macro' macro) args) + recursive_expansion (monad#each meta#monad expansion top_level_expansion)] + (in (list#conjoint recursive_expansion))) + + {#None} + (in (list token))} + ?macro)) - {#Item [x {#End}]} - xs + _ + (meta#in (list token))} + token)) - {#Item [x xs']} - (partial_list x sep (list#interposed sep xs'))} - xs)) +(def''' .private (full_expansion' full_expansion name args) + (-> (-> Code ($' Meta ($' List Code))) Symbol ($' List Code) ($' Meta ($' List Code))) + (do meta#monad + [name' (normal name) + ?macro (named_macro name')] + ({{#Some macro} + (do meta#monad + [expansion (("lux type as" Macro' macro) args) + expansion' (monad#each meta#monad full_expansion expansion)] + (in (list#conjoint expansion'))) + + {#None} + (do meta#monad + [args' (monad#each meta#monad full_expansion args)] + (in (list (form$ {#Item (symbol$ name) (list#conjoint args')}))))} + ?macro))) + +(def''' .private (in_module module meta) + (All (_ a) + (-> Text ($' Meta a) ($' Meta a))) + (function' [lux] + ({[..#info info ..#source source + ..#current_module current_module ..#modules modules + ..#scopes scopes ..#type_context type_context + ..#host host ..#seed seed + ..#expected expected ..#location location + ..#extensions extensions ..#scope_type_vars scope_type_vars + ..#eval eval] + ({{#Left error} + {#Left error} + + {#Right [[..#info info' ..#source source' + ..#current_module _ ..#modules modules' + ..#scopes scopes' ..#type_context type_context' + ..#host host' ..#seed seed' + ..#expected expected' ..#location location' + ..#extensions extensions' ..#scope_type_vars scope_type_vars' + ..#eval eval'] + output]} + {#Right [[..#info info' ..#source source' + ..#current_module current_module ..#modules modules' + ..#scopes scopes' ..#type_context type_context' + ..#host host' ..#seed seed' + ..#expected expected' ..#location location' + ..#extensions extensions' ..#scope_type_vars scope_type_vars' + ..#eval eval'] + output]}} + (meta [..#info info ..#source source + ..#current_module {.#Some module} ..#modules modules + ..#scopes scopes ..#type_context type_context + ..#host host ..#seed seed + ..#expected expected ..#location location + ..#extensions extensions ..#scope_type_vars scope_type_vars + ..#eval eval]))} + lux))) + +(def''' .private (full_expansion expand_in_module?) + (-> Bit Code ($' Meta ($' List Code))) + (function' again [syntax] + ({[_ {#Form {#Item head tail}}] + ({[_ {#Form {#Item [_ {#Text "lux in-module"}] + {#Item [_ {#Text module}] + {#Item [_ {#Symbol name}] + {#End}}}}}] + (if expand_in_module? + (..in_module module (..full_expansion' again name tail)) + (do meta#monad + [members' (monad#each meta#monad again {#Item head tail})] + (in (list (form$ (list#conjoint members')))))) + + [_ {#Symbol name}] + (..full_expansion' again name tail) + + _ + (do meta#monad + [members' (monad#each meta#monad again {#Item head tail})] + (in (list (form$ (list#conjoint members')))))} + head) + + [_ {#Variant members}] + (do meta#monad + [members' (monad#each meta#monad again members)] + (in (list (variant$ (list#conjoint members'))))) + + [_ {#Tuple members}] + (do meta#monad + [members' (monad#each meta#monad again members)] + (in (list (tuple$ (list#conjoint members'))))) + + _ + (meta#in (list syntax))} + syntax))) + +(def''' .private (text#encoded original) + (-> Text Text) + (all text#composite ..double_quote original ..double_quote)) + +(def''' .private (code#encoded code) + (-> Code Text) + ({[_ {#Bit value}] + (bit#encoded value) + + [_ {#Nat value}] + (nat#encoded value) + + [_ {#Int value}] + (int#encoded value) + + [_ {#Rev value}] + ("lux io error" "@code#encoded Undefined behavior.") + + [_ {#Frac value}] + (frac#encoded value) -(def:''' .private (single_expansion token) - (-> Code ($' Meta ($' List Code))) - ({[_ {#Form {#Item [_ {#Symbol name}] args}}] - (do meta#monad - [name' (normal name) - ?macro (named_macro name')] - ({{#Some macro} - (("lux type as" Macro' macro) args) - - {#None} - (in (list token))} - ?macro)) + [_ {#Text value}] + (text#encoded value) + + [_ {#Symbol [module name]}] + (symbol#encoded [module name]) + + [_ {#Form xs}] + (all text#composite "(" (|> xs + (list#each code#encoded) + (list#interposed " ") + list#reversed + (list#mix text#composite "")) ")") + + [_ {#Tuple xs}] + (all text#composite "[" (|> xs + (list#each code#encoded) + (list#interposed " ") + list#reversed + (list#mix text#composite "")) "]") + + [_ {#Variant xs}] + (all text#composite "{" (|> xs + (list#each code#encoded) + (list#interposed " ") + list#reversed + (list#mix text#composite "")) "}")} + code)) + +(def''' .private (normal_type type) + (-> Code Code) + ({[_ {#Variant {#Item [_ {#Symbol symbol}] parts}}] + (` {(~ (symbol$ symbol)) (~+ (list#each normal_type parts))}) + + [_ {#Tuple members}] + (` (Tuple (~+ (list#each normal_type members)))) + + [_ {#Form {#Item [_ {#Text "lux in-module"}] + {#Item [_ {#Text module}] + {#Item type' + {#End}}}}}] + (` ("lux in-module" (~ (text$ module)) (~ (normal_type type')))) + + [_ {#Form {#Item [_ {#Symbol ["" "~"]}] {#Item expression {#End}}}}] + expression + + [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item body {#End}}}}] + {#Item value + {#End}}}}] + [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item (normal_type body) {#End}}}}] + {#Item value + {#End}}}}] + + [_0 {#Form {#Item [_1 {#Symbol ["library/lux" "__adjusted_quantified_type__"]}] + {#Item _permission + {#Item _level + {#Item body + {#End}}}}}}] + [_0 {#Form {#Item [_1 {#Symbol [..prelude "__adjusted_quantified_type__"]}] + {#Item _permission + {#Item _level + {#Item (normal_type body) + {#End}}}}}}] + + [_ {#Form {#Item type_fn args}}] + (list#mix ("lux type check" (-> Code Code Code) + (function' [arg type_fn] (` {.#Apply (~ arg) (~ type_fn)}))) + (normal_type type_fn) + (list#each normal_type args)) - _ - (meta#in (list token))} - token)) + _ + type} + type)) -(def:''' .private (expansion token) - (-> Code ($' Meta ($' List Code))) - ({[_ {#Form {#Item [_ {#Symbol name}] args}}] +(def'' .public type + Macro + (macro (_ tokens) + ({{#Item type {#End}} (do meta#monad - [name' (normal name) - ?macro (named_macro name')] - ({{#Some macro} + [initialized_quantification? (function' [lux] {#Right [lux (initialized_quantification? lux)]})] + (if initialized_quantification? (do meta#monad - [top_level_expansion (("lux type as" Macro' macro) args) - recursive_expansion (monad#each meta#monad expansion top_level_expansion)] - (in (list#conjoint recursive_expansion))) - - {#None} - (in (list token))} - ?macro)) - - _ - (meta#in (list token))} - token)) - -(def:''' .private (full_expansion' full_expansion name args) - (-> (-> Code ($' Meta ($' List Code))) Symbol ($' List Code) ($' Meta ($' List Code))) - (do meta#monad - [name' (normal name) - ?macro (named_macro name')] - ({{#Some macro} - (do meta#monad - [expansion (("lux type as" Macro' macro) args) - expansion' (monad#each meta#monad full_expansion expansion)] - (in (list#conjoint expansion'))) - - {#None} - (do meta#monad - [args' (monad#each meta#monad full_expansion args)] - (in (list (form$ {#Item (symbol$ name) (list#conjoint args')}))))} - ?macro))) - -(def:''' .private (in_module module meta) - (All (_ a) - (-> Text ($' Meta a) ($' Meta a))) - (function' [lux] - ({[..#info info ..#source source - ..#current_module current_module ..#modules modules - ..#scopes scopes ..#type_context type_context - ..#host host ..#seed seed - ..#expected expected ..#location location - ..#extensions extensions ..#scope_type_vars scope_type_vars - ..#eval eval] - ({{#Left error} - {#Left error} - - {#Right [[..#info info' ..#source source' - ..#current_module _ ..#modules modules' - ..#scopes scopes' ..#type_context type_context' - ..#host host' ..#seed seed' - ..#expected expected' ..#location location' - ..#extensions extensions' ..#scope_type_vars scope_type_vars' - ..#eval eval'] - output]} - {#Right [[..#info info' ..#source source' - ..#current_module current_module ..#modules modules' - ..#scopes scopes' ..#type_context type_context' - ..#host host' ..#seed seed' - ..#expected expected' ..#location location' - ..#extensions extensions' ..#scope_type_vars scope_type_vars' - ..#eval eval'] - output]}} - (meta [..#info info ..#source source - ..#current_module {.#Some module} ..#modules modules - ..#scopes scopes ..#type_context type_context - ..#host host ..#seed seed - ..#expected expected ..#location location - ..#extensions extensions ..#scope_type_vars scope_type_vars - ..#eval eval]))} - lux))) - -(def:''' .private (full_expansion expand_in_module?) - (-> Bit Code ($' Meta ($' List Code))) - (function' again [syntax] - ({[_ {#Form {#Item head tail}}] - ({[_ {#Form {#Item [_ {#Text "lux in-module"}] - {#Item [_ {#Text module}] - {#Item [_ {#Symbol name}] - {#End}}}}}] - (if expand_in_module? - (..in_module module (..full_expansion' again name tail)) - (do meta#monad - [members' (monad#each meta#monad again {#Item head tail})] - (in (list (form$ (list#conjoint members')))))) + [type+ (full_expansion #0 type)] + ({{#Item type' {#End}} + (in (list (normal_type type'))) - [_ {#Symbol name}] - (..full_expansion' again name tail) - - _ - (do meta#monad - [members' (monad#each meta#monad again {#Item head tail})] - (in (list (form$ (list#conjoint members')))))} - head) - - [_ {#Variant members}] - (do meta#monad - [members' (monad#each meta#monad again members)] - (in (list (variant$ (list#conjoint members'))))) - - [_ {#Tuple members}] - (do meta#monad - [members' (monad#each meta#monad again members)] - (in (list (tuple$ (list#conjoint members'))))) - - _ - (meta#in (list syntax))} - syntax))) - -(def:''' .private (text#encoded original) - (-> Text Text) - (all text#composite ..double_quote original ..double_quote)) - -(def:''' .private (code#encoded code) - (-> Code Text) - ({[_ {#Bit value}] - (bit#encoded value) - - [_ {#Nat value}] - (nat#encoded value) - - [_ {#Int value}] - (int#encoded value) - - [_ {#Rev value}] - ("lux io error" "@code#encoded Undefined behavior.") - - [_ {#Frac value}] - (frac#encoded value) - - [_ {#Text value}] - (text#encoded value) - - [_ {#Symbol [module name]}] - (symbol#encoded [module name]) - - [_ {#Form xs}] - (all text#composite "(" (|> xs - (list#each code#encoded) - (list#interposed " ") - list#reversed - (list#mix text#composite "")) ")") - - [_ {#Tuple xs}] - (all text#composite "[" (|> xs - (list#each code#encoded) - (list#interposed " ") - list#reversed - (list#mix text#composite "")) "]") - - [_ {#Variant xs}] - (all text#composite "{" (|> xs - (list#each code#encoded) - (list#interposed " ") - list#reversed - (list#mix text#composite "")) "}")} - code)) - -(def:''' .private (normal_type type) - (-> Code Code) - ({[_ {#Variant {#Item [_ {#Symbol symbol}] parts}}] - (` {(~ (symbol$ symbol)) (~+ (list#each normal_type parts))}) - - [_ {#Tuple members}] - (` (Tuple (~+ (list#each normal_type members)))) - - [_ {#Form {#Item [_ {#Text "lux in-module"}] - {#Item [_ {#Text module}] - {#Item type' - {#End}}}}}] - (` ("lux in-module" (~ (text$ module)) (~ (normal_type type')))) - - [_ {#Form {#Item [_ {#Symbol ["" "~"]}] {#Item expression {#End}}}}] - expression - - [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item body {#End}}}}] - {#Item value - {#End}}}}] - [_0 {#Form {#Item [_1 {#Variant {#Item binding {#Item (normal_type body) {#End}}}}] - {#Item value - {#End}}}}] - - [_0 {#Form {#Item [_1 {#Symbol ["library/lux" "__adjusted_quantified_type__"]}] - {#Item _permission - {#Item _level - {#Item body - {#End}}}}}}] - [_0 {#Form {#Item [_1 {#Symbol [..prelude "__adjusted_quantified_type__"]}] - {#Item _permission - {#Item _level - {#Item (normal_type body) - {#End}}}}}}] - - [_ {#Form {#Item type_fn args}}] - (list#mix ("lux type check" (-> Code Code Code) - (function' [arg type_fn] (` {.#Apply (~ arg) (~ type_fn)}))) - (normal_type type_fn) - (list#each normal_type args)) + _ + (failure "The expansion of the type-syntax had to yield a single element.")} + type+)) + (in (list (..quantified (` (..type (~ type)))))))) _ - type} - type)) - -(def:'' .public type - Macro - (macro (_ tokens) - ({{#Item type {#End}} - (do meta#monad - [initialized_quantification? (function' [lux] {#Right [lux (initialized_quantification? lux)]})] - (if initialized_quantification? - (do meta#monad - [type+ (full_expansion #0 type)] - ({{#Item type' {#End}} - (in (list (normal_type type'))) - - _ - (failure "The expansion of the type-syntax had to yield a single element.")} - type+)) - (in (list (..quantified (` (..type (~ type)))))))) - - _ - (failure "Wrong syntax for type")} - tokens))) - -(def:'' .public is - Macro - (macro (_ tokens) - ({{#Item type {#Item value {#End}}} - (meta#in (list (` ("lux type check" - (..type (~ type)) - (~ value))))) + (failure "Wrong syntax for type")} + tokens))) - _ - (failure "Wrong syntax for :")} - tokens))) +(def'' .public is + Macro + (macro (_ tokens) + ({{#Item type {#Item value {#End}}} + (meta#in (list (` ("lux type check" + (..type (~ type)) + (~ value))))) -(def:'' .public as - Macro - (macro (_ tokens) - ({{#Item type {#Item value {#End}}} - (meta#in (list (` ("lux type as" - (..type (~ type)) - (~ value))))) + _ + (failure "Wrong syntax for :")} + tokens))) - _ - (failure "Wrong syntax for as")} - tokens))) +(def'' .public as + Macro + (macro (_ tokens) + ({{#Item type {#Item value {#End}}} + (meta#in (list (` ("lux type as" + (..type (~ type)) + (~ value))))) -(def:''' .private (empty? xs) - (All (_ a) - (-> ($' List a) Bit)) - ({{#End} #1 - _ #0} - xs)) + _ + (failure "Wrong syntax for as")} + tokens))) + +(def''' .private (empty? xs) + (All (_ a) + (-> ($' List a) Bit)) + ({{#End} #1 + _ #0} + xs)) (with_template [<name> <type> <value>] - [(def:''' .private (<name> xy) - (All (_ a b) - (-> (Tuple a b) <type>)) - (let' [[x y] xy] - <value>))] + [(def''' .private (<name> xy) + (All (_ a b) + (-> (Tuple a b) <type>)) + (let' [[x y] xy] + <value>))] [product#left a x] [product#right b y]) -(def:''' .private (generated_symbol prefix state) - (-> Text ($' Meta Code)) - ({[..#info info ..#source source ..#current_module _ ..#modules modules - ..#scopes scopes ..#type_context types ..#host host - ..#seed seed ..#expected expected - ..#location location ..#extensions extensions - ..#scope_type_vars scope_type_vars ..#eval _eval] - {#Right [..#info info ..#source source ..#current_module _ ..#modules modules - ..#scopes scopes ..#type_context types ..#host host - ..#seed ("lux i64 +" 1 seed) ..#expected expected - ..#location location ..#extensions extensions - ..#scope_type_vars scope_type_vars ..#eval _eval] - (local$ (all text#composite "__gensym__" prefix (nat#encoded seed)))}} - state)) - -(def:'' .public exec - Macro - (macro (_ tokens) - ({{#Item value actions} - (let' [dummy (local$ "")] - (meta#in (list (list#mix ("lux type check" (-> Code Code Code) - (function' [pre post] (` ({(~ dummy) (~ post)} - (~ pre))))) - value - actions)))) - - _ - (failure "Wrong syntax for exec")} - (list#reversed tokens)))) - -(def:'' .private def:' - Macro - (macro (_ tokens) - (let' [parts (is (Maybe [Code Code (List Code) (Maybe Code) Code]) - ({{#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item type {#Item body {#End}}}}} - {#Some [export_policy name args {#Some type} body]} - - {#Item export_policy {#Item name {#Item type {#Item body {#End}}}}} - {#Some [export_policy name {#End} {#Some type} body]} - - {#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item body {#End}}}} - {#Some [export_policy name args {#None} body]} - - {#Item export_policy {#Item name {#Item body {#End}}}} - {#Some [export_policy name {#End} {#None} body]} +(def''' .private (generated_symbol prefix state) + (-> Text ($' Meta Code)) + ({[..#info info ..#source source ..#current_module _ ..#modules modules + ..#scopes scopes ..#type_context types ..#host host + ..#seed seed ..#expected expected + ..#location location ..#extensions extensions + ..#scope_type_vars scope_type_vars ..#eval _eval] + {#Right [..#info info ..#source source ..#current_module _ ..#modules modules + ..#scopes scopes ..#type_context types ..#host host + ..#seed ("lux i64 +" 1 seed) ..#expected expected + ..#location location ..#extensions extensions + ..#scope_type_vars scope_type_vars ..#eval _eval] + (local$ (all text#composite "__gensym__" prefix (nat#encoded seed)))}} + state)) - _ - {#None}} - tokens))] - ({{#Some [export_policy name args ?type body]} - (let' [body' ({{#End} - body +(def'' .public exec + Macro + (macro (_ tokens) + ({{#Item value actions} + (let' [dummy (local$ "")] + (meta#in (list (list#mix ("lux type check" (-> Code Code Code) + (function' [pre post] (` ({(~ dummy) (~ post)} + (~ pre))))) + value + actions)))) - _ - (` (function' (~ name) [(~+ args)] (~ body)))} - args) - body'' ({{#Some type} - (` (is (~ type) (~ body'))) - - {#None} - body'} - ?type)] - (meta#in (list (` ("lux def" (~ name) - (~ body'') - (~ export_policy)))))) - - {#None} - (failure "Wrong syntax for def'")} - parts)))) - -(def:' .private (case_expansion branches) - (-> (List Code) (Meta (List Code))) - ({{#Item [_ {#Form {#Item [_ {#Symbol name}] args}}] - {#Item body - branches'}} - (do meta#monad - [??? (macro? name)] - (if ??? - (do meta#monad - [init_expansion (single_expansion (form$ (partial_list (symbol$ name) (form$ args) body branches')))] - (case_expansion init_expansion)) - (do meta#monad - [sub_expansion (case_expansion branches')] - (in (partial_list (form$ (partial_list (symbol$ name) args)) - body - sub_expansion))))) - - {#Item pattern {#Item body branches'}} - (do meta#monad - [sub_expansion (case_expansion branches')] - (in (partial_list pattern body sub_expansion))) - - {#End} - (do meta#monad [] (in (list))) + _ + (failure "Wrong syntax for exec")} + (list#reversed tokens)))) + +(def'' .private def' + Macro + (macro (_ tokens) + (let' [parts (is (Maybe [Code Code (List Code) (Maybe Code) Code]) + ({{#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item type {#Item body {#End}}}}} + {#Some [export_policy name args {#Some type} body]} + + {#Item export_policy {#Item name {#Item type {#Item body {#End}}}}} + {#Some [export_policy name {#End} {#Some type} body]} + + {#Item export_policy {#Item [_ {#Form {#Item name args}}] {#Item body {#End}}}} + {#Some [export_policy name args {#None} body]} + + {#Item export_policy {#Item name {#Item body {#End}}}} + {#Some [export_policy name {#End} {#None} body]} - _ - (failure (all text#composite "'lux.case' expects an even number of tokens: " (|> branches - (list#each code#encoded) - (list#interposed " ") - list#reversed - (list#mix text#composite ""))))} - branches)) - -(def:'' .public case - Macro - (macro (_ tokens) - ({{#Item value branches} + _ + {#None}} + tokens))] + ({{#Some [export_policy name args ?type body]} + (let' [body' ({{#End} + body + + _ + (` (function' (~ name) [(~+ args)] (~ body)))} + args) + body'' ({{#Some type} + (` (is (~ type) (~ body'))) + + {#None} + body'} + ?type)] + (meta#in (list (` ("lux def" (~ name) + (~ body'') + (~ export_policy)))))) + + {#None} + (failure "Wrong syntax for def'")} + parts)))) + +(def' .private (case_expansion branches) + (-> (List Code) (Meta (List Code))) + ({{#Item [_ {#Form {#Item [_ {#Symbol name}] args}}] + {#Item body + branches'}} + (do meta#monad + [??? (macro? name)] + (if ??? (do meta#monad - [expansion (case_expansion branches)] - (in (list (` ((~ (variant$ expansion)) (~ value)))))) - - _ - (failure "Wrong syntax for case")} - tokens))) - -(def:'' .public pattern - Macro - (macro (_ tokens) - (case tokens - {#Item [_ {#Form {#Item pattern {#End}}}] {#Item body branches}} + [init_expansion (single_expansion (form$ (partial_list (symbol$ name) (form$ args) body branches')))] + (case_expansion init_expansion)) (do meta#monad - [pattern+ (full_expansion #1 pattern)] - (case pattern+ - {#Item pattern' {#End}} - (in (partial_list pattern' body branches)) - - _ - (failure "`pattern` can only expand to 1 pattern."))) - - _ - (failure "Wrong syntax for `pattern` macro")))) + [sub_expansion (case_expansion branches')] + (in (partial_list (form$ (partial_list (symbol$ name) args)) + body + sub_expansion))))) -(def:'' .private pattern#or - Macro - (macro (_ tokens) - (case tokens - (pattern (partial_list [_ {#Form patterns}] body branches)) - (case patterns - {#End} - (failure "pattern#or cannot have 0 patterns") + {#Item pattern {#Item body branches'}} + (do meta#monad + [sub_expansion (case_expansion branches')] + (in (partial_list pattern body sub_expansion))) - _ - (let' [pairs (|> patterns - (list#each (function' [pattern] (list pattern body))) - (list#conjoint))] - (meta#in (list#composite pairs branches)))) - _ - (failure "Wrong syntax for pattern#or")))) + {#End} + (do meta#monad [] (in (list))) -(def:'' .public symbol - Macro - (macro (_ tokens) - (case tokens - (pattern (list [_ {#Symbol [module name]}])) - (meta#in (list (` [(~ (text$ module)) (~ (text$ name))]))) - - _ - (failure (..wrong_syntax_error [..prelude "symbol"]))))) + _ + (failure (all text#composite "'lux.case' expects an even number of tokens: " (|> branches + (list#each code#encoded) + (list#interposed " ") + list#reversed + (list#mix text#composite ""))))} + branches)) + +(def'' .public case + Macro + (macro (_ tokens) + ({{#Item value branches} + (do meta#monad + [expansion (case_expansion branches)] + (in (list (` ((~ (variant$ expansion)) (~ value)))))) -(def:' .private (symbol? code) - (-> Code Bit) - (case code - [_ {#Symbol _}] - #1 + _ + (failure "Wrong syntax for case")} + tokens))) + +(def'' .public pattern + Macro + (macro (_ tokens) + (case tokens + {#Item [_ {#Form {#Item pattern {#End}}}] {#Item body branches}} + (do meta#monad + [pattern+ (full_expansion #1 pattern)] + (case pattern+ + {#Item pattern' {#End}} + (in (partial_list pattern' body branches)) + + _ + (failure "`pattern` can only expand to 1 pattern."))) + + _ + (failure "Wrong syntax for `pattern` macro")))) - _ - #0)) +(def'' .private pattern#or + Macro + (macro (_ tokens) + (case tokens + (pattern (partial_list [_ {#Form patterns}] body branches)) + (case patterns + {#End} + (failure "pattern#or cannot have 0 patterns") -(def:'' .public let - Macro - (macro (_ tokens) - (case tokens - (pattern (list [_ {#Tuple bindings}] body)) - (case (..pairs bindings) - {#Some bindings} - (|> bindings - list#reversed - (list#mix (is (-> [Code Code] Code Code) - (function' [lr body'] - (let' [[l r] lr] - (if (symbol? l) - (` ({(~ l) (~ body')} (~ r))) - (` (case (~ r) (~ l) (~ body'))))))) - body) - list - meta#in) + _ + (let' [pairs (|> patterns + (list#each (function' [pattern] (list pattern body))) + (list#conjoint))] + (meta#in (list#composite pairs branches)))) + _ + (failure "Wrong syntax for pattern#or")))) + +(def'' .public symbol + Macro + (macro (_ tokens) + (case tokens + (pattern (list [_ {#Symbol [module name]}])) + (meta#in (list (` [(~ (text$ module)) (~ (text$ name))]))) + + _ + (failure (..wrong_syntax_error [..prelude "symbol"]))))) - {#None} - (failure "let requires an even number of parts")) +(def' .private (symbol? code) + (-> Code Bit) + (case code + [_ {#Symbol _}] + #1 - _ - (failure (..wrong_syntax_error (symbol ..let)))))) + _ + #0)) + +(def'' .public let + Macro + (macro (_ tokens) + (case tokens + (pattern (list [_ {#Tuple bindings}] body)) + (case (..pairs bindings) + {#Some bindings} + (|> bindings + list#reversed + (list#mix (is (-> [Code Code] Code Code) + (function' [lr body'] + (let' [[l r] lr] + (if (symbol? l) + (` ({(~ l) (~ body')} (~ r))) + (` (case (~ r) (~ l) (~ body'))))))) + body) + list + meta#in) -(def:'' .public function - Macro - (macro (_ tokens) - (case (is (Maybe [Text Code (List Code) Code]) - (case tokens - (pattern (list [_ {#Form (partial_list [_ {#Symbol ["" name]}] head tail)}] body)) - {#Some name head tail body} - - _ - {#None})) - {#Some g!name head tail body} - (let [g!blank (local$ "") - nest (is (-> Code (-> Code Code Code)) - (function' [g!name] - (function' [arg body'] - (if (symbol? arg) - (` ([(~ g!name) (~ arg)] (~ body'))) - (` ([(~ g!name) (~ g!blank)] - (.case (~ g!blank) (~ arg) (~ body'))))))))] - (meta#in (list (nest (..local$ g!name) head - (list#mix (nest g!blank) body (list#reversed tail)))))) + {#None} + (failure "let requires an even number of parts")) - {#None} - (failure (..wrong_syntax_error (symbol ..function)))))) + _ + (failure (..wrong_syntax_error (symbol ..let)))))) + +(def'' .public function + Macro + (macro (_ tokens) + (case (is (Maybe [Text Code (List Code) Code]) + (case tokens + (pattern (list [_ {#Form (partial_list [_ {#Symbol ["" name]}] head tail)}] body)) + {#Some name head tail body} + + _ + {#None})) + {#Some g!name head tail body} + (let [g!blank (local$ "") + nest (is (-> Code (-> Code Code Code)) + (function' [g!name] + (function' [arg body'] + (if (symbol? arg) + (` ([(~ g!name) (~ arg)] (~ body'))) + (` ([(~ g!name) (~ g!blank)] + (.case (~ g!blank) (~ arg) (~ body'))))))))] + (meta#in (list (nest (..local$ g!name) head + (list#mix (nest g!blank) body (list#reversed tail)))))) -(def:' .private Parser - Type - {#Named [..prelude "Parser"] - (..type (All (_ a) - (-> (List Code) (Maybe [(List Code) a]))))}) + {#None} + (failure (..wrong_syntax_error (symbol ..function)))))) -(def:' .private (parsed parser tokens) - (All (_ a) (-> (Parser a) (List Code) (Maybe a))) - (case (parser tokens) - (pattern {#Some [(list) it]}) - {#Some it} +(def' .private Parser + Type + {#Named [..prelude "Parser"] + (..type (All (_ a) + (-> (List Code) (Maybe [(List Code) a]))))}) - _ - {#None})) - -(def:' .private (inP it tokens) - (All (_ a) - (-> a (Parser a))) - {#Some [tokens it]}) - -(def:' .private (orP leftP rightP tokens) - (All (_ l r) - (-> (Parser l) - (Parser r) - (Parser (Or l r)))) - (case (leftP tokens) - {#Some [tokens left]} - {#Some [tokens {#Left left}]} +(def' .private (parsed parser tokens) + (All (_ a) (-> (Parser a) (List Code) (Maybe a))) + (case (parser tokens) + (pattern {#Some [(list) it]}) + {#Some it} - _ - (case (rightP tokens) - {#Some [tokens right]} - {#Some [tokens {#Right right}]} + _ + {#None})) + +(def' .private (inP it tokens) + (All (_ a) + (-> a (Parser a))) + {#Some [tokens it]}) + +(def' .private (orP leftP rightP tokens) + (All (_ l r) + (-> (Parser l) + (Parser r) + (Parser (Or l r)))) + (case (leftP tokens) + {#Some [tokens left]} + {#Some [tokens {#Left left}]} - _ - {#None}))) - -(def:' .private (eitherP leftP rightP tokens) - (All (_ a) - (-> (Parser a) - (Parser a) - (Parser a))) - (case (leftP tokens) - {#None} - (rightP tokens) - - it - it)) - -(def:' .private (andP leftP rightP tokens) - (All (_ l r) - (-> (Parser l) - (Parser r) - (Parser [l r]))) - (do maybe#monad - [left (leftP tokens) - .let [[tokens left] left] - right (rightP tokens) - .let [[tokens right] right]] - (in [tokens [left right]]))) - -(def:' .private (afterP leftP rightP tokens) - (All (_ l r) - (-> (Parser l) - (Parser r) - (Parser r))) - (do maybe#monad - [left (leftP tokens) - .let [[tokens left] left]] - (rightP tokens))) - -(def:' .private (someP itP tokens) - (All (_ a) - (-> (Parser a) - (Parser (List a)))) - (case (itP tokens) - {#Some [tokens head]} - (do maybe#monad - [it (someP itP tokens) - .let [[tokens tail] it]] - (in [tokens (partial_list head tail)])) + _ + (case (rightP tokens) + {#Some [tokens right]} + {#Some [tokens {#Right right}]} - {#None} - {#Some [tokens (list)]})) - -(def:' .private (manyP itP tokens) - (All (_ a) - (-> (Parser a) - (Parser (List a)))) - (do maybe#monad - [it (itP tokens) - .let [[tokens head] it] - it (someP itP tokens) - .let [[tokens tail] it]] - (in [tokens (partial_list head tail)]))) - -(def:' .private (maybeP itP tokens) - (All (_ a) - (-> (Parser a) - (Parser (Maybe a)))) - (case (itP tokens) - {#Some [tokens it]} - {#Some [tokens {#Some it}]} + _ + {#None}))) + +(def' .private (eitherP leftP rightP tokens) + (All (_ a) + (-> (Parser a) + (Parser a) + (Parser a))) + (case (leftP tokens) + {#None} + (rightP tokens) + + it + it)) + +(def' .private (andP leftP rightP tokens) + (All (_ l r) + (-> (Parser l) + (Parser r) + (Parser [l r]))) + (do maybe#monad + [left (leftP tokens) + .let [[tokens left] left] + right (rightP tokens) + .let [[tokens right] right]] + (in [tokens [left right]]))) + +(def' .private (afterP leftP rightP tokens) + (All (_ l r) + (-> (Parser l) + (Parser r) + (Parser r))) + (do maybe#monad + [left (leftP tokens) + .let [[tokens left] left]] + (rightP tokens))) + +(def' .private (someP itP tokens) + (All (_ a) + (-> (Parser a) + (Parser (List a)))) + (case (itP tokens) + {#Some [tokens head]} + (do maybe#monad + [it (someP itP tokens) + .let [[tokens tail] it]] + (in [tokens (partial_list head tail)])) - {#None} - {#Some [tokens {#None}]})) + {#None} + {#Some [tokens (list)]})) + +(def' .private (manyP itP tokens) + (All (_ a) + (-> (Parser a) + (Parser (List a)))) + (do maybe#monad + [it (itP tokens) + .let [[tokens head] it] + it (someP itP tokens) + .let [[tokens tail] it]] + (in [tokens (partial_list head tail)]))) + +(def' .private (maybeP itP tokens) + (All (_ a) + (-> (Parser a) + (Parser (Maybe a)))) + (case (itP tokens) + {#Some [tokens it]} + {#Some [tokens {#Some it}]} -(def:' .private (tupleP itP tokens) - (All (_ a) - (-> (Parser a) (Parser a))) - (case tokens - (pattern (partial_list [_ {#Tuple input}] tokens')) - (do maybe#monad - [it (parsed itP input)] - (in [tokens' it])) + {#None} + {#Some [tokens {#None}]})) - _ - {#None})) +(def' .private (tupleP itP tokens) + (All (_ a) + (-> (Parser a) (Parser a))) + (case tokens + (pattern (partial_list [_ {#Tuple input}] tokens')) + (do maybe#monad + [it (parsed itP input)] + (in [tokens' it])) -(def:' .private (formP itP tokens) - (All (_ a) - (-> (Parser a) (Parser a))) - (case tokens - (pattern (partial_list [_ {#Form input}] tokens')) - (do maybe#monad - [it (parsed itP input)] - (in [tokens' it])) + _ + {#None})) - _ - {#None})) +(def' .private (formP itP tokens) + (All (_ a) + (-> (Parser a) (Parser a))) + (case tokens + (pattern (partial_list [_ {#Form input}] tokens')) + (do maybe#monad + [it (parsed itP input)] + (in [tokens' it])) -(def:' .private (bindingP tokens) - (Parser [Text Code]) - (case tokens - (pattern (partial_list [_ {#Symbol ["" name]}] value &rest)) - {#Some [&rest [name value]]} + _ + {#None})) - _ - {#None})) +(def' .private (bindingP tokens) + (Parser [Text Code]) + (case tokens + (pattern (partial_list [_ {#Symbol ["" name]}] value &rest)) + {#Some [&rest [name value]]} -(def:' .private (endP tokens) - (Parser Any) - (case tokens - (pattern (list)) - {#Some [tokens []]} + _ + {#None})) - _ - {#None})) +(def' .private (endP tokens) + (Parser Any) + (case tokens + (pattern (list)) + {#Some [tokens []]} -(def:' .private (anyP tokens) - (Parser Code) - (case tokens - (pattern (partial_list code tokens')) - {#Some [tokens' code]} + _ + {#None})) - _ - {#None})) +(def' .private (anyP tokens) + (Parser Code) + (case tokens + (pattern (partial_list code tokens')) + {#Some [tokens' code]} -(def:' .private (localP tokens) - (-> (List Code) (Maybe [(List Code) Text])) - (case tokens - (pattern (partial_list [_ {#Symbol ["" local]}] tokens')) - {#Some [tokens' local]} + _ + {#None})) - _ - {#None})) +(def' .private (localP tokens) + (-> (List Code) (Maybe [(List Code) Text])) + (case tokens + (pattern (partial_list [_ {#Symbol ["" local]}] tokens')) + {#Some [tokens' local]} + + _ + {#None})) -(def:' .private (symbolP tokens) - (-> (List Code) (Maybe [(List Code) Symbol])) - (case tokens - (pattern (partial_list [_ {#Symbol it}] tokens')) - {#Some [tokens' it]} +(def' .private (symbolP tokens) + (-> (List Code) (Maybe [(List Code) Symbol])) + (case tokens + (pattern (partial_list [_ {#Symbol it}] tokens')) + {#Some [tokens' it]} - _ - {#None})) + _ + {#None})) (with_template [<parser> <item_type> <item_parser>] - [(def:' .private (<parser> tokens) - (-> (List Code) (Maybe (List <item_type>))) - (case tokens - {#End} - {#Some {#End}} + [(def' .private (<parser> tokens) + (-> (List Code) (Maybe (List <item_type>))) + (case tokens + {#End} + {#Some {#End}} - _ - (do maybe#monad - [% (<item_parser> tokens) - .let' [[tokens head] %] - tail (<parser> tokens)] - (in {#Item head tail}))))] + _ + (do maybe#monad + [% (<item_parser> tokens) + .let' [[tokens head] %] + tail (<parser> tokens)] + (in {#Item head tail}))))] [parametersP Text localP] [enhanced_parametersP Code anyP] ) (with_template [<parser> <parameter_type> <parameters_parser>] - [(def:' .private (<parser> tokens) - (Parser [Text (List <parameter_type>)]) - (case tokens - (pattern (partial_list [_ {#Form local_declaration}] tokens')) - (do maybe#monad - [% (localP local_declaration) - .let' [[local_declaration name] %] - parameters (<parameters_parser> local_declaration)] - (in [tokens' [name parameters]])) - - _ - (do maybe#monad - [% (localP tokens) - .let' [[tokens' name] %]] - (in [tokens' [name {#End}]]))))] + [(def' .private (<parser> tokens) + (Parser [Text (List <parameter_type>)]) + (case tokens + (pattern (partial_list [_ {#Form local_declaration}] tokens')) + (do maybe#monad + [% (localP local_declaration) + .let' [[local_declaration name] %] + parameters (<parameters_parser> local_declaration)] + (in [tokens' [name parameters]])) + + _ + (do maybe#monad + [% (localP tokens) + .let' [[tokens' name] %]] + (in [tokens' [name {#End}]]))))] [local_declarationP Text parametersP] [enhanced_local_declarationP Code enhanced_parametersP] ) -(def:' .private (export_policyP tokens) - (-> (List Code) [(List Code) Code]) - (case tokens - (pattern (partial_list candidate tokens')) - (case candidate - [_ {#Bit it}] - [tokens' candidate] - - [_ {#Symbol ["" _]}] - [tokens (` .private)] - - [_ {#Symbol it}] - [tokens' candidate] +(def' .private (export_policyP tokens) + (-> (List Code) [(List Code) Code]) + (case tokens + (pattern (partial_list candidate tokens')) + (case candidate + [_ {#Bit it}] + [tokens' candidate] + + [_ {#Symbol ["" _]}] + [tokens (` .private)] + + [_ {#Symbol it}] + [tokens' candidate] - _ - [tokens (` .private)]) + _ + [tokens (` .private)]) - _ - [tokens (` .private)])) + _ + [tokens (` .private)])) (with_template [<parser> <parameter_type> <local>] - [(def:' .private (<parser> tokens) - (-> (List Code) (Maybe [(List Code) [Code Text (List <parameter_type>)]])) - (do maybe#monad - [.let' [[tokens export_policy] (export_policyP tokens)] - % (<local> tokens) - .let' [[tokens [name parameters]] %]] - (in [tokens [export_policy name parameters]])))] + [(def' .private (<parser> tokens) + (-> (List Code) (Maybe [(List Code) [Code Text (List <parameter_type>)]])) + (do maybe#monad + [.let' [[tokens export_policy] (export_policyP tokens)] + % (<local> tokens) + .let' [[tokens [name parameters]] %]] + (in [tokens [export_policy name parameters]])))] [declarationP Text local_declarationP] [enhanced_declarationP Code enhanced_local_declarationP] ) -(def:' .private (bodyP tokens) - (-> (List Code) (Maybe [(List Code) [(Maybe Code) Code]])) - (case tokens - ... TB - (pattern (partial_list type body tokens')) - {#Some [tokens' [{#Some type} body]]} +(def' .private (bodyP tokens) + (-> (List Code) (Maybe [(List Code) [(Maybe Code) Code]])) + (case tokens + ... TB + (pattern (partial_list type body tokens')) + {#Some [tokens' [{#Some type} body]]} - ... B - (pattern (partial_list body tokens')) - {#Some [tokens' [{#None} body]]} + ... B + (pattern (partial_list body tokens')) + {#Some [tokens' [{#None} body]]} - _ - {#None})) - -(def:' .private (definitionP tokens) - (-> (List Code) (Maybe [Code Text (List Code) (Maybe Code) Code])) - (do maybe#monad - [% (enhanced_declarationP tokens) - .let' [[tokens [export_policy name parameters]] %] - % (bodyP tokens) - .let' [[tokens [?type body]] %] - _ (endP tokens)] - (in [export_policy name parameters ?type body]))) - -(def:'' .public def: - Macro - (macro (_ tokens) - (case (definitionP tokens) - {#Some [export_policy name parameters ?type body]} - (let [body (case parameters - {#End} - body + _ + {#None})) + +(def' .private (definitionP tokens) + (-> (List Code) (Maybe [Code Text (List Code) (Maybe Code) Code])) + (do maybe#monad + [% (enhanced_declarationP tokens) + .let' [[tokens [export_policy name parameters]] %] + % (bodyP tokens) + .let' [[tokens [?type body]] %] + _ (endP tokens)] + (in [export_policy name parameters ?type body]))) + +(def'' .public def + Macro + (macro (_ tokens) + (case (definitionP tokens) + {#Some [export_policy name parameters ?type body]} + (let [body (case parameters + {#End} + body - _ - (` (function ((~ (..local$ name)) (~+ parameters)) - (~ body)))) - body (case ?type - {#Some type} - (` (is (~ type) - (~ body))) - - {#None} - body)] - (meta#in (list (` ("lux def" (~ (..local$ name)) - (~ body) - (~ export_policy)))))) - - {#None} - (failure (..wrong_syntax_error (symbol ..def:)))))) + _ + (` (function ((~ (..local$ name)) (~+ parameters)) + (~ body)))) + body (case ?type + {#Some type} + (` (is (~ type) + (~ body))) + + {#None} + body)] + (meta#in (list (` ("lux def" (~ (..local$ name)) + (~ body) + (~ export_policy)))))) + + {#None} + (failure (..wrong_syntax_error (symbol ..def)))))) -(def: (list#one f xs) +(def (list#one f xs) (All (_ a b) (-> (-> a (Maybe b)) (List a) (Maybe b))) (case xs @@ -2957,7 +2957,7 @@ {#Some y}))) (with_template [<name> <form> <message>] - [(def: .public <name> + [(def .public <name> (macro (_ tokens) (case (list#reversed tokens) (pattern (partial_list last init)) @@ -2972,15 +2972,15 @@ [and (if (~ pre) (~ post) #0) "'and' requires >=1 clauses."] [or (if (~ pre) #1 (~ post)) "'or' requires >=1 clauses."]) -(def: (index part text) +(def (index part text) (-> Text Text (Maybe Nat)) ("lux text index" 0 part text)) -(def: .public (panic! message) +(def .public (panic! message) (-> Text Nothing) ("lux io error" message)) -(def: maybe#else +(def maybe#else (macro (_ tokens state) (case tokens (pattern (list else maybe)) @@ -2996,7 +2996,7 @@ _ {#Left (..wrong_syntax_error (symbol ..maybe#else))}))) -(def: (text#all_split_by splitter input) +(def (text#all_split_by splitter input) (-> Text Text (List Text)) (case (..index splitter input) {#None} @@ -3011,7 +3011,7 @@ ("lux text size" input))] ("lux text clip" after_offset after_length input)))))) -(def: (item idx xs) +(def (item idx xs) (All (_ a) (-> Nat (List a) (Maybe a))) (case xs @@ -3024,7 +3024,7 @@ (item ("lux i64 -" 1 idx) xs')))) ... https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B2-reduction -(def: (reduced env type) +(def (reduced env type) (-> (List Type) Type Type) (case type {#Sum left right} @@ -3070,7 +3070,7 @@ type )) -(def: (applied_type param type_fn) +(def (applied_type param type_fn) (-> Type Type (Maybe Type)) (case type_fn {#UnivQ env body} @@ -3091,7 +3091,7 @@ {#None})) (with_template [<name> <tag>] - [(def: (<name> type) + [(def (<name> type) (-> Type (List Type)) (case type {<tag> left right} @@ -3105,7 +3105,7 @@ [flat_lambda #Function] ) -(def: (flat_application type) +(def (flat_application type) (-> Type [Type (List Type)]) (case type {#Apply head func'} @@ -3115,7 +3115,7 @@ _ [type (list)])) -(def: (interface_methods type) +(def (interface_methods type) (-> Type (Maybe (List Type))) (case type {#Product _} @@ -3141,7 +3141,7 @@ _ {#Some (list type)})) -(def: (module name) +(def (module name) (-> Text (Meta Module)) (function (_ state) (let [[..#info info ..#source source ..#current_module _ ..#modules modules @@ -3155,7 +3155,7 @@ _ {#Left (all text#composite "Unknown module: " name)})))) -(def: (type_slot [module name]) +(def (type_slot [module name]) (-> Symbol (Meta [Nat (List Symbol) Bit Type])) (do meta#monad [=module (..module module) @@ -3176,7 +3176,7 @@ _ (failure (text#composite "Unknown slot: " (symbol#encoded [module name])))))) -(def: (record_slots type) +(def (record_slots type) (-> Type (Meta (Maybe [(List Symbol) (List Type)]))) (case type {#Apply arg func} @@ -3213,7 +3213,7 @@ _ (meta#in {#None}))) -(def: expected_type +(def expected_type (Meta Type) (function (_ state) (let [[..#info info ..#source source ..#current_module _ ..#modules modules @@ -3227,7 +3227,7 @@ {#None} {#Left "Not expecting any type."})))) -(def: (type#encoded type) +(def (type#encoded type) (-> Type Text) (case type {#Primitive name params} @@ -3273,7 +3273,7 @@ (symbol#encoded name) )) -(def: .public implementation +(def .public implementation (macro (_ tokens) (do meta#monad [tokens' (monad#each meta#monad expansion tokens) @@ -3310,7 +3310,7 @@ (list#conjoint tokens'))] (in (list (tuple$ (list#conjoint members))))))) -(def: (text#interposed separator parts) +(def (text#interposed separator parts) (-> Text (List Text) Text) (case parts {#End} @@ -3322,12 +3322,12 @@ head tail))) -(def: (function#identity value) +(def (function#identity value) (All (_ a) (-> a a)) value) -(def: (everyP itP tokens) +(def (everyP itP tokens) (All (_ a) (-> (-> (List Code) (Maybe [(List Code) a])) (-> (List Code) (Maybe (List a))))) @@ -3347,7 +3347,7 @@ {#End} {#Some (list)})) -(def: (caseP tokens) +(def (caseP tokens) (-> (List Code) (Maybe [(List Code) [Text Code]])) (case tokens (pattern (partial_list [_ {#Variant (list [_ {#Symbol ["" niladic]}])}] tokens')) @@ -3359,7 +3359,7 @@ _ {#None})) -(def: .public Variant +(def .public Variant (macro (_ tokens) (case (everyP caseP tokens) {#Some cases} @@ -3371,7 +3371,7 @@ {#None} (failure (..wrong_syntax_error (symbol ..Variant)))))) -(def: (slotP tokens) +(def (slotP tokens) (-> (List Code) (Maybe [(List Code) [Text Code]])) (case tokens (pattern (partial_list [_ {#Symbol ["" slot]}] type tokens')) @@ -3380,7 +3380,7 @@ _ {#None})) -(def: .public Record +(def .public Record (macro (_ tokens) (case tokens (pattern (list [_ {#Tuple record}])) @@ -3397,7 +3397,7 @@ _ (failure (..wrong_syntax_error (symbol ..Record)))))) -(def: (typeP tokens) +(def (typeP tokens) (-> (List Code) (Maybe [Code Text (List Text) Code])) (do maybe#monad [% (declarationP tokens) @@ -3407,7 +3407,7 @@ _ (endP tokens)] (in [export_policy name parameters definition]))) -(def: (textP tokens) +(def (textP tokens) (-> (List Code) (Maybe [(List Code) Text])) (case tokens (pattern (partial_list [_ {#Text it}] tokens')) @@ -3416,7 +3416,7 @@ _ {#None})) -(def: (type_declaration it) +(def (type_declaration it) (-> Code (Meta (Tuple Code (Maybe (Either (List Text) (List Text)))))) ({[_ {#Form {#Item [_ {#Symbol declarer}] parameters}}] (do meta#monad @@ -3448,7 +3448,7 @@ (meta#in [type {#None}])} it)) -(def: .public type: +(def .public type: (macro (_ tokens) (case (typeP tokens) {#Some [export_policy name args type_codes]} @@ -3503,11 +3503,11 @@ #import_alias (Maybe Text) #import_referrals (List Referral)])) -(def: referral_parser +(def referral_parser (Parser Referral) (formP (andP symbolP (someP anyP)))) -(def: (referrals_parser aliased?) +(def (referrals_parser aliased?) (-> Bit (Parser (List Referral))) (all eitherP (manyP referral_parser) @@ -3517,12 +3517,12 @@ (list)))) (inP (list)))) -(def: (text#split_at' at x) +(def (text#split_at' at x) (-> Nat Text [Text Text]) [("lux text clip" 0 at x) ("lux text clip" at (|> x "lux text size" ("lux i64 -" at)) x)]) -(def: (text#split_by token sample) +(def (text#split_by token sample) (-> Text Text (Maybe [Text Text])) (do ..maybe#monad [index (..index token sample) @@ -3530,7 +3530,7 @@ [_ post] (text#split_at' ("lux text size" token) post')]] (in [pre post]))) -(def: (replaced pattern replacement template) +(def (replaced pattern replacement template) (-> Text Text Text Text) ((is (-> Text Text Text) (function (again left right) @@ -3542,11 +3542,11 @@ ("lux text concat" left right)))) "" template)) -(def: (alias_stand_in index) +(def (alias_stand_in index) (-> Nat Text) (all "lux text concat" "[" (nat#encoded index) "]")) -(def: (module_alias context aliased) +(def (module_alias context aliased) (-> (List Text) Text Text) (product#right (list#mix (function (_ replacement [index aliased]) @@ -3555,13 +3555,13 @@ [0 aliased] context))) -(def: .public module_separator +(def .public module_separator "/") -(def: parallel_hierarchy_sigil +(def parallel_hierarchy_sigil "\") -(def: (normal_parallel_path' hierarchy root) +(def (normal_parallel_path' hierarchy root) (-> Text Text Text) (case [(text#split_by ..module_separator hierarchy) (text#split_by ..parallel_hierarchy_sigil root)] @@ -3574,7 +3574,7 @@ "" hierarchy _ (all text#composite root ..module_separator hierarchy)))) -(def: (normal_parallel_path hierarchy root) +(def (normal_parallel_path hierarchy root) (-> Text Text (Maybe Text)) (case (text#split_by ..parallel_hierarchy_sigil root) {#Some ["" root']} @@ -3583,7 +3583,7 @@ _ {#None})) -(def: (relative_ups relatives input) +(def (relative_ups relatives input) (-> Nat Text Nat) (case ("lux text index" relatives ..module_separator input) {#None} @@ -3594,7 +3594,7 @@ (relative_ups ("lux i64 +" 1 relatives) input) relatives))) -(def: (list#after amount list) +(def (list#after amount list) (All (_ a) (-> Nat (List a) (List a))) (case [amount list] (pattern#or [0 _] [_ {#End}]) @@ -3603,7 +3603,7 @@ [_ {#Item _ tail}] (list#after ("lux i64 -" 1 amount) tail))) -(def: (absolute_module_name nested? relative_root module) +(def (absolute_module_name nested? relative_root module) (-> Bit Text Text (Meta Text)) (case (relative_ups 0 module) 0 @@ -3630,7 +3630,7 @@ "Importing module: " module \n " Relative Root: " relative_root \n)))))) -(def: (imports_parser nested? relative_root context imports) +(def (imports_parser nested? relative_root context imports) (-> Bit Text (List Text) (List Code) (Meta (List Importation))) (do meta#monad [imports' (monad#each meta#monad @@ -3701,7 +3701,7 @@ imports)] (in (list#conjoint imports')))) -(def: (exported_definitions module state) +(def (exported_definitions module state) (-> Text (Meta (List Text))) (let [[current_module modules] (case state [..#info info ..#source source ..#current_module current_module ..#modules modules @@ -3753,7 +3753,7 @@ code#encoded))}) )) -(def: (list#only p xs) +(def (list#only p xs) (All (_ a) (-> (-> a Bit) (List a) (List a))) (case xs @@ -3765,7 +3765,7 @@ {#Item x (list#only p xs')} (list#only p xs')))) -(def: (is_member? cases name) +(def (is_member? cases name) (-> (List Text) Text Bit) (let [output (list#mix (function (_ case prev) (or prev @@ -3774,7 +3774,7 @@ cases)] output)) -(def: (test_referrals current_module imported_module all_defs referred_defs) +(def (test_referrals current_module imported_module all_defs referred_defs) (-> Text Text (List Text) (List Text) (Meta (List Any))) (monad#each meta#monad (is (-> Text (Meta Any)) @@ -3784,11 +3784,11 @@ (failure (all text#composite _def " is not defined in module " imported_module " @ " current_module))))) referred_defs)) -(def: (alias_definition imported_module def) +(def (alias_definition imported_module def) (-> Text Text Code) (` ("lux def alias" (~ (local$ def)) (~ (symbol$ [imported_module def]))))) -(def: .public only +(def .public only (macro (_ tokens) (case (..parsed (all ..andP ..textP @@ -3805,21 +3805,21 @@ {.#None} (failure (..wrong_syntax_error (symbol ..only)))))) -(def: .public |>> +(def .public |>> (macro (_ tokens) (do meta#monad [g!_ (..generated_symbol "_") g!arg (..generated_symbol "arg")] (meta#in (list (` (function ((~ g!_) (~ g!arg)) (|> (~ g!arg) (~+ tokens))))))))) -(def: .public <<| +(def .public <<| (macro (_ tokens) (do meta#monad [g!_ (..generated_symbol "_") g!arg (..generated_symbol "arg")] (meta#in (list (` (function ((~ g!_) (~ g!arg)) (<| (~+ tokens) (~ g!arg))))))))) -(def: .public except +(def .public except (macro (_ tokens) (case (..parsed (all ..andP ..textP @@ -3838,7 +3838,7 @@ {.#None} (failure (..wrong_syntax_error (symbol ..except)))))) -(def: (in_env name state) +(def (in_env name state) (-> Text Lux (Maybe Type)) (case state [..#info info ..#source source ..#current_module _ ..#modules modules @@ -3860,7 +3860,7 @@ locals)))) scopes))) -(def: (definition_type name state) +(def (definition_type name state) (-> Symbol Lux (Maybe Type)) (let [[v_module v_name] name [..#info info ..#source source ..#current_module _ ..#modules modules @@ -3897,7 +3897,7 @@ {#Slot _} {#None}))))) -(def: (definition_value name state) +(def (definition_value name state) (-> Symbol (Meta [Type Any])) (let [[v_module v_name] name [..#info info ..#source source ..#current_module _ ..#modules modules @@ -3934,7 +3934,7 @@ {#Slot _} {#Left (text#composite "Unknown definition: " (symbol#encoded name))}))))) -(def: (type_variable idx bindings) +(def (type_variable idx bindings) (-> Nat (List [Nat (Maybe Type)]) (Maybe Type)) (case bindings {#End} @@ -3945,7 +3945,7 @@ bound (type_variable idx bindings')))) -(def: (type_definition full_name) +(def (type_definition full_name) (-> Symbol (Meta Type)) (do meta#monad [.let [[module name] full_name] @@ -3988,7 +3988,7 @@ temp)) ))) -(def: (zipped_2 xs ys) +(def (zipped_2 xs ys) (All (_ a b) (-> (List a) (List b) (List [a b]))) (case xs @@ -4003,7 +4003,7 @@ _ (list))) -(def: .public open +(def .public open (macro (_ tokens) (case tokens (pattern (partial_list [_ {#Form (list [_ {#Text alias}])}] body branches)) @@ -4060,7 +4060,7 @@ _ (failure (..wrong_syntax_error (symbol ..open)))))) -(def: .public cond +(def .public cond (macro (_ tokens) (case (list#reversed tokens) (pattern (partial_list else branches')) @@ -4079,7 +4079,7 @@ _ (failure (..wrong_syntax_error (symbol ..cond)))))) -(def: (enumeration' idx xs) +(def (enumeration' idx xs) (All (_ a) (-> Nat (List a) (List [Nat a]))) (case xs @@ -4089,12 +4089,12 @@ {#End} {#End})) -(def: (enumeration xs) +(def (enumeration xs) (All (_ a) (-> (List a) (List [Nat a]))) (enumeration' 0 xs)) -(def: .public the +(def .public the (macro (_ tokens) (case tokens (pattern (list [_ {#Symbol slot'}] record)) @@ -4136,7 +4136,7 @@ _ (failure (..wrong_syntax_error (symbol ..the)))))) -(def: (open_declaration imported_module alias tags my_tag_index [module short] source type) +(def (open_declaration imported_module alias tags my_tag_index [module short] source type) (-> Text Text (List Symbol) Nat Symbol Code Type (Meta (List Code))) (do meta#monad [output (record_slots type) @@ -4165,7 +4165,7 @@ (~ source+) #0))))))) -(def: (implementation_declarations imported_module alias implementation) +(def (implementation_declarations imported_module alias implementation) (-> Text Text Symbol (Meta (List Code))) (do meta#monad [interface (type_definition implementation) @@ -4185,7 +4185,7 @@ "Can only 'open:' structs: " (symbol#encoded implementation) " : " (type#encoded interface)))))) -(def: (localized module global) +(def (localized module global) (-> Text Symbol Symbol) (case global ["" local] @@ -4194,7 +4194,7 @@ _ global)) -(def: .public open: +(def .public open: (macro (_ tokens) (case (..parsed (all ..andP (..maybeP (all ..andP @@ -4252,14 +4252,14 @@ {.#None} (failure (..wrong_syntax_error (symbol ..open:)))))) -(def: (imported_by? import_name module_name) +(def (imported_by? import_name module_name) (-> Text Text (Meta Bit)) (do meta#monad [module (module module_name) .let [[..#module_hash _ ..#module_aliases _ ..#definitions _ ..#imports imports ..#module_state _] module]] (in (is_member? imports import_name)))) -(def: (referrals module_name extra) +(def (referrals module_name extra) (-> Text (List Code) (Meta (List Referral))) (do meta#monad [extra,referral (case (referrals_parser #0 extra) @@ -4281,7 +4281,7 @@ (list#interposed " ") (list#mix text#composite ""))))))) -(def: refer +(def refer (macro (_ tokens) (case tokens (pattern (partial_list [_ {#Text imported_module}] [_ {#Text alias}] options)) @@ -4299,7 +4299,7 @@ _ (failure (..wrong_syntax_error (symbol ..refer)))))) -(def: .public with +(def .public with (macro (_ tokens) (case (..parsed (..andP ..anyP ..anyP) tokens) @@ -4310,7 +4310,7 @@ {.#None} (failure (..wrong_syntax_error (symbol ..with)))))) -(def: .public at +(def .public at (macro (_ tokens) (case tokens (pattern (list implementation [_ {#Symbol member}])) @@ -4322,7 +4322,7 @@ _ (failure (..wrong_syntax_error (symbol ..at)))))) -(def: .public has +(def .public has (macro (_ tokens) (case tokens (pattern (list [_ {#Symbol slot'}] value record)) @@ -4406,7 +4406,7 @@ _ (failure (..wrong_syntax_error (symbol ..has)))))) -(def: .public revised +(def .public revised (macro (_ tokens) (case tokens (pattern (list [_ {#Symbol slot'}] fun record)) @@ -4476,7 +4476,7 @@ _ (failure (..wrong_syntax_error (symbol ..revised)))))) -(def: .private with_template#pattern +(def .private with_template#pattern (macro (_ tokens) (case tokens (pattern (partial_list [_ {#Form (list [_ {#Tuple bindings}] @@ -4507,7 +4507,7 @@ (failure (..wrong_syntax_error (symbol ..with_template#pattern)))))) (with_template [<name> <extension>] - [(def: .public <name> + [(def .public <name> (All (_ s) (-> (I64 s) (I64 s))) (|>> (<extension> 1)))] @@ -4516,7 +4516,7 @@ [-- "lux i64 -"] ) -(def: (interleaved xs ys) +(def (interleaved xs ys) (All (_ a) (-> (List a) (List a) (List a))) (case xs @@ -4531,7 +4531,7 @@ {#Item y ys'} (partial_list x y (interleaved xs' ys'))))) -(def: (type_code type) +(def (type_code type) (-> Type Code) (case type {#Primitive name params} @@ -4562,7 +4562,7 @@ ... (~ (type_code anonymous))}) (symbol$ [module name]))) -(def: .public loop +(def .public loop (macro (_ tokens) (let [?params (case tokens (pattern (list [_ {#Form (list name [_ {#Tuple bindings}])}] body)) @@ -4605,7 +4605,7 @@ {#None} (failure (..wrong_syntax_error (symbol ..loop))))))) -(def: (with_expansions' label tokens target) +(def (with_expansions' label tokens target) (-> Text (List Code) Code (List Code)) (case target (pattern#or [_ {#Bit _}] [_ {#Nat _}] [_ {#Int _}] [_ {#Rev _}] [_ {#Frac _}] [_ {#Text _}]) @@ -4624,7 +4624,7 @@ [#Variant] [#Tuple]))) -(def: .public with_expansions +(def .public with_expansions (macro (_ tokens) (case (parsed (andP (tupleP (someP bindingP)) (someP anyP)) tokens) {#Some [bindings bodies]} @@ -4657,7 +4657,7 @@ {#None} (failure (..wrong_syntax_error (symbol ..with_expansions)))))) -(def: (flat_alias type) +(def (flat_alias type) (-> Type Type) (case type (with_template#pattern [<name>] @@ -4676,7 +4676,7 @@ _ type)) -(def: (static_simple_literal name) +(def (static_simple_literal name) (-> Symbol (Meta Code)) (do meta#monad [type+value (definition_value name) @@ -4695,7 +4695,7 @@ _ (failure (text#composite "Cannot anti-quote type: " (symbol#encoded name)))))) -(def: (static_literal token) +(def (static_literal token) (-> Code (Meta Code)) (case token [_ {#Symbol [def_module def_name]}] @@ -4720,7 +4720,7 @@ ... (at meta#monad in token) )) -(def: .public static +(def .public static (macro (_ tokens) (case tokens (pattern (list pattern)) @@ -4734,7 +4734,7 @@ (type: Multi_Level_Case [Code (List [Code Code])]) -(def: (case_level^ level) +(def (case_level^ level) (-> Code (Meta [Code Code])) (case level (pattern [_ {#Tuple (list expr binding)}]) @@ -4744,7 +4744,7 @@ (meta#in [level (` #1)]) )) -(def: (multi_level_case^ levels) +(def (multi_level_case^ levels) (-> (List Code) (Meta Multi_Level_Case)) (case levels {#End} @@ -4755,7 +4755,7 @@ [extras' (monad#each meta#monad case_level^ extras)] (in [init extras'])))) -(def: (multi_level_case$ g!_ [[init_pattern levels] body]) +(def (multi_level_case$ g!_ [[init_pattern levels] body]) (-> Code [Multi_Level_Case Code] (List Code)) (let [inner_pattern_body (list#mix (function (_ [calculation pattern] success) (let [bind? (case pattern @@ -4775,7 +4775,7 @@ (is (List [Code Code]) (list#reversed levels)))] (list init_pattern inner_pattern_body))) -(def: pattern#multi +(def pattern#multi (macro (_ tokens) (case tokens (pattern (partial_list [_meta {#Form levels}] body next_branches)) @@ -4807,12 +4807,12 @@ _ (failure (..wrong_syntax_error (symbol ..pattern#multi)))))) -(def: .public (same? reference sample) +(def .public (same? reference sample) (All (_ a) (-> a a Bit)) ("lux is" reference sample)) -(def: .public as_expected +(def .public as_expected (macro (_ tokens) (case tokens (pattern (list expr)) @@ -4823,12 +4823,12 @@ _ (failure (..wrong_syntax_error (symbol ..as_expected)))))) -(def: location +(def location (Meta Location) (function (_ compiler) {#Right [compiler (the #location compiler)]})) -(def: .public undefined +(def .public undefined (macro (_ tokens) (case tokens {#End} @@ -4842,7 +4842,7 @@ _ (failure (..wrong_syntax_error (symbol ..undefined)))))) -(def: .public type_of +(def .public type_of (macro (_ tokens) (case tokens (pattern (list [_ {#Symbol var_name}])) @@ -4859,7 +4859,7 @@ _ (failure (..wrong_syntax_error (symbol ..type_of)))))) -(def: (templateP tokens) +(def (templateP tokens) (-> (List Code) (Maybe [Text (List Text) (List Code)])) (do maybe#monad [% (local_declarationP tokens) @@ -4869,7 +4869,7 @@ _ (endP tokens)] (in [name parameters templates]))) -(def: .public template +(def .public template (macro (_ tokens) (case (templateP tokens) {#Some [name args input_templates]} @@ -4897,7 +4897,7 @@ (failure (..wrong_syntax_error (symbol ..template)))))) (with_template [<name> <to>] - [(def: .public <name> + [(def .public <name> (template (<name> it) [(..|> it (..is (..I64 ..Any)) (..as <to>))]))] @@ -4907,11 +4907,11 @@ [rev ..Rev] ) -(def: .public these +(def .public these (macro (_ tokens compiler) {#Right [compiler tokens]})) -(def: .public char +(def .public char (macro (_ tokens compiler) (case tokens (pattern#multi (pattern (list [_ {#Text input}])) @@ -4923,12 +4923,12 @@ _ {#Left (..wrong_syntax_error (symbol ..char))}))) -(def: target +(def target (Meta Text) (function (_ compiler) {#Right [compiler (the [#info #target] compiler)]})) -(def: (platform_name choice) +(def (platform_name choice) (-> Code (Meta Text)) (case choice [_ {#Text platform}] @@ -4954,7 +4954,7 @@ "Invalid target platform syntax: " (..code#encoded choice) \n "Must be either a text literal or a symbol.")))) -(def: (target_pick target options default) +(def (target_pick target options default) (-> Text (List [Code Code]) (Maybe Code) (Meta (List Code))) (case options {#End} @@ -4972,7 +4972,7 @@ (meta#in (list pick)) (target_pick target options' default))))) -(def: .public for +(def .public for (macro (_ tokens) (case (..parsed (..andP (..someP (..andP ..anyP ..anyP)) (..maybeP ..anyP)) @@ -4986,7 +4986,7 @@ (failure (..wrong_syntax_error (symbol ..for)))))) ... TODO: Delete "scope_type_vars" (including the #scope_type_vars Lux state) and "parameter" ASAP. -(for "{old}" (these (def: (scope_type_vars state) +(for "{old}" (these (def (scope_type_vars state) (Meta (List Nat)) (case state [..#info info ..#source source ..#current_module _ ..#modules modules @@ -4995,7 +4995,7 @@ ..#scope_type_vars scope_type_vars ..#eval _eval] {#Right [state scope_type_vars]})) - (def: .public parameter + (def .public parameter (macro (_ tokens) (case tokens (pattern (list [_ {#Nat idx}])) @@ -5010,9 +5010,9 @@ _ (failure (..wrong_syntax_error (symbol ..$))))))) - (these (def: .public parameter ""))) + (these (def .public parameter ""))) -(def: (refer_code imported_module alias referrals) +(def (refer_code imported_module alias referrals) (-> Text Text (List Referral) Code) (` ((~! ..refer) (~ (text$ imported_module)) @@ -5021,7 +5021,7 @@ (` ((~ (symbol$ macro)) (~+ parameters)))) referrals))))) -(def: .public using +(def .public using (macro (_ _imports) (do meta#monad [current_module ..current_module_name @@ -5048,12 +5048,12 @@ =refers) =refers)})))) -(def: (symbol#= [moduleL shortL] [moduleR shortR]) +(def (symbol#= [moduleL shortL] [moduleR shortR]) (-> Symbol Symbol Bit) (and (text#= moduleL moduleR) (text#= shortL shortR))) -(def: (type#= left right) +(def (type#= left right) (-> Type Type Bit) (case [left right] [{#Primitive nameL parametersL} {#Primitive nameR parametersR}] @@ -5099,15 +5099,15 @@ (type: .public Immediate_UnQuote (Primitive "#Macro/Immediate_UnQuote")) -(def: .public immediate_unquote +(def .public immediate_unquote (-> Macro Immediate_UnQuote) (|>> (as Immediate_UnQuote))) -(def: immediate_unquote_macro +(def immediate_unquote_macro (-> Immediate_UnQuote Macro') (|>> (as Macro'))) -(def: .public ~~ +(def .public ~~ (..immediate_unquote (macro (_ it) (case it @@ -5117,7 +5117,7 @@ _ (failure (wrong_syntax_error (symbol ..~~))))))) -(def: aggregate_embedded_expansions +(def aggregate_embedded_expansions (template (_ embedded_expansions <@> <tag> <*>) [(do meta#monad [<*>' (monad#each meta#monad embedded_expansions <*>)] @@ -5127,7 +5127,7 @@ (list#mix list#composite (list))) [<@> {<tag> (list#each product#right <*>')}]]))])) -(def: (meta#try it) +(def (meta#try it) (All (_ a) (-> (Meta a) (Meta (Either Text a)))) (function (_ state) (case (it state) @@ -5137,7 +5137,7 @@ {#Right [state output]} {#Right [state {#Right output}]}))) -(def: (embedded_expansions code) +(def (embedded_expansions code) (-> Code (Meta [(List Code) Code])) (case code (pattern [@ {#Form (partial_list [@symbol {#Symbol original_symbol}] parameters)}]) @@ -5175,7 +5175,7 @@ _ (meta#in [(list) code]))) -(def: .public `` +(def .public `` (macro (_ tokens) (case tokens (pattern (list raw)) @@ -5188,15 +5188,15 @@ _ (failure (..wrong_syntax_error (symbol ..``)))))) -(def: .public false +(def .public false Bit #0) -(def: .public true +(def .public true Bit #1) -(def: .public try +(def .public try (macro (_ tokens) (case tokens (pattern (list expression)) @@ -5209,7 +5209,7 @@ _ (..failure (..wrong_syntax_error (symbol ..try)))))) -(def: (methodP tokens) +(def (methodP tokens) (-> (List Code) (Maybe [(List Code) [Text Code]])) (case tokens (pattern (partial_list [_ {#Form (list [_ {#Text "lux type check"}] @@ -5221,7 +5221,7 @@ _ {#None})) -(def: .public Interface +(def .public Interface (macro (_ tokens) (do meta#monad [methods' (monad#each meta#monad expansion tokens)] @@ -5233,14 +5233,14 @@ {#None} (failure (..wrong_syntax_error (symbol ..Interface))))))) -(def: (recursive_type g!self g!dummy name body) +(def (recursive_type g!self g!dummy name body) (-> Code Code Text Code Code) (` {.#Apply (..Primitive "") (.All ((~ g!self) (~ g!dummy)) (~ (let$ (local$ name) (` {.#Apply (..Primitive "") (~ g!self)}) body)))})) -(def: .public Rec +(def .public Rec (macro (_ tokens) (case tokens (pattern (list [_ {#Symbol "" name}] body)) diff --git a/stdlib/source/library/lux/abstract/apply.lux b/stdlib/source/library/lux/abstract/apply.lux index 0685484d5..35320cbd4 100644 --- a/stdlib/source/library/lux/abstract/apply.lux +++ b/stdlib/source/library/lux/abstract/apply.lux @@ -14,16 +14,16 @@ (-> (f a) (f (-> a b)) (f b))) on))) -(def: .public (composite f_monad f_apply g_apply) +(def .public (composite f_monad f_apply g_apply) (All (_ F G) (-> (Monad F) (Apply F) (Apply G) ... TODO: Replace (All (_ a) (F (G a))) with (functor.Then F G) (Apply (All (_ a) (F (G a)))))) (implementation - (def: functor + (def functor (functor.composite (the functor f_apply) (the functor g_apply))) - (def: (on fgx fgf) + (def (on fgx fgf) ... TODO: Switch from this version to the one below (in comments) ASAP. (for @.old (let [fgf' (at f_apply on fgf diff --git a/stdlib/source/library/lux/abstract/codec.lux b/stdlib/source/library/lux/abstract/codec.lux index ce6bab822..1af71150f 100644 --- a/stdlib/source/library/lux/abstract/codec.lux +++ b/stdlib/source/library/lux/abstract/codec.lux @@ -14,16 +14,16 @@ (is (-> m (Try a)) decoded))) -(def: .public (composite cb_codec ba_codec) +(def .public (composite cb_codec ba_codec) (All (_ a b c) (-> (Codec c b) (Codec b a) (Codec c a))) (implementation - (def: encoded + (def encoded (|>> (at ba_codec encoded) (at cb_codec encoded))) - (def: (decoded cy) + (def (decoded cy) (do try.monad [by (at cb_codec decoded cy)] (at ba_codec decoded by))))) diff --git a/stdlib/source/library/lux/abstract/comonad.lux b/stdlib/source/library/lux/abstract/comonad.lux index 54f8707a3..405acfbf1 100644 --- a/stdlib/source/library/lux/abstract/comonad.lux +++ b/stdlib/source/library/lux/abstract/comonad.lux @@ -23,7 +23,7 @@ (-> (w a) (w (w a)))) disjoint))) -(def: .public be +(def .public be (macro (_ tokens state) (case (is (Maybe [(Maybe Text) Code (List Code) Code]) (case tokens diff --git a/stdlib/source/library/lux/abstract/comonad/free.lux b/stdlib/source/library/lux/abstract/comonad/free.lux index 60cbb883b..2e7e7cf1c 100644 --- a/stdlib/source/library/lux/abstract/comonad/free.lux +++ b/stdlib/source/library/lux/abstract/comonad/free.lux @@ -8,20 +8,20 @@ (type: .public (Free F a) [a (F (Free F a))]) -(def: .public (functor dsl) +(def .public (functor dsl) (All (_ F) (-> (Functor F) (Functor (Free F)))) (implementation - (def: (each f [head tail]) + (def (each f [head tail]) [(f head) (at dsl each (each f) tail)]))) -(def: .public (comonad dsl) +(def .public (comonad dsl) (All (_ F) (-> (Functor F) (CoMonad (Free F)))) (implementation - (def: functor (..functor dsl)) + (def functor (..functor dsl)) - (def: (out [head tail]) + (def (out [head tail]) head) - (def: (disjoint [head tail]) + (def (disjoint [head tail]) [[head tail] (at dsl each disjoint tail)]))) diff --git a/stdlib/source/library/lux/abstract/enum.lux b/stdlib/source/library/lux/abstract/enum.lux index fbc9249ba..58e127f7d 100644 --- a/stdlib/source/library/lux/abstract/enum.lux +++ b/stdlib/source/library/lux/abstract/enum.lux @@ -10,7 +10,7 @@ (is (-> e e) succ) (is (-> e e) pred))) -(def: .public (range enum from to) +(def .public (range enum from to) (All (_ a) (-> (Enum a) a a (List a))) (let [(open "/#[0]") enum] (loop (again [end to diff --git a/stdlib/source/library/lux/abstract/equivalence.lux b/stdlib/source/library/lux/abstract/equivalence.lux index 064492b0f..fcd0f41cd 100644 --- a/stdlib/source/library/lux/abstract/equivalence.lux +++ b/stdlib/source/library/lux/abstract/equivalence.lux @@ -10,17 +10,17 @@ (is (-> a a Bit) =))) -(def: .public (rec sub) +(def .public (rec sub) (All (_ a) (-> (-> (Equivalence a) (Equivalence a)) (Equivalence a))) (implementation - (def: (= left right) + (def (= left right) (sub = left right)))) -(def: .public functor +(def .public functor (contravariant.Functor Equivalence) (implementation - (def: (each f equivalence) + (def (each f equivalence) (implementation - (def: (= reference sample) + (def (= reference sample) (at equivalence = (f reference) (f sample))))))) diff --git a/stdlib/source/library/lux/abstract/functor.lux b/stdlib/source/library/lux/abstract/functor.lux index fb80f0f1f..43bfa28d9 100644 --- a/stdlib/source/library/lux/abstract/functor.lux +++ b/stdlib/source/library/lux/abstract/functor.lux @@ -12,10 +12,10 @@ (type: .public (Or f g) (All (_ a) (.Or (f a) (g a)))) -(def: .public (sum (open "f#[0]") (open "g#[0]")) +(def .public (sum (open "f#[0]") (open "g#[0]")) (All (_ F G) (-> (Functor F) (Functor G) (Functor (..Or F G)))) (implementation - (def: (each f fa|ga) + (def (each f fa|ga) (case fa|ga {.#Left fa} {.#Left (f#each f fa)} @@ -26,18 +26,18 @@ (type: .public (And f g) (All (_ a) (.And (f a) (g a)))) -(def: .public (product (open "f#[0]") (open "g#[0]")) +(def .public (product (open "f#[0]") (open "g#[0]")) (All (_ F G) (-> (Functor F) (Functor G) (Functor (..And F G)))) (implementation - (def: (each f [fa ga]) + (def (each f [fa ga]) [(f#each f fa) (g#each f ga)]))) (type: .public (Then f g) (All (_ a) (f (g a)))) -(def: .public (composite (open "f#[0]") (open "g#[0]")) +(def .public (composite (open "f#[0]") (open "g#[0]")) (All (_ F G) (-> (Functor F) (Functor G) (Functor (..Then F G)))) (implementation - (def: (each f fga) + (def (each f fga) (f#each (g#each f) fga)))) diff --git a/stdlib/source/library/lux/abstract/hash.lux b/stdlib/source/library/lux/abstract/hash.lux index 31a8d24b7..ef5df6022 100644 --- a/stdlib/source/library/lux/abstract/hash.lux +++ b/stdlib/source/library/lux/abstract/hash.lux @@ -13,14 +13,14 @@ (is (-> a Nat) hash))) -(def: .public functor +(def .public functor (contravariant.Functor Hash) (implementation - (def: (each f super) + (def (each f super) (implementation - (def: equivalence + (def equivalence (at equivalence.functor each f (at super equivalence))) - (def: hash + (def hash (|>> f (at super hash))))))) diff --git a/stdlib/source/library/lux/abstract/interval.lux b/stdlib/source/library/lux/abstract/interval.lux index 9f4a4a6ec..0a538e925 100644 --- a/stdlib/source/library/lux/abstract/interval.lux +++ b/stdlib/source/library/lux/abstract/interval.lux @@ -18,22 +18,22 @@ (is a top))) -(def: .public (between enum bottom top) +(def .public (between enum bottom top) (All (_ a) (-> (Enum a) a a (Interval a))) (implementation - (def: enum enum) - (def: bottom bottom) - (def: top top))) + (def enum enum) + (def bottom bottom) + (def top top))) -(def: .public (singleton enum elem) +(def .public (singleton enum elem) (All (_ a) (-> (Enum a) a (Interval a))) (implementation - (def: enum enum) - (def: bottom elem) - (def: top elem))) + (def enum enum) + (def bottom elem) + (def top elem))) (with_template [<name> <comp>] - [(def: .public (<name> interval) + [(def .public (<name> interval) (All (_ a) (-> (Interval a) Bit)) (let [(open ",#[0]") interval] (<comp> ,#bottom ,#top)))] @@ -43,7 +43,7 @@ [singleton? ,#=] ) -(def: .public (within? interval elem) +(def .public (within? interval elem) (All (_ a) (-> (Interval a) a Bit)) (let [(open ",#[0]") interval] (cond (inner? interval) @@ -59,7 +59,7 @@ (,#= ,#top elem))))) (with_template [<name> <limit>] - [(def: .public (<name> elem interval) + [(def .public (<name> elem interval) (All (_ a) (-> a (Interval a) Bit)) (let [(open "[0]") interval] (= <limit> elem)))] @@ -68,45 +68,45 @@ [ends_with? top] ) -(def: .public (borders? interval elem) +(def .public (borders? interval elem) (All (_ a) (-> (Interval a) a Bit)) (or (starts_with? elem interval) (ends_with? elem interval))) -(def: .public (union left right) +(def .public (union left right) (All (_ a) (-> (Interval a) (Interval a) (Interval a))) (implementation - (def: enum (the enum right)) - (def: bottom (order.min (at right order) (at left bottom) (at right bottom))) - (def: top (order.max (at right order) (at left top) (at right top))))) + (def enum (the enum right)) + (def bottom (order.min (at right order) (at left bottom) (at right bottom))) + (def top (order.max (at right order) (at left top) (at right top))))) -(def: .public (intersection left right) +(def .public (intersection left right) (All (_ a) (-> (Interval a) (Interval a) (Interval a))) (implementation - (def: enum (the enum right)) - (def: bottom (order.max (at right order) (at left bottom) (at right bottom))) - (def: top (order.min (at right order) (at left top) (at right top))))) + (def enum (the enum right)) + (def bottom (order.max (at right order) (at left bottom) (at right bottom))) + (def top (order.min (at right order) (at left top) (at right top))))) -(def: .public (complement interval) +(def .public (complement interval) (All (_ a) (-> (Interval a) (Interval a))) (implementation - (def: enum (the enum interval)) - (def: bottom (at interval succ (at interval top))) - (def: top (at interval pred (at interval bottom))))) + (def enum (the enum interval)) + (def bottom (at interval succ (at interval top))) + (def top (at interval pred (at interval bottom))))) -(def: .public (precedes? reference sample) +(def .public (precedes? reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (let [(open "[0]") reference limit (at reference bottom)] (and (< limit (at sample bottom)) (< limit (at sample top))))) -(def: .public (succeeds? reference sample) +(def .public (succeeds? reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (precedes? sample reference)) (with_template [<name> <comp>] - [(def: .public (<name> reference sample) + [(def .public (<name> reference sample) (All (_ a) (-> a (Interval a) Bit)) (let [(open ",#[0]") sample] (and (<comp> reference ,#bottom) @@ -116,20 +116,20 @@ [after? (order.> ,#order)] ) -(def: .public (meets? reference sample) +(def .public (meets? reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (let [(open ",#[0]") reference limit (at reference bottom)] (and (,#= limit (at sample top)) (order.<= ,#order limit (at sample bottom))))) -(def: .public (touches? reference sample) +(def .public (touches? reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (or (meets? reference sample) (meets? sample reference))) (with_template [<name> <eq_side> <ineq> <ineq_side>] - [(def: .public (<name> reference sample) + [(def .public (<name> reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (let [(open ",#[0]") reference] (and (,#= (at reference <eq_side>) @@ -142,15 +142,15 @@ [finishes? ,#top order.>= ,#bottom] ) -(def: .public equivalence +(def .public equivalence (All (_ a) (Equivalence (Interval a))) (implementation - (def: (= reference sample) + (def (= reference sample) (let [(open ",#[0]") reference] (and (,#= ,#bottom (at sample bottom)) (,#= ,#top (at sample top))))))) -(def: .public (nested? reference sample) +(def .public (nested? reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (cond (or (singleton? sample) (and (inner? reference) (inner? sample)) @@ -171,7 +171,7 @@ (order.<= ,#order (at reference top) (at sample top))))) )) -(def: .public (overlaps? reference sample) +(def .public (overlaps? reference sample) (All (_ a) (-> (Interval a) (Interval a) Bit)) (let [(open ",#[0]") reference] (and (not (at ..equivalence = reference sample)) diff --git a/stdlib/source/library/lux/abstract/mix.lux b/stdlib/source/library/lux/abstract/mix.lux index 3dc3ecc71..ea317146b 100644 --- a/stdlib/source/library/lux/abstract/mix.lux +++ b/stdlib/source/library/lux/abstract/mix.lux @@ -10,7 +10,7 @@ (-> (-> b a a) a (F b) a)) mix))) -(def: .public (with_monoid monoid mix value) +(def .public (with_monoid monoid mix value) (All (_ F a) (-> (Monoid a) (Mix F) (F a) a)) (let [(open "/#[0]") monoid] diff --git a/stdlib/source/library/lux/abstract/monad.lux b/stdlib/source/library/lux/abstract/monad.lux index 18c22027d..ecd4e1ac4 100644 --- a/stdlib/source/library/lux/abstract/monad.lux +++ b/stdlib/source/library/lux/abstract/monad.lux @@ -6,7 +6,7 @@ [// [functor (.only Functor)]]) -(def: (list#mix f init xs) +(def (list#mix f init xs) (All (_ a b) (-> (-> b a a) a (List b) a)) (case xs @@ -16,7 +16,7 @@ {.#Item x xs'} (list#mix f (f x init) xs'))) -(def: (list#size xs) +(def (list#size xs) (All (_ a) (-> (List a) Nat)) (loop (again [counter 0 xs xs]) @@ -27,14 +27,14 @@ {.#Item _ xs'} (again (++ counter) xs')))) -(def: (reversed xs) +(def (reversed xs) (All (_ a) (-> (List a) (List a))) (list#mix (function (_ head tail) {.#Item head tail}) {.#End} xs)) -(def: (pairs xs) +(def (pairs xs) (All (_ a) (-> (List a) (List [a a]))) (case xs {.#Item x1 {.#Item x2 xs'}} @@ -54,7 +54,7 @@ (-> (m (m a)) (m a))) conjoint))) -(def: .public do +(def .public do (macro (_ tokens state) (case (is (Maybe [(Maybe Text) Code (List Code) Code]) (case tokens @@ -107,14 +107,14 @@ {.#None} {.#Left "Wrong syntax for 'do'"}))) -(def: .public (then monad f) +(def .public (then monad f) (All (_ ! a b) (-> (Monad !) (-> a (! b)) (-> (! a) (! b)))) (|>> (at monad each f) (at monad conjoint))) -(def: .public (all monad) +(def .public (all monad) (All (_ ! a) (-> (Monad !) (List (! a)) (! (List a)))) @@ -130,7 +130,7 @@ (!#each (|>> {.#Item _x}) (again xs')))) !#conjoint))))) -(def: .public (each monad f) +(def .public (each monad f) (All (_ M a b) (-> (Monad M) (-> a (M b)) (List a) (M (List b)))) @@ -146,7 +146,7 @@ (!#each (|>> {.#Item _x}) (again xs')))) !#conjoint))))) -(def: .public (only monad f) +(def .public (only monad f) (All (_ ! a b) (-> (Monad !) (-> a (! Bit)) (List a) (! (List a)))) @@ -166,7 +166,7 @@ (again xs')))) !#conjoint))))) -(def: .public (mix monad f init xs) +(def .public (mix monad f init xs) (All (_ M a b) (-> (Monad M) (-> b a (M a)) a (List b) (M a))) diff --git a/stdlib/source/library/lux/abstract/monad/free.lux b/stdlib/source/library/lux/abstract/monad/free.lux index af3436ab4..f4e440054 100644 --- a/stdlib/source/library/lux/abstract/monad/free.lux +++ b/stdlib/source/library/lux/abstract/monad/free.lux @@ -11,10 +11,10 @@ {#Pure a} {#Effect (F (Free F a))})) -(def: .public (functor dsl) +(def .public (functor dsl) (All (_ F) (-> (Functor F) (Functor (Free F)))) (implementation - (def: (each f ea) + (def (each f ea) (case ea {#Pure a} {#Pure (f a)} @@ -22,13 +22,13 @@ {#Effect value} {#Effect (at dsl each (each f) value)})))) -(def: .public (apply dsl) +(def .public (apply dsl) (All (_ F) (-> (Functor F) (Apply (Free F)))) (implementation - (def: functor + (def functor (..functor dsl)) - (def: (on ea ef) + (def (on ea ef) (case [ef ea] [{#Pure f} {#Pure a}] {#Pure (f a)} @@ -42,15 +42,15 @@ {#Effect (at dsl each (on ea) ff)} )))) -(def: .public (monad dsl) +(def .public (monad dsl) (All (_ F) (-> (Functor F) (Monad (Free F)))) (implementation - (def: functor (..functor dsl)) + (def functor (..functor dsl)) - (def: (in a) + (def (in a) {#Pure a}) - (def: (conjoint efefa) + (def (conjoint efefa) (case efefa {#Pure efa} (case efa diff --git a/stdlib/source/library/lux/abstract/monad/indexed.lux b/stdlib/source/library/lux/abstract/monad/indexed.lux index f1d774637..30d3b403f 100644 --- a/stdlib/source/library/lux/abstract/monad/indexed.lux +++ b/stdlib/source/library/lux/abstract/monad/indexed.lux @@ -27,7 +27,7 @@ (type: Binding [Code Code]) -(def: binding +(def binding (Parser Binding) (<>.and <code>.any <code>.any)) @@ -36,24 +36,24 @@ {#Macro Symbol Code} {#Binding Binding})) -(def: global +(def global (Parser Symbol) (//.do <>.monad [[module short] <code>.symbol _ (<>.assertion "" (case module "" false _ true))] (in [module short]))) -(def: context +(def context (Parser Context) (<>.or (<>.and ..global <code>.any) binding)) -(def: (pair_list [binding value]) +(def (pair_list [binding value]) (All (_ a) (-> [a a] (List a))) (list binding value)) -(def: named_monad +(def named_monad (Parser [(Maybe Text) Code]) (<>.either (<code>.tuple (<>.and (at <>.monad each (|>> {.#Some}) <code>.local) @@ -61,7 +61,7 @@ (at <>.monad each (|>> [{.#None}]) <code>.any))) -(def: .public do +(def .public do (syntax (_ [[?name monad] ..named_monad context (<code>.tuple (<>.some context)) expression <code>.any]) diff --git a/stdlib/source/library/lux/abstract/monoid.lux b/stdlib/source/library/lux/abstract/monoid.lux index a93d844a8..f5afe510a 100644 --- a/stdlib/source/library/lux/abstract/monoid.lux +++ b/stdlib/source/library/lux/abstract/monoid.lux @@ -9,13 +9,13 @@ (is (-> a a a) composite))) -(def: .public (and left right) +(def .public (and left right) (All (_ l r) (-> (Monoid l) (Monoid r) (Monoid [l r]))) (implementation - (def: identity + (def identity [(at left identity) (at right identity)]) - (def: (composite [lL rL] [lR rR]) + (def (composite [lL rL] [lR rR]) [(at left composite lL lR) (at right composite rL rR)]))) diff --git a/stdlib/source/library/lux/abstract/order.lux b/stdlib/source/library/lux/abstract/order.lux index e8dfbc834..71e546ed4 100644 --- a/stdlib/source/library/lux/abstract/order.lux +++ b/stdlib/source/library/lux/abstract/order.lux @@ -19,16 +19,16 @@ (type: .public (Comparison a) (-> (Order a) a a Bit)) -(def: .public (<= order parameter subject) +(def .public (<= order parameter subject) Comparison (or (at order < parameter subject) (at order = parameter subject))) -(def: .public (> order parameter subject) +(def .public (> order parameter subject) Comparison (at order < subject parameter)) -(def: .public (>= order parameter subject) +(def .public (>= order parameter subject) Comparison (or (at order < subject parameter) (at order = subject parameter))) @@ -36,21 +36,21 @@ (type: .public (Choice a) (-> (Order a) a a a)) -(def: .public (min order x y) +(def .public (min order x y) Choice (if (at order < y x) x y)) -(def: .public (max order x y) +(def .public (max order x y) Choice (if (at order < y x) y x)) -(def: .public functor +(def .public functor (contravariant.Functor Order) (implementation - (def: (each f order) + (def (each f order) (implementation - (def: equivalence + (def equivalence (at equivalence.functor each f (at order equivalence))) - (def: (< reference sample) + (def (< reference sample) (at order < (f reference) (f sample))))))) diff --git a/stdlib/source/library/lux/abstract/predicate.lux b/stdlib/source/library/lux/abstract/predicate.lux index 61a2bb41c..8becf51cd 100644 --- a/stdlib/source/library/lux/abstract/predicate.lux +++ b/stdlib/source/library/lux/abstract/predicate.lux @@ -12,11 +12,11 @@ (-> a Bit)) (with_template [<identity_name> <identity_value> <composition_name> <composition>] - [(def: .public <identity_name> + [(def .public <identity_name> Predicate (function.constant <identity_value>)) - (def: .public (<composition_name> left right) + (def .public (<composition_name> left right) (All (_ a) (-> (Predicate a) (Predicate a) (Predicate a))) (function (_ value) (<composition> (left value) @@ -27,35 +27,35 @@ ) (with_template [<name> <identity> <composition>] - [(def: .public <name> + [(def .public <name> (All (_ a) (Monoid (Predicate a))) (implementation - (def: identity <identity>) - (def: composite <composition>)))] + (def identity <identity>) + (def composite <composition>)))] [union ..none ..or] [intersection ..all ..and] ) -(def: .public (complement predicate) +(def .public (complement predicate) (All (_ a) (-> (Predicate a) (Predicate a))) (|>> predicate not)) -(def: .public (difference sub base) +(def .public (difference sub base) (All (_ a) (-> (Predicate a) (Predicate a) (Predicate a))) (function (_ value) (.and (base value) (not (sub value))))) -(def: .public (rec predicate) +(def .public (rec predicate) (All (_ a) (-> (-> (Predicate a) (Predicate a)) (Predicate a))) (function (again input) (predicate again input))) -(def: .public functor +(def .public functor (contravariant.Functor Predicate) (implementation - (def: (each f fb) + (def (each f fb) (|>> f fb)))) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index 4661a546e..2fe9f788f 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -32,29 +32,29 @@ [#bottom (Maybe Code) #top (List Code)])) -(def: top +(def top (Parser (List Code)) (<code>.tuple (<>.some <code>.any))) -(def: bottom +(def bottom (Parser Code) (<code>.not ..top)) -(def: stack +(def stack (Parser Stack) (<>.either (<>.and (<>.maybe bottom) ..top) (<>.and (<>#each (|>> {.#Some}) bottom) (<>#in (list))))) -(def: (stack_type tops bottom) +(def (stack_type tops bottom) (-> (List Code) Code Code) (list#mix (function (_ top bottom) (` [(~ bottom) (~ top)])) bottom tops)) -(def: .public => +(def .public => (syntax (_ [inputs stack outputs stack]) (with_symbols [g!_ common_bottom] @@ -70,14 +70,14 @@ (` (-> (~ input_stack) (~ output_stack)))))))))) -(def: .public (value it) +(def .public (value it) (All (_ ,,, a) (-> (=> [] ,,, [a]) a)) (|> [] it product.right)) -(def: .public apply +(def .public apply (syntax (_ [arity (<>.only (n.> 0) <code>.nat)]) (with_symbols [g!_ g!func g!stack g!output] (monad.do [! meta.monad] @@ -90,65 +90,65 @@ [(~ g!stack) ((~ g!func) (~+ g!inputs))])))))))))) (with_template [<arity>] - [(`` (def: .public (~~ (template.symbol ["apply_" <arity>])) + [(`` (def .public (~~ (template.symbol ["apply_" <arity>])) (..apply <arity>)))] [1] [2] [3] [4] [5] [6] [7] [8] ) -(def: .public (push x) +(def .public (push x) (All (_ a) (-> a (=> [] [a]))) (function (_ stack) [stack x])) -(def: .public drop +(def .public drop (All (_ t) (=> [t] [])) (function (_ [stack top]) stack)) -(def: .public nip +(def .public nip (All (_ _ a) (=> [_ a] [a])) (function (_ [[stack _] top]) [stack top])) -(def: .public dup +(def .public dup (All (_ a) (=> [a] [a a])) (function (_ [stack top]) [[stack top] top])) -(def: .public swap +(def .public swap (All (_ a b) (=> [a b] [b a])) (function (_ [[stack l] r]) [[stack r] l])) -(def: .public left_rotation +(def .public left_rotation (All (_ a b c) (=> [a b c] [b c a])) (function (_ [[[stack a] b] c]) [[[stack b] c] a])) -(def: .public right_rotation +(def .public right_rotation (All (_ a b c) (=> [a b c] [c a b])) (function (_ [[[stack a] b] c]) [[[stack c] a] b])) -(def: .public && +(def .public && (All (_ a b) (=> [a b] [(Tuple a b)])) (function (_ [[stack l] r]) [stack [l r]])) -(def: .public left +(def .public left (All (_ a b) (=> [a] [(Or a b)])) (function (_ [stack l]) [stack {0 #0 l}])) -(def: .public right +(def .public right (All (_ a b) (=> [b] [(Or a b)])) (function (_ [stack r]) [stack {0 #1 r}])) (with_template [<input> <output> <word> <func>] - [(`` (def: .public <word> + [(`` (def .public <word> (=> [<input> <input>] [<output>]) (function (_ [[stack subject] param]) [stack (<func> param subject)])))] @@ -198,7 +198,7 @@ [Frac Bit f/>= f.>=] ) -(def: .public if +(def .public if (All (_ ,,,0 ,,,1) (type.let [then (=> ,,,0 ,,,1) else (=> ,,,0 ,,,1)] @@ -209,7 +209,7 @@ (then stack) (else stack)))) -(def: .public call +(def .public call (All (_ ,,,0 ,,,1) (type.let [quote (=> ,,,0 ,,,1)] (=> ,,,0 [quote] @@ -217,7 +217,7 @@ (function (_ [stack quote]) (quote stack))) -(def: .public loop +(def .public loop (All (_ ,,,) (type.let [test (=> ,,, ,,, [Bit])] @@ -229,21 +229,21 @@ (loop [stack' pred]) stack')))) -(def: .public dip +(def .public dip (All (_ ,,, a) (=> ,,, [a (=> ,,, ,,,)] ,,, [a])) (function (_ [[stack a] quote]) [(quote stack) a])) -(def: .public dip_2 +(def .public dip_2 (All (_ ,,, a b) (=> ,,, [a b (=> ,,, ,,,)] ,,, [a b])) (function (_ [[[stack a] b] quote]) [[(quote stack) a] b])) -(def: .public do +(def .public do (All (_ ,,,0 ,,,1) (type.let [body (=> ,,,0 ,,,1) pred (=> ,,,1 ,,,0 [Bit])] @@ -252,7 +252,7 @@ (function (_ [[stack pred] body]) [[(body stack) pred] body])) -(def: .public while +(def .public while (All (_ ,,,0 ,,,1) (type.let [body (=> ,,,1 ,,,0) pred (=> ,,,0 ,,,1 [Bit])] @@ -264,21 +264,21 @@ (while [[(body stack') pred] body]) stack')))) -(def: .public compose +(def .public compose (All (_ ,,,0 ,,, ,,,1) (=> [(=> ,,,0 ,,,) (=> ,,, ,,,1)] [(=> ,,,0 ,,,1)])) (function (_ [[stack f] g]) [stack (|>> f g)])) -(def: .public partial +(def .public partial (All (_ ,,,0 ,,,1 a) (=> ,,,0 [a (=> ,,,0 [a] ,,,1)] ,,,0 [(=> ,,,0 ,,,1)])) (function (_ [[stack arg] quote]) [stack (|>> (push arg) quote)])) -(def: .public when +(def .public when (All (_ ,,,) (type.let [body (=> ,,, ,,,)] (=> ,,, [Bit body] @@ -288,7 +288,7 @@ (push ..drop) if)) -(def: .public ? +(def .public ? (All (_ a) (=> [Bit a a] [a])) (|>> left_rotation diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index 40bc65ec2..e67bb3f2b 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -31,7 +31,7 @@ [(Rec Mailbox [(Async [(<Mail> Actor s) Mailbox]) (Resolver [(<Mail> Actor s) Mailbox])])])] - (these (def: (pending [read write]) + (these (def (pending [read write]) (All (_ a) (-> (Rec Mailbox [(Async [a Mailbox]) @@ -62,7 +62,7 @@ (type: .public (Behavior s) (-> (Mail s) s (Actor s) (Async (Try s)))) - (def: .public (spawn! behavior init) + (def .public (spawn! behavior init) (All (_ s) (-> (Behavior s) s (IO (Actor s)))) (io (let [self (sharing [s] (is (Behavior s) @@ -88,7 +88,7 @@ (again state' tail))))] self))) - (def: .public (alive? actor) + (def .public (alive? actor) (All (_ s) (-> (Actor s) (IO Bit))) (let [[obituary _] (the #obituary (representation actor))] (|> obituary @@ -101,18 +101,18 @@ _ bit.no)))))) - (def: .public (obituary' actor) + (def .public (obituary' actor) (All (_ s) (-> (Actor s) (IO (Maybe (Obituary s))))) (let [[obituary _] (the #obituary (representation actor))] (async.value obituary))) - (def: .public obituary + (def .public obituary (All (_ s) (-> (Actor s) (Async (Obituary s)))) (|>> representation (the #obituary) product.left)) - (def: .public (mail! mail actor) + (def .public (mail! mail actor) (All (_ s) (-> (Mail s) (Actor s) (IO (Try Any)))) (do [! io.monad] [alive? (..alive? actor)] @@ -140,7 +140,7 @@ (type: .public (Message s o) (-> s (Actor s) (Async (Try [s o])))) - (def: (mail message) + (def (mail message) (All (_ s o) (-> (Message s o) [(Async (Try o)) (Mail s)])) (let [[async resolve] (sharing [s o] (is (Message s o) @@ -163,7 +163,7 @@ (io.run! (resolve {try.#Failure error})) (async.resolved {try.#Failure error})))))])) - (def: .public (tell! message actor) + (def .public (tell! message actor) (All (_ s o) (-> (Message s o) (Actor s) (Async (Try o)))) (let [[async mail] (..mail message)] (do async.monad @@ -176,12 +176,12 @@ (in {try.#Failure error}))))) ))) -(def: .public default +(def .public default Behavior (function (_ mail state self) (mail state self))) -(def: .public (poison! actor) +(def .public (poison! actor) (All (_ s) (-> (Actor s) (IO (Try Any)))) (..mail! (function (_ state self) (async.resolved (exception.except ..poisoned []))) @@ -190,10 +190,10 @@ (type: .public Stop (IO Any)) -(def: continue! true) -(def: stop! false) +(def continue! true) +(def stop! false) -(def: .public (observe! action channel actor) +(def .public (observe! action channel actor) (All (_ r w s) (-> (-> r Stop (Mail s)) (Channel' r w) (Actor s) (IO Any))) (let [signal (is (Atom Bit) (atom.atom ..continue!)) diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux index 192c4e24c..11020adad 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -34,7 +34,7 @@ (-> w (IO Bit))) ... Sets an async's value if it has not been done yet. - (def: (resolver async) + (def (resolver async) (All (_ r w) (-> (Async' r w) (Resolver w))) (function (resolve value) (let [async (representation async)] @@ -54,23 +54,23 @@ (in #1)) (resolve value)))))))) - (def: .public (resolved value) + (def .public (resolved value) (All (_ a) (-> a (Async a))) (abstraction (atom [{.#Some (variance.write value)} (list)]))) - (def: .public (async _) + (def .public (async _) (All (_ r w) (-> Any [(Async' r w) (Resolver w)])) (let [async (abstraction (atom [{.#None} (list)]))] [async (..resolver async)])) - (def: .public value + (def .public value (All (_ r w) (-> (Async' r w) (IO (Maybe r)))) (|>> representation atom.read! (at io.functor each (|>> product.left (maybe#each (|>> variance.read)))))) - (def: .public (upon! f async) + (def .public (upon! f async) (All (_ r w) (-> (-> r (IO Any)) (Async' r w) (IO Any))) (do [! io.monad] [.let [async (representation async)] @@ -87,7 +87,7 @@ (upon! f (abstraction async))))))) ) -(def: .public resolved? +(def .public resolved? (All (_ r w) (-> (Async' r w) (IO Bit))) (|>> ..value (at io.functor each @@ -98,10 +98,10 @@ {.#Some _} #1))))) -(def: .public functor +(def .public functor (Functor Async) (implementation - (def: (each f fa) + (def (each f fa) (let [[fb resolve] (sharing [a b] (is (-> a b) f) @@ -111,12 +111,12 @@ (io.run! (..upon! (|>> f resolve) fa)) fb))))) -(def: .public apply +(def .public apply (Apply Async) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (let [[fb resolve] (sharing [a b] (is (Async (-> a b)) ff) @@ -128,14 +128,14 @@ ff)) fb))))) -(def: .public monad +(def .public monad (Monad Async) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: in ..resolved) + (def in ..resolved) - (def: (conjoint mma) + (def (conjoint mma) (let [[ma resolve] (sharing [a] (is (Async (Async a)) mma) @@ -145,7 +145,7 @@ (io.run! (..upon! (..upon! resolve) mma)) ma))))) -(def: .public (and left right) +(def .public (and left right) (All (_ lr lw rr rw) (-> (Async' lr lw) (Async' rr rw) (Async [lr rr]))) (let [[read! write!] (sharing [lr lw rr rw] (is [(Async' lr lw) (Async' rr rw)] @@ -159,7 +159,7 @@ left))] read!)) -(def: .public (or left right) +(def .public (or left right) (All (_ lr lw rr rw) (-> (Async' lr lw) (Async' rr rw) (Async (Or lr rr)))) (let [[left|right resolve] (sharing [lr lw rr rw] (is [(Async' lr lw) (Async' rr rw)] @@ -177,7 +177,7 @@ <sides> left|right)))) -(def: .public (either left right) +(def .public (either left right) (All (_ a lw rw) (-> (Async' a lw) (Async' a rw) (Async a))) (let [[left||right resolve] (sharing [a lw rw] (is [(Async' a lw) (Async' a rw)] @@ -192,7 +192,7 @@ [right])) left||right)))) -(def: .public (schedule! milli_seconds computation) +(def .public (schedule! milli_seconds computation) (All (_ a) (-> Nat (IO a) (Async a))) (let [[!out resolve] (sharing [a] (is (IO a) @@ -207,19 +207,19 @@ io.run!) !out))) -(def: .public future +(def .public future (All (_ a) (-> (IO a) (Async a))) (..schedule! 0)) -(def: .public (after milli_seconds value) +(def .public (after milli_seconds value) (All (_ a) (-> Nat a (Async a))) (..schedule! milli_seconds (io value))) -(def: .public (delay milli_seconds) +(def .public (delay milli_seconds) (-> Nat (Async Any)) (..after milli_seconds [])) -(def: .public (within milli_seconds async) +(def .public (within milli_seconds async) (All (_ r w) (-> Nat (Async' r w) (Async (Maybe r)))) (..or (..delay milli_seconds) async)) diff --git a/stdlib/source/library/lux/control/concurrency/atom.lux b/stdlib/source/library/lux/control/concurrency/atom.lux index 86399e1a6..e98479e10 100644 --- a/stdlib/source/library/lux/control/concurrency/atom.lux +++ b/stdlib/source/library/lux/control/concurrency/atom.lux @@ -38,7 +38,7 @@ (type: .public (Atom a) (Atom'' (Mutable a a))) - (def: .public (atom value) + (def .public (atom value) (All (_ a) (-> a (Atom a))) (abstraction (with_expansions [<jvm> (as_expected (java/util/concurrent/atomic/AtomicReference::new value))] @@ -46,14 +46,14 @@ @.jvm <jvm> (array.has! 0 (variance.write value) (array.empty 1)))))) - (def: .public (read! atom) + (def .public (read! atom) (All (_ r w) (-> (Atom' r w) (IO r))) (with_expansions [<jvm> (java/util/concurrent/atomic/AtomicReference::get (representation atom))] (io.io (for @.old (variance.read <jvm>) @.jvm <jvm> (variance.read (array.item 0 (representation atom))))))) - (def: .public (compare_and_swap! current new atom) + (def .public (compare_and_swap! current new atom) (All (_ r w) (-> r w (Atom' r w) (IO Bit))) (io.io (for @.old (ffi.of_boolean (java/util/concurrent/atomic/AtomicReference::compareAndSet (variance.write @@ -73,7 +73,7 @@ false)))) ) -(def: .public (update! f atom) +(def .public (update! f atom) (All (_ r w) (-> (-> r w) (Atom' r w) (IO [r w]))) (loop (again [_ []]) (do io.monad @@ -84,7 +84,7 @@ (in [old new]) (again []))))) -(def: .public (write! value atom) +(def .public (write! value atom) (All (_ r w) (-> w (Atom' r w) (IO r))) (|> atom (..update! (function.constant value)) diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux index 43aae713f..16ef2927c 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -35,13 +35,13 @@ (is (-> w (IO (Try Any))) feed))) -(def: (sink resolution) +(def (sink resolution) (All (_ a) (-> (async.Resolver (Maybe [(Mutable a a) (Channel a)])) (Sink a))) (let [sink (atom.atom resolution)] (implementation - (def: close + (def close (loop (again [_ []]) (do [! io.monad] [current (atom.read! sink) @@ -58,7 +58,7 @@ ... Someone else fed the sink while I was closing it. (again []))))))) - (def: (feed value) + (def (feed value) (loop (again [_ []]) (do [! io.monad] [current (atom.read! sink) @@ -83,27 +83,27 @@ ... Someone else fed the sink. (again [])))))))))) -(def: .public (channel _) +(def .public (channel _) (All (_ a) (-> Any [(Channel a) (Sink a)])) (let [[async resolve] (async.async [])] [async (..sink resolve)])) -(def: .public functor +(def .public functor (Functor Channel) (implementation - (def: (each f) + (def (each f) (async#each (maybe#each (function (_ [head tail]) [(variance.write (f (variance.read head))) (each f tail)])))))) -(def: .public apply +(def .public apply (Apply Channel) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (do async.monad [item_f ff item_a fa] @@ -115,19 +115,19 @@ _ (in {.#None})))))) -(def: empty +(def empty Channel (async.resolved {.#None})) -(def: .public monad +(def .public monad (Monad Channel) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) (async.resolved {.#Some [(variance.write a) ..empty]})) - (def: (conjoint mma) + (def (conjoint mma) (let [[output sink] (sharing [a] (is (Channel (Channel a)) mma) @@ -161,7 +161,7 @@ (type: .public (Subscriber a) (-> a (IO (Maybe Any)))) -(def: .public (subscribe! subscriber channel) +(def .public (subscribe! subscriber channel) (All (_ r w) (-> (Subscriber r) (Channel' r w) (IO Any))) (io (exec (is (Async Any) @@ -181,7 +181,7 @@ (in []))))) []))) -(def: .public (only pass? channel) +(def .public (only pass? channel) (All (_ a) (-> (-> a Bit) (Channel a) (Channel a))) (do async.monad [item channel] @@ -195,13 +195,13 @@ {.#None} (in {.#None})))) -(def: .public (of_async async) +(def .public (of_async async) (All (_ a) (-> (Async a) (Channel a))) (async#each (function (_ value) {.#Some [(variance.write value) ..empty]}) async)) -(def: .public (mix f init channel) +(def .public (mix f init channel) (All (_ a b) (-> (-> b a (Async a)) a (Channel b) (Async a))) @@ -216,7 +216,7 @@ [init' (f (variance.read head) init)] (mix f init' tail))))) -(def: .public (mixes f init channel) +(def .public (mixes f init channel) (All (_ a b) (-> (-> b a (Async a)) a (Channel b) (Channel a))) @@ -234,7 +234,7 @@ [init' (f (variance.read head) init)] (mixes f init' tail)))))) -(def: .public (poll milli_seconds action) +(def .public (poll milli_seconds action) (All (_ a) (-> Nat (IO a) [(Channel a) (Sink a)])) (let [[output sink] (channel [])] @@ -246,11 +246,11 @@ (async.upon! again (async.delay milli_seconds))))) [output sink]))) -(def: .public (periodic milli_seconds) +(def .public (periodic milli_seconds) (-> Nat [(Channel Any) (Sink Any)]) (..poll milli_seconds (io []))) -(def: .public (iterations f init) +(def .public (iterations f init) (All (_ s o) (-> (-> s (Async (Maybe [s o]))) s (Channel o))) (do async.monad [?next (f init)] @@ -261,7 +261,7 @@ {.#None} {.#None})))) -(def: (distinct' equivalence previous channel) +(def (distinct' equivalence previous channel) (All (_ a) (-> (Equivalence a) a (Channel a) (Channel a))) (do async.monad [item channel] @@ -274,7 +274,7 @@ {.#None} (in {.#None})))) -(def: .public (distinct equivalence channel) +(def .public (distinct equivalence channel) (All (_ a) (-> (Equivalence a) (Channel a) (Channel a))) (do async.monad [item channel] @@ -285,7 +285,7 @@ {.#None} {.#None})))) -(def: .public (list channel) +(def .public (list channel) (All (_ a) (-> (Channel a) (Async (List a)))) (do [! async.monad] [item channel] @@ -297,7 +297,7 @@ {.#None} (in {.#End})))) -(def: .public (sequential milli_seconds values) +(def .public (sequential milli_seconds values) (All (_ a) (-> Nat (List a) (Channel a))) (case values {.#End} diff --git a/stdlib/source/library/lux/control/concurrency/semaphore.lux b/stdlib/source/library/lux/control/concurrency/semaphore.lux index 5cf050d4b..fbfacf228 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -33,10 +33,10 @@ (primitive .public Semaphore (Atom State) - (def: most_positions_possible + (def most_positions_possible (.nat (at i.interval top))) - (def: .public (semaphore initial_open_positions) + (def .public (semaphore initial_open_positions) (-> Nat Semaphore) (let [max_positions (n.min initial_open_positions ..most_positions_possible)] @@ -44,7 +44,7 @@ #open_positions (.int max_positions) #waiting_list queue.empty])))) - (def: .public (wait! semaphore) + (def .public (wait! semaphore) (Ex (_ k) (-> Semaphore (Async Any))) (let [semaphore (representation semaphore) [signal sink] (is [(Async Any) (Resolver Any)] @@ -69,7 +69,7 @@ (exception.report "Max Positions" (%.nat max_positions))) - (def: .public (signal! semaphore) + (def .public (signal! semaphore) (Ex (_ k) (-> Semaphore (Async (Try Int)))) (let [semaphore (representation semaphore)] (async.future @@ -97,19 +97,19 @@ (primitive .public Mutex Semaphore - (def: .public (mutex _) + (def .public (mutex _) (-> Any Mutex) (abstraction (semaphore 1))) - (def: acquire! + (def acquire! (-> Mutex (Async Any)) (|>> representation ..wait!)) - (def: release! + (def release! (-> Mutex (Async (Try Int))) (|>> representation ..signal!)) - (def: .public (synchronize! mutex procedure) + (def .public (synchronize! mutex procedure) (All (_ a) (-> Mutex (IO (Async a)) (Async a))) (do async.monad [_ (..acquire! mutex) @@ -118,7 +118,7 @@ (in output))) ) -(def: .public limit +(def .public limit (refinement.refiner (n.> 0))) (type: .public Limit @@ -131,14 +131,14 @@ #start_turnstile Semaphore #end_turnstile Semaphore]) - (def: .public (barrier limit) + (def .public (barrier limit) (-> Limit Barrier) (abstraction [#limit limit #count (atom.atom 0) #start_turnstile (..semaphore 0) #end_turnstile (..semaphore 0)])) - (def: (un_block! times turnstile) + (def (un_block! times turnstile) (-> Nat Semaphore (Async Any)) (loop (again [step 0]) (if (n.< times step) @@ -148,7 +148,7 @@ (at async.monad in [])))) (with_template [<phase> <update> <goal> <turnstile>] - [(def: (<phase> barrier) + [(def (<phase> barrier) (-> Barrier (Async Any)) (do async.monad [.let [barrier (representation barrier) @@ -164,7 +164,7 @@ [end! -- 0 #end_turnstile] ) - (def: .public (block! barrier) + (def .public (block! barrier) (-> Barrier (Async Any)) (do async.monad [_ (..start! barrier)] diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux index 2a0ae3956..87dd101c9 100644 --- a/stdlib/source/library/lux/control/concurrency/stm.lux +++ b/stdlib/source/library/lux/control/concurrency/stm.lux @@ -35,15 +35,15 @@ (type: .public (Var a) (Var'' (Mutable a a))) - (def: .public (var value) + (def .public (var value) (All (_ a) (-> a (Var a))) (abstraction (atom.atom [(variance.write value) (list)]))) - (def: read! + (def read! (All (_ r w) (-> (Var' r w) r)) (|>> representation atom.read! io.run! product.left variance.read)) - (def: (write! new_value var) + (def (write! new_value var) (All (_ r w) (-> w (Var' r w) (IO Any))) (do [! io.monad] [.let [var' (representation var)] @@ -70,7 +70,7 @@ (in [])) (write! new_value var)))) - (def: .public (changes target) + (def .public (changes target) (All (_ a) (-> (Var a) (IO [(Channel a) (Sink a)]))) (do io.monad [.let [[channel sink] (sharing [a] @@ -80,8 +80,8 @@ (frp.channel [])))] _ (atom.update! (function (_ [value observers]) [value {.#Item (implementation - (def: close (at sink close)) - (def: feed (|>> variance.read (at sink feed)))) + (def close (at sink close)) + (def feed (|>> variance.read (at sink feed)))) observers}]) (representation target))] (in [channel sink]))) @@ -99,7 +99,7 @@ (type: .public (STM a) (-> Tx [Tx a])) -(def: (var_value var tx) +(def (var_value var tx) (All (_ r w) (-> (Var' r w) Tx (Maybe r))) (|> tx (list.example (function (_ [_var _original _current]) @@ -109,7 +109,7 @@ _current)) as_expected)) -(def: .public (read var) +(def .public (read var) (All (_ r w) (-> (Var' r w) (STM r))) (function (_ tx) (case (var_value var tx) @@ -124,7 +124,7 @@ tx} value])))) -(def: (with_updated_var var value tx) +(def (with_updated_var var value tx) (All (_ r w) (-> (Var' r w) w Tx Tx)) (case tx {.#End} @@ -142,7 +142,7 @@ #current _current] (with_updated_var var value tx')}))) -(def: .public (write value var) +(def .public (write value var) (All (_ r w) (-> w (Var' r w) (STM Any))) (function (_ tx) (case (var_value var tx) @@ -157,40 +157,40 @@ tx} []]))) -(def: .public functor +(def .public functor (Functor STM) (implementation - (def: (each f fa) + (def (each f fa) (function (_ tx) (let [[tx' a] (fa tx)] [tx' (f a)]))))) -(def: .public apply +(def .public apply (Apply STM) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ tx) (let [[tx' f] (ff tx) [tx'' a] (fa tx')] [tx'' (f a)]))))) -(def: .public monad +(def .public monad (Monad STM) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) (function (_ tx) [tx a])) - (def: (conjoint mma) + (def (conjoint mma) (function (_ tx) (let [[tx' ma] (mma tx)] (ma tx')))))) -(def: .public (update f var) +(def .public (update f var) (All (_ r w) (-> (-> r w) (Var' r w) (STM [r w]))) (do ..monad [before (..read var) @@ -198,36 +198,36 @@ _ (..write after var)] (in [before after]))) -(def: (can_commit? tx) +(def (can_commit? tx) (-> Tx Bit) (list.every? (function (_ [_var _original _current]) (same? _original (..read! _var))) tx)) -(def: (commit_var! [_var _original _current]) +(def (commit_var! [_var _original _current]) (-> (Ex (_ r w) (Tx_Frame r w)) (IO Any)) (if (same? (as Any _original) (as Any _current)) (io []) (..write! _current _var))) -(def: fresh_tx Tx (list)) +(def fresh_tx Tx (list)) (type: (Commit a) [(STM a) (Async a) (Resolver a)]) -(def: pending_commits +(def pending_commits (Atom (Rec Commits [(Async [(Ex (_ a) (Commit a)) Commits]) (Resolver [(Ex (_ a) (Commit a)) Commits])])) (atom (async.async []))) -(def: commit_processor_flag +(def commit_processor_flag (Atom Bit) (atom #0)) -(def: (issue_commit! commit) +(def (issue_commit! commit) (All (_ a) (-> (Commit a) (IO Any))) (let [entry [commit (async.async [])]] (do [! io.monad] @@ -246,7 +246,7 @@ {.#Some [head tail]} (again tail))))))) -(def: (process_commit! commit) +(def (process_commit! commit) (All (_ a) (-> (Commit a) (IO Any))) (let [[stm_proc output resolve] commit [finished_tx value] (stm_proc fresh_tx)] @@ -256,7 +256,7 @@ (resolve value)) (..issue_commit! commit)))) -(def: start_commit_processor! +(def start_commit_processor! (IO Any) (do [! io.monad] [flag (atom.read! commit_processor_flag)] @@ -275,7 +275,7 @@ (in []))) ))) -(def: .public (commit! stm_proc) +(def .public (commit! stm_proc) (All (_ a) (-> (STM a) (Async a))) (let [[output resolver] (async.async [])] (exec diff --git a/stdlib/source/library/lux/control/concurrency/thread.lux b/stdlib/source/library/lux/control/concurrency/thread.lux index 4428f9daa..030e0c053 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -73,7 +73,7 @@ #action (IO Any)])) )) -(def: .public parallelism +(def .public parallelism Nat (with_expansions [<default> 1 <jvm> (<| (configuration.for ["lua_compiler?" ""] @@ -88,7 +88,7 @@ ... Default <default>))) -(with_expansions [<jvm> (these (def: runner +(with_expansions [<jvm> (these (def runner java/util/concurrent/ScheduledThreadPoolExecutor (|> ..parallelism .int @@ -100,14 +100,14 @@ @.python (these) ... Default - (these (def: started? + (these (def started? (Atom Bit) (atom.atom false)) - (def: runner + (def runner (Atom (List Thread)) (atom.atom (list)))))) -(def: (execute! action) +(def (execute! action) (-> (IO Any) Any) (case (try (io.run! action)) {try.#Failure error} @@ -120,7 +120,7 @@ {try.#Success _} [])) -(def: .public (schedule! milli_seconds action) +(def .public (schedule! milli_seconds action) (-> Nat (IO Any) (IO Any)) (with_expansions [<jvm> (let [runnable (ffi.object [] [java/lang/Runnable] [] @@ -163,7 +163,7 @@ ... https://en.wikipedia.org/wiki/Event_loop ... Starts the event-loop. - (def: .public run! + (def .public run! (IO Any) (do [! io.monad] [started? (atom.read! ..started?)] diff --git a/stdlib/source/library/lux/control/continuation.lux b/stdlib/source/library/lux/control/continuation.lux index 3cbd80b92..5c3ac3e9c 100644 --- a/stdlib/source/library/lux/control/continuation.lux +++ b/stdlib/source/library/lux/control/continuation.lux @@ -16,15 +16,15 @@ (type: .public (Cont i o) (-> (-> i o) o)) -(def: .public (continued next cont) +(def .public (continued next cont) (All (_ i o) (-> (-> i o) (Cont i o) o)) (cont next)) -(def: .public result +(def .public result (All (_ a) (-> (Cont a a) a)) (..continued function.identity)) -(def: .public (with_current f) +(def .public (with_current f) (All (_ a b z) (-> (-> (-> a (Cont b z)) (Cont a z)) @@ -33,17 +33,17 @@ (f (function (_ a) (function (_ _) (k a))) k))) -(def: .public pending +(def .public pending (syntax (_ [expr <code>.any]) (with_symbols [g!_ g!k] (in (list (` (.function ((~ g!_) (~ g!k)) ((~ g!k) (~ expr))))))))) -(def: .public (reset scope) +(def .public (reset scope) (All (_ i o) (-> (Cont i i) (Cont i o))) (function (_ k) (k (result scope)))) -(def: .public (shift f) +(def .public (shift f) (All (_ a) (-> (-> (-> a (Cont a a)) (Cont a a)) @@ -52,37 +52,37 @@ (f (function (_ a) (function (_ ic) (ic (oc a)))) function.identity))) -(def: .public functor +(def .public functor (All (_ o) (Functor (All (_ i) (Cont i o)))) (implementation - (def: (each f fv) + (def (each f fv) (function (_ k) (fv (function.composite k f)))))) -(def: .public apply +(def .public apply (All (_ o) (Apply (All (_ i) (Cont i o)))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fv ff) + (def (on fv ff) (function (_ k) (|> (k (f v)) (function (_ v)) fv (function (_ f)) ff))))) -(def: .public monad +(def .public monad (All (_ o) (Monad (All (_ i) (Cont i o)))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in value) + (def (in value) (function (_ k) (k value))) - (def: (conjoint ffa) + (def (conjoint ffa) (function (_ k) (ffa (continued k)))))) -(def: .public (portal init) +(def .public (portal init) (All (_ i o z) (-> i (Cont [(-> i (Cont o z)) diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index 81e46e66d..f80419c98 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -31,11 +31,11 @@ [#label Text #constructor (-> a Text)])) -(def: .public (match? exception error) +(def .public (match? exception error) (All (_ e) (-> (Exception e) Text Bit)) (text.starts_with? (the #label exception) error)) -(def: .public (when exception then try) +(def .public (when exception then try) (All (_ e a) (-> (Exception e) (-> Text a) (Try a) (Try a))) @@ -52,7 +52,7 @@ then)} {//.#Failure error})))) -(def: .public (otherwise else try) +(def .public (otherwise else try) (All (_ a) (-> (-> Text a) (Try a) a)) (case try @@ -62,21 +62,21 @@ {//.#Failure error} (else error))) -(def: .public (error exception message) +(def .public (error exception message) (All (_ e) (-> (Exception e) e Text)) ((the ..#constructor exception) message)) -(def: .public (except exception message) +(def .public (except exception message) (All (_ e a) (-> (Exception e) e (Try a))) {//.#Failure (..error exception message)}) -(def: .public (assertion exception message test) +(def .public (assertion exception message test) (All (_ e) (-> (Exception e) e Bit (Try Any))) (if test {//.#Success []} (..except exception message))) -(def: exception +(def exception (Parser [Code (List |type_variable|.Variable) [Text (List |input|.Input)] (Maybe Code)]) (let [private (is (Parser [(List |type_variable|.Variable) [Text (List |input|.Input)] (Maybe Code)]) (all <>.and @@ -90,14 +90,14 @@ (<>.and (<>#in (` .private)) private) ))) -(def: .public exception: +(def .public exception: (syntax (_ [[export_policy t_vars [name inputs] body] ..exception]) (macro.with_symbols [g!_ g!descriptor] (do meta.monad [current_module meta.current_module_name .let [descriptor (all text#composite "{" current_module "." name "}" text.new_line) g!self (code.local name)]] - (in (list (` (def: (~ export_policy) + (in (list (` (def (~ export_policy) (~ g!self) (All ((~ g!_) (~+ (list#each |type_variable|.format t_vars))) (..Exception [(~+ (list#each (the |input|.#type) inputs))])) @@ -107,7 +107,7 @@ ((~! text#composite) (~ g!descriptor) (~ (maybe.else (' "") body))))]))))))))) -(def: (report' entries) +(def (report' entries) (-> (List [Text Text]) Text) (let [header_separator ": " largest_header_size (list#mix (function (_ [header _] max) @@ -138,13 +138,13 @@ (on_entry head) tail)))) -(def: .public report +(def .public report (syntax (_ [entries (<>.many (<>.and <code>.any <code>.any))]) (in (list (` ((~! ..report') (list (~+ (|> entries (list#each (function (_ [header message]) (` [(~ header) (~ message)])))))))))))) -(def: .public (listing format entries) +(def .public (listing format entries) (All (_ a) (-> (-> a Text) (List a) Text)) (|> entries @@ -157,7 +157,7 @@ list.reversed ..report')) -(def: separator +(def separator (let [gap (all "lux text concat" text.new_line text.new_line) horizontal_line (|> "-" (list.repeated 64) text.together)] (all "lux text concat" @@ -165,14 +165,14 @@ horizontal_line gap))) -(def: (decorated prelude error) +(def (decorated prelude error) (-> Text Text Text) (all "lux text concat" prelude ..separator error)) -(def: .public (with exception message computation) +(def .public (with exception message computation) (All (_ e a) (-> (Exception e) e (Try a) (Try a))) (case computation {//.#Failure error} diff --git a/stdlib/source/library/lux/control/function.lux b/stdlib/source/library/lux/control/function.lux index 15cd56f93..bbf4969b3 100644 --- a/stdlib/source/library/lux/control/function.lux +++ b/stdlib/source/library/lux/control/function.lux @@ -4,31 +4,31 @@ [abstract [monoid (.only Monoid)]]]]) -(def: .public identity +(def .public identity (All (_ a) (-> a a)) (|>>)) -(def: .public (composite f g) +(def .public (composite f g) (All (_ a b c) (-> (-> b c) (-> a b) (-> a c))) (|>> g f)) -(def: .public (constant value) +(def .public (constant value) (All (_ o) (-> o (All (_ i) (-> i o)))) (function (_ _) value)) -(def: .public (flipped f) +(def .public (flipped f) (All (_ a b c) (-> (-> a b c) (-> b a c))) (function (_ x y) (f y x))) -(def: .public (on input function) +(def .public (on input function) (All (_ i o) (-> i (-> i o) o)) (function input)) -(def: .public monoid +(def .public monoid (All (_ a) (Monoid (-> a a))) (implementation - (def: identity ..identity) - (def: composite ..composite))) + (def identity ..identity) + (def composite ..composite))) diff --git a/stdlib/source/library/lux/control/function/contract.lux b/stdlib/source/library/lux/control/function/contract.lux index 753a90460..4bae3020d 100644 --- a/stdlib/source/library/lux/control/function/contract.lux +++ b/stdlib/source/library/lux/control/function/contract.lux @@ -24,13 +24,13 @@ [post_condition_failed] ) -(def: (assert! message test) +(def (assert! message test) (-> Text Bit []) (if test [] (panic! message))) -(def: .public pre +(def .public pre (syntax (_ [test <code>.any expr <code>.any]) (in (list (` (exec @@ -38,7 +38,7 @@ (~ test)) (~ expr))))))) -(def: .public post +(def .public post (syntax (_ [test <code>.any expr <code>.any]) (with_symbols [g!output] diff --git a/stdlib/source/library/lux/control/function/inline.lux b/stdlib/source/library/lux/control/function/inline.lux index e171f1f87..9481dd27c 100644 --- a/stdlib/source/library/lux/control/function/inline.lux +++ b/stdlib/source/library/lux/control/function/inline.lux @@ -15,11 +15,11 @@ [syntax (.only syntax) ["|[0]|" export]]]]]) -(def: declaration +(def declaration (Parser [Text (List Code)]) (<code>.form (<>.and <code>.local (<>.some <code>.any)))) -(def: inline +(def inline (Parser [Code [Text (List Code)] Code Code]) (|export|.parser (all <>.and @@ -28,7 +28,7 @@ <code>.any ))) -(def: .public inline: +(def .public inlined (syntax (_ [[privacy [name parameters] type term] ..inline]) (do [! meta.monad] [@ meta.current_module_name @@ -47,6 +47,6 @@ (list#each (function (_ parameter) (list parameter (` (~! <code>.any))))) list#conjoint)]] - (in (list (` (def: (~ privacy) (~ (code.local name)) + (in (list (` (def (~ privacy) (~ (code.local name)) ((~! syntax) ((~ (code.local name)) [(~+ g!parameters)]) (.at (~! meta.monad) (~' in) (.list (.`' (~ inlined)))))))))))) diff --git a/stdlib/source/library/lux/control/function/memo.lux b/stdlib/source/library/lux/control/function/memo.lux index 47ed679d5..60c464887 100644 --- a/stdlib/source/library/lux/control/function/memo.lux +++ b/stdlib/source/library/lux/control/function/memo.lux @@ -17,7 +17,7 @@ ["[0]" // ["[1]" mixin (.only Mixin Recursive)]]) -(def: .public memoization +(def .public memoization (All (_ i o) (Mixin i (State (Dictionary i o) o))) (function (_ delegate recur) @@ -37,7 +37,7 @@ (type: .public (Memo i o) (Recursive i (State (Dictionary i o) o))) -(def: .public (open memo) +(def .public (open memo) (All (_ i o) (type.let [Memory (Dictionary i o)] (-> (Memo i o) (-> [Memory i] [Memory o])))) @@ -45,14 +45,14 @@ (function (_ [memory input]) (|> input memo (state.result memory))))) -(def: .public (closed hash memo) +(def .public (closed hash memo) (All (_ i o) (-> (Hash i) (Memo i o) (-> i o))) (let [memo (//.fixed (//.mixed ..memoization (//.of_recursive memo))) empty (dictionary.empty hash)] (|>> memo (state.result empty) product.right))) -(def: .public (none hash memo) +(def .public (none hash memo) (All (_ i o) (-> (Hash i) (Memo i o) (-> i o))) (let [memo (//.fixed (//.of_recursive memo)) diff --git a/stdlib/source/library/lux/control/function/mixin.lux b/stdlib/source/library/lux/control/function/mixin.lux index d23e86e04..44796c733 100644 --- a/stdlib/source/library/lux/control/function/mixin.lux +++ b/stdlib/source/library/lux/control/function/mixin.lux @@ -12,42 +12,42 @@ (type: .public (Mixin i o) (-> (-> i o) (-> i o) (-> i o))) -(def: .public (fixed f) +(def .public (fixed f) (All (_ i o) (-> (Mixin i o) (-> i o))) (function (mix input) ((f mix mix) input))) -(def: .public nothing +(def .public nothing Mixin (function (_ delegate recur) delegate)) -(def: .public (mixed parent child) +(def .public (mixed parent child) (All (_ i o) (-> (Mixin i o) (Mixin i o) (Mixin i o))) (function (_ delegate recur) (parent (child delegate recur) recur))) -(def: .public monoid +(def .public monoid (All (_ i o) (Monoid (Mixin i o))) (implementation - (def: identity ..nothing) - (def: composite ..mixed))) + (def identity ..nothing) + (def composite ..mixed))) -(def: .public (advice when then) +(def .public (advice when then) (All (_ i o) (-> (Predicate i) (Mixin i o) (Mixin i o))) (function (_ delegate recur input) (if (when input) ((then delegate recur) input) (delegate input)))) -(def: .public (before monad action) +(def .public (before monad action) (All (_ ! i o) (-> (Monad !) (-> i (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) (do monad [_ (action input)] (delegate input)))) -(def: .public (after monad action) +(def .public (after monad action) (All (_ ! i o) (-> (Monad !) (-> i o (! Any)) (Mixin i (! o)))) (function (_ delegate recur input) (do monad @@ -58,7 +58,7 @@ (type: .public (Recursive i o) (-> (-> i o) (-> i o))) -(def: .public (of_recursive recursive) +(def .public (of_recursive recursive) (All (_ i o) (-> (Recursive i o) (Mixin i o))) (function (_ delegate recur) (recursive recur))) diff --git a/stdlib/source/library/lux/control/function/mutual.lux b/stdlib/source/library/lux/control/function/mutual.lux index bdf3fbde9..d0b03aa08 100644 --- a/stdlib/source/library/lux/control/function/mutual.lux +++ b/stdlib/source/library/lux/control/function/mutual.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except Definition let def: macro) + [lux (.except Definition let def macro) ["[0]" meta] [abstract ["[0]" monad (.only do)]] @@ -30,7 +30,7 @@ #type Code #body Code])) -(.def: mutual +(.def mutual (Parser [Declaration Code Code]) (all <>.and declaration.parser @@ -38,21 +38,21 @@ <code>.any )) -(.def: (mutual_definition context g!context [g!name mutual]) +(.def (mutual_definition context g!context [g!name mutual]) (-> (List Code) Code [Code Mutual] Code) (` (function ((~ g!name) (~ g!context)) (.let [[(~+ context)] (~ g!context)] (function (~ (declaration.format (the #declaration mutual))) (~ (the #body mutual))))))) -(.def: (macro g!context g!self) +(.def (macro g!context g!self) (-> Code Code Macro) (<| (as Macro) (is Macro') (function (_ parameters) (at meta.monad in (list (` (((~ g!self) (~ g!context)) (~+ parameters)))))))) -(.def: .public let +(.def .public let (syntax (_ [functions (<code>.tuple (<>.some ..mutual)) body <code>.any]) (case functions @@ -101,12 +101,12 @@ [#export_policy Code #mutual Mutual])) -(.def: definition +(.def definition (Parser Definition) (<code>.tuple (<>.either (<>.and <code>.any ..mutual) (<>.and (<>#in (` .private)) ..mutual)))) -(.def: .public def: +(.def .public def (syntax (_ [functions (<>.many ..definition)]) (case functions {.#End} @@ -115,7 +115,7 @@ {.#Item definition {.#End}} (.let [(open "_[0]") definition (open "_[0]") _#mutual] - (in (list (` (.def: (~ _#export_policy) (~ (declaration.format _#declaration)) + (in (list (` (.def (~ _#export_policy) (~ (declaration.format _#declaration)) (~ _#type) (~ _#body)))))) @@ -138,7 +138,7 @@ (..macro g!context g!name)]) (list.zipped_2 hidden_names functions)))] - (in (list.partial (` (.def: (~ g!context) + (in (list.partial (` (.def (~ g!context) [(~+ (list#each (the [#mutual #type]) functions))] (.let [(~ g!context) (is (Rec (~ g!context) [(~+ context_types)]) @@ -150,7 +150,7 @@ g!pop (list#each (function (_ mutual) (.let [g!name (|> mutual (the [#mutual #declaration declaration.#name]) code.local)] - (` (.def: + (` (.def (~ (the #export_policy mutual)) (~ g!name) (~ (the [#mutual #type] mutual)) diff --git a/stdlib/source/library/lux/control/io.lux b/stdlib/source/library/lux/control/io.lux index 0b2372c6b..fecb0ee7b 100644 --- a/stdlib/source/library/lux/control/io.lux +++ b/stdlib/source/library/lux/control/io.lux @@ -17,54 +17,54 @@ (primitive .public (IO a) (-> Any a) - (def: label + (def label (All (_ a) (-> (-> Any a) (IO a))) (|>> abstraction)) - (def: !io + (def !io (template (!io computation) [(abstraction (template.with_locals [g!func g!arg] (function (g!func g!arg) computation)))])) - (def: run!' + (def run!' (template (run!' io) ... creatio ex nihilo [((representation io) [])])) - (def: .public io + (def .public io (syntax (_ [computation <code>.any]) (with_symbols [g!func g!arg] (in (list (` ((~! ..label) (function ((~ g!func) (~ g!arg)) (~ computation))))))))) - (def: .public run! + (def .public run! (All (_ a) (-> (IO a) a)) (|>> ..run!')) - (def: .public functor + (def .public functor (Functor IO) (implementation - (def: (each f) + (def (each f) (|>> ..run!' f !io)))) - (def: .public apply + (def .public apply (Apply IO) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (!io ((..run!' ff) (..run!' fa)))))) - (def: .public monad + (def .public monad (Monad IO) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: in + (def in (|>> !io)) - (def: conjoint + (def conjoint (|>> ..run!' ..run!' !io)))) ) diff --git a/stdlib/source/library/lux/control/lazy.lux b/stdlib/source/library/lux/control/lazy.lux index 343f866f7..50f18e0dd 100644 --- a/stdlib/source/library/lux/control/lazy.lux +++ b/stdlib/source/library/lux/control/lazy.lux @@ -20,7 +20,7 @@ (primitive .public (Lazy a) (-> [] a) - (def: (lazy' generator) + (def (lazy' generator) (All (_ a) (-> (-> [] a) (Lazy a))) (let [cache (atom.atom (sharing [a] (is (-> [] a) @@ -38,38 +38,38 @@ (io.run! (atom.compare_and_swap! _ {.#Some value} cache)) value))))))) - (def: .public (value lazy) + (def .public (value lazy) (All (_ a) (-> (Lazy a) a)) ((representation lazy) []))) -(def: .public lazy +(def .public lazy (syntax (_ [expression <code>.any]) (with_symbols [g!_] (in (list (` ((~! ..lazy') (function ((~ g!_) (~ g!_)) (~ expression))))))))) -(def: .public (equivalence (open "_#[0]")) +(def .public (equivalence (open "_#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Lazy a)))) (implementation - (def: (= left right) + (def (= left right) (_#= (..value left) (..value right))))) -(def: .public functor +(def .public functor (Functor Lazy) (implementation - (def: (each f fa) + (def (each f fa) (lazy (f (value fa)))))) -(def: .public apply +(def .public apply (Apply Lazy) (implementation - (def: functor ..functor) - (def: (on fa ff) + (def functor ..functor) + (def (on fa ff) (lazy ((value ff) (value fa)))))) -(def: .public monad +(def .public monad (Monad Lazy) (implementation - (def: functor ..functor) - (def: in (|>> lazy)) - (def: conjoint ..value))) + (def functor ..functor) + (def in (|>> lazy)) + (def conjoint ..value))) diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index 00cef670e..b138ab65c 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -15,13 +15,13 @@ ... {.#None} ... {.#Some a}) -(def: .public monoid +(def .public monoid (All (_ a) (Monoid (Maybe a))) (implementation - (def: identity + (def identity {.#None}) - (def: (composite mx my) + (def (composite mx my) (case mx {.#None} my @@ -29,10 +29,10 @@ _ mx)))) -(def: .public functor +(def .public functor (Functor Maybe) (implementation - (def: (each f ma) + (def (each f ma) (case ma {.#Some a} {.#Some (f a)} @@ -41,12 +41,12 @@ it (as_expected it))))) -(def: .public apply +(def .public apply (Apply Maybe) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (case [ff fa] [{.#Some f} {.#Some a}] {.#Some (f a)} @@ -54,15 +54,15 @@ _ {.#None})))) -(def: .public monad +(def .public monad (Monad Maybe) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in x) + (def (in x) {.#Some x}) - (def: (conjoint mma) + (def (conjoint mma) (case mma {.#Some mx} mx @@ -71,10 +71,10 @@ it (as_expected it))))) -(def: .public (equivalence super) +(def .public (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (Maybe a)))) (implementation - (def: (= mx my) + (def (= mx my) (case [mx my] [{.#None} {.#None}] #1 @@ -85,13 +85,13 @@ _ #0)))) -(def: .public (hash super) +(def .public (hash super) (All (_ a) (-> (Hash a) (Hash (Maybe a)))) (implementation - (def: equivalence + (def equivalence (..equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value {.#None} 1 @@ -99,18 +99,18 @@ {.#Some value} (at super hash value))))) -(def: .public (with monad) +(def .public (with monad) (All (_ M) (-> (Monad M) (Monad (All (_ a) (M (Maybe a)))))) (implementation - (def: functor + (def functor (functor.composite (the monad.functor monad) ..functor)) - (def: in + (def in (|>> (at ..monad in) (at monad in))) - (def: (conjoint MmMma) + (def (conjoint MmMma) (do monad [mMma MmMma] (case mMma @@ -121,11 +121,11 @@ it (in (as_expected it))))))) -(def: .public (lifted monad) +(def .public (lifted monad) (All (_ M a) (-> (Monad M) (-> (M a) (M (Maybe a))))) (at monad each (at ..monad in))) -(def: .public else +(def .public else (macro (_ tokens state) (case tokens (pattern (.list else maybe)) @@ -141,11 +141,11 @@ _ {.#Left "Wrong syntax for 'else'"}))) -(def: .public trusted +(def .public trusted (All (_ a) (-> (Maybe a) a)) (|>> (..else (undefined)))) -(def: .public (list value) +(def .public (list value) (All (_ a) (-> (Maybe a) (List a))) (case value {.#Some value} @@ -155,7 +155,7 @@ _ (.list))) -(def: .public when +(def .public when (macro (_ tokens state) (case tokens (pattern (.list test then)) diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index fef41832d..1c402df83 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -19,10 +19,10 @@ (type: .public (Parser s a) (-> s (Try [s a]))) -(def: .public functor +(def .public functor (All (_ s) (Functor (Parser s))) (implementation - (def: (each f ma) + (def (each f ma) (function (_ input) (case (ma input) {try.#Success [input' a]} @@ -31,12 +31,12 @@ {try.#Failure msg} {try.#Failure msg}))))) -(def: .public apply +(def .public apply (All (_ s) (Apply (Parser s))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ input) (case (ff input) {try.#Success [input' f]} @@ -50,16 +50,16 @@ {try.#Failure msg} {try.#Failure msg}))))) -(def: .public monad +(def .public monad (All (_ s) (Monad (Parser s))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in x) + (def (in x) (function (_ input) {try.#Success [input x]})) - (def: (conjoint mma) + (def (conjoint mma) (function (_ input) (case (mma input) {try.#Success [input' ma]} @@ -68,14 +68,14 @@ {try.#Failure msg} {try.#Failure msg}))))) -(def: .public (assertion message test) +(def .public (assertion message test) (All (_ s) (-> Text Bit (Parser s Any))) (function (_ input) (if test {try.#Success [input []]} {try.#Failure message}))) -(def: .public (maybe parser) +(def .public (maybe parser) (All (_ s a) (-> (Parser s a) (Parser s (Maybe a)))) (function (_ input) @@ -86,19 +86,19 @@ {try.#Failure _} {try.#Success [input {.#None}]}))) -(def: .public (result parser input) +(def .public (result parser input) (All (_ s a) (-> (Parser s a) s (Try [s a]))) (parser input)) -(def: .public (and first second) +(def .public (and first second) (All (_ s a b) (-> (Parser s a) (Parser s b) (Parser s [a b]))) (do [! ..monad] [head first] (at ! each (|>> [head]) second))) -(def: .public (or left right) +(def .public (or left right) (All (_ s a b) (-> (Parser s a) (Parser s b) (Parser s (Or a b)))) (function (_ tokens) @@ -114,7 +114,7 @@ {try.#Failure error} {try.#Failure error})))) -(def: .public (either this that) +(def .public (either this that) (All (_ s a) (-> (Parser s a) (Parser s a) (Parser s a))) (function (_ tokens) @@ -125,7 +125,7 @@ output output))) -(def: .public (some parser) +(def .public (some parser) (All (_ s a) (-> (Parser s a) (Parser s (List a)))) (function (_ input) @@ -138,14 +138,14 @@ {try.#Failure _} {try.#Success [input (list)]}))) -(def: .public (many parser) +(def .public (many parser) (All (_ s a) (-> (Parser s a) (Parser s (List a)))) (|> (..some parser) (..and parser) (at ..monad each (|>> {.#Item})))) -(def: .public (exactly amount parser) +(def .public (exactly amount parser) (All (_ s a) (-> Nat (Parser s a) (Parser s (List a)))) (case amount 0 (at ..monad in (list)) @@ -155,13 +155,13 @@ (exactly (-- amount)) (at ! each (|>> {.#Item x})))))) -(def: .public (at_least amount parser) +(def .public (at_least amount parser) (All (_ s a) (-> Nat (Parser s a) (Parser s (List a)))) (do [! ..monad] [minimum (..exactly amount parser)] (at ! each (list#composite minimum) (..some parser)))) -(def: .public (at_most amount parser) +(def .public (at_most amount parser) (All (_ s a) (-> Nat (Parser s a) (Parser s (List a)))) (case amount 0 (at ..monad in (list)) @@ -175,7 +175,7 @@ {try.#Failure msg} {try.#Success [input (list)]})))) -(def: .public (between minimum additional parser) +(def .public (between minimum additional parser) (All (_ s a) (-> Nat Nat (Parser s a) (Parser s (List a)))) (do [! ..monad] [minimum (..exactly minimum parser)] @@ -184,7 +184,7 @@ _ (at ! each (list#composite minimum) (..at_most additional parser))))) -(def: .public (separated_by separator parser) +(def .public (separated_by separator parser) (All (_ s a b) (-> (Parser s b) (Parser s a) (Parser s (List a)))) (do [! ..monad] [?x (..maybe parser)] @@ -198,7 +198,7 @@ {.#None} (in {.#End})))) -(def: .public (not parser) +(def .public (not parser) (All (_ s a) (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) @@ -208,12 +208,12 @@ _ {try.#Failure "Expected to fail; yet succeeded."}))) -(def: .public (failure message) +(def .public (failure message) (All (_ s a) (-> Text (Parser s a))) (function (_ input) {try.#Failure message})) -(def: .public (lifted operation) +(def .public (lifted operation) (All (_ s a) (-> (Try a) (Parser s a))) (function (_ input) (case operation @@ -223,7 +223,7 @@ {try.#Failure error} {try.#Failure error}))) -(def: .public (else value parser) +(def .public (else value parser) (All (_ s a) (-> a (Parser s a) (Parser s a))) (function (_ input) (case (parser input) @@ -233,37 +233,37 @@ {try.#Failure error} {try.#Success [input value]}))) -(def: .public remaining +(def .public remaining (All (_ s) (Parser s s)) (function (_ inputs) {try.#Success [inputs inputs]})) -(def: .public (rec parser) +(def .public (rec parser) (All (_ s a) (-> (-> (Parser s a) (Parser s a)) (Parser s a))) (function (_ inputs) (..result (parser (rec parser)) inputs))) -(def: .public (after param subject) +(def .public (after param subject) (All (_ s _ a) (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad [_ param] subject)) -(def: .public (before param subject) +(def .public (before param subject) (All (_ s _ a) (-> (Parser s _) (Parser s a) (Parser s a))) (do ..monad [output subject _ param] (in output))) -(def: .public (only test parser) +(def .public (only test parser) (All (_ s a) (-> (-> a Bit) (Parser s a) (Parser s a))) (do ..monad [output parser _ (..assertion "Constraint failed." (test output))] (in output))) -(def: .public (parses? parser) +(def .public (parses? parser) (All (_ s a) (-> (Parser s a) (Parser s Bit))) (function (_ input) (case (parser input) @@ -273,7 +273,7 @@ {try.#Failure error} {try.#Success [input false]}))) -(def: .public (parses parser) +(def .public (parses parser) (All (_ s a) (-> (Parser s a) (Parser s Any))) (function (_ input) (case (parser input) @@ -283,7 +283,7 @@ {try.#Failure error} {try.#Failure error}))) -(def: .public (speculative parser) +(def .public (speculative parser) (All (_ s a) (-> (Parser s a) (Parser s a))) (function (_ input) (case (parser input) @@ -293,7 +293,7 @@ failure failure))) -(def: .public (codec codec parser) +(def .public (codec codec parser) (All (_ s a z) (-> (Codec a z) (Parser s a) (Parser s z))) (function (_ input) (case (parser input) diff --git a/stdlib/source/library/lux/control/parser/cli.lux b/stdlib/source/library/lux/control/parser/cli.lux index 89ea21893..b00698644 100644 --- a/stdlib/source/library/lux/control/parser/cli.lux +++ b/stdlib/source/library/lux/control/parser/cli.lux @@ -13,7 +13,7 @@ (type: .public (Parser a) (//.Parser (List Text) a)) -(def: .public (result parser inputs) +(def .public (result parser inputs) (All (_ a) (-> (Parser a) (List Text) (Try a))) (case (//.result parser inputs) {try.#Success [remaining output]} @@ -27,7 +27,7 @@ {try.#Failure try} {try.#Failure try})) -(def: .public any +(def .public any (Parser Text) (function (_ inputs) (case inputs @@ -37,7 +37,7 @@ _ {try.#Failure "Cannot parse empty arguments."}))) -(def: .public (parse parser) +(def .public (parse parser) (All (_ a) (-> (-> Text (Try a)) (Parser a))) (function (_ inputs) (do try.monad @@ -45,7 +45,7 @@ output (parser raw)] (in [remaining output])))) -(def: .public (this reference) +(def .public (this reference) (-> Text (Parser Any)) (function (_ inputs) (do try.monad @@ -54,7 +54,7 @@ (in [remaining []]) {try.#Failure (format "Missing token: '" reference "'")})))) -(def: .public (somewhere cli) +(def .public (somewhere cli) (All (_ a) (-> (Parser a) (Parser a))) (function (_ inputs) (loop (again [immediate inputs]) @@ -73,20 +73,20 @@ (in [{.#Item to_omit remaining} output]))))))) -(def: .public end +(def .public end (Parser Any) (function (_ inputs) (case inputs {.#End} {try.#Success [inputs []]} _ {try.#Failure (format "Unknown parameters: " (text.interposed " " inputs))}))) -(def: .public (named name value) +(def .public (named name value) (All (_ a) (-> Text (Parser a) (Parser a))) (|> value (//.after (..this name)) ..somewhere)) -(def: .public (parameter [short long] value) +(def .public (parameter [short long] value) (All (_ a) (-> [Text Text] (Parser a) (Parser a))) (|> value (//.after (//.either (..this short) (..this long))) diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index abdcb7075..337201593 100644 --- a/stdlib/source/library/lux/control/parser/code.lux +++ b/stdlib/source/library/lux/control/parser/code.lux @@ -22,7 +22,7 @@ ["[0]" symbol]]]] ["[0]" //]) -(def: (un_paired pairs) +(def (un_paired pairs) (All (_ a) (-> (List [a a]) (List a))) (case pairs {.#End} @@ -34,13 +34,13 @@ (type: .public Parser (//.Parser (List Code))) -(def: remaining_inputs +(def remaining_inputs (-> (List Code) Text) (|>> (list#each code.format) (text.interposed " ") (all text#composite text.new_line "Remaining input: "))) -(def: .public any +(def .public any (Parser Code) (function (_ tokens) (case tokens @@ -50,7 +50,7 @@ {.#Item [t tokens']} {try.#Success [tokens' t]}))) -(def: .public next +(def .public next (Parser Code) (function (_ tokens) (case tokens @@ -62,7 +62,7 @@ (with_template [<query> <check> <type> <tag> <eq> <desc>] [(with_expansions [<failure> (these {try.#Failure (all text#composite "Cannot parse " <desc> (remaining_inputs tokens))})] - (def: .public <query> + (def .public <query> (Parser <type>) (function (_ tokens) (case tokens @@ -72,7 +72,7 @@ _ <failure>))) - (def: .public (<check> expected) + (def .public (<check> expected) (-> <type> (Parser Any)) (function (_ tokens) (case tokens @@ -93,7 +93,7 @@ [symbol this_symbol Symbol .#Symbol symbol.equivalence "symbol"] ) -(def: .public (this code) +(def .public (this code) (-> Code (Parser Any)) (function (_ tokens) (case tokens @@ -107,7 +107,7 @@ {try.#Failure "There are no tokens to parse!"}))) (with_expansions [<failure> (these {try.#Failure (all text#composite "Cannot parse local symbol" (remaining_inputs tokens))})] - (def: .public local + (def .public local (Parser Text) (function (_ tokens) (case tokens @@ -117,7 +117,7 @@ _ <failure>))) - (def: .public (this_local expected) + (def .public (this_local expected) (-> Text (Parser Any)) (function (_ tokens) (case tokens @@ -130,7 +130,7 @@ <failure>)))) (with_expansions [<failure> (these {try.#Failure (all text#composite "Cannot parse local symbol" (remaining_inputs tokens))})] - (def: .public global + (def .public global (Parser Symbol) (function (_ tokens) (case tokens @@ -143,7 +143,7 @@ _ <failure>))) - (def: .public (this_global expected) + (def .public (this_global expected) (-> Symbol (Parser Any)) (function (_ tokens) (case tokens @@ -159,7 +159,7 @@ <failure>)))) (with_template [<name> <tag> <desc>] - [(def: .public (<name> p) + [(def .public (<name> p) (All (_ a) (-> (Parser a) (Parser a))) (function (_ tokens) @@ -177,21 +177,21 @@ [tuple .#Tuple "tuple"] ) -(def: .public end +(def .public end (Parser Any) (function (_ tokens) (case tokens {.#End} {try.#Success [tokens []]} _ {try.#Failure (all text#composite "Expected list of tokens to be empty!" (remaining_inputs tokens))}))) -(def: .public end? +(def .public end? (Parser Bit) (function (_ tokens) {try.#Success [tokens (case tokens {.#End} true _ false)]})) -(def: .public (result parser inputs) +(def .public (result parser inputs) (All (_ a) (-> (Parser a) (List Code) (Try a))) (case (parser inputs) {try.#Failure error} @@ -208,14 +208,14 @@ (text.interposed ", ") (text#composite "Unconsumed inputs: "))}))) -(def: .public (locally inputs parser) +(def .public (locally inputs parser) (All (_ a) (-> (List Code) (Parser a) (Parser a))) (function (_ real) (do try.monad [value (..result parser inputs)] (in [real value])))) -(def: .public (not parser) +(def .public (not parser) (All (_ a) (-> (Parser a) (Parser Code))) (do //.monad [sample ..next diff --git a/stdlib/source/library/lux/control/parser/environment.lux b/stdlib/source/library/lux/control/parser/environment.lux index b6a669a56..601cd9a5d 100644 --- a/stdlib/source/library/lux/control/parser/environment.lux +++ b/stdlib/source/library/lux/control/parser/environment.lux @@ -25,11 +25,11 @@ (type: .public (Parser a) (//.Parser Environment a)) -(def: .public empty +(def .public empty Environment (dictionary.empty text.hash)) -(def: .public (property name) +(def .public (property name) (-> Property (Parser Text)) (function (_ environment) (case (dictionary.value name environment) @@ -39,6 +39,6 @@ {.#None} (exception.except ..unknown_property [name])))) -(def: .public (result parser environment) +(def .public (result parser environment) (All (_ a) (-> (Parser a) Environment (Try a))) (at try.monad each product.right (parser environment))) diff --git a/stdlib/source/library/lux/control/parser/json.lux b/stdlib/source/library/lux/control/parser/json.lux index 8f7fe459f..308c8c918 100644 --- a/stdlib/source/library/lux/control/parser/json.lux +++ b/stdlib/source/library/lux/control/parser/json.lux @@ -31,7 +31,7 @@ (exception: .public empty_input) -(def: .public (result parser json) +(def .public (result parser json) (All (_ a) (-> (Parser a) JSON (Try a))) (case (//.result parser (list json)) {try.#Success [remainder output]} @@ -45,7 +45,7 @@ {try.#Failure error} {try.#Failure error})) -(def: .public any +(def .public any (Parser JSON) (<| (function (_ inputs)) (case inputs @@ -60,7 +60,7 @@ "Value" (/.format value))) (with_template [<name> <type> <tag>] - [(def: .public <name> + [(def .public <name> (Parser <type>) (do //.monad [head ..any] @@ -84,7 +84,7 @@ "Sample" (/.format sample))) (with_template [<test> <check> <type> <equivalence> <tag>] - [(def: .public (<test> test) + [(def .public (<test> test) (-> <type> (Parser Bit)) (do //.monad [head ..any] @@ -95,7 +95,7 @@ _ (//.failure (exception.error ..unexpected_value [head]))))) - (def: .public (<check> test) + (def .public (<check> test) (-> <type> (Parser Any)) (do //.monad [head ..any] @@ -113,12 +113,12 @@ [string? this_string /.String text.equivalence /.#String] ) -(def: .public (nullable parser) +(def .public (nullable parser) (All (_ a) (-> (Parser a) (Parser (Maybe a)))) (//.or ..null parser)) -(def: .public (array parser) +(def .public (array parser) (All (_ a) (-> (Parser a) (Parser a))) (do //.monad [head ..any] @@ -139,7 +139,7 @@ _ (//.failure (exception.error ..unexpected_value [head]))))) -(def: .public (object parser) +(def .public (object parser) (All (_ a) (-> (Parser a) (Parser a))) (do //.monad [head ..any] @@ -165,7 +165,7 @@ _ (//.failure (exception.error ..unexpected_value [head]))))) -(def: .public (field field_name parser) +(def .public (field field_name parser) (All (_ a) (-> Text (Parser a) (Parser a))) (function (again inputs) (case inputs @@ -191,7 +191,7 @@ _ (exception.except ..unconsumed_input inputs)))) -(def: .public dictionary +(def .public dictionary (All (_ a) (-> (Parser a) (Parser (Dictionary Text a)))) (|>> (//.and ..string) //.some diff --git a/stdlib/source/library/lux/control/parser/tree.lux b/stdlib/source/library/lux/control/parser/tree.lux index 751d370db..b7a37f0ef 100644 --- a/stdlib/source/library/lux/control/parser/tree.lux +++ b/stdlib/source/library/lux/control/parser/tree.lux @@ -15,17 +15,17 @@ (type: .public (Parser t a) (//.Parser (Zipper t) a)) -(def: .public (result' parser zipper) +(def .public (result' parser zipper) (All (_ t a) (-> (Parser t a) (Zipper t) (Try a))) (do try.monad [[zipper output] (//.result parser zipper)] (in output))) -(def: .public (result parser tree) +(def .public (result parser tree) (All (_ t a) (-> (Parser t a) (Tree t) (Try a))) (result' parser (zipper.zipper tree))) -(def: .public value +(def .public value (All (_ t) (Parser t t)) (function (_ zipper) {try.#Success [zipper (zipper.value zipper)]})) @@ -33,7 +33,7 @@ (exception: .public cannot_move_further) (with_template [<name> <direction>] - [(def: .public <name> + [(def .public <name> (All (_ t) (Parser t [])) (function (_ zipper) (case (<direction> zipper) diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index 1b8a9de5a..cff760d80 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -23,7 +23,7 @@ ["[0]" check]]]] ["[0]" //]) -(def: |recursion_dummy| +(def |recursion_dummy| (template (|recursion_dummy|) [{.#Primitive "" {.#End}}])) @@ -69,11 +69,11 @@ (type: .public (Parser a) (//.Parser [Env (List Type)] a)) -(def: .public fresh +(def .public fresh Env (dictionary.empty n.hash)) -(def: (result' env poly types) +(def (result' env poly types) (All (_ a) (-> Env (Parser a) (List Type) (Try a))) (case (//.result poly [env types]) {try.#Failure error} @@ -87,16 +87,16 @@ _ (exception.except ..unconsumed_input remaining)))) -(def: .public (result poly type) +(def .public (result poly type) (All (_ a) (-> (Parser a) Type (Try a))) (result' ..fresh poly (list type))) -(def: .public env +(def .public env (Parser Env) (.function (_ [env inputs]) {try.#Success [[env inputs] env]})) -(def: (with_env temp poly) +(def (with_env temp poly) (All (_ a) (-> Env (Parser a) (Parser a))) (.function (_ [env inputs]) (case (//.result poly [temp inputs]) @@ -106,7 +106,7 @@ {try.#Success [[_ remaining] output]} {try.#Success [[env remaining] output]}))) -(def: .public next +(def .public next (Parser Type) (.function (_ [env inputs]) (case inputs @@ -116,7 +116,7 @@ {.#Item headT tail} {try.#Success [[env inputs] headT]}))) -(def: .public any +(def .public any (Parser Type) (.function (_ [env inputs]) (case inputs @@ -126,7 +126,7 @@ {.#Item headT tail} {try.#Success [[env tail] headT]}))) -(def: .public (local types poly) +(def .public (local types poly) (All (_ a) (-> (List Type) (Parser a) (Parser a))) (.function (_ [env pass_through]) (case (result' env poly types) @@ -136,11 +136,11 @@ {try.#Success output} {try.#Success [[env pass_through] output]}))) -(def: (label idx) +(def (label idx) (-> Nat Code) (code.local (all text#composite "label" text.tab (n#encoded idx)))) -(def: .public (with_extension type poly) +(def .public (with_extension type poly) (All (_ a) (-> Type (Parser a) (Parser [Code a]))) (.function (_ [env inputs]) (let [current_id (dictionary.size env) @@ -155,7 +155,7 @@ {try.#Success [[env inputs'] [g!var output]]})))) (with_template [<name> <flattener> <exception>] - [(`` (def: .public (<name> poly) + [(`` (def .public (<name> poly) (All (_ a) (-> (Parser a) (Parser a))) (do //.monad [headT ..any] @@ -168,7 +168,7 @@ [tuple type.flat_tuple ..not_tuple] ) -(def: polymorphic' +(def polymorphic' (Parser [Nat Type]) (do //.monad [headT any @@ -177,7 +177,7 @@ (//.failure (exception.error ..not_polymorphic headT)) (in [num_arg bodyT])))) -(def: .public (polymorphic poly) +(def .public (polymorphic poly) (All (_ a) (-> (Parser a) (Parser [Code (List Code) a]))) (do [! //.monad] [headT any @@ -214,7 +214,7 @@ [output poly] (in [funcL all_varsL output]))))) -(def: .public (function in_poly out_poly) +(def .public (function in_poly out_poly) (All (_ i o) (-> (Parser i) (Parser o) (Parser [i o]))) (do //.monad [headT any @@ -224,7 +224,7 @@ (local (list outputT) out_poly)) (//.failure (exception.error ..not_function headT))))) -(def: .public (applied poly) +(def .public (applied poly) (All (_ a) (-> (Parser a) (Parser a))) (do //.monad [headT any @@ -234,7 +234,7 @@ (..local {.#Item funcT paramsT} poly)))) (with_template [<name> <test>] - [(def: .public (<name> expected) + [(def .public (<name> expected) (-> Type (Parser Any)) (do //.monad [actual any] @@ -247,14 +247,14 @@ [super (function.flipped check.subsumes?)] ) -(def: .public (argument env idx) +(def .public (argument env idx) (-> Env Nat Nat) (let [env_level (n./ 2 (dictionary.size env)) parameter_level (n./ 2 idx) parameter_idx (n.% 2 idx)] (|> env_level -- (n.- parameter_level) (n.* 2) (n.+ parameter_idx)))) -(def: .public parameter +(def .public parameter (Parser Code) (do //.monad [env ..env @@ -271,7 +271,7 @@ _ (//.failure (exception.error ..not_parameter headT))))) -(def: .public (this_parameter id) +(def .public (this_parameter id) (-> Nat (Parser Any)) (do //.monad [env ..env @@ -285,7 +285,7 @@ _ (//.failure (exception.error ..not_parameter headT))))) -(def: .public existential +(def .public existential (Parser Nat) (do //.monad [headT any] @@ -296,7 +296,7 @@ _ (//.failure (exception.error ..not_existential headT))))) -(def: .public named +(def .public named (Parser [Symbol Type]) (do //.monad [inputT any] @@ -307,7 +307,7 @@ _ (//.failure (exception.error ..not_named inputT))))) -(def: .public (recursive poly) +(def .public (recursive poly) (All (_ a) (-> (Parser a) (Parser [Code a]))) (do [! //.monad] [headT any] @@ -323,7 +323,7 @@ _ (//.failure (exception.error ..not_recursive headT))))) -(def: .public recursive_self +(def .public recursive_self (Parser Code) (do //.monad [env ..env @@ -337,7 +337,7 @@ _ (//.failure (exception.error ..not_recursive headT))))) -(def: .public recursive_call +(def .public recursive_call (Parser Code) (do [! //.monad] [env ..env diff --git a/stdlib/source/library/lux/control/parser/xml.lux b/stdlib/source/library/lux/control/parser/xml.lux index 05680953a..16802de51 100644 --- a/stdlib/source/library/lux/control/parser/xml.lux +++ b/stdlib/source/library/lux/control/parser/xml.lux @@ -40,7 +40,7 @@ (exception.report "Inputs" (exception.listing (at /.codec encoded) inputs))) -(def: (result' parser attrs documents) +(def (result' parser attrs documents) (All (_ a) (-> (Parser a) Attrs (List XML) (Try a))) (case (//.result parser [attrs documents]) {try.#Success [[attrs' remaining] output]} @@ -51,11 +51,11 @@ {try.#Failure error} {try.#Failure error})) -(def: .public (result parser documents) +(def .public (result parser documents) (All (_ a) (-> (Parser a) (List XML) (Try a))) (..result' parser /.attributes documents)) -(def: .public text +(def .public text (Parser Text) (function (_ [attrs documents]) (case documents @@ -70,7 +70,7 @@ {/.#Node _} (exception.except ..unexpected_input []))))) -(def: .public tag +(def .public tag (Parser Tag) (function (_ [attrs documents]) (case documents @@ -85,7 +85,7 @@ {/.#Node tag _ _} {try.#Success [[attrs documents] tag]})))) -(def: .public (attribute name) +(def .public (attribute name) (-> Attribute (Parser Text)) (function (_ [attrs documents]) (case (dictionary.value name attrs) @@ -95,7 +95,7 @@ {.#Some value} {try.#Success [[attrs documents] value]}))) -(def: .public (node expected parser) +(def .public (node expected parser) (All (_ a) (-> Tag (Parser a) (Parser a))) (function (_ [attrs documents]) (case documents @@ -114,7 +114,7 @@ (try#each (|>> [[attrs tail]]))) (exception.except ..wrong_tag [expected actual])))))) -(def: .public any +(def .public any (Parser XML) (function (_ [attrs documents]) (case documents @@ -126,7 +126,7 @@ (exception: .public nowhere) -(def: .public (somewhere parser) +(def .public (somewhere parser) (All (_ a) (-> (Parser a) (Parser a))) (function (again [attrs input]) (case (//.result parser [attrs input]) diff --git a/stdlib/source/library/lux/control/pipe.lux b/stdlib/source/library/lux/control/pipe.lux index 611aaf179..7f7762924 100644 --- a/stdlib/source/library/lux/control/pipe.lux +++ b/stdlib/source/library/lux/control/pipe.lux @@ -19,29 +19,29 @@ ["n" nat] ["i" int]]]]]) -(def: body +(def body (Parser (List Code)) (<code>.tuple (<>.some <code>.any))) -(def: .public new +(def .public new (syntax (_ [start <code>.any body ..body prev <code>.any]) (in (list (` (|> (~ start) (~+ body))))))) -(def: .public let +(def .public let (syntax (_ [binding <code>.any body <code>.any prev <code>.any]) (in (list (` (.let [(~ binding) (~ prev)] (~ body))))))) -(def: _reversed_ +(def _reversed_ (Parser Any) (function (_ tokens) {try.#Success [(list.reversed tokens) []]})) -(def: .public cond +(def .public cond (syntax (_ [_ _reversed_ prev <code>.any else ..body @@ -55,7 +55,7 @@ (` (|> (~ g!temp) (~+ then)))))) (|> (~ g!temp) (~+ else)))))))))) -(def: .public if +(def .public if (syntax (_ [test ..body then ..body else ..body @@ -64,7 +64,7 @@ [(~+ else)] (~ prev))))))) -(def: .public when +(def .public when (syntax (_ [test ..body then ..body prev <code>.any]) @@ -72,7 +72,7 @@ [] (~ prev))))))) -(def: .public while +(def .public while (syntax (_ [test ..body then ..body prev <code>.any]) @@ -82,7 +82,7 @@ ((~ g!again) (|> (~ g!temp) (~+ then))) (~ g!temp))))))))) -(def: .public do +(def .public do (syntax (_ [monad <code>.any steps (<>.some ..body) prev <code>.any]) @@ -100,7 +100,7 @@ _ (in (list prev)))))) -(def: .public exec +(def .public exec (syntax (_ [body ..body prev <code>.any]) (with_symbols [g!temp] @@ -108,7 +108,7 @@ (.exec (|> (~ g!temp) (~+ body)) (~ g!temp))))))))) -(def: .public tuple +(def .public tuple (syntax (_ [paths (<>.many ..body) prev <code>.any]) (with_symbols [g!temp] @@ -116,7 +116,7 @@ [(~+ (list#each (function (_ body) (` (|> (~ g!temp) (~+ body)))) paths))]))))))) -(def: .public case +(def .public case (syntax (_ [branches (<>.many (<>.and <code>.any <code>.any)) prev <code>.any]) (in (list (` (.case (~ prev) diff --git a/stdlib/source/library/lux/control/reader.lux b/stdlib/source/library/lux/control/reader.lux index dc9c65f57..923b10562 100644 --- a/stdlib/source/library/lux/control/reader.lux +++ b/stdlib/source/library/lux/control/reader.lux @@ -10,62 +10,62 @@ (type: .public (Reader r a) (-> r a)) -(def: .public read +(def .public read (All (_ r) (Reader r r)) (function (_ env) env)) -(def: .public (local change proc) +(def .public (local change proc) (All (_ r a) (-> (-> r r) (Reader r a) (Reader r a))) (|>> change proc)) -(def: .public (result env proc) +(def .public (result env proc) (All (_ r a) (-> r (Reader r a) a)) (proc env)) -(def: .public functor +(def .public functor (All (_ r) (Functor (Reader r))) (implementation - (def: (each f fa) + (def (each f fa) (function (_ env) (f (fa env)))))) -(def: .public apply +(def .public apply (All (_ r) (Apply (Reader r))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ env) ((ff env) (fa env)))))) -(def: .public monad +(def .public monad (All (_ r) (Monad (Reader r))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in x) + (def (in x) (function (_ env) x)) - (def: (conjoint mma) + (def (conjoint mma) (function (_ env) (mma env env))))) -(def: .public (with monad) +(def .public (with monad) (All (_ !) (-> (Monad !) (All (_ e) (Monad (All (_ a) (Reader e (! a))))))) (implementation - (def: functor + (def functor (functor.composite ..functor (the monad.functor monad))) - (def: in + (def in (|>> (at monad in) (at ..monad in))) - (def: (conjoint eMeMa) + (def (conjoint eMeMa) (function (_ env) (do monad [eMa (result env eMeMa)] (result env eMa)))))) -(def: .public lifted +(def .public lifted (All (_ ! e a) (-> (! a) (Reader e (! a)))) (at ..monad in)) diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index ea1abcec3..2c91dbbb8 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -23,7 +23,7 @@ (! [(List (Cleaner r !)) (Try a)]))) -(def: separator +(def separator Text (format text.new_line "-----------------------------------------" text.new_line @@ -42,7 +42,7 @@ (format separator error|output)))) -(def: (clean clean_up output) +(def (clean clean_up output) (All (_ a) (-> (Try Any) (Try a) (Try a))) (case clean_up {try.#Success _} @@ -51,7 +51,7 @@ {try.#Failure error} (exception.except ..clean_up_error [error output]))) -(def: .public (run! monad computation) +(def .public (run! monad computation) (All (_ ! a) (-> (Monad !) (All (_ r) (Region r ! a)) (! (Try a)))) @@ -61,7 +61,7 @@ (monad.each ! (function (_ cleaner) (cleaner []))) (at ! each (list#mix clean output))))) -(def: .public (acquire! monad cleaner value) +(def .public (acquire! monad cleaner value) (All (_ ! a) (-> (Monad !) (-> a (! (Try Any))) a (All (_ r) (Region r ! a)))) (function (_ [region cleaners]) @@ -69,12 +69,12 @@ cleaners} {try.#Success value}]))) -(def: .public (functor super) +(def .public (functor super) (All (_ !) (-> (Functor !) (All (_ r) (Functor (Region r !))))) (implementation - (def: (each f) + (def (each f) (function (_ fa) (function (_ region+cleaners) (at super each @@ -87,15 +87,15 @@ {try.#Failure error})]) (fa region+cleaners))))))) -(def: .public (apply super) +(def .public (apply super) (All (_ !) (-> (Monad !) (All (_ r) (Apply (Region r !))))) (implementation - (def: functor + (def functor (..functor (the monad.functor super))) - (def: (on fa ff) + (def (on fa ff) (function (_ [region cleaners]) (do super [[cleaners ef] (ff [region cleaners]) @@ -112,19 +112,19 @@ {try.#Failure error} (in [cleaners {try.#Failure error}]))))))) -(def: .public (monad super) +(def .public (monad super) (All (_ !) (-> (Monad !) (All (_ r) (Monad (Region r !))))) (implementation - (def: functor + (def functor (..functor (the monad.functor super))) - (def: (in value) + (def (in value) (function (_ [region cleaners]) (at super in [cleaners {try.#Success value}]))) - (def: (conjoint ffa) + (def (conjoint ffa) (function (_ [region cleaners]) (do super [[cleaners efa] (ffa [region cleaners])] @@ -135,20 +135,20 @@ {try.#Failure error} (in [cleaners {try.#Failure error}]))))))) -(def: .public (failure monad error) +(def .public (failure monad error) (All (_ ! a) (-> (Monad !) Text (All (_ r) (Region r ! a)))) (function (_ [region cleaners]) (at monad in [cleaners {try.#Failure error}]))) -(def: .public (except monad exception message) +(def .public (except monad exception message) (All (_ ! e a) (-> (Monad !) (Exception e) e (All (_ r) (Region r ! a)))) (failure monad (exception.error exception message))) -(def: .public (lifted monad operation) +(def .public (lifted monad operation) (All (_ ! a) (-> (Monad !) (! a) (All (_ r) (Region r ! a)))) diff --git a/stdlib/source/library/lux/control/remember.lux b/stdlib/source/library/lux/control/remember.lux index 8cd386ca6..1110c57bf 100644 --- a/stdlib/source/library/lux/control/remember.lux +++ b/stdlib/source/library/lux/control/remember.lux @@ -36,7 +36,7 @@ {.#None} ""))) -(def: deadline +(def deadline (Parser Date) (all <>.either (<>#each (|>> instant.of_millis instant.date) @@ -50,7 +50,7 @@ {try.#Failure message} (<>.failure message))))) -(def: .public remember +(def .public remember (syntax (_ [deadline ..deadline message <c>.text focus (<>.maybe <c>.any)]) @@ -66,7 +66,7 @@ (meta.failure (exception.error ..must_remember [deadline today message focus])))))) (with_template [<name> <message>] - [(`` (def: .public <name> + [(`` (def .public <name> (syntax (_ [deadline ..deadline message <c>.text focus (<>.maybe <c>.any)]) diff --git a/stdlib/source/library/lux/control/security/capability.lux b/stdlib/source/library/lux/control/security/capability.lux index 482f61161..6df5eaf19 100644 --- a/stdlib/source/library/lux/control/security/capability.lux +++ b/stdlib/source/library/lux/control/security/capability.lux @@ -26,20 +26,20 @@ (primitive .public (Capability brand input output) (-> input output) - (def: capability + (def capability (All (_ brand input output) (-> (-> input output) (Capability brand input output))) (|>> abstraction)) - (def: .public (use capability input) + (def .public (use capability input) (All (_ brand input output) (-> (Capability brand input output) input output)) ((representation capability) input)) - (def: .public capability: + (def .public capability: (syntax (_ [[export_policy declaration [forger input output]] (|export|.parser (all <>.and @@ -55,14 +55,14 @@ (in (list (` (type: (~ export_policy) (~ (|declaration|.format declaration)) (~ capability))) - (` (def: (~ (code.local forger)) + (` (def (~ (code.local forger)) (All ((~ g!_) (~+ (list#each code.local vars))) (-> (-> (~ input) (~ output)) (~ capability))) (~! ..capability))) )))))) - (def: .public (async capability) + (def .public (async capability) (All (_ brand input output) (-> (Capability brand input (IO output)) (Capability brand input (Async output)))) diff --git a/stdlib/source/library/lux/control/security/policy.lux b/stdlib/source/library/lux/control/security/policy.lux index f8856c593..fe683cf05 100644 --- a/stdlib/source/library/lux/control/security/policy.lux +++ b/stdlib/source/library/lux/control/security/policy.lux @@ -27,7 +27,7 @@ (-> (Policy brand value from) (Policy brand value to)))) - (def: .public (delegation downgrade upgrade) + (def .public (delegation downgrade upgrade) (All (_ brand from to) (-> (Can_Downgrade brand from) (Can_Upgrade brand to) (Delegation brand from to))) @@ -37,43 +37,43 @@ (-> (Privilege brand label) (scope label))) - (def: privilege + (def privilege Privilege [#can_upgrade (|>> abstraction) #can_downgrade (|>> representation)]) - (def: .public (with_policy context) + (def .public (with_policy context) (All (_ brand scope) (Ex (_ label) (-> (Context brand scope label) (scope label)))) (context ..privilege)) - (def: (of_policy constructor) + (def (of_policy constructor) (-> Type Type) (type (All (_ brand label) (constructor (All (_ value) (Policy brand value label)))))) - (def: .public functor + (def .public functor (~ (..of_policy Functor)) (implementation - (def: (each f fa) + (def (each f fa) (|> fa representation f abstraction)))) - (def: .public apply + (def .public apply (~ (..of_policy Apply)) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (abstraction ((representation ff) (representation fa)))))) - (def: .public monad + (def .public monad (~ (..of_policy Monad)) (implementation - (def: functor ..functor) - (def: in (|>> abstraction)) - (def: conjoint (|>> representation)))) + (def functor ..functor) + (def in (|>> abstraction)) + (def conjoint (|>> representation)))) ) (with_template [<brand> <value> <upgrade> <downgrade>] diff --git a/stdlib/source/library/lux/control/state.lux b/stdlib/source/library/lux/control/state.lux index dc007f65a..484592e71 100644 --- a/stdlib/source/library/lux/control/state.lux +++ b/stdlib/source/library/lux/control/state.lux @@ -9,70 +9,70 @@ (type: .public (State s a) (-> s [s a])) -(def: .public get +(def .public get (All (_ s) (State s s)) (function (_ state) [state state])) -(def: .public (put new_state) +(def .public (put new_state) (All (_ s) (-> s (State s Any))) (function (_ state) [new_state []])) -(def: .public (update change) +(def .public (update change) (All (_ s) (-> (-> s s) (State s Any))) (function (_ state) [(change state) []])) -(def: .public (use user) +(def .public (use user) (All (_ s a) (-> (-> s a) (State s a))) (function (_ state) [state (user state)])) -(def: .public (local change action) +(def .public (local change action) (All (_ s a) (-> (-> s s) (State s a) (State s a))) (function (_ state) (let [[state' output] (action (change state))] [state output]))) -(def: .public (result state action) +(def .public (result state action) (All (_ s a) (-> s (State s a) [s a])) (action state)) -(def: .public functor +(def .public functor (All (_ s) (Functor (State s))) (implementation - (def: (each f ma) + (def (each f ma) (function (_ state) (let [[state' a] (ma state)] [state' (f a)]))))) -(def: .public apply +(def .public apply (All (_ s) (Apply (State s))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ state) (let [[state' f] (ff state) [state'' a] (fa state')] [state'' (f a)]))))) -(def: .public monad +(def .public monad (All (_ s) (Monad (State s))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) (function (_ state) [state a])) - (def: (conjoint mma) + (def (conjoint mma) (function (_ state) (let [[state' ma] (mma state)] (ma state')))))) -(def: .public (while condition body) +(def .public (while condition body) (All (_ s) (-> (State s Bit) (State s Any) (State s Any))) (do [! ..monad] [execute? condition] @@ -82,26 +82,26 @@ (while condition body)) (in [])))) -(def: .public (do_while condition body) +(def .public (do_while condition body) (All (_ s) (-> (State s Bit) (State s Any) (State s Any))) (do ..monad [_ body] (while condition body))) -(def: (with//functor functor) +(def (with//functor functor) (All (_ M s) (-> (Functor M) (Functor (All (_ a) (-> s (M [s a])))))) (implementation - (def: (each f sfa) + (def (each f sfa) (function (_ state) (at functor each (function (_ [s a]) [s (f a)]) (sfa state)))))) -(def: (with//apply monad) +(def (with//apply monad) (All (_ M s) (-> (Monad M) (Apply (All (_ a) (-> s (M [s a])))))) (implementation - (def: functor (with//functor (at monad functor))) + (def functor (with//functor (at monad functor))) - (def: (on sFa sFf) + (def (on sFa sFf) (function (_ state) (do monad [[state f] (sFf state) @@ -111,26 +111,26 @@ (type: .public (+State M s a) (-> s (M [s a]))) -(def: .public (result' state action) +(def .public (result' state action) (All (_ M s a) (-> s (+State M s a) (M [s a]))) (action state)) -(def: .public (with monad) +(def .public (with monad) (All (_ M s) (-> (Monad M) (Monad (+State M s)))) (implementation - (def: functor (with//functor (at monad functor))) + (def functor (with//functor (at monad functor))) - (def: (in a) + (def (in a) (function (_ state) (at monad in [state a]))) - (def: (conjoint sMsMa) + (def (conjoint sMsMa) (function (_ state) (do monad [[state' sMa] (sMsMa state)] (sMa state')))))) -(def: .public (lifted monad ma) +(def .public (lifted monad ma) (All (_ M s a) (-> (Monad M) (M a) (+State M s a))) (function (_ state) (do monad diff --git a/stdlib/source/library/lux/control/thread.lux b/stdlib/source/library/lux/control/thread.lux index bb48b31b0..4dbe81f34 100644 --- a/stdlib/source/library/lux/control/thread.lux +++ b/stdlib/source/library/lux/control/thread.lux @@ -28,14 +28,14 @@ (type: .public (Box t a) (Box'' t (Mutable a a))) - (def: .public (box init) + (def .public (box init) (All (_ a) (-> a (All (_ !) (Thread ! (Box ! a))))) (function (_ !) (|> (array.empty 1) (array.has! 0 (variance.write init)) abstraction))) - (def: .public (read! box) + (def .public (read! box) (All (_ ! r w) (-> (Box' ! r w) (Thread ! r))) (function (_ !) (|> box @@ -43,7 +43,7 @@ (array.item 0) variance.read))) - (def: .public (write! value box) + (def .public (write! value box) (All (_ r w) (-> w (All (_ !) (-> (Box' ! r w) (Thread ! Any))))) (function (_ !) (|> box @@ -52,49 +52,49 @@ abstraction))) ) -(def: .public (result thread) +(def .public (result thread) (All (_ a) (-> (All (_ !) (Thread ! a)) a)) (thread [])) -(def: .public io +(def .public io (All (_ a) (-> (All (_ !) (Thread ! a)) (IO a))) (|>> ..result io.io)) -(def: .public functor +(def .public functor (All (_ !) (Functor (Thread !))) (implementation - (def: (each f) + (def (each f) (function (_ fa) (function (_ !) (f (fa !))))))) -(def: .public apply +(def .public apply (All (_ !) (Apply (Thread !))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ !) ((ff !) (fa !)))))) -(def: .public monad +(def .public monad (All (_ !) (Monad (Thread !))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in value) + (def (in value) (function (_ !) value)) - (def: (conjoint ffa) + (def (conjoint ffa) (function (_ !) ((ffa !) !))))) -(def: .public (update! f box) +(def .public (update! f box) (All (_ ! r w) (-> (-> r w) (Box' ! r w) (Thread ! [r w]))) (do ..monad [old (read! box) diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index 6d0467043..23d3cf178 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -15,10 +15,10 @@ {#Failure Text} {#Success a})) -(def: .public functor +(def .public functor (Functor Try) (implementation - (def: (each f ma) + (def (each f ma) (case ma {#Success datum} {#Success (f datum)} @@ -27,12 +27,12 @@ it (as_expected it))))) -(def: .public apply +(def .public apply (Apply Try) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (case ff {#Success f} (case fa @@ -47,15 +47,15 @@ it (as_expected it))))) -(def: .public monad +(def .public monad (Monad Try) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) {#Success a}) - (def: (conjoint mma) + (def (conjoint mma) (case mma {#Success ma} ma @@ -64,19 +64,19 @@ it (as_expected it))))) -(def: .public (with monad) +(def .public (with monad) ... TODO: Replace (All (_ a) (! (Try a))) with (functor.Then ! Try) (All (_ !) (-> (Monad !) (Monad (All (_ a) (! (Try a)))))) (implementation - (def: functor + (def functor (functor.composite (the monad.functor monad) ..functor)) - (def: in + (def in (|>> (at ..monad in) (at monad in))) - (def: (conjoint MeMea) + (def (conjoint MeMea) (do monad [eMea MeMea] (case eMea @@ -87,14 +87,14 @@ it (in (as_expected it))))))) -(def: .public (lifted monad) +(def .public (lifted monad) (All (_ ! a) (-> (Monad !) (-> (! a) (! (Try a))))) (at monad each (at ..monad in))) -(def: .public (equivalence (open "_#[0]")) +(def .public (equivalence (open "_#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Try a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Success reference} {#Success sample}] (_#= reference sample) @@ -106,7 +106,7 @@ false )))) -(def: .public (trusted try) +(def .public (trusted try) (All (_ a) (-> (Try a) a)) (case try @@ -116,7 +116,7 @@ {#Failure message} (panic! message))) -(def: .public (maybe try) +(def .public (maybe try) (All (_ a) (-> (Try a) (Maybe a))) (case try @@ -127,7 +127,7 @@ _ {.#None})) -(def: .public (of_maybe maybe) +(def .public (of_maybe maybe) (All (_ a) (-> (Maybe a) (Try a))) (case maybe @@ -138,7 +138,7 @@ {#Failure (`` (("lux in-module" (~~ (static .prelude)) .symbol#encoded) (symbol ..of_maybe)))})) -(def: .public else +(def .public else (macro (_ tokens compiler) (case tokens (pattern (list else try)) @@ -153,7 +153,7 @@ _ {#Failure "Wrong syntax for 'else'"}))) -(def: .public when +(def .public when (macro (_ tokens state) (case tokens (pattern (.list test then)) diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index 88b536e30..6df2cf695 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -13,54 +13,54 @@ [#log log #value value])) -(def: .public (write message) +(def .public (write message) (All (_ log) (-> log (Writer log Any))) [message []]) -(def: .public functor +(def .public functor (All (_ l) (Functor (Writer l))) (implementation - (def: (each f fa) + (def (each f fa) (let [[log datum] fa] [log (f datum)])))) -(def: .public (apply monoid) +(def .public (apply monoid) (All (_ l) (-> (Monoid l) (Apply (Writer l)))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (let [[log1 f] ff [log2 a] fa] [(at monoid composite log1 log2) (f a)])))) -(def: .public (monad monoid) +(def .public (monad monoid) (All (_ l) (-> (Monoid l) (Monad (Writer l)))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: in + (def in (|>> [(at monoid identity)])) - (def: (conjoint mma) + (def (conjoint mma) (let [[log1 [log2 a]] mma] [(at monoid composite log1 log2) a])))) -(def: .public (with monoid monad) +(def .public (with monoid monad) (All (_ l M) (-> (Monoid l) (Monad M) (Monad (All (_ a) (M (Writer l a)))))) (implementation - (def: functor + (def functor (functor.composite (the monad.functor monad) ..functor)) - (def: in + (def in (let [writer (..monad monoid)] (|>> (at writer in) (at monad in)))) - (def: (conjoint MlMla) + (def (conjoint MlMla) (do monad [[l1 Mla] (for @.old (is {.#Apply (Writer (parameter 0) @@ -74,7 +74,7 @@ [l2 a] Mla] (in [(at monoid composite l1 l2) a]))))) -(def: .public (lifted monoid monad) +(def .public (lifted monoid monad) (All (_ l M a) (-> (Monoid l) (Monad M) (-> (M a) (M (Writer l a))))) diff --git a/stdlib/source/library/lux/data/binary.lux b/stdlib/source/library/lux/data/binary.lux index b80d38724..102440856 100644 --- a/stdlib/source/library/lux/data/binary.lux +++ b/stdlib/source/library/lux/data/binary.lux @@ -23,15 +23,15 @@ (type: .public Binary /.Binary) -(def: .public size +(def .public size (-> Binary Nat) (|>> /.size)) -(def: .public empty +(def .public empty (-> Nat Binary) (|>> /.empty)) -(def: .public (mix $ init it) +(def .public (mix $ init it) (All (_ a) (-> (-> I64 a a) a Binary a)) (let [size (/.size it)] (loop (again [index 0 @@ -47,7 +47,7 @@ "Index" (%.nat index))) (with_template [<safe> <unsafe> <shift>] - [(def: .public (<safe> index it) + [(def .public (<safe> index it) (-> Nat Binary (Try I64)) (if (n.< (/.size it) (|> index <shift>)) {try.#Success (<unsafe> index it)} @@ -60,7 +60,7 @@ ) (with_template [<safe> <unsafe> <shift>] - [(def: .public (<safe> index value it) + [(def .public (<safe> index value it) (-> Nat (I64 Any) Binary (Try Binary)) (if (n.< (/.size it) (|> index <shift>)) {try.#Success (<unsafe> index value it)} @@ -72,10 +72,10 @@ [has_64! /.has_64! (n.+ 7)] ) -(def: .public equivalence +(def .public equivalence (Equivalence Binary) (implementation - (def: (= reference sample) + (def (= reference sample) (/.= reference sample)))) (exception: .public (cannot_copy [bytes Nat @@ -86,7 +86,7 @@ "Source input space" (%.nat source_input) "Target output space" (%.nat target_output))) -(def: .public (copy! bytes source_offset source target_offset target) +(def .public (copy! bytes source_offset source target_offset target) (-> Nat Nat Binary Nat Binary (Try Binary)) (let [source_input (n.- source_offset (/.size source)) target_output (n.- target_offset (/.size target))] @@ -103,7 +103,7 @@ "Offset" (%.nat offset) "Length" (%.nat length))) -(def: .public (slice offset length binary) +(def .public (slice offset length binary) (-> Nat Nat Binary (Try Binary)) (let [size (/.size binary) limit (n.+ length offset)] @@ -111,7 +111,7 @@ (exception.except ..slice_out_of_bounds [size offset length]) {try.#Success (/.slice offset length binary)}))) -(def: .public (after bytes binary) +(def .public (after bytes binary) (-> Nat Binary Binary) (cond (n.= 0 bytes) binary @@ -122,13 +122,13 @@ ... else (/.empty 0))) -(def: .public monoid +(def .public monoid (Monoid Binary) (implementation - (def: identity + (def identity (/.empty 0)) - (def: (composite left right) + (def (composite left right) (let [sizeL (/.size left) sizeR (/.size right) output (/.empty (n.+ sizeL sizeR))] diff --git a/stdlib/source/library/lux/data/bit.lux b/stdlib/source/library/lux/data/bit.lux index 6d9988573..369c9002c 100644 --- a/stdlib/source/library/lux/data/bit.lux +++ b/stdlib/source/library/lux/data/bit.lux @@ -10,56 +10,56 @@ ["[0]" function]]]]) (with_template [<zero> <one>] - [(def: .public <zero> Bit #0) - (def: .public <one> Bit #1)] + [(def .public <zero> Bit #0) + (def .public <one> Bit #1)] [no yes] [off on] ) -(def: .public equivalence +(def .public equivalence (Equivalence Bit) (implementation - (def: (= x y) + (def (= x y) (if x y (not y))))) -(def: .public hash +(def .public hash (Hash Bit) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (hash value) + (def (hash value) (case value #0 2 #1 3)))) (with_template [<name> <identity> <op>] - [(def: .public <name> + [(def .public <name> (Monoid Bit) (implementation - (def: identity <identity>) - (def: (composite x y) (<op> x y))))] + (def identity <identity>) + (def (composite x y) (<op> x y))))] [disjunction #0 or] [conjunction #1 and] ) -(def: .public codec +(def .public codec (Codec Text Bit) (implementation - (def: (encoded x) + (def (encoded x) (if x "#1" "#0")) - (def: (decoded input) + (def (decoded input) (case input "#1" {.#Right #1} "#0" {.#Right #0} _ {.#Left "Wrong syntax for Bit."})))) -(def: .public complement +(def .public complement (All (_ a) (-> (-> a Bit) (-> a Bit))) (function.composite not)) diff --git a/stdlib/source/library/lux/data/collection/array.lux b/stdlib/source/library/lux/data/collection/array.lux index f4e987ca9..0d02cef25 100644 --- a/stdlib/source/library/lux/data/collection/array.lux +++ b/stdlib/source/library/lux/data/collection/array.lux @@ -14,7 +14,7 @@ [variance (.only)]]]] ["!" \\unsafe]) -(def: .public type_name +(def .public type_name Text !.type) @@ -24,123 +24,123 @@ (type: .public Array !.Array) -(def: .public empty +(def .public empty (All (_ a) (-> Nat (Array a))) (|>> !.empty)) -(def: .public size +(def .public size (All (_ r w) (-> (Array' r w) Nat)) (|>> !.size)) -(def: .public (item index array) +(def .public (item index array) (All (_ r w) (-> Nat (Array' r w) (Maybe r))) (if (!.lacks? index array) {.#None} {.#Some (!.item index array)})) -(def: .public (has! index value array) +(def .public (has! index value array) (All (_ r w) (-> Nat w (Array' r w) (Array' r w))) (!.has! index value array)) -(def: .public (lacks! index array) +(def .public (lacks! index array) (All (_ r w) (-> Nat (Array' r w) (Array' r w))) (!.lacks! index array)) -(def: .public (lacks? index array) +(def .public (lacks? index array) (All (_ r w) (-> Nat (Array' r w) Bit)) (!.lacks? index array)) -(def: .public (has? index array) +(def .public (has? index array) (All (_ r w) (-> Nat (Array' r w) Bit)) (!.has? index array)) -(def: .public (revised! index $ array) +(def .public (revised! index $ array) (All (_ r w) (-> Nat (-> r w) (Array' r w) (Array' r w))) (!.revised! index $ array)) -(def: .public (upsert! index default transform array) +(def .public (upsert! index default transform array) (All (_ r w) (-> Nat r (-> r w) (Array' r w) (Array' r w))) (!.upsert! index default transform array)) -(def: .public (copy! length src_start src_array dest_start dest_array) +(def .public (copy! length src_start src_array dest_start dest_array) (All (_ r w) (-> Nat Nat (Array' w Nothing) Nat (Array' r w) (Array' r w))) (!.copy! length src_start src_array dest_start dest_array)) -(def: .public occupancy +(def .public occupancy (All (_ r w) (-> (Array' r w) Nat)) (|>> !.occupancy)) -(def: .public vacancy +(def .public vacancy (All (_ r w) (-> (Array' r w) Nat)) (|>> !.vacancy)) -(def: .public (only! ? it) +(def .public (only! ? it) (All (_ r w) (-> (Predicate r) (Array' r w) (Array' r w))) (!.only! ? it)) -(def: .public (example ? it) +(def .public (example ? it) (All (_ r w) (-> (Predicate r) (Array' r w) (Maybe r))) (!.example ? it)) -(def: .public (example' ? it) +(def .public (example' ? it) (All (_ r w) (-> (-> Nat r Bit) (Array' r w) (Maybe [Nat r]))) (!.example' ? it)) -(def: .public clone +(def .public clone (All (_ a) (-> (Array a) (Array a))) (|>> !.clone)) -(def: .public of_list +(def .public of_list (All (_ a) (-> (List a) (Array a))) (|>> !.of_list)) -(def: .public (list default array) +(def .public (list default array) (All (_ r w) (-> (Maybe r) (Array' r w) (List r))) (!.list default array)) -(def: .public (equivalence //) +(def .public (equivalence //) (All (_ r) (-> (Equivalence r) (Equivalence (Ex (_ w) (Array' r w))))) (implementation - (def: (= left/* right/*) + (def (= left/* right/*) (!.= // left/* right/*)))) -(def: .public monoid +(def .public monoid (All (_ a) (Monoid (Array a))) (implementation - (def: identity (!.empty 0)) + (def identity (!.empty 0)) - (def: (composite left/* right/*) + (def (composite left/* right/*) (!.composite left/* right/*)))) -(def: .public mix +(def .public mix (Mix (All (_ r) (Array' r Nothing))) (implementation - (def: (mix $ init it) + (def (mix $ init it) (!.mix (function (_ index partial total) ($ partial total)) init it)))) -(def: .public functor +(def .public functor (Functor Array) (implementation - (def: (each $ input) + (def (each $ input) (!.each $ input)))) (with_template [<safe> <unsafe>] - [(def: .public (<safe> ? it) + [(def .public (<safe> ? it) (All (_ r w) (-> (Predicate r) (Predicate (Array' r w)))) (<unsafe> ? it))] @@ -149,7 +149,7 @@ [any? !.any?] ) -(def: .public (one ? it) +(def .public (one ? it) (All (_ r r' w) (-> (-> r (Maybe r')) (Array' r w) (Maybe r'))) (!.one ? it)) diff --git a/stdlib/source/library/lux/data/collection/bits.lux b/stdlib/source/library/lux/data/collection/bits.lux index c33ecd77f..8c524156e 100644 --- a/stdlib/source/library/lux/data/collection/bits.lux +++ b/stdlib/source/library/lux/data/collection/bits.lux @@ -17,36 +17,36 @@ (type: .public Chunk I64) -(def: .public chunk_size +(def .public chunk_size i64.width) (type: .public Bits (Array Chunk)) -(def: empty_chunk +(def empty_chunk Chunk (.i64 0)) -(def: .public empty +(def .public empty Bits (array.empty 0)) -(def: .public (size bits) +(def .public (size bits) (-> Bits Nat) (array#mix (function (_ chunk total) (|> chunk i64.ones (n.+ total))) 0 bits)) -(def: .public (capacity bits) +(def .public (capacity bits) (-> Bits Nat) (|> bits array.size (n.* chunk_size))) -(def: .public empty? +(def .public empty? (-> Bits Bit) (|>> ..size (n.= 0))) -(def: .public (bit index bits) +(def .public (bit index bits) (-> Nat Bits Bit) (let [[chunk_index bit_index] (n./% chunk_size index)] (.and (n.< (array.size bits) chunk_index) @@ -54,14 +54,14 @@ (maybe.else empty_chunk) (i64.one? bit_index))))) -(def: (chunk idx bits) +(def (chunk idx bits) (-> Nat Bits Chunk) (if (n.< (array.size bits) idx) (|> bits (array.item idx) (maybe.else empty_chunk)) empty_chunk)) (with_template [<name> <op>] - [(def: .public (<name> index input) + [(def .public (<name> index input) (-> Nat Bits Bits) (let [[chunk_index bit_index] (n./% chunk_size index)] (loop (again [size|output (n.max (++ chunk_index) @@ -94,7 +94,7 @@ [flipped i64.flipped] ) -(def: .public (intersects? reference sample) +(def .public (intersects? reference sample) (-> Bits Bits Bit) (let [chunks (n.min (array.size reference) (array.size sample))] @@ -107,7 +107,7 @@ (again (++ idx))) #0)))) -(def: .public (not input) +(def .public (not input) (-> Bits Bits) (case (array.size input) 0 @@ -131,7 +131,7 @@ output)))))) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Bits Bits Bits) (case (n.max (array.size param) (array.size subject)) @@ -162,10 +162,10 @@ [xor i64.xor] ) -(def: .public equivalence +(def .public equivalence (Equivalence Bits) (implementation - (def: (= reference sample) + (def (= reference sample) (let [size (n.max (array.size reference) (array.size sample))] (loop (again [idx 0]) diff --git a/stdlib/source/library/lux/data/collection/dictionary.lux b/stdlib/source/library/lux/data/collection/dictionary.lux index 124adeceb..a9f167556 100644 --- a/stdlib/source/library/lux/data/collection/dictionary.lux +++ b/stdlib/source/library/lux/data/collection/dictionary.lux @@ -88,7 +88,7 @@ ... Which is the same as 0000 0000 0000 0000 0000 0000 0000 0000. ... Or 0x00000000. ... Which is 32 zeroes, since the branching factor is 32. -(def: clean_bitmap +(def clean_bitmap Bit_Map 0) @@ -101,41 +101,41 @@ ... factor). ... The initial shifting level, though, is 0 (which corresponds to the ... shift in the shallowest node on the tree, which is the root node). -(def: root_level +(def root_level Level 0) ... The exponent to which 2 must be elevated, to reach the branching ... factor of the data-structure. -(def: branching_exponent +(def branching_exponent Nat 5) ... The threshold on which #Hierarchy nodes are demoted to #Base nodes, ... which is 1/4 of the branching factor (or a left-shift 2). -(def: demotion_threshold +(def demotion_threshold Nat (i64.left_shifted (n.- 2 branching_exponent) 1)) ... The threshold on which #Base nodes are promoted to #Hierarchy nodes, ... which is 1/2 of the branching factor (or a left-shift 1). -(def: promotion_threshold +(def promotion_threshold Nat (i64.left_shifted (n.- 1 branching_exponent) 1)) ... The size of hierarchy-nodes, which is 2^(branching-exponent). -(def: hierarchy_nodes_size +(def hierarchy_nodes_size Nat (i64.left_shifted branching_exponent 1)) ... The cannonical empty node, which is just an empty #Base node. -(def: empty_node +(def empty_node Node {#Base clean_bitmap (array.empty 0)}) ... Expands a copy of the array, to have 1 extra slot, which is used ... for storing the value. -(def: (array#has idx value old_array) +(def (array#has idx value old_array) (All (_ a) (-> Index a (Array a) (Array a))) (let [old_size (array.size old_array)] (|> (array.empty (++ old_size)) @@ -144,19 +144,19 @@ (array.copy! (n.- idx old_size) idx old_array (++ idx))))) ... Creates a copy of an array with an index set to a particular value. -(def: (array#revised idx value array) +(def (array#revised idx value array) (All (_ a) (-> Index a (Array a) (Array a))) (|> array array.clone (array.has! idx value))) ... Creates a clone of the array, with an empty position at index. -(def: (array#clear idx array) +(def (array#clear idx array) (All (_ a) (-> Index (Array a) (Array a))) (|> array array.clone (array.lacks! idx))) ... Shrinks a copy of the array by removing the space at index. -(def: (array#lacks idx array) +(def (array#lacks idx array) (All (_ a) (-> Index (Array a) (Array a))) (let [new_size (-- (array.size array))] (|> (array.empty new_size) @@ -165,32 +165,32 @@ ... Increases the level-shift by the branching-exponent, to explore ... levels further down the tree. -(def: level_up +(def level_up (-> Level Level) (n.+ branching_exponent)) -(def: hierarchy_mask +(def hierarchy_mask Bit_Map (-- hierarchy_nodes_size)) ... Gets the branching-factor sized section of the hash corresponding ... to a particular level, and uses that as an index into the array. -(def: (level_index level hash) +(def (level_index level hash) (-> Level Hash_Code Index) (i64.and ..hierarchy_mask (i64.right_shifted level hash))) ... A mechanism to go from indices to bit-positions. -(def: (to_bit_position index) +(def (to_bit_position index) (-> Index Bit_Position) (i64.left_shifted index 1)) ... The bit-position within a base that a given hash-code would have. -(def: (level_bit_position level hash) +(def (level_bit_position level hash) (-> Level Hash_Code Bit_Position) (to_bit_position (level_index level hash))) -(def: (with_bit_position? bit bitmap) +(def (with_bit_position? bit bitmap) (-> Bit_Position Bit_Map Bit) (|> bitmap (i64.and bit) @@ -198,39 +198,39 @@ not)) ... Figures out whether a bitmap only contains a single bit-position. -(def: only_bit_position? +(def only_bit_position? (-> Bit_Position Bit_Map Bit) n.=) -(def: (with_bit_position bit bitmap) +(def (with_bit_position bit bitmap) (-> Bit_Position Bit_Map Bit_Map) (i64.or bit bitmap)) -(def: without_bit_position +(def without_bit_position (-> Bit_Position Bit_Map Bit_Map) i64.xor) ... Figures out the size of a bitmap-indexed array by counting all the ... 1s within the bitmap. -(def: bitmap_size +(def bitmap_size (-> Bit_Map Nat) i64.ones) ... A mask that, for a given bit position, only allows all the 1s prior ... to it, which would indicate the bitmap-size (and, thus, index) ... associated with it. -(def: bit_position_mask +(def bit_position_mask (-> Bit_Position Bit_Map) --) ... The index on the base array, based on its bit-position. -(def: (base_index bit_position bitmap) +(def (base_index bit_position bitmap) (-> Bit_Position Bit_Map Index) (bitmap_size (i64.and (bit_position_mask bit_position) bitmap))) ... Produces the index of a KV-pair within a #Collisions node. -(def: (collision_index key_hash key colls) +(def (collision_index key_hash key colls) (All (_ k v) (-> (Hash k) k (Collisions k v) (Maybe Index))) (at maybe.monad each product.left (array.example' (function (_ idx [key' val']) @@ -239,7 +239,7 @@ ... When #Hierarchy nodes grow too small, they're demoted to #Base ... nodes to save space. -(def: (demotion except_idx [h_size h_array]) +(def (demotion except_idx [h_size h_array]) (All (_ k v) (-> Index (Hierarchy k v) [Bit_Map (Base k v)])) (product.right (list#mix (function (_ idx [insertion_idx node]) (let [[bitmap base] node] @@ -256,11 +256,11 @@ ... When #Base nodes grow too large, they're promoted to #Hierarchy to ... add some depth to the tree and help keep its balance. -(def: hierarchy_indices +(def hierarchy_indices (List Index) (list.indices hierarchy_nodes_size)) -(def: (promotion node#has key_hash level bitmap base) +(def (promotion node#has key_hash level bitmap base) (All (_ k v) (-> (-> Level Hash_Code k v (Hash k) (Node k v) (Node k v)) (Hash k) Level @@ -286,7 +286,7 @@ ... All empty nodes look the same (a #Base node with clean bitmap is ... used). ... So, this test is introduced to detect them. -(def: (node#empty? node) +(def (node#empty? node) (All (_ k v) (-> (Node k v) Bit)) (`` (case node {#Base (~~ (static ..clean_bitmap)) _} @@ -295,7 +295,7 @@ _ #0))) -(def: (node#has level hash key val key_hash node) +(def (node#has level hash key val key_hash node) (All (_ k v) (-> Level Hash_Code k v (Hash k) (Node k v) (Node k v))) (case node ... For #Hierarchy nodes, check whether one can add the element to @@ -387,7 +387,7 @@ (node#has level hash key val key_hash))) )) -(def: (node#lacks level hash key key_hash node) +(def (node#lacks level hash key key_hash node) (All (_ k v) (-> Level Hash_Code k (Hash k) (Node k v) (Node k v))) (case node ... For #Hierarchy nodes, find out if there's a valid sub-node for @@ -474,7 +474,7 @@ {#Collisions _hash (array#lacks idx _colls)})) )) -(def: (node#value level hash key key_hash node) +(def (node#value level hash key key_hash node) (All (_ k v) (-> Level Hash_Code k (Hash k) (Node k v) (Maybe v))) (case node ... For #Hierarchy nodes, just look-up the key on its children. @@ -505,7 +505,7 @@ _colls)) )) -(def: (node#size node) +(def (node#size node) (All (_ k v) (-> (Node k v) Nat)) (case node {#Hierarchy _size hierarchy} @@ -528,7 +528,7 @@ (array.size colls) )) -(def: (node#mix f init node) +(def (node#mix f init node) (All (_ k v a) (-> (-> [k v] a a) a (Node k v) a)) (case node {#Hierarchy _size hierarchy} @@ -554,7 +554,7 @@ init colls))) -(def: node#entries +(def node#entries (All (_ k v) (-> (Node k v) (List [k v]))) (node#mix (function (_ head tail) {.#Item head tail}) @@ -565,31 +565,31 @@ [#hash (Hash k) #root (Node k v)])) -(def: .public key_hash +(def .public key_hash (All (_ k v) (-> (Dictionary k v) (Hash k))) (the ..#hash)) -(def: .public (empty key_hash) +(def .public (empty key_hash) (All (_ k v) (-> (Hash k) (Dictionary k v))) [#hash key_hash #root ..empty_node]) -(def: .public (has key val dict) +(def .public (has key val dict) (All (_ k v) (-> k v (Dictionary k v) (Dictionary k v))) (let [[key_hash node] dict] [key_hash (node#has root_level (at key_hash hash key) key val key_hash node)])) -(def: .public (lacks key dict) +(def .public (lacks key dict) (All (_ k v) (-> k (Dictionary k v) (Dictionary k v))) (let [[key_hash node] dict] [key_hash (node#lacks root_level (at key_hash hash key) key key_hash node)])) -(def: .public (value key dict) +(def .public (value key dict) (All (_ k v) (-> k (Dictionary k v) (Maybe v))) (let [[key_hash node] dict] (node#value root_level (at key_hash hash key) key key_hash node))) -(def: .public (key? dict key) +(def .public (key? dict key) (All (_ k v) (-> (Dictionary k v) k Bit)) (case (value key dict) {.#None} #0 @@ -597,13 +597,13 @@ (exception: .public key_already_exists) -(def: .public (has' key val dict) +(def .public (has' key val dict) (All (_ k v) (-> k v (Dictionary k v) (Try (Dictionary k v)))) (case (value key dict) {.#None} {try.#Success (has key val dict)} {.#Some _} (exception.except ..key_already_exists []))) -(def: .public (revised key f dict) +(def .public (revised key f dict) (All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (value key dict) {.#None} @@ -612,26 +612,26 @@ {.#Some val} (has key (f val) dict))) -(def: .public (revised' key default f dict) +(def .public (revised' key default f dict) (All (_ k v) (-> k v (-> v v) (Dictionary k v) (Dictionary k v))) (..has key (f (maybe.else default (..value key dict))) dict)) -(def: .public size +(def .public size (All (_ k v) (-> (Dictionary k v) Nat)) (|>> (the #root) ..node#size)) -(def: .public empty? +(def .public empty? (All (_ k v) (-> (Dictionary k v) Bit)) (|>> size (n.= 0))) -(def: .public entries +(def .public entries (All (_ k v) (-> (Dictionary k v) (List [k v]))) (|>> (the #root) ..node#entries)) -(def: .public (of_list key_hash kvs) +(def .public (of_list key_hash kvs) (All (_ k v) (-> (Hash k) (List [k v]) (Dictionary k v))) (list#mix (function (_ [k v] dict) (..has k v dict)) @@ -639,7 +639,7 @@ kvs)) (with_template [<side> <name>] - [(def: .public <name> + [(def .public <name> (All (_ k v) (-> (Dictionary k v) (List <side>))) (|>> (the #root) (node#mix (function (_ [k v] bundle) @@ -650,14 +650,14 @@ [v values] ) -(def: .public (composite dict2 dict1) +(def .public (composite dict2 dict1) (All (_ k v) (-> (Dictionary k v) (Dictionary k v) (Dictionary k v))) (node#mix (function (_ [key val] dict) (has key val dict)) dict1 (the #root dict2))) -(def: .public (composite_with f dict2 dict1) +(def .public (composite_with f dict2 dict1) (All (_ k v) (-> (-> v v v) (Dictionary k v) (Dictionary k v) (Dictionary k v))) (node#mix (function (_ [key val2] dict) (case (value key dict) @@ -669,7 +669,7 @@ dict1 (the #root dict2))) -(def: .public (re_bound from_key to_key dict) +(def .public (re_bound from_key to_key dict) (All (_ k v) (-> k k (Dictionary k v) (Dictionary k v))) (case (value from_key dict) {.#None} @@ -680,7 +680,7 @@ (lacks from_key) (has to_key val)))) -(def: .public (sub keys dict) +(def .public (sub keys dict) (All (_ k v) (-> (List k) (Dictionary k v) (Dictionary k v))) (let [[key_hash _] dict] (list#mix (function (_ key new_dict) @@ -690,10 +690,10 @@ (empty key_hash) keys))) -(def: .public (equivalence (open ",#[0]")) +(def .public (equivalence (open ",#[0]")) (All (_ k v) (-> (Equivalence v) (Equivalence (Dictionary k v)))) (implementation - (def: (= reference subject) + (def (= reference subject) (and (n.= (..size reference) (..size subject)) (list.every? (function (_ [k rv]) @@ -705,10 +705,10 @@ #0)) (..entries reference)))))) -(def: node_functor +(def node_functor (All (_ k) (Functor (Node k))) (implementation - (def: (each f fa) + (def (each f fa) (case fa {#Hierarchy size hierarchy} {#Hierarchy size (array.each (each f) hierarchy)} @@ -728,14 +728,14 @@ [k (f v)]) collisions)})))) -(def: .public functor +(def .public functor (All (_ k) (Functor (Dictionary k))) (implementation - (def: (each f fa) + (def (each f fa) (.revised #root (at ..node_functor each f) fa)))) -(def: .public (monoid hash) +(def .public (monoid hash) (All (_ k v) (-> (Hash k) (Monoid (Dictionary k v)))) (implementation - (def: identity (..empty hash)) - (def: composite ..composite))) + (def identity (..empty hash)) + (def composite ..composite))) diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index 38521368c..8592aaeec 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -17,7 +17,7 @@ [number ["n" nat]]]]]) -(def: error_message +(def error_message "Invariant violation") (type: Color @@ -34,7 +34,7 @@ #right (Maybe (Node k v))])) (with_template [<create> <color>] - [(def: (<create> key value left right) + [(def (<create> key value left right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) [#color {<color>} #key key @@ -51,14 +51,14 @@ [#order (Order k) #root (Maybe (Node k v))])) -(def: .public (empty order) +(def .public (empty order) (All (_ k v) (-> (Order k) (Dictionary k v))) [#order order #root {.#None}]) ... TODO: Doing inneficient access of Order functions due to compiler bug. ... TODO: Must improve it as soon as bug is fixed. -(def: .public (value key dict) +(def .public (value key dict) (All (_ k v) (-> k (Dictionary k v) (Maybe v))) (let [... (open "_#[0]") (the #order dict) ] @@ -83,7 +83,7 @@ ... TODO: Doing inneficient access of Order functions due to compiler bug. ... TODO: Must improve it as soon as bug is fixed. -(def: .public (key? dict key) +(def .public (key? dict key) (All (_ k v) (-> (Dictionary k v) k Bit)) (let [... (open "_#[0]") (the #order dict) ] @@ -102,7 +102,7 @@ (again (the #right node))))))))) (with_template [<name> <side>] - [(def: .public (<name> dict) + [(def .public (<name> dict) (All (_ k v) (-> (Dictionary k v) (Maybe v))) (case (the #root dict) {.#None} @@ -121,7 +121,7 @@ [max #right] ) -(def: .public (size dict) +(def .public (size dict) (All (_ k v) (-> (Dictionary k v) Nat)) (loop (again [node (the #root dict)]) (case node @@ -132,12 +132,12 @@ (++ (n.+ (again (the #left node)) (again (the #right node))))))) -(def: .public empty? +(def .public empty? (All (_ k v) (-> (Dictionary k v) Bit)) (|>> ..size (n.= 0))) (with_template [<name> <other_color> <self_color> <no_change>] - [(def: (<name> self) + [(def (<name> self) (All (_ k v) (-> (Node k v) (Node k v))) (case (the #color self) {<other_color>} @@ -151,7 +151,7 @@ [reddened #Black #Red (panic! error_message)] ) -(def: (with_left addition center) +(def (with_left addition center) (All (_ k v) (-> (Node k v) (Node k v) (Node k v))) (case (the #color center) {#Red} @@ -200,7 +200,7 @@ {#Black} <default_behavior>)))) -(def: (with_right addition center) +(def (with_right addition center) (All (_ k v) (-> (Node k v) (Node k v) (Node k v))) (case (the #color center) {#Red} @@ -249,7 +249,7 @@ {#Black} <default_behavior>)))) -(def: .public (has key value dict) +(def .public (has key value dict) (All (_ k v) (-> k v (Dictionary k v) (Dictionary k v))) (let [(open "_#[0]") (the #order dict) root' (loop (again [?root (the #root dict)]) @@ -278,7 +278,7 @@ ))] (.has #root root' dict))) -(def: (left_balanced key value ?left ?right) +(def (left_balanced key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left (^.multi {.#Some left} @@ -307,7 +307,7 @@ _ (black key value ?left ?right))) -(def: (right_balanced key value ?left ?right) +(def (right_balanced key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right (^.multi {.#Some right} @@ -334,7 +334,7 @@ _ (black key value ?left ?right))) -(def: (without_left key value ?left ?right) +(def (without_left key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?left (^.multi {.#Some left} @@ -363,7 +363,7 @@ (panic! error_message)) )) -(def: (without_right key value ?left ?right) +(def (without_right key value ?left ?right) (All (_ k v) (-> k v (Maybe (Node k v)) (Maybe (Node k v)) (Node k v))) (case ?right (^.multi {.#Some right} @@ -392,7 +392,7 @@ (panic! error_message) ))) -(def: (prepended ?left ?right) +(def (prepended ?left ?right) (All (_ k v) (-> (Maybe (Node k v)) (Maybe (Node k v)) (Maybe (Node k v)))) (case [?left ?right] [{.#None} _] @@ -472,7 +472,7 @@ _ (undefined))) -(def: .public (lacks key dict) +(def .public (lacks key dict) (All (_ k v) (-> k (Dictionary k v) (Dictionary k v))) (let [(open "_#[0]") (the #order dict) [?root found?] (loop (again [?root (the #root dict)]) @@ -527,7 +527,7 @@ (.has #root {.#Some (blackened root)} dict) ))) -(def: .public (revised key transform dict) +(def .public (revised key transform dict) (All (_ k v) (-> k (-> v v) (Dictionary k v) (Dictionary k v))) (case (..value key dict) {.#Some old} @@ -536,7 +536,7 @@ {.#None} dict)) -(def: .public (of_list order list) +(def .public (of_list order list) (All (_ k v) (-> (Order k) (List [k v]) (Dictionary k v))) (list#mix (function (_ [key value] dict) (..has key value dict)) @@ -544,7 +544,7 @@ list)) (with_template [<name> <type> <output>] - [(def: .public (<name> dict) + [(def .public (<name> dict) (All (_ k v) (-> (Dictionary k v) (List <type>))) (loop (again [node (the #root dict)]) (case node @@ -562,10 +562,10 @@ [values v (the #value node')] ) -(def: .public (equivalence (open ",#[0]")) +(def .public (equivalence (open ",#[0]")) (All (_ k v) (-> (Equivalence v) (Equivalence (Dictionary k v)))) (implementation - (def: (= reference sample) + (def (= reference sample) (let [(open "/#[0]") (the #order reference)] (loop (again [entriesR (entries reference) entriesS (entries sample)]) diff --git a/stdlib/source/library/lux/data/collection/dictionary/plist.lux b/stdlib/source/library/lux/data/collection/dictionary/plist.lux index d594f7b5e..3dd3521c4 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/plist.lux @@ -19,19 +19,19 @@ (type: .public (PList a) (List [Text a])) -(def: .public empty +(def .public empty PList {.#End}) -(def: .public size +(def .public size (All (_ a) (-> (PList a) Nat)) list.size) -(def: .public empty? +(def .public empty? (All (_ a) (-> (PList a) Bit)) (|>> ..size (n.= 0))) -(def: .public (value key properties) +(def .public (value key properties) (All (_ a) (-> Text (PList a) (Maybe a))) (case properties {.#End} @@ -43,7 +43,7 @@ (value key properties')))) (with_template [<name> <type> <access>] - [(def: .public <name> + [(def .public <name> (All (_ a) (-> (PList a) (List <type>))) (list#each <access>))] @@ -51,7 +51,7 @@ [values a product.right] ) -(def: .public (contains? key properties) +(def .public (contains? key properties) (All (_ a) (-> Text (PList a) Bit)) (case (..value key properties) {.#Some _} @@ -60,7 +60,7 @@ {.#None} false)) -(def: .public (has key val properties) +(def .public (has key val properties) (All (_ a) (-> Text a (PList a) (PList a))) (case properties {.#End} @@ -73,7 +73,7 @@ {.#Item [k' v'] (has key val properties')}))) -(def: .public (revised key f properties) +(def .public (revised key f properties) (All (_ a) (-> Text (-> a a) (PList a) (PList a))) (case properties {.#End} @@ -84,7 +84,7 @@ {.#Item [k' (f v')] properties'} {.#Item [k' v'] (revised key f properties')}))) -(def: .public (lacks key properties) +(def .public (lacks key properties) (All (_ a) (-> Text (PList a) (PList a))) (case properties {.#End} @@ -96,10 +96,10 @@ {.#Item [k' v'] (lacks key properties')}))) -(def: .public (equivalence (open "/#[0]")) +(def .public (equivalence (open "/#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (PList a)))) (implementation - (def: (= reference subject) + (def (= reference subject) (and (n.= (list.size reference) (list.size subject)) (list.every? (function (_ [key val]) @@ -109,13 +109,13 @@ (maybe.else false))) subject))))) -(def: .public monoid +(def .public monoid (All (_ a) (Monoid (PList a))) (implementation - (def: identity + (def identity ..empty) - (def: (composite left right) + (def (composite left right) (list#mix (function (_ [key val] it) (..has key val it)) right diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index dec3d00c1..6be267e78 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -23,10 +23,10 @@ ... #End ... {#Item a (List a)}) -(def: .public mix +(def .public mix (Mix List) (implementation - (def: (mix f init xs) + (def (mix f init xs) (case xs {.#End} init @@ -34,7 +34,7 @@ {.#Item x xs'} (mix f (f x init) xs'))))) -(def: .public (mixes f init inputs) +(def .public (mixes f init inputs) (All (_ a b) (-> (-> a b b) b (List a) (List b))) (case inputs {.#End} @@ -43,7 +43,7 @@ {.#Item [head tail]} {.#Item [init (mixes f (f head init) tail)]})) -(def: .public (reversed xs) +(def .public (reversed xs) (All (_ a) (-> (List a) (List a))) (mix (function (_ head tail) @@ -51,7 +51,7 @@ {.#End} xs)) -(def: .public (only keep? xs) +(def .public (only keep? xs) (All (_ a) (-> (Predicate a) (List a) (List a))) (case xs @@ -63,7 +63,7 @@ {.#Item x (only keep? xs')} (only keep? xs')))) -(def: .public (partition satisfies? list) +(def .public (partition satisfies? list) (All (_ a) (-> (Predicate a) (List a) [(List a) (List a)])) (case list {.#End} @@ -75,12 +75,12 @@ [{.#Item head in} out] [in {.#Item head out}])))) -(def: wrong_syntax_error +(def wrong_syntax_error (template (_ <it>) [((`` ("lux in-module" (~~ (static .prelude)) .wrong_syntax_error)) (symbol <it>))])) -(def: .public partial +(def .public partial (macro (_ tokens state) (case (reversed tokens) {.#Item tail heads} @@ -92,7 +92,7 @@ _ {.#Left (wrong_syntax_error ..partial)}))) -(def: .public (pairs xs) +(def .public (pairs xs) (All (_ a) (-> (List a) (Maybe (List [a a])))) (case xs (pattern (partial x1 x2 xs')) @@ -110,7 +110,7 @@ {.#None})) (with_template [<name> <then> <else>] - [(def: .public (<name> n xs) + [(def .public (<name> n xs) (All (_ a) (-> Nat (List a) (List a))) (if (n.> 0 n) @@ -127,7 +127,7 @@ ) (with_template [<name> <then> <else>] - [(def: .public (<name> predicate xs) + [(def .public (<name> predicate xs) (All (_ a) (-> (Predicate a) (List a) (List a))) (case xs @@ -143,7 +143,7 @@ [until (until predicate xs') xs] ) -(def: .public (split_at n xs) +(def .public (split_at n xs) (All (_ a) (-> Nat (List a) [(List a) (List a)])) (case n @@ -156,7 +156,7 @@ (let [[tail rest] (split_at (-- n) xs')] [{.#Item x tail} rest])))) -(def: (split_when' predicate ys xs) +(def (split_when' predicate ys xs) (All (_ a) (-> (Predicate a) (List a) (List a) [(List a) (List a)])) (case xs @@ -168,13 +168,13 @@ [ys xs] (split_when' predicate {.#Item x ys} xs')))) -(def: .public (split_when predicate xs) +(def .public (split_when predicate xs) (All (_ a) (-> (Predicate a) (List a) [(List a) (List a)])) (let [[ys' xs'] (split_when' predicate {.#End} xs)] [(reversed ys') xs'])) -(def: .public (sub size list) +(def .public (sub size list) (All (_ a) (-> Nat (List a) (List (List a)))) (case list {.#End} @@ -184,14 +184,14 @@ (let [[pre post] (split_at size list)] {.#Item pre (sub size post)}))) -(def: .public (repeated n x) +(def .public (repeated n x) (All (_ a) (-> Nat a (List a))) (case n 0 {.#End} _ {.#Item x (repeated (-- n) x)})) -(def: (iterations' f x) +(def (iterations' f x) (All (_ a) (-> (-> a (Maybe a)) a (List a))) (case (f x) @@ -201,7 +201,7 @@ {.#None} (list))) -(def: .public (iterations f x) +(def .public (iterations f x) (All (_ a) (-> (-> a (Maybe a)) a (List a))) (case (f x) @@ -211,7 +211,7 @@ {.#None} (list x))) -(def: .public (one check xs) +(def .public (one check xs) (All (_ a b) (-> (-> a (Maybe b)) (List a) (Maybe b))) (case xs @@ -226,7 +226,7 @@ {.#None} (one check xs')))) -(def: .public (all check xs) +(def .public (all check xs) (All (_ a b) (-> (-> a (Maybe b)) (List a) (List b))) (for @.js @@ -252,7 +252,7 @@ {.#None} (all check xs'))))) -(def: .public (example predicate xs) +(def .public (example predicate xs) (All (_ a) (-> (Predicate a) (List a) (Maybe a))) (..one (function (_ value) @@ -261,7 +261,7 @@ {.#None})) xs)) -(def: .public (interposed sep xs) +(def .public (interposed sep xs) (All (_ a) (-> a (List a) (List a))) (case xs @@ -274,12 +274,12 @@ {.#Item x xs'} (partial x sep (interposed sep xs')))) -(def: .public (size list) +(def .public (size list) (All (_ a) (-> (List a) Nat)) (mix (function (_ _ acc) (n.+ 1 acc)) 0 list)) (with_template [<name> <init> <op>] - [(def: .public (<name> predicate items) + [(def .public (<name> predicate items) (All (_ a) (-> (Predicate a) (List a) Bit)) (case items @@ -294,7 +294,7 @@ [any? #0 or] ) -(def: .public (item i xs) +(def .public (item i xs) (All (_ a) (-> Nat (List a) (Maybe a))) (case xs @@ -306,10 +306,10 @@ 0 {.#Some x} _ (item (-- i) xs')))) -(def: .public (equivalence Equivalence<a>) +(def .public (equivalence Equivalence<a>) (All (_ a) (-> (Equivalence a) (Equivalence (List a)))) (implementation - (def: (= xs ys) + (def (= xs ys) (case [xs ys] [{.#End} {.#End}] #1 @@ -322,24 +322,24 @@ #0 )))) -(def: .public (hash super) +(def .public (hash super) (All (_ a) (-> (Hash a) (Hash (List a)))) (implementation - (def: equivalence + (def equivalence (..equivalence (at super equivalence))) - (def: hash + (def hash (at ..mix mix (function (_ member hash) (n.+ (at super hash member) hash)) 0)))) -(def: .public monoid +(def .public monoid (All (_ a) (Monoid (List a))) (implementation - (def: identity + (def identity {.#End}) - (def: (composite xs ys) + (def (composite xs ys) (case xs {.#End} ys @@ -349,10 +349,10 @@ (open: "[0]" ..monoid) -(def: .public functor +(def .public functor (Functor List) (implementation - (def: (each f ma) + (def (each f ma) (case ma {.#End} {.#End} @@ -362,12 +362,12 @@ (open: "[0]" ..functor) -(def: .public apply +(def .public apply (Apply List) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (case ff {.#End} {.#End} @@ -377,18 +377,18 @@ (on fa) (composite (each f fa))))))) -(def: .public monad +(def .public monad (Monad List) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) {.#Item a {.#End}}) - (def: conjoint + (def conjoint (|>> reversed (mix composite identity))))) -(def: .public (sorted < xs) +(def .public (sorted < xs) (All (_ a) (-> (-> a a Bit) (List a) (List a))) (case xs {.#End} @@ -406,7 +406,7 @@ xs')] (.all composite (sorted < pre) (list x) (sorted < post))))) -(def: .public (empty? xs) +(def .public (empty? xs) (All (_ a) (Predicate (List a))) (case xs {.#End} @@ -415,7 +415,7 @@ _ false)) -(def: .public (member? eq xs x) +(def .public (member? eq xs x) (All (_ a) (-> (Equivalence a) (List a) a Bit)) (case xs {.#End} @@ -426,7 +426,7 @@ (member? eq xs' x)))) (with_template [<name> <output> <side>] - [(def: .public (<name> xs) + [(def .public (<name> xs) (All (_ a) (-> (List a) (Maybe <output>))) (case xs {.#End} @@ -439,17 +439,17 @@ [tail (List a) xs'] ) -(def: .public (indices size) +(def .public (indices size) (All (_ a) (-> Nat (List Nat))) (case size 0 (list) _ (|> size -- (enum.range n.enum 0)))) -(def: (symbol$ name) +(def (symbol$ name) (-> Text Code) [["" 0 0] {.#Symbol "" name}]) -(def: (nat#encoded value) +(def (nat#encoded value) (-> Nat Text) (loop (again [input value output ""]) @@ -471,7 +471,7 @@ 0 output' _ (again input' output'))))) -(def: .public zipped +(def .public zipped (macro (_ tokens state) (case tokens (pattern (list [_ {.#Nat num_lists}])) @@ -509,10 +509,10 @@ _ {.#Left (wrong_syntax_error ..zipped)}))) -(def: .public zipped_2 (zipped 2)) -(def: .public zipped_3 (zipped 3)) +(def .public zipped_2 (zipped 2)) +(def .public zipped_3 (zipped 3)) -(def: .public zipped_with +(def .public zipped_with (macro (_ tokens state) (case tokens (pattern (list [_ {.#Nat num_lists}])) @@ -553,10 +553,10 @@ _ {.#Left (wrong_syntax_error ..zipped_with)}))) -(def: .public zipped_with_2 (zipped_with 2)) -(def: .public zipped_with_3 (zipped_with 3)) +(def .public zipped_with_2 (zipped_with 2)) +(def .public zipped_with_3 (zipped_with 3)) -(def: .public (last xs) +(def .public (last xs) (All (_ a) (-> (List a) (Maybe a))) (case xs {.#End} @@ -568,7 +568,7 @@ {.#Item x xs'} (last xs'))) -(def: .public (inits xs) +(def .public (inits xs) (All (_ a) (-> (List a) (Maybe (List a)))) (case xs {.#End} @@ -586,21 +586,21 @@ {.#Some {.#Item x tail}}) )) -(def: .public together +(def .public together (All (_ a) (-> (List (List a)) (List a))) (at ..monad conjoint)) -(def: .public (with monad) +(def .public (with monad) (All (_ M) (-> (Monad M) (Monad (All (_ a) (M (List a)))))) (implementation - (def: functor + (def functor (functor.composite (the monad.functor monad) ..functor)) - (def: in + (def in (|>> (at ..monad in) (at monad in))) - (def: (conjoint MlMla) + (def (conjoint MlMla) (do [! monad] [lMla MlMla ... TODO: Remove this version ASAP and use one below. @@ -610,11 +610,11 @@ (monad.all ! lMla))] (in (..together lla)))))) -(def: .public (lifted monad) +(def .public (lifted monad) (All (_ M a) (-> (Monad M) (-> (M a) (M (List a))))) (at monad each (at ..monad in))) -(def: .public (enumeration xs) +(def .public (enumeration xs) (All (_ a) (-> (List a) (List [Nat a]))) (loop (again [idx 0 xs xs]) @@ -625,7 +625,7 @@ {.#Item x xs'} {.#Item [idx x] (again (++ idx) xs')}))) -(def: .public when +(def .public when (macro (_ tokens state) (case tokens (pattern (.list test then)) @@ -636,7 +636,7 @@ _ {.#Left (wrong_syntax_error ..when)}))) -(def: .public (revised item revision it) +(def .public (revised item revision it) (All (_ a) (-> Nat (-> a a) (List a) (List a))) (case it {.#End} diff --git a/stdlib/source/library/lux/data/collection/queue.lux b/stdlib/source/library/lux/data/collection/queue.lux index d6d421304..54c1024b6 100644 --- a/stdlib/source/library/lux/data/collection/queue.lux +++ b/stdlib/source/library/lux/data/collection/queue.lux @@ -16,42 +16,42 @@ [#front (List a) #rear (List a)])) -(def: .public empty +(def .public empty Queue [#front (.list) #rear (.list)]) -(def: .public (of_list entries) +(def .public (of_list entries) (All (_ a) (-> (List a) (Queue a))) [#front entries #rear (.list)]) -(def: .public (list queue) +(def .public (list queue) (All (_ a) (-> (Queue a) (List a))) (let [(open "_[0]") queue] (list#composite _#front (list.reversed _#rear)))) -(def: .public front +(def .public front (All (_ a) (-> (Queue a) (Maybe a))) (|>> (the #front) list.head)) -(def: .public (size queue) +(def .public (size queue) (All (_ a) (-> (Queue a) Nat)) (let [(open "_[0]") queue] (n.+ (list.size _#front) (list.size _#rear)))) -(def: .public empty? +(def .public empty? (All (_ a) (-> (Queue a) Bit)) (|>> (the #front) list.empty?)) -(def: .public (member? equivalence queue member) +(def .public (member? equivalence queue member) (All (_ a) (-> (Equivalence a) (Queue a) a Bit)) (let [(open "_[0]") queue] (or (list.member? equivalence _#front member) (list.member? equivalence _#rear member)))) -(def: .public (next queue) +(def .public (next queue) (All (_ a) (-> (Queue a) (Queue a))) (case (the #front queue) ... Empty... @@ -69,7 +69,7 @@ (|> queue (has #front front')))) -(def: .public (end val queue) +(def .public (end val queue) (All (_ a) (-> a (Queue a) (Queue a))) (case (the #front queue) {.#End} @@ -78,17 +78,17 @@ _ (revised #rear (|>> {.#Item val}) queue))) -(def: .public (equivalence super) +(def .public (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (Queue a)))) (implementation - (def: (= reference subject) + (def (= reference subject) (at (list.equivalence super) = (..list reference) (..list subject))))) -(def: .public functor +(def .public functor (Functor Queue) (implementation - (def: (each f fa) + (def (each f fa) [#front (|> fa (the #front) (list#each f)) #rear (|> fa (the #rear) (list#each f))]))) diff --git a/stdlib/source/library/lux/data/collection/queue/priority.lux b/stdlib/source/library/lux/data/collection/queue/priority.lux index e3016e239..30cc94613 100644 --- a/stdlib/source/library/lux/data/collection/queue/priority.lux +++ b/stdlib/source/library/lux/data/collection/queue/priority.lux @@ -19,18 +19,18 @@ (type: .public Priority Nat) -(def: .public max +(def .public max Priority n#top) -(def: .public min +(def .public min Priority n#bottom) -(def: builder +(def builder (tree.builder n.maximum)) -(def: :@: +(def :@: (by_example [@] (is (tree.Builder @ Priority) ..builder) @@ -39,18 +39,18 @@ (primitive .public (Queue a) (Maybe (Tree :@: Priority a)) - (def: .public empty + (def .public empty Queue (abstraction {.#None})) - (def: .public (front queue) + (def .public (front queue) (All (_ a) (-> (Queue a) (Maybe a))) (do maybe.monad [tree (representation queue)] (tree.one (n.= (tree.tag tree)) tree))) - (def: .public (size queue) + (def .public (size queue) (All (_ a) (-> (Queue a) Nat)) (case (representation queue) {.#None} @@ -65,7 +65,7 @@ {0 #1 [left right]} (n.+ (again left) (again right)))))) - (def: .public (member? equivalence queue member) + (def .public (member? equivalence queue member) (All (_ a) (-> (Equivalence a) (Queue a) a Bit)) (case (representation queue) {.#None} @@ -81,7 +81,7 @@ (or (again left) (again right)))))) - (def: .public (next queue) + (def .public (next queue) (All (_ a) (-> (Queue a) (Queue a))) (abstraction (do maybe.monad @@ -109,7 +109,7 @@ {.#Some =right} {.#Some (at ..builder branch left =right)}))))))) - (def: .public (end priority value queue) + (def .public (end priority value queue) (All (_ a) (-> Priority a (Queue a) (Queue a))) (let [addition (at ..builder leaf priority value)] (abstraction @@ -121,6 +121,6 @@ {.#Some (at ..builder branch tree addition)})))) ) -(def: .public empty? +(def .public empty? (All (_ a) (-> (Queue a) Bit)) (|>> ..size (n.= 0))) diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index bae056369..da7ea73c1 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -51,16 +51,16 @@ (type: Index Nat) -(def: branching_exponent +(def branching_exponent Nat 5) -(def: root_level +(def root_level Level 0) (with_template [<name> <op>] - [(def: <name> + [(def <name> (-> Level Level) (<op> branching_exponent))] @@ -68,23 +68,23 @@ [level_down n.-] ) -(def: full_node_size +(def full_node_size Nat (i64.left_shifted branching_exponent 1)) -(def: branch_idx_mask +(def branch_idx_mask Nat (-- full_node_size)) -(def: branch_idx +(def branch_idx (-> Index Index) (i64.and branch_idx_mask)) -(def: (empty_hierarchy _) +(def (empty_hierarchy _) (All (_ a) (-> Any (Hierarchy a))) (array.empty ..full_node_size)) -(def: (tail_off sequence_size) +(def (tail_off sequence_size) (-> Nat Nat) (if (n.< full_node_size sequence_size) 0 @@ -92,7 +92,7 @@ (i64.right_shifted branching_exponent) (i64.left_shifted branching_exponent)))) -(def: (path level tail) +(def (path level tail) (All (_ a) (-> Level (Base a) (Node a))) (if (n.= 0 level) {#Base tail} @@ -100,12 +100,12 @@ (array.has! 0 (path (level_down level) tail)) {#Hierarchy}))) -(def: (tail singleton) +(def (tail singleton) (All (_ a) (-> a (Base a))) (|> (array.empty 1) (array.has! 0 singleton))) -(def: (with_tail size level tail parent) +(def (with_tail size level tail parent) (All (_ a) (-> Nat Level (Base a) (Hierarchy a) (Hierarchy a))) (let [sub_idx (branch_idx (i64.right_shifted level (-- size))) ... If we're currently on a bottom node @@ -126,14 +126,14 @@ (|> (array.clone parent) (array.has! sub_idx sub_node)))) -(def: (expanded_tail val tail) +(def (expanded_tail val tail) (All (_ a) (-> a (Base a) (Base a))) (let [tail_size (array.size tail)] (|> (array.empty (++ tail_size)) (array.copy! tail_size 0 tail 0) (array.has! tail_size val)))) -(def: (hierarchy#has level idx val hierarchy) +(def (hierarchy#has level idx val hierarchy) (All (_ a) (-> Level Index a (Hierarchy a) (Hierarchy a))) (let [sub_idx (branch_idx (i64.right_shifted level idx))] (case (array.item sub_idx hierarchy) @@ -151,7 +151,7 @@ _ (undefined)))) -(def: (without_tail size level hierarchy) +(def (without_tail size level hierarchy) (All (_ a) (-> Nat Level (Hierarchy a) (Maybe (Hierarchy a)))) (let [sub_idx (branch_idx (i64.right_shifted level (n.- 2 size)))] (cond (n.= 0 sub_idx) @@ -176,7 +176,7 @@ {.#Some}) ))) -(def: (node#list node) +(def (node#list node) (All (_ a) (-> (Node a) (List a))) (case node {#Base base} @@ -197,18 +197,18 @@ #root (Hierarchy a) #tail (Base a)])) -(def: .public empty +(def .public empty Sequence [#level (level_up root_level) #size 0 #root (empty_hierarchy []) #tail (array.empty 0)]) -(def: .public (size sequence) +(def .public (size sequence) (All (_ a) (-> (Sequence a) Nat)) (the #size sequence)) -(def: .public (suffix val sequence) +(def .public (suffix val sequence) (All (_ a) (-> a (Sequence a) (Sequence a))) ... Check if there is room in the tail. (let [sequence_size (the #size sequence)] @@ -249,11 +249,11 @@ (exception: base_was_not_found) -(def: .public (within_bounds? sequence idx) +(def .public (within_bounds? sequence idx) (All (_ a) (-> (Sequence a) Nat Bit)) (n.< (the #size sequence) idx)) -(def: (base_for idx sequence) +(def (base_for idx sequence) (All (_ a) (-> Index (Sequence a) (Try (Base a)))) (if (within_bounds? sequence idx) (if (n.< (tail_off (the #size sequence)) idx) @@ -275,7 +275,7 @@ {try.#Success (the #tail sequence)}) (exception.except ..index_out_of_bounds [sequence idx]))) -(def: .public (item idx sequence) +(def .public (item idx sequence) (All (_ a) (-> Nat (Sequence a) (Try a))) (do try.monad [base (base_for idx sequence) @@ -284,7 +284,7 @@ (exception.except ..incorrect_sequence_structure []) {try.#Success (array.item index base)}))) -(def: .public (has idx val sequence) +(def .public (has idx val sequence) (All (_ a) (-> Nat a (Sequence a) (Try (Sequence a)))) (let [sequence_size (the #size sequence)] (if (within_bounds? sequence idx) @@ -297,13 +297,13 @@ sequence))} (exception.except ..index_out_of_bounds [sequence idx])))) -(def: .public (revised idx revision it) +(def .public (revised idx revision it) (All (_ a) (-> Nat (-> a a) (Sequence a) (Try (Sequence a)))) (do try.monad [val (..item idx it)] (..has idx (revision val) it))) -(def: .public (prefix sequence) +(def .public (prefix sequence) (All (_ a) (-> (Sequence a) (Sequence a))) (case (the #size sequence) 0 @@ -348,31 +348,31 @@ (.has #tail new_tail)))))) )) -(def: .public (list sequence) +(def .public (list sequence) (All (_ a) (-> (Sequence a) (List a))) (list#composite (node#list {#Hierarchy (the #root sequence)}) (node#list {#Base (the #tail sequence)}))) -(def: .public of_list +(def .public of_list (All (_ a) (-> (List a) (Sequence a))) (list#mix ..suffix ..empty)) -(def: .public (member? equivalence sequence val) +(def .public (member? equivalence sequence val) (All (_ a) (-> (Equivalence a) (Sequence a) a Bit)) (list.member? equivalence (list sequence) val)) -(def: .public empty? +(def .public empty? (All (_ a) (-> (Sequence a) Bit)) (|>> (the #size) (n.= 0))) -(def: .public sequence +(def .public sequence (syntax (_ [elems (<>.some <code>.any)]) (in (.list (` (..of_list (.list (~+ elems)))))))) -(def: (node_equivalence //#=) +(def (node_equivalence //#=) (All (_ a) (-> (Equivalence a) (Equivalence (Node a)))) (implementation - (def: (= v1 v2) + (def (= v1 v2) (case [v1 v2] [{#Base b1} {#Base b2}] (array.= //#= b1 b2) @@ -383,10 +383,10 @@ _ #0)))) -(def: .public (equivalence //#=) +(def .public (equivalence //#=) (All (_ a) (-> (Equivalence a) (Equivalence (Sequence a)))) (implementation - (def: (= v1 v2) + (def (= v1 v2) (and (n.= (the #size v1) (the #size v2)) (let [(open "node#[0]") (node_equivalence //#=)] (and (node#= {#Base (the #tail v1)} @@ -394,10 +394,10 @@ (node#= {#Hierarchy (the #root v1)} {#Hierarchy (the #root v2)}))))))) -(def: node_mix +(def node_mix (Mix Node) (implementation - (def: (mix $ init xs) + (def (mix $ init xs) (case xs {#Base base} (array.mix (function (_ _ item output) ($ item output)) @@ -409,10 +409,10 @@ init hierarchy))))) -(def: .public mix +(def .public mix (Mix Sequence) (implementation - (def: (mix $ init xs) + (def (mix $ init xs) (let [(open "[0]") node_mix] (mix $ (mix $ @@ -420,18 +420,18 @@ {#Hierarchy (the #root xs)}) {#Base (the #tail xs)}))))) -(def: .public monoid +(def .public monoid (All (_ a) (Monoid (Sequence a))) (implementation - (def: identity ..empty) + (def identity ..empty) - (def: (composite xs ys) + (def (composite xs ys) (list#mix suffix xs (..list ys))))) -(def: node_functor +(def node_functor (Functor Node) (implementation - (def: (each $ xs) + (def (each $ xs) (case xs {#Base base} {#Base (array.each $ base)} @@ -439,10 +439,10 @@ {#Hierarchy hierarchy} {#Hierarchy (array.each (each $) hierarchy)})))) -(def: .public functor +(def .public functor (Functor Sequence) (implementation - (def: (each $ xs) + (def (each $ xs) [#level (the #level xs) #size (the #size xs) #root (let [ ... TODO: This binding was established to get around a compilation error. Fix and inline! @@ -450,12 +450,12 @@ (|> xs (the #root) (array.each $))) #tail (|> xs (the #tail) (array.each $))]))) -(def: .public apply +(def .public apply (Apply Sequence) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (let [(open "[0]") ..functor (open "[0]") ..mix (open "[0]") ..monoid @@ -463,27 +463,27 @@ ff)] (mix composite identity results))))) -(def: .public monad +(def .public monad (Monad Sequence) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: in + (def in (|>> sequence)) - (def: conjoint + (def conjoint (let [(open "[0]") ..mix (open "[0]") ..monoid] (mix (function (_ post pre) (composite pre post)) identity))))) -(def: .public reversed +(def .public reversed (All (_ a) (-> (Sequence a) (Sequence a))) (|>> ..list list.reversed (list#mix suffix ..empty))) (with_template [<name> <array> <init> <op>] - [(def: .public <name> + [(def .public <name> (All (_ a) (-> (Predicate a) (Sequence a) Bit)) (let [help (is (All (_ a) @@ -504,7 +504,7 @@ [any? array.any? #0 or] ) -(def: .public (only when items) +(def .public (only when items) (All (_ a) (-> (-> a Bit) (Sequence a) (Sequence a))) (..mix (function (_ item output) (if (when item) @@ -513,7 +513,7 @@ ..empty items)) -(def: (one|node check items) +(def (one|node check items) (All (_ a b) (-> (-> a (Maybe b)) (Node a) (Maybe b))) (case items @@ -523,7 +523,7 @@ {#Hierarchy items} (array.one (one|node check) items))) -(def: .public (one check items) +(def .public (one check items) (All (_ a b) (-> (-> a (Maybe b)) (Sequence a) (Maybe b))) (case (let [... TODO: This binding was established to get around a compilation error. Fix and inline! diff --git a/stdlib/source/library/lux/data/collection/set.lux b/stdlib/source/library/lux/data/collection/set.lux index 138d5c351..fd2e32815 100644 --- a/stdlib/source/library/lux/data/collection/set.lux +++ b/stdlib/source/library/lux/data/collection/set.lux @@ -20,88 +20,88 @@ (type: .public (Set a) (Dictionary a Any)) -(def: .public member_hash +(def .public member_hash (All (_ a) (-> (Set a) (Hash a))) //.key_hash) -(def: .public empty +(def .public empty (All (_ a) (-> (Hash a) (Set a))) //.empty) -(def: .public size +(def .public size (All (_ a) (-> (Set a) Nat)) //.size) -(def: .public (has elem set) +(def .public (has elem set) (All (_ a) (-> a (Set a) (Set a))) (|> set (//.has elem []))) -(def: .public lacks +(def .public lacks (All (_ a) (-> a (Set a) (Set a))) //.lacks) -(def: .public member? +(def .public member? (All (_ a) (-> (Set a) a Bit)) //.key?) -(def: .public list +(def .public list (All (_ a) (-> (Set a) (List a))) //.keys) -(def: .public union +(def .public union (All (_ a) (-> (Set a) (Set a) (Set a))) //.composite) -(def: .public (difference sub base) +(def .public (difference sub base) (All (_ a) (-> (Set a) (Set a) (Set a))) (list#mix ..lacks base (..list sub))) -(def: .public (intersection filter base) +(def .public (intersection filter base) (All (_ a) (-> (Set a) (Set a) (Set a))) (//.sub (//.keys filter) base)) -(def: .public equivalence +(def .public equivalence (All (_ a) (Equivalence (Set a))) (implementation - (def: (= (^.let reference [hash _]) sample) + (def (= (^.let reference [hash _]) sample) (and (n.= (..size reference) (..size sample)) (list.every? (..member? reference) (..list sample)))))) -(def: .public hash +(def .public hash (All (_ a) (Hash (Set a))) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (hash set) + (def (hash set) (|> set ..list (at (list.hash (..member_hash set)) hash))))) -(def: .public (monoid hash) +(def .public (monoid hash) (All (_ a) (-> (Hash a) (Monoid (Set a)))) (implementation - (def: identity (..empty hash)) - (def: composite ..union))) + (def identity (..empty hash)) + (def composite ..union))) -(def: .public empty? +(def .public empty? (All (_ a) (-> (Set a) Bit)) (|>> ..size (n.= 0))) -(def: .public (of_list hash elements) +(def .public (of_list hash elements) (All (_ a) (-> (Hash a) (List a) (Set a))) (list#mix ..has (..empty hash) elements)) -(def: .public (sub? super sub) +(def .public (sub? super sub) (All (_ a) (-> (Set a) (Set a) Bit)) (list.every? (..member? super) (..list sub))) -(def: .public (super? sub super) +(def .public (super? sub super) (All (_ a) (-> (Set a) (Set a) Bit)) (..sub? super sub)) -(def: .public predicate +(def .public predicate (All (_ a) (-> (Set a) (Predicate a))) ..member?) diff --git a/stdlib/source/library/lux/data/collection/set/multi.lux b/stdlib/source/library/lux/data/collection/set/multi.lux index 3e63b2926..72e1e1620 100644 --- a/stdlib/source/library/lux/data/collection/set/multi.lux +++ b/stdlib/source/library/lux/data/collection/set/multi.lux @@ -23,15 +23,15 @@ (primitive .public (Set a) (Dictionary a Nat) - (def: .public empty + (def .public empty (All (_ a) (-> (Hash a) (Set a))) (|>> dictionary.empty abstraction)) - (def: .public size + (def .public size (All (_ a) (-> (Set a) Nat)) (|>> representation dictionary.values (list#mix n.+ 0))) - (def: .public (has multiplicity elem set) + (def .public (has multiplicity elem set) (All (_ a) (-> Nat a (Set a) (Set a))) (case multiplicity 0 set @@ -40,7 +40,7 @@ (dictionary.revised' elem 0 (n.+ multiplicity)) abstraction))) - (def: .public (lacks multiplicity elem set) + (def .public (lacks multiplicity elem set) (All (_ a) (-> Nat a (Set a) (Set a))) (case multiplicity 0 set @@ -54,11 +54,11 @@ {.#None} set))) - (def: .public (multiplicity set elem) + (def .public (multiplicity set elem) (All (_ a) (-> (Set a) a Nat)) (|> set representation (dictionary.value elem) (maybe.else 0))) - (def: .public list + (def .public list (All (_ a) (-> (Set a) (List a))) (|>> representation dictionary.entries @@ -67,7 +67,7 @@ {.#End}))) (with_template [<name> <composite>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (All (_ a) (-> (Set a) (Set a) (Set a))) (abstraction (dictionary.composite_with <composite> (representation parameter) (representation subject))))] @@ -75,7 +75,7 @@ [sum n.+] ) - (def: .public (intersection parameter subject) + (def .public (intersection parameter subject) (All (_ a) (-> (Set a) (Set a) (Set a))) (let [subject (representation subject)] (list#mix (function (_ [elem multiplicity] output) @@ -86,7 +86,7 @@ (..empty (dictionary.key_hash subject)) (dictionary.entries subject)))) - (def: .public (difference parameter subject) + (def .public (difference parameter subject) (All (_ a) (-> (Set a) (Set a) (Set a))) (|> parameter representation @@ -95,7 +95,7 @@ (..lacks multiplicity elem output)) subject))) - (def: .public (sub? reference subject) + (def .public (sub? reference subject) (All (_ a) (-> (Set a) (Set a) Bit)) (|> subject representation @@ -105,17 +105,17 @@ (..multiplicity reference) (n.>= multiplicity)))))) - (def: .public (support set) + (def .public (support set) (All (_ a) (-> (Set a) (//.Set a))) (let [(^.let set [hash _]) (representation set)] (|> set dictionary.keys (//.of_list hash)))) - (def: .public equivalence + (def .public equivalence (All (_ a) (Equivalence (Set a))) (implementation - (def: (= reference sample) + (def (= reference sample) (let [reference (representation reference)] (and (n.= (dictionary.size reference) (dictionary.size (representation sample))) @@ -126,12 +126,12 @@ (..multiplicity sample) (n.= multiplicity)))))))))) - (def: .public hash + (def .public hash (All (_ a) (Hash (Set a))) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (hash set) + (def (hash set) (let [set (representation set) [hash _] set] (list#mix (function (_ [elem multiplicity] acc) @@ -140,23 +140,23 @@ (dictionary.entries set)))))) ) -(def: .public (member? set elem) +(def .public (member? set elem) (All (_ a) (-> (Set a) a Bit)) (|> elem (..multiplicity set) (n.> 0))) -(def: .public empty? +(def .public empty? (All (_ a) (-> (Set a) Bit)) (|>> ..size (n.= 0))) -(def: .public (of_list hash subject) +(def .public (of_list hash subject) (All (_ a) (-> (Hash a) (List a) (Set a))) (list#mix (..has 1) (..empty hash) subject)) -(def: .public (of_set subject) +(def .public (of_set subject) (All (_ a) (-> (//.Set a) (Set a))) (..of_list (//.member_hash subject) (//.list subject))) -(def: .public super? +(def .public super? (All (_ a) (-> (Set a) (Set a) Bit)) (function.flipped sub?)) diff --git a/stdlib/source/library/lux/data/collection/set/ordered.lux b/stdlib/source/library/lux/data/collection/set/ordered.lux index c876afca0..5cdd23dec 100644 --- a/stdlib/source/library/lux/data/collection/set/ordered.lux +++ b/stdlib/source/library/lux/data/collection/set/ordered.lux @@ -15,16 +15,16 @@ (primitive .public (Set a) (/.Dictionary a a) - (def: .public empty + (def .public empty (All (_ a) (-> (Order a) (Set a))) (|>> /.empty abstraction)) - (def: .public (member? set elem) + (def .public (member? set elem) (All (_ a) (-> (Set a) a Bit)) (/.key? (representation set) elem)) (with_template [<type> <name> <alias>] - [(def: .public <name> + [(def .public <name> (All (_ a) (-> (Set a) <type>)) (|>> representation <alias>))] @@ -34,52 +34,52 @@ [Bit empty? /.empty?] ) - (def: .public (has elem set) + (def .public (has elem set) (All (_ a) (-> a (Set a) (Set a))) (|> set representation (/.has elem elem) abstraction)) - (def: .public (lacks elem set) + (def .public (lacks elem set) (All (_ a) (-> a (Set a) (Set a))) (|> set representation (/.lacks elem) abstraction)) - (def: .public list + (def .public list (All (_ a) (-> (Set a) (List a))) (|>> representation /.keys)) - (def: .public (of_list order list) + (def .public (of_list order list) (All (_ a) (-> (Order a) (List a) (Set a))) (list#mix has (..empty order) list)) - (def: .public (union left right) + (def .public (union left right) (All (_ a) (-> (Set a) (Set a) (Set a))) (list#mix ..has right (..list left))) - (def: .public (intersection left right) + (def .public (intersection left right) (All (_ a) (-> (Set a) (Set a) (Set a))) (|> (..list right) (list.only (..member? left)) (..of_list (the /.#order (representation right))))) - (def: .public (difference param subject) + (def .public (difference param subject) (All (_ a) (-> (Set a) (Set a) (Set a))) (|> (..list subject) (list.only (|>> (..member? param) not)) (..of_list (the /.#order (representation subject))))) - (def: .public equivalence + (def .public equivalence (All (_ a) (Equivalence (Set a))) (implementation - (def: (= reference sample) + (def (= reference sample) (at (list.equivalence (at (representation reference) equivalence)) = (..list reference) (..list sample))))) ) -(def: .public (sub? super sub) +(def .public (sub? super sub) (All (_ a) (-> (Set a) (Set a) Bit)) (|> sub ..list (list.every? (..member? super)))) -(def: .public (super? sub super) +(def .public (super? sub super) (All (_ a) (-> (Set a) (Set a) Bit)) (sub? super sub)) diff --git a/stdlib/source/library/lux/data/collection/stack.lux b/stdlib/source/library/lux/data/collection/stack.lux index 086b727ca..5a7f19904 100644 --- a/stdlib/source/library/lux/data/collection/stack.lux +++ b/stdlib/source/library/lux/data/collection/stack.lux @@ -13,19 +13,19 @@ (primitive .public (Stack a) (List a) - (def: .public empty + (def .public empty Stack (abstraction (list))) - (def: .public size + (def .public size (All (_ a) (-> (Stack a) Nat)) (|>> representation //.size)) - (def: .public empty? + (def .public empty? (All (_ a) (-> (Stack a) Bit)) (|>> representation //.empty?)) - (def: .public (value stack) + (def .public (value stack) (All (_ a) (-> (Stack a) (Maybe a))) (case (representation stack) {.#End} @@ -34,7 +34,7 @@ {.#Item value _} {.#Some value})) - (def: .public (next stack) + (def .public (next stack) (All (_ a) (-> (Stack a) (Maybe [a (Stack a)]))) (case (representation stack) {.#End} @@ -43,22 +43,22 @@ {.#Item top stack'} {.#Some [top (abstraction stack')]})) - (def: .public (top value stack) + (def .public (top value stack) (All (_ a) (-> a (Stack a) (Stack a))) (abstraction {.#Item value (representation stack)})) - (def: .public (equivalence super) + (def .public (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (Stack a)))) (implementation - (def: (= reference subject) + (def (= reference subject) (at (//.equivalence super) = (representation reference) (representation subject))))) - (def: .public functor + (def .public functor (Functor Stack) (implementation - (def: (each f value) + (def (each f value) (|> value representation (at //.functor each f) diff --git a/stdlib/source/library/lux/data/collection/stream.lux b/stdlib/source/library/lux/data/collection/stream.lux index f2f45add6..29b789e09 100644 --- a/stdlib/source/library/lux/data/collection/stream.lux +++ b/stdlib/source/library/lux/data/collection/stream.lux @@ -22,18 +22,18 @@ (type: .public (Stream a) (Cont [a (Stream a)])) -(def: .public (iterations step init) +(def .public (iterations step init) (All (_ a b) (-> (-> a [a b]) a (Stream b))) (let [[next x] (step init)] (//.pending [x (iterations step next)]))) -(def: .public (repeated x) +(def .public (repeated x) (All (_ a) (-> a (Stream a))) (//.pending [x (repeated x)])) -(def: .public (cycle [start next]) +(def .public (cycle [start next]) (All (_ a) (-> [a (List a)] (Stream a))) (loop (again [head start @@ -46,7 +46,7 @@ (again head' tail'))]))) (with_template [<name> <return>] - [(def: .public (<name> stream) + [(def .public (<name> stream) (All (_ a) (-> (Stream a) <return>)) (let [[head tail] (//.result stream)] <name>))] @@ -55,7 +55,7 @@ [tail (Stream a)] ) -(def: .public (item idx stream) +(def .public (item idx stream) (All (_ a) (-> Nat (Stream a) a)) (let [[head tail] (//.result stream)] (case idx @@ -63,7 +63,7 @@ _ (item (-- idx) tail)))) (with_template [<taker> <dropper> <pred_type> <pred_test> <pred_step> <post_test>] - [(def: .public (<taker> pred xs) + [(def .public (<taker> pred xs) (All (_ a) (-> <pred_type> (Stream a) (List a))) (let [[x xs'] (//.result xs)] @@ -71,7 +71,7 @@ (list.partial x (<taker> <pred_step> xs')) (list)))) - (def: .public (<dropper> pred xs) + (def .public (<dropper> pred xs) (All (_ a) (-> <pred_type> (Stream a) (Stream a))) (let [[x xs'] (//.result xs)] @@ -84,7 +84,7 @@ ) (with_template [<splitter> <pred_type> <pred_test> <pred_step>] - [(def: .public (<splitter> pred xs) + [(def .public (<splitter> pred xs) (All (_ a) (-> <pred_type> (Stream a) [(List a) (Stream a)])) (let [[x xs'] (//.result xs)] @@ -97,37 +97,37 @@ [split_at Nat (n.= 0 pred) (-- pred)] ) -(def: .public (only predicate stream) +(def .public (only predicate stream) (All (_ a) (-> (-> a Bit) (Stream a) (Stream a))) (let [[head tail] (//.result stream)] (if (predicate head) (//.pending [head (only predicate tail)]) (only predicate tail)))) -(def: .public (partition left? xs) +(def .public (partition left? xs) (All (_ a) (-> (-> a Bit) (Stream a) [(Stream a) (Stream a)])) [(..only left? xs) (..only (bit.complement left?) xs)]) -(def: .public functor +(def .public functor (Functor Stream) (implementation - (def: (each f fa) + (def (each f fa) (let [[head tail] (//.result fa)] (//.pending [(f head) (each f tail)]))))) -(def: .public comonad +(def .public comonad (CoMonad Stream) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: out head) + (def out head) - (def: (disjoint wa) + (def (disjoint wa) (let [[head tail] (//.result wa)] (//.pending [wa (disjoint tail)]))))) -(def: .public pattern +(def .public pattern (syntax (_ [patterns (<code>.form (<>.many <code>.any)) body <code>.any branches (<>.some <code>.any)]) diff --git a/stdlib/source/library/lux/data/collection/tree.lux b/stdlib/source/library/lux/data/collection/tree.lux index 64b0d13f7..d1f9d46ba 100644 --- a/stdlib/source/library/lux/data/collection/tree.lux +++ b/stdlib/source/library/lux/data/collection/tree.lux @@ -21,7 +21,7 @@ [#value a #children (List (Tree a))])) -(def: .public (flat tree) +(def .public (flat tree) (All (_ a) (-> (Tree a) (List a))) (|> tree (the #children) @@ -29,12 +29,12 @@ list#conjoint {.#Item (the #value tree)})) -(def: .public (leaf value) +(def .public (leaf value) (All (_ a) (-> a (Tree a))) [#value value #children (list)]) -(def: .public (branch value children) +(def .public (branch value children) (All (_ a) (-> a (List (Tree a)) (Tree a))) [#value value #children children]) @@ -43,7 +43,7 @@ (Rec Tree_Code [Code (List Tree_Code)])) -(def: tree^ +(def tree^ (Parser Tree_Code) (|> (|>> <>.some <code>.variant @@ -54,31 +54,31 @@ (<>.else (list)) (<>.and <code>.any))) -(def: .public tree +(def .public tree (syntax (_ [root tree^]) (in (list (loop (again [[value children] root]) (` [#value (~ value) #children (list (~+ (list#each again children)))])))))) -(def: .public (equivalence super) +(def .public (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (Tree a)))) (implementation - (def: (= tx ty) + (def (= tx ty) (and (at super = (the #value tx) (the #value ty)) (at (list.equivalence (equivalence super)) = (the #children tx) (the #children ty)))))) -(def: .public functor +(def .public functor (Functor Tree) (implementation - (def: (each f fa) + (def (each f fa) [#value (f (the #value fa)) #children (list#each (each f) (the #children fa))]))) -(def: .public mix +(def .public mix (Mix Tree) (implementation - (def: (mix f init tree) + (def (mix f init tree) (list#mix (function (_ tree' init') (mix f init' tree')) (f (the #value tree) init) diff --git a/stdlib/source/library/lux/data/collection/tree/finger.lux b/stdlib/source/library/lux/data/collection/tree/finger.lux index 0d8527308..3046509d3 100644 --- a/stdlib/source/library/lux/data/collection/tree/finger.lux +++ b/stdlib/source/library/lux/data/collection/tree/finger.lux @@ -30,7 +30,7 @@ branch))) (with_template [<name> <tag> <output>] - [(def: .public <name> + [(def .public <name> (All (_ @ t v) (-> (Tree @ t v) <output>)) (|>> representation (the <tag>)))] @@ -38,22 +38,22 @@ [root #root (Either v [(Tree @ t v) (Tree @ t v)])] ) - (def: .public (builder monoid) + (def .public (builder monoid) (All (_ t) (Ex (_ @) (-> (Monoid t) (Builder @ t)))) (implementation - (def: (leaf tag value) + (def (leaf tag value) (abstraction [#monoid monoid #tag tag #root {.#Left value}])) - (def: (branch left right) + (def (branch left right) (abstraction [#monoid monoid #tag (at monoid composite (..tag left) (..tag right)) #root {.#Right [left right]}])))) - (def: .public (value tree) + (def .public (value tree) (All (_ @ t v) (-> (Tree @ t v) v)) (case (the #root (representation tree)) {0 #0 value} @@ -62,7 +62,7 @@ {0 #1 [left right]} (value left))) - (def: .public (tags tree) + (def .public (tags tree) (All (_ @ t v) (-> (Tree @ t v) (List t))) (case (the #root (representation tree)) {0 #0 value} @@ -72,7 +72,7 @@ (list#composite (tags left) (tags right)))) - (def: .public (values tree) + (def .public (values tree) (All (_ @ t v) (-> (Tree @ t v) (List v))) (case (the #root (representation tree)) {0 #0 value} @@ -82,7 +82,7 @@ (list#composite (values left) (values right)))) - (def: .public (one predicate tree) + (def .public (one predicate tree) (All (_ @ t v) (-> (Predicate t) (Tree @ t v) (Maybe v))) (let [[monoid tag root] (representation tree)] (if (predicate tag) @@ -101,7 +101,7 @@ {.#None}))) ) -(def: .public (exists? predicate tree) +(def .public (exists? predicate tree) (All (_ @ t v) (-> (Predicate t) (Tree @ t v) Bit)) (case (..one predicate tree) {.#Some _} diff --git a/stdlib/source/library/lux/data/collection/tree/zipper.lux b/stdlib/source/library/lux/data/collection/tree/zipper.lux index d02c354bb..e6bb39ba6 100644 --- a/stdlib/source/library/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/library/lux/data/collection/tree/zipper.lux @@ -29,12 +29,12 @@ [#family (Maybe (Family Zipper a)) #node (Tree a)])) -(def: .public (equivalence super) +(def .public (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (Zipper a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (let [== (all product.equivalence (maybe.equivalence (all product.equivalence @@ -44,40 +44,40 @@ (//.equivalence super))] (== reference sample))))) -(def: .public (zipper tree) +(def .public (zipper tree) (All (_ a) (-> (Tree a) (Zipper a))) [#family {.#None} #node tree]) -(def: .public tree +(def .public tree (All (_ a) (-> (Zipper a) (Tree a))) (the #node)) -(def: .public value +(def .public value (All (_ a) (-> (Zipper a) a)) (the [#node //.#value])) -(def: .public (set value zipper) +(def .public (set value zipper) (All (_ a) (-> a (Zipper a) (Zipper a))) (has [#node //.#value] value zipper)) -(def: .public (update transform zipper) +(def .public (update transform zipper) (All (_ a) (-> (-> a a) (Zipper a) (Zipper a))) (revised [#node //.#value] transform zipper)) -(def: children +(def children (All (_ a) (-> (Zipper a) (List (Tree a)))) (the [#node //.#children])) -(def: .public leaf? +(def .public leaf? (All (_ a) (-> (Zipper a) Bit)) (|>> ..children list.empty?)) -(def: .public branch? +(def .public branch? (All (_ a) (-> (Zipper a) Bit)) (|>> ..leaf? not)) -(def: .public (start? zipper) +(def .public (start? zipper) (All (_ a) (-> (Zipper a) Bit)) (case (the #family zipper) {.#None} @@ -86,7 +86,7 @@ _ false)) -(def: .public (down zipper) +(def .public (down zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..children zipper) {.#End} @@ -98,7 +98,7 @@ #rights tail]} #node head]})) -(def: .public (up zipper) +(def .public (up zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (do maybe.monad [family (the #family zipper)] @@ -117,7 +117,7 @@ _#parent)))))) (with_template [<one> <all> <side> <op_side>] - [(def: .public (<one> zipper) + [(def .public (<one> zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (the #family zipper) {.#Some family} @@ -141,7 +141,7 @@ {.#None} {.#None})) - (def: .public (<all> zipper) + (def .public (<all> zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (the #family zipper) {.#None} @@ -170,7 +170,7 @@ [left leftmost #lefts #rights] ) -(def: .public (next zipper) +(def .public (next zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..down zipper) {.#Some forward} @@ -187,7 +187,7 @@ [@ (..up @)] (again @)))))) -(def: (bottom zipper) +(def (bottom zipper) (All (_ a) (-> (Zipper a) (Zipper a))) (case (..right zipper) {.#Some forward} @@ -201,7 +201,7 @@ {.#None} zipper))) -(def: .public (previous zipper) +(def .public (previous zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (..left zipper) {.#None} @@ -216,7 +216,7 @@ backward)})) (with_template [<name> <move>] - [(def: .public (<name> zipper) + [(def .public (<name> zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (case (<move> zipper) {.#None} @@ -235,7 +235,7 @@ [start ..previous] ) -(def: .public (end? zipper) +(def .public (end? zipper) (All (_ a) (-> (Zipper a) Bit)) (case (..end zipper) {.#None} @@ -244,19 +244,19 @@ {.#Some _} false)) -(def: .public (interpose value zipper) +(def .public (interpose value zipper) (All (_ a) (-> a (Zipper a) (Zipper a))) (revised [#node //.#children] (|>> (//.branch value) list) zipper)) -(def: .public (adopt value zipper) +(def .public (adopt value zipper) (All (_ a) (-> a (Zipper a) (Zipper a))) (revised [#node //.#children] (|>> {.#Item (//.leaf value)}) zipper)) -(def: .public (remove zipper) +(def .public (remove zipper) (All (_ a) (-> (Zipper a) (Maybe (Zipper a)))) (do maybe.monad [family (the #family zipper)] @@ -274,7 +274,7 @@ (has #node next)))))) (with_template [<name> <side>] - [(def: .public (<name> value zipper) + [(def .public (<name> value zipper) (All (_ a) (-> a (Zipper a) (Maybe (Zipper a)))) (case (the #family zipper) {.#None} @@ -289,10 +289,10 @@ [insert_right #rights] ) -(def: .public functor +(def .public functor (Functor Zipper) (implementation - (def: (each f (open "_[0]")) + (def (each f (open "_[0]")) [#family (maybe#each (function (_ (open "_[0]")) [#parent (each f _#parent) #lefts (list#each (//#each f) _#lefts) @@ -300,16 +300,16 @@ _#family) #node (//#each f _#node)]))) -(def: .public comonad +(def .public comonad (CoMonad Zipper) (implementation - (def: functor + (def functor ..functor) - (def: out + (def out (the [#node //.#value])) - (def: (disjoint (open "_[0]")) + (def (disjoint (open "_[0]")) (let [tree_splitter (is (All (_ a) (-> (Tree a) (Tree (Zipper a)))) (function (tree_splitter tree) [//.#value (..zipper tree) diff --git a/stdlib/source/library/lux/data/color.lux b/stdlib/source/library/lux/data/color.lux index 2a89c02fe..519b0f020 100644 --- a/stdlib/source/library/lux/data/color.lux +++ b/stdlib/source/library/lux/data/color.lux @@ -18,17 +18,17 @@ [type [primitive (.except)]]]]) -(def: rgb_limit 256) -(def: top (-- rgb_limit)) +(def rgb_limit 256) +(def top (-- rgb_limit)) -(def: rgb_factor +(def rgb_factor (|> top .int int.frac)) -(def: down +(def down (-> Nat Frac) (|>> .int int.frac (f./ rgb_factor))) -(def: up +(def up (-> Frac Nat) (|>> (f.* rgb_factor) f.int .nat)) @@ -54,79 +54,79 @@ (primitive .public Color RGB - (def: .public (of_rgb [red green blue]) + (def .public (of_rgb [red green blue]) (-> RGB Color) (abstraction [#red (n.% ..rgb_limit red) #green (n.% ..rgb_limit green) #blue (n.% ..rgb_limit blue)])) - (def: .public rgb + (def .public rgb (-> Color RGB) (|>> representation)) - (def: .public equivalence + (def .public equivalence (Equivalence Color) (implementation - (def: (= reference sample) + (def (= reference sample) (let [[rR gR bR] (representation reference) [rS gS bS] (representation sample)] (and (n.= rR rS) (n.= gR gS) (n.= bR bS)))))) - (def: .public hash + (def .public hash (Hash Color) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (hash value) + (def (hash value) (let [[r g b] (representation value)] (all i64.or (i64.left_shifted 16 r) (i64.left_shifted 8 g) b))))) - (def: .public black + (def .public black Color (..of_rgb [#red 0 #green 0 #blue 0])) - (def: .public white + (def .public white Color (..of_rgb [#red ..top #green ..top #blue ..top])) - (def: .public addition + (def .public addition (Monoid Color) (implementation - (def: identity ..black) + (def identity ..black) - (def: (composite left right) + (def (composite left right) (let [[lR lG lB] (representation left) [rR rG rB] (representation right)] (abstraction [#red (n.max lR rR) #green (n.max lG rG) #blue (n.max lB rB)]))))) - (def: (opposite_intensity value) + (def (opposite_intensity value) (-> Nat Nat) (|> ..top (n.- value))) - (def: .public (complement color) + (def .public (complement color) (-> Color Color) (let [[red green blue] (representation color)] (abstraction [#red (opposite_intensity red) #green (opposite_intensity green) #blue (opposite_intensity blue)]))) - (def: .public subtraction + (def .public subtraction (Monoid Color) (implementation - (def: identity ..white) + (def identity ..white) - (def: (composite left right) + (def (composite left right) (let [[lR lG lB] (representation (..complement left)) [rR rG rB] (representation right)] (abstraction [#red (n.min lR rR) @@ -134,7 +134,7 @@ #blue (n.min lB rB)]))))) ) -(def: .public (hsl color) +(def .public (hsl color) (-> Color HSL) (let [[red green blue] (rgb color) red (..down red) @@ -169,7 +169,7 @@ saturation luminance])))) -(def: (hue_rgb p q t) +(def (hue_rgb p q t) (-> Frac Frac Frac Nat) (let [t (cond (f.< +0.0 t) (f.+ +1.0 t) (f.> +1.0 t) (f.- +1.0 t) @@ -188,7 +188,7 @@ ... else p)))) -(def: .public (of_hsl [hue saturation luminance]) +(def .public (of_hsl [hue saturation luminance]) (-> HSL Color) (if (f.= +0.0 saturation) ... Achromatic @@ -206,7 +206,7 @@ #green (|> hue (hue_rgb p q)) #blue (|> hue (f.- third) (hue_rgb p q))])))) -(def: .public (hsb color) +(def .public (hsb color) (-> Color HSB) (let [[red green blue] (rgb color) red (..down red) @@ -238,7 +238,7 @@ saturation brightness])))) -(def: .public (of_hsb [hue saturation brightness]) +(def .public (of_hsb [hue saturation brightness]) (-> HSB Color) (let [hue (|> hue (f.* +6.0)) i (f.floor hue) @@ -255,7 +255,7 @@ #green (..up green) #blue (..up blue)]))) -(def: .public (cmyk color) +(def .public (cmyk color) (-> Color CMYK) (let [[red green blue] (rgb color) red (..down red) @@ -273,7 +273,7 @@ #yellow yellow #key key])) -(def: .public (of_cmyk [cyan magenta yellow key]) +(def .public (of_cmyk [cyan magenta yellow key]) (-> CMYK Color) (if (f.= +1.0 key) (of_rgb [#red 0 @@ -289,7 +289,7 @@ #green (..up green) #blue (..up blue)])))) -(def: (normal ratio) +(def (normal ratio) (-> Frac Frac) (cond (f.> +1.0 ratio) (f.% +1.0 ratio) @@ -300,7 +300,7 @@ ... else ratio)) -(def: .public (interpolated ratio end start) +(def .public (interpolated ratio end start) (-> Frac Color Color Color) (let [dS (..normal ratio) dE (|> +1.0 (f.- dS)) @@ -317,7 +317,7 @@ #blue (interpolated' blueE blueS)]))) (with_template [<name> <target>] - [(def: .public (<name> ratio color) + [(def .public (<name> ratio color) (-> Frac Color Color) (..interpolated ratio <target> color))] @@ -326,7 +326,7 @@ ) (with_template [<op> <name>] - [(def: .public (<name> ratio color) + [(def .public (<name> ratio color) (-> Frac Color Color) (let [[hue saturation luminance] (hsl color)] (of_hsl [hue @@ -339,7 +339,7 @@ [f.- un_saturated] ) -(def: .public (gray_scale color) +(def .public (gray_scale color) (-> Color Color) (let [[_ _ luminance] (hsl color)] (of_hsl [+0.0 @@ -347,7 +347,7 @@ luminance]))) (with_template [<name> <1> <2>] - [(`` (def: .public (<name> color) + [(`` (def .public (<name> color) (-> Color [Color Color Color]) (let [[hue saturation luminance] (hsl color)] [color @@ -364,7 +364,7 @@ ) (with_template [<name> <1> <2> <3>] - [(`` (def: .public (<name> color) + [(`` (def .public (<name> color) (-> Color [Color Color Color Color]) (let [[hue saturation luminance] (hsb color)] [color @@ -388,7 +388,7 @@ (type: .public Palette (-> Spread Nat Color (List Color))) -(`` (def: .public (analogous spread variations color) +(`` (def .public (analogous spread variations color) Palette (let [[hue saturation brightness] (hsb color) spread (..normal spread)] @@ -398,7 +398,7 @@ brightness])) (list.indices variations))))) -(`` (def: .public (monochromatic spread variations color) +(`` (def .public (monochromatic spread variations color) Palette (let [[hue saturation brightness] (hsb color) spread (..normal spread)] @@ -413,15 +413,15 @@ (type: .public Alpha Rev) -(def: .public transparent +(def .public transparent Alpha rev#bottom) -(def: .public translucent +(def .public translucent Alpha .5) -(def: .public opaque +(def .public opaque Alpha rev#top) diff --git a/stdlib/source/library/lux/data/color/named.lux b/stdlib/source/library/lux/data/color/named.lux index 99fae8434..43633595d 100644 --- a/stdlib/source/library/lux/data/color/named.lux +++ b/stdlib/source/library/lux/data/color/named.lux @@ -7,7 +7,7 @@ ... https://developer.mozilla.org/en-US/docs/Web/CSS/color_value (with_template [<red> <green> <blue> <name>] - [(`` (def: .public <name> + [(`` (def .public <name> Color (//.of_rgb [//.#red (hex <red>) //.#green (hex <green>) diff --git a/stdlib/source/library/lux/data/format/css.lux b/stdlib/source/library/lux/data/format/css.lux index df39b6b61..dca23f87c 100644 --- a/stdlib/source/library/lux/data/format/css.lux +++ b/stdlib/source/library/lux/data/format/css.lux @@ -30,29 +30,29 @@ (primitive .public (CSS brand) Text - (def: .public css + (def .public css (-> (CSS Any) Text) (|>> representation)) - (def: .public empty + (def .public empty (CSS Any) (abstraction "")) (type: .public Style (List (Ex (_ brand) [(Property brand) (Value brand)]))) - (def: .public (rule selector style) + (def .public (rule selector style) (-> (Selector Any) Style (CSS Common)) (abstraction (format (/selector.selector selector) "{" (/style.inline (/style.style style)) "}"))) - (def: .public char_set + (def .public char_set (-> Encoding (CSS Special)) (|>> encoding.name %.text (text.enclosed ["@charset " ";"]) abstraction)) - (def: .public (font font) + (def .public (font font) (-> Font (CSS Special)) (let [with_unicode (case (the /font.#unicode_range font) {.#Some unicode_range} @@ -75,7 +75,7 @@ (format "@font-face") abstraction))) - (def: .public (import url query) + (def .public (import url query) (-> URL (Maybe Query) (CSS Special)) (abstraction (format (format "@import url(" (%.text url) ")") (case query @@ -86,7 +86,7 @@ "") ";"))) - (def: separator + (def separator text.new_line) (type: .public Frame @@ -94,7 +94,7 @@ [#when (Value Percentage) #what Style])) - (def: .public (key_frames animation frames) + (def .public (key_frames animation frames) (-> (Value Animation) (List Frame) (CSS Special)) (abstraction (format "@keyframes " (/value.value animation) " {" (|> frames @@ -105,18 +105,18 @@ (text.interposed ..separator)) "}"))) - (def: !composite + (def !composite (template (!composite <pre> <post>) [(abstraction (format (representation <pre>) ..separator (representation <post>)))])) - (def: .public (and pre post) + (def .public (and pre post) (All (_ kind) (-> (CSS kind) (CSS kind) (CSS kind))) (!composite pre post)) - (def: .public (in_context combinator selector css) + (def .public (in_context combinator selector css) (-> Combinator (Selector Any) (CSS Common) (CSS Common)) (|> css representation @@ -128,13 +128,13 @@ (text.interposed ..separator) abstraction)) - (def: .public (dependent combinator selector style inner) + (def .public (dependent combinator selector style inner) (-> Combinator (Selector Any) Style (CSS Common) (CSS Common)) (!composite (..rule selector style) (..in_context combinator selector inner))) (with_template [<name> <combinator>] - [(def: .public <name> + [(def .public <name> (-> (Selector Any) Style (CSS Common) (CSS Common)) (..dependent <combinator>))] @@ -142,7 +142,7 @@ [with_children /selector.sub] ) - (def: .public (in_case specializer selector css) + (def .public (in_case specializer selector css) (All (_ kind) (-> (Specializer kind) (Selector (Generic Any)) (CSS Common) (CSS Common))) (|> css @@ -155,14 +155,14 @@ (text.interposed ..separator) abstraction)) - (def: .public (specialized combinator selector style inner) + (def .public (specialized combinator selector style inner) (All (_ kind) (-> (Specializer kind) (Selector (Generic Any)) Style (CSS Common) (CSS Common))) (!composite (..rule selector style) (..in_case combinator selector inner))) (with_template [<name> <combinator>] - [(def: .public <name> + [(def .public <name> (-> (Selector (Generic Any)) Style (CSS Common) (CSS Common)) (..specialized <combinator>))] diff --git a/stdlib/source/library/lux/data/format/css/class.lux b/stdlib/source/library/lux/data/format/css/class.lux index 1fb58b4d7..6a867e331 100644 --- a/stdlib/source/library/lux/data/format/css/class.lux +++ b/stdlib/source/library/lux/data/format/css/class.lux @@ -16,15 +16,15 @@ (primitive .public Class Text - (def: .public class + (def .public class (-> Class Text) (|>> representation)) - (def: .public custom + (def .public custom (-> Text Class) (|>> abstraction)) - (def: .public generic + (def .public generic (syntax (_ []) (do meta.monad [module meta.current_module_name diff --git a/stdlib/source/library/lux/data/format/css/id.lux b/stdlib/source/library/lux/data/format/css/id.lux index 2ba540356..96a9ef1d2 100644 --- a/stdlib/source/library/lux/data/format/css/id.lux +++ b/stdlib/source/library/lux/data/format/css/id.lux @@ -16,15 +16,15 @@ (primitive .public ID Text - (def: .public id + (def .public id (-> ID Text) (|>> representation)) - (def: .public custom + (def .public custom (-> Text ID) (|>> abstraction)) - (def: .public generic + (def .public generic (syntax (_ []) (do meta.monad [module meta.current_module_name diff --git a/stdlib/source/library/lux/data/format/css/property.lux b/stdlib/source/library/lux/data/format/css/property.lux index 21348e82d..5fa507633 100644 --- a/stdlib/source/library/lux/data/format/css/property.lux +++ b/stdlib/source/library/lux/data/format/css/property.lux @@ -54,20 +54,20 @@ White_Space Word_Break Word_Wrap Writing_Mode Z_Index)]]) -(def: text_symbol +(def text_symbol (syntax (_ [symbol s.text]) (in (list (code.local (text.replaced "-" "_" symbol)))))) (primitive .public (Property brand) Text - (def: .public name + (def .public name (-> (Property Any) Text) (|>> representation)) (with_template [<brand> <alias>+ <property>+] [(`` (with_template [<alias> <property>] - [(def: .public <alias> + [(def .public <alias> (Property <brand>) (abstraction <property>))] @@ -75,7 +75,7 @@ (with_expansions [<rows> (template.spliced <property>+)] (with_template [<property>] - [(`` (def: .public (~~ (text_symbol <property>)) + [(`` (def .public (~~ (text_symbol <property>)) (Property <brand>) (abstraction <property>)))] diff --git a/stdlib/source/library/lux/data/format/css/query.lux b/stdlib/source/library/lux/data/format/css/query.lux index f4d2fccd5..6af2f5539 100644 --- a/stdlib/source/library/lux/data/format/css/query.lux +++ b/stdlib/source/library/lux/data/format/css/query.lux @@ -21,19 +21,19 @@ Pointer Hover Light Scripting Motion Color_Scheme)]]) -(def: text_symbol +(def text_symbol (syntax (_ [symbol s.text]) (in (list (code.local (text.replaced "-" "_" symbol)))))) (primitive .public Media Text - (def: .public media + (def .public media (-> Media Text) (|>> representation)) (with_template [<media>] - [(`` (def: .public (~~ (text_symbol <media>)) + [(`` (def .public (~~ (text_symbol <media>)) Media (abstraction <media>)))] @@ -46,12 +46,12 @@ (primitive .public Feature Text - (def: .public feature + (def .public feature (-> Feature Text) (|>> representation)) (with_template [<feature> <brand>] - [(`` (def: .public ((~~ (text_symbol <feature>)) input) + [(`` (def .public ((~~ (text_symbol <feature>)) input) (-> (Value <brand>) Feature) (abstraction (format "(" <feature> ": " (//value.value input) ")"))))] @@ -106,12 +106,12 @@ (primitive .public Query Text - (def: .public query + (def .public query (-> Query Text) (|>> representation)) (with_template [<name> <operator>] - [(def: .public <name> + [(def .public <name> (-> Media Query) (|>> ..media (format <operator>) abstraction))] @@ -119,12 +119,12 @@ [only "only "] ) - (def: .public not + (def .public not (-> Feature Query) (|>> ..feature (format "not ") abstraction)) (with_template [<name> <operator>] - [(def: .public (<name> left right) + [(def .public (<name> left right) (-> Query Query Query) (abstraction (format (representation left) <operator> diff --git a/stdlib/source/library/lux/data/format/css/selector.lux b/stdlib/source/library/lux/data/format/css/selector.lux index 2fe5ae11e..ee3291e33 100644 --- a/stdlib/source/library/lux/data/format/css/selector.lux +++ b/stdlib/source/library/lux/data/format/css/selector.lux @@ -38,20 +38,20 @@ (primitive .public (Selector kind) Text - (def: .public selector + (def .public selector (-> (Selector Any) Text) (|>> representation)) - (def: .public any + (def .public any (Selector Cannot_Chain) (abstraction "*")) - (def: .public tag + (def .public tag (-> Tag (Selector Cannot_Chain)) (|>> abstraction)) (with_template [<name> <type> <prefix> <kind> <out>] - [(def: .public <name> + [(def .public <name> (-> <type> (Selector <kind>)) (|>> <out> (format <prefix>) abstraction))] @@ -61,7 +61,7 @@ (with_template [<right> <left> <combinator>+] [(`` (with_template [<combinator> <name>] - [(def: .public (<name> right left) + [(def .public (<name> right left) (-> (Selector <right>) (Selector <left>) (Selector Composite)) (abstraction (format (representation left) <combinator> @@ -89,12 +89,12 @@ (type: .public Combinator (-> (Selector Any) (Selector Any) (Selector Composite))) - (def: .public (with? attribute) + (def .public (with? attribute) (-> Attribute (Selector Can_Chain)) (abstraction (format "[" attribute "]"))) (with_template [<check> <name>] - [(def: .public (<name> attribute value) + [(def .public (<name> attribute value) (-> Attribute Text (Selector Can_Chain)) (abstraction (format "[" attribute <check> value "]")))] @@ -108,7 +108,7 @@ (with_template [<kind> <pseudo>+] [(`` (with_template [<name> <pseudo>] - [(def: .public <name> + [(def .public <name> (Selector <kind>) (abstraction <pseudo>))] @@ -152,7 +152,7 @@ [selection "::selection"]]] ) - (def: .public (language locale) + (def .public (language locale) (-> Locale (Selector Can_Chain)) (|> locale locale.code @@ -160,7 +160,7 @@ (format ":lang") abstraction)) - (def: .public not + (def .public not (-> (Selector Any) (Selector Can_Chain)) (|>> representation (text.enclosed ["(" ")"]) @@ -170,12 +170,12 @@ (primitive .public Index Text - (def: .public index + (def .public index (-> Nat Index) (|>> %.nat abstraction)) (with_template [<name> <index>] - [(def: .public <name> Index (abstraction <index>))] + [(def .public <name> Index (abstraction <index>))] [odd "odd"] [even "even"] @@ -186,7 +186,7 @@ [#constant Int #variable Int])) - (def: .public (formula input) + (def .public (formula input) (-> Formula Index) (let [(open "_[0]") input] (abstraction (format (if (i.< +0 _#variable) @@ -195,7 +195,7 @@ (%.int _#constant))))) (with_template [<name> <pseudo>] - [(def: .public (<name> index) + [(def .public (<name> index) (-> Index (Selector Can_Chain)) (|> (representation index) (text.enclosed ["(" ")"]) diff --git a/stdlib/source/library/lux/data/format/css/style.lux b/stdlib/source/library/lux/data/format/css/style.lux index eba1e112d..50df42453 100644 --- a/stdlib/source/library/lux/data/format/css/style.lux +++ b/stdlib/source/library/lux/data/format/css/style.lux @@ -15,11 +15,11 @@ (primitive .public Style Text - (def: .public empty + (def .public empty Style (abstraction "")) - (def: .public (with [property value]) + (def .public (with [property value]) (All (_ brand) (-> [(Property brand) (Value brand)] (-> Style Style))) @@ -27,11 +27,11 @@ (format (//property.name property) ": " (//value.value value) ";") abstraction)) - (def: .public inline + (def .public inline (-> Style Text) (|>> representation)) - (def: .public (style config) + (def .public (style config) (-> (List (Ex (_ brand) [(Property brand) (Value brand)])) Style) (list#mix ..with ..empty config)) diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux index 66c82fe50..79afc29d6 100644 --- a/stdlib/source/library/lux/data/format/css/value.lux +++ b/stdlib/source/library/lux/data/format/css/value.lux @@ -29,28 +29,28 @@ [// [selector (.only Label)]]) -(def: text_symbol +(def text_symbol (syntax (_ [symbol <code>.text]) (in (list (code.local (text.replaced "-" "_" symbol)))))) -(def: enumeration +(def enumeration (template (_ <abstraction> <representation> <out> <sample>+ <definition>+) [(primitive .public <abstraction> <representation> - (def: .public <out> + (def .public <out> (-> <abstraction> <representation>) (|>> representation)) (`` (with_template [<name> <value>] - [(def: .public <name> <abstraction> (abstraction <value>))] + [(def .public <name> <abstraction> (abstraction <value>))] (~~ (template.spliced <sample>+)) )) (template.spliced <definition>+))])) -(def: (%number value) +(def (%number value) (Format Frac) (let [raw (%.frac value)] (if (f.< +0.0 value) @@ -60,12 +60,12 @@ (primitive .public (Value brand) Text - (def: .public value + (def .public value (-> (Value Any) Text) (|>> representation)) (with_template [<name> <value>] - [(def: .public <name> Value (abstraction <value>))] + [(def .public <name> Value (abstraction <value>))] [initial "initial"] [inherit "inherit"] @@ -90,7 +90,7 @@ [(primitive .public <brand> Any) (`` (with_template [<name> <value>] - [(def: .public <name> + [(def .public <name> (Value <brand>) (abstraction <value>))] @@ -98,7 +98,7 @@ (with_expansions [<rows> (template.spliced <value>+)] (with_template [<value>] - [(`` (def: .public (~~ (..text_symbol <value>)) + [(`` (def .public (~~ (..text_symbol <value>)) (Value <brand>) (abstraction <value>)))] @@ -775,9 +775,9 @@ []] ) - (def: value_separator ",") + (def value_separator ",") - (def: (apply name inputs) + (def (apply name inputs) (-> Text (List Text) Value) (|> inputs (text.interposed ..value_separator) @@ -793,18 +793,18 @@ [end "end"]] []) - (def: .public (steps intervals step) + (def .public (steps intervals step) (-> Nat Step (Value Timing)) (..apply "steps" (list (%.nat intervals) (..step step)))) - (def: .public (cubic_bezier p0 p1 p2 p3) + (def .public (cubic_bezier p0 p1 p2 p3) (-> Frac Frac Frac Frac (Value Timing)) (|> (list p0 p1 p2 p3) (list#each %number) (..apply "cubic-bezier"))) (with_template [<name> <brand>] - [(def: .public <name> + [(def .public <name> (-> Nat (Value <brand>)) (|>> %.nat abstraction))] @@ -814,18 +814,18 @@ [span_line Grid_Span] ) - (def: .public animation + (def .public animation (-> Label (Value Animation)) (|>> abstraction)) - (def: .public (rgb color) + (def .public (rgb color) (-> color.Color (Value Color)) (let [[red green blue] (color.rgb color)] (..apply "rgb" (list (%.nat red) (%.nat green) (%.nat blue))))) - (def: .public (rgba pigment) + (def .public (rgba pigment) (-> color.Pigment (Value Color)) (let [(open "_[0]") pigment [red green blue] (color.rgb _#color)] @@ -837,7 +837,7 @@ (format "0" (%.rev _#alpha))))))) (with_template [<name> <suffix>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> Frac (Value Length)) (abstraction (format (%number value) <suffix>)))] @@ -859,14 +859,14 @@ [fr "fr"] ) - (def: (%int value) + (def (%int value) (Format Int) (if (i.< +0 value) (%.int value) (%.nat (.nat value)))) (with_template [<name> <suffix>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> Int (Value Time)) (abstraction (format (if (i.< +0 value) (%.int value) @@ -878,13 +878,13 @@ [milli_seconds "ms"] ) - (def: .public thickness + (def .public thickness (-> (Value Length) (Value Thickness)) (|>> transmutation)) - (def: slice_separator " ") + (def slice_separator " ") - (def: .public (slice_number/2 horizontal vertical) + (def .public (slice_number/2 horizontal vertical) (-> Nat Nat (Value Slice)) (abstraction (format (%.nat horizontal) ..slice_separator (%.nat vertical)))) @@ -892,18 +892,18 @@ (primitive .public Stop Text - (def: .public stop + (def .public stop (-> (Value Color) Stop) (|>> (representation Value) (abstraction Stop))) - (def: stop_separator " ") + (def stop_separator " ") - (def: .public (single_stop length color) + (def .public (single_stop length color) (-> (Value Length) (Value Color) Stop) (abstraction (format (representation Value color) ..stop_separator (representation Value length)))) - (def: .public (double_stop start end color) + (def .public (double_stop start end color) (-> (Value Length) (Value Length) (Value Color) Stop) (abstraction (format (representation Value color) ..stop_separator (representation Value start) ..stop_separator @@ -912,11 +912,11 @@ (primitive .public Hint Text - (def: .public hint + (def .public hint (-> (Value Length) Hint) (|>> (representation Value) (abstraction Hint))) - (def: (with_hint [hint stop]) + (def (with_hint [hint stop]) (-> [(Maybe Hint) Stop] Text) (case hint {.#None} @@ -931,22 +931,22 @@ (primitive .public Angle Text - (def: .public angle + (def .public angle (-> Angle Text) (|>> representation)) - (def: .public (turn value) + (def .public (turn value) (-> Rev Angle) (abstraction (format (%.rev value) "turn"))) - (def: degree_limit Nat 360) + (def degree_limit Nat 360) - (def: .public (degree value) + (def .public (degree value) (-> Nat Angle) (abstraction (format (%.nat (n.% ..degree_limit value)) "deg"))) (with_template [<degree> <name>] - [(def: .public <name> + [(def .public <name> Angle (..degree <degree>))] @@ -957,7 +957,7 @@ ) (with_template [<name> <function>] - [(def: .public (<name> angle start next) + [(def .public (<name> angle start next) (-> Angle Stop (List/1 [(Maybe Hint) Stop]) (Value Image)) (let [[now after] next] (..apply <function> (list.partial (representation Angle angle) @@ -969,24 +969,24 @@ ) ) - (def: percentage_limit Nat (.++ 100)) + (def percentage_limit Nat (.++ 100)) - (def: .public (%% value) + (def .public (%% value) (-> Nat (Value Percentage)) (abstraction (format (%.nat (n.% percentage_limit value)) "%"))) - (def: .public slice_percent/1 + (def .public slice_percent/1 (-> (Value Percentage) (Value Slice)) (|>> transmutation)) - (def: .public (slice_percent/2 horizontal vertical) + (def .public (slice_percent/2 horizontal vertical) (-> (Value Percentage) (Value Percentage) (Value Slice)) (abstraction (format (representation horizontal) ..slice_separator (representation vertical)))) (with_template [<input> <pre> <function>+] [(`` (with_template [<name> <function>] - [(def: .public <name> + [(def .public <name> (-> <input> (Value Filter)) (|>> <pre> (list) (..apply <function>)))] @@ -1006,13 +1006,13 @@ [sepia "sepia"]]] ) - (def: .public svg_filter + (def .public svg_filter (-> URL (Value Filter)) (|>> (list) (..apply "url"))) - (def: default_shadow_length (px +0.0)) + (def default_shadow_length (px +0.0)) - (def: .public (drop_shadow horizontal vertical blur spread color) + (def .public (drop_shadow horizontal vertical blur spread color) (-> (Value Length) (Value Length) (Maybe (Value Length)) (Maybe (Value Length)) (Value Color) @@ -1026,10 +1026,10 @@ (list) (..apply "drop-shadow"))) - (def: length_separator " ") + (def length_separator " ") (with_template [<name> <type>] - [(def: .public (<name> horizontal vertical) + [(def .public (<name> horizontal vertical) (-> (Value Length) (Value Length) (Value <type>)) (abstraction (format (representation horizontal) ..length_separator @@ -1039,11 +1039,11 @@ [fit Fit] ) - (def: .public (fit/1 length) + (def .public (fit/1 length) (-> (Value Length) (Value Fit)) (..fit length length)) - (def: .public image + (def .public image (-> URL (Value Image)) (|>> %.text (list) @@ -1068,7 +1068,7 @@ []) (with_template [<name> <function>] - [(def: .public (<name> shape extent location start next) + [(def .public (<name> shape extent location start next) (-> Shape (Maybe Extent) (Value Location) Stop (List/1 [(Maybe Hint) Stop]) (Value Image)) @@ -1089,7 +1089,7 @@ [repeating_radial_gradient "repeating-radial-gradient"] ) - (def: .public (shadow horizontal vertical blur spread color inset?) + (def .public (shadow horizontal vertical blur spread color inset?) (-> (Value Length) (Value Length) (Maybe (Value Length)) (Maybe (Value Length)) (Value Color) Bit @@ -1113,30 +1113,30 @@ #bottom (Value Length) #left (Value Length)])) - (def: .public (clip rectangle) + (def .public (clip rectangle) (-> Rectangle (Value Clip)) (`` (..apply "rect" (list (~~ (with_template [<side>] [(representation (the <side> rectangle))] [#top] [#right] [#bottom] [#left])))))) - (def: .public counter + (def .public counter (-> Label (Value Counter)) (|>> abstraction)) - (def: .public current_count + (def .public current_count (-> (Value Counter) (Value Content)) (|>> representation (list) (..apply "counter"))) - (def: .public text + (def .public text (-> Text (Value Content)) (|>> %.text abstraction)) - (def: .public attribute + (def .public attribute (-> Label (Value Content)) (|>> (list) (..apply "attr"))) - (def: .public media + (def .public media (-> URL (Value Content)) (|>> (list) (..apply "url"))) @@ -1149,11 +1149,11 @@ [cursive "cursive"] [fantasy "fantasy"] [monospace "monospace"]] - [(def: .public font + [(def .public font (-> Text Font) (|>> %.text abstraction)) - (def: .public (font_family options) + (def .public (font_family options) (-> (List Font) (Value Font)) (case options {.#Item _} @@ -1165,35 +1165,35 @@ {.#End} ..initial))]) - (def: .public font_size + (def .public font_size (-> (Value Length) (Value Font_Size)) (|>> transmutation)) - (def: .public number + (def .public number (-> Frac (Value Number)) (|>> %number abstraction)) - (def: .public grid + (def .public grid (-> Label (Value Grid)) (|>> abstraction)) - (def: .public fit_content + (def .public fit_content (-> (Value Length) (Value Grid_Content)) (|>> representation (list) (..apply "fit-content"))) - (def: .public (min_max min max) + (def .public (min_max min max) (-> (Value Grid_Content) (Value Grid_Content) (Value Grid_Content)) (..apply "minmax" (list (representation min) (representation max)))) - (def: .public grid_span + (def .public grid_span (-> Nat (Value Grid_Span)) (|>> %.nat (format "span ") abstraction)) - (def: grid_column_separator " ") - (def: grid_row_separator " ") + (def grid_column_separator " ") + (def grid_row_separator " ") - (def: .public grid_template + (def .public grid_template (-> (List (List (Maybe (Value Grid)))) (Value Grid_Template)) (let [empty (is (Value Grid) (abstraction "."))] @@ -1204,11 +1204,11 @@ (text.interposed ..grid_row_separator) abstraction))) - (def: .public (resolution dpi) + (def .public (resolution dpi) (-> Nat (Value Resolution)) (abstraction (format (%.nat dpi) "dpi"))) - (def: .public (ratio numerator denominator) + (def .public (ratio numerator denominator) (-> Nat Nat (Value Ratio)) (abstraction (format (%.nat numerator) "/" (%.nat denominator)))) @@ -1227,20 +1227,20 @@ [double_left_quote "\201C"] [double_right_quote "\201D"] [low_double_quote "\201E"]] - [(def: .public quote + [(def .public quote (-> Text Quote) (|>> abstraction))]) - (def: quote_separator " ") + (def quote_separator " ") - (def: .public (quotes [left0 right0] [left1 right1]) + (def .public (quotes [left0 right0] [left1 right1]) (-> [Quote Quote] [Quote Quote] (Value Quotes)) (|> (list left0 right0 left1 right1) (list#each (|>> ..quote_text %.text)) (text.interposed ..quote_separator) abstraction)) - (def: .public (matrix_2d [a b] [c d] [tx ty]) + (def .public (matrix_2d [a b] [c d] [tx ty]) (-> [Frac Frac] [Frac Frac] [Frac Frac] @@ -1249,7 +1249,7 @@ (list#each %number) (..apply "matrix"))) - (def: .public (matrix_3d [a0 b0 c0 d0] [a1 b1 c1 d1] [a2 b2 c2 d2] [a3 b3 c3 d3]) + (def .public (matrix_3d [a0 b0 c0 d0] [a1 b1 c1 d1] [a2 b2 c2 d2] [a3 b3 c3 d3]) (-> [Frac Frac Frac Frac] [Frac Frac Frac Frac] [Frac Frac Frac Frac] @@ -1260,7 +1260,7 @@ (..apply "matrix3d"))) (with_template [<name> <function> <input_types> <input_values>] - [(`` (def: .public (<name> [(~~ (template.spliced <input_values>))]) + [(`` (def .public (<name> [(~~ (template.spliced <input_values>))]) (-> [(~~ (template.spliced <input_types>))] (Value Transform)) (|> (list (~~ (template.spliced <input_values>))) (list#each %number) @@ -1282,7 +1282,7 @@ ) (with_template [<name> <function> <input_types> <input_values>] - [(`` (def: .public (<name> [(~~ (template.spliced <input_values>))]) + [(`` (def .public (<name> [(~~ (template.spliced <input_values>))]) (-> [(~~ (template.spliced <input_types>))] (Value Transform)) (|> (list (~~ (template.spliced <input_values>))) (list#each ..angle) @@ -1298,36 +1298,36 @@ [skew_y "skewY" [Angle] [angle]] ) - (def: .public (rotate_3d [x y z angle]) + (def .public (rotate_3d [x y z angle]) (-> [Frac Frac Frac Angle] (Value Transform)) (..apply "rotate3d" (list (%number x) (%number y) (%number z) (..angle angle)))) - (def: origin_separator " ") + (def origin_separator " ") - (def: .public (origin_2d x y) + (def .public (origin_2d x y) (-> (Value Length) (Value Length) (Value Transform_Origin)) (abstraction (format (representation x) ..origin_separator (representation y)))) - (def: .public (origin_3d x y z) + (def .public (origin_3d x y z) (-> (Value Length) (Value Length) (Value Length) (Value Transform_Origin)) (abstraction (format (representation x) ..origin_separator (representation y) ..origin_separator (representation z)))) - (def: .public vertical_align + (def .public vertical_align (-> (Value Length) (Value Vertical_Align)) (|>> transmutation)) - (def: .public (z_index index) + (def .public (z_index index) (-> Int (Value Z_Index)) (abstraction (if (i.< +0 index) (%.int index) (%.nat (.nat index))))) (with_template [<separator> <type> <multi>] - [(def: .public (<multi> pre post) + [(def .public (<multi> pre post) (-> (Value <type>) (Value <type>) (Value <type>)) (abstraction (format (representation pre) <separator> @@ -1340,7 +1340,7 @@ ... https://developer.mozilla.org/en-US/docs/Web/CSS/calc() (with_template [<name> <parameter>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (.All (_ kind) (-> (Value <parameter>) (Value (Numeric kind)) (Value (Numeric kind)))) diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux index 3a8bcd5c6..7a9d61adc 100644 --- a/stdlib/source/library/lux/data/format/html.lux +++ b/stdlib/source/library/lux/data/format/html.lux @@ -43,7 +43,7 @@ {#Top} {#Frame Text})) -(def: (target value) +(def (target value) (-> Target Text) (case value {#Blank} "_blank" @@ -53,7 +53,7 @@ {#Frame name} name)) ... Properly formats text to ensure no injection can happen on the HTML. -(def: safe +(def safe (-> Text Text) (|>> (text.replaced "&" "&") (text.replaced "<" "<") @@ -62,20 +62,20 @@ (text.replaced "'" "'") (text.replaced "/" "/"))) -(def: attributes +(def attributes (-> Attributes Text) (|>> (list#each (function (_ [key val]) (format " " key "=" text.double_quote (..safe val) text.double_quote))) text.together)) -(def: (open tag attributes) +(def (open tag attributes) (-> Tag Attributes Text) (|> attributes ..attributes (format tag) (text.enclosed ["<" ">"]))) -(def: close +(def close (-> Tag Text) (text.enclosed ["</" ">"])) @@ -119,40 +119,40 @@ [Track Track']]] ) - (def: .public html + (def .public html (-> Document Text) (|>> representation)) - (def: .public (and pre post) + (def .public (and pre post) (All (_ brand) (-> (HTML brand) (HTML brand) (HTML brand))) (abstraction (format (representation pre) (representation post)))) - (def: .public (comment content node) + (def .public (comment content node) (All (_ brand) (-> Text (HTML brand) (HTML brand))) (abstraction (format (text.enclosed ["<!--" "-->"] content) (representation node)))) - (def: (empty name attributes) + (def (empty name attributes) (-> Tag Attributes HTML) (abstraction (format (..open name attributes) (..close name)))) - (def: (simple tag attributes) + (def (simple tag attributes) (-> Tag Attributes HTML) (|> attributes (..open tag) abstraction)) - (def: (tag name attributes content) + (def (tag name attributes content) (-> Tag Attributes (HTML Any) HTML) (abstraction (format (..open name attributes) (representation content) (..close name)))) - (def: (raw tag attributes content) + (def (raw tag attributes content) (-> Text Attributes Text HTML) (abstraction (format (..open tag attributes) @@ -160,7 +160,7 @@ (..close tag)))) (.with_template [<name> <tag> <brand>] - [(def: .public <name> + [(def .public <name> (-> Attributes <brand>) (..simple <tag>))] @@ -172,7 +172,7 @@ [parameter "param" Parameter] ) - (def: .public (base href target) + (def .public (base href target) (-> URL (Maybe Target) Meta) (let [partial (list ["href" href]) full (case target @@ -183,40 +183,40 @@ partial)] (..simple "base" full))) - (def: .public style + (def .public style (-> Style Meta) (|>> style.inline (..raw "style" (list)))) - (def: .public (script attributes inline) + (def .public (script attributes inline) (-> Attributes (Maybe Script) Meta) (|> inline (maybe#each js.code) (maybe.else "") (..raw "script" attributes))) - (def: .public text + (def .public text (-> Text Content) (|>> ..safe abstraction)) (.with_template [<tag> <alias> <name>] - [(def: .public <name> + [(def .public <name> Element (..simple <tag> (list))) - (def: .public <alias> <name>)] + (def .public <alias> <name>)] ["br" br line_break] ["wbr" wbr word_break] ["hr" hr separator] ) - (def: .public (image source attributes) + (def .public (image source attributes) (-> URL Attributes Image) (|> attributes {.#Item ["src" source]} (..simple "img"))) - (def: .public (svg attributes content) + (def .public (svg attributes content) (-> Attributes XML Element) (|> content (at xml.codec encoded) @@ -227,10 +227,10 @@ [#horizontal Nat #vertical Nat])) - (def: metric_separator ",") - (def: coord_separator ",") + (def metric_separator ",") + (def coord_separator ",") - (def: (%coord [horizontal vertical]) + (def (%coord [horizontal vertical]) (Format Coord) (format (%.nat horizontal) ..metric_separator (%.nat vertical))) @@ -251,15 +251,15 @@ #third Coord #extra (List Coord)])) - (def: (%rectangle [start end]) + (def (%rectangle [start end]) (Format Rectangle) (format (%coord start) ..coord_separator (%coord end))) - (def: (%circle [center radius]) + (def (%circle [center radius]) (Format Circle) (format (%coord center) ..metric_separator (%.nat radius))) - (def: (%polygon [first second third extra]) + (def (%polygon [first second third extra]) (Format Polygon) (|> (list.partial first second third extra) (list#each %coord) @@ -272,7 +272,7 @@ {#Polygon Polygon})) (.with_template [<name> <shape> <type> <format>] - [(def: (<name> attributes shape) + [(def (<name> attributes shape) (-> Attributes <type> (HTML Any)) (..simple "area" (list.partial ["shape" <shape>] ["coords" (<format> shape)] @@ -283,7 +283,7 @@ [polygon "poly" Polygon ..%polygon] ) - (def: (area attributes shape) + (def (area attributes shape) (-> Attributes Shape (HTML Any)) (case shape {#Rectangle rectangle} @@ -295,7 +295,7 @@ {#Polygon polygon} (..polygon attributes polygon))) - (def: .public (each attributes areas for) + (def .public (each attributes areas for) (-> Attributes (List [Attributes Shape]) Image Image) (all ..and for @@ -308,7 +308,7 @@ (list#mix (function.flipped ..and) head tail))))) (.with_template [<name> <tag> <type>] - [(def: .public <name> + [(def .public <name> (-> Attributes <type>) (..empty <tag>))] @@ -320,7 +320,7 @@ ) (.with_template [<name> <tag>] - [(def: .public (<name> attributes media on_unsupported) + [(def .public (<name> attributes media on_unsupported) (-> Attributes Media (Maybe Content) Element) (..tag <tag> attributes (|> on_unsupported @@ -331,20 +331,20 @@ [video "video"] ) - (def: .public (picture attributes sources image) + (def .public (picture attributes sources image) (-> Attributes Source Image Element) (..tag "picture" attributes (..and sources image))) - (def: .public (anchor href attributes content) + (def .public (anchor href attributes content) (-> URL Attributes Element Element) (..tag "a" (list.partial ["href" href] attributes) content)) - (def: .public label + (def .public label (-> ID Input) (|>> ["for"] list (..empty "label"))) (.with_template [<name> <container_tag> <description_tag> <type>] - [(def: .public (<name> description attributes content) + [(def .public (<name> description attributes content) (-> (Maybe Content) Attributes <type> <type>) (..tag <container_tag> attributes (case description @@ -362,7 +362,7 @@ ) (.with_template [<name> <tag> <type>] - [(def: .public (<name> attributes content) + [(def .public (<name> attributes content) (-> Attributes (Maybe Content) <type>) (|> content (maybe.else (..text "")) @@ -376,7 +376,7 @@ (-> Attributes Content Element)) (.with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> Phrase (..tag <tag>))] @@ -412,9 +412,9 @@ [variable "var"] ) - (def: .public incorrect ..struck) + (def .public incorrect ..struck) - (def: (ruby_pronunciation pronunciation) + (def (ruby_pronunciation pronunciation) (-> Content (HTML Any)) (..tag "rt" (list) (all ..and @@ -422,7 +422,7 @@ pronunciation (..tag "rp" (list) (..text ")"))))) - (def: .public (ruby attributes content pronunciation) + (def .public (ruby attributes content pronunciation) (-> Attributes Content Content Element) (..tag "ruby" attributes (all ..and @@ -433,7 +433,7 @@ (-> Attributes Element Element)) (.with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> Composite (..tag <tag>))] @@ -451,7 +451,7 @@ ) (.with_template [<tag> <name> <input>] - [(def: <name> + [(def <name> (-> <input> (HTML Any)) (..tag <tag> (list)))] @@ -459,7 +459,7 @@ ["dd" description Element] ) - (def: .public (description_list attributes descriptions) + (def .public (description_list attributes descriptions) (-> Attributes (List [Content Element]) Element) (case (list#each (function (_ [term description]) (all ..and @@ -473,10 +473,10 @@ (..tag "dl" attributes (list#mix (function.flipped ..and) head tail)))) - (def: .public p ..paragraph) + (def .public p ..paragraph) (.with_template [<name> <tag> <input> <output>] - [(def: .public <name> + [(def .public <name> (-> Attributes <input> <output>) (..tag <tag>))] @@ -495,7 +495,7 @@ ) (.with_template [<name> <tag> <input> <output>] - [(def: .public <name> + [(def .public <name> (-> <input> <output>) (..tag <tag> (list)))] @@ -509,7 +509,7 @@ ) (.with_template [<name> <tag> <input> <output>] - [(def: <name> + [(def <name> (-> <input> <output>) (..tag <tag> (list)))] @@ -520,7 +520,7 @@ [columns_group "colgroup" Column HTML] ) - (def: .public (table attributes caption columns headers rows footer) + (def .public (table attributes caption columns headers rows footer) (-> Attributes (Maybe Content) (Maybe Column) Header (List Cell) (Maybe Cell) Element) (let [head (..table_head (..table_row headers)) content (case (list#each table_row rows) @@ -556,7 +556,7 @@ content))) (.with_template [<name> <doc_type>] - [(def: .public <name> + [(def .public <name> (-> Head Body Document) (let [doc_type <doc_type>] (function (_ head body) diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index 19c3a9bba..af8a52bb4 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -59,12 +59,12 @@ [Object (Dictionary String JSON)] ) -(def: .public null? +(def .public null? (Predicate JSON) (|>> (pipe.case {#Null} true _ false))) -(def: .public object +(def .public object (-> (List [String JSON]) JSON) (|>> (dictionary.of_list text.hash) {..#Object})) @@ -79,7 +79,7 @@ {#Object' (Dictionary String JSON')} {#Code' Code}))) -(def: jsonP +(def jsonP (<code>.Parser JSON') (<>.rec (function (_ jsonP) @@ -95,7 +95,7 @@ <code>.any )))) -(def: (jsonF token) +(def (jsonF token) (-> JSON' Code) (case token {#Null' _} @@ -122,11 +122,11 @@ {#Code' code} code)) -(def: .public json +(def .public json (syntax (_ [token ..jsonP]) (in (list (` (is JSON (~ (jsonF token)))))))) -(def: .public (fields json) +(def .public (fields json) (-> JSON (Try (List String))) (case json {#Object obj} @@ -135,7 +135,7 @@ _ {try.#Failure (all text#composite "Cannot get the fields of a non-object.")})) -(def: .public (field key json) +(def .public (field key json) (-> String JSON (Try JSON)) (case json {#Object obj} @@ -149,7 +149,7 @@ _ {try.#Failure (all text#composite "Cannot get field '" key "' on a non-object.")})) -(def: .public (has key value json) +(def .public (has key value json) (-> String JSON JSON (Try JSON)) (case json {#Object obj} @@ -159,7 +159,7 @@ {try.#Failure (all text#composite "Cannot set field '" key "' on a non-object.")})) (with_template [<name> <tag> <type>] - [(def: .public (<name> key json) + [(def .public (<name> key json) (-> Text JSON (Try <type>)) (case (field key json) {try.#Success {<tag> value}} @@ -178,10 +178,10 @@ [object_field #Object Object] ) -(def: .public equivalence +(def .public equivalence (Equivalence JSON) (implementation - (def: (= x y) + (def (= x y) (case [x y] [{#Null} {#Null}] #1 @@ -222,17 +222,17 @@ ............................................................ ............................................................ -(def: (null_format _) +(def (null_format _) (-> Null Text) "null") -(def: boolean_format +(def boolean_format (-> Boolean Text) (|>> (pipe.case #0 "false" #1 "true"))) -(def: number_format +(def number_format (-> Number Text) (|>> (pipe.case +0.0 ... OR -0.0 @@ -244,16 +244,16 @@ raw (|> raw (text.split_at 1) maybe.trusted product.right)))))) -(def: escape "\") -(def: escaped_dq (text#composite ..escape text.double_quote)) +(def escape "\") +(def escaped_dq (text#composite ..escape text.double_quote)) -(def: string_format +(def string_format (-> String Text) (|>> (text.replaced text.double_quote ..escaped_dq) (text.enclosed [text.double_quote text.double_quote]))) (with_template [<token> <name>] - [(def: <name> + [(def <name> Text <token>)] @@ -267,14 +267,14 @@ ["}" object_end] ) -(def: (array_format format) +(def (array_format format) (-> (-> JSON Text) (-> Array Text)) (|>> (sequence#each format) sequence.list (text.interposed ..value_separator) (text.enclosed [..array_start ..array_end]))) -(def: (kv_format format [key value]) +(def (kv_format format [key value]) (-> (-> JSON Text) (-> [String JSON] Text)) (all text#composite (..string_format key) @@ -282,14 +282,14 @@ (format value) )) -(def: (object_format format) +(def (object_format format) (-> (-> JSON Text) (-> Object Text)) (|>> dictionary.entries (list#each (..kv_format format)) (text.interposed ..value_separator) (text.enclosed [..object_start ..object_end]))) -(def: .public (format json) +(def .public (format json) (-> JSON Text) (case json (^.with_template [<tag> <format>] @@ -307,25 +307,25 @@ ............................................................ ............................................................ -(def: space_parser +(def space_parser (Parser Text) (<text>.some <text>.space)) -(def: value_separator_parser +(def value_separator_parser (Parser [Text Any Text]) (all <>.and ..space_parser (<text>.this ..value_separator) ..space_parser)) -(def: null_parser +(def null_parser (Parser Null) (do <>.monad [_ (<text>.this "null")] (in []))) (with_template [<name> <token> <value>] - [(def: <name> + [(def <name> (Parser Boolean) (do <>.monad [_ (<text>.this <token>)] @@ -335,13 +335,13 @@ [false_parser "false" #0] ) -(def: boolean_parser +(def boolean_parser (Parser Boolean) (all <>.either ..true_parser ..false_parser)) -(def: number_parser +(def number_parser (Parser Number) (do [! <>.monad] [signed? (<>.parses? (<text>.this "-")) @@ -363,7 +363,7 @@ {try.#Success value} (in value)))) -(def: escaped_parser +(def escaped_parser (Parser Text) (all <>.either (<>.after (<text>.this "\t") @@ -381,7 +381,7 @@ (<>.after (<text>.this "\\") (<>#in "\")))) -(def: string_parser +(def string_parser (Parser String) (<| (<text>.enclosed [text.double_quote text.double_quote]) (loop (again [_ []])) @@ -395,7 +395,7 @@ (in (all text#composite chars escaped next_chars))) (in chars)))) -(def: (kv_parser json_parser) +(def (kv_parser json_parser) (-> (Parser JSON) (Parser [String JSON])) (do <>.monad [key ..string_parser @@ -406,7 +406,7 @@ (in [key value]))) (with_template [<name> <type> <open> <close> <elem_parser> <prep>] - [(def: (<name> json_parser) + [(def (<name> json_parser) (-> (Parser JSON) (Parser <type>)) (do <>.monad [_ (<text>.this <open>) @@ -420,7 +420,7 @@ [object_parser Object ..object_start ..object_end (kv_parser json_parser) (dictionary.of_list text.hash)] ) -(def: json_parser +(def json_parser (Parser JSON) (<>.rec (function (_ json_parser) @@ -432,8 +432,8 @@ (array_parser json_parser) (object_parser json_parser))))) -(def: .public codec +(def .public codec (Codec Text JSON) (implementation - (def: encoded ..format) - (def: decoded (<text>.result json_parser)))) + (def encoded ..format) + (def decoded (<text>.result json_parser)))) diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux index d65c5e6f6..f328045dc 100644 --- a/stdlib/source/library/lux/data/format/markdown.lux +++ b/stdlib/source/library/lux/data/format/markdown.lux @@ -13,7 +13,7 @@ ... https://www.markdownguide.org/basic-syntax/ -(def: safe +(def safe (-> Text Text) (|>> (text.replaced "\" "\\") (text.replaced "`" "\`") @@ -37,19 +37,19 @@ (primitive .public (Markdown brand) Text - (def: .public empty + (def .public empty Markdown (abstraction "")) - (def: .public text + (def .public text (-> Text (Markdown Span)) (|>> ..safe abstraction)) - (def: blank_line + (def blank_line (format text.new_line text.new_line)) (with_template [<name> <prefix>] - [(def: .public (<name> content) + [(def .public (<name> content) (-> Text (Markdown Block)) (abstraction (format <prefix> " " (..safe content) ..blank_line)))] @@ -61,20 +61,20 @@ [heading/6 "######"] ) - (def: (block content) + (def (block content) (-> Text (Markdown Block)) (abstraction (format content ..blank_line))) - (def: .public paragraph + (def .public paragraph (-> (Markdown Span) (Markdown Block)) (|>> representation ..block)) - (def: .public break + (def .public break (Markdown Span) (abstraction (format " " text.new_line))) (with_template [<name> <wrapper>] - [(def: .public <name> + [(def .public <name> (-> (Markdown Span) (Markdown Span)) (|>> representation (text.enclosed [<wrapper> <wrapper>]) @@ -84,7 +84,7 @@ [italic "_"] ) - (def: (prefix with) + (def (prefix with) (-> Text (-> Text Text)) (|>> (text.all_split_by text.new_line) (list#each (function (_ line) @@ -93,17 +93,17 @@ (format with line)))) (text.interposed text.new_line))) - (def: indent + (def indent (-> Text Text) (..prefix text.tab)) - (def: .public quote + (def .public quote (-> (Markdown Block) (Markdown Block)) (|>> representation (..prefix "> ") abstraction)) - (def: .public numbered_list + (def .public numbered_list (-> (List [(Markdown Span) (Maybe (Markdown Block))]) (Markdown Block)) (|>> list.enumeration @@ -122,7 +122,7 @@ (text.interposed text.new_line) ..block)) - (def: .public bullet_list + (def .public bullet_list (-> (List [(Markdown Span) (Maybe (Markdown Block))]) (Markdown Block)) (|>> (list#each (function (_ [summary detail]) @@ -141,19 +141,19 @@ ..block)) ... A snippet of code. - (def: .public snippet + (def .public snippet (-> Text (Markdown Span)) (|>> (text.enclosed ["`` " " ``"]) abstraction)) ... A (generic) block of code. - (def: .public generic_code + (def .public generic_code (-> Text (Markdown Block)) (let [open (format "```" text.new_line) close (format text.new_line "```")] (|>> (text.enclosed [open close]) ..block))) ... A block of code of a specific language. - (def: .public (code language block) + (def .public (code language block) (-> Text Text (Markdown Block)) (let [open (format "```" language text.new_line) close (format text.new_line "```")] @@ -161,15 +161,15 @@ (text.enclosed [open close]) ..block))) - (def: .public (image description url) + (def .public (image description url) (-> Text URL (Markdown Span)) (abstraction (format "![" (..safe description) "](" url ")"))) - (def: .public horizontal_rule + (def .public horizontal_rule (Markdown Block) (..block "___")) - (def: .public (link description url) + (def .public (link description url) (-> (Markdown Span) URL (Markdown Span)) (abstraction (format "[" (representation description) "](" url ")"))) @@ -177,7 +177,7 @@ Text) (with_template [<name> <type>] - [(def: .public <name> + [(def .public <name> (-> <type> (Markdown Span)) (|>> (text.enclosed ["<" ">"]) abstraction))] @@ -186,7 +186,7 @@ ) (with_template [<name> <brand> <infix>] - [(def: .public (<name> pre post) + [(def .public (<name> pre post) (-> (Markdown <brand>) (Markdown <brand>) (Markdown <brand>)) (abstraction (format (representation pre) <infix> (representation post))))] @@ -194,7 +194,7 @@ [then Block ""] ) - (def: .public markdown + (def .public markdown (All (_ a) (-> (Markdown a) Text)) (|>> representation)) ) diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index 272d666de..4fd668306 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -41,11 +41,11 @@ (type: Size Nat) -(def: octal_size +(def octal_size Size 8) -(def: (octal_padding max_size number) +(def (octal_padding max_size number) (-> Size Text Text) (let [padding_size (n.- (text.size number) max_size) @@ -54,16 +54,16 @@ text.together)] (format padding number))) -(def: blank " ") -(def: null text.null) +(def blank " ") +(def null text.null) -(def: small_size Size 6) -(def: big_size Size 11) +(def small_size Size 6) +(def big_size Size 11) (with_template [<exception> <limit> <size> <type> <in> <out> <writer> <suffix> <coercion>] - [(def: .public <limit> + [(def .public <limit> Nat (|> ..octal_size (list.repeated <size>) @@ -78,17 +78,17 @@ (primitive .public <type> Nat - (def: .public (<in> value) + (def .public (<in> value) (-> Nat (Try <type>)) (if (n.< <limit> value) {try.#Success (abstraction value)} (exception.except <exception> [value]))) - (def: .public <out> + (def .public <out> (-> <type> Nat) (|>> representation)) - (def: <writer> + (def <writer> (Writer <type>) (let [suffix <suffix> padded_size (n.+ (text.size suffix) <size>)] @@ -99,7 +99,7 @@ (at utf8.codec encoded) (\\format.segment padded_size)))) - (def: <coercion> + (def <coercion> (-> Nat <type>) (|>> (n.% <limit>) abstraction)) @@ -121,7 +121,7 @@ "Expected" (%.nat expected) "Actual" (%.nat actual))) -(def: small_suffix +(def small_suffix (Parser Any) (do <>.monad [pre_end <binary>.bits_8 @@ -135,7 +135,7 @@ (n.= expected end)))] (in []))) -(def: small_parser +(def small_parser (Parser Small) (do <>.monad [digits (<binary>.segment ..small_size) @@ -146,7 +146,7 @@ [value (at n.octal decoded digits)] (..small value))))) -(def: big_parser +(def big_parser (Parser Big) (do <>.monad [digits (<binary>.segment ..big_size) @@ -163,28 +163,28 @@ (primitive Checksum Text - (def: from_checksum + (def from_checksum (-> Checksum Text) (|>> representation)) - (def: dummy_checksum + (def dummy_checksum Checksum (abstraction " ")) - (def: checksum_suffix + (def checksum_suffix (format ..blank ..null)) - (def: checksum + (def checksum (-> Binary Nat) (binary.mix n.+ 0)) - (def: checksum_checksum + (def checksum_checksum (|> ..dummy_checksum representation (at utf8.codec encoded) ..checksum)) - (def: checksum_code + (def checksum_code (-> Binary Checksum) (|>> ..checksum ..as_small @@ -194,7 +194,7 @@ (text.suffix ..checksum_suffix) abstraction)) - (def: checksum_writer + (def checksum_writer (Writer Checksum) (let [padded_size (n.+ (text.size ..checksum_suffix) ..small_size)] @@ -202,7 +202,7 @@ (at utf8.codec encoded) (\\format.segment padded_size)))) - (def: checksum_parser + (def checksum_parser (Parser [Nat Checksum]) (do <>.monad [ascii (<binary>.segment ..small_size) @@ -214,11 +214,11 @@ (abstraction (format digits ..checksum_suffix))]))) ) -(def: last_ascii +(def last_ascii Char (number.hex "007F")) -(def: ascii? +(def ascii? (-> Text Bit) (|>> (at utf8.codec encoded) (binary.mix (function (_ char verdict) @@ -230,10 +230,10 @@ (exception.report "Text" (%.text text))) -(def: .public name_size Size 31) -(def: .public path_size Size 99) +(def .public name_size Size 31) +(def .public path_size Size 99) -(def: (un_padded string) +(def (un_padded string) (-> Binary Binary) (case (binary!.size string) 0 string @@ -258,7 +258,7 @@ "Size" (%.nat (text.size value)) "Maximum" (%.nat <size>))) - (def: .public (<in> value) + (def .public (<in> value) (-> <representation> (Try <type>)) (if (..ascii? value) (if (|> value @@ -269,11 +269,11 @@ {try.#Success (abstraction value)}) (exception.except ..not_ascii [value]))) - (def: .public <out> + (def .public <out> (-> <type> <representation>) (|>> representation)) - (def: <writer> + (def <writer> (Writer <type>) (let [suffix ..null padded_size (n.+ (text.size suffix) <size>)] @@ -282,7 +282,7 @@ (at utf8.codec encoded) (\\format.segment padded_size)))) - (def: <parser> + (def <parser> (Parser <type>) (do <>.monad [string (<binary>.segment <size>) @@ -295,7 +295,7 @@ [text (at utf8.codec decoded (..un_padded string))] (<in> text))))) - (def: .public <none> + (def .public <none> <type> (try.trusted (<in> ""))) )] @@ -304,19 +304,19 @@ [Path file.Path ..path_size path_is_too_long path from_path path_writer path_parser no_path] ) -(def: magic_size Size 7) +(def magic_size Size 7) (primitive Magic Text - (def: ustar + (def ustar (abstraction "ustar ")) - (def: from_magic + (def from_magic (-> Magic Text) (|>> representation)) - (def: magic_writer + (def magic_writer (Writer Magic) (let [padded_size (n.+ (text.size ..null) ..magic_size)] @@ -324,7 +324,7 @@ (at utf8.codec encoded) (\\format.segment padded_size)))) - (def: magic_parser + (def magic_parser (Parser Magic) (do <>.monad [string (<binary>.segment ..magic_size) @@ -337,32 +337,32 @@ (at utf8.codec decoded string))))) ) -(def: block_size Size 512) +(def block_size Size 512) -(def: owner_id_size ..small_size) +(def owner_id_size ..small_size) -(def: blank_size Size (text.size ..blank)) -(def: null_size Size (text.size ..null)) -(def: mode_size Size ..small_size) -(def: content_size Size ..big_size) -(def: modification_time_size Size ..big_size) -(def: checksum_size Size ..small_size) -(def: link_flag_size Size 1) -(def: device_size Size ..small_size) +(def blank_size Size (text.size ..blank)) +(def null_size Size (text.size ..null)) +(def mode_size Size ..small_size) +(def content_size Size ..big_size) +(def modification_time_size Size ..big_size) +(def checksum_size Size ..small_size) +(def link_flag_size Size 1) +(def device_size Size ..small_size) -(def: small_number +(def small_number (-> Size Size) (|>> (all n.+ ..blank_size ..null_size))) -(def: big_number +(def big_number (-> Size Size) (|>> (all n.+ ..blank_size))) -(def: string +(def string (-> Size Size) (|>> (all n.+ ..null_size))) -(def: header_size +(def header_size (all n.+ ... name (..string ..path_size) @@ -396,11 +396,11 @@ (primitive Link_Flag Char - (def: link_flag + (def link_flag (-> Link_Flag Char) (|>> representation)) - (def: link_flag_writer + (def link_flag_writer (Writer Link_Flag) (|>> representation \\format.bits_8)) @@ -415,7 +415,7 @@ [(char "6") fifo] [(char "7") contiguous])] (with_template [<flag> <name>] - [(def: <name> + [(def <name> Link_Flag (abstraction <flag>))] @@ -426,7 +426,7 @@ (exception.report "Value" (%.nat value))) - (def: link_flag_parser + (def link_flag_parser (Parser Link_Flag) (do <>.monad [it <binary>.bits_8] @@ -444,17 +444,17 @@ (primitive .public Mode Nat - (def: .public mode + (def .public mode (-> Mode Nat) (|>> representation)) - (def: .public (and left right) + (def .public (and left right) (-> Mode Mode Mode) (abstraction (i64.or (representation left) (representation right)))) - (def: mode_writer + (def mode_writer (Writer Mode) (|>> representation ..small @@ -483,14 +483,14 @@ ["2000" set_group_id_on_execution] ["4000" set_user_id_on_execution])] (with_template [<code> <name>] - [(def: .public <name> + [(def .public <name> Mode (abstraction (number.oct <code>)))] <options> ) - (def: maximum_mode + (def maximum_mode Mode (all and ..none @@ -512,7 +512,7 @@ ..set_user_id_on_execution )) - (def: mode_parser + (def mode_parser (Parser Mode) (do [! <>.monad] [value (at ! each ..from_small ..small_parser)] @@ -523,7 +523,7 @@ (in (abstraction value)))))) ) -(def: maximum_content_size +(def maximum_content_size Nat (|> ..octal_size (list.repeated ..content_size) @@ -532,17 +532,17 @@ (primitive .public Content [Big Binary] - (def: .public (content content) + (def .public (content content) (-> Binary (Try Content)) (do try.monad [size (..big (binary!.size content))] (in (abstraction [size content])))) - (def: from_content + (def from_content (-> Content [Big Binary]) (|>> representation)) - (def: .public data + (def .public data (-> Content Binary) (|>> representation product.right)) ) @@ -550,7 +550,7 @@ (type: .public ID Small) -(def: .public no_id +(def .public no_id ID (..as_small 0)) @@ -582,14 +582,14 @@ (type: Device Small) -(def: no_device +(def no_device Device (try.trusted (..small 0))) (type: .public Tar (Sequence Entry)) -(def: (blocks size) +(def (blocks size) (-> Big Nat) (n.+ (n./ ..block_size (..from_big size)) @@ -597,7 +597,7 @@ 0 0 _ 1))) -(def: rounded_content_size +(def rounded_content_size (-> Big Nat) (|>> ..blocks (n.* ..block_size))) @@ -619,7 +619,7 @@ #major_device Device #minor_device Device])) -(def: header_writer' +(def header_writer' (Writer Header) (all \\format.and ..path_writer @@ -638,7 +638,7 @@ ..small_writer )) -(def: (header_writer header) +(def (header_writer header) (Writer Header) (let [checksum (|> header (has #checksum ..dummy_checksum) @@ -649,14 +649,14 @@ (\\format.result ..header_writer') (\\format.segment ..block_size)))) -(def: modification_time +(def modification_time (-> Instant Big) (|>> instant.relative (duration.ticks duration.second) .nat ..as_big)) -(def: (file_writer link_flag) +(def (file_writer link_flag) (-> Link_Flag (Writer File)) (function (_ [path modification_time mode ownership content]) (let [[size content] (..from_content content) @@ -679,15 +679,15 @@ #minor_device ..no_device] content])))) -(def: normal_file_writer +(def normal_file_writer (Writer File) (..file_writer ..normal)) -(def: contiguous_file_writer +(def contiguous_file_writer (Writer File) (..file_writer ..contiguous)) -(def: (symbolic_link_writer path) +(def (symbolic_link_writer path) (Writer Path) (..header_writer [#path ..no_path @@ -705,7 +705,7 @@ #major_device ..no_device #minor_device ..no_device])) -(def: (directory_writer path) +(def (directory_writer path) (Writer Path) (..header_writer [#path path @@ -723,7 +723,7 @@ #major_device ..no_device #minor_device ..no_device])) -(def: entry_writer +(def entry_writer (Writer Entry) (|>> (pipe.case {#Normal value} (..normal_file_writer value) @@ -731,11 +731,11 @@ {#Directory value} (..directory_writer value) {#Contiguous value} (..contiguous_file_writer value)))) -(def: end_of_archive_size +(def end_of_archive_size Size (n.* 2 ..block_size)) -(def: .public writer +(def .public writer (Writer Tar) (let [end_of_archive (binary!.empty ..end_of_archive_size)] (function (_ tar) @@ -751,7 +751,7 @@ "Expected" (%.nat expected) "Actual" (%.nat actual))) -(def: header_padding_size +(def header_padding_size (n.- header_size block_size)) ... When the checksum gets originally calculated, the assumption is that all the characters in the checksum field @@ -760,7 +760,7 @@ ... an incorrect result, as the contents of the checksum field would be an actual checksum, instead of just spaces. ... To correct for this, it is necessary to calculate the checksum of just the checksum field, subtract that, and then ... add-in the checksum of the spaces. -(def: (expected_checksum checksum header) +(def (expected_checksum checksum header) (-> Checksum Binary Nat) (let [|checksum| (|> checksum ..from_checksum @@ -770,7 +770,7 @@ (n.- |checksum|) (n.+ ..checksum_checksum)))) -(def: header_parser +(def header_parser (Parser Header) (do <>.monad [binary_header (<>.speculative (<binary>.segment block_size)) @@ -808,7 +808,7 @@ #major_device major_device #minor_device minor_device]))) -(def: (file_parser header) +(def (file_parser header) (-> Header (Parser File)) (do <>.monad [.let [size (the #size header) @@ -831,7 +831,7 @@ #id (the #group_id header)]] content]))) -(def: entry_parser +(def entry_parser (Parser Entry) (do [! <>.monad] [header ..header_parser] @@ -850,7 +850,7 @@ ... It's safe to implement the parser this way because the range of values for Nat is 2^64 ... Whereas the maximum possible value for the checksum of a 512 block is (256 × 512) = 131,072 -(def: end_of_archive_block_parser +(def end_of_archive_block_parser (Parser Any) (do <>.monad [block (<binary>.segment ..block_size)] @@ -861,7 +861,7 @@ (exception: .public invalid_end_of_archive) -(def: end_of_archive_parser +(def end_of_archive_parser (Parser Any) (do <>.monad [_ (<>.at_most 2 end_of_archive_block_parser) @@ -870,7 +870,7 @@ (exception.assertion ..invalid_end_of_archive [] done?)))) -(def: .public parser +(def .public parser (Parser Tar) (|> (<>.some ..entry_parser) (at <>.monad each sequence.of_list) diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux index ff08ad834..41ec13be0 100644 --- a/stdlib/source/library/lux/data/format/xml.lux +++ b/stdlib/source/library/lux/data/format/xml.lux @@ -31,7 +31,7 @@ (type: .public Attrs (Dictionary Attribute Text)) -(def: .public attributes +(def .public attributes Attrs (dictionary.empty symbol.hash)) @@ -41,10 +41,10 @@ {#Text Text} {#Node Tag Attrs (List XML)}))) -(def: namespace_separator +(def namespace_separator ":") -(def: xml_standard_escape_char^ +(def xml_standard_escape_char^ (Parser Text) (all <>.either (<>.after (<text>.this "<") (<>#in "<")) @@ -54,7 +54,7 @@ (<>.after (<text>.this """) (<>#in text.double_quote)) )) -(def: xml_unicode_escape_char^ +(def xml_unicode_escape_char^ (Parser Text) (|> (do [! <>.monad] [hex? (<>.maybe (<text>.this "x"))] @@ -71,17 +71,17 @@ (<>.before (<text>.this ";")) (<>.after (<text>.this "&#")))) -(def: xml_escape_char^ +(def xml_escape_char^ (Parser Text) (<>.either xml_standard_escape_char^ xml_unicode_escape_char^)) -(def: xml_char^ +(def xml_char^ (Parser Text) (<>.either (<text>.none_of (all text#composite "<>&" text.double_quote)) xml_escape_char^)) -(def: xml_identifier +(def xml_identifier (Parser Text) (<text>.slice (all <text>.and! @@ -90,7 +90,7 @@ (<text>.some! (<>.either (<text>.one_of! "_.-") <text>.alpha_num!))))) -(def: namespaced_symbol^ +(def namespaced_symbol^ (Parser Symbol) (do <>.monad [first_part xml_identifier @@ -102,22 +102,22 @@ {.#Some second_part} (in [first_part second_part])))) -(def: tag^ namespaced_symbol^) -(def: attr_name^ namespaced_symbol^) +(def tag^ namespaced_symbol^) +(def attr_name^ namespaced_symbol^) -(def: spaced^ +(def spaced^ (All (_ a) (-> (Parser a) (Parser a))) (let [white_space^ (<>.some <text>.space)] (|>> (<>.before white_space^) (<>.after white_space^)))) -(def: attr_value^ +(def attr_value^ (Parser Text) (let [value^ (<text>.some xml_char^)] (<>.either (<text>.enclosed [text.double_quote text.double_quote] value^) (<text>.enclosed ["'" "'"] value^)))) -(def: attrs^ +(def attrs^ (Parser Attrs) (<| (at <>.monad each (dictionary.of_list symbol.hash)) <>.some @@ -125,7 +125,7 @@ (<>.after (<text>.this "=")) (..spaced^ attr_value^))) -(def: (close_tag^ expected) +(def (close_tag^ expected) (-> Tag (Parser [])) (do <>.monad [actual (|> tag^ @@ -137,21 +137,21 @@ " Actual: " (symbol#encoded actual) \n) (symbol#= expected actual)))) -(def: comment^ +(def comment^ (Parser Slice) (|> (<text>.not! (<text>.this "--")) <text>.some! (<text>.enclosed ["<!--" "-->"]) ..spaced^)) -(def: xml_header^ +(def xml_header^ (Parser Attrs) (|> (..spaced^ attrs^) (<>.before (<text>.this "?>")) (<>.after (<text>.this "<?xml")) ..spaced^)) -(def: cdata^ +(def cdata^ (Parser Slice) (let [end (<text>.this "]]>")] (|> (<text>.some! (<text>.not! end)) @@ -159,17 +159,17 @@ (<>.after (<text>.this "<![CDATA[")) ..spaced^))) -(def: text^ +(def text^ (Parser XML) (|> (..spaced^ (<text>.many xml_char^)) (<>.either (<text>.slice cdata^)) (<>#each (|>> {#Text})))) -(def: null^ +(def null^ (Parser Any) (<text>.this (text.of_char 0))) -(def: xml^ +(def xml^ (Parser XML) (|> (<>.rec (function (_ node^) @@ -202,7 +202,7 @@ (<>.before (<>.some ..null^)) (<>.after (<>.maybe ..xml_header^)))) -(def: (sanitize_value input) +(def (sanitize_value input) (-> Text Text) (|> input (text.replaced "&" "&") @@ -211,17 +211,17 @@ (text.replaced "'" "'") (text.replaced text.double_quote """))) -(def: .public (tag [namespace name]) +(def .public (tag [namespace name]) (-> Tag Text) (case namespace "" name _ (all text#composite namespace ..namespace_separator name))) -(def: .public attribute +(def .public attribute (-> Attribute Text) ..tag) -(def: xml_header +(def xml_header Text (let [quote (is (-> Text Text) (function (_ value) @@ -232,10 +232,10 @@ " encoding=" (quote "UTF-8") "?>"))) -(def: .public codec +(def .public codec (Codec Text XML) (implementation - (def: encoded + (def encoded (let [attributes (is (-> Attrs Text) (function (_ attrs) (|> attrs @@ -275,13 +275,13 @@ text.together) text.new_line prefix "</" tag ">"))))) )))) - (def: decoded + (def decoded (<text>.result ..xml^)))) -(def: .public equivalence +(def .public equivalence (Equivalence XML) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Text reference/value} {#Text sample/value}] (text#= reference/value sample/value) diff --git a/stdlib/source/library/lux/data/identity.lux b/stdlib/source/library/lux/data/identity.lux index 55e942681..30d890dff 100644 --- a/stdlib/source/library/lux/data/identity.lux +++ b/stdlib/source/library/lux/data/identity.lux @@ -12,28 +12,28 @@ (type: .public (Identity a) a) -(def: .public functor +(def .public functor (Functor Identity) (implementation - (def: each function.identity))) + (def each function.identity))) -(def: .public apply +(def .public apply (Apply Identity) (implementation - (def: functor ..functor) - (def: (on fa ff) + (def functor ..functor) + (def (on fa ff) (ff fa)))) -(def: .public monad +(def .public monad (Monad Identity) (implementation - (def: functor ..functor) - (def: in function.identity) - (def: conjoint function.identity))) + (def functor ..functor) + (def in function.identity) + (def conjoint function.identity))) -(def: .public comonad +(def .public comonad (CoMonad Identity) (implementation - (def: functor ..functor) - (def: out function.identity) - (def: disjoint function.identity))) + (def functor ..functor) + (def out function.identity) + (def disjoint function.identity))) diff --git a/stdlib/source/library/lux/data/product.lux b/stdlib/source/library/lux/data/product.lux index 02caab668..6e8767e04 100644 --- a/stdlib/source/library/lux/data/product.lux +++ b/stdlib/source/library/lux/data/product.lux @@ -6,7 +6,7 @@ [hash (.only Hash)]]]]) (with_template [<name>] - [(def: .public (<name> [left right]) + [(def .public (<name> [left right]) (All (_ left right) (-> [left right] <name>)) <name>)] @@ -16,14 +16,14 @@ ) ... https://en.wikipedia.org/wiki/Currying -(def: .public (curried f) +(def .public (curried f) (All (_ a b c) (-> (-> [a b] c) (-> a b c))) (function (_ x y) (f [x y]))) -(def: .public (uncurried f) +(def .public (uncurried f) (All (_ a b c) (-> (-> a b c) (-> [a b] c))) @@ -31,38 +31,38 @@ (let [[x y] xy] (f x y)))) -(def: .public (swapped [left right]) +(def .public (swapped [left right]) (All (_ left right) (-> [left right] [right left])) [right left]) -(def: .public (then f g) +(def .public (then f g) (All (_ a b c d) (-> (-> a c) (-> b d) (-> [a b] [c d]))) (function (_ [x y]) [(f x) (g y)])) -(def: .public (forked f g) +(def .public (forked f g) (All (_ a l r) (-> (-> a l) (-> a r) (-> a [l r]))) (function (_ x) [(f x) (g x)])) -(def: .public (equivalence left right) +(def .public (equivalence left right) (All (_ l r) (-> (Equivalence l) (Equivalence r) (Equivalence [l r]))) (implementation - (def: (= [rl rr] [sl sr]) + (def (= [rl rr] [sl sr]) (and (at left = rl sl) (at right = rr sr))))) -(def: .public (hash left right) +(def .public (hash left right) (All (_ l r) (-> (Hash l) (Hash r) (Hash [l r]))) (implementation - (def: equivalence + (def equivalence (..equivalence (at left equivalence) (at right equivalence))) - (def: (hash [leftV rightV]) + (def (hash [leftV rightV]) ("lux i64 +" (at left hash leftV) (at right hash rightV))))) diff --git a/stdlib/source/library/lux/data/store.lux b/stdlib/source/library/lux/data/store.lux index c5b82a4c5..8e4c0746d 100644 --- a/stdlib/source/library/lux/data/store.lux +++ b/stdlib/source/library/lux/data/store.lux @@ -12,43 +12,43 @@ [#cursor s #peek (-> s a)])) -(def: (extend f wa) +(def (extend f wa) (All (_ s a b) (-> (-> (Store s a) b) (Store s a) (Store s b))) [#cursor (the #cursor wa) #peek (function (_ s) (f (has #cursor s wa)))]) -(def: .public functor +(def .public functor (All (_ s) (Functor (Store s))) (implementation - (def: (each f fa) + (def (each f fa) (extend (function (_ store) (f (at store peek (at store cursor)))) fa)))) -(def: .public comonad +(def .public comonad (All (_ s) (CoMonad (Store s))) (implementation - (def: functor + (def functor ..functor) - (def: (out wa) + (def (out wa) (a/an peek (a/an cursor))) - (def: disjoint + (def disjoint (extend id)))) -(def: .public (peeks trans store) +(def .public (peeks trans store) (All (_ s a) (-> (-> s s) (Store s a) a)) (|> (a/an cursor) trans (a/an peek))) -(def: .public (seek cursor store) +(def .public (seek cursor store) (All (_ s a) (-> s (Store s a) (Store s a))) (at (a/an disjoint store) peek cursor)) -(def: .public (seeks change store) +(def .public (seeks change store) (All (_ s a) (-> (-> s s) (Store s a) (Store s a))) (|> store (a/an disjoint) (peeks change))) -(def: .public (experiment Functor<f> change store) +(def .public (experiment Functor<f> change store) (All (_ f s a) (-> (Functor f) (-> s (f s)) (Store s a) (f a))) (at Functor<f> each (a/an peek) (change (a/an cursor)))) diff --git a/stdlib/source/library/lux/data/sum.lux b/stdlib/source/library/lux/data/sum.lux index 00dddc0e6..ce03e75d6 100644 --- a/stdlib/source/library/lux/data/sum.lux +++ b/stdlib/source/library/lux/data/sum.lux @@ -6,7 +6,7 @@ [hash (.only Hash)]]]]) (with_template [<right?> <name>] - [(def: .public (<name> value) + [(def .public (<name> value) (All (_ left right) (-> <name> (Or left right))) {0 <right?> value})] @@ -14,7 +14,7 @@ [#0 left] [#1 right]) -(def: .public (either on_left on_right) +(def .public (either on_left on_right) (All (_ a b c) (-> (-> a c) (-> b c) (-> (Or a b) c))) @@ -23,7 +23,7 @@ {0 #0 l} (on_left l) {0 #1 r} (on_right r)))) -(def: .public (then on_left on_right) +(def .public (then on_left on_right) (All (_ l l' r r') (-> (-> l l') (-> r r') (-> (Or l r) (Or l' r')))) @@ -33,7 +33,7 @@ {0 #1 r} {0 #1 (on_right r)}))) (with_template [<name> <side> <right?>] - [(def: .public (<name> items) + [(def .public (<name> items) (All (_ a b) (-> (List (Or a b)) (List <side>))) (case items {.#End} @@ -49,7 +49,7 @@ [rights b #1] ) -(def: .public (partition xs) +(def .public (partition xs) (All (_ a b) (-> (List (Or a b)) [(List a) (List b)])) (case xs {.#End} @@ -61,10 +61,10 @@ {0 #0 x'} [{.#Item x' lefts} rights] {0 #1 x'} [lefts {.#Item x' rights}])))) -(def: .public (equivalence left right) +(def .public (equivalence left right) (All (_ l r) (-> (Equivalence l) (Equivalence r) (Equivalence (Or l r)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{.#Left reference} {.#Left sample}] (at left = reference sample) @@ -75,13 +75,13 @@ _ false)))) -(def: .public (hash left right) +(def .public (hash left right) (All (_ l r) (-> (Hash l) (Hash r) (Hash (Or l r)))) (implementation - (def: equivalence + (def equivalence (..equivalence (at left equivalence) (at right equivalence))) - (def: (hash value) + (def (hash value) (.nat (case value {.#Left value} ("lux i64 *" +2 (.int (at left hash value))) diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index 918fde82a..9c2649f55 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -26,13 +26,13 @@ ... TODO: Instead of ints, chars should be produced fron nats. ... (The JVM specifies chars as 16-bit unsigned integers) -(def: .public of_char +(def .public of_char (-> Char Text) (|>> .int "lux i64 char")) (with_template [<code> <short> <long>] - [(def: .public <long> (..of_char <code>)) - (def: .public <short> <long>)] + [(def .public <long> (..of_char <code>)) + (def .public <short> <long>)] [00 \0 null] [07 \a alarm] @@ -45,28 +45,28 @@ [34 \'' double_quote] ) -(def: .public line_feed +(def .public line_feed ..new_line) -(def: .public size +(def .public size (-> Text Nat) (|>> "lux text size")) -(def: .public (char index input) +(def .public (char index input) (-> Nat Text (Maybe Char)) (if (n.< ("lux text size" input) index) {.#Some ("lux text char" index input)} {.#None})) -(def: .public (index_since offset pattern input) +(def .public (index_since offset pattern input) (-> Nat Text Text (Maybe Nat)) ("lux text index" offset pattern input)) -(def: .public (index pattern input) +(def .public (index pattern input) (-> Text Text (Maybe Nat)) (index_since 0 pattern input)) -(def: .public (last_index part text) +(def .public (last_index part text) (-> Text Text (Maybe Nat)) (loop (again [offset 0 output (is (Maybe Nat) @@ -79,7 +79,7 @@ {.#Some offset'} (again (++ offset') output'))))) -(def: .public (starts_with? prefix x) +(def .public (starts_with? prefix x) (-> Text Text Bit) (case (index prefix x) {.#Some 0} @@ -88,7 +88,7 @@ _ false)) -(def: .public (ends_with? postfix x) +(def .public (ends_with? postfix x) (-> Text Text Bit) (case (last_index postfix x) {.#Some n} @@ -98,12 +98,12 @@ _ false)) -(def: .public (enclosed_by? boundary value) +(def .public (enclosed_by? boundary value) (-> Text Text Bit) (and (starts_with? boundary value) (ends_with? boundary value))) -(def: .public (contains? sub text) +(def .public (contains? sub text) (-> Text Text Bit) (case ("lux text index" 0 sub text) {.#Some _} @@ -112,40 +112,40 @@ _ false)) -(def: .public (prefix param subject) +(def .public (prefix param subject) (-> Text Text Text) ("lux text concat" param subject)) -(def: .public (suffix param subject) +(def .public (suffix param subject) (-> Text Text Text) ("lux text concat" subject param)) -(def: .public (enclosed [left right] content) +(def .public (enclosed [left right] content) (-> [Text Text] Text Text) (all "lux text concat" left content right)) -(def: .public (enclosed' boundary content) +(def .public (enclosed' boundary content) (-> Text Text Text) (enclosed [boundary boundary] content)) -(def: .public format +(def .public format (-> Text Text) (..enclosed' ..double_quote)) -(def: .public (clip offset size input) +(def .public (clip offset size input) (-> Nat Nat Text (Maybe Text)) (if (|> size (n.+ offset) (n.> ("lux text size" input))) {.#None} {.#Some ("lux text clip" offset size input)})) -(def: .public (clip_since offset input) +(def .public (clip_since offset input) (-> Nat Text (Maybe Text)) (let [size ("lux text size" input)] (if (n.> size offset) {.#None} {.#Some ("lux text clip" offset (n.- offset size) input)}))) -(def: .public (split_at at x) +(def .public (split_at at x) (-> Nat Text (Maybe [Text Text])) (case [(..clip 0 at x) (..clip_since at x)] [{.#Some pre} {.#Some post}] @@ -154,7 +154,7 @@ _ {.#None})) -(def: .public (split_by token sample) +(def .public (split_by token sample) (-> Text Text (Maybe [Text Text])) (do maybe.monad [index (index token sample) @@ -162,7 +162,7 @@ [_ post] (split_at (size token) post')] (in [pre post]))) -(def: .public (all_split_by token sample) +(def .public (all_split_by token sample) (-> Text Text (List Text)) (loop (again [input sample output (is (List Text) (list))]) @@ -177,14 +177,14 @@ {.#Item input} list.reversed)))) -(def: .public (replaced_once pattern replacement template) +(def .public (replaced_once pattern replacement template) (-> Text Text Text Text) (<| (maybe.else template) (do maybe.monad [[pre post] (..split_by pattern template)] (in (all "lux text concat" pre replacement post))))) -(for @.js (these (def: defined? +(for @.js (these (def defined? (macro (_ tokens lux) (case tokens (pattern (list it)) @@ -197,7 +197,7 @@ _ {.#Left ""}))) - (def: if_nashorn + (def if_nashorn (macro (_ tokens lux) (case tokens (pattern (list then else)) @@ -211,7 +211,7 @@ {.#Left ""})))) (these)) -(def: .public (replaced pattern replacement template) +(def .public (replaced pattern replacement template) (-> Text Text Text Text) (with_expansions [... Inefficient default <default> (loop (again [left "" @@ -258,34 +258,34 @@ ... Inefficient default <default>))) -(def: .public equivalence +(def .public equivalence (Equivalence Text) (implementation - (def: (= reference sample) + (def (= reference sample) ("lux text =" reference sample)))) -(def: .public order +(def .public order (Order Text) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< reference sample) + (def (< reference sample) ("lux text <" reference sample)))) -(def: .public monoid +(def .public monoid (Monoid Text) (implementation - (def: identity "") + (def identity "") - (def: (composite left right) + (def (composite left right) ("lux text concat" left right)))) -(def: .public hash +(def .public hash (Hash Text) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (hash input) + (def (hash input) (for @.old (|> input (is (Primitive "java.lang.Object")) @@ -313,29 +313,29 @@ (n.+ ("lux text char" index input)))) hash))))))) -(def: .public together +(def .public together (-> (List Text) Text) (let [(^.open "[0]") ..monoid] (|>> list.reversed (list#mix composite identity)))) -(def: .public (interposed separator texts) +(def .public (interposed separator texts) (-> Text (List Text) Text) (case separator "" (..together texts) _ (|> texts (list.interposed separator) ..together))) -(def: .public (empty? text) +(def .public (empty? text) (-> Text Bit) (case text "" true _ false)) -(def: .public space +(def .public space Text " ") -(def: .public (space? char) +(def .public (space? char) (-> Char Bit) (with_expansions [<options> (with_template [<char>] [(pattern (.char (~~ (static <char>))))] @@ -354,7 +354,7 @@ _ false)))) -(def: .public (lower_cased value) +(def .public (lower_cased value) (-> Text Text) (for @.old (as Text @@ -377,7 +377,7 @@ (as Text ("ruby object do" "downcase" value [])))) -(def: .public (upper_cased value) +(def .public (upper_cased value) (-> Text Text) (for @.old (as Text diff --git a/stdlib/source/library/lux/data/text/buffer.lux b/stdlib/source/library/lux/data/text/buffer.lux index a099758f5..82404b2dd 100644 --- a/stdlib/source/library/lux/data/text/buffer.lux +++ b/stdlib/source/library/lux/data/text/buffer.lux @@ -56,7 +56,7 @@ ... default (Sequence Text)) - (def: .public empty + (def .public empty Buffer (abstraction (with_expansions [<jvm> [0 function.identity]] (for @.old <jvm> @@ -66,7 +66,7 @@ ... default sequence.empty)))) - (def: .public (then chunk buffer) + (def .public (then chunk buffer) (-> Text Buffer Buffer) (with_expansions [<jvm> (let [[capacity transform] (representation buffer) then! (is (-> Text java/lang/StringBuilder java/lang/StringBuilder) @@ -98,7 +98,7 @@ ... default (|> buffer representation (sequence.suffix chunk) abstraction)))) - (def: .public size + (def .public size (-> Buffer Nat) (with_expansions [<jvm> (|>> representation product.left)] (for @.old <jvm> @@ -111,7 +111,7 @@ (n.+ (//.size chunk) total)) 0))))) - (def: .public (text buffer) + (def .public (text buffer) (-> Buffer Text) (with_expansions [<jvm> (let [[capacity transform] (representation buffer)] (|> (java/lang/StringBuilder::new (ffi.as_int (.int capacity))) diff --git a/stdlib/source/library/lux/data/text/encoding.lux b/stdlib/source/library/lux/data/text/encoding.lux index 2863d9623..16a0a2891 100644 --- a/stdlib/source/library/lux/data/text/encoding.lux +++ b/stdlib/source/library/lux/data/text/encoding.lux @@ -11,7 +11,7 @@ Text (with_template [<name> <encoding>] - [(`` (def: .public <name> + [(`` (def .public <name> Encoding (abstraction <encoding>)))] @@ -160,7 +160,7 @@ [koi8_u "KOI8-U"] ) - (def: .public name + (def .public name (-> Encoding Text) (|>> representation)) ) diff --git a/stdlib/source/library/lux/data/text/encoding/utf8.lux b/stdlib/source/library/lux/data/text/encoding/utf8.lux index a95d4f163..8c7e5ef26 100644 --- a/stdlib/source/library/lux/data/text/encoding/utf8.lux +++ b/stdlib/source/library/lux/data/text/encoding/utf8.lux @@ -55,7 +55,7 @@ (these (ffi.import Almost_Binary) (ffi.import (unpack [ffi.String ffi.String] Almost_Binary)) (ffi.import (array_values [Almost_Binary] Binary)) - (def: php_byte_array_format "C*")) + (def php_byte_array_format "C*")) @.scheme ... https://srfi.schemers.org/srfi-140/srfi-140.html @@ -63,7 +63,7 @@ (ffi.import (utf8->string [Binary] Text))) (these))) -(def: (encoded value) +(def (encoded value) (-> Text Binary) (for @.old (java/lang/String::getBytes (ffi.as_string (//.name //.utf_8)) @@ -109,7 +109,7 @@ @.scheme (..string->utf8 value))) -(def: (decoded value) +(def (decoded value) (-> Binary (Try Text)) (with_expansions [<jvm> {try.#Success (ffi.of_string (java/lang/String::new value (ffi.as_string (//.name //.utf_8))))}] (for @.old <jvm> @@ -155,8 +155,8 @@ ..utf8->string {try.#Success})))) -(def: .public codec +(def .public codec (Codec Binary Text) (implementation - (def: encoded ..encoded) - (def: decoded ..decoded))) + (def encoded ..encoded) + (def decoded ..decoded))) diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux index 258c5c3a9..f2c21a26e 100644 --- a/stdlib/source/library/lux/data/text/escape.lux +++ b/stdlib/source/library/lux/data/text/escape.lux @@ -20,10 +20,10 @@ ["[0]" // (.only Char) ["%" \\format (.only format)]]) -(def: sigil "\") +(def sigil "\") (with_template [<char> <sigil>] - [(def: <char> + [(def <char> (|> <sigil> (//.char 0) maybe.trusted))] [sigil_char ..sigil] @@ -31,10 +31,10 @@ ) (with_template [<literal> <sigil> <escaped>] - [(def: <sigil> + [(def <sigil> (|> <literal> (//.char 0) maybe.trusted)) - (def: <escaped> + (def <escaped> (format ..sigil <literal>))] ["0" \0_sigil escaped_\0] @@ -50,7 +50,7 @@ ) (with_template [<char> <text>] - [(def: <char> + [(def <char> (|> <text> (//.char 0) maybe.trusted))] [\0 //.\0] @@ -65,10 +65,10 @@ [\\ ..sigil] ) -(def: ascii_bottom (hex "20")) -(def: ascii_top (hex "7E")) +(def ascii_bottom (hex "20")) +(def ascii_top (hex "7E")) -(def: .public (escapable? char) +(def .public (escapable? char) (-> Char Bit) (or (n.< ..ascii_bottom char) (n.> ..ascii_top char) @@ -83,7 +83,7 @@ _ false))) -(def: (ascii_escaped replacement pre_offset pre_limit previous current) +(def (ascii_escaped replacement pre_offset pre_limit previous current) (-> Text Nat Nat Text Text [Text Text Nat]) (let [post_offset (++ pre_offset) post_limit (n.- post_offset pre_limit)] @@ -93,7 +93,7 @@ ("lux text clip" post_offset post_limit current) post_limit])) -(def: (unicode_escaped char pre_offset pre_limit previous current) +(def (unicode_escaped char pre_offset pre_limit previous current) (-> Char Nat Nat Text Text [Text Text Nat]) (let [code (at n.hex encoded char) replacement (format ..sigil "u" @@ -110,7 +110,7 @@ ("lux text clip" post_offset post_limit current) post_limit])) -(def: .public (escaped text) +(def .public (escaped text) (-> Text Text) (loop (again [offset 0 previous "" @@ -160,16 +160,16 @@ "In" (%.text text) "At" (%.nat offset))) -(def: code_size +(def code_size 4) -(def: ascii_escape_offset +(def ascii_escape_offset 2) -(def: unicode_escape_offset +(def unicode_escape_offset (n.+ ..ascii_escape_offset ..code_size)) -(def: (ascii_un_escaped replacement offset previous current limit) +(def (ascii_un_escaped replacement offset previous current limit) (-> Text Nat Text Text Nat [Text Text Nat]) (let [limit' (|> limit (n.- offset) (n.- ..ascii_escape_offset))] [(format previous @@ -178,7 +178,7 @@ ("lux text clip" (n.+ ..ascii_escape_offset offset) limit' current) limit'])) -(def: (unicode_un_escaped offset previous current limit) +(def (unicode_un_escaped offset previous current limit) (-> Nat Text Text Nat (Try [Text Text Nat])) (case (|> current ("lux text clip" (n.+ ..ascii_escape_offset offset) ..code_size) @@ -194,7 +194,7 @@ {try.#Failure error} (exception.except ..invalid_unicode_escape [current offset]))) -(def: .public (un_escaped text) +(def .public (un_escaped text) (-> Text (Try Text)) (loop (again [offset 0 previous "" @@ -239,7 +239,7 @@ "" current _ (format previous current))}))) -(def: .public literal +(def .public literal (syntax (_ [literal <code>.text]) (case (..un_escaped literal) {try.#Success un_escaped} diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index 34ce70739..6648375ba 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -26,11 +26,11 @@ ["[0]" // (.only) ["%" \\format (.only format)]]) -(def: regex_char^ +(def regex_char^ (Parser Text) (<text>.none_of "\.|&()[]{}")) -(def: escaped_char^ +(def escaped_char^ (Parser Text) (do <>.monad [? (<>.parses? (<text>.this "\"))] @@ -38,31 +38,31 @@ <text>.any regex_char^))) -(def: (refine^ refinement^ base^) +(def (refine^ refinement^ base^) (All (_ a) (-> (Parser a) (Parser Text) (Parser Text))) (do <>.monad [output base^ _ (<text>.local output refinement^)] (in output))) -(def: word^ +(def word^ (Parser Text) (<>.either <text>.alpha_num (<text>.one_of "_"))) -(def: (copy reference) +(def (copy reference) (-> Text (Parser Text)) (<>.after (<text>.this reference) (<>#in reference))) -(def: together^ +(def together^ (-> (Parser (List Text)) (Parser Text)) (at <>.monad each //.together)) -(def: symbol_char^ +(def symbol_char^ (Parser Text) (<text>.none_of (format "[]{}()s.<>" //.double_quote))) -(def: symbol_part^ +(def symbol_part^ (Parser Text) (do <>.monad [head (refine^ (<text>.not <text>.decimal) @@ -70,7 +70,7 @@ tail (<text>.some symbol_char^)] (in (format head tail)))) -(def: (symbol^ current_module) +(def (symbol^ current_module) (-> Text (Parser Symbol)) (all <>.either (<>.and (<>#in current_module) (<>.after (<text>.this "..") symbol_part^)) @@ -78,13 +78,13 @@ (<>.and (<>#in .prelude) (<>.after (<text>.this ".") symbol_part^)) (<>.and (<>#in "") symbol_part^))) -(def: (re_var^ current_module) +(def (re_var^ current_module) (-> Text (Parser Code)) (do <>.monad [symbol (<text>.enclosed ["\@<" ">"] (symbol^ current_module))] (in (` (is ((~! <text>.Parser) Text) (~ (code.symbol symbol))))))) -(def: re_range^ +(def re_range^ (Parser Code) (do [! <>.monad] [from (|> regex_char^ (at ! each (|>> (//.char 0) maybe.trusted))) @@ -92,19 +92,19 @@ to (|> regex_char^ (at ! each (|>> (//.char 0) maybe.trusted)))] (in (` ((~! <text>.range) (~ (code.nat from)) (~ (code.nat to))))))) -(def: re_char^ +(def re_char^ (Parser Code) (do <>.monad [char escaped_char^] (in (` ((~! ..copy) (~ (code.text char))))))) -(def: re_options^ +(def re_options^ (Parser Code) (do <>.monad [options (<text>.many escaped_char^)] (in (` ((~! <text>.one_of) (~ (code.text options))))))) -(def: re_user_class^' +(def re_user_class^' (Parser Code) (do <>.monad [negate? (<>.maybe (<text>.this "^")) @@ -115,7 +115,7 @@ {.#Some _} (` ((~! <text>.not) (all ((~! <>.either)) (~+ parts)))) {.#None} (` (all ((~! <>.either)) (~+ parts))))))) -(def: re_user_class^ +(def re_user_class^ (Parser Code) (do <>.monad [init ..re_user_class^' @@ -127,34 +127,34 @@ init rest)))) -(def: blank^ +(def blank^ (Parser Text) (<text>.one_of (format " " //.tab))) -(def: ascii^ +(def ascii^ (Parser Text) (<text>.range (hex "0") (hex "7F"))) -(def: control^ +(def control^ (Parser Text) (<>.either (<text>.range (hex "0") (hex "1F")) (<text>.one_of (//.of_char (hex "7F"))))) -(def: punct^ +(def punct^ (Parser Text) (<text>.one_of (format "!#$%&'()*+,-./:;<=>?@[\]^_`{|}~" //.double_quote))) -(def: graph^ +(def graph^ (Parser Text) (<>.either punct^ <text>.alpha_num)) -(def: print^ +(def print^ (Parser Text) (<>.either graph^ (<text>.one_of (//.of_char (hex "20"))))) -(def: re_system_class^ +(def re_system_class^ (Parser Code) (do <>.monad [] @@ -183,17 +183,17 @@ (<>.after (<text>.this "\p{Print}") (in (` (~! print^)))) ))) -(def: re_class^ +(def re_class^ (Parser Code) (<>.either re_system_class^ (<text>.enclosed ["[" "]"] re_user_class^))) -(def: number^ +(def number^ (Parser Nat) (|> (<text>.many <text>.decimal) (<>.codec n.decimal))) -(def: re_back_reference^ +(def re_back_reference^ (Parser Code) (<>.either (do <>.monad [_ (<text>.this "\") @@ -205,7 +205,7 @@ _ (<text>.this ">")] (in (` ((~! ..copy) (~ (code.symbol ["" captured_symbol])))))))) -(def: (re_simple^ current_module) +(def (re_simple^ current_module) (-> Text (Parser Code)) (all <>.either re_class^ @@ -214,7 +214,7 @@ re_char^ )) -(def: (re_simple_quantified^ current_module) +(def (re_simple_quantified^ current_module) (-> Text (Parser Code)) (do <>.monad [base (re_simple^ current_module) @@ -237,7 +237,7 @@ "Input" (format (%.nat from) "," (%.nat to)) "Should be" (format (%.nat to) "," (%.nat from)))) -(def: (re_counted_quantified^ current_module) +(def (re_counted_quantified^ current_module) (-> Text (Parser Code)) (do [! <>.monad] [base (re_simple^ current_module)] @@ -261,12 +261,12 @@ [limit number^] (in (` ((~! together^) ((~! <>.exactly) (~ (code.nat limit)) (~ base)))))))))) -(def: (re_quantified^ current_module) +(def (re_quantified^ current_module) (-> Text (Parser Code)) (<>.either (re_simple_quantified^ current_module) (re_counted_quantified^ current_module))) -(def: (re_complex^ current_module) +(def (re_complex^ current_module) (-> Text (Parser Code)) (all <>.either (re_quantified^ current_module) @@ -277,7 +277,7 @@ {#Non_Capturing} {#Capturing [(Maybe Text) Nat]})) -(def: (re_sequential^ capturing? re_scoped^ current_module) +(def (re_sequential^ capturing? re_scoped^ current_module) (-> Bit (-> Text (Parser [Re_Group Code])) Text @@ -329,11 +329,11 @@ ((~ (' in)) [(~ g!total) (~+ (list.reversed names))])))]) )) -(def: (unflatten^ lexer) +(def (unflatten^ lexer) (-> (Parser Text) (Parser [Text Any])) (<>.and lexer (at <>.monad in []))) -(def: (|||^ left right) +(def (|||^ left right) (All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser [Text (Or l r)]))) (function (_ input) (case (left input) @@ -348,7 +348,7 @@ {try.#Failure error} {try.#Failure error})))) -(def: (|||_^ left right) +(def (|||_^ left right) (All (_ l r) (-> (Parser [Text l]) (Parser [Text r]) (Parser Text))) (function (_ input) (case (left input) @@ -363,13 +363,13 @@ {try.#Failure error} {try.#Failure error})))) -(def: (prep_alternative [num_captures alt]) +(def (prep_alternative [num_captures alt]) (-> [Nat Code] Code) (if (n.> 0 num_captures) alt (` ((~! unflatten^) (~ alt))))) -(def: (re_alternative^ capturing? re_scoped^ current_module) +(def (re_alternative^ capturing? re_scoped^ current_module) (-> Bit (-> Text (Parser [Re_Group Code])) Text @@ -387,7 +387,7 @@ (~ (prep_alternative head)) (~+ (list#each prep_alternative tail))))])))) -(def: (re_scoped^ current_module) +(def (re_scoped^ current_module) (-> Text (Parser [Re_Group Code])) (all <>.either (do <>.monad @@ -411,11 +411,11 @@ _ (<text>.this ")")] (in [{#Capturing [{.#None} num_captures]} pattern])))) -(def: (regex^ current_module) +(def (regex^ current_module) (-> Text (Parser Code)) (at <>.monad each product.right (re_alternative^ #1 re_scoped^ current_module))) -(def: .public regex +(def .public regex (syntax (_ [pattern <code>.text]) (do meta.monad [current_module meta.current_module_name] @@ -428,7 +428,7 @@ {try.#Success regex} (in (list regex)))))) -(def: .public pattern +(def .public pattern (syntax (_ [[pattern bindings] (<code>.form (<>.and <code>.text (<>.maybe <code>.any))) body <code>.any branches (<>.many <code>.any)]) diff --git a/stdlib/source/library/lux/data/text/unicode/block.lux b/stdlib/source/library/lux/data/text/unicode/block.lux index 7f3eeb32d..db55002a9 100644 --- a/stdlib/source/library/lux/data/text/unicode/block.lux +++ b/stdlib/source/library/lux/data/text/unicode/block.lux @@ -17,14 +17,14 @@ (primitive .public Block (Interval Char) - (def: .public monoid + (def .public monoid (Monoid Block) (implementation - (def: identity + (def identity (abstraction (interval.between n.enum n#top n#bottom))) - (def: (composite left right) + (def (composite left right) (let [left (representation left) right (representation right)] (abstraction @@ -34,12 +34,12 @@ (n.max (at left top) (at right top)))))))) - (def: .public (block start additional) + (def .public (block start additional) (-> Char Nat Block) (abstraction (interval.between n.enum start (n.+ additional start)))) (with_template [<name> <slot>] - [(def: .public <name> + [(def .public <name> (-> Block Char) (|>> representation (the <slot>)))] @@ -47,34 +47,34 @@ [end interval.top] ) - (def: .public (size block) + (def .public (size block) (-> Block Nat) (let [start (the interval.bottom (representation block)) end (the interval.top (representation block))] (|> end (n.- start) ++))) - (def: .public (within? block char) + (def .public (within? block char) (All (_ a) (-> Block Char Bit)) (interval.within? (representation block) char)) ) -(def: .public equivalence +(def .public equivalence (Equivalence Block) (implementation - (def: (= reference subject) + (def (= reference subject) (and (n.= (..start reference) (..start subject)) (n.= (..end reference) (..end subject)))))) -(def: .public hash +(def .public hash (Hash Block) (implementation - (def: equivalence ..equivalence) - (def: (hash value) + (def equivalence ..equivalence) + (def (hash value) (i64.or (i64.left_shifted 32 (..start value)) (..end value))))) (with_template [<start> <end> <name>] - [(def: .public <name> + [(def .public <name> Block (let [start (hex <start>) end (hex <end>)] diff --git a/stdlib/source/library/lux/data/text/unicode/set.lux b/stdlib/source/library/lux/data/text/unicode/set.lux index 287c78ca0..1abe5427f 100644 --- a/stdlib/source/library/lux/data/text/unicode/set.lux +++ b/stdlib/source/library/lux/data/text/unicode/set.lux @@ -16,10 +16,10 @@ [// (.only Char)] ["[1][0]" block (.only Block)]]]) -(def: builder +(def builder (tree.builder //block.monoid)) -(def: :@: +(def :@: (by_example [@] (is (tree.Builder @ Block) ..builder) @@ -29,19 +29,19 @@ (primitive .public Set (Tree :@: Block []) - (def: .public (composite left right) + (def .public (composite left right) (-> Set Set Set) (abstraction (at builder branch (representation left) (representation right)))) - (def: (singleton block) + (def (singleton block) (-> Block Set) (abstraction (at builder leaf block []))) - (def: .public (set [head tail]) + (def .public (set [head tail]) (-> [Block (List Block)] Set) (list#mix (is (-> Block Set Set) (function (_ block set) @@ -49,7 +49,7 @@ (..singleton head) tail)) - (def: character/0 + (def character/0 Set (..set [//block.basic_latin (list //block.latin_1_supplement @@ -82,7 +82,7 @@ //block.myanmar //block.georgian)])) - (def: character/1 + (def character/1 Set (..set [//block.hangul_jamo (list //block.ethiopic @@ -116,7 +116,7 @@ //block.enclosed_alphanumerics //block.box_drawing)])) - (def: character/2 + (def character/2 Set (..set [//block.block_elements (list //block.geometric_shapes @@ -150,7 +150,7 @@ //block.hangul_syllables )])) - (def: .public character + (def .public character Set (all ..composite ..character/0 @@ -158,7 +158,7 @@ ..character/2 )) - (def: .public non_character + (def .public non_character Set (..set [//block.high_surrogates (list //block.high_private_use_surrogates @@ -193,26 +193,26 @@ ... //block.tags )])) - (def: .public full + (def .public full Set (all ..composite ..character ..non_character )) - (def: .public start + (def .public start (-> Set Char) (|>> representation tree.tag //block.start)) - (def: .public end + (def .public end (-> Set Char) (|>> representation tree.tag //block.end)) - (def: .public (member? set character) + (def .public (member? set character) (-> Set Char Bit) (loop (again [tree (representation set)]) (if (//block.within? (tree.tag tree) character) @@ -225,16 +225,16 @@ (again right))) false))) - (def: .public equivalence + (def .public equivalence (Equivalence Set) (implementation - (def: (= reference subject) + (def (= reference subject) (set#= (set.of_list //block.hash (tree.tags (representation reference))) (set.of_list //block.hash (tree.tags (representation subject))))))) ) (with_template [<name> <blocks>] - [(def: .public <name> + [(def .public <name> Set (..set <blocks>))] diff --git a/stdlib/source/library/lux/data/trace.lux b/stdlib/source/library/lux/data/trace.lux index cc92f72ac..87032785f 100644 --- a/stdlib/source/library/lux/data/trace.lux +++ b/stdlib/source/library/lux/data/trace.lux @@ -12,22 +12,22 @@ [#monoid (Monoid t) #trace (-> t a)])) -(def: .public functor +(def .public functor (All (_ t) (Functor (Trace t))) (implementation - (def: (each f fa) + (def (each f fa) (revised #trace (composite f) fa)))) -(def: .public comonad +(def .public comonad (All (_ t) (CoMonad (Trace t))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (out wa) + (def (out wa) ((the #trace wa) (the [#monoid monoid.#identity] wa))) - (def: (disjoint wa) + (def (disjoint wa) (let [monoid (the #monoid wa)] [#monoid monoid #trace (function (_ t1) @@ -36,6 +36,6 @@ ((the #trace wa) (at monoid composite t1 t2)))])])))) -(def: .public (result context tracer) +(def .public (result context tracer) (All (_ t a) (-> t (Trace t a) a)) (at tracer trace context)) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 5aa890145..a4cbd9b25 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -119,10 +119,10 @@ (import (format [Text .Any] Text))) )) -(def: Inspector +(def Inspector (.type (Format Any))) -(for @.lua (def: (tuple_array tuple) +(for @.lua (def (tuple_array tuple) (-> (array.Array Any) (array.Array Any)) (array.of_list (loop (again [idx 0]) @@ -132,7 +132,7 @@ {.#Item member (again (++ idx))}))))) (these)) -(def: (tuple_inspection inspection) +(def (tuple_inspection inspection) (-> Inspector Inspector) (with_expansions [<adaption> (for @.lua (~~ (these ..tuple_array)) (~~ (these)))] @@ -143,7 +143,7 @@ (text.interposed " ") (text.enclosed ["[" "]"]))))) -(def: .public (inspection value) +(def .public (inspection value) Inspector (with_expansions [<jvm> (let [object (as java/lang/Object value)] (`` (<| (~~ (with_template [<class> <processing>] @@ -387,7 +387,7 @@ (type: Representation (-> Any Text)) -(def: primitive_representation +(def primitive_representation (Parser Representation) (`` (all <>.either (do <>.monad @@ -407,7 +407,7 @@ [Text %.text])) ))) -(def: (special_representation representation) +(def (special_representation representation) (-> (Parser Representation) (Parser Representation)) (`` (all <>.either (~~ (with_template [<type> <formatter>] @@ -442,7 +442,7 @@ (in (|>> (as (Maybe Any)) (%.maybe elemR))))))) -(def: (variant_representation representation) +(def (variant_representation representation) (-> (Parser Representation) (Parser Representation)) (do <>.monad [membersR+ (<type>.variant (<>.many representation))] @@ -468,7 +468,7 @@ (undefined)))] (%.format "{" (%.nat lefts) " " (%.bit right?) " " sub_repr "}")))))) -(def: (tuple_representation representation) +(def (tuple_representation representation) (-> (Parser Representation) (Parser Representation)) (do <>.monad [membersR+ (<type>.tuple (<>.many representation))] @@ -487,7 +487,7 @@ (%.format (headR leftV) " " (again tailR rightV)))))] (%.format "[" tuple_body "]")))))) -(def: representation_parser +(def representation_parser (Parser Representation) (<>.rec (function (_ representation) @@ -513,7 +513,7 @@ (<>.failure "") )))) -(def: .public (representation type value) +(def .public (representation type value) (-> Type Any (Try Text)) (case (<type>.result ..representation_parser type) {try.#Success representation} @@ -522,14 +522,14 @@ {try.#Failure _} (exception.except ..cannot_represent_value type))) -(def: .public private +(def .public private (syntax (_ [definition <code>.symbol]) (let [[module _] definition] (in (list (` ("lux in-module" (~ (code.text module)) (~ (code.symbol definition))))))))) -(def: .public (log! message) +(def .public (log! message) (-> Text Any) ("lux io log" message)) @@ -539,7 +539,7 @@ "Location" (%.location location) "Type" (%.type type))) -(def: .public hole +(def .public hole (syntax (_ []) (do meta.monad [location meta.location @@ -549,7 +549,7 @@ (type: Target [Text (Maybe Code)]) -(def: target +(def target (<code>.Parser Target) (<>.either (<>.and <code>.local (at <>.monad in {.#None})) @@ -560,7 +560,7 @@ (exception.report "Name" (%.text name))) -(def: .public here +(def .public here (syntax (_ [targets (is (<code>.Parser (List Target)) (|> ..target <>.some diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux index abe8d3ff3..3c5ad2e10 100644 --- a/stdlib/source/library/lux/documentation.lux +++ b/stdlib/source/library/lux/documentation.lux @@ -35,7 +35,7 @@ [lux ["[0]" syntax]]]]]]]) -(def: |recursion_dummy| +(def |recursion_dummy| (template (_) [{.#Primitive "" {.#End}}])) @@ -44,12 +44,12 @@ {#Comment Text} {#Code Code})) -(def: fragment +(def fragment (Parser Fragment) (<>.or <code>.text <code>.any)) -(def: (reference_column code) +(def (reference_column code) (-> Code Nat) (case code (^.with_template [<tag>] @@ -73,7 +73,7 @@ [.#Tuple]) )) -(def: (padding reference_column [_ old_line old_column] [_ new_line new_column]) +(def (padding reference_column [_ old_line old_column] [_ new_line new_column]) (-> Nat Location Location Text) (if (n.= old_line new_line) (if (n.< old_column new_column) @@ -86,7 +86,7 @@ "" (text.together (list.repeated (n.- reference_column new_column) " ")))))) -(def: (code_documentation expected_module old_location reference_column example) +(def (code_documentation expected_module old_location reference_column example) (-> Text Location Nat Code [Location Text]) (case example [new_location {.#Symbol [module short]}] @@ -130,15 +130,15 @@ [syntax.open_tuple syntax.close_tuple .#Tuple]) )) -(def: blank_line +(def blank_line Text (format \n \n)) -(def: single_line_comment +(def single_line_comment (-> Text Text) (text.prefix "... ")) -(def: (fragment_documentation module fragment) +(def (fragment_documentation module fragment) (-> Text Fragment Text) (case fragment {#Comment comment} @@ -151,10 +151,10 @@ (..code_documentation module (has .#column reference_column location) reference_column) product.right)))) -(def: parameter_name_options "abcdefghijklmnopqrstuvwxyz") -(def: parameter_name_options_count (text.size parameter_name_options)) +(def parameter_name_options "abcdefghijklmnopqrstuvwxyz") +(def parameter_name_options_count (text.size parameter_name_options)) -(def: (parameter_type_name id) +(def (parameter_type_name id) (-> Nat Text) (format "_" (%.nat id)) ... (case (text.char id ..parameter_name_options) @@ -166,13 +166,13 @@ ... (parameter_type_name (n.% parameter_name_options_count id)))) ) -(def: type_variable_names +(def type_variable_names (Stream Text) (stream.iterations (product.forked ++ parameter_type_name) 0)) (with_template [<name> <partition>] - [(def: (<name> id) + [(def (<name> id) (-> Nat Bit) (<partition> id))] @@ -180,11 +180,11 @@ [type_parameter? n.odd?] ) -(def: (parameter_id level id) +(def (parameter_id level id) (-> Nat Nat Nat) (n.- (n./ 2 id) level)) -(def: (parameter_name [type_function_name type_function_arguments] level id) +(def (parameter_name [type_function_name type_function_arguments] level id) (-> [Text (List Text)] Nat Nat Text) (if (type_parameter? id) (let [parameter_id (..parameter_id level id)] @@ -200,7 +200,7 @@ (stream.item parameter_id))))) type_function_name)) -(def: (level_parameters offset level) +(def (level_parameters offset level) (-> Nat Nat (List Text)) (if (n.= 0 level) (list) @@ -209,14 +209,14 @@ (enum.range n.enum 0) (list#each (|>> (n.+ (++ offset)) parameter_type_name))))) -(def: (nested line_prefix body) +(def (nested line_prefix body) (-> Text Text Text) (|> body (text.all_split_by \n) (list#each (text.prefix line_prefix)) (text.interposed \n))) -(def: (%type' level type_function_name nestable? module type) +(def (%type' level type_function_name nestable? module type) (-> Nat Text Bit Text Type Text) (case type {.#Primitive name params} @@ -298,11 +298,11 @@ (%.symbol [_module _name])) )) -(def: type +(def type (-> Text Type Text) (%type' (-- 0) "?" true)) -(def: (parameterized_type arity type) +(def (parameterized_type arity type) (-> Nat Type (Maybe Type)) (case arity 0 {.#Some type} @@ -313,7 +313,7 @@ _ {.#None}))) -(def: (type_definition' nestable? level arity type_function_info tags module type) +(def (type_definition' nestable? level arity type_function_info tags module type) (-> Bit Nat Nat [Text (List Text)] (List Text) Text Type Text) (case tags (pattern (list single_tag)) @@ -436,7 +436,7 @@ (%.symbol [_module _name])) ))) -(def: (type_definition module [name parameters] tags type) +(def (type_definition module [name parameters] tags type) (-> Text [Text (List Text)] (List Text) Type Text) (let [arity (list.size parameters)] (case (parameterized_type arity type) @@ -446,7 +446,7 @@ {.#None} (..type module type)))) -(def: description +(def description (Parser (Maybe Code)) (<>.or (<code>.this_text "") <code>.any)) @@ -455,7 +455,7 @@ (exception.report "Name" (%.symbol name))) -(def: qualified_symbol +(def qualified_symbol (Parser Symbol) (do <>.monad [name <code>.symbol] @@ -466,7 +466,7 @@ _ (in name)))) -(def: example_separator +(def example_separator Code (let [c/01 "...." c/04 (format c/01 c/01 c/01 c/01) @@ -478,11 +478,11 @@ (type: Example (List Fragment)) -(def: example +(def example (Parser Example) (<code>.tuple (<>.many ..fragment))) -(def: (example_documentation module example) +(def (example_documentation module example) (-> Text Example Code) (|> example (list#each (..fragment_documentation module)) @@ -493,13 +493,13 @@ (type: Declaration [Symbol (List Text)]) -(def: declaration +(def declaration (Parser Declaration) (<>.either (<>.and ..qualified_symbol (<>#in (list))) (<code>.form (<>.and ..qualified_symbol (<>.some (<code>.local)))))) -(def: minimal_definition_documentation +(def minimal_definition_documentation (syntax (_ [[name parameters] ..declaration]) (do meta.monad [.let [g!module (code.text (product.left name))] @@ -538,7 +538,7 @@ (` ((~! ..type) (~ g!module) (~ g!type)))))))) )))))))) -(def: definition_documentation +(def definition_documentation (syntax (_ [[name parameters] ..declaration description ..description examples (<>.some ..example)]) @@ -581,7 +581,7 @@ #expected (Set Text) #definitions (List Definition)])) -(def: .public default +(def .public default (syntax (_ [[name parameters] ..declaration]) (macro.with_symbols [g!_] (let [[_ short] name] @@ -593,7 +593,7 @@ (~+ (list#each code.local parameters))))])))] ((~ g!_) []))))))))) -(def: .public documentation +(def .public documentation (syntax (_ [[name parameters] ..declaration extra (<>.some <code>.any)]) (macro.with_symbols [g!_] @@ -607,7 +607,7 @@ (~+ extra))])))] ((~ g!_) []))))))))) -(def: definitions_documentation +(def definitions_documentation (-> (List Definition) (Markdown Block)) (|>> (list.sorted (function (_ left right) (text#< (the #definition right) @@ -615,11 +615,11 @@ (list#each (the #documentation)) (list#mix md.then md.empty))) -(def: expected_separator +(def expected_separator Text (text.of_char 31)) -(def: expected_format +(def expected_format (-> (List Text) Text) (list#mix (function (_ short aggregate) (case aggregate @@ -627,12 +627,12 @@ _ (format aggregate ..expected_separator short))) "")) -(def: expected +(def expected (-> Text (Set Text)) (|>> (text.all_split_by ..expected_separator) (set.of_list text.hash))) -(def: .public module +(def .public module (syntax (_ [[name _] ..qualified_symbol description <code>.any definitions (<code>.tuple (<>.some <code>.any)) @@ -652,7 +652,7 @@ (at (~! list.monoid) (~' identity))) (~+ subs)))))))))) -(def: listing +(def listing (-> (List Text) (Markdown Block)) (|>> (list.sorted text#<) (list#each (function (_ definition) @@ -660,7 +660,7 @@ {.#None}])) md.numbered_list)) -(def: (module_documentation module) +(def (module_documentation module) (-> Module (Markdown Block)) (let [(open "_[0]") module] (all md.then @@ -709,7 +709,7 @@ (..listing un_expected))) ))) -(def: .public markdown +(def .public markdown (-> (List Module) Text) (|>> (list.sorted (function (_ left right) (text#< (the #module right) (the #module left)))) diff --git a/stdlib/source/library/lux/extension.lux b/stdlib/source/library/lux/extension.lux index 424cfcba8..1cbaf8642 100644 --- a/stdlib/source/library/lux/extension.lux +++ b/stdlib/source/library/lux/extension.lux @@ -31,7 +31,7 @@ #archive Text #inputs (List Code)])) -(def: (declaration default) +(def (declaration default) (-> Code (Parser Declaration)) (<c>.form (all <>.and <c>.any @@ -41,7 +41,7 @@ (<c>.tuple (<>.some <c>.any))))) (with_template [<any> <end> <and> <result> <extension> <name>] - [(def: .public <name> + [(def .public <name> (syntax (_ [[name extension phase archive inputs] (..declaration (` <any>)) body <c>.any]) (let [g!name (code.local extension) diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index 9fc79a2d9..49042f104 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -39,23 +39,23 @@ ["[0]" type (.open: "[1]#[0]" equivalence) ["[0]" check]]]]) -(def: internal +(def internal (-> External Text) (|>> name.internal name.read)) -(def: signature +(def signature (All (_ category) (-> (Type category) Text)) (|>> jvm.signature signature.signature)) -(def: reflection +(def reflection (All (_ category) (-> (Type (<| Return' Value' category)) Text)) (|>> jvm.reflection reflection.reflection)) (with_template [<name> <class>] - [(`` (def: .public <name> + [(`` (def .public <name> .Type {.#Primitive <class> {.#End}}))] @@ -71,7 +71,7 @@ ) (with_template [<name> <class>] - [(`` (def: .public <name> + [(`` (def .public <name> .Type {.#Primitive (reflection.reflection <class>) {.#End}}))] @@ -86,20 +86,20 @@ [char reflection.char] ) -(def: (get_static_field class field) +(def (get_static_field class field) (-> Text Text Code) (` ("jvm member get static" (~ (code.text class)) (~ (code.text field))))) -(def: (get_virtual_field class field object) +(def (get_virtual_field class field object) (-> Text Text Code Code) (` ("jvm member get virtual" (~ (code.text class)) (~ (code.text field)) (~ object)))) -(def: boxes +(def boxes (Dictionary (Type Value) Text) (|> (list [jvm.boolean box.boolean] [jvm.byte box.byte] @@ -112,7 +112,7 @@ (dictionary.of_list jvm.hash))) (with_template [<name> <pre> <post>] - [(def: (<name> unboxed boxed raw) + [(def (<name> unboxed boxed raw) (-> (Type Value) Text Code Code) (let [unboxed (..reflection unboxed)] (` (|> (~ raw) @@ -125,7 +125,7 @@ ) (with_template [<name> <op> <from> <to>] - [(def: .public <name> + [(def .public <name> (template (<name> value) [(|> value (.is <from>) @@ -166,7 +166,7 @@ ) (with_template [<name> <from> <to> <0> <1>] - [(def: .public <name> + [(def .public <name> (template (<name> value) [(|> value <0> <1>)]))] @@ -177,7 +177,7 @@ [short_to_char ..Short ..Character ..short_to_int ..int_to_char] ) -(def: constructor_method_name +(def constructor_method_name "<init>") (type: Primitive_Mode @@ -327,7 +327,7 @@ {#MethodDecl [ImportMethodCommons ImportMethodDecl]} {#FieldAccessDecl ImportFieldDecl})) -(def: (primitive_type mode type) +(def (primitive_type mode type) (-> Primitive_Mode (Type Primitive) Code) (case mode {#ManualPrM} @@ -362,7 +362,7 @@ ... else (undefined)))) -(def: (parameter_type value_type type) +(def (parameter_type value_type type) (-> (-> (Type Value) Code) (-> (Type Parameter) Code)) (`` (<| (~~ (with_template [<when> <binding> <then>] @@ -390,7 +390,7 @@ (undefined) ))) -(def: (value_type mode type) +(def (value_type mode type) (-> Primitive_Mode (Type Value) Code) (`` (<| (~~ (with_template [<when> <binding> <then>] [(case (<when> type) @@ -404,25 +404,25 @@ (undefined) ))) -(def: declaration_type$ +(def declaration_type$ (-> (Type Declaration) Code) (|>> ..signature code.text)) -(def: (get_const_parser class_name field_name) +(def (get_const_parser class_name field_name) (-> Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] _ (<code>.this (code.symbol ["" dotted_name]))] (in (get_static_field class_name field_name)))) -(def: (get_var_parser class_name field_name self_name) +(def (get_var_parser class_name field_name self_name) (-> Text Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] _ (<code>.this (code.symbol ["" dotted_name]))] (in (get_virtual_field class_name field_name (code.local self_name))))) -(def: (put_var_parser class_name field_name self_name) +(def (put_var_parser class_name field_name self_name) (-> Text Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] @@ -434,7 +434,7 @@ (~ value) (~ (code.local self_name))))))) -(def: (replaced f input) +(def (replaced f input) (-> (-> Code Code) Code Code) (case (f input) (^.with_template [<tag>] @@ -447,7 +447,7 @@ ast' ast')) -(def: (parser->replacer p ast) +(def (parser->replacer p ast) (-> (Parser Code) (-> Code Code)) (case (<>.result p (list ast)) {.#Right [{.#End} ast']} @@ -457,7 +457,7 @@ ast )) -(def: (field->parser class_name self_name [[field_name _ _] field]) +(def (field->parser class_name self_name [[field_name _ _] field]) (-> Text Text [Member_Declaration FieldDecl] (Parser Code)) (case field {#ConstantField _} @@ -467,11 +467,11 @@ (<>.either (get_var_parser class_name field_name self_name) (put_var_parser class_name field_name self_name)))) -(def: (decorate_input [class value]) +(def (decorate_input [class value]) (-> [(Type Value) Code] Code) (` [(~ (code.text (..signature class))) (~ value)])) -(def: (constructor_parser class_name arguments) +(def (constructor_parser class_name arguments) (-> Text (List Argument) (Parser Code)) (do <>.monad [args (.is (Parser (List Code)) @@ -482,7 +482,7 @@ (list.zipped_2 (list#each product.right arguments)) (list#each ..decorate_input)))))))) -(def: (static_method_parser class_name method_name arguments) +(def (static_method_parser class_name method_name arguments) (-> Text Text (List Argument) (Parser Code)) (do <>.monad [.let [dotted_name (format "::" method_name "!")] @@ -495,7 +495,7 @@ (list#each ..decorate_input)))))))) (with_template [<name> <jvm_op>] - [(def: (<name> class_vars class_name type_vars method_name arguments self_name) + [(def (<name> class_vars class_name type_vars method_name arguments self_name) (-> (List (Type Var)) Text (List (Type Var)) Text (List Argument) Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" method_name "!")] @@ -514,7 +514,7 @@ [virtual_method_parser "jvm member invoke virtual"] ) -(def: (method->parser class_vars class_name [[method_name _ _] meth_def]) +(def (method->parser class_vars class_name [[method_name _ _] meth_def]) (-> (List (Type Var)) Text [Member_Declaration Method_Definition] (Parser Code)) (case meth_def {#ConstructorMethod strict? type_vars self_name args constructor_args return_expr exs} @@ -535,7 +535,7 @@ {#NativeMethod type_vars args return_type exs} (virtual_method_parser class_vars class_name type_vars method_name args ""))) -(def: privacy_modifier^ +(def privacy_modifier^ (Parser Privacy) (let [(open "[0]") <>.monad] (all <>.or @@ -544,7 +544,7 @@ (<code>.this (' "protected")) (in [])))) -(def: inheritance_modifier^ +(def inheritance_modifier^ (Parser Inheritance) (let [(open "[0]") <>.monad] (all <>.or @@ -562,12 +562,12 @@ "Name" (%.text name) "Type Variables" (exception.listing parser.name type_vars))) -(def: (assertion exception payload test) +(def (assertion exception payload test) (All (_ e) (-> (Exception e) e Bit (Parser Any))) (<>.assertion (exception.error exception payload) test)) -(def: (valid_class_name type_vars) +(def (valid_class_name type_vars) (-> (List (Type Var)) (Parser External)) (do <>.monad [name <code>.local @@ -579,7 +579,7 @@ name)))] (in name))) -(def: (class^' parameter^ type_vars) +(def (class^' parameter^ type_vars) (-> (-> (List (Type Var)) (Parser (Type Parameter))) (-> (List (Type Var)) (Parser (Type Class)))) (do <>.monad @@ -596,7 +596,7 @@ "Unexpected Type Variable" (%.text name) "Expected Type Variables" (exception.listing parser.name type_vars))) -(def: (type_variable options) +(def (type_variable options) (-> (List (Type Var)) (Parser (Type Parameter))) (do <>.monad [name <code>.local @@ -604,14 +604,14 @@ (list.member? text.equivalence (list#each parser.name options) name))] (in (jvm.var name)))) -(def: wildcard^ +(def wildcard^ (Parser (Type Parameter)) (do <>.monad [_ (<code>.this (' ?))] (in jvm.wildcard))) (with_template [<name> <comparison> <constructor>] - [(def: <name> + [(def <name> (-> (Parser (Type Class)) (Parser (Type Parameter))) (|>> (<>.after (<code>.this (' <comparison>))) (<>.after ..wildcard^) @@ -622,7 +622,7 @@ [lower^ > jvm.lower] ) -(def: (parameter^ type_vars) +(def (parameter^ type_vars) (-> (List (Type Var)) (Parser (Type Parameter))) (<>.rec (function (_ _) @@ -635,7 +635,7 @@ class^ ))))) -(def: (itself^ type) +(def (itself^ type) (All (_ category) (-> (Type (<| Return' Value' category)) (Parser (Type (<| Return' Value' category))))) @@ -643,7 +643,7 @@ [_ (<code>.this_symbol ["" (..reflection type)])] (in type))) -(def: primitive^ +(def primitive^ (Parser (Type Primitive)) (all <>.either (itself^ jvm.boolean) @@ -656,12 +656,12 @@ (itself^ jvm.char) )) -(def: array^ +(def array^ (-> (Parser (Type Value)) (Parser (Type Array))) (|>> <code>.tuple (at <>.monad each jvm.array))) -(def: (type^ type_vars) +(def (type^ type_vars) (-> (List (Type Var)) (Parser (Type Value))) (<>.rec (function (_ type^) @@ -671,26 +671,26 @@ (..array^ type^) )))) -(def: void^ +(def void^ (Parser (Type Void)) (do <>.monad [_ (<code>.this_symbol ["" (reflection.reflection reflection.void)])] (in jvm.void))) -(def: (return^ type_vars) +(def (return^ type_vars) (-> (List (Type Var)) (Parser (Type Return))) (<>.either ..void^ (..type^ type_vars))) -(def: var^ +(def var^ (Parser (Type Var)) (at <>.monad each jvm.var <code>.local)) -(def: vars^ +(def vars^ (Parser (List (Type Var))) (<code>.tuple (<>.some var^))) -(def: declaration^ +(def declaration^ (Parser (Type Declaration)) (do <>.monad [[name variables] (.is (Parser [External (List (Type Var))]) @@ -701,15 +701,15 @@ ))] (in (jvm.declaration name variables)))) -(def: (class^ type_vars) +(def (class^ type_vars) (-> (List (Type Var)) (Parser (Type Class))) (class^' parameter^ type_vars)) -(def: annotation_parameters^ +(def annotation_parameters^ (Parser (List Annotation_Parameter)) (<code>.tuple (<>.some (<>.and <code>.text <code>.any)))) -(def: annotation^ +(def annotation^ (Parser Annotation) (<>.either (do <>.monad [ann_name <code>.local] @@ -717,21 +717,21 @@ (<code>.form (<>.and <code>.local annotation_parameters^)))) -(def: annotations^ +(def annotations^ (Parser (List Annotation)) (<| (<>.else (list)) (do <>.monad [_ (<code>.this (' "ann"))] (<code>.tuple (<>.some ..annotation^))))) -(def: (throws_decl^ type_vars) +(def (throws_decl^ type_vars) (-> (List (Type Var)) (Parser (List (Type Class)))) (<| (<>.else (list)) (do <>.monad [_ (<code>.this (' "throws"))] (<code>.tuple (<>.some (..class^ type_vars)))))) -(def: (method_decl^ type_vars) +(def (method_decl^ type_vars) (-> (List (Type Var)) (Parser [Member_Declaration MethodDecl])) (<code>.form (do <>.monad [tvars (<>.else (list) ..vars^) @@ -746,14 +746,14 @@ #method_output output #method_exs exs]])))) -(def: state_modifier^ +(def state_modifier^ (Parser State) (all <>.or (<code>.this (' "volatile")) (<code>.this (' "final")) (at <>.monad in []))) -(def: (field_decl^ type_vars) +(def (field_decl^ type_vars) (-> (List (Type Var)) (Parser [Member_Declaration FieldDecl])) (<>.either (<code>.form (do <>.monad [_ (<code>.this (' "const")) @@ -771,24 +771,24 @@ type (..type^ type_vars)] (in [[name pm anns] {#VariableField [sm static? type]}]))))) -(def: (argument^ type_vars) +(def (argument^ type_vars) (-> (List (Type Var)) (Parser Argument)) (<>.and <code>.local (..type^ type_vars))) -(def: (arguments^ type_vars) +(def (arguments^ type_vars) (-> (List (Type Var)) (Parser (List Argument))) (<code>.tuple (<>.some (..argument^ type_vars)))) -(def: (constructor_arg^ type_vars) +(def (constructor_arg^ type_vars) (-> (List (Type Var)) (Parser (Typed Code))) (<>.and (..type^ type_vars) <code>.any)) -(def: (constructor_args^ type_vars) +(def (constructor_args^ type_vars) (-> (List (Type Var)) (Parser (List (Typed Code)))) (<code>.tuple (<>.some (..constructor_arg^ type_vars)))) -(def: (constructor_method^ class_vars) +(def (constructor_method^ class_vars) (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition])) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -808,7 +808,7 @@ #member_anns annotations] {#ConstructorMethod strict_fp? method_vars self_name arguments constructor_args body exs}])))) -(def: (virtual_method_def^ class_vars) +(def (virtual_method_def^ class_vars) (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition])) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -829,7 +829,7 @@ #member_anns annotations] {#VirtualMethod final? strict_fp? method_vars self_name arguments return_type body exs}])))) -(def: overriden_method_def^ +(def overriden_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [strict_fp? (<>.parses? (<code>.this (' "strict"))) @@ -850,7 +850,7 @@ #member_anns annotations] {#OverridenMethod strict_fp? owner_class method_vars self_name arguments return_type body exs}])))) -(def: static_method_def^ +(def static_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -869,7 +869,7 @@ #member_anns annotations] {#StaticMethod strict_fp? method_vars arguments return_type body exs}])))) -(def: abstract_method_def^ +(def abstract_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -886,7 +886,7 @@ #member_anns annotations] {#AbstractMethod method_vars arguments return_type exs}])))) -(def: native_method_def^ +(def native_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -903,7 +903,7 @@ #member_anns annotations] {#NativeMethod method_vars arguments return_type exs}])))) -(def: (method_def^ class_vars) +(def (method_def^ class_vars) (-> (List (Type Var)) (Parser [Member_Declaration Method_Definition])) (all <>.either (..constructor_method^ class_vars) @@ -913,34 +913,34 @@ ..abstract_method_def^ ..native_method_def^)) -(def: partial_call^ +(def partial_call^ (Parser Partial_Call) (<code>.form (<>.and <code>.symbol (<>.some <code>.any)))) -(def: import_member_alias^ +(def import_member_alias^ (Parser (Maybe Text)) (<>.maybe (do <>.monad [_ (<code>.this (' "as"))] <code>.local))) -(def: (import_member_args^ type_vars) +(def (import_member_args^ type_vars) (-> (List (Type Var)) (Parser (List [Bit (Type Value)]))) (<code>.tuple (<>.some (<>.and (<>.parses? (<code>.this (' "?"))) (..type^ type_vars))))) -(def: import_member_return_flags^ +(def import_member_return_flags^ (Parser [Bit Bit Bit]) (all <>.and (<>.parses? (<code>.this (' "io"))) (<>.parses? (<code>.this (' "try"))) (<>.parses? (<code>.this (' "?"))))) -(def: primitive_mode^ +(def primitive_mode^ (Parser Primitive_Mode) (<>.or (<code>.this (' "manual")) (<code>.this (' "auto")))) -(def: (import_member_decl^ owner_vars) +(def (import_member_decl^ owner_vars) (-> (List (Type Var)) (Parser Import_Member_Declaration)) (all <>.either (<code>.form (do <>.monad @@ -1002,7 +1002,7 @@ #import_field_type gtype]}))) )) -(def: (privacy_modifier$ pm) +(def (privacy_modifier$ pm) (-> Privacy Code) (case pm {#PublicP} (code.text "public") @@ -1010,23 +1010,23 @@ {#ProtectedP} (code.text "protected") {#DefaultP} (code.text "default"))) -(def: (inheritance_modifier$ im) +(def (inheritance_modifier$ im) (-> Inheritance Code) (case im {#FinalI} (code.text "final") {#AbstractI} (code.text "abstract") {#DefaultI} (code.text "default"))) -(def: (annotation_parameter$ [name value]) +(def (annotation_parameter$ [name value]) (-> Annotation_Parameter Code) (` [(~ (code.text name)) (~ value)])) -(def: (annotation$ [name params]) +(def (annotation$ [name params]) (-> Annotation Code) (` ((~ (code.text name)) (~+ (list#each annotation_parameter$ params))))) (with_template [<name> <category>] - [(def: <name> + [(def <name> (-> (Type <category>) Code) (|>> ..signature code.text))] @@ -1038,11 +1038,11 @@ [class$ Class] ) -(def: var$' +(def var$' (-> (Type Var) Code) (|>> ..signature code.local)) -(def: (method_decl$ [[name pm anns] method_decl]) +(def (method_decl$ [[name pm anns] method_decl]) (-> [Member_Declaration MethodDecl] Code) (let [(open "[0]") method_decl] (` ((~ (code.text name)) @@ -1052,14 +1052,14 @@ [(~+ (list#each value$ #method_inputs))] (~ (return$ #method_output)))))) -(def: (state_modifier$ it) +(def (state_modifier$ it) (-> State Code) (case it {#VolatileS} (' "volatile") {#FinalS} (' "final") {#DefaultS} (' "default"))) -(def: (field_decl$ [[name pm anns] field]) +(def (field_decl$ [[name pm anns] field]) (-> [Member_Declaration FieldDecl] Code) (case field {#ConstantField class value} @@ -1081,15 +1081,15 @@ )) )) -(def: (argument$ [name type]) +(def (argument$ [name type]) (-> Argument Code) (` [(~ (code.text name)) (~ (value$ type))])) -(def: (constructor_arg$ [class term]) +(def (constructor_arg$ [class term]) (-> (Typed Code) Code) (` [(~ (value$ class)) (~ term)])) -(def: (overriden_method_macro super_class name declaration type_vars self_name expected_arguments) +(def (overriden_method_macro super_class name declaration type_vars self_name expected_arguments) (-> (Type Class) Text (Type Declaration) (List (Type Var)) Text (List Argument) Macro) (syntax (_ [_ (<code>.this (' "super")) actual_arguments (<code>.tuple (<>.exactly (list.size expected_arguments) <code>.any))]) @@ -1104,7 +1104,7 @@ (list.zipped_2 (list#each product.right expected_arguments)) (list#each ..decorate_input))))))))) -(def: (method_def$ fully_qualified_class_name method_parser super_class fields [[name pm anns] method_def]) +(def (method_def$ fully_qualified_class_name method_parser super_class fields [[name pm anns] method_def]) (-> External (Parser Code) (Type Class) (List [Member_Declaration FieldDecl]) [Member_Declaration Method_Definition] (Meta Code)) (case method_def {#ConstructorMethod strict_fp? type_vars self_name arguments constructor_args body exs} @@ -1195,15 +1195,15 @@ (~ (return$ return_type))))) )) -(def: (complete_call$ g!obj [method args]) +(def (complete_call$ g!obj [method args]) (-> Code Partial_Call Code) (` ((~ (code.symbol method)) (~+ args) (~ g!obj)))) -(def: $Object +(def $Object (Type Class) (jvm.class "java.lang.Object" (list))) -(def: .public class +(def .public class (syntax (_ [.let [! <>.monad] im inheritance_modifier^ [full_class_name class_vars] (at ! each parser.declaration ..declaration^) @@ -1230,7 +1230,7 @@ [(~+ (list#each field_decl$ fields))] [(~+ methods)]))))))) -(def: .public interface +(def .public interface (syntax (_ [.let [! <>.monad] [full_class_name class_vars] (at ! each parser.declaration ..declaration^) supers (<>.else (list) @@ -1243,7 +1243,7 @@ [(~+ (list#each annotation$ annotations))] (~+ (list#each method_decl$ members)))))))) -(def: .public object +(def .public object (syntax (_ [class_vars ..vars^ super (<>.else $Object (class^ class_vars)) @@ -1260,15 +1260,15 @@ [(~+ (list#each constructor_arg$ constructor_args))] [(~+ methods)]))))))) -(def: .public null +(def .public null (syntax (_ []) (in (list (` ("jvm object null")))))) -(def: .public (null? obj) +(def .public (null? obj) (-> (.Primitive "java.lang.Object") Bit) ("jvm object null?" obj)) -(def: .public ??? +(def .public ??? (syntax (_ [expr <code>.any]) (with_symbols [g!temp] (in (list (` (let [(~ g!temp) (~ expr)] @@ -1276,7 +1276,7 @@ {.#Some (~ g!temp)} {.#None})))))))) -(def: .public !!! +(def .public !!! (syntax (_ [expr <code>.any]) (with_symbols [g!value] (in (list (` (.case (~ expr) @@ -1286,7 +1286,7 @@ {.#None} ("jvm object null")))))))) -(def: .public as +(def .public as (syntax (_ [class (..type^ (list)) unchecked (<>.maybe <code>.any)]) (with_symbols [g!_ g!unchecked] @@ -1309,12 +1309,12 @@ (~ check_code)))))) ))))) -(def: .public synchronized +(def .public synchronized (syntax (_ [lock <code>.any body <code>.any]) (in (list (` ("jvm object synchronized" (~ lock) (~ body))))))) -(def: .public do_to +(def .public do_to (syntax (_ [obj <code>.any methods (<>.some partial_call^)]) (with_symbols [g!obj] @@ -1322,19 +1322,19 @@ (exec (~+ (list#each (complete_call$ g!obj) methods)) (~ g!obj))))))))) -(def: (class_import$ declaration) +(def (class_import$ declaration) (-> (Type Declaration) Code) (let [[full_name params] (parser.declaration declaration) def_name (..internal full_name) params' (list#each ..var$' params)] (template.with_locals [g!_] - (` (def: (~ (code.symbol ["" def_name])) + (` (def (~ (code.symbol ["" def_name])) .Type (All ((~ (' g!_)) (~+ params')) (.Primitive (~ (code.text full_name)) [(~+ params')]))))))) -(def: (member_type_vars class_tvars member) +(def (member_type_vars class_tvars member) (-> (List (Type Var)) Import_Member_Declaration (List (Type Var))) (case member {#ConstructorDecl [commons _]} @@ -1351,7 +1351,7 @@ _ class_tvars)) -(def: (member_def_arg_bindings vars member) +(def (member_def_arg_bindings vars member) (-> (List (Type Var)) Import_Member_Declaration (Meta [(List [Bit Code]) (List (Type Value)) (List Code)])) (case member (^.or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) @@ -1376,7 +1376,7 @@ _ (at meta.monad in [(list) (list) (list)]))) -(def: (with_return_maybe member never_null? unboxed return_term) +(def (with_return_maybe member never_null? unboxed return_term) (-> Import_Member_Declaration Bit (Type Value) Code Code) (case member (^.or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) @@ -1399,7 +1399,7 @@ return_term)) (with_template [<name> <tag> <term_trans>] - [(def: (<name> member return_term) + [(def (<name> member return_term) (-> Import_Member_Declaration Code Code) (case member (^.or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) @@ -1415,7 +1415,7 @@ ) (with_template [<input?> <name> <unbox/box> <special+>] - [(def: (<name> mode [unboxed raw]) + [(def (<name> mode [unboxed raw]) (-> Primitive_Mode [(Type Value) Code] Code) (let [[unboxed refined post] (.is [(Type Value) Code (List Code)] (case mode @@ -1472,11 +1472,11 @@ [jvm.double (list) [(` (.is (.Primitive (~ (code.text box.double)))))]]]] ) -(def: (un_quoted quoted) +(def (un_quoted quoted) (-> Code Code) (` ((~' ~) (~ quoted)))) -(def: (jvm_invoke_inputs mode classes inputs) +(def (jvm_invoke_inputs mode classes inputs) (-> Primitive_Mode (List (Type Value)) (List [Bit Code]) (List Code)) (|> inputs (list.zipped_2 classes) @@ -1488,13 +1488,13 @@ [class] (with_automatic_input_conversion mode)))))) -(def: (import_name format class member) +(def (import_name format class member) (-> Text Text Text Text) (|> format (text.replaced "[1]" class) (text.replaced "[0]" member))) -(def: syntax_inputs +(def syntax_inputs (-> (List Code) (List Code)) (|>> (list#each (function (_ name) (list name (` (~! <code>.any))))) @@ -1506,7 +1506,7 @@ "Class" (%.text class) "Field" (%.text field))) -(def: (member_def_interop vars kind class [arg_function_inputs input_jvm_types arg_types] member method_prefix import_format) +(def (member_def_interop vars kind class [arg_function_inputs input_jvm_types arg_types] member method_prefix import_format) (-> (List (Type Var)) Class_Kind (Type Declaration) [(List [Bit Code]) (List (Type Value)) (List Code)] Import_Member_Declaration Text Text (Meta (List Code))) (let [[full_name class_tvars] (parser.declaration class)] (case member @@ -1525,7 +1525,7 @@ getter_interop (.is (-> Text Code) (function (_ name) (let [getter_name (code.symbol ["" (..import_name import_format method_prefix name)])] - (` (def: (~ getter_name) + (` (def (~ getter_name) (~ enum_type) (~ (get_static_field full_name name)))))))]] (in (list#each getter_interop enum_members)))) @@ -1546,7 +1546,7 @@ (with_return_maybe member true classT) (with_return_try member) (with_return_io member))]] - (in (list (` (def: (~ def_name) + (in (list (` (def (~ def_name) ((~! syntax) ((~ def_name) [(~+ (syntax_inputs (list#each product.right arg_function_inputs)))]) ((~' in) (.list (.` (~ jvm_interop)))))))))) @@ -1601,7 +1601,7 @@ (|> callC (with_return_try member) (with_return_io member))))]] - (in (list (` (def: (~ def_name) + (in (list (` (def (~ def_name) ((~! syntax) ((~ def_name) [(~+ (syntax_inputs (list#each product.right arg_function_inputs))) (~+ (syntax_inputs object_ast))]) ((~' in) (.list (.` (~ jvm_interop))))))))))) @@ -1657,14 +1657,14 @@ (` {.#Right []}) (` {.#Right [(~ g!obj)]})) (` ((~' in) (.list (.` (~ getter_body))))))] - (list (` (def: (~ g!name) + (list (` (def (~ g!name) ((~! syntax) ((~ g!name) [(~ write|read) (~ parser)]) (case (~ write|read) (~+ write) (~+ read)))))))))) ))) -(def: (member_import$ vars kind class [import_format member]) +(def (member_import$ vars kind class [import_format member]) (-> (List (Type Var)) Class_Kind (Type Declaration) [Text Import_Member_Declaration] (Meta (List Code))) (let [[full_name _] (parser.declaration class) method_prefix (..internal full_name)] @@ -1672,21 +1672,21 @@ [=args (member_def_arg_bindings vars member)] (member_def_interop vars kind class =args member method_prefix import_format)))) -(def: interface? +(def interface? (All (_ a) (-> (.Primitive "java.lang.Class" [a]) Bit)) (|>> ("jvm member invoke virtual" [] "java.lang.Class" "isInterface" []) "jvm object cast" (.is ..Boolean) (.as Bit))) -(def: load_class +(def load_class (-> External (Try (.Primitive "java.lang.Class" [Any]))) (|>> (.as (.Primitive "java.lang.String")) ["Ljava/lang/String;"] ("jvm member invoke static" [] "java.lang.Class" "forName" []) try)) -(def: (class_kind declaration) +(def (class_kind declaration) (-> (Type Declaration) (Meta Class_Kind)) (let [[class_name _] (parser.declaration declaration)] (case (load_class class_name) @@ -1698,7 +1698,7 @@ {.#Left _} (meta.failure (format "Unknown class: " class_name))))) -(def: .public import +(def .public import (syntax (_ [declaration ..declaration^ .let [[class_name class_type_vars] (parser.declaration declaration)] import_format <code>.text @@ -1710,7 +1710,7 @@ (monad.each ! (member_import$ class_type_vars kind declaration)))] (in (list.partial (class_import$ declaration) (list#conjoint =members)))))) -(def: .public array +(def .public array (syntax (_ [type (..type^ (list)) size <code>.any]) (let [g!size (` (|> (~ size) @@ -1740,7 +1740,7 @@ "Lux Type" (%.type type))) (with_expansions [<failure> (these (meta.failure (exception.error ..cannot_convert_to_jvm_type [type])))] - (def: (lux_type->jvm_type context type) + (def (lux_type->jvm_type context type) (-> Type_Context .Type (Meta (Type Value))) (if (type#= .Any type) (at meta.monad in $Object) @@ -1838,7 +1838,7 @@ _ <failure>)))) -(def: .public length +(def .public length (syntax (_ [array <code>.any]) (case array [_ {.#Symbol array_name}] @@ -1874,7 +1874,7 @@ (in (list (` (let [(~ g!array) (~ array)] (..length (~ g!array)))))))))) -(def: .public read! +(def .public read! (syntax (_ [idx <code>.any array <code>.any]) (case array @@ -1913,7 +1913,7 @@ (in (list (` (let [(~ g!array) (~ array)] (..read! (~ idx) (~ g!array)))))))))) -(def: .public write! +(def .public write! (syntax (_ [idx <code>.any value <code>.any array <code>.any]) @@ -1954,11 +1954,11 @@ (in (list (` (let [(~ g!array) (~ array)] (..write! (~ idx) (~ value) (~ g!array)))))))))) -(def: .public class_for +(def .public class_for (syntax (_ [type (..type^ (list))]) (in (list (` ("jvm object class" (~ (code.text (..reflection type))))))))) -(def: .public type +(def .public type (syntax (_ [type (..type^ (list))]) (in (list (..value_type {#ManualPrM} type))))) @@ -1967,7 +1967,7 @@ "Signature" (..signature type) "Reflection" (..reflection type))) -(def: .public is +(def .public is (syntax (_ [type (..type^ (list)) object <code>.any]) (case [(parser.array? type) @@ -1980,11 +1980,11 @@ (meta.failure (exception.error ..cannot_cast_to_non_object [type]))))) (with_template [<forward> <from> <to> <backward>] - [(def: .public <forward> + [(def .public <forward> (template (<forward> it) [(|> it (.is <from>) (.as <to>))])) - (def: .public <backward> + (def .public <backward> (template (<backward> it) [(|> it (.is <to>) (.as <from>))]))] @@ -1995,11 +1995,11 @@ ) (with_template [<forward> <from> <$> <mid> <$'> <to> <backward>] - [(def: .public <forward> + [(def .public <forward> (template (<forward> it) [(|> it (.is <from>) (.as <mid>) <$> (.is <to>))])) - (def: .public <backward> + (def .public <backward> (template (<backward> it) [(|> it (.is <to>) <$'> (.is <mid>) (.as <from>))]))] diff --git a/stdlib/source/library/lux/ffi.lux b/stdlib/source/library/lux/ffi.lux index 65fb0ea9c..d63363c38 100644 --- a/stdlib/source/library/lux/ffi.lux +++ b/stdlib/source/library/lux/ffi.lux @@ -96,7 +96,7 @@ (type: Alias (Maybe Text)) - (def: alias + (def alias (Parser Alias) (<>.maybe (<>.after (<code>.this (' "as")) <code>.local))) @@ -105,7 +105,7 @@ [#optional? Bit #mandatory Code])) - (def: optional + (def optional (Parser Optional) (let [token "?"] (<| (<>.and (<>.parses? (<code>.this_text token))) @@ -119,7 +119,7 @@ #anonymous a])) (with_template [<case> <name>] - [(def: <case> + [(def <case> (All (_ a) (-> (Parser a) (Parser (Named a)))) (|>> (all <>.and <name> @@ -133,18 +133,18 @@ (type: Output Optional) - (def: output + (def output (Parser Output) ..optional) (type: Global (Named Output)) - (def: variables + (def variables (Parser (List Text)) (<>.else (list) (<code>.tuple (<>.some <code>.local)))) - (def: (generalized $ it) + (def (generalized $ it) (All (_ a) (-> (-> (List Text) a a) (-> (Parser a) (Parser a)))) @@ -160,7 +160,7 @@ #io? Bit #try? Bit])) - (def: input + (def input (Parser Input) (all <>.and (<>#in (list)) @@ -171,7 +171,7 @@ (type: Constructor (Named Input)) - (def: constructor + (def constructor (Parser Constructor) (<| <code>.form (..generalized (has [#anonymous #variables])) @@ -183,11 +183,11 @@ [#static? Bit #member a])) - (def: static! + (def static! (Parser Any) (<code>.this_text "static")) - (def: (member it) + (def (member it) (All (_ a) (-> (Parser a) (Parser (Member a)))) @@ -201,7 +201,7 @@ (type: Field (Member (Named Output))) - (def: field + (def field (Parser Field) (<| <code>.form ..member @@ -213,7 +213,7 @@ [#input Input #output Optional])) - (def: procedure + (def procedure (Parser (Named Procedure)) (<| (..generalized (has [#anonymous #input #variables])) ..named @@ -225,7 +225,7 @@ (type: Method (Member (Named Procedure))) - (def: method + (def method (Parser Method) (<| <code>.form ..member @@ -239,7 +239,7 @@ {#Field Field} {#Method Method})))) - (`` (`` (def: sub + (`` (`` (def sub (Parser Sub) (all <>.or (~~ (for @.lua (~~ (these)) @@ -249,14 +249,14 @@ ..method )))) - (def: parameters + (def parameters (-> (List Optional) (List Optional)) (|>> list.enumeration (list#each (.function (_ [idx [optional? type]]) [#optional? optional? #mandatory (|> idx %.nat code.local)])))) - (def: (output_type it) + (def (output_type it) (-> Optional Code) (if (the #optional? it) (` (.Maybe (~ (the #mandatory it)))) @@ -264,17 +264,17 @@ (`` (with_template [<lux_it> <host_it> <lux_?> <host_?>] - [(def: .public (<lux_it> _) + [(def .public (<lux_it> _) (-> Any Nothing) (as_expected (<host_it>))) - (def: .public <lux_?> + (def .public <lux_?> (-> Any Bit) (|>> <host_?>)) (template.with_locals [g!it] - (these (def: g!it' (' g!it)) - (def: (host_optional it) + (these (def g!it' (' g!it)) + (def (host_optional it) (-> Optional Code) (.if (.the #optional? it) (` (.case (~ (the #mandatory it)) @@ -285,7 +285,7 @@ (<host_it>))) (the #mandatory it))) - (def: (lux_optional it output) + (def (lux_optional it output) (-> Optional Code Code) (` (.let [(~ g!it') (~ output)] (~ (if (the #optional? it) @@ -319,7 +319,7 @@ #namespace Namespace #members (List Sub)])) - (def: class + (def class (Parser Class) (all <>.and (<>.either (<>.and <code>.local @@ -336,14 +336,14 @@ {#Procedure (Named Procedure)} {#Global Global})) - (def: importP + (def importP (Parser Import) (all <>.or ..class (<code>.form ..procedure) (<code>.form (..named ..output)))) - (def: (input_type input :it:) + (def (input_type input :it:) (-> Input Code Code) (let [:it: (if (the #try? input) (` (.Either .Text (~ :it:))) @@ -352,7 +352,7 @@ (` ((~! io.IO) (~ :it:))) :it:))) - (def: (input_term input term) + (def (input_term input term) (-> Input Code Code) (let [term (if (the #try? input) (` (.try (~ term))) @@ -361,7 +361,7 @@ (` ((~! io.io) (~ term))) term))) - (def: (procedure_definition import! source it) + (def (procedure_definition import! source it) (-> (List Code) Code (Named Procedure) Code) (let [g!it (|> (the #alias it) (maybe.else (the #name it)) @@ -377,7 +377,7 @@ parameters (list#each ..output_type :parameters:))] - (` (.def: ((~ g!it) (~+ (case g!parameters + (` (.def ((~ g!it) (~+ (case g!parameters {.#End} (list g!it) _ (list#each (the #mandatory) g!parameters)))) (.All ((~ g!it) (~+ g!variables)) @@ -393,19 +393,19 @@ (` (<apply> (.as_expected (~ source)) [(~+ (list#each ..host_optional g!parameters))])))))))))) - (def: (namespaced namespace class alias member) + (def (namespaced namespace class alias member) (-> Namespace Text Alias Text Text) (|> namespace (text.replaced "[1]" (maybe.else class alias)) (text.replaced "[0]" member))) - (def: class_separator ".") + (def class_separator ".") - (def: host_path + (def host_path (text.replaced .module_separator ..class_separator)) (for @.js (these) - (def: (imported class) + (def (imported class) (-> Text Code) (case (text.all_split_by .module_separator class) {.#Item head tail} @@ -419,13 +419,13 @@ {.#End} (` (<import> (~ (code.text class))))))) - (def: (global_definition import! it) + (def (global_definition import! it) (-> (List Code) Global Code) (let [g!name (|> (the #alias it) (maybe.else (the #name it)) code.local) :output: (the #anonymous it)] - (` (.def: (~ g!name) + (` (.def (~ g!name) (~ (..output_type :output:)) (.exec (~+ import!) @@ -435,7 +435,7 @@ (for @.lua (these) @.ruby (these) - (def: (constructor_definition [class_name class_parameters] alias namespace it) + (def (constructor_definition [class_name class_parameters] alias namespace it) (-> Declaration Alias Namespace Constructor Code) (let [g!it (|> it (the #alias) @@ -449,7 +449,7 @@ g!class_variables (list#each code.local class_parameters) g!class (` ((~ (code.local (maybe.else class_name alias))) (~+ g!class_variables))) :output: [#optional? false #mandatory g!class]] - (` (.def: ((~ g!it) (~+ (case g!parameters + (` (.def ((~ g!it) (~+ (case g!parameters {.#End} (list g!it) _ (list#each (the #mandatory) g!parameters)))) (.All ((~ g!it) (~+ g!class_variables) (~+ g!input_variables)) @@ -465,7 +465,7 @@ (~ (..imported class_name)))))) [(~+ (list#each ..host_optional g!parameters))])))))))))) - (def: (static_field_definition import! [class_name class_parameters] alias namespace it) + (def (static_field_definition import! [class_name class_parameters] alias namespace it) (-> (List Code) Declaration Alias Namespace (Named Output) Code) (let [field (the #name it) g!it (|> (the #alias it) @@ -473,7 +473,7 @@ (..namespaced namespace class_name alias) code.local) :field: (the #anonymous it)] - (` (def: (~ g!it) + (` (def (~ g!it) ((~! syntax) ((~ g!it) []) (.at (~! meta.monad) (~' in) (.list (`' (.exec @@ -485,7 +485,7 @@ (` (<get> (~ (code.text field)) (~ (..imported class_name))))))))))))))))) - (def: (virtual_field_definition [class_name class_parameters] alias namespace it) + (def (virtual_field_definition [class_name class_parameters] alias namespace it) (-> Declaration Alias Namespace (Named Output) Code) (let [name (the #name it) g!it (|> (the #alias it) @@ -496,7 +496,7 @@ :field: (the #anonymous it) g!variables (list#each code.local class_parameters) g!class (` ((~ (code.local (maybe.else class_name alias))) (~+ g!variables)))] - (` (.def: ((~ g!it) (~ g!it)) + (` (.def ((~ g!it) (~ g!it)) (.All ((~ g!it) (~+ g!variables)) (.-> (~ g!class) (~ (..output_type :field:)))) @@ -504,13 +504,13 @@ (~ (<| (lux_optional :field:) (` (<get> (~ (code.text name)) (~ g!it)))))))))) - (def: (field_definition import! class alias namespace it) + (def (field_definition import! class alias namespace it) (-> (List Code) Declaration Alias Namespace Field Code) (if (the #static? it) (..static_field_definition import! class alias namespace (the #member it)) (..virtual_field_definition class alias namespace (the #member it)))) - (def: (static_method_definition import! [class_name class_parameters] alias namespace it) + (def (static_method_definition import! [class_name class_parameters] alias namespace it) (-> (List Code) Declaration Alias Namespace (Named Procedure) Code) (let [method (the #name it) name (|> (the #alias it) @@ -525,7 +525,7 @@ (.as (..Object .Any) (~ (..imported class_name)))))))))) - (def: (virtual_method_definition [class_name class_parameters] alias namespace it) + (def (virtual_method_definition [class_name class_parameters] alias namespace it) (-> Declaration Alias Namespace (Named Procedure) Code) (let [method (the #name it) g!it (|> (the #alias it) @@ -540,7 +540,7 @@ g!class_variables (list#each code.local class_parameters) g!class (` ((~ (code.local (maybe.else class_name alias))) (~+ g!class_variables))) :output: (the #output procedure)] - (` (.def: ((~ g!it) (~+ (list#each (the #mandatory) g!parameters)) (~ g!it)) + (` (.def ((~ g!it) (~+ (list#each (the #mandatory) g!parameters)) (~ g!it)) (.All ((~ g!it) (~+ g!class_variables) (~+ g!input_variables)) (.-> (~+ (list#each ..output_type :parameters:)) (~ g!class) @@ -554,13 +554,13 @@ (~ g!it) [(~+ (list#each ..host_optional g!parameters))]))))))))) - (def: (method_definition import! class alias namespace it) + (def (method_definition import! class alias namespace it) (-> (List Code) Declaration Alias Namespace Method Code) (if (the #static? it) (static_method_definition import! class alias namespace (the #member it)) (virtual_method_definition class alias namespace (the #member it)))) - (def: .public import + (def .public import (syntax (_ [host_module (<>.maybe <code>.text) it ..importP]) (let [host_module_import! (is (List Code) @@ -606,7 +606,7 @@ )))) (for @.ruby (these) - (def: .public function + (def .public function (syntax (_ [[self inputs] (<code>.form (all <>.and <code>.local @@ -622,11 +622,11 @@ (.function ((~ (code.local self)) [(~+ (list#each product.left inputs))]) (~ term))))))))) - (for @.js (these (def: .public type_of + (for @.js (these (def .public type_of (template (type_of object) [("js type-of" object)])) - (def: .public global + (def .public global (syntax (_ [type <code>.any [head tail] (<code>.tuple (<>.and <code>.local (<>.some <code>.local)))]) (with_symbols [g!_] @@ -652,7 +652,7 @@ (..global (~ type) [(~ (code.local (%.format head "." next))) (~+ (list#each code.local tail))])))))))))))) - (def: !defined? + (def !defined? (template (_ <global>) [(.case (..global Any <global>) {.#None} @@ -662,7 +662,7 @@ .true)])) (with_template [<name> <global>] - [(def: .public <name> + [(def .public <name> Bit (!defined? <global>))] @@ -670,7 +670,7 @@ [on_nashorn? [java lang Object]] ) - (def: .public on_node_js? + (def .public on_node_js? Bit (|> (..global (Object Any) [process]) (maybe#each (|>> [] @@ -682,7 +682,7 @@ ... These extensions must be defined this way because importing any of the modules ... normally used when writing extensions would introduce a circular dependency ... because the Archive type depends on Binary, and that module depends on this ffi module. - (def: extension_name + (def extension_name (syntax (_ []) (do meta.monad [module meta.current_module_name @@ -692,15 +692,15 @@ (with_expansions [<undefined> (..extension_name) <undefined?> (..extension_name) <object> (..extension_name)] - (these (def: extension_analysis + (these (def extension_analysis (template (_ <name> <parameter>) [{5 #1 [<name> <parameter>]}])) - (def: text_analysis + (def text_analysis (template (_ <it>) [{0 #0 {5 #1 <it>}}])) - (def: analysis + (def analysis (template (_ <name> <bindings> <parser> <inputs> <body>) [("lux def analysis" <name> (.function (_ name phase archive inputs) @@ -714,7 +714,7 @@ {try.#Success <inputs>} <body>)))))])) - (def: generation + (def generation (template (_ <name> <bindings> <inputs> <body>) [("lux def generation" <name> (.function (_ name phase archive inputs) @@ -738,7 +738,7 @@ (list) {try.#Success [state js.undefined]}) - (def: .public undefined + (def .public undefined (template (undefined) [(.is ..Undefined (<undefined>))])) @@ -757,7 +757,7 @@ [[state it] (phase archive it state)] (in [state (js.= js.undefined it)]))) - (def: .public undefined? + (def .public undefined? (template (undefined? <it>) [(.as .Bit (.is .Any (<undefined?> <it>)))])) @@ -774,11 +774,11 @@ it)] (in [state (extension_analysis name (list.reversed output))]))) - (def: text_synthesis + (def text_synthesis (template (_ <it>) [{0 #0 {2 #1 <it>}}])) - (def: (pairs it) + (def (pairs it) (All (_ a) (-> (List a) (List [a a]))) (case it (pattern (list.partial left right tail)) @@ -808,7 +808,7 @@ (pairs (list.partial head_key head_value tail)))] (in [state (js.object (list.reversed output))]))) - (def: .public object + (def .public object (syntax (_ [it (<>.some <code>.any)]) (in (list (` (.as (..Object .Any) (<object> (~+ it)))))))) diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index 2fa4e5b7a..c7d8c3dd2 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -28,7 +28,7 @@ ["[0]" meta]]]) (with_template [<name> <op> <from> <to>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> (Primitive <from>) (Primitive <to>)) (<op> value))] @@ -64,11 +64,11 @@ ) (with_template [<forward> <from> <to> <backward>] - [(def: .public <forward> + [(def .public <forward> (template (<forward> it) [(|> it (.is <from>) (.as (Primitive <to>)))])) - (def: .public <backward> + (def .public <backward> (template (<backward> it) [(|> it (.is (Primitive <to>)) (.as <from>))]))] @@ -79,11 +79,11 @@ ) (with_template [<forward> <from> <$> <mid> <$'> <to> <backward>] - [(def: .public <forward> + [(def .public <forward> (template (<forward> it) [(|> it (.is <from>) (.as (Primitive <mid>)) <$> (.is (Primitive <to>)))])) - (def: .public <backward> + (def .public <backward> (template (<backward> it) [(|> it (.is (Primitive <to>)) <$'> (.is (Primitive <mid>)) (.as <from>))]))] @@ -94,8 +94,8 @@ ) ... [Utils] -(def: constructor_method_name "<init>") -(def: member_separator "::") +(def constructor_method_name "<init>") +(def member_separator "::") ... Types (type: JVM_Code @@ -282,7 +282,7 @@ {#FieldAccessDecl ImportFieldDecl})) ... Utils -(def: (manual_primitive_type class) +(def (manual_primitive_type class) (-> Text (Maybe Code)) (case class (^.with_template [<prim> <type>] @@ -301,7 +301,7 @@ _ {.#None})) -(def: (auto_primitive_type class) +(def (auto_primitive_type class) (-> Text (Maybe Code)) (case class (^.with_template [<prim> <type>] @@ -319,11 +319,11 @@ _ {.#None})) -(def: safe +(def safe (-> Text Text) (text.replaced "/" ".")) -(def: (generic_class_type' mode type_params in_array? name+params +(def (generic_class_type' mode type_params in_array? name+params class_type') (-> Primitive_Mode (List Type_Parameter) Bit [Text (List GenericType)] (-> Primitive_Mode (List Type_Parameter) Bit GenericType Code) @@ -344,7 +344,7 @@ =params (list#each (class_type' mode type_params in_array?) params)] (` (Primitive (~ (code.text name)) [(~+ =params)]))))) -(def: (class_type' mode type_params in_array? class) +(def (class_type' mode type_params in_array? class) (-> Primitive_Mode (List Type_Parameter) Bit GenericType Code) (case class {#GenericTypeVar name} @@ -374,15 +374,15 @@ (class_type' mode type_params in_array? upper_bound) )) -(def: (class_type mode type_params class) +(def (class_type mode type_params class) (-> Primitive_Mode (List Type_Parameter) GenericType Code) (class_type' mode type_params #0 class)) -(def: (type_param_type$ [name bounds]) +(def (type_param_type$ [name bounds]) (-> Type_Parameter Code) (code.symbol ["" name])) -(def: (class_decl_type$ (open "[0]")) +(def (class_decl_type$ (open "[0]")) (-> Class_Declaration Code) (let [=params (list#each (.is (-> Type_Parameter Code) (function (_ [pname pbounds]) @@ -396,9 +396,9 @@ (` (Primitive (~ (code.text (safe #class_name))) [(~+ =params)])))) -(def: type_var_class Text "java.lang.Object") +(def type_var_class Text "java.lang.Object") -(def: (simple_class$ env class) +(def (simple_class$ env class) (-> (List Type_Parameter) GenericType Text) (case class {#GenericTypeVar name} @@ -443,21 +443,21 @@ (format "[L" (simple_class$ env param) ";")) )) -(def: (get_const_parser class_name field_name) +(def (get_const_parser class_name field_name) (-> Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] _ (<code>.this (code.symbol ["" dotted_name]))] (in (`' ((~ (code.text (format "jvm getstatic" ":" class_name ":" field_name)))))))) -(def: (get_var_parser class_name field_name) +(def (get_var_parser class_name field_name) (-> Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] _ (<code>.this (code.symbol ["" dotted_name]))] (in (`' ((~ (code.text (format "jvm getfield" ":" class_name ":" field_name))) _jvm_this))))) -(def: (put_var_parser class_name field_name) +(def (put_var_parser class_name field_name) (-> Text Text (Parser Code)) (do <>.monad [.let [dotted_name (format "::" field_name)] @@ -465,7 +465,7 @@ (<code>.form (all <>.and (<code>.this (' :=)) (<code>.this (code.symbol ["" dotted_name])) <code>.any)))] (in (`' ((~ (code.text (format "jvm putfield" ":" class_name ":" field_name))) _jvm_this (~ value)))))) -(def: (pre_walk_replace f input) +(def (pre_walk_replace f input) (-> (-> Code Code) Code Code) (case (f input) (^.with_template [<tag>] @@ -478,7 +478,7 @@ ast' ast')) -(def: (parser_replacer p ast) +(def (parser_replacer p ast) (-> (Parser Code) (-> Code Code)) (case (<>.result p (list ast)) {.#Right [{.#End} ast']} @@ -488,7 +488,7 @@ ast )) -(def: (field_parser class_name [[field_name _ _] field]) +(def (field_parser class_name [[field_name _ _] field]) (-> Text [Member_Declaration FieldDecl] (Parser Code)) (case field {#ConstantField _} @@ -498,7 +498,7 @@ (<>.either (get_var_parser class_name field_name) (put_var_parser class_name field_name)))) -(def: (constructor_parser params class_name arg_decls) +(def (constructor_parser params class_name arg_decls) (-> (List Type_Parameter) Text (List ArgDecl) (Parser Code)) (do <>.monad [args (.is (Parser (List Code)) @@ -508,7 +508,7 @@ (in (` ((~ (code.text (format "jvm new" ":" class_name ":" (text.interposed "," arg_decls')))) (~+ args)))))) -(def: (static_method_parser params class_name method_name arg_decls) +(def (static_method_parser params class_name method_name arg_decls) (-> (List Type_Parameter) Text Text (List ArgDecl) (Parser Code)) (do <>.monad [.let [dotted_name (format "::" method_name "!")] @@ -520,7 +520,7 @@ (~+ args)))))) (with_template [<name> <jvm_op>] - [(def: (<name> params class_name method_name arg_decls) + [(def (<name> params class_name method_name arg_decls) (-> (List Type_Parameter) Text Text (List ArgDecl) (Parser Code)) (do <>.monad [.let [dotted_name (format "::" method_name "!")] @@ -535,7 +535,7 @@ [virtual_method_parser "jvm invokevirtual"] ) -(def: (method_parser params class_name [[method_name _ _] meth_def]) +(def (method_parser params class_name [[method_name _ _] meth_def]) (-> (List Type_Parameter) Text [Member_Declaration Method_Definition] (Parser Code)) (case meth_def {#ConstructorMethod strict? type_vars args constructor_args return_expr exs} @@ -555,7 +555,7 @@ (virtual_method_parser params class_name method_name args))) ... Parsers -(def: privacy_modifier^ +(def privacy_modifier^ (Parser Privacy) (let [(open "[0]") <>.monad] (all <>.or @@ -564,7 +564,7 @@ (<code>.this (' "protected")) (in [])))) -(def: inheritance_modifier^ +(def inheritance_modifier^ (Parser Inheritance) (let [(open "[0]") <>.monad] (all <>.or @@ -572,17 +572,17 @@ (<code>.this (' "abstract")) (in [])))) -(def: bound_kind^ +(def bound_kind^ (Parser BoundKind) (<>.or (<code>.this (' <)) (<code>.this (' >)))) -(def: (no_periods_assertion name) +(def (no_periods_assertion name) (-> Text (Parser Any)) (<>.assertion "Names in class declarations cannot contain periods." (not (text.contains? "." name)))) -(def: (generic_type^ type_vars) +(def (generic_type^ type_vars) (-> (List Type_Parameter) (Parser GenericType)) (<>.rec (function (_ again^) @@ -627,7 +627,7 @@ (in {#GenericClass name params}))) )))) -(def: type_param^ +(def type_param^ (Parser Type_Parameter) (<>.either (do <>.monad [param_name <code>.local] @@ -638,14 +638,14 @@ bounds (<>.many (..generic_type^ (list)))] (in [param_name bounds]))))) -(def: type_params^ +(def type_params^ (Parser (List Type_Parameter)) (|> ..type_param^ <>.some <code>.tuple (<>.else (list)))) -(def: class_decl^ +(def class_decl^ (Parser Class_Declaration) (<>.either (do <>.monad [name <code>.local @@ -658,7 +658,7 @@ (in [name params]))) )) -(def: (super_class_decl^ type_vars) +(def (super_class_decl^ type_vars) (-> (List Type_Parameter) (Parser Super_Class_Decl)) (<>.either (do <>.monad [name <code>.local @@ -670,11 +670,11 @@ params (<>.some (..generic_type^ type_vars))] (in [name params]))))) -(def: annotation_params^ +(def annotation_params^ (Parser (List AnnotationParam)) (<code>.tuple (<>.some (<>.and <code>.text <code>.any)))) -(def: annotation^ +(def annotation^ (Parser Annotation) (<>.either (do <>.monad [ann_name <code>.local] @@ -682,31 +682,31 @@ (<code>.form (<>.and <code>.local annotation_params^)))) -(def: annotations^' +(def annotations^' (Parser (List Annotation)) (do <>.monad [_ (<code>.this (' "ann"))] (<code>.tuple (<>.some ..annotation^)))) -(def: annotations^ +(def annotations^ (Parser (List Annotation)) (do <>.monad [anns?? (<>.maybe ..annotations^')] (in (maybe.else (list) anns??)))) -(def: (throws_decl'^ type_vars) +(def (throws_decl'^ type_vars) (-> (List Type_Parameter) (Parser (List GenericType))) (do <>.monad [_ (<code>.this (' "throws"))] (<code>.tuple (<>.some (..generic_type^ type_vars))))) -(def: (throws_decl^ type_vars) +(def (throws_decl^ type_vars) (-> (List Type_Parameter) (Parser (List GenericType))) (do <>.monad [exs? (<>.maybe (throws_decl'^ type_vars))] (in (maybe.else (list) exs?)))) -(def: (method_decl^ type_vars) +(def (method_decl^ type_vars) (-> (List Type_Parameter) (Parser [Member_Declaration MethodDecl])) (<code>.form (do <>.monad [tvars ..type_params^ @@ -720,14 +720,14 @@ #method_output output #method_exs exs]])))) -(def: state_modifier^ +(def state_modifier^ (Parser State) (all <>.or (<code>.this (' "volatile")) (<code>.this (' "final")) (at <>.monad in []))) -(def: (field_decl^ type_vars) +(def (field_decl^ type_vars) (-> (List Type_Parameter) (Parser [Member_Declaration FieldDecl])) (<>.either (<code>.form (do <>.monad [_ (<code>.this (' "const")) @@ -744,24 +744,24 @@ type (..generic_type^ type_vars)] (in [[name pm anns] {#VariableField [sm type]}]))))) -(def: (arg_decl^ type_vars) +(def (arg_decl^ type_vars) (-> (List Type_Parameter) (Parser ArgDecl)) (<>.and <code>.local (..generic_type^ type_vars))) -(def: (arg_decls^ type_vars) +(def (arg_decls^ type_vars) (-> (List Type_Parameter) (Parser (List ArgDecl))) (<code>.tuple (<>.some (arg_decl^ type_vars)))) -(def: (constructor_arg^ type_vars) +(def (constructor_arg^ type_vars) (-> (List Type_Parameter) (Parser ConstructorArg)) (<>.and (..generic_type^ type_vars) <code>.any)) -(def: (constructor_args^ type_vars) +(def (constructor_args^ type_vars) (-> (List Type_Parameter) (Parser (List ConstructorArg))) (<code>.tuple (<>.some (constructor_arg^ type_vars)))) -(def: (constructor_method^ class_vars) +(def (constructor_method^ class_vars) (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition])) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -779,7 +779,7 @@ #member_anns annotations] {#ConstructorMethod strict_fp? method_vars arg_decls constructor_args body exs}])))) -(def: (virtual_method_def^ class_vars) +(def (virtual_method_def^ class_vars) (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition])) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -803,7 +803,7 @@ this_name arg_decls return_type body exs}])))) -(def: overriden_method_def^ +(def overriden_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [strict_fp? (<>.parses? (<code>.this (' "strict"))) @@ -826,7 +826,7 @@ this_name arg_decls return_type body exs}])))) -(def: static_method_def^ +(def static_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -845,7 +845,7 @@ #member_anns annotations] {#StaticMethod strict_fp? method_vars arg_decls return_type body exs}])))) -(def: abstract_method_def^ +(def abstract_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -862,7 +862,7 @@ #member_anns annotations] {#AbstractMethod method_vars arg_decls return_type exs}])))) -(def: native_method_def^ +(def native_method_def^ (Parser [Member_Declaration Method_Definition]) (<code>.form (do <>.monad [pm privacy_modifier^ @@ -879,7 +879,7 @@ #member_anns annotations] {#NativeMethod method_vars arg_decls return_type exs}])))) -(def: (method_def^ class_vars) +(def (method_def^ class_vars) (-> (List Type_Parameter) (Parser [Member_Declaration Method_Definition])) (all <>.either (..constructor_method^ class_vars) @@ -889,30 +889,30 @@ ..abstract_method_def^ ..native_method_def^)) -(def: partial_call^ +(def partial_call^ (Parser Partial_Call) (<code>.form (<>.and <code>.symbol (<>.some <code>.any)))) -(def: import_member_alias^ +(def import_member_alias^ (Parser (Maybe Text)) (<>.maybe (do <>.monad [_ (<code>.this (' "as"))] <code>.local))) -(def: (import_member_args^ type_vars) +(def (import_member_args^ type_vars) (-> (List Type_Parameter) (Parser (List [Bit GenericType]))) (<code>.tuple (<>.some (<>.and (<>.parses? (<code>.this (' "?"))) (..generic_type^ type_vars))))) -(def: import_member_return_flags^ +(def import_member_return_flags^ (Parser [Bit Bit Bit]) (all <>.and (<>.parses? (<code>.this (' "io"))) (<>.parses? (<code>.this (' "try"))) (<>.parses? (<code>.this (' "?"))))) -(def: primitive_mode^ +(def primitive_mode^ (Parser Primitive_Mode) (<>.or (<code>.this (' "manual")) (<code>.this (' "auto")))) -(def: (import_member_decl^ owner_vars) +(def (import_member_decl^ owner_vars) (-> (List Type_Parameter) (Parser Import_Member_Declaration)) (all <>.either (<code>.form (do <>.monad @@ -974,19 +974,19 @@ )) ... Generators -(def: with_parens +(def with_parens (-> JVM_Code JVM_Code) (text.enclosed ["(" ")"])) -(def: with_brackets +(def with_brackets (-> JVM_Code JVM_Code) (text.enclosed ["[" "]"])) -(def: spaced +(def spaced (-> (List JVM_Code) JVM_Code) (text.interposed " ")) -(def: (privacy_modifier$ pm) +(def (privacy_modifier$ pm) (-> Privacy JVM_Code) (case pm {#PublicP} "public" @@ -994,28 +994,28 @@ {#ProtectedP} "protected" {#DefaultP} "default")) -(def: (inheritance_modifier$ im) +(def (inheritance_modifier$ im) (-> Inheritance JVM_Code) (case im {#FinalI} "final" {#AbstractI} "abstract" {#DefaultI} "default")) -(def: (annotation_param$ [name value]) +(def (annotation_param$ [name value]) (-> AnnotationParam JVM_Code) (format name "=" (code.format value))) -(def: (annotation$ [name params]) +(def (annotation$ [name params]) (-> Annotation JVM_Code) (format "(" name " " "{" (text.interposed text.tab (list#each annotation_param$ params)) "}" ")")) -(def: (bound_kind$ kind) +(def (bound_kind$ kind) (-> BoundKind JVM_Code) (case kind {#UpperBound} "<" {#LowerBound} ">")) -(def: (generic_type$ gtype) +(def (generic_type$ gtype) (-> GenericType JVM_Code) (case gtype {#GenericTypeVar name} @@ -1033,21 +1033,21 @@ {#GenericWildcard {.#Some [bound_kind bound]}} (format (bound_kind$ bound_kind) (generic_type$ bound)))) -(def: (type_param$ [name bounds]) +(def (type_param$ [name bounds]) (-> Type_Parameter JVM_Code) (format "(" name " " (spaced (list#each generic_type$ bounds)) ")")) -(def: (class_decl$ (open "[0]")) +(def (class_decl$ (open "[0]")) (-> Class_Declaration JVM_Code) (format "(" (safe #class_name) " " (spaced (list#each type_param$ #class_params)) ")")) -(def: (super_class_decl$ (open "[0]")) +(def (super_class_decl$ (open "[0]")) (-> Super_Class_Decl JVM_Code) (format "(" (safe #super_class_name) " " (spaced (list#each generic_type$ #super_class_params)) ")")) -(def: (method_decl$ [[name pm anns] method_decl]) +(def (method_decl$ [[name pm anns] method_decl]) (-> [Member_Declaration MethodDecl] JVM_Code) (let [(open "[0]") method_decl] (with_parens @@ -1059,14 +1059,14 @@ (generic_type$ #method_output)) )))) -(def: (state_modifier$ sm) +(def (state_modifier$ sm) (-> State JVM_Code) (case sm {#VolatileS} "volatile" {#FinalS} "final" {#DefaultS} "default")) -(def: (field_decl$ [[name pm anns] field]) +(def (field_decl$ [[name pm anns] field]) (-> [Member_Declaration FieldDecl] JVM_Code) (case field {#ConstantField class value} @@ -1087,17 +1087,17 @@ )) )) -(def: (arg_decl$ [name type]) +(def (arg_decl$ [name type]) (-> ArgDecl JVM_Code) (with_parens (spaced (list name (generic_type$ type))))) -(def: (constructor_arg$ [class term]) +(def (constructor_arg$ [class term]) (-> ConstructorArg JVM_Code) (with_brackets (spaced (list (generic_type$ class) (code.format term))))) -(def: (method_def$ replacer super_class [[name pm anns] method_def]) +(def (method_def$ replacer super_class [[name pm anns] method_def]) (-> (-> Code Code) Super_Class_Decl [Member_Declaration Method_Definition] JVM_Code) (case method_def {#ConstructorMethod strict_fp? type_vars arg_decls constructor_args body exs} @@ -1192,17 +1192,17 @@ (generic_type$ return_type)))) )) -(def: (complete_call$ g!obj [method args]) +(def (complete_call$ g!obj [method args]) (-> Code Partial_Call Code) (` ((~ (code.symbol method)) (~+ args) (~ g!obj)))) ... [Syntax] -(def: object_super_class +(def object_super_class Super_Class_Decl [#super_class_name "java/lang/Object" #super_class_params (list)]) -(def: .public class +(def .public class (syntax (_ [im inheritance_modifier^ class_decl ..class_decl^ .let [full_class_name (product.left class_decl)] @@ -1232,7 +1232,7 @@ (with_brackets (spaced (list#each (method_def$ replacer super) methods))))))]] (in (list (` ((~ (code.text def_code))))))))) -(def: .public interface +(def .public interface (syntax (_ [class_decl ..class_decl^ .let [class_vars (product.right class_decl)] supers (<>.else (list) @@ -1246,7 +1246,7 @@ (spaced (list#each method_decl$ members)))))] (in (list (` ((~ (code.text def_code))))))))) -(def: .public object +(def .public object (syntax (_ [class_vars (<code>.tuple (<>.some ..type_param^)) super (<>.else object_super_class (..super_class_decl^ class_vars)) @@ -1261,15 +1261,15 @@ (with_brackets (spaced (list#each (method_def$ function.identity super) methods))))))] (in (list (` ((~ (code.text def_code))))))))) -(def: .public null +(def .public null (syntax (_ []) (in (list (` ("jvm object null")))))) -(def: .public (null? obj) +(def .public (null? obj) (-> (Primitive "java.lang.Object") Bit) ("jvm object null?" obj)) -(def: .public ??? +(def .public ??? (syntax (_ [expr <code>.any]) (with_symbols [g!temp] (in (list (` (let [(~ g!temp) (~ expr)] @@ -1277,7 +1277,7 @@ {.#None} {.#Some (~ g!temp)})))))))) -(def: .public !!! +(def .public !!! (syntax (_ [expr <code>.any]) (with_symbols [g!value] (in (list (` (.case (~ expr) @@ -1287,7 +1287,7 @@ {.#None} ("jvm object null")))))))) -(def: .public as +(def .public as (syntax (_ [class (..generic_type^ (list)) unchecked (<>.maybe <code>.any)]) (with_symbols [g!_ g!unchecked] @@ -1310,12 +1310,12 @@ (~ check_code)))))) ))))) -(def: .public synchronized +(def .public synchronized (syntax (_ [lock <code>.any body <code>.any]) (in (list (` ("jvm object synchronized" (~ lock) (~ body))))))) -(def: .public do_to +(def .public do_to (syntax (_ [obj <code>.any methods (<>.some partial_call^)]) (with_symbols [g!obj] @@ -1323,17 +1323,17 @@ (exec (~+ (list#each (complete_call$ g!obj) methods)) (~ g!obj))))))))) -(def: (class_import$ [full_name params]) +(def (class_import$ [full_name params]) (-> Class_Declaration Code) (let [params' (list#each (|>> product.left code.local) params)] (template.with_locals [g!_] - (` (def: (~ (code.symbol ["" full_name])) + (` (def (~ (code.symbol ["" full_name])) Type (All ((~ (' g!_)) (~+ params')) (Primitive (~ (code.text (safe full_name))) [(~+ params')]))))))) -(def: (member_type_vars class_tvars member) +(def (member_type_vars class_tvars member) (-> (List Type_Parameter) Import_Member_Declaration (List Type_Parameter)) (case member {#ConstructorDecl [commons _]} @@ -1350,7 +1350,7 @@ _ class_tvars)) -(def: (member_def_arg_bindings type_params class member) +(def (member_def_arg_bindings type_params class member) (-> (List Type_Parameter) Class_Declaration Import_Member_Declaration (Meta [(List [Bit Code]) (List Text) (List Code)])) (case member (^.or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) @@ -1377,7 +1377,7 @@ _ (at meta.monad in [(list) (list) (list)]))) -(def: (decorate_return_maybe class member return_term) +(def (decorate_return_maybe class member return_term) (-> Class_Declaration Import_Member_Declaration Code Code) (case member (^.or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) @@ -1396,7 +1396,7 @@ return_term)) (with_template [<name> <tag> <term_trans>] - [(def: (<name> member return_term) + [(def (<name> member return_term) (-> Import_Member_Declaration Code Code) (case member (^.or {#ConstructorDecl [commons _]} {#MethodDecl [commons _]}) @@ -1411,18 +1411,18 @@ [decorate_return_io #import_member_io? (` ((~! io.io) (~ return_term)))] ) -(def: (free_type_param? [name bounds]) +(def (free_type_param? [name bounds]) (-> Type_Parameter Bit) (case bounds {.#End} #1 _ #0)) -(def: (lux_type_parameter [name _]) +(def (lux_type_parameter [name _]) (-> Type_Parameter Code) (code.symbol ["" name])) (with_template [<name> <byte> <short> <int> <float>] - [(def: (<name> mode [class expression]) + [(def (<name> mode [class expression]) (-> Primitive_Mode [Text Code] Code) (case mode {#ManualPrM} @@ -1435,11 +1435,11 @@ [auto_convert_output byte_to_long short_to_long int_to_long float_to_double] ) -(def: (un_quote quoted) +(def (un_quote quoted) (-> Code Code) (` ((~' ~) (~ quoted)))) -(def: (jvm_extension_inputs mode classes inputs) +(def (jvm_extension_inputs mode classes inputs) (-> Primitive_Mode (List Text) (List [Bit Code]) (List Code)) (|> inputs (list#each (function (_ [maybe? input]) @@ -1449,19 +1449,19 @@ (list.zipped_2 classes) (list#each (auto_convert_input mode)))) -(def: (import_name format class member) +(def (import_name format class member) (-> Text Text Text Text) (|> format (text.replaced "[1]" class) (text.replaced "[0]" member))) -(def: syntax_inputs +(def syntax_inputs (-> (List Code) (List Code)) (|>> (list#each (function (_ name) (list name (` (~! <code>.any))))) list#conjoint)) -(def: (member_def_interop type_params kind class [arg_function_inputs arg_classes arg_types] member method_prefix import_format) +(def (member_def_interop type_params kind class [arg_function_inputs arg_classes arg_types] member method_prefix import_format) (-> (List Type_Parameter) Class_Kind Class_Declaration [(List [Bit Code]) (List Text) (List Code)] Import_Member_Declaration Text Text (Meta (List Code))) (let [[full_name class_tvars] class full_name (safe full_name) @@ -1485,7 +1485,7 @@ getter_interop (.is (-> Text Code) (function (_ name) (let [getter_name (code.symbol ["" (..import_name import_format method_prefix name)])] - (` (def: (~ getter_name) + (` (def (~ getter_name) (~ enum_type) ((~ (code.text (format "jvm getstatic" ":" full_name ":" name)))))))))]] (in (list#each getter_interop enum_members)))) @@ -1499,7 +1499,7 @@ (decorate_return_maybe class member) (decorate_return_try member) (decorate_return_io member))]] - (in (list (` (def: (~ def_name) + (in (list (` (def (~ def_name) ((~! syntax) ((~ def_name) [(~+ (syntax_inputs (list#each product.right arg_function_inputs)))]) ((~' in) (.list (.` (~ jvm_interop)))))))))) @@ -1533,7 +1533,7 @@ (decorate_return_maybe class member) (decorate_return_try member) (decorate_return_io member))]] - (in (list (` (def: (~ def_name) + (in (list (` (def (~ def_name) ((~! syntax) ((~ def_name) [(~+ (syntax_inputs (list#each product.right arg_function_inputs))) (~+ (syntax_inputs object_ast))]) ((~' in) (.list (.` (~ jvm_interop))))))))))) @@ -1569,7 +1569,7 @@ getter_body (if #import_field_setter? (` ((~! io.io) (~ getter_body))) getter_body)] - (in (` (def: (~ getter_name) + (in (` (def (~ getter_name) ((~! syntax) (~ getter_call) ((~' in) (.list (.` (~ getter_body)))))))))) setter_interop (.is (Meta (List Code)) @@ -1590,14 +1590,14 @@ (if #import_field_static? (list) (list (un_quote g!obj))))] - (in (list (` (def: (~ setter_name) + (in (list (` (def (~ setter_name) ((~! syntax) (~ setter_call) ((~' in) (.list (.` ((~! io.io) ((~ (code.text setter_command)) (~+ g!obj+) (~ setter_value))))))))))))) (in (list))))] (in (list.partial getter_interop setter_interop))) ))) -(def: (member_import$ type_params kind class [import_format member]) +(def (member_import$ type_params kind class [import_format member]) (-> (List Type_Parameter) Class_Kind Class_Declaration [Text Import_Member_Declaration] (Meta (List Code))) (let [[method_prefix _] class] (do meta.monad @@ -1607,15 +1607,15 @@ (type: (java/lang/Class a) (Primitive "java.lang.Class" [a])) -(def: interface? +(def interface? (All (_ a) (-> (java/lang/Class a) Bit)) (|>> "jvm invokevirtual:java.lang.Class:isInterface:")) -(def: (load_class class_name) +(def (load_class class_name) (-> Text (Try (java/lang/Class Any))) (try ("jvm invokestatic:java.lang.Class:forName:java.lang.String" class_name))) -(def: (class_kind [class_name _]) +(def (class_kind [class_name _]) (-> Class_Declaration (Meta Class_Kind)) (let [class_name (..safe class_name)] (case (..load_class class_name) @@ -1628,7 +1628,7 @@ (meta.failure (format "Cannot load class: " class_name text.new_line error))))) -(def: .public import +(def .public import (syntax (_ [class_decl ..class_decl^ import_format <code>.text members (<>.some (..import_member_decl^ (product.right class_decl)))]) @@ -1639,7 +1639,7 @@ (monad.each ! (member_import$ (product.right class_decl) kind class_decl)))] (in (list.partial (class_import$ class_decl) (list#conjoint =members)))))) -(def: .public array +(def .public array (syntax (_ [type (..generic_type^ (list)) size <code>.any]) (case type @@ -1658,11 +1658,11 @@ _ (in (list (` ("jvm anewarray" (~ (code.text (generic_type$ type))) (~ size)))))))) -(def: .public length +(def .public length (syntax (_ [array <code>.any]) (in (list (` ("jvm arraylength" (~ array))))))) -(def: (type_class_name type) +(def (type_class_name type) (-> Type (Meta Text)) (if (type#= Any type) (at meta.monad in "java.lang.Object") @@ -1684,7 +1684,7 @@ _ (meta.failure (format "Cannot convert to JvmType: " (type.format type)))))) -(def: .public read! +(def .public read! (syntax (_ [idx <code>.any array <code>.any]) (case array @@ -1713,7 +1713,7 @@ (in (list (` (let [(~ g!array) (~ array)] (..read! (~ idx) (~ g!array)))))))))) -(def: .public write! +(def .public write! (syntax (_ [idx <code>.any value <code>.any array <code>.any]) @@ -1743,14 +1743,14 @@ (in (list (` (let [(~ g!array) (~ array)] (..write! (~ idx) (~ value) (~ g!array)))))))))) -(def: .public class_for +(def .public class_for (syntax (_ [type (..generic_type^ (list))]) (in (list (` ("jvm object class" (~ (code.text (simple_class$ (list) type))))))))) -(def: .public type +(def .public type (syntax (_ [type (..generic_type^ (list))]) (in (list (..class_type {#ManualPrM} (list) type))))) -(def: .public is +(def .public is (template (is type term) [(.as type term)])) diff --git a/stdlib/source/library/lux/ffi.php.lux b/stdlib/source/library/lux/ffi.php.lux index f354972a3..36f828a48 100644 --- a/stdlib/source/library/lux/ffi.php.lux +++ b/stdlib/source/library/lux/ffi.php.lux @@ -48,7 +48,7 @@ (type: Nullable [Bit Code]) -(def: nullable +(def nullable (Parser Nullable) (let [token (' "?")] (<| (<>.and (<>.parses? (<code>.this token))) @@ -58,18 +58,18 @@ (type: Alias Text) -(def: alias +(def alias (Parser Alias) (<>.after (<code>.this (' "as")) <code>.local)) (type: Field [Bit Text (Maybe Alias) Nullable]) -(def: static! +(def static! (Parser Any) (<code>.this (' "static"))) -(def: field +(def field (Parser Field) (<code>.form (all <>.and (<>.parses? ..static!) @@ -77,7 +77,7 @@ (<>.maybe ..alias) ..nullable))) -(def: constant +(def constant (Parser Field) (<code>.form (all <>.and (<>#in true) @@ -102,7 +102,7 @@ {#Static Static_Method} {#Virtual Virtual_Method})) -(def: common_method +(def common_method (Parser Common_Method) (all <>.and <code>.local @@ -112,10 +112,10 @@ (<>.parses? (<code>.this (' "try"))) ..nullable)) -(def: static_method +(def static_method (<>.after ..static! ..common_method)) -(def: method +(def method (Parser Method) (<code>.form (<>.or ..static_method ..common_method))) @@ -125,26 +125,26 @@ {#Field Field} {#Method Method})) -(def: member +(def member (Parser Member) (all <>.or ..field ..method )) -(def: input_variables +(def input_variables (-> (List Nullable) (List [Bit Code])) (|>> list.enumeration (list#each (function (_ [idx [nullable? type]]) [nullable? (|> idx %.nat code.local)])))) -(def: (nullable_type [nullable? type]) +(def (nullable_type [nullable? type]) (-> Nullable Code) (if nullable? (` (.Maybe (~ type))) type)) -(def: (with_null g!temp [nullable? input]) +(def (with_null g!temp [nullable? input]) (-> Code [Bit Code] Code) (if nullable? (` (case (~ input) @@ -155,7 +155,7 @@ ("php object null"))) input)) -(def: (without_null g!temp [nullable? outputT] output) +(def (without_null g!temp [nullable? outputT] output) (-> Code Nullable Code Code) (if nullable? (` (let [(~ g!temp) (~ output)] @@ -173,7 +173,7 @@ {#Function Static_Method} {#Constant Field})) -(def: import +(def import (Parser Import) (all <>.or (all <>.and @@ -186,7 +186,7 @@ ..constant )) -(def: .public try +(def .public try (syntax (_ [expression <code>.any]) ... {.#doc (example (case (try (risky_computation input)) ... {.#Right success} @@ -196,34 +196,34 @@ ... (recover_from_failure error)))} (in (list (` ("lux try" ((~! io.io) (~ expression)))))))) -(def: (with_io with? without) +(def (with_io with? without) (-> Bit Code Code) (if with? (` ((~! io.io) (~ without))) without)) -(def: (io_type io? rawT) +(def (io_type io? rawT) (-> Bit Code Code) (if io? (` ((~! io.IO) (~ rawT))) rawT)) -(def: (with_try with? without_try) +(def (with_try with? without_try) (-> Bit Code Code) (if with? (` (..try (~ without_try))) without_try)) -(def: (try_type try? rawT) +(def (try_type try? rawT) (-> Bit Code Code) (if try? (` (.Either .Text (~ rawT))) rawT)) -(def: (make_function g!method g!temp source inputsT io? try? outputT) +(def (make_function g!method g!temp source inputsT io? try? outputT) (-> Code Code Code (List Nullable) Bit Bit Nullable Code) (let [g!inputs (input_variables inputsT)] - (` (def: ((~ g!method) + (` (def ((~ g!method) [(~+ (list#each product.right g!inputs))]) (-> [(~+ (list#each nullable_type inputsT))] (~ (|> (nullable_type outputT) @@ -237,7 +237,7 @@ (as ..Function (~ source)) (~+ (list#each (with_null g!temp) g!inputs))))))))))) -(def: .public import +(def .public import (syntax (_ [import ..import]) (with_symbols [g!temp] (case import @@ -258,12 +258,12 @@ {#Field [static? field alias fieldT]} (let [g!field (qualify (maybe.else field alias))] (if static? - (` (def: (~ g!field) + (` (def (~ g!field) ((~! syntax) ((~ g!field) []) (at (~! meta.monad) (~' in) (list (` (.as (~ (nullable_type fieldT)) ("php constant" (~ (code.text (%.format class "::" field))))))))))) - (` (def: ((~ g!field) (~ g!object)) + (` (def ((~ g!field) (~ g!object)) (-> (~ g!type) (~ (nullable_type fieldT))) (as_expected @@ -285,7 +285,7 @@ {#Virtual [method alias inputsT io? try? outputT]} (let [g!inputs (input_variables inputsT)] - (` (def: ((~ (qualify (maybe.else method alias))) + (` (def ((~ (qualify (maybe.else method alias))) [(~+ (list#each product.right g!inputs))] (~ g!object)) (-> [(~+ (list#each nullable_type inputsT))] @@ -316,7 +316,7 @@ {#Constant [_ name alias fieldT]} (let [imported (` ("php constant" (~ (code.text name)))) g!name (code.local (maybe.else name alias))] - (in (list (` (def: (~ g!name) + (in (list (` (def (~ g!name) ((~! syntax) ((~ g!name) []) (at (~! meta.monad) (~' in) (list (` (.as (~ (nullable_type fieldT)) (~ imported))))))))))) diff --git a/stdlib/source/library/lux/ffi.scm.lux b/stdlib/source/library/lux/ffi.scm.lux index 79b59264d..0b4918927 100644 --- a/stdlib/source/library/lux/ffi.scm.lux +++ b/stdlib/source/library/lux/ffi.scm.lux @@ -48,7 +48,7 @@ (type: Nilable [Bit Code]) -(def: nilable +(def nilable (Parser Nilable) (let [token (' "?")] (<| (<>.and (<>.parses? (<code>.this token))) @@ -58,18 +58,18 @@ (type: Alias Text) -(def: alias +(def alias (Parser Alias) (<>.after (<code>.this (' "as")) <code>.local)) (type: Field [Bit Text (Maybe Alias) Nilable]) -(def: static! +(def static! (Parser Any) (<code>.this (' "static"))) -(def: field +(def field (Parser Field) (<code>.form (all <>.and (<>.parses? ..static!) @@ -77,7 +77,7 @@ (<>.maybe ..alias) ..nilable))) -(def: constant +(def constant (Parser Field) (<code>.form (all <>.and (<>#in true) @@ -94,7 +94,7 @@ #try? Bit #output Nilable])) -(def: common_method +(def common_method (Parser Common_Method) (all <>.and <code>.local @@ -104,19 +104,19 @@ (<>.parses? (<code>.this (' "try"))) ..nilable)) -(def: input_variables +(def input_variables (-> (List Nilable) (List [Bit Code])) (|>> list.enumeration (list#each (function (_ [idx [nilable? type]]) [nilable? (|> idx %.nat code.local)])))) -(def: (nilable_type [nilable? type]) +(def (nilable_type [nilable? type]) (-> Nilable Code) (if nilable? (` (.Maybe (~ type))) type)) -(def: (with_nil g!temp [nilable? input]) +(def (with_nil g!temp [nilable? input]) (-> Code [Bit Code] Code) (if nilable? (` (case (~ input) @@ -127,7 +127,7 @@ ("scheme object nil"))) input)) -(def: (without_nil g!temp [nilable? outputT] output) +(def (without_nil g!temp [nilable? outputT] output) (-> Code Nilable Code Code) (if nilable? (` (let [(~ g!temp) (~ output)] @@ -144,14 +144,14 @@ {#Function Common_Method} {#Constant Field})) -(def: import +(def import (Parser Import) (all <>.or (<code>.form ..common_method) ..constant )) -(def: .public try +(def .public try (syntax (_ [expression <code>.any]) ... {.#doc (example (case (try (risky_computation input)) ... {.#Right success} @@ -161,34 +161,34 @@ ... (recover_from_failure error)))} (in (list (` ("lux try" ((~! io.io) (~ expression)))))))) -(def: (with_io with? without) +(def (with_io with? without) (-> Bit Code Code) (if with? (` ((~! io.io) (~ without))) without)) -(def: (io_type io? rawT) +(def (io_type io? rawT) (-> Bit Code Code) (if io? (` ((~! io.IO) (~ rawT))) rawT)) -(def: (with_try with? without_try) +(def (with_try with? without_try) (-> Bit Code Code) (if with? (` (..try (~ without_try))) without_try)) -(def: (try_type try? rawT) +(def (try_type try? rawT) (-> Bit Code Code) (if try? (` (.Either .Text (~ rawT))) rawT)) -(def: (make_function g!method g!temp source inputsT io? try? outputT) +(def (make_function g!method g!temp source inputsT io? try? outputT) (-> Code Code Code (List Nilable) Bit Bit Nilable Code) (let [g!inputs (input_variables inputsT)] - (` (def: ((~ g!method) + (` (def ((~ g!method) [(~+ (list#each product.right g!inputs))]) (-> [(~+ (list#each nilable_type inputsT))] (~ (|> (nilable_type outputT) @@ -202,7 +202,7 @@ (as ..Function (~ source)) (~+ (list#each (with_nil g!temp) g!inputs))))))))))) -(def: .public import +(def .public import (syntax (_ [import ..import]) (with_symbols [g!temp] (case import @@ -219,7 +219,7 @@ {#Constant [_ name alias fieldT]} (let [imported (` ("scheme constant" (~ (code.text name)))) g!name (code.local (maybe.else name alias))] - (in (list (` (def: (~ g!name) + (in (list (` (def (~ g!name) ((~! syntax) ((~ g!name) []) (at (~! meta.monad) (~' in) (list (` (.as (~ (nilable_type fieldT)) (~ imported))))))))))) diff --git a/stdlib/source/library/lux/ffi/export.js.lux b/stdlib/source/library/lux/ffi/export.js.lux index d121509d5..001e58022 100644 --- a/stdlib/source/library/lux/ffi/export.js.lux +++ b/stdlib/source/library/lux/ffi/export.js.lux @@ -36,7 +36,7 @@ [analysis ["[0]" type]]]]]]]]) -(def: definition +(def definition (-> Code (Meta [Text Code])) (|>> (list) (<code>.result (<| <code>.form @@ -85,7 +85,7 @@ (generation.log! (%.format "Export " (%.text name)))))] (in directive.no_requirements))) - (def: .public export + (def .public export (syntax (_ [exports (<>.many <code>.any)]) (let [! meta.monad] (|> exports diff --git a/stdlib/source/library/lux/ffi/export.jvm.lux b/stdlib/source/library/lux/ffi/export.jvm.lux index ed68b06d6..402c8b8da 100644 --- a/stdlib/source/library/lux/ffi/export.jvm.lux +++ b/stdlib/source/library/lux/ffi/export.jvm.lux @@ -18,7 +18,7 @@ #type Code #term Code])) -(def: (api of) +(def (api of) (All (_ of) (-> (Parser of) (Parser (API of)))) (<code>.form (all <>.and @@ -30,7 +30,7 @@ (type: Constant Text) -(def: constant +(def constant (Parser Constant) <code>.local) @@ -40,7 +40,7 @@ #name Text #requirements (List [Text Code])])) -(def: function +(def function (Parser Function) (<code>.form (all <>.and @@ -57,14 +57,14 @@ {#Constant (API Constant)} {#Function (API Function)})) -(def: exportP +(def exportP (Parser Export) (all <>.or (..api ..constant) (..api ..function) )) -(def: .public export +(def .public export (syntax (_ [api <code>.local exports (<>.many ..exportP)]) (let [initialization (is (List (API Constant)) diff --git a/stdlib/source/library/lux/ffi/export.lua.lux b/stdlib/source/library/lux/ffi/export.lua.lux index 679c0e50d..2f4f8345e 100644 --- a/stdlib/source/library/lux/ffi/export.lua.lux +++ b/stdlib/source/library/lux/ffi/export.lua.lux @@ -36,7 +36,7 @@ [analysis ["[0]" type]]]]]]]]) -(def: definition +(def definition (-> Code (Meta [Text Code])) (|>> (list) (<code>.result (<| <code>.form @@ -101,7 +101,7 @@ (generation.log! (%.format "Export " (%.text name)))))] (in directive.no_requirements))) - (def: .public export + (def .public export (syntax (_ [exports (<>.many <code>.any)]) (let [! meta.monad] (|> exports diff --git a/stdlib/source/library/lux/ffi/export.py.lux b/stdlib/source/library/lux/ffi/export.py.lux index 6c0356abb..4ffa40ba8 100644 --- a/stdlib/source/library/lux/ffi/export.py.lux +++ b/stdlib/source/library/lux/ffi/export.py.lux @@ -36,7 +36,7 @@ [analysis ["[0]" type]]]]]]]]) -(def: definition +(def definition (-> Code (Meta [Text Code])) (|>> (list) (<code>.result (<| <code>.form @@ -78,7 +78,7 @@ (generation.log! (%.format "Export " (%.text name)))))] (in directive.no_requirements))) - (def: .public export + (def .public export (syntax (_ [exports (<>.many <code>.any)]) (let [! meta.monad] (|> exports diff --git a/stdlib/source/library/lux/ffi/export.rb.lux b/stdlib/source/library/lux/ffi/export.rb.lux index 16bc77b68..633164c92 100644 --- a/stdlib/source/library/lux/ffi/export.rb.lux +++ b/stdlib/source/library/lux/ffi/export.rb.lux @@ -38,12 +38,12 @@ ["[0]" analysis ["[1]" type]]]]]]]]) -(def: upper! (<text>.one_of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) -(def: lower! (<text>.one_of! "abcdefghijklmnopqrstuvwxyz")) -(def: decimal! (<text>.one_of! "0123456789")) -(def: sigil! (<text>.one_of! "_")) +(def upper! (<text>.one_of! "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) +(def lower! (<text>.one_of! "abcdefghijklmnopqrstuvwxyz")) +(def decimal! (<text>.one_of! "0123456789")) +(def sigil! (<text>.one_of! "_")) -(def: tail! +(def tail! (all <>.either ..upper! ..lower! @@ -52,7 +52,7 @@ )) (with_template [<name> <head>] - [(def: <name> + [(def <name> (Parser Text) (<| <text>.slice (<text>.and! <head>) @@ -68,13 +68,13 @@ {#Method Text} {#Global Text})) -(def: name +(def name (Parser Name) (<>.or ..method (<>.either ..global ..constant))) -(def: definition +(def definition (-> Code (Meta [Name Code])) (|>> (list) (<code>.result (<| <code>.form @@ -127,7 +127,7 @@ (generation.log! (%.format "Export " (%.text name)))))] (in directive.no_requirements))) - (def: .public export + (def .public export (syntax (_ [exports (<>.many <code>.any)]) (let [! meta.monad] (|> exports diff --git a/stdlib/source/library/lux/ffi/node_js.js.lux b/stdlib/source/library/lux/ffi/node_js.js.lux index 27d69787d..fb507fca0 100644 --- a/stdlib/source/library/lux/ffi/node_js.js.lux +++ b/stdlib/source/library/lux/ffi/node_js.js.lux @@ -7,7 +7,7 @@ ["[0]" maybe (.open: "[1]#[0]" monoid functor)]]]]) (with_template [<name> <path>] - [(def: <name> + [(def <name> (Maybe (-> Text Any)) (ffi.global (-> Text Any) <path>))] @@ -16,7 +16,7 @@ [process_load [global process mainModule constructor _load]] ) -(def: .public (require module) +(def .public (require module) (-> Text (Maybe Any)) (maybe#each (function.on module) (all maybe#composite diff --git a/stdlib/source/library/lux/locale.lux b/stdlib/source/library/lux/locale.lux index 9587c8a8f..7b90f5386 100644 --- a/stdlib/source/library/lux/locale.lux +++ b/stdlib/source/library/lux/locale.lux @@ -19,10 +19,10 @@ (primitive .public Locale Text - (def: territory_separator "_") - (def: encoding_separator ".") + (def territory_separator "_") + (def encoding_separator ".") - (def: .public (locale language territory encoding) + (def .public (locale language territory encoding) (-> Language (Maybe Territory) (Maybe Encoding) Locale) (abstraction (format (language.code language) (|> territory @@ -32,15 +32,15 @@ (maybe#each (|>> encoding.name (format ..encoding_separator))) (maybe.else ""))))) - (def: .public code + (def .public code (-> Locale Text) (|>> representation)) - (def: .public hash + (def .public hash (Hash Locale) (at hash.functor each ..code text.hash)) - (def: .public equivalence + (def .public equivalence (Equivalence Locale) (at ..hash equivalence)) ) diff --git a/stdlib/source/library/lux/locale/language.lux b/stdlib/source/library/lux/locale/language.lux index 21930e92f..0e6379d57 100644 --- a/stdlib/source/library/lux/locale/language.lux +++ b/stdlib/source/library/lux/locale/language.lux @@ -18,7 +18,7 @@ #code Text]) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (-> Language Text) (|>> representation (the <tag>)))] @@ -29,12 +29,12 @@ (with_template [<bundle>] [(with_expansions [<bundle>' (template.spliced <bundle>)] (with_template [<code> <name> <definition> <alias>+] - [(def: .public <definition> + [(def .public <definition> Language (abstraction [#name <name> #code <code>])) (`` (with_template [<alias>] - [(def: .public <alias> + [(def .public <alias> Language <definition>)] @@ -556,19 +556,19 @@ ["zun" "Zuni" zuni []] ["zza" "Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki" zaza [[dimili] [dimli] [kirdki] [kirmanjki] [zazaki]]]]]) - (def: .public equivalence + (def .public equivalence (Equivalence Language) (implementation - (def: (= reference sample) + (def (= reference sample) (same? reference sample)))) - (def: .public hash + (def .public hash (Hash Language) (implementation - (def: equivalence + (def equivalence ..equivalence) - (def: hash + (def hash (|>> ..code (at text.hash hash))))) ) diff --git a/stdlib/source/library/lux/locale/territory.lux b/stdlib/source/library/lux/locale/territory.lux index b31531412..9dfed05f9 100644 --- a/stdlib/source/library/lux/locale/territory.lux +++ b/stdlib/source/library/lux/locale/territory.lux @@ -20,7 +20,7 @@ #code Nat]) (with_template [<name> <field> <type>] - [(def: .public <name> + [(def .public <name> (-> Territory <type>) (|>> representation (the <field>)))] @@ -32,7 +32,7 @@ ) (with_template [<short> <long> <number> <name> <main> <neighbor>+] - [(def: .public <main> + [(def .public <main> Territory (abstraction [#name <name> #short <short> @@ -40,7 +40,7 @@ #code <number>])) (`` (with_template [<neighbor>] - [(def: .public <neighbor> Territory <main>)] + [(def .public <neighbor> Territory <main>)] (~~ (template.spliced <neighbor>+))))] @@ -295,18 +295,18 @@ ["ZW" "ZWE" 716 "Zimbabwe" zimbabwe []] ) - (def: .public equivalence + (def .public equivalence (Equivalence Territory) (implementation - (def: (= reference sample) + (def (= reference sample) (same? reference sample)))) - (def: .public hash + (def .public hash (Hash Territory) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: hash + (def hash (|>> representation (the #long) (at text.hash hash))))) diff --git a/stdlib/source/library/lux/macro.lux b/stdlib/source/library/lux/macro.lux index e7dda08c5..35d94cb88 100644 --- a/stdlib/source/library/lux/macro.lux +++ b/stdlib/source/library/lux/macro.lux @@ -18,7 +18,7 @@ ["[0]" location] ["[0]" symbol (.open: "[1]#[0]" codec)]]]]) -(def: .public (single_expansion syntax) +(def .public (single_expansion syntax) (-> Code (Meta (List Code))) (case syntax [_ {.#Form {.#Item [[_ {.#Symbol name}] args]}}] @@ -34,7 +34,7 @@ _ (at //.monad in (list syntax)))) -(def: .public (expansion syntax) +(def .public (expansion syntax) (-> Code (Meta (List Code))) (case syntax [_ {.#Form {.#Item [[_ {.#Symbol name}] args]}}] @@ -54,7 +54,7 @@ _ (at //.monad in (list syntax)))) -(def: .public (full_expansion syntax) +(def .public (full_expansion syntax) (-> Code (Meta (List Code))) (case syntax [_ {.#Form {.#Item [[_ {.#Symbol name}] args]}}] @@ -91,7 +91,7 @@ _ (at //.monad in (list syntax)))) -(def: .public (symbol prefix) +(def .public (symbol prefix) (-> Text (Meta Code)) (do //.monad [id //.seed] @@ -100,7 +100,7 @@ (all text#composite "__gensym__" prefix) [""] code.symbol)))) -(def: (local ast) +(def (local ast) (-> Code (Meta Text)) (case ast [_ {.#Symbol [_ name]}] @@ -109,13 +109,13 @@ _ (//.failure (text#composite "Code is not a local symbol: " (code.format ast))))) -(def: .public wrong_syntax_error +(def .public wrong_syntax_error (-> Symbol Text) (|>> symbol#encoded (text.prefix (text#composite "Wrong syntax for " text.\'')) (text.suffix (text#composite text.\'' ".")))) -(def: .public with_symbols +(def .public with_symbols (.macro (_ tokens) (case tokens (pattern (list [_ {.#Tuple symbols}] body)) @@ -131,7 +131,7 @@ _ (//.failure (..wrong_syntax_error (.symbol ..with_symbols)))))) -(def: .public (one_expansion token) +(def .public (one_expansion token) (-> Code (Meta Code)) (do //.monad [token+ (..expansion token)] @@ -143,7 +143,7 @@ (//.failure "Macro expanded to more than 1 element.")))) (with_template [<macro> <func>] - [(def: .public <macro> + [(def .public <macro> (.macro (_ tokens) (let [[module _] (.symbol .._) [_ short] (.symbol <macro>) @@ -179,7 +179,7 @@ [log_full_expansion! ..full_expansion] ) -(def: .public times +(def .public times (.macro (_ tokens) (case tokens (pattern (list.partial [_ {.#Nat times}] terms)) @@ -199,17 +199,17 @@ _ (//.failure (..wrong_syntax_error (.symbol ..times)))))) -(def: .public final +(def .public final (.macro (_ it) (let [! //.monad] (|> it (monad.each ! ..expansion) (at ! each list#conjoint))))) -(def: .public function +(def .public function (-> Macro Macro') (|>> (as Macro'))) -(def: .public macro +(def .public macro (-> Macro' Macro) (|>> (as Macro))) diff --git a/stdlib/source/library/lux/macro/code.lux b/stdlib/source/library/lux/macro/code.lux index 72b09aff4..53b0d826e 100644 --- a/stdlib/source/library/lux/macro/code.lux +++ b/stdlib/source/library/lux/macro/code.lux @@ -37,7 +37,7 @@ ... (Ann Location (Code' (Ann Location)))) (with_template [<name> <type> <tag>] - [(def: .public (<name> x) + [(def .public (<name> x) (-> <type> Code) [location.dummy {<tag> x}])] @@ -54,16 +54,16 @@ ) (with_template [<name> <tag>] - [(def: .public (<name> name) + [(def .public (<name> name) (-> Text Code) [location.dummy {<tag> ["" name]}])] [local .#Symbol]) -(def: .public equivalence +(def .public equivalence (Equivalence Code) (implementation - (def: (= x y) + (def (= x y) (case [x y] (^.with_template [<tag> <eq>] [[[_ {<tag> x'}] [_ {<tag> y'}]] @@ -86,7 +86,7 @@ _ false)))) -(def: .public (format ast) +(def .public (format ast) (-> Code Text) (case ast (^.with_template [<tag> <struct>] @@ -119,7 +119,7 @@ [.#Tuple "[" "]"]) )) -(def: .public (replaced original substitute ast) +(def .public (replaced original substitute ast) (-> Code Code Code Code) (if (at ..equivalence = original ast) substitute diff --git a/stdlib/source/library/lux/macro/local.lux b/stdlib/source/library/lux/macro/local.lux index 2d93ea1fc..3538cc454 100644 --- a/stdlib/source/library/lux/macro/local.lux +++ b/stdlib/source/library/lux/macro/local.lux @@ -35,7 +35,7 @@ [unknown_definition] ) -(def: (with_module name body) +(def (with_module name body) (All (_ a) (-> Text (-> Module (Try [Module a])) (Meta a))) (function (_ compiler) (case (|> compiler (the .#modules) (plist.value name)) @@ -51,7 +51,7 @@ {.#None} (exception.except ..unknown_module [name])))) -(def: (push_one [name macro]) +(def (push_one [name macro]) (-> [Symbol Macro] (Meta Any)) (do meta.monad [[module_name definition_name] (meta.normal name) @@ -68,7 +68,7 @@ {.#Some _} (exception.except ..cannot_shadow_definition [module_name definition_name])))))) -(def: (pop_one name) +(def (pop_one name) (-> Symbol (Meta Any)) (do meta.monad [[module_name definition_name] (meta.normal name) @@ -84,7 +84,7 @@ {.#None} (exception.except ..unknown_definition [module_name definition_name])))))) -(def: (pop_all macros self) +(def (pop_all macros self) (-> (List Symbol) Symbol Macro) ("lux macro" (function (_ _) @@ -99,7 +99,7 @@ {.#None} (list))))))) -(def: .public (push macros) +(def .public (push macros) (-> (List [Symbol Macro]) (Meta Code)) (do meta.monad [_ (monad.each meta.monad ..push_one macros) @@ -110,7 +110,7 @@ (..push_one [g!pop (..pop_all (list#each product.left macros) g!pop)]))] (in (` ((~ g!pop)))))) -(def: .public (with macros expression? body) +(def .public (with macros expression? body) (-> (List [Symbol Macro]) Bit Code (Meta (List Code))) (do [! meta.monad] [g!pop (..push macros)] @@ -123,7 +123,7 @@ (in (list body g!pop))))) -(def: .public let +(def .public let (syntax (_ [locals (<code>.tuple (<>.some (<>.and <code>.local <code>.any))) body <code>.any]) (do [! meta.monad] diff --git a/stdlib/source/library/lux/macro/pattern.lux b/stdlib/source/library/lux/macro/pattern.lux index 9e8e64d70..7408d86e2 100644 --- a/stdlib/source/library/lux/macro/pattern.lux +++ b/stdlib/source/library/lux/macro/pattern.lux @@ -2,10 +2,10 @@ [library [lux (.except or let with_template |> `)]]) -(def: partial_list +(def partial_list (`` ("lux in-module" (~~ (static .prelude)) .partial_list))) -(def: locally +(def locally (macro (_ tokens lux) (.let [[prelude _] (symbol ._)] (case tokens @@ -17,7 +17,7 @@ {.#Left ""})))) (.with_template [<name>] - [(def: <name> (..locally <name>))] + [(def <name> (..locally <name>))] [list#size] [list#composite] @@ -72,7 +72,7 @@ [frac$] ) -(def: .public or +(def .public or (macro (_ tokens) (case tokens (pattern (partial_list [_ {.#Form patterns}] body branches)) @@ -88,7 +88,7 @@ _ (failure (..wrong_syntax_error (symbol ..or)))))) -(def: .public with_template +(def .public with_template (macro (_ tokens) (case tokens (pattern (partial_list [_ {.#Form (list [_ {.#Tuple bindings}] @@ -118,7 +118,7 @@ _ (failure (..wrong_syntax_error (symbol ..with_template)))))) -(def: .public multi +(def .public multi (macro (_ tokens) (case tokens (pattern (partial_list [_meta {.#Form levels}] body next_branches)) @@ -150,7 +150,7 @@ _ (failure (..wrong_syntax_error (symbol ..multi)))))) -(def: .public let +(def .public let (macro (_ tokens) (case tokens (pattern (partial_list [_meta {.#Form (list [_ {.#Symbol ["" name]}] pattern)}] body branches)) @@ -162,7 +162,7 @@ _ (failure (..wrong_syntax_error (symbol ..let)))))) -(def: .public |> +(def .public |> (macro (_ tokens) (case tokens (pattern (partial_list [_meta {.#Form (list [_ {.#Symbol ["" name]}] [_ {.#Tuple steps}])}] body branches)) @@ -175,11 +175,11 @@ _ (failure (..wrong_syntax_error (symbol ..|>)))))) -(def: (name$ [module name]) +(def (name$ [module name]) (-> Symbol Code) (.` [(~ (text$ module)) (~ (text$ name))])) -(def: (untemplated_partial_list last inits) +(def (untemplated_partial_list last inits) (-> Code (List Code) Code) (case inits {.#End} @@ -189,7 +189,7 @@ (.` {.#Item (~ init) (~ (untemplated_partial_list last inits'))}))) (.with_template [<tag> <name>] - [(def: (<name> g!meta untemplated_pattern elems) + [(def (<name> g!meta untemplated_pattern elems) (-> Code (-> Code (Meta Code)) (-> (List Code) (Meta Code))) (case (list#reversed elems) @@ -209,7 +209,7 @@ [.#Tuple untemplated_tuple] ) -(def: (untemplated_pattern pattern) +(def (untemplated_pattern pattern) (-> Code (Meta Code)) (do meta#monad [g!meta (..generated_symbol "g!meta")] @@ -239,7 +239,7 @@ [.#Tuple ..untemplated_tuple]) ))) -(def: .public ` +(def .public ` (macro (_ tokens) (case tokens (pattern (partial_list [_meta {.#Form (list template)}] body branches)) diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux index 8c1a54eba..94ea416fe 100644 --- a/stdlib/source/library/lux/macro/syntax.lux +++ b/stdlib/source/library/lux/macro/syntax.lux @@ -24,7 +24,7 @@ ["[0]" / ["[1][0]" export]]) -(def: (self_documenting binding parser) +(def (self_documenting binding parser) (All (_ a) (-> Code (Parser a) (Parser a))) (function (_ tokens) (case (parser tokens) @@ -36,13 +36,13 @@ "Failed to parse: " (code.format binding) text.new_line error)}))) -(def: (un_paired pairs) +(def (un_paired pairs) (All (_ a) (-> (List [a a]) (List a))) (case pairs {.#End} {.#End} {.#Item [[x y] pairs']} (list.partial x y (un_paired pairs')))) -(def: syntaxP +(def syntaxP (Parser [[Text (Maybe Text) (List Code)] Code]) (all <>.and (</>.form (all <>.and @@ -51,7 +51,7 @@ (</>.tuple (<>.some </>.any)))) </>.any)) -(def: .public syntax +(def .public syntax (macro (_ tokens) (case (</>.result ..syntaxP tokens) {try.#Success [[name g!state args] body]} diff --git a/stdlib/source/library/lux/macro/syntax/check.lux b/stdlib/source/library/lux/macro/syntax/check.lux index 893f9bc88..774c59e17 100644 --- a/stdlib/source/library/lux/macro/syntax/check.lux +++ b/stdlib/source/library/lux/macro/syntax/check.lux @@ -14,7 +14,7 @@ [macro ["[0]" code]]]]) -(def: extension +(def extension "lux check") (type: .public Check @@ -22,20 +22,20 @@ [#type Code #value Code])) -(def: .public equivalence +(def .public equivalence (Equivalence Check) (all product.equivalence code.equivalence code.equivalence )) -(def: .public (format (open "_[0]")) +(def .public (format (open "_[0]")) (-> Check Code) (` ((~ (code.text ..extension)) (~ _#type) (~ _#value)))) -(def: .public parser +(def .public parser (Parser Check) (<| <code>.form (<>.after (<code>.this_text ..extension)) diff --git a/stdlib/source/library/lux/macro/syntax/declaration.lux b/stdlib/source/library/lux/macro/syntax/declaration.lux index b0c23e135..d5e7ab443 100644 --- a/stdlib/source/library/lux/macro/syntax/declaration.lux +++ b/stdlib/source/library/lux/macro/syntax/declaration.lux @@ -19,21 +19,21 @@ [#name Text #arguments (List Text)])) -(def: .public equivalence +(def .public equivalence (Equivalence Declaration) (all product.equivalence text.equivalence (list.equivalence text.equivalence) )) -(def: .public parser +(def .public parser (Parser Declaration) (<>.either (<>.and <code>.local (<>#in (list))) (<code>.form (<>.and <code>.local (<>.some <code>.local))))) -(def: .public (format value) +(def .public (format value) (-> Declaration Code) (let [g!name (code.local (the #name value))] (case (the #arguments value) diff --git a/stdlib/source/library/lux/macro/syntax/definition.lux b/stdlib/source/library/lux/macro/syntax/definition.lux index 7bc9a964f..02df002bb 100644 --- a/stdlib/source/library/lux/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/macro/syntax/definition.lux @@ -30,7 +30,7 @@ Code) #export? Bit])) -(def: .public equivalence +(def .public equivalence (Equivalence Definition) (all product.equivalence text.equivalence @@ -41,16 +41,16 @@ bit.equivalence )) -(def: extension +(def extension "lux def") -(def: dummy +(def dummy Code (` [.#module (~ (code.text (the .#module location.dummy))) .#line (~ (code.nat (the .#line location.dummy))) .#column (~ (code.nat (the .#column location.dummy)))])) -(def: .public (format (open "_[0]")) +(def .public (format (open "_[0]")) (-> Definition Code) (` ((~ (code.text ..extension)) (~ (code.local _#name)) @@ -62,7 +62,7 @@ value)) (~ (code.bit _#export?))))) -(def: .public (parser compiler) +(def .public (parser compiler) (-> Lux (Parser Definition)) (do [! <>.monad] [raw <code>.any @@ -84,7 +84,7 @@ (exception.report "Definition" (%.code (..format definition)))) -(def: .public (typed compiler) +(def .public (typed compiler) (-> Lux (Parser Definition)) (do <>.monad [definition (..parser compiler) diff --git a/stdlib/source/library/lux/macro/syntax/export.lux b/stdlib/source/library/lux/macro/syntax/export.lux index 323b9d3b5..0aedf4a21 100644 --- a/stdlib/source/library/lux/macro/syntax/export.lux +++ b/stdlib/source/library/lux/macro/syntax/export.lux @@ -9,11 +9,11 @@ [macro ["^" pattern]]]]) -(def: .public default_policy +(def .public default_policy Code (` .private)) -(def: policy +(def policy (Parser Code) (do [! <>.monad] [candidate <code>.next] @@ -30,6 +30,6 @@ _ (in default_policy)))) -(def: .public parser +(def .public parser (All (_ a) (-> (Parser a) (Parser [Code a]))) (<>.and ..policy)) diff --git a/stdlib/source/library/lux/macro/syntax/input.lux b/stdlib/source/library/lux/macro/syntax/input.lux index bdac8cad3..bc6622bc6 100644 --- a/stdlib/source/library/lux/macro/syntax/input.lux +++ b/stdlib/source/library/lux/macro/syntax/input.lux @@ -18,14 +18,14 @@ [#binding Code #type Code])) -(def: .public equivalence +(def .public equivalence (Equivalence Input) (all product.equivalence code.equivalence code.equivalence )) -(def: .public format +(def .public format (-> (List Input) Code) (|>> (list#each (function (_ value) (list (the #binding value) @@ -33,7 +33,7 @@ list#conjoint code.tuple)) -(def: .public parser +(def .public parser (Parser (List Input)) (<| <code>.tuple <>.some diff --git a/stdlib/source/library/lux/macro/syntax/type/variable.lux b/stdlib/source/library/lux/macro/syntax/type/variable.lux index ca141f0bd..fb0f0db06 100644 --- a/stdlib/source/library/lux/macro/syntax/type/variable.lux +++ b/stdlib/source/library/lux/macro/syntax/type/variable.lux @@ -14,14 +14,14 @@ (type: .public Variable Text) -(def: .public equivalence +(def .public equivalence (Equivalence Variable) text.equivalence) -(def: .public format +(def .public format (-> Variable Code) code.local) -(def: .public parser +(def .public parser (Parser Variable) <code>.local) diff --git a/stdlib/source/library/lux/macro/template.lux b/stdlib/source/library/lux/macro/template.lux index 2251051d5..750f4fb8b 100644 --- a/stdlib/source/library/lux/macro/template.lux +++ b/stdlib/source/library/lux/macro/template.lux @@ -28,15 +28,15 @@ ["[0]" code] ["[0]" local]]) -(def: .public spliced +(def .public spliced (syntax (_ [parts (<code>.tuple (<>.some <code>.any))]) (in parts))) -(def: .public amount +(def .public amount (syntax (_ [parts (<code>.tuple (<>.some <code>.any))]) (in (list (code.nat (list.size parts)))))) -(def: .public with_locals +(def .public with_locals (syntax (_ [locals (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -49,7 +49,7 @@ list#conjoint))] (~ body)))))))) -(def: (symbol_side module_side? parser) +(def (symbol_side module_side? parser) (-> Bit (Parser Symbol) (Parser Text)) (do <>.monad [[module short] parser] @@ -59,7 +59,7 @@ _ module) short)))) -(def: (snippet module_side?) +(def (snippet module_side?) (-> Bit (Parser Text)) (.let [full_symbol (..symbol_side module_side? <code>.symbol)] (all <>.either @@ -75,16 +75,16 @@ (<>#each frac#encoded <code>.frac) ))) -(def: (part module_side?) +(def (part module_side?) (-> Bit (Parser (List Text))) (<code>.tuple (<>.many (..snippet module_side?)))) -(def: .public text +(def .public text (syntax (_ [simple (..part false)]) (in (list (|> simple (text.interposed "") code.text))))) (with_template [<name> <simple> <complex>] - [(def: .public <name> + [(def .public <name> (syntax (_ [name (<>.or (<>.and (..part true) (..part false)) (..part false))]) (case name @@ -101,7 +101,7 @@ (type: Environment (Dictionary Text Code)) -(def: (applied env template) +(def (applied env template) (-> Environment Code Code) (case template [_ {.#Symbol "" name}] @@ -134,7 +134,7 @@ "Expected" (at nat.decimal encoded expected) "Actual" (at nat.decimal encoded actual))) -(def: (macro (open "_[0]")) +(def (macro (open "_[0]")) (-> Local Macro) ("lux macro" (function (_ inputs compiler) @@ -147,7 +147,7 @@ {.#Right [compiler (list#each (..applied environment) _#template)]}) (exception.except ..irregular_arguments [parameters_amount inputs_amount])))))) -(def: local +(def local (Parser Local) (do <>.monad [[name parameters] (<code>.form (<>.and <code>.local @@ -158,7 +158,7 @@ #template template]))) ... TODO: Get rid of this (and any local definitions it depends on) once the bootstrapping compiler is gone. -(def: .public let +(def .public let (syntax (_ [locals (<code>.tuple (<>.some ..local)) body <code>.any]) (do meta.monad diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux index 6bd87711b..913a5c1b0 100644 --- a/stdlib/source/library/lux/math.lux +++ b/stdlib/source/library/lux/math.lux @@ -44,7 +44,7 @@ (exception.report "Type" (%.type type))) -(def: (composite phase archive <+> last prevs) +(def (composite phase archive <+> last prevs) (-> Phase Archive Code Analysis (List Analysis) (Operation Analysis)) (case <+> [_ {.#Text $}] @@ -109,7 +109,7 @@ ... else (phase.except ..no_arithmetic_for [:it:]))))))) - (def: .public <name> + (def .public <name> (syntax (_ [operands (<>.some <code>.any)]) (in (list (` (<extension> (~+ operands)))))))))] @@ -162,7 +162,7 @@ ... else (phase.except ..no_arithmetic_for [:it:])))))) - (def: .public <name> + (def .public <name> (syntax (_ [left <code>.any right <code>.any]) (in (list (` (<extension> (~ left) (~ right)))))))))] @@ -218,7 +218,7 @@ ... else (phase.except ..no_arithmetic_for [:it:])))))) - (def: .public <name> + (def .public <name> (syntax (_ [left <code>.any right <code>.any]) (in (list (` (<extension> (~ left) (~ right)))))))))] diff --git a/stdlib/source/library/lux/math/infix.lux b/stdlib/source/library/lux/math/infix.lux index bb3039035..2a6456e4f 100644 --- a/stdlib/source/library/lux/math/infix.lux +++ b/stdlib/source/library/lux/math/infix.lux @@ -26,7 +26,7 @@ {#Unary Code Infix} {#Binary Infix Code Infix}))) -(def: literal +(def literal (Parser Code) (all <>.either (<>#each code.bit <code>.bit) @@ -37,7 +37,7 @@ (<>#each code.text <code>.text) (<>#each code.symbol <code>.symbol))) -(def: expression +(def expression (Parser Infix) (<| <>.rec (function (_ expression)) (all <>.or @@ -55,7 +55,7 @@ steps)))) ))) -(def: (prefix infix) +(def (prefix infix) (-> Infix Code) (case infix {#Const value} @@ -70,6 +70,6 @@ {#Binary left op right} (` ((~ op) (~ (prefix right)) (~ (prefix left)))))) -(def: .public infix +(def .public infix (syntax (_ [expr ..expression]) (in (list (..prefix expr))))) diff --git a/stdlib/source/library/lux/math/logic/continuous.lux b/stdlib/source/library/lux/math/logic/continuous.lux index 195601894..738497496 100644 --- a/stdlib/source/library/lux/math/logic/continuous.lux +++ b/stdlib/source/library/lux/math/logic/continuous.lux @@ -8,34 +8,34 @@ [number ["/" rev (.open: "[1]#[0]" interval)]]]]]) -(def: .public false Rev /#bottom) -(def: .public true Rev /#top) +(def .public false Rev /#bottom) +(def .public true Rev /#top) (with_template [<name> <chooser> <monoid> <identity>] - [(def: .public <name> + [(def .public <name> (-> Rev Rev Rev) <chooser>) - (def: .public <monoid> + (def .public <monoid> (Monoid Rev) (implementation - (def: identity <identity>) - (def: composite <name>)))] + (def identity <identity>) + (def composite <name>)))] [or /.max disjunction ..false] [and /.min conjunction ..true] ) -(def: .public (not input) +(def .public (not input) (-> Rev Rev) (/.- input ..true)) -(def: .public (implies consequent antecedent) +(def .public (implies consequent antecedent) (-> Rev Rev Rev) (or (not antecedent) consequent)) -(def: .public (= left right) +(def .public (= left right) (-> Rev Rev Rev) (and (or (not left) right) (or left (not right)))) diff --git a/stdlib/source/library/lux/math/logic/fuzzy.lux b/stdlib/source/library/lux/math/logic/fuzzy.lux index d21962ea6..6d337604e 100644 --- a/stdlib/source/library/lux/math/logic/fuzzy.lux +++ b/stdlib/source/library/lux/math/logic/fuzzy.lux @@ -19,14 +19,14 @@ (type: .public (Fuzzy a) (-> a Rev)) -(def: .public functor +(def .public functor (contravariant.Functor Fuzzy) (implementation - (def: (each f fb) + (def (each f fb) (|>> f fb)))) (with_template [<name> <verdict>] - [(def: .public <name> + [(def .public <name> Fuzzy (function (_ _) <verdict>))] @@ -35,12 +35,12 @@ [full //.true] ) -(def: .public (membership set elem) +(def .public (membership set elem) (All (_ a) (-> (Fuzzy a) a Rev)) (set elem)) (with_template [<set_composition> <membership_composition>] - [(def: .public (<set_composition> left right) + [(def .public (<set_composition> left right) (All (_ a) (-> (Fuzzy a) (Fuzzy a) (Fuzzy a))) (function (_ elem) (<membership_composition> (left elem) @@ -50,31 +50,31 @@ [intersection //.and] ) -(def: .public (complement set) +(def .public (complement set) (All (_ a) (-> (Fuzzy a) (Fuzzy a))) (|>> set //.not)) -(def: .public (difference sub base) +(def .public (difference sub base) (All (_ a) (-> (Fuzzy a) (Fuzzy a) (Fuzzy a))) (..intersection (..complement sub) base)) -(def: .public (of_predicate predicate) +(def .public (of_predicate predicate) (All (_ a) (-> (Predicate a) (Fuzzy a))) (function (_ elem) (if (predicate elem) //.true //.false))) -(def: .public (predicate treshold set) +(def .public (predicate treshold set) (All (_ a) (-> Rev (Fuzzy a) (Predicate a))) (function (_ elem) (/.> treshold (set elem)))) -(def: .public of_set +(def .public of_set (All (_ a) (-> (Set a) (Fuzzy a))) (|>> set.member? ..of_predicate)) -(def: (ascending from to) +(def (ascending from to) (-> Rev Rev (Fuzzy Rev)) (let [measure (/.- from to)] (function (_ elem) @@ -91,23 +91,23 @@ ... above //.true)))) -(def: (descending from to) +(def (descending from to) (-> Rev Rev (Fuzzy Rev)) (..complement (..ascending from to))) -(def: .public (gradient from to) +(def .public (gradient from to) (-> Rev Rev (Fuzzy Rev)) (if (/.< to from) (..ascending from to) (..descending from to))) -(def: !sort_2 +(def !sort_2 (template (_ <low> <high>) [(if (/.> <low> <high>) [<low> <high>] [<high> <low>])])) -(def: .public (triangle bottom middle top) +(def .public (triangle bottom middle top) (-> Rev Rev Rev (Fuzzy Rev)) (let [[low_0 high_0] (!sort_2 bottom middle) [bottom' high_1] (!sort_2 low_0 top) @@ -115,7 +115,7 @@ (..intersection (..ascending bottom' middle') (..descending middle' top')))) -(def: .public (trapezoid bottom middle_bottom middle_top top) +(def .public (trapezoid bottom middle_bottom middle_top top) (-> Rev Rev Rev Rev (Fuzzy Rev)) (let [[low_0 high_0] (!sort_2 bottom middle_bottom) [low_1 high_1] (!sort_2 middle_top top) @@ -125,7 +125,7 @@ (..intersection (..ascending bottom' middle_bottom') (..descending middle_top' top')))) -(def: .public (cut treshold set) +(def .public (cut treshold set) (All (_ a) (-> Rev (Fuzzy a) (Fuzzy a))) (function (_ elem) (let [membership (set elem)] diff --git a/stdlib/source/library/lux/math/modular.lux b/stdlib/source/library/lux/math/modular.lux index c12f2111d..183679ce8 100644 --- a/stdlib/source/library/lux/math/modular.lux +++ b/stdlib/source/library/lux/math/modular.lux @@ -31,13 +31,13 @@ [#modulus (Modulus m) #value Int]) - (def: .public (modular modulus value) + (def .public (modular modulus value) (All (_ %) (-> (Modulus %) Int (Mod %))) (abstraction [#modulus modulus #value (i.mod (//.divisor modulus) value)])) (with_template [<name> <type> <side>] - [(def: .public <name> + [(def .public <name> (All (_ %) (-> (Mod %) <type>)) (|>> representation <side>))] @@ -51,25 +51,25 @@ "Expected" (i#encoded (//.divisor modulus)) "Actual" (i#encoded parsed))) - (def: separator + (def separator " mod ") - (def: intL + (def intL (Parser Int) (<>.codec i.decimal (<text>.and (<text>.one_of "-+") (<text>.many <text>.decimal)))) - (def: .public (codec expected) + (def .public (codec expected) (All (_ %) (-> (Modulus %) (Codec Text (Mod %)))) (implementation - (def: (encoded modular) + (def (encoded modular) (let [[_ value] (representation modular)] (all text#composite (i#encoded value) ..separator (i#encoded (//.divisor expected))))) - (def: decoded + (def decoded (<text>.result (do <>.monad [[value _ actual] (all <>.and intL (<text>.this ..separator) intL) @@ -78,7 +78,7 @@ (in (..modular expected value))))))) (with_template [<name> <op>] - [(def: .public (<name> reference subject) + [(def .public (<name> reference subject) (All (_ %) (-> (Mod %) (Mod %) Bit)) (let [[_ reference] (representation reference) [_ subject] (representation subject)] @@ -91,19 +91,19 @@ [>= i.>=] ) - (def: .public equivalence + (def .public equivalence (All (_ %) (Equivalence (Mod %))) (implementation - (def: = ..=))) + (def = ..=))) - (def: .public order + (def .public order (All (_ %) (Order (Mod %))) (implementation - (def: equivalence ..equivalence) - (def: < ..<))) + (def equivalence ..equivalence) + (def < ..<))) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (All (_ %) (-> (Mod %) (Mod %) (Mod %))) (let [[modulus param] (representation param) [_ subject] (representation subject)] @@ -118,19 +118,19 @@ ) (with_template [<composition> <identity> <monoid>] - [(def: .public (<monoid> modulus) + [(def .public (<monoid> modulus) (All (_ %) (-> (Modulus %) (Monoid (Mod %)))) (implementation - (def: identity + (def identity (..modular modulus <identity>)) - (def: composite + (def composite <composition>)))] [..+ +0 addition] [..* +1 multiplication] ) - (def: .public (inverse modular) + (def .public (inverse modular) (All (_ %) (-> (Mod %) (Maybe (Mod %)))) (let [[modulus value] (representation modular) [[vk mk] gcd] (i.extended_gcd value (//.divisor modulus))] @@ -145,7 +145,7 @@ "Reference" (i#encoded (//.divisor reference)) "Subject" (i#encoded (//.divisor subject)))) -(def: .public (adapter reference subject) +(def .public (adapter reference subject) (All (_ r% s%) (-> (Modulus r%) (Modulus s%) (Try (-> (Mod s%) (Mod r%))))) diff --git a/stdlib/source/library/lux/math/modulus.lux b/stdlib/source/library/lux/math/modulus.lux index 7071c834a..3f976476a 100644 --- a/stdlib/source/library/lux/math/modulus.lux +++ b/stdlib/source/library/lux/math/modulus.lux @@ -23,22 +23,22 @@ (primitive .public (Modulus %) Int - (def: .public (modulus value) + (def .public (modulus value) (Ex (_ %) (-> Int (Try (Modulus %)))) (if (i.= +0 value) (exception.except ..zero_cannot_be_a_modulus []) {try.#Success (abstraction value)})) - (def: .public divisor + (def .public divisor (All (_ %) (-> (Modulus %) Int)) (|>> representation)) - (def: .public (= reference subject) + (def .public (= reference subject) (All (_ %r %s) (-> (Modulus %r) (Modulus %s) Bit)) (i.= (representation reference) (representation subject))) - (def: .public (congruent? modulus reference subject) + (def .public (congruent? modulus reference subject) (All (_ %) (-> (Modulus %) Int Int Bit)) (|> subject (i.- reference) @@ -46,7 +46,7 @@ (i.= +0))) ) -(def: .public literal +(def .public literal (syntax (_ [divisor <code>.int]) (meta.lifted (do try.monad diff --git a/stdlib/source/library/lux/math/number.lux b/stdlib/source/library/lux/math/number.lux index 59310fc99..4e1beb005 100644 --- a/stdlib/source/library/lux/math/number.lux +++ b/stdlib/source/library/lux/math/number.lux @@ -15,10 +15,10 @@ ["[1][0]" rev] ["[1][0]" frac]]) -(def: separator +(def separator ",") -(def: (separator_prefixed? number) +(def (separator_prefixed? number) (-> Text Bit) (case ("lux text index" 0 ..separator number) {.#Some 0} @@ -27,12 +27,12 @@ _ #0)) -(def: without_separators +(def without_separators (-> Text Text) (text.replaced ..separator "")) (with_template [<macro> <nat> <int> <rev> <frac> <error>] - [(def: .public <macro> + [(def .public <macro> (macro (_ tokens state) (case tokens {.#Item [meta {.#Text repr'}] {.#End}} diff --git a/stdlib/source/library/lux/math/number/complex.lux b/stdlib/source/library/lux/math/number/complex.lux index 8708b9c7f..58a8cd4be 100644 --- a/stdlib/source/library/lux/math/number/complex.lux +++ b/stdlib/source/library/lux/math/number/complex.lux @@ -22,34 +22,34 @@ [#real Frac #imaginary Frac])) -(def: .public complex +(def .public complex (syntax (_ [real <code>.any ?imaginary (<>.maybe <code>.any)]) (in (list (` [..#real (~ real) ..#imaginary (~ (maybe.else (' +0.0) ?imaginary))]))))) -(def: .public i +(def .public i Complex (..complex +0.0 +1.0)) -(def: .public +one +(def .public +one Complex (..complex +1.0 +0.0)) -(def: .public -one +(def .public -one Complex (..complex -1.0 +0.0)) -(def: .public zero +(def .public zero Complex (..complex +0.0 +0.0)) -(def: .public (not_a_number? complex) +(def .public (not_a_number? complex) (-> Complex Bit) (or (f.not_a_number? (the #real complex)) (f.not_a_number? (the #imaginary complex)))) -(def: .public (= param input) +(def .public (= param input) (-> Complex Complex Bit) (and (f.= (the #real param) (the #real input)) @@ -57,7 +57,7 @@ (the #imaginary input)))) (with_template [<name> <op>] - [(def: .public (<name> param input) + [(def .public (<name> param input) (-> Complex Complex Complex) [#real (<op> (the #real param) (the #real input)) @@ -68,13 +68,13 @@ [- f.-] ) -(def: .public equivalence +(def .public equivalence (Equivalence Complex) (implementation - (def: = ..=))) + (def = ..=))) (with_template [<name> <transform>] - [(def: .public <name> + [(def .public <name> (-> Complex Complex) (|>> (revised #real <transform>) (revised #imaginary <transform>)))] @@ -83,18 +83,18 @@ [signum f.signum] ) -(def: .public conjugate +(def .public conjugate (-> Complex Complex) (revised #imaginary f.opposite)) -(def: .public (*' param input) +(def .public (*' param input) (-> Frac Complex Complex) [#real (f.* param (the #real input)) #imaginary (f.* param (the #imaginary input))]) -(def: .public (* param input) +(def .public (* param input) (-> Complex Complex Complex) [#real (f.- (f.* (the #imaginary param) (the #imaginary input)) @@ -105,7 +105,7 @@ (f.* (the #imaginary param) (the #real input)))]) -(def: .public (/ param input) +(def .public (/ param input) (-> Complex Complex Complex) (let [(open "[0]") param] (if (f.< (f.abs #imaginary) @@ -119,13 +119,13 @@ [..#real (|> (the ..#imaginary input) (f.* quot) (f.+ (the ..#real input)) (f./ denom)) ..#imaginary (|> (the ..#imaginary input) (f.- (f.* quot (the ..#real input))) (f./ denom))])))) -(def: .public (/' param subject) +(def .public (/' param subject) (-> Frac Complex Complex) (let [(open "[0]") subject] [..#real (f./ param #real) ..#imaginary (f./ param #imaginary)])) -(def: .public (% param input) +(def .public (% param input) (-> Complex Complex Complex) (let [scaled (/ param input) quotient (|> scaled @@ -134,7 +134,7 @@ (- (* quotient param) input))) -(def: .public (cos subject) +(def .public (cos subject) (-> Complex Complex) (let [(open "[0]") subject] [..#real (f.* (f.cosh #imaginary) @@ -142,7 +142,7 @@ ..#imaginary (f.opposite (f.* (f.sinh #imaginary) (f.sin #real)))])) -(def: .public (cosh subject) +(def .public (cosh subject) (-> Complex Complex) (let [(open "[0]") subject] [..#real (f.* (f.cos #imaginary) @@ -150,7 +150,7 @@ ..#imaginary (f.* (f.sin #imaginary) (f.sinh #real))])) -(def: .public (sin subject) +(def .public (sin subject) (-> Complex Complex) (let [(open "[0]") subject] [..#real (f.* (f.cosh #imaginary) @@ -158,7 +158,7 @@ ..#imaginary (f.* (f.sinh #imaginary) (f.cos #real))])) -(def: .public (sinh subject) +(def .public (sinh subject) (-> Complex Complex) (let [(open "[0]") subject] [..#real (f.* (f.cos #imaginary) @@ -166,7 +166,7 @@ ..#imaginary (f.* (f.sin #imaginary) (f.cosh #real))])) -(def: .public (tan subject) +(def .public (tan subject) (-> Complex Complex) (let [(open "[0]") subject r2 (f.* +2.0 #real) @@ -175,7 +175,7 @@ [..#real (f./ d (f.sin r2)) ..#imaginary (f./ d (f.sinh i2))])) -(def: .public (tanh subject) +(def .public (tanh subject) (-> Complex Complex) (let [(open "[0]") subject r2 (f.* +2.0 #real) @@ -184,7 +184,7 @@ [..#real (f./ d (f.sinh r2)) ..#imaginary (f./ d (f.sin i2))])) -(def: .public (abs subject) +(def .public (abs subject) (-> Complex Frac) (let [(open "[0]") subject] (if (f.< (f.abs #imaginary) @@ -200,21 +200,21 @@ (f.* (f.pow +0.5 (f.+ +1.0 (f.* q q))) (f.abs #real))))))) -(def: .public (exp subject) +(def .public (exp subject) (-> Complex Complex) (let [(open "[0]") subject r_exp (f.exp #real)] [..#real (f.* r_exp (f.cos #imaginary)) ..#imaginary (f.* r_exp (f.sin #imaginary))])) -(def: .public (log subject) +(def .public (log subject) (-> Complex Complex) (let [(open "[0]") subject] [..#real (|> subject ..abs f.log) ..#imaginary (f.atan_2 #real #imaginary)])) (with_template [<name> <type> <op>] - [(def: .public (<name> param input) + [(def .public (<name> param input) (-> <type> Complex Complex) (|> input log (<op> param) exp))] @@ -222,11 +222,11 @@ [pow' Frac ..*'] ) -(def: (with_sign sign magnitude) +(def (with_sign sign magnitude) (-> Frac Frac Frac) (f.* (f.signum sign) magnitude)) -(def: .public (root_2 input) +(def .public (root_2 input) (-> Complex Complex) (let [(open "[0]") input t (|> input ..abs (f.+ (f.abs #real)) (f./ +2.0) (f.pow +0.5))] @@ -238,11 +238,11 @@ ..#imaginary (f./ (f.* +2.0 t) #imaginary)]))) -(def: (root_2-1z input) +(def (root_2-1z input) (-> Complex Complex) (|> (complex +1.0) (- (* input input)) ..root_2)) -(def: .public (reciprocal (open "[0]")) +(def .public (reciprocal (open "[0]")) (-> Complex Complex) (if (f.< (f.abs #imaginary) (f.abs #real)) @@ -257,14 +257,14 @@ [..#real scale ..#imaginary (|> scale f.opposite (f.* q))]))) -(def: .public (acos input) +(def .public (acos input) (-> Complex Complex) (|> input (..+ (|> input ..root_2-1z (..* ..i))) ..log (..* (..opposite ..i)))) -(def: .public (asin input) +(def .public (asin input) (-> Complex Complex) (|> input ..root_2-1z @@ -272,7 +272,7 @@ ..log (..* (..opposite ..i)))) -(def: .public (atan input) +(def .public (atan input) (-> Complex Complex) (|> input (..+ ..i) @@ -280,11 +280,11 @@ ..log (..* (../ (..complex +2.0) ..i)))) -(def: .public (argument (open "[0]")) +(def .public (argument (open "[0]")) (-> Complex Frac) (f.atan_2 #real #imaginary)) -(def: .public (roots nth input) +(def .public (roots nth input) (-> Nat Complex (List Complex)) (case nth 0 (list) @@ -304,7 +304,7 @@ [..#real real ..#imaginary imaginary]))))))) -(def: .public (approximately? margin_of_error standard value) +(def .public (approximately? margin_of_error standard value) (-> Frac Complex Complex Bit) (and (f.approximately? margin_of_error (the ..#real standard) diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index ea62f7c92..c3203335a 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -24,7 +24,7 @@ ["[1][0]" rev]]) (with_template [<name> <value>] - [(def: .public <name> + [(def .public <name> <value>)] [e +2.7182818284590452354] @@ -36,7 +36,7 @@ (for @.old (these (with_template [<name> <method>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (<method> it))] @@ -57,18 +57,18 @@ [root_2 "jvm invokestatic:java.lang.Math:sqrt:double"] [root_3 "jvm invokestatic:java.lang.Math:cbrt:double"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) ("jvm invokestatic:java.lang.Math:pow:double,double" subject param))) @.jvm - (these (def: !double + (these (def !double (template (_ value) [(|> value (as (Primitive "java.lang.Double")) "jvm object cast")])) - (def: !frac + (def !frac (template (_ value) [(|> value "jvm object cast" @@ -76,7 +76,7 @@ (as Frac))])) (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> !double ["D"] @@ -101,7 +101,7 @@ [root_3 "cbrt"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) (|> ("jvm member invoke static" [] "java.lang.Math" "pow" [] ["D" (!double subject)] ["D" (!double param)]) @@ -109,7 +109,7 @@ @.js (these (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> [] ("js apply" ("js constant" <method>)) @@ -133,13 +133,13 @@ [root_3 "Math.cbrt"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) (as Frac ("js apply" ("js constant" "Math.pow") [subject param])))) @.python (these (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> [] ("python object do" <method> ("python import" "math")) @@ -162,11 +162,11 @@ [root_2 "sqrt"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) (as Frac ("python object do" "pow" ("python import" "math") [subject param]))) - (def: .public (root_3 it) + (def .public (root_3 it) (-> Frac Frac) (if ("lux f64 <" +0.0 it) (|> it @@ -178,7 +178,7 @@ @.lua (these (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> [] ("lua apply" ("lua constant" <method>)) @@ -201,11 +201,11 @@ [root_2 "math.sqrt"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) ("lua power" param subject)) - (def: .public (root_3 it) + (def .public (root_3 it) (-> Frac Frac) (if ("lux f64 <" +0.0 it) (|> it @@ -217,7 +217,7 @@ @.ruby (these (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> [] ("ruby apply" ("ruby constant" <method>)) @@ -239,7 +239,7 @@ ) (with_template [<name> <method>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (|> ("ruby object do" <method> it []) (as Int) @@ -249,13 +249,13 @@ [floor "floor"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) (as Frac ("ruby object do" "**" subject [param])))) @.php (these (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> ("php apply" ("php constant" <method>)) (as Frac)))] @@ -277,17 +277,17 @@ [root_2 "sqrt"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) (as Frac ("php apply" ("php constant" "pow") subject param))) - (def: .public root_3 + (def .public root_3 (-> Frac Frac) (..pow ("lux f64 /" +3.0 +1.0)))) @.scheme (these (with_template [<name> <method>] - [(def: .public <name> + [(def .public <name> (-> Frac Frac) (|>> ("scheme apply" ("scheme constant" <method>)) (as Frac)))] @@ -309,16 +309,16 @@ [root_2 "sqrt"] ) - (def: .public (pow param subject) + (def .public (pow param subject) (-> Frac Frac Frac) (as Frac ("scheme apply" ("scheme constant" "expt") subject param))) - (def: .public root_3 + (def .public root_3 (-> Frac Frac) (..pow ("lux f64 /" +3.0 +1.0)))) ) -(def: .public (round it) +(def .public (round it) (-> Frac Frac) (let [floored (floor it) diff ("lux f64 -" floored it)] @@ -331,7 +331,7 @@ ... else floored))) -(def: .public (atan_2 x y) +(def .public (atan_2 x y) (-> Frac Frac Frac) (cond ("lux f64 <" x +0.0) (..atan ("lux f64 /" x y)) @@ -352,13 +352,13 @@ ... ("lux f64 =" +0.0 y) ("lux f64 /" +0.0 +0.0)))) -(def: .public (log_by base it) +(def .public (log_by base it) (-> Frac Frac Frac) ("lux f64 /" (..log base) (..log it))) -(def: .public (factorial it) +(def .public (factorial it) (-> Nat Nat) (loop (again [acc 1 it it]) @@ -366,7 +366,7 @@ (again (//nat.* it acc) (-- it)) acc))) -(def: .public (hypotenuse catA catB) +(def .public (hypotenuse catA catB) (-> Frac Frac Frac) (..pow +0.5 ("lux f64 +" (..pow +2.0 catA) @@ -375,11 +375,11 @@ ... Hyperbolic functions ... https://en.wikipedia.org/wiki/Hyperbolic_function#Definitions (with_template [<name> <comp> <inverse>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (|> (..exp it) (<comp> (..exp ("lux f64 *" -1.0 it))) ("lux f64 /" +2.0))) - (def: .public (<inverse> it) + (def .public (<inverse> it) (-> Frac Frac) (|> +2.0 ("lux f64 /" (|> (..exp it) (<comp> (..exp ("lux f64 *" -1.0 it)))))))] @@ -388,7 +388,7 @@ ) (with_template [<name> <top> <bottom>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (let [e+ (exp it) e- (exp ("lux f64 *" -1.0 it)) @@ -402,7 +402,7 @@ ... https://en.wikipedia.org/wiki/Inverse_hyperbolic_functions#Definitions_in_terms_of_logarithms (with_template [<name> <comp>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (|> it (pow +2.0) (<comp> +1.0) (pow +0.5) ("lux f64 +" it) log))] @@ -411,7 +411,7 @@ ) (with_template [<name> <base> <diff>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (let [it+ (|> <base> ("lux f64 +" <diff>)) it- (|> <base> ("lux f64 -" <diff>))] @@ -422,7 +422,7 @@ ) (with_template [<name> <op>] - [(def: .public (<name> it) + [(def .public (<name> it) (-> Frac Frac) (let [it^2 (|> it (pow +2.0))] (|> +1.0 (<op> it^2) (pow +0.5) ("lux f64 +" +1.0) ("lux f64 /" it) log)))] @@ -432,7 +432,7 @@ ) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Frac Frac Bit) (<op> param subject))] @@ -440,22 +440,22 @@ [< "lux f64 <"] ) -(def: .public (<= reference sample) +(def .public (<= reference sample) (-> Frac Frac Bit) (or ("lux f64 <" reference sample) ("lux f64 =" reference sample))) -(def: .public (> reference sample) +(def .public (> reference sample) (-> Frac Frac Bit) ("lux f64 <" sample reference)) -(def: .public (>= reference sample) +(def .public (>= reference sample) (-> Frac Frac Bit) (or ("lux f64 <" sample reference) ("lux f64 =" sample reference))) (with_template [<comparison> <name>] - [(def: .public <name> + [(def .public <name> (Predicate Frac) (<comparison> +0.0))] @@ -465,7 +465,7 @@ ) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Frac Frac Frac) (<op> param subject))] @@ -476,33 +476,33 @@ [% "lux f64 %"] ) -(def: .public (/% param subject) +(def .public (/% param subject) (-> Frac Frac [Frac Frac]) [(../ param subject) (..% param subject)]) -(def: .public opposite +(def .public opposite (-> Frac Frac) (..* -1.0)) -(def: .public (abs it) +(def .public (abs it) (-> Frac Frac) (if (..< +0.0 it) (..* -1.0 it) it)) -(def: .public (signum it) +(def .public (signum it) (-> Frac Frac) (cond (..= +0.0 it) +0.0 (..< +0.0 it) -1.0 ... else +1.0)) -(def: min_exponent -1022) -(def: max_exponent (//int.frac +1023)) +(def min_exponent -1022) +(def max_exponent (//int.frac +1023)) (with_template [<name> <test>] - [(def: .public (<name> left right) + [(def .public (<name> left right) (-> Frac Frac Frac) (if (<test> right left) left @@ -512,23 +512,23 @@ [max ..>] ) -(def: .public nat +(def .public nat (-> Frac Nat) (|>> "lux f64 i64" .nat)) -(def: .public int +(def .public int (-> Frac Int) (|>> "lux f64 i64")) -(def: mantissa_size Nat 52) -(def: exponent_size Nat 11) +(def mantissa_size Nat 52) +(def exponent_size Nat 11) -(def: frac_denominator +(def frac_denominator (|> -1 ("lux i64 right-shift" ..exponent_size) "lux i64 f64")) -(def: .public rev +(def .public rev (-> Frac Rev) (|>> ..abs (..% +1.0) @@ -537,7 +537,7 @@ ("lux i64 left-shift" ..exponent_size))) (with_template [<name> <numerator>] - [(def: .public <name> + [(def .public <name> Frac (../ +0.0 <numerator>))] @@ -545,40 +545,40 @@ [positive_infinity +1.0] ) -(def: .public negative_infinity +(def .public negative_infinity Frac (..* -1.0 ..positive_infinity)) -(def: .public (not_a_number? it) +(def .public (not_a_number? it) (-> Frac Bit) (not (..= it it))) -(def: .public (number? it) +(def .public (number? it) (-> Frac Bit) (not (or (..not_a_number? it) (..= ..positive_infinity it) (..= ..negative_infinity it)))) -(def: .public equivalence +(def .public equivalence (Equivalence Frac) (implementation - (def: (= left right) + (def (= left right) (or (..= left right) (and (..not_a_number? left) (..not_a_number? right)))))) -(def: .public order +(def .public order (Order Frac) (implementation - (def: equivalence ..equivalence) - (def: < ..<))) + (def equivalence ..equivalence) + (def < ..<))) -(def: .public smallest +(def .public smallest Frac (..pow (//int.frac (//int.- (.int ..mantissa_size) ..min_exponent)) +2.0)) -(def: .public biggest +(def .public biggest Frac (let [f2^-52 (..pow (//nat.frac (//nat.- ..mantissa_size 0)) +2.0) f2^+1023 (..pow ..max_exponent +2.0)] @@ -587,11 +587,11 @@ (..* f2^+1023)))) (with_template [<name> <composite> <identity>] - [(def: .public <name> + [(def .public <name> (Monoid Frac) (implementation - (def: identity <identity>) - (def: composite <composite>)))] + (def identity <identity>) + (def composite <composite>)))] [addition ..+ +0.0] [multiplication ..* +1.0] @@ -599,10 +599,10 @@ [maximum ..max (..* -1.0 ..biggest)] ) -(def: .public decimal +(def .public decimal (Codec Text Frac) (implementation - (def: (encoded x) + (def (encoded x) (case x -0.0 (let [output ("lux f64 encode" x)] (if (text.starts_with? "-" output) @@ -612,7 +612,7 @@ ("lux f64 encode" x) ("lux text concat" "+" ("lux f64 encode" x))))) - (def: (decoded input) + (def (decoded input) (case ("lux f64 decode" input) {.#Some value} {try.#Success value} @@ -620,20 +620,20 @@ {.#None} {try.#Failure "Could not decode Frac"})))) -(def: log/2 +(def log/2 (-> Frac Frac) (|>> ..log (../ (..log +2.0)))) -(def: double_bias Nat 1023) +(def double_bias Nat 1023) -(def: exponent_mask (//i64.mask ..exponent_size)) +(def exponent_mask (//i64.mask ..exponent_size)) -(def: exponent_offset ..mantissa_size) -(def: sign_offset (//nat.+ ..exponent_size ..exponent_offset)) +(def exponent_offset ..mantissa_size) +(def sign_offset (//nat.+ ..exponent_size ..exponent_offset)) (with_template [<cast> <hex> <name>] - [(def: <name> + [(def <name> (|> <hex> (at //nat.hex decoded) try.trusted @@ -647,10 +647,10 @@ [.nat "7FF" special_exponent_bits] ) -(def: smallest_exponent +(def smallest_exponent (..log/2 ..smallest)) -(def: .public (bits it) +(def .public (bits it) (-> Frac I64) (.i64 (cond (..not_a_number? it) ..not_a_number_bits @@ -703,7 +703,7 @@ ))) (with_template [<getter> <size> <offset>] - [(def: <getter> + [(def <getter> (-> (I64 Any) I64) (let [mask (|> 1 (//i64.left_shifted <size>) -- (//i64.left_shifted <offset>))] (|>> (//i64.and mask) (//i64.right_shifted <offset>) .i64)))] @@ -713,7 +713,7 @@ [sign 1 ..sign_offset] ) -(def: .public (of_bits it) +(def .public (of_bits it) (-> I64 Frac) (case [(is Nat (..exponent it)) (is Nat (..mantissa it)) @@ -752,7 +752,7 @@ (..* exponent) (..* sign))))) -(def: (representation_exponent codec representation) +(def (representation_exponent codec representation) (-> (Codec Text Nat) Text (Try [Text Int])) (case [("lux text index" 0 "e+" representation) ("lux text index" 0 "E+" representation) @@ -777,10 +777,10 @@ {try.#Success [representation +0]})) (with_template [<struct> <nat> <int> <error>] - [(def: .public <struct> + [(def .public <struct> (Codec Text Frac) (implementation - (def: (encoded value) + (def (encoded value) (let [bits (..bits value) mantissa (..mantissa bits) exponent (//int.- (.int ..double_bias) (..exponent bits)) @@ -794,7 +794,7 @@ ".0E" (at <int> encoded exponent)))) - (def: (decoded representation) + (def (decoded representation) (let [negative? (text.starts_with? "-" representation) positive? (text.starts_with? "+" representation)] (if (or negative? positive?) @@ -830,20 +830,20 @@ [hex //nat.hex //int.hex "Invalid hexadecimal syntax: "] ) -(def: .public hash +(def .public hash (Hash Frac) (implementation - (def: equivalence ..equivalence) - (def: hash ..bits))) + (def equivalence ..equivalence) + (def hash ..bits))) -(def: .public (approximately? margin_of_error standard value) +(def .public (approximately? margin_of_error standard value) (-> Frac Frac Frac Bit) (|> value (..- standard) ..abs (..< margin_of_error))) -(def: .public (mod divisor dividend) +(def .public (mod divisor dividend) (All (_ m) (-> Frac Frac Frac)) (let [remainder (..% divisor dividend)] (if (or (and (..< +0.0 divisor) diff --git a/stdlib/source/library/lux/math/number/i16.lux b/stdlib/source/library/lux/math/number/i16.lux index 76488032d..7f1cfda9b 100644 --- a/stdlib/source/library/lux/math/number/i16.lux +++ b/stdlib/source/library/lux/math/number/i16.lux @@ -9,10 +9,10 @@ [// ["[0]" i64 (.only Sub)]]) -(def: sub +(def sub (maybe.trusted (i64.sub 16))) -(def: .public I16 +(def .public I16 Type ... TODO: Switch to the cleaner approach ASAP. (case (type_of ..sub) @@ -27,7 +27,7 @@ ... (I64 size)) ) -(def: .public equivalence (Equivalence I16) (at ..sub sub_equivalence)) -(def: .public width Nat (at ..sub bits)) -(def: .public i16 (-> I64 I16) (at ..sub narrow)) -(def: .public i64 (-> I16 I64) (at ..sub wide)) +(def .public equivalence (Equivalence I16) (at ..sub sub_equivalence)) +(def .public width Nat (at ..sub bits)) +(def .public i16 (-> I64 I16) (at ..sub narrow)) +(def .public i64 (-> I16 I64) (at ..sub wide)) diff --git a/stdlib/source/library/lux/math/number/i32.lux b/stdlib/source/library/lux/math/number/i32.lux index 42a35144c..65958842e 100644 --- a/stdlib/source/library/lux/math/number/i32.lux +++ b/stdlib/source/library/lux/math/number/i32.lux @@ -9,12 +9,12 @@ [// ["[0]" i64 (.only Sub)]]) -(def: sub +(def sub ... TODO: Stop needing this coercion. (as (Sub (I64 (Primitive "#I32"))) (maybe.trusted (i64.sub 32)))) -(def: .public I32 +(def .public I32 Type ... TODO: Switch to the cleaner approach ASAP. (case (type_of ..sub) @@ -29,7 +29,7 @@ ... (I64 size)) ) -(def: .public equivalence (Equivalence I32) (at ..sub sub_equivalence)) -(def: .public width Nat (at ..sub bits)) -(def: .public i32 (-> I64 I32) (at ..sub narrow)) -(def: .public i64 (-> I32 I64) (at ..sub wide)) +(def .public equivalence (Equivalence I32) (at ..sub sub_equivalence)) +(def .public width Nat (at ..sub bits)) +(def .public i32 (-> I64 I32) (at ..sub narrow)) +(def .public i64 (-> I32 I64) (at ..sub wide)) diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index 78a5c798f..c476676a5 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -10,19 +10,19 @@ [// ["n" nat]]) -(def: .public bits_per_byte +(def .public bits_per_byte 8) -(def: .public bytes_per_i64 +(def .public bytes_per_i64 8) -(def: .public width +(def .public width Nat (n.* ..bits_per_byte ..bytes_per_i64)) (with_template [<parameter_type> <name> <op>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (All (_ s) (-> <parameter_type> (I64 s) (I64 s))) (<op> parameter subject))] @@ -38,27 +38,27 @@ (type: .public Mask I64) -(def: .public (bit position) +(def .public (bit position) (-> Nat Mask) (|> 1 .i64 (..left_shifted (n.% ..width position)))) -(def: .public sign +(def .public sign Mask (..bit (-- ..width))) -(def: .public not +(def .public not (All (_ s) (-> (I64 s) (I64 s))) (..xor (.i64 (-- 0)))) -(def: .public false +(def .public false Mask (.i64 0)) -(def: .public true +(def .public true Mask (..not ..false)) -(def: .public (mask amount_of_bits) +(def .public (mask amount_of_bits) (-> Nat Mask) (case amount_of_bits 0 ..false @@ -66,11 +66,11 @@ 0 ..true bits (|> 1 .i64 (..left_shifted (n.% ..width bits)) .--)))) -(def: (with_shift shift value) +(def (with_shift shift value) (-> Nat Nat Nat) (|> value (right_shifted shift) (n.+ value))) -(def: .public (ones it) +(def .public (ones it) (-> (I64 Any) Nat) (let [ones' (n.- (|> it (right_shifted 1) (..and 6148914691236517205) i64) (i64 it))] @@ -82,12 +82,12 @@ (with_shift 32) (..and 127)))) -(def: .public (zero index input) +(def .public (zero index input) (All (_ s) (-> Nat (I64 s) (I64 s))) (|> index ..bit ..not (..and input))) (with_template [<name> <op>] - [(def: .public (<name> index input) + [(def .public (<name> index input) (All (_ s) (-> Nat (I64 s) (I64 s))) (|> index ..bit (<op> input)))] @@ -95,16 +95,16 @@ [flipped ..xor] ) -(def: .public (one? index input) +(def .public (one? index input) (-> Nat (I64 Any) Bit) (|> input .i64 (..and (..bit index)) (n.= 0) .not)) -(def: .public (zero? index input) +(def .public (zero? index input) (-> Nat (I64 Any) Bit) (.not (..one? index input))) (with_template [<name> <forward> <backward>] - [(def: .public (<name> distance input) + [(def .public (<name> distance input) (All (_ s) (-> Nat (I64 s) (I64 s))) (..or (<forward> distance input) (<backward> (n.- (n.% ..width distance) ..width) input)))] @@ -113,35 +113,35 @@ [right_rotated ..right_shifted ..left_shifted] ) -(def: .public (region offset size) +(def .public (region offset size) (-> Nat Nat Mask) (..left_rotated offset (..mask size))) -(def: .public equivalence +(def .public equivalence (All (_ a) (Equivalence (I64 a))) (implementation - (def: (= reference sample) + (def (= reference sample) ("lux i64 =" reference sample)))) -(def: .public hash +(def .public hash (All (_ a) (Hash (I64 a))) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: hash (|>> .nat)))) + (def hash (|>> .nat)))) (with_template [<monoid> <identity> <composite>] - [(def: .public <monoid> + [(def .public <monoid> (All (_ a) (Monoid (I64 a))) (implementation - (def: identity <identity>) - (def: composite <composite>)))] + (def identity <identity>) + (def composite <composite>)))] [disjunction ..false ..or] [conjunction ..true ..and] ) -(def: .public reversed +(def .public reversed (All (_ a) (-> (I64 a) (I64 a))) (let [swapper (is (-> Nat (All (_ a) (-> (I64 a) (I64 a)))) (function (_ power) @@ -189,7 +189,7 @@ (is (-> (I64 size) I64) wide))) -(def: .public (sub width) +(def .public (sub width) (Ex (_ size) (-> Nat (Maybe (Sub size)))) (if (.and (n.> 0 width) (n.< ..width width)) @@ -199,12 +199,12 @@ co_mantissa (..xor (.i64 -1) mantissa)] {.#Some (is Sub (implementation - (def: sub_equivalence ..equivalence) - (def: bits width) - (def: (narrow value) + (def sub_equivalence ..equivalence) + (def bits width) + (def (narrow value) (..or (|> value (..and ..sign) (..right_shifted sign_shift)) (|> value (..and mantissa)))) - (def: (wide value) + (def (wide value) (.i64 (case (.nat (..and sign value)) 0 value _ (..or co_mantissa value))))))}) diff --git a/stdlib/source/library/lux/math/number/i8.lux b/stdlib/source/library/lux/math/number/i8.lux index 36bafd4d6..6c13fc7ab 100644 --- a/stdlib/source/library/lux/math/number/i8.lux +++ b/stdlib/source/library/lux/math/number/i8.lux @@ -9,10 +9,10 @@ [// ["[0]" i64 (.only Sub)]]) -(def: sub +(def sub (maybe.trusted (i64.sub 8))) -(def: .public I8 +(def .public I8 Type ... TODO: Switch to the cleaner approach ASAP. (case (type_of ..sub) @@ -27,7 +27,7 @@ ... (I64 size)) ) -(def: .public equivalence (Equivalence I8) (at ..sub sub_equivalence)) -(def: .public width Nat (at ..sub bits)) -(def: .public i8 (-> I64 I8) (at ..sub narrow)) -(def: .public i64 (-> I8 I64) (at ..sub wide)) +(def .public equivalence (Equivalence I8) (at ..sub sub_equivalence)) +(def .public width Nat (at ..sub bits)) +(def .public i8 (-> I64 I8) (at ..sub narrow)) +(def .public i64 (-> I8 I64) (at ..sub wide)) diff --git a/stdlib/source/library/lux/math/number/int.lux b/stdlib/source/library/lux/math/number/int.lux index 19d2459f9..2f13df457 100644 --- a/stdlib/source/library/lux/math/number/int.lux +++ b/stdlib/source/library/lux/math/number/int.lux @@ -22,7 +22,7 @@ ["[1][0]" i64]]) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Int Int Bit) (<op> param subject))] @@ -30,24 +30,24 @@ [< "lux i64 <"] ) -(def: .public (<= reference sample) +(def .public (<= reference sample) (-> Int Int Bit) (if ("lux i64 <" reference sample) #1 ("lux i64 =" reference sample))) -(def: .public (> reference sample) +(def .public (> reference sample) (-> Int Int Bit) ("lux i64 <" sample reference)) -(def: .public (>= reference sample) +(def .public (>= reference sample) (-> Int Int Bit) (if ("lux i64 <" sample reference) #1 ("lux i64 =" reference sample))) (with_template [<comparison> <name>] - [(def: .public <name> + [(def .public <name> (Predicate Int) (<comparison> +0))] @@ -57,7 +57,7 @@ ) (with_template [<name> <test>] - [(def: .public (<name> left right) + [(def .public (<name> left right) (-> Int Int Int) (if (<test> right left) left @@ -68,7 +68,7 @@ ) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Int Int Int) (<op> param subject))] @@ -79,22 +79,22 @@ [% "lux i64 %"] ) -(def: .public (/% param subject) +(def .public (/% param subject) (-> Int Int [Int Int]) [(../ param subject) (..% param subject)]) -(def: .public (opposite it) +(def .public (opposite it) (-> Int Int) (..- it +0)) -(def: .public (abs it) +(def .public (abs it) (-> Int Int) (if (..< +0 it) (..* -1 it) it)) -(def: .public (signum it) +(def .public (signum it) (-> Int Int) (cond (..= +0 it) +0 (..< +0 it) -1 @@ -102,7 +102,7 @@ +1)) ... https://rob.conery.io/2018/08/21/mod-and-remainder-are-not-the-same/ -(def: .public (mod divisor dividend) +(def .public (mod divisor dividend) (All (_ m) (-> Int Int Int)) (let [remainder (..% divisor dividend)] (if (or (and (..< +0 divisor) @@ -112,27 +112,27 @@ (..+ divisor remainder) remainder))) -(def: .public even? +(def .public even? (-> Int Bit) (|>> (..% +2) ("lux i64 =" +0))) -(def: .public odd? +(def .public odd? (-> Int Bit) (|>> ..even? not)) ... https://en.wikipedia.org/wiki/Greatest_common_divisor -(def: .public (gcd a b) +(def .public (gcd a b) (-> Int Int Int) (case b +0 a _ (gcd b (..% b a)))) -(def: .public (co_prime? a b) +(def .public (co_prime? a b) (-> Int Int Bit) (..= +1 (..gcd a b))) ... https://en.wikipedia.org/wiki/Extended_Euclidean_algorithm -(def: .public (extended_gcd a b) +(def .public (extended_gcd a b) (-> Int Int [[Int Int] Int]) (loop (again [x +1 x1 +0 y +0 y1 +1 @@ -145,7 +145,7 @@ b1 (- (* q b1) a1)))))) ... https://en.wikipedia.org/wiki/Least_common_multiple -(def: .public (lcm a b) +(def .public (lcm a b) (-> Int Int Int) (case [a b] (^.or [_ +0] [+0 _]) @@ -154,48 +154,48 @@ _ (|> a (/ (gcd a b)) (* b)))) -(def: .public frac +(def .public frac (-> Int Frac) (|>> "lux i64 f64")) -(def: .public equivalence +(def .public equivalence (Equivalence Int) (implementation - (def: = ..=))) + (def = ..=))) -(def: .public order +(def .public order (Order Int) (implementation - (def: equivalence ..equivalence) - (def: < ..<))) + (def equivalence ..equivalence) + (def < ..<))) -(def: .public enum +(def .public enum (Enum Int) (implementation - (def: order ..order) - (def: succ ++) - (def: pred --))) + (def order ..order) + (def succ ++) + (def pred --))) ... TODO: Find out why the numeric literals fail during JS compilation. -(def: .public interval +(def .public interval (Interval Int) (implementation - (def: enum ..enum) - (def: top + (def enum ..enum) + (def top ... +9,223,372,036,854,775,807 (let [half (//i64.left_shifted 62 +1)] (+ half (-- half)))) - (def: bottom + (def bottom ... -9,223,372,036,854,775,808 (//i64.left_shifted 63 +1)))) (with_template [<name> <composite> <identity>] - [(def: .public <name> + [(def .public <name> (Monoid Int) (implementation - (def: identity <identity>) - (def: composite <composite>)))] + (def identity <identity>) + (def composite <composite>)))] [addition ..+ +0] [multiplication ..* +1] @@ -203,19 +203,19 @@ [minimum ..min (at ..interval top)] ) -(def: -sign "-") -(def: +sign "+") +(def -sign "-") +(def +sign "+") (with_template [<struct> <codec> <error>] - [(def: .public <struct> + [(def .public <struct> (Codec Text Int) (implementation - (def: (encoded value) + (def (encoded value) (if (..< +0 value) (|> value ++ ..opposite .nat ++ (at <codec> encoded) ("lux text concat" ..-sign)) (|> value .nat (at <codec> encoded) ("lux text concat" ..+sign)))) - (def: (decoded repr) + (def (decoded repr) (let [input_size ("lux text size" repr)] (if (//nat.> 1 input_size) (case ("lux text clip" 0 1 repr) @@ -241,13 +241,13 @@ [hex //nat.hex "Invalid hexadecimal syntax for Int: "] ) -(def: .public hash +(def .public hash (Hash Int) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> .nat)))) + (def equivalence ..equivalence) + (def hash (|>> .nat)))) -(def: .public (right_shifted parameter subject) +(def .public (right_shifted parameter subject) (-> Nat Int Int) (with_expansions [<positive> (//i64.right_shifted parameter subject)] (if (< +0 subject) diff --git a/stdlib/source/library/lux/math/number/nat.lux b/stdlib/source/library/lux/math/number/nat.lux index 206a6fe46..53828d2fa 100644 --- a/stdlib/source/library/lux/math/number/nat.lux +++ b/stdlib/source/library/lux/math/number/nat.lux @@ -17,7 +17,7 @@ ["^" pattern]]]]) (with_template [<extension> <output> <name>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (-> Nat Nat <output>) (<extension> parameter subject))] @@ -26,16 +26,16 @@ ["lux i64 -" Nat -] ) -(def: high +(def high (-> (I64 Any) I64) (|>> ("lux i64 right-shift" 32))) -(def: low +(def low (-> (I64 Any) I64) (let [mask (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))] (|>> ("lux i64 and" mask)))) -(def: .public (< reference sample) +(def .public (< reference sample) (-> Nat Nat Bit) (let [referenceH (..high reference) sampleH (..high sample)] @@ -47,22 +47,22 @@ (..low sample)) #0)))) -(def: .public (<= reference sample) +(def .public (<= reference sample) (-> Nat Nat Bit) (or (..< reference sample) ("lux i64 =" reference sample))) -(def: .public (> reference sample) +(def .public (> reference sample) (-> Nat Nat Bit) (..< sample reference)) -(def: .public (>= reference sample) +(def .public (>= reference sample) (-> Nat Nat Bit) (or (..< sample reference) ("lux i64 =" reference sample))) (with_template [<name> <test>] - [(def: .public (<name> left right) + [(def .public (<name> left right) (-> Nat Nat Nat) (if (<test> right left) left @@ -72,13 +72,13 @@ [max ..>] ) -(def: .public (* parameter subject) +(def .public (* parameter subject) (-> Nat Nat Nat) (.nat ("lux i64 *" (.int parameter) (.int subject)))) -(def: .public (/ parameter subject) +(def .public (/ parameter subject) (-> Nat Nat Nat) (if ("lux i64 <" +0 (.int parameter)) (if (..< parameter subject) @@ -96,7 +96,7 @@ quotient ("lux i64 +" 1 quotient))))) -(def: .public (/% parameter subject) +(def .public (/% parameter subject) (-> Nat Nat [Nat Nat]) (let [quotient (../ parameter subject) flat ("lux i64 *" @@ -104,24 +104,24 @@ (.int quotient))] [quotient ("lux i64 -" flat subject)])) -(def: .public (% parameter subject) +(def .public (% parameter subject) (-> Nat Nat Nat) (let [flat ("lux i64 *" (.int parameter) (.int (../ parameter subject)))] ("lux i64 -" flat subject))) -(def: .public (gcd a b) +(def .public (gcd a b) (-> Nat Nat Nat) (case b 0 a _ (gcd b (..% b a)))) -(def: .public (co_prime? a b) +(def .public (co_prime? a b) (-> Nat Nat Bit) (..= 1 (..gcd a b))) -(def: .public (lcm a b) +(def .public (lcm a b) (-> Nat Nat Nat) (case [a b] (^.or [_ 0] [0 _]) @@ -130,49 +130,49 @@ _ (|> a (../ (..gcd a b)) (..* b)))) -(def: .public even? +(def .public even? (-> Nat Bit) (|>> (..% 2) ("lux i64 =" 0))) -(def: .public odd? +(def .public odd? (-> Nat Bit) (|>> ..even? not)) -(def: .public frac +(def .public frac (-> Nat Frac) (|>> .int "lux i64 f64")) -(def: .public equivalence +(def .public equivalence (Equivalence Nat) (implementation - (def: = ..=))) + (def = ..=))) -(def: .public order +(def .public order (Order Nat) (implementation - (def: equivalence ..equivalence) - (def: < ..<))) + (def equivalence ..equivalence) + (def < ..<))) -(def: .public enum +(def .public enum (Enum Nat) (implementation - (def: order ..order) - (def: succ ++) - (def: pred --))) + (def order ..order) + (def succ ++) + (def pred --))) -(def: .public interval +(def .public interval (Interval Nat) (implementation - (def: enum ..enum) - (def: top (-- 0)) - (def: bottom 0))) + (def enum ..enum) + (def top (-- 0)) + (def bottom 0))) (with_template [<name> <composite> <identity>] - [(def: .public <name> + [(def .public <name> (Monoid Nat) (implementation - (def: identity <identity>) - (def: composite <composite>)))] + (def identity <identity>) + (def composite <composite>)))] [addition ..+ 0] [multiplication ..* 1] @@ -180,21 +180,21 @@ [maximum ..max (at ..interval bottom)] ) -(def: (binary_character value) +(def (binary_character value) (-> Nat Text) (case value 0 "0" 1 "1" _ (undefined))) -(def: (binary_value digit) +(def (binary_value digit) (-> Nat (Maybe Nat)) (case digit (pattern (char "0")) {.#Some 0} (pattern (char "1")) {.#Some 1} _ {.#None})) -(def: (octal_character value) +(def (octal_character value) (-> Nat Text) (case value 0 "0" @@ -207,7 +207,7 @@ 7 "7" _ (undefined))) -(def: (octal_value digit) +(def (octal_value digit) (-> Nat (Maybe Nat)) (case digit (pattern (char "0")) {.#Some 0} @@ -220,7 +220,7 @@ (pattern (char "7")) {.#Some 7} _ {.#None})) -(def: (decimal_character value) +(def (decimal_character value) (-> Nat Text) (case value 0 "0" @@ -235,7 +235,7 @@ 9 "9" _ (undefined))) -(def: (decimal_value digit) +(def (decimal_value digit) (-> Nat (Maybe Nat)) (case digit (pattern (char "0")) {.#Some 0} @@ -250,7 +250,7 @@ (pattern (char "9")) {.#Some 9} _ {.#None})) -(def: (hexadecimal_character value) +(def (hexadecimal_character value) (-> Nat Text) (case value 0 "0" @@ -271,7 +271,7 @@ 15 "F" _ (undefined))) -(def: (hexadecimal_value digit) +(def (hexadecimal_value digit) (-> Nat (Maybe Nat)) (case digit (^.with_template [<character> <number>] @@ -286,10 +286,10 @@ _ {.#None})) (with_template [<shift> <struct> <to_character> <to_value> <error>] - [(def: .public <struct> + [(def .public <struct> (Codec Text Nat) (implementation - (def: encoded + (def encoded (let [mask (|> 1 ("lux i64 left-shift" <shift>) --)] (function (_ value) (loop (again [input value @@ -304,7 +304,7 @@ input' (again input' output'))))))) - (def: (decoded repr) + (def (decoded repr) (let [input_size ("lux text size" repr)] (if (..> 0 input_size) (loop (again [idx 0 @@ -327,10 +327,10 @@ [4 hex hexadecimal_character hexadecimal_value "Invalid hexadecimal syntax for Nat: "] ) -(def: .public decimal +(def .public decimal (Codec Text Nat) (implementation - (def: (encoded value) + (def (encoded value) (loop (again [input value output ""]) (let [digit (decimal_character (..% 10 input)) @@ -342,7 +342,7 @@ input' (again input' output'))))) - (def: (decoded repr) + (def (decoded repr) (let [input_size ("lux text size" repr)] (with_expansions [<failure> {try.#Failure ("lux text concat" "Invalid decimal syntax for Nat: " repr)}] (if (..> 0 input_size) @@ -359,8 +359,8 @@ {try.#Success output})) <failure>)))))) -(def: .public hash +(def .public hash (Hash Nat) (implementation - (def: equivalence ..equivalence) - (def: hash function.identity))) + (def equivalence ..equivalence) + (def hash function.identity))) diff --git a/stdlib/source/library/lux/math/number/ratio.lux b/stdlib/source/library/lux/math/number/ratio.lux index 225b8da06..c4fe7a26d 100644 --- a/stdlib/source/library/lux/math/number/ratio.lux +++ b/stdlib/source/library/lux/math/number/ratio.lux @@ -27,117 +27,117 @@ [#numerator Nat #denominator Nat])) -(def: .public (nat value) +(def .public (nat value) (-> Ratio (Maybe Nat)) (case (the #denominator value) 1 {.#Some (the #numerator value)} _ {.#None})) -(def: (normal (open "_[0]")) +(def (normal (open "_[0]")) (-> Ratio Ratio) (let [common (n.gcd _#numerator _#denominator)] [..#numerator (n./ common _#numerator) ..#denominator (n./ common _#denominator)])) -(def: .public ratio +(def .public ratio (syntax (_ [numerator <code>.any ?denominator (<>.maybe <code>.any)]) (in (list (` ((~! ..normal) [..#numerator (~ numerator) ..#denominator (~ (maybe.else (' 1) ?denominator))])))))) -(def: .public (= parameter subject) +(def .public (= parameter subject) (-> Ratio Ratio Bit) (and (n.= (the #numerator parameter) (the #numerator subject)) (n.= (the #denominator parameter) (the #denominator subject)))) -(def: .public equivalence +(def .public equivalence (Equivalence Ratio) (implementation - (def: = ..=))) + (def = ..=))) -(def: (equalized parameter subject) +(def (equalized parameter subject) (-> Ratio Ratio [Nat Nat]) [(n.* (the #denominator subject) (the #numerator parameter)) (n.* (the #denominator parameter) (the #numerator subject))]) -(def: .public (< parameter subject) +(def .public (< parameter subject) (-> Ratio Ratio Bit) (let [[parameter' subject'] (..equalized parameter subject)] (n.< parameter' subject'))) -(def: .public (<= parameter subject) +(def .public (<= parameter subject) (-> Ratio Ratio Bit) (or (< parameter subject) (= parameter subject))) -(def: .public (> parameter subject) +(def .public (> parameter subject) (-> Ratio Ratio Bit) (..< subject parameter)) -(def: .public (>= parameter subject) +(def .public (>= parameter subject) (-> Ratio Ratio Bit) (or (> parameter subject) (= parameter subject))) -(def: .public order +(def .public order (Order Ratio) (implementation - (def: equivalence ..equivalence) - (def: < ..<))) + (def equivalence ..equivalence) + (def < ..<))) -(def: .public (+ parameter subject) +(def .public (+ parameter subject) (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject)] (normal [(n.+ parameter' subject') (n.* (the #denominator parameter) (the #denominator subject))]))) -(def: .public (- parameter subject) +(def .public (- parameter subject) (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject)] (normal [(n.- parameter' subject') (n.* (the #denominator parameter) (the #denominator subject))]))) -(def: .public (* parameter subject) +(def .public (* parameter subject) (-> Ratio Ratio Ratio) (normal [(n.* (the #numerator parameter) (the #numerator subject)) (n.* (the #denominator parameter) (the #denominator subject))])) -(def: .public (/ parameter subject) +(def .public (/ parameter subject) (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject)] (normal [subject' parameter']))) -(def: .public (% parameter subject) +(def .public (% parameter subject) (-> Ratio Ratio Ratio) (let [[parameter' subject'] (..equalized parameter subject) quot (n./ parameter' subject')] (..- (revised #numerator (n.* quot) parameter) subject))) -(def: .public (reciprocal (open "_[0]")) +(def .public (reciprocal (open "_[0]")) (-> Ratio Ratio) [..#numerator _#denominator ..#denominator _#numerator]) -(def: separator ":") +(def separator ":") -(def: .public codec +(def .public codec (Codec Text Ratio) (implementation - (def: (encoded (open "_[0]")) + (def (encoded (open "_[0]")) (all text#composite (n#encoded _#numerator) ..separator (n#encoded _#denominator))) - (def: (decoded input) + (def (decoded input) (case (text.split_by ..separator input) {.#Some [num denom]} (do try.monad @@ -150,11 +150,11 @@ {.#Left (text#composite "Invalid syntax for ratio: " input)})))) (with_template [<identity> <composite> <name>] - [(def: .public <name> + [(def .public <name> (Monoid Ratio) (implementation - (def: identity (..ratio <identity>)) - (def: composite <composite>)))] + (def identity (..ratio <identity>)) + (def composite <composite>)))] [0 ..+ addition] [1 ..* multiplication] diff --git a/stdlib/source/library/lux/math/number/rev.lux b/stdlib/source/library/lux/math/number/rev.lux index f7200c908..d74da6b2e 100644 --- a/stdlib/source/library/lux/math/number/rev.lux +++ b/stdlib/source/library/lux/math/number/rev.lux @@ -20,12 +20,12 @@ ["[1][0]" nat] ["[1][0]" int]]) -(def: .public /1 +(def .public /1 Rev (.rev -1)) (with_template [<power> <name>] - [(def: .public <name> + [(def .public <name> Rev (.rev (//i64.left_shifted (//nat.- <power> //i64.width) 1)))] @@ -43,30 +43,30 @@ [12 /4096] ) -(def: .public (= reference sample) +(def .public (= reference sample) (-> Rev Rev Bit) ("lux i64 =" reference sample)) -(def: .public (< reference sample) +(def .public (< reference sample) (-> Rev Rev Bit) (//nat.< (.nat reference) (.nat sample))) -(def: .public (<= reference sample) +(def .public (<= reference sample) (-> Rev Rev Bit) (or (//nat.< (.nat reference) (.nat sample)) ("lux i64 =" reference sample))) -(def: .public (> reference sample) +(def .public (> reference sample) (-> Rev Rev Bit) (..< sample reference)) -(def: .public (>= reference sample) +(def .public (>= reference sample) (-> Rev Rev Bit) (or (..< sample reference) ("lux i64 =" reference sample))) (with_template [<name> <test>] - [(def: .public (<name> left right) + [(def .public (<name> left right) (-> Rev Rev Rev) (if (<test> right left) left @@ -77,7 +77,7 @@ ) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Rev Rev Rev) (<op> param subject))] @@ -85,16 +85,16 @@ [- "lux i64 -"] ) -(def: high +(def high (-> (I64 Any) I64) (|>> ("lux i64 right-shift" 32))) -(def: low +(def low (-> (I64 Any) I64) (let [mask (|> 1 ("lux i64 left-shift" 32) ("lux i64 -" 1))] (|>> ("lux i64 and" mask)))) -(def: .public (* param subject) +(def .public (* param subject) (-> Rev Rev Rev) (let [subjectH (..high subject) subjectL (..low subject) @@ -112,26 +112,26 @@ ..high ("lux i64 +" top)))) -(def: even_one (//i64.right_rotated 1 1)) -(def: odd_one (-- 0)) +(def even_one (//i64.right_rotated 1 1)) +(def odd_one (-- 0)) -(def: (even_reciprocal numerator) +(def (even_reciprocal numerator) (-> Nat Nat) (//nat./ (//i64.right_shifted 1 numerator) ..even_one)) -(def: (odd_reciprocal numerator) +(def (odd_reciprocal numerator) (-> Nat Nat) (//nat./ numerator ..odd_one)) (with_expansions [<least_significant_bit> 1] - (def: .public (reciprocal numerator) + (def .public (reciprocal numerator) (-> Nat Rev) (.rev (case (is Nat ("lux i64 and" <least_significant_bit> numerator)) 0 (..even_reciprocal numerator) _ (..odd_reciprocal numerator)))) - (def: .public (/ param subject) + (def .public (/ param subject) (-> Rev Rev Rev) (if ("lux i64 =" +0 param) (panic! "Cannot divide Rev by zero!") @@ -141,7 +141,7 @@ (.rev (//nat.* reciprocal (.nat subject))))))) (with_template [<operator> <name> <output> <output_type>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Rev Rev <output_type>) (<output> (<operator> (.nat param) (.nat subject))))] @@ -150,7 +150,7 @@ ) (with_template [<operator> <name>] - [(def: .public (<name> scale subject) + [(def .public (<name> scale subject) (-> Nat Rev Rev) (.rev (<operator> (.nat scale) (.nat subject))))] @@ -158,76 +158,76 @@ [//nat./ down] ) -(def: .public (/% param subject) +(def .public (/% param subject) (-> Rev Rev [Rev Rev]) [(../ param subject) (..% param subject)]) -(def: mantissa +(def mantissa (-> (I64 Any) Frac) (|>> ("lux i64 right-shift" 11) "lux i64 f64")) -(def: frac_denominator +(def frac_denominator (..mantissa -1)) -(def: .public frac +(def .public frac (-> Rev Frac) (|>> ..mantissa ("lux f64 /" ..frac_denominator))) -(def: .public equivalence +(def .public equivalence (Equivalence Rev) (implementation - (def: = ..=))) + (def = ..=))) -(def: .public hash +(def .public hash (Hash Rev) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> .nat)))) + (def equivalence ..equivalence) + (def hash (|>> .nat)))) -(def: .public order +(def .public order (Order Rev) (implementation - (def: equivalence ..equivalence) - (def: < ..<))) + (def equivalence ..equivalence) + (def < ..<))) -(def: .public enum +(def .public enum (Enum Rev) (implementation - (def: order ..order) - (def: succ ++) - (def: pred --))) + (def order ..order) + (def succ ++) + (def pred --))) -(def: .public interval +(def .public interval (Interval Rev) (implementation - (def: enum ..enum) - (def: top (.rev -1)) - (def: bottom (.rev 0)))) + (def enum ..enum) + (def top (.rev -1)) + (def bottom (.rev 0)))) (with_template [<name> <composite> <identity>] - [(def: .public <name> + [(def .public <name> (Monoid Rev) (implementation - (def: identity (at interval <identity>)) - (def: composite <composite>)))] + (def identity (at interval <identity>)) + (def composite <composite>)))] [addition ..+ bottom] [maximum ..max bottom] [minimum ..min top] ) -(def: (decimals input) +(def (decimals input) (-> Text Text) ("lux text clip" 1 (-- ("lux text size" input)) input)) (with_template [<struct> <codec> <char_bit_size> <error>] [(with_expansions [<failure> (these {try.#Failure ("lux text concat" <error> repr)})] - (def: .public <struct> + (def .public <struct> (Codec Text Rev) (implementation - (def: (encoded value) + (def (encoded value) (let [raw_output (at <codec> encoded (.nat value)) max_num_chars (//nat.+ (//nat./ <char_bit_size> //i64.width) (case (//nat.% <char_bit_size> //i64.width) @@ -245,7 +245,7 @@ ("lux text concat" zero_padding) ("lux text concat" ".")))) - (def: (decoded repr) + (def (decoded repr) (let [repr_size ("lux text size" repr)] (if (//nat.> 1 repr_size) (case ("lux text char" 0 repr) @@ -279,21 +279,21 @@ (type: Digits (Array Nat)) -(def: (digits _) +(def (digits _) (-> Any Digits) (array.empty //i64.width)) -(def: (digit idx digits) +(def (digit idx digits) (-> Nat Digits Nat) (|> digits (array.item idx) (maybe.else 0))) -(def: digits#put! +(def digits#put! (-> Nat Nat Digits Digits) array.has!) -(def: (digits#times_5! idx output) +(def (digits#times_5! idx output) (-> Nat Digits Digits) (loop (again [idx idx carry 0 @@ -307,7 +307,7 @@ (//nat./ 10 raw) (digits#put! idx (//nat.% 10 raw) output)))))) -(def: (power_digits power) +(def (power_digits power) (-> Nat Digits) (loop (again [times power output (|> (..digits []) @@ -317,7 +317,7 @@ (again (-- times) (digits#times_5! power output))))) -(def: (format digits) +(def (format digits) (-> Digits Text) (loop (again [idx (-- //i64.width) all_zeroes? true @@ -336,7 +336,7 @@ (at //nat.decimal encoded digit) output))))))) -(def: (digits#+! param subject) +(def (digits#+! param subject) (-> Digits Digits Digits) (loop (again [idx (-- //i64.width) carry 0 @@ -351,7 +351,7 @@ (//nat./ 10 raw) (digits#put! idx (//nat.% 10 raw) output)))))) -(def: (text_digits input) +(def (text_digits input) (-> Text (Maybe Digits)) (let [length ("lux text size" input)] (if (//nat.> //i64.width length) @@ -368,7 +368,7 @@ (digits#put! idx digit output))) {.#Some output}))))) -(def: (digits#< param subject) +(def (digits#< param subject) (-> Digits Digits Bit) (loop (again [idx 0]) (and (//nat.< //i64.width idx) @@ -378,7 +378,7 @@ (again (++ idx)) (//nat.< pd sd)))))) -(def: (digits#-!' idx param subject) +(def (digits#-!' idx param subject) (-> Nat Nat Digits Digits) (let [sd (..digit idx subject)] (if (//nat.< param sd) @@ -390,7 +390,7 @@ (digits#-!' (-- idx) 1))) (digits#put! idx (//nat.- param sd) subject)))) -(def: (digits#-! param subject) +(def (digits#-! param subject) (-> Digits Digits Digits) (loop (again [idx (-- //i64.width) output subject]) @@ -399,10 +399,10 @@ (again (-- idx) (digits#-!' idx (..digit idx param) output))))) -(def: .public decimal +(def .public decimal (Codec Text Rev) (implementation - (def: (encoded input) + (def (encoded input) (case (.nat input) 0 ".0" @@ -421,7 +421,7 @@ (again (-- idx) digits))))))) - (def: (decoded input) + (def (decoded input) (let [dotted? (case ("lux text index" 0 "." input) {.#Some 0} true diff --git a/stdlib/source/library/lux/math/random.lux b/stdlib/source/library/lux/math/random.lux index a1a94b0a1..c7e6d0663 100644 --- a/stdlib/source/library/lux/math/random.lux +++ b/stdlib/source/library/lux/math/random.lux @@ -44,40 +44,40 @@ (type: .public (Random a) (-> PRNG [PRNG a])) -(def: .public functor +(def .public functor (Functor Random) (implementation - (def: (each f fa) + (def (each f fa) (function (_ state) (let [[state' a] (fa state)] [state' (f a)]))))) -(def: .public apply +(def .public apply (Apply Random) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ state) (let [[state' f] (ff state) [state'' a] (fa state')] [state'' (f a)]))))) -(def: .public monad +(def .public monad (Monad Random) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) (function (_ state) [state a])) - (def: (conjoint ffa) + (def (conjoint ffa) (function (_ state) (let [[state' fa] (ffa state)] (fa state')))))) -(def: .public (only pred gen) +(def .public (only pred gen) (All (_ a) (-> (-> a Bit) (Random a) (Random a))) (do ..monad [sample gen] @@ -85,7 +85,7 @@ (in sample) (only pred gen)))) -(def: .public (one check random) +(def .public (one check random) (All (_ a b) (-> (-> a (Maybe b)) (Random a) (Random b))) (do ..monad @@ -97,7 +97,7 @@ {.#None} (one check random)))) -(def: .public (refined refiner gen) +(def .public (refined refiner gen) (All (_ t r) (-> (Refiner t r) (Random t) (Random (Refined t r)))) (do ..monad [sample gen] @@ -108,13 +108,13 @@ {.#None} (refined refiner gen)))) -(def: .public bit +(def .public bit (Random Bit) (function (_ prng) (let [[prng output] (prng [])] [prng (|> output (i64.and 1) (n.= 1))]))) -(def: .public i64 +(def .public i64 (Random I64) (function (_ prng) (let [[prng left] (prng []) @@ -124,7 +124,7 @@ ("lux i64 +" right))]))) (with_template [<name> <type> <cast>] - [(def: .public <name> + [(def .public <name> (Random <type>) (at ..functor each (|>> <cast>) ..i64))] @@ -133,11 +133,11 @@ [rev Rev .rev] ) -(def: .public frac +(def .public frac (Random Frac) (at ..functor each (|>> .i64 f.of_bits) ..nat)) -(def: .public safe_frac +(def .public safe_frac (Random Frac) (let [mantissa_range (.int (i64.left_shifted 53 1)) mantissa_max (i.frac (-- mantissa_range))] @@ -147,7 +147,7 @@ (f./ mantissa_max)) ..int))) -(def: .public (char set) +(def .public (char set) (-> unicode.Set (Random Char)) (let [start (unicode.start set) end (unicode.end set) @@ -158,7 +158,7 @@ (at ..functor each in_range) (..only (unicode.member? set))))) -(def: .public (text char_gen size) +(def .public (text char_gen size) (-> (Random Char) Nat (Random Text)) (if (n.= 0 size) (at ..monad in "") @@ -168,7 +168,7 @@ (in (text#composite (text.of_char x) xs))))) (with_template [<name> <set>] - [(def: .public <name> + [(def .public <name> (-> Nat (Random Text)) (..text (..char <set>)))] @@ -182,7 +182,7 @@ ) (with_template [<name> <type> <ctor> <gen>] - [(def: .public <name> + [(def .public <name> (Random <type>) (do ..monad [left <gen> @@ -193,14 +193,14 @@ [complex c.Complex c.complex ..safe_frac] ) -(def: .public (and left right) +(def .public (and left right) (All (_ a b) (-> (Random a) (Random b) (Random [a b]))) (function (_ prng) (let [[prng left] (left prng) [prng right] (right prng)] [prng [left right]]))) -(def: .public (or left right) +(def .public (or left right) (All (_ a b) (-> (Random a) (Random b) (Random (Or a b)))) (function (_ prng) (let [[prng ?] (..bit prng)] @@ -210,7 +210,7 @@ (let [[prng right] (right prng)] [prng {0 #1 right}]))))) -(def: .public (either left right) +(def .public (either left right) (All (_ a) (-> (Random a) (Random a) (Random a))) (function (_ prng) (let [[prng ?] (..bit prng)] @@ -218,13 +218,13 @@ (left prng) (right prng))))) -(def: .public (rec gen) +(def .public (rec gen) (All (_ a) (-> (-> (Random a) (Random a)) (Random a))) (function (_ state) (let [gen' (gen (rec gen))] (gen' state)))) -(def: .public (maybe value_gen) +(def .public (maybe value_gen) (All (_ a) (-> (Random a) (Random (Maybe a)))) (do [! ..monad] [some? bit] @@ -234,7 +234,7 @@ (in {.#Some value})) (in {.#None})))) -(def: .public (list size value_gen) +(def .public (list size value_gen) (All (_ a) (-> Nat (Random a) (Random (List a)))) (if (n.> 0 size) (do ..monad @@ -243,7 +243,7 @@ (in {.#Item x xs})) (at ..monad in (.list)))) -(def: .public (sequence size value_gen) +(def .public (sequence size value_gen) (All (_ a) (-> Nat (Random a) (Random (Sequence a)))) (if (n.> 0 size) (do ..monad @@ -253,7 +253,7 @@ (at ..monad in sequence.empty))) (with_template [<name> <type> <ctor>] - [(def: .public (<name> size value_gen) + [(def .public (<name> size value_gen) (All (_ a) (-> Nat (Random a) (Random (<type> a)))) (do ..monad [values (list size value_gen)] @@ -264,7 +264,7 @@ [stack Stack (list#mix stack.top stack.empty)] ) -(def: .public (set hash size value_gen) +(def .public (set hash size value_gen) (All (_ a) (-> (Hash a) Nat (Random a) (Random (Set a)))) (if (n.> 0 size) (do [! ..monad] @@ -278,7 +278,7 @@ (again []))))) (at ..monad in (set.empty hash)))) -(def: .public (dictionary hash size key_gen value_gen) +(def .public (dictionary hash size key_gen value_gen) (All (_ k v) (-> (Hash k) Nat (Random k) (Random v) (Random (Dictionary k v)))) (if (n.> 0 size) (do [! ..monad] @@ -293,23 +293,23 @@ (again []))))) (at ..monad in (dictionary.empty hash)))) -(def: .public instant +(def .public instant (Random Instant) (at ..functor each instant.of_millis ..int)) -(def: .public date +(def .public date (Random Date) (at ..functor each instant.date ..instant)) -(def: .public time +(def .public time (Random Time) (at ..functor each instant.time ..instant)) -(def: .public duration +(def .public duration (Random Duration) (at ..functor each duration.of_millis ..int)) -(def: .public month +(def .public month (Random Month) (let [(open "_#[0]") ..monad] (..either (..either (..either (_#in {month.#January}) @@ -325,7 +325,7 @@ (..either (_#in {month.#November}) (_#in {month.#December}))))))) -(def: .public day +(def .public day (Random Day) (let [(open "_#[0]") ..monad] (..either (..either (_#in {day.#Sunday}) @@ -336,18 +336,18 @@ (..either (_#in {day.#Friday}) (_#in {day.#Saturday})))))) -(def: .public (result prng calc) +(def .public (result prng calc) (All (_ a) (-> PRNG (Random a) [PRNG a])) (calc prng)) -(def: .public (prng update return) +(def .public (prng update return) (All (_ a) (-> (-> a a) (-> a I64) (-> a PRNG))) (function (again state) (function (_ _) [(again (update state)) (return state)]))) -(def: .public (pcg_32 [increase seed]) +(def .public (pcg_32 [increase seed]) (-> [(I64 Any) (I64 Any)] PRNG) (let [magic 6364136223846793005] (function (_ _) @@ -360,7 +360,7 @@ (i64.right_rotated rot) .i64))]))) -(def: .public (xoroshiro_128+ [s0 s1]) +(def .public (xoroshiro_128+ [s0 s1]) (-> [(I64 Any) (I64 Any)] PRNG) (function (_ _) [(let [s01 (i64.xor s0 s1)] @@ -373,7 +373,7 @@ ... https://en.wikipedia.org/wiki/Xorshift#Initialization ... http://xorshift.di.unimi.it/splitmix64.c -(def: .public split_mix_64 +(def .public split_mix_64 (-> Nat PRNG) (let [twist (is (-> Nat Nat Nat) (function (_ shift value) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index a4a6d6ec3..3c0e85615 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -30,10 +30,10 @@ ... (type: (Meta a) ... (-> Lux (Try [Lux a]))) -(def: .public functor +(def .public functor (Functor Meta) (implementation - (def: (each f fa) + (def (each f fa) (function (_ lux) (case (fa lux) {try.#Failure msg} @@ -42,12 +42,12 @@ {try.#Success [lux' a]} {try.#Success [lux' (f a)]}))))) -(def: .public apply +(def .public apply (Apply Meta) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ lux) (case (ff lux) {try.#Success [lux' f]} @@ -61,16 +61,16 @@ {try.#Failure msg} {try.#Failure msg}))))) -(def: .public monad +(def .public monad (Monad Meta) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in x) + (def (in x) (function (_ lux) {try.#Success [lux x]})) - (def: (conjoint mma) + (def (conjoint mma) (function (_ lux) (case (mma lux) {try.#Failure msg} @@ -79,11 +79,11 @@ {try.#Success [lux' ma]} (ma lux')))))) -(def: .public (result' lux action) +(def .public (result' lux action) (All (_ a) (-> Lux (Meta a) (Try [Lux a]))) (action lux)) -(def: .public (result lux action) +(def .public (result lux action) (All (_ a) (-> Lux (Meta a) (Try a))) (case (action lux) {try.#Failure error} @@ -92,7 +92,7 @@ {try.#Success [_ output]} {try.#Success output})) -(def: .public (either left right) +(def .public (either left right) (All (_ a) (-> (Meta a) (Meta a) (Meta a))) (function (_ lux) (case (left lux) @@ -102,20 +102,20 @@ {try.#Success [lux' output]} {try.#Success [lux' output]}))) -(def: .public (assertion message test) +(def .public (assertion message test) (-> Text Bit (Meta Any)) (function (_ lux) (if test {try.#Success [lux []]} {try.#Failure message}))) -(def: .public (failure error) +(def .public (failure error) (All (_ a) (-> Text (Meta a))) (function (_ state) {try.#Failure (location.with (the .#location state) error)})) -(def: .public (module name) +(def .public (module name) (-> Text (Meta Module)) (function (_ lux) (case (plist.value name (the .#modules lux)) @@ -125,7 +125,7 @@ _ {try.#Failure (all text#composite "Unknown module: " name)}))) -(def: .public current_module_name +(def .public current_module_name (Meta Text) (function (_ lux) (case (the .#current_module lux) @@ -135,14 +135,14 @@ _ {try.#Failure "No current module."}))) -(def: .public current_module +(def .public current_module (Meta Module) (let [(open "#[0]") ..monad] (|> ..current_module_name (#each ..module) #conjoint))) -(def: (macro_type? type) +(def (macro_type? type) (-> Type Bit) (`` (case type {.#Named [(~~ (static .prelude)) "Macro"] {.#Primitive "#Macro" {.#End}}} @@ -151,7 +151,7 @@ _ false))) -(def: .public (normal name) +(def .public (normal name) (-> Symbol (Meta Symbol)) (case name ["" name] @@ -162,7 +162,7 @@ _ (at ..monad in name))) -(def: .public (macro full_name) +(def .public (macro full_name) (-> Symbol (Meta (Maybe Macro))) (do ..monad [[module name] (..normal full_name)] @@ -202,13 +202,13 @@ {.#Slot _} {.#None})))))]})))) -(def: .public seed +(def .public seed (Meta Nat) (function (_ lux) {try.#Success [(revised .#seed ++ lux) (the .#seed lux)]})) -(def: .public (module_exists? module) +(def .public (module_exists? module) (-> Text (Meta Bit)) (function (_ lux) {try.#Success [lux (case (plist.value module (the .#modules lux)) @@ -218,14 +218,14 @@ {.#None} #0)]})) -(def: (on_either f x1 x2) +(def (on_either f x1 x2) (All (_ a b) (-> (-> a (Maybe b)) a a (Maybe b))) (case (f x1) {.#None} (f x2) {.#Some y} {.#Some y})) -(def: (type_variable idx bindings) +(def (type_variable idx bindings) (-> Nat (List [Nat (Maybe Type)]) (Maybe Type)) (case bindings {.#End} @@ -236,7 +236,7 @@ bound (type_variable idx bindings')))) -(def: (clean_type type) +(def (clean_type type) (-> Type (Meta Type)) (case type {.#Var var} @@ -253,7 +253,7 @@ _ (at ..monad in type))) -(def: .public (var_type name) +(def .public (var_type name) (-> Text (Meta Type)) (function (_ lux) (let [test (is (-> [Text [Type Any]] Bit) @@ -277,23 +277,23 @@ {.#None} {try.#Failure (all text#composite "Unknown variable: " name)})))) -(def: without_lux_runtime +(def without_lux_runtime (-> (List Text) (List Text)) ... The Lux runtime shows up as "" ... so I'm excluding it. (list.only (|>> text.empty? not))) -(def: listing_separator +(def listing_separator Text (all text#composite text.new_line " ")) -(def: module_listing +(def module_listing (-> (List Text) Text) (|>> ..without_lux_runtime (list.sorted text#<) (text.interposed ..listing_separator))) -(def: .public (definition name) +(def .public (definition name) (-> Symbol (Meta Global)) (do ..monad [name (..normal name) @@ -361,7 +361,7 @@ "") " All known modules: " all_known_modules text.new_line)}))))) -(def: .public (export name) +(def .public (export name) (-> Symbol (Meta Definition)) (do ..monad [definition (..definition name)] @@ -392,7 +392,7 @@ "Slots are not considered exports: " (symbol#encoded name)))))) -(def: .public (definition_type name) +(def .public (definition_type name) (-> Symbol (Meta Type)) (do ..monad [definition (definition name)] @@ -416,7 +416,7 @@ "Slots have no type: " (symbol#encoded name)))))) -(def: .public (type name) +(def .public (type name) (-> Symbol (Meta Type)) (case name ["" _name] @@ -426,7 +426,7 @@ _ (definition_type name))) -(def: .public (type_definition name) +(def .public (type_definition name) (-> Symbol (Meta Type)) (do ..monad [definition (definition name)] @@ -452,7 +452,7 @@ {.#Slot _} (..failure (all text#composite "Slot is not a type: " (symbol#encoded name)))))) -(def: .public (globals module) +(def .public (globals module) (-> Text (Meta (List [Text Global]))) (function (_ lux) (case (plist.value module (the .#modules lux)) @@ -462,7 +462,7 @@ {.#Some module} {try.#Success [lux (the .#definitions module)]}))) -(def: .public (definitions module) +(def .public (definitions module) (-> Text (Meta (List [Text Definition]))) (at ..monad each (list.all (function (_ [name global]) @@ -483,7 +483,7 @@ {.#None}))) (..globals module))) -(def: .public (exports module_name) +(def .public (exports module_name) (-> Text (Meta (List [Text Definition]))) (do ..monad [constants (..definitions module_name)] @@ -493,7 +493,7 @@ (in [name [exported? def_type def_value]]) (list)))))) -(def: .public modules +(def .public modules (Meta (List [Text Module])) (function (_ lux) (|> lux @@ -501,7 +501,7 @@ [lux] {try.#Success}))) -(def: .public (tags_of type_name) +(def .public (tags_of type_name) (-> Symbol (Meta (Maybe (List Symbol)))) (do ..monad [.let [[module_name name] type_name] @@ -517,12 +517,12 @@ _ (in {.#None})))) -(def: .public location +(def .public location (Meta Location) (function (_ lux) {try.#Success [lux (the .#location lux)]})) -(def: .public expected_type +(def .public expected_type (Meta Type) (function (_ lux) (case (the .#expected lux) @@ -532,26 +532,26 @@ {.#None} {try.#Failure "Not expecting any type."}))) -(def: .public (imported_modules module_name) +(def .public (imported_modules module_name) (-> Text (Meta (List Text))) (do ..monad [(open "_[0]") (..module module_name)] (in _#imports))) -(def: .public (imported_by? import module) +(def .public (imported_by? import module) (-> Text Text (Meta Bit)) (do ..monad [(open "_[0]") (..module module)] (in (list.any? (text#= import) _#imports)))) -(def: .public (imported? import) +(def .public (imported? import) (-> Text (Meta Bit)) (at ..functor each (|>> (the .#imports) (list.any? (text#= import))) ..current_module)) (with_template [<name> <tag> <description>] - [(def: .public (<name> label_name) + [(def .public (<name> label_name) (-> Symbol (Meta [Nat (List Symbol) Type])) (do ..monad [.let [[module name] label_name] @@ -572,7 +572,7 @@ [slot .#Slot "slot"] ) -(def: .public (tag_lists module) +(def .public (tag_lists module) (-> Text (Meta (List [(List Symbol) Type]))) (do ..monad [=module (..module module) @@ -596,7 +596,7 @@ {.#None})) (the .#definitions =module))))) -(def: .public locals +(def .public locals (Meta (List (List [Text Type]))) (function (_ lux) (case (list.inits (the .#scopes lux)) @@ -610,7 +610,7 @@ [name type]))) scopes)]}))) -(def: .public (de_aliased def_name) +(def .public (de_aliased def_name) (-> Symbol (Meta Symbol)) (do ..monad [constant (..definition def_name)] @@ -630,17 +630,17 @@ {.#Slot _} def_name)))) -(def: .public compiler_state +(def .public compiler_state (Meta Lux) (function (_ lux) {try.#Success [lux lux]})) -(def: .public type_context +(def .public type_context (Meta Type_Context) (function (_ lux) {try.#Success [lux (the .#type_context lux)]})) -(def: .public (lifted result) +(def .public (lifted result) (All (_ a) (-> (Try a) (Meta a))) (case result {try.#Success output} @@ -649,14 +649,14 @@ {try.#Failure error} (..failure error))) -(def: .public (eval type code) +(def .public (eval type code) (-> Type Code (Meta Any)) (do [! ..monad] [eval (at ! each (the .#eval) ..compiler_state)] (eval type code))) -(def: .public (try computation) +(def .public (try computation) (All (_ it) (-> (Meta it) (Meta (Try it)))) (function (_ lux) (case (computation lux) @@ -667,7 +667,7 @@ {try.#Success [lux {try.#Failure error}]}))) (with_template [<type> <name> <slot>] - [(def: .public <name> + [(def .public <name> (Meta <type>) (function (_ lux) {try.#Success [lux diff --git a/stdlib/source/library/lux/meta/configuration.lux b/stdlib/source/library/lux/meta/configuration.lux index abd48664e..9d30b3590 100644 --- a/stdlib/source/library/lux/meta/configuration.lux +++ b/stdlib/source/library/lux/meta/configuration.lux @@ -28,20 +28,20 @@ (type: .public Configuration (/.PList Text)) -(def: .public equivalence +(def .public equivalence (Equivalence Configuration) (/.equivalence text.equivalence)) -(def: .public monoid +(def .public monoid (Monoid Configuration) /.monoid) -(def: .public empty +(def .public empty Configuration /.empty) (with_template [<ascii> <name>] - [(def: <name> + [(def <name> Text (text.of_char (hex <ascii>)))] @@ -49,17 +49,17 @@ ["03" end] ) -(def: format' +(def format' (-> Text Text) (text.enclosed [..start ..end])) -(def: .public format +(def .public format (%.Format Configuration) (|>> (list#each (function (_ [feature value]) (%.format (..format' feature) (..format' value)))) text.together)) -(def: .public parser +(def .public parser (Parser Configuration) (let [parser' (is (Parser Text) (<| (<>.after (<text>.this ..start)) @@ -69,11 +69,11 @@ (exception: .public invalid) -(def: configuration +(def configuration (<code>.Parser Configuration) (<code>.tuple (<>.some (<>.and <code>.text <code>.text)))) -(def: (subsumes? actual expected) +(def (subsumes? actual expected) (-> Configuration Configuration Bit) (case expected {.#End} @@ -86,7 +86,7 @@ (maybe.else false)) (subsumes? expected tail)))) -(def: .public for +(def .public for (syntax (_ [specializations (<>.some (<>.and ..configuration <code>.any)) default (<>.maybe <code>.any)]) (do meta.monad diff --git a/stdlib/source/library/lux/meta/location.lux b/stdlib/source/library/lux/meta/location.lux index c71dcd094..acb911ab8 100644 --- a/stdlib/source/library/lux/meta/location.lux +++ b/stdlib/source/library/lux/meta/location.lux @@ -4,21 +4,21 @@ [abstract [equivalence (.only Equivalence)]]]]) -(def: .public equivalence +(def .public equivalence (Equivalence Location) (implementation - (def: (= reference subject) + (def (= reference subject) (and ("lux text =" (the .#module reference) (the .#module subject)) ("lux i64 =" (the .#line reference) (the .#line subject)) ("lux i64 =" (the .#column reference) (the .#column subject)))))) -(def: .public dummy +(def .public dummy Location [.#module "" .#line 0 .#column 0]) -(def: .public here +(def .public here (macro (_ tokens compiler) (case tokens {.#End} @@ -32,7 +32,7 @@ _ {.#Left (`` (("lux in-module" (~~ (static .prelude)) wrong_syntax_error) (symbol ..here)))}))) -(def: .public (format it) +(def .public (format it) (-> Location Text) (let [separator "," [file line column] it] @@ -42,10 +42,10 @@ (`` (("lux in-module" (~~ (static .prelude)) .nat#encoded) line)) separator (`` (("lux in-module" (~~ (static .prelude)) .nat#encoded) column))))) -(def: \n +(def \n ("lux i64 char" +10)) -(def: .public (with location error) +(def .public (with location error) (-> Location Text Text) (all "lux text concat" (..format location) \n error)) diff --git a/stdlib/source/library/lux/meta/symbol.lux b/stdlib/source/library/lux/meta/symbol.lux index 7966482ce..fba56c993 100644 --- a/stdlib/source/library/lux/meta/symbol.lux +++ b/stdlib/source/library/lux/meta/symbol.lux @@ -14,7 +14,7 @@ ... [Text Text]) (with_template [<name>] - [(def: .public (<name> [module short]) + [(def .public (<name> [module short]) (-> Symbol Text) <name>)] @@ -22,35 +22,35 @@ [short] ) -(def: .public hash +(def .public hash (Hash Symbol) (product.hash text.hash text.hash)) -(def: .public equivalence +(def .public equivalence (Equivalence Symbol) (at ..hash equivalence)) -(def: .public order +(def .public order (Order Symbol) (implementation - (def: equivalence ..equivalence) - (def: (< [moduleP shortP] [moduleS shortS]) + (def equivalence ..equivalence) + (def (< [moduleP shortP] [moduleS shortS]) (if (text#= moduleP moduleS) (at text.order < shortP shortS) (at text.order < moduleP moduleS))))) -(def: .public separator +(def .public separator ".") -(def: .public codec +(def .public codec (Codec Text Symbol) (implementation - (def: (encoded [module short]) + (def (encoded [module short]) (case module "" short _ (all text#composite module ..separator short))) - (def: (decoded input) + (def (decoded input) (case (text.all_split_by ..separator input) (pattern (list short)) {.#Right ["" short]} diff --git a/stdlib/source/library/lux/meta/version.lux b/stdlib/source/library/lux/meta/version.lux index 4fc4b2409..e90c95a53 100644 --- a/stdlib/source/library/lux/meta/version.lux +++ b/stdlib/source/library/lux/meta/version.lux @@ -19,11 +19,11 @@ [compiler [version (.only Version)]]]]]) -(def: .public latest +(def .public latest Version 00,07,00) -(def: .public current +(def .public current (syntax (_ []) (do meta.monad [it meta.version] @@ -31,7 +31,7 @@ (exception: .public invalid) -(def: .public for +(def .public for (syntax (_ [specializations (<>.some (<>.and <code>.text <code>.any)) default (<>.maybe <code>.any)]) (do meta.monad diff --git a/stdlib/source/library/lux/program.lux b/stdlib/source/library/lux/program.lux index 11ddcdd16..1e4622bcc 100644 --- a/stdlib/source/library/lux/program.lux +++ b/stdlib/source/library/lux/program.lux @@ -20,12 +20,12 @@ {#Raw Text} {#Parsed (List Code)})) -(def: arguments^ +(def arguments^ (<code>.Parser Arguments) (<>.or <code>.local (<code>.tuple (<>.some <code>.any)))) -(def: .public program: +(def .public program: (syntax (_ [args ..arguments^ body <code>.any]) (with_symbols [g!program g!args g!_ g!output g!message] diff --git a/stdlib/source/library/lux/static.lux b/stdlib/source/library/lux/static.lux index ea40d2733..4fd6c1674 100644 --- a/stdlib/source/library/lux/static.lux +++ b/stdlib/source/library/lux/static.lux @@ -18,7 +18,7 @@ ["[0]" random (.only Random)]]]]) (with_template [<name> <type> <format>] - [(def: .public <name> + [(def .public <name> (syntax (_ [expression <code>.any]) (at meta.monad each (|>> (as <type>) <format> list) @@ -32,14 +32,14 @@ [text .Text code.text] ) -(def: pcg_32_magic_inc +(def pcg_32_magic_inc Nat (hex "FEDCBA9876543210")) (with_expansions [<type> (Ex (_ a) [(-> a Code) a])] - (def: .public literal + (def .public literal (syntax (_ [format <code>.any expression <code>.any]) (do meta.monad @@ -51,7 +51,7 @@ (with_expansions [<type> (Ex (_ a) [(-> a Code) (List a)])] - (def: .public literals + (def .public literals (syntax (_ [format <code>.any expression <code>.any]) (do meta.monad @@ -60,12 +60,12 @@ .let [[format expression] (as <type> pair)]] (in (list#each format expression)))))) -(def: .public seed +(def .public seed (syntax (_ []) (meta#each (|>> code.nat list) meta.seed))) (with_template [<name> <random> <format>] - [(def: .public <name> + [(def .public <name> (syntax (_ []) (do meta.monad [seed meta.seed @@ -83,7 +83,7 @@ (with_expansions [<type> (Ex (_ a) [(-> a Code) (Random a)])] - (def: .public random + (def .public random (syntax (_ [format <code>.any random <code>.any]) (do meta.monad @@ -98,7 +98,7 @@ (with_expansions [<type> (Ex (_ a) [(-> a Code) (Random (List a))])] - (def: .public randoms + (def .public randoms (syntax (_ [format <code>.any random <code>.any]) (do meta.monad @@ -110,7 +110,7 @@ random)]] (in (list#each format result)))))) -(def: .public if +(def .public if (syntax (_ [test <code>.any then <code>.any else <code>.any]) @@ -120,7 +120,7 @@ then else)))))) -(def: .public cond +(def .public cond (syntax (_ [test,then/* (<>.some (<>.and <code>.any <code>.any)) else <code>.any]) (in (list (list#mix (function (_ [test then] else) @@ -130,7 +130,7 @@ else (list.reversed test,then/*)))))) -(def: .public when +(def .public when (syntax (_ [test <code>.any then <code>.any]) (do meta.monad diff --git a/stdlib/source/library/lux/target.lux b/stdlib/source/library/lux/target.lux index 66e8ea31b..cee1e3084 100644 --- a/stdlib/source/library/lux/target.lux +++ b/stdlib/source/library/lux/target.lux @@ -1,12 +1,12 @@ (.using - [library - [lux (.except)]]) + [library + [lux (.except)]]) (type: .public Target Text) (with_template [<name> <value>] - [(def: .public <name> + [(def .public <name> Target <value>)] diff --git a/stdlib/source/library/lux/target/common_lisp.lux b/stdlib/source/library/lux/target/common_lisp.lux index a95e1df67..b0107d234 100644 --- a/stdlib/source/library/lux/target/common_lisp.lux +++ b/stdlib/source/library/lux/target/common_lisp.lux @@ -16,18 +16,18 @@ [type [primitive (.except)]]]]) -(def: as_form +(def as_form (-> Text Text) (text.enclosed ["(" ")"])) (primitive .public (Code brand) Text - (def: .public manual + (def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) @@ -62,29 +62,29 @@ [#input Var/* #output (Expression Any)])) - (def: .public nil + (def .public nil Literal (abstraction "()")) (with_template [<prefix> <name>] - [(def: .public <name> + [(def .public <name> (-> Text Literal) (|>> (format <prefix>) abstraction))] ["'" symbol] [":" keyword]) - (def: .public bool + (def .public bool (-> Bit Literal) (|>> (pipe.case #0 ..nil #1 (..symbol "t")))) - (def: .public int + (def .public int (-> Int Literal) (|>> %.int abstraction)) - (def: .public float + (def .public float (-> Frac Literal) (|>> (pipe.cond [(f.= f.positive_infinity)] [(pipe.new "(/ 1.0 0.0)" [])] @@ -99,7 +99,7 @@ [%.frac]) abstraction)) - (def: .public (double value) + (def .public (double value) (-> Frac Literal) (abstraction (.cond (f.= f.positive_infinity value) @@ -117,7 +117,7 @@ (text.replaced_once "E" "d" raw) (format raw "d0")))))) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -134,24 +134,24 @@ )) ))) - (def: .public string + (def .public string (-> Text Literal) (|>> ..safe (text.enclosed' text.double_quote) abstraction)) - (def: .public var + (def .public var (-> Text Var/1) (|>> abstraction)) - (def: .public args + (def .public args (-> (List Var/1) Var/*) (|>> (list#each ..code) (text.interposed " ") ..as_form abstraction)) - (def: .public (args& singles rest) + (def .public (args& singles rest) (-> (List Var/1) Var/1 Var/*) (|> (case singles {.#End} @@ -166,19 +166,19 @@ ..as_form abstraction)) - (def: form + (def form (-> (List (Expression Any)) Expression) (|>> (list#each ..code) (text.interposed " ") ..as_form abstraction)) - (def: .public (call/* func) + (def .public (call/* func) (-> (Expression Any) (-> (List (Expression Any)) (Computation Any))) (|>> {.#Item func} ..form)) (with_template [<name> <function>] - [(def: .public <name> + [(def .public <name> (-> (List (Expression Any)) (Computation Any)) (..call/* (..var <function>)))] @@ -186,7 +186,7 @@ [list/* "list"] ) - (def: .public (labels definitions body) + (def .public (labels definitions body) (-> (List [Var/1 Lambda]) (Expression Any) (Computation Any)) (..form (list (..var "labels") (..form (list#each (function (_ [def_name [def_args def_body]]) @@ -194,19 +194,19 @@ definitions)) body))) - (def: .public (destructuring_bind [bindings expression] body) + (def .public (destructuring_bind [bindings expression] body) (-> [Var/* (Expression Any)] (List (Expression Any)) (Computation Any)) (..form (list.partial (..var "destructuring-bind") (transmutation bindings) expression body))) (with_template [<call> <input_var>+ <input_type>+ <function>+] - [(`` (def: .public (<call> [(~~ (template.spliced <input_var>+))] function) + [(`` (def .public (<call> [(~~ (template.spliced <input_var>+))] function) (-> [(~~ (template.spliced <input_type>+))] (Expression Any) (Computation Any)) (..call/* function (list (~~ (template.spliced <input_var>+)))))) (`` (with_template [<lux_name> <host_name>] - [(def: .public (<lux_name> args) + [(def .public (<lux_name> args) (-> [(~~ (template.spliced <input_type>+))] (Computation Any)) (<call> args (..var <host_name>)))] @@ -264,7 +264,7 @@ (with_template [<call> <input_type>+ <function>+] [(`` (with_template [<lux_name> <host_name>] - [(def: .public (<lux_name> args) + [(def .public (<lux_name> args) (-> [(~~ (template.spliced <input_type>+))] (Access Any)) (transmutation (<call> args (..var <host_name>))))] @@ -281,29 +281,29 @@ [gethash/2 "gethash"]]] ) - (def: .public (make_hash_table/with_size size) + (def .public (make_hash_table/with_size size) (-> (Expression Any) (Computation Any)) (..call/* (..var "make-hash-table") (list (..keyword "size") size))) - (def: .public (funcall/+ [func args]) + (def .public (funcall/+ [func args]) (-> [(Expression Any) (List (Expression Any))] (Computation Any)) (..call/* (..var "funcall") (list.partial func args))) - (def: .public (search/3 [reference space start]) + (def .public (search/3 [reference space start]) (-> [(Expression Any) (Expression Any) (Expression Any)] (Computation Any)) (..call/* (..var "search") (list reference space (..keyword "start2") start))) - (def: .public (concatenate/2|string [left right]) + (def .public (concatenate/2|string [left right]) (-> [(Expression Any) (Expression Any)] (Computation Any)) (concatenate/3 [(..symbol "string") left right])) (with_template [<lux_name> <host_name>] - [(def: .public (<lux_name> left right) + [(def .public (<lux_name> left right) (-> (Expression Any) (Expression Any) (Computation Any)) (..form (list (..var <host_name>) left right)))] @@ -312,7 +312,7 @@ ) (with_template [<lux_name> <host_name>] - [(def: .public (<lux_name> [param subject]) + [(def .public (<lux_name> [param subject]) (-> [(Expression Any) (Expression Any)] (Computation Any)) (..form (list (..var <host_name>) subject param)))] @@ -332,20 +332,20 @@ [logxor/2 "logxor"] ) - (def: .public (if test then else) + (def .public (if test then else) (-> (Expression Any) (Expression Any) (Expression Any) (Computation Any)) (..form (list (..var "if") test then else))) - (def: .public (when test then) + (def .public (when test then) (-> (Expression Any) (Expression Any) (Computation Any)) (..form (list (..var "when") test then))) - (def: .public (lambda input body) + (def .public (lambda input body) (-> Var/* (Expression Any) Literal) (..form (list (..var "lambda") (transmutation input) body))) (with_template [<lux_name> <host_name>] - [(def: .public (<lux_name> bindings body) + [(def .public (<lux_name> bindings body) (-> (List [Var/1 (Expression Any)]) (List (Expression Any)) (Computation Any)) (..form (list.partial (..var <host_name>) (|> bindings @@ -358,16 +358,16 @@ [let* "let*"] ) - (def: .public (defparameter name body) + (def .public (defparameter name body) (-> Var/1 (Expression Any) (Expression Any)) (..form (list (..var "defparameter") name body))) - (def: .public (defun name inputs body) + (def .public (defun name inputs body) (-> Var/1 Var/* (Expression Any) (Expression Any)) (..form (list (..var "defun") name (transmutation inputs) body))) (with_template [<name> <symbol>] - [(def: .public <name> + [(def .public <name> (-> (List (Expression Any)) (Computation Any)) (|>> (list.partial (..var <symbol>)) ..form))] @@ -376,11 +376,11 @@ [values/* "values"] ) - (def: .public (setq name value) + (def .public (setq name value) (-> Var/1 (Expression Any) (Expression Any)) (..form (list (..var "setq") name value))) - (def: .public (setf access value) + (def .public (setf access value) (-> (Access Any) (Expression Any) (Expression Any)) (..form (list (..var "setf") access value))) @@ -390,7 +390,7 @@ #condition Var/1 #body (Expression Any)])) - (def: .public (handler_case handlers body) + (def .public (handler_case handlers body) (-> (List Handler) (Expression Any) (Computation Any)) (..form (list.partial (..var "handler-case") body @@ -401,7 +401,7 @@ handlers)))) (with_template [<name> <prefix>] - [(def: .public (<name> conditions expression) + [(def .public (<name> conditions expression) (-> (List Text) (Expression Any) (Expression Any)) (case conditions {.#End} @@ -421,23 +421,23 @@ [conditional+ "#+"] [conditional- "#-"]) - (def: .public label + (def .public label (-> Text Label) (|>> abstraction)) - (def: .public (block name body) + (def .public (block name body) (-> Label (List (Expression Any)) (Computation Any)) (..form (list.partial (..var "block") (transmutation name) body))) - (def: .public (return_from target value) + (def .public (return_from target value) (-> Label (Expression Any) (Computation Any)) (..form (list (..var "return-from") (transmutation target) value))) - (def: .public (return value) + (def .public (return value) (-> (Expression Any) (Computation Any)) (..form (list (..var "return") value))) - (def: .public (cond clauses else) + (def .public (cond clauses else) (-> (List [(Expression Any) (Expression Any)]) (Expression Any) (Computation Any)) (..form (list.partial (..var "cond") (list#composite (list#each (function (_ [test then]) @@ -445,28 +445,28 @@ clauses) (list (..form (list (..bool true) else))))))) - (def: .public tag + (def .public tag (-> Text Tag) (|>> abstraction)) - (def: .public go + (def .public go (-> Tag (Expression Any)) (|>> (list (..var "go")) ..form)) - (def: .public values_list/1 + (def .public values_list/1 (-> (Expression Any) (Expression Any)) (|>> (list (..var "values-list")) ..form)) - (def: .public (multiple_value_setq bindings values) + (def .public (multiple_value_setq bindings values) (-> Var/* (Expression Any) (Expression Any)) (..form (list (..var "multiple-value-setq") (transmutation bindings) values))) ) -(def: .public (while condition body) +(def .public (while condition body) (-> (Expression Any) (Expression Any) (Computation Any)) (..form (list (..var "loop") (..var "while") condition (..var "do") body))) diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux index ae5ffe9d1..5b057a697 100644 --- a/stdlib/source/library/lux/target/js.lux +++ b/stdlib/source/library/lux/target/js.lux @@ -17,18 +17,18 @@ [type [primitive (.except)]]]]) -(def: expression +(def expression (text.enclosed ["(" ")"])) -(def: element +(def element (text.enclosed ["[" "]"])) ... Added the carriage return for better Windows compatibility. -(def: \n+ +(def \n+ Text (format text.carriage_return text.new_line)) -(def: nested +(def nested (-> Text Text) (|>> (format \n+) (text.replaced text.new_line (format text.new_line text.tab)))) @@ -36,7 +36,7 @@ (primitive .public (Code brand) Text - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) @@ -64,20 +64,20 @@ ) (with_template [<name> <literal>] - [(def: .public <name> Literal (abstraction <literal>))] + [(def .public <name> Literal (abstraction <literal>))] [null "null"] [undefined "undefined"] ) - (def: .public boolean + (def .public boolean (-> Bit Literal) (|>> (pipe.case #0 "false" #1 "true") abstraction)) - (def: .public (number value) + (def .public (number value) (-> Frac Literal) (abstraction (cond (f.not_a_number? value) @@ -92,7 +92,7 @@ ... else (|> value %.frac ..expression)))) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<replace> <find>] [(text.replaced <find> <replace>)] @@ -110,36 +110,36 @@ )) ))) - (def: .public string + (def .public string (-> Text Literal) (|>> ..safe (text.enclosed [text.double_quote text.double_quote]) abstraction)) - (def: argument_separator ", ") - (def: field_separator ": ") - (def: statement_suffix ";") + (def argument_separator ", ") + (def field_separator ": ") + (def statement_suffix ";") - (def: .public array + (def .public array (-> (List Expression) Computation) (|>> (list#each ..code) (text.interposed ..argument_separator) ..element abstraction)) - (def: .public var + (def .public var (-> Text Var) (|>> abstraction)) - (def: .public (at index array_or_object) + (def .public (at index array_or_object) (-> Expression Expression Access) (abstraction (format (representation array_or_object) (..element (representation index))))) - (def: .public (the field object) + (def .public (the field object) (-> Text Expression Access) (abstraction (format (representation object) "." field))) - (def: .public (apply function inputs) + (def .public (apply function inputs) (-> Expression (List Expression) Computation) (|> inputs (list#each ..code) @@ -148,11 +148,11 @@ (format (representation function)) abstraction)) - (def: .public (do method inputs object) + (def .public (do method inputs object) (-> Text (List Expression) Expression Computation) (apply (..the method object) inputs)) - (def: .public object + (def .public object (-> (List [Text Expression]) Computation) (|>> (list#each (.function (_ [key val]) (format (representation (..string key)) ..field_separator (representation val)))) @@ -161,19 +161,19 @@ ..expression abstraction)) - (def: .public (, pre post) + (def .public (, pre post) (-> Expression Expression Computation) (|> (format (representation pre) ..argument_separator (representation post)) ..expression abstraction)) - (def: .public (then pre post) + (def .public (then pre post) (-> Statement Statement Statement) (abstraction (format (representation pre) \n+ (representation post)))) - (def: block + (def block (-> Statement Text) (let [close (format \n+ "}")] (|>> representation @@ -181,7 +181,7 @@ (text.enclosed ["{" close])))) - (def: .public (function_definition name inputs body) + (def .public (function_definition name inputs body) (-> Var (List Var) Statement Statement) (|> body ..block @@ -193,14 +193,14 @@ " ") abstraction)) - (def: .public (function name inputs body) + (def .public (function name inputs body) (-> Var (List Var) Statement Computation) (|> (..function_definition name inputs body) representation ..expression abstraction)) - (def: .public (closure inputs body) + (def .public (closure inputs body) (-> (List Var) Statement Computation) (|> body ..block @@ -214,7 +214,7 @@ abstraction)) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Expression Expression Computation) (|> (format (representation subject) " " <op> " " (representation param)) ..expression @@ -244,7 +244,7 @@ ) (with_template [<prefix> <name>] - [(def: .public <name> + [(def .public <name> (-> Expression Computation) (|>> representation (text.prefix <prefix>) ..expression abstraction))] @@ -255,7 +255,7 @@ (with_template [<name> <input> <format>] [... A 32-bit integer expression. - (def: .public (<name> value) + (def .public (<name> value) (-> <input> Computation) (abstraction (..expression (format (<format> value) "|0"))))] @@ -263,13 +263,13 @@ [i32 Int %.int] ) - (def: .public (int value) + (def .public (int value) (-> Int Literal) (abstraction (.if (i.< +0 value) (%.int value) (%.nat (.nat value))))) - (def: .public (? test then else) + (def .public (? test then else) (-> Expression Expression Expression Computation) (|> (format (representation test) " ? " (representation then) @@ -277,14 +277,14 @@ ..expression abstraction)) - (def: .public type_of + (def .public type_of (-> Expression Computation) (|>> representation (format "typeof ") ..expression abstraction)) - (def: .public (new constructor inputs) + (def .public (new constructor inputs) (-> Expression (List Expression) Computation) (|> (format "new " (representation constructor) (|> inputs @@ -294,71 +294,71 @@ ..expression abstraction)) - (def: .public statement + (def .public statement (-> Expression Statement) (|>> representation (text.suffix ..statement_suffix) abstraction)) - (def: .public use_strict + (def .public use_strict Statement (abstraction (format text.double_quote "use strict" text.double_quote ..statement_suffix))) - (def: .public (declare name) + (def .public (declare name) (-> Var Statement) (abstraction (format "var " (representation name) ..statement_suffix))) - (def: .public (define name value) + (def .public (define name value) (-> Var Expression Statement) (abstraction (format "var " (representation name) " = " (representation value) ..statement_suffix))) - (def: .public (set name value) + (def .public (set name value) (-> Location Expression Statement) (abstraction (format (representation name) " = " (representation value) ..statement_suffix))) - (def: .public (throw message) + (def .public (throw message) (-> Expression Statement) (abstraction (format "throw " (representation message) ..statement_suffix))) - (def: .public (return value) + (def .public (return value) (-> Expression Statement) (abstraction (format "return " (representation value) ..statement_suffix))) - (def: .public delete + (def .public delete (-> Location Expression) (|>> representation (format "delete ") ..expression abstraction)) - (def: .public (if test then! else!) + (def .public (if test then! else!) (-> Expression Statement Statement Statement) (abstraction (format "if(" (representation test) ") " (..block then!) " else " (..block else!)))) - (def: .public (when test then!) + (def .public (when test then!) (-> Expression Statement Statement) (abstraction (format "if(" (representation test) ") " (..block then!)))) - (def: .public (while test body) + (def .public (while test body) (-> Expression Statement Loop) (abstraction (format "while(" (representation test) ") " (..block body)))) - (def: .public (do_while test body) + (def .public (do_while test body) (-> Expression Statement Loop) (abstraction (format "do " (..block body) " while(" (representation test) ")" ..statement_suffix))) - (def: .public (try body [exception catch]) + (def .public (try body [exception catch]) (-> Statement [Var Statement] Statement) (abstraction (format "try " (..block body) " catch(" (representation exception) ") " (..block catch)))) - (def: .public (for var init condition update iteration) + (def .public (for var init condition update iteration) (-> Var Expression Expression Expression Statement Loop) (abstraction (format "for(" (representation (..define var init)) " " (representation condition) @@ -366,20 +366,20 @@ ")" (..block iteration)))) - (def: .public label + (def .public label (-> Text Label) (|>> abstraction)) - (def: .public (with_label label loop) + (def .public (with_label label loop) (-> Label Loop Statement) (abstraction (format (representation label) ": " (representation loop)))) (with_template [<keyword> <0> <1>] - [(def: .public <0> + [(def .public <0> Statement (abstraction (format <keyword> ..statement_suffix))) - (def: .public (<1> label) + (def .public (<1> label) (-> Label Statement) (abstraction (format <keyword> " " (representation label) ..statement_suffix)))] @@ -388,7 +388,7 @@ ) (with_template [<name> <js>] - [(def: .public <name> + [(def .public <name> (-> Location Expression) (|>> representation (text.suffix <js>) @@ -398,11 +398,11 @@ [-- "--"] ) - (def: .public (comment commentary on) + (def .public (comment commentary on) (All (_ kind) (-> Text (Code kind) (Code kind))) (abstraction (format "/* " commentary " */" " " (representation on)))) - (def: .public (switch input cases default) + (def .public (switch input cases default) (-> Expression (List [(List Literal) Statement]) (Maybe Statement) Statement) (abstraction (format "switch (" (representation input) ") " (|> (format (|> cases @@ -425,13 +425,13 @@ ) (with_template [<apply> <arg>+ <type>+ <function>+] - [(`` (def: .public (<apply> function) + [(`` (def .public (<apply> function) (-> Expression (~~ (template.spliced <type>+)) Computation) (.function (_ (~~ (template.spliced <arg>+))) (..apply function (list (~~ (template.spliced <arg>+))))))) (`` (with_template [<definition> <function>] - [(def: .public <definition> (<apply> (..var <function>)))] + [(def .public <definition> (<apply> (..var <function>)))] (~~ (template.spliced <function>+))))] diff --git a/stdlib/source/library/lux/target/jvm/attribute.lux b/stdlib/source/library/lux/target/jvm/attribute.lux index 30a3fe5f3..eb6fd8566 100644 --- a/stdlib/source/library/lux/target/jvm/attribute.lux +++ b/stdlib/source/library/lux/target/jvm/attribute.lux @@ -35,7 +35,7 @@ #length U4 #info about])) -(def: .public (info_equivalence Equivalence<about>) +(def .public (info_equivalence Equivalence<about>) (All (_ about) (-> (Equivalence about) (Equivalence (Info about)))) @@ -44,7 +44,7 @@ //unsigned.equivalence Equivalence<about>)) -(def: (info_writer writer) +(def (info_writer writer) (All (_ about) (-> (Writer about) (Writer (Info about)))) @@ -67,7 +67,7 @@ <Code>) ) -(def: .public equivalence +(def .public equivalence (Equivalence Attribute) (equivalence.rec (function (_ equivalence) @@ -77,7 +77,7 @@ (info_equivalence //index.equivalence) )))) -(def: common_attribute_length +(def common_attribute_length (all n.+ ... u2 attribute_name_index; //unsigned.bytes/2 @@ -85,7 +85,7 @@ //unsigned.bytes/4 )) -(def: (length attribute) +(def (length attribute) (-> Attribute Nat) (case attribute (^.with_template [<tag>] @@ -96,19 +96,19 @@ [#Signature]))) ... TODO: Inline ASAP -(def: (constant' index @name) +(def (constant' index @name) (-> (Constant Any) (Index UTF8) Attribute) {#Constant [#name @name ... https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.2 #length (|> /constant.length //unsigned.u4 try.trusted) #info index]}) -(def: .public (constant index) +(def .public (constant index) (-> (Constant Any) (Resource Attribute)) (//pool#each (constant' index) (//pool.utf8 "ConstantValue"))) ... TODO: Inline ASAP -(def: (code' specification @name) +(def (code' specification @name) (-> Code (Index UTF8) Attribute) {#Code [#name @name ... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 @@ -118,26 +118,26 @@ try.trusted) #info specification]}) -(def: .public (code specification) +(def .public (code specification) (-> Code (Resource Attribute)) (//pool#each (code' specification) (//pool.utf8 "Code"))) ... TODO: Inline ASAP -(def: (signature' it @name) +(def (signature' it @name) (-> (Index UTF8) (Index UTF8) Attribute) {#Signature [#name @name ... https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.9 #length (|> //index.length //unsigned.u4 try.trusted) #info it]}) -(def: .public (signature it) +(def .public (signature it) (All (_ category) (-> (Signature category) (Resource Attribute))) (do [! //pool.monad] [it (|> it //signature.signature //pool.utf8)] (at ! each (signature' it) (//pool.utf8 "Signature")))) -(def: .public (writer it) +(def .public (writer it) (Writer Attribute) (case it {#Constant it} diff --git a/stdlib/source/library/lux/target/jvm/attribute/code.lux b/stdlib/source/library/lux/target/jvm/attribute/code.lux index cc795b920..835b6726a 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code.lux @@ -29,7 +29,7 @@ #exception_table (Sequence Exception) #attributes (Sequence Attribute)])) -(def: .public (length length code) +(def .public (length length code) (All (_ Attribute) (-> (-> Attribute Nat) (Code Attribute) Nat)) (all n.+ ... u2 max_stack; @@ -54,7 +54,7 @@ (sequence#each length) (sequence#mix n.+ 0)))) -(def: .public (equivalence attribute_equivalence) +(def .public (equivalence attribute_equivalence) (All (_ attribute) (-> (Equivalence attribute) (Equivalence (Code attribute)))) (all product.equivalence @@ -65,7 +65,7 @@ )) ... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 -(def: .public (writer writer code) +(def .public (writer writer code) (All (_ Attribute) (-> (Writer Attribute) (Writer (Code Attribute)))) (all binaryF#composite ... u2 max_stack; diff --git a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux index b71573669..f71d52cfd 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/code/exception.lux @@ -26,7 +26,7 @@ #handler Address #catch (Index Class)])) -(def: .public equivalence +(def .public equivalence (Equivalence Exception) (all product.equivalence ////address.equivalence @@ -36,7 +36,7 @@ )) ... https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.3 -(def: .public length +(def .public length Nat (all n.+ ... u2 start_pc; @@ -49,7 +49,7 @@ ////unsigned.bytes/2 )) -(def: .public writer +(def .public writer (Writer Exception) (all \\format.and ////address.writer diff --git a/stdlib/source/library/lux/target/jvm/attribute/constant.lux b/stdlib/source/library/lux/target/jvm/attribute/constant.lux index 6e20c2ad1..34c8582ca 100644 --- a/stdlib/source/library/lux/target/jvm/attribute/constant.lux +++ b/stdlib/source/library/lux/target/jvm/attribute/constant.lux @@ -15,13 +15,13 @@ (type: .public (Constant a) (Index (Value a))) -(def: .public equivalence +(def .public equivalence (All (_ a) (Equivalence (Constant a))) ///index.equivalence) -(def: .public length +(def .public length ///index.length) -(def: .public writer +(def .public writer (All (_ a) (Writer (Constant a))) ///index.writer) diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index 882c0dfdf..99901a4a3 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -64,7 +64,7 @@ #next Label #known Resolver])) -(def: fresh +(def fresh Tracker [#program_counter /address.start #next 0 @@ -73,16 +73,16 @@ (type: .public Relative (-> Resolver (Try [(Sequence Exception) Instruction]))) -(def: no_exceptions +(def no_exceptions (Sequence Exception) sequence.empty) -(def: relative#identity +(def relative#identity Relative (function (_ _) {try.#Success [..no_exceptions _.empty]})) -(def: try|do +(def try|do (template (_ <binding> <term> <then>) [(.case <term> {try.#Success <binding>} @@ -91,11 +91,11 @@ failure (as_expected failure))])) -(def: try|in +(def try|in (template (_ <it>) [{try.#Success <it>}])) -(def: (relative#composite left right) +(def (relative#composite left right) (-> Relative Relative Relative) (cond (same? ..relative#identity left) right @@ -110,16 +110,16 @@ (try|in [(at sequence.monoid composite left_exceptions right_exceptions) (_#composite left_instruction right_instruction)]))))) -(def: relative_monoid +(def relative_monoid (Monoid Relative) (implementation - (def: identity ..relative#identity) - (def: composite ..relative#composite))) + (def identity ..relative#identity) + (def composite ..relative#composite))) (type: .public (Bytecode a) (+State Try [Pool Environment Tracker] (Writer Relative a))) -(def: .public new_label +(def .public new_label (Bytecode Label) (function (_ [pool environment tracker]) {try.#Success [[pool @@ -144,7 +144,7 @@ "Expected" (/stack.format expected) "Actual" (/stack.format actual))) -(def: .public (set? label) +(def .public (set? label) (-> Label (Bytecode (Maybe [Stack Address]))) (function (_ state) (let [[pool environment tracker] state] @@ -157,7 +157,7 @@ _ {.#None})]]}))) -(def: .public (acknowledged? label) +(def .public (acknowledged? label) (-> Label (Bytecode (Maybe Stack))) (function (_ state) (let [[pool environment tracker] state] @@ -170,7 +170,7 @@ _ {.#None})]]}))) -(def: .public stack +(def .public stack (Bytecode (Maybe Stack)) (function (_ state) (let [[pool environment tracker] state] @@ -185,7 +185,7 @@ tracker)] [..relative#identity []]]))] - (def: .public (set_label label) + (def .public (set_label label) (-> Label (Bytecode Any)) (function (_ [pool environment tracker]) (let [@here (the #program_counter tracker)] @@ -205,10 +205,10 @@ environment)) <success>)))))) -(def: .public functor +(def .public functor (Functor Bytecode) (implementation - (def: (each $ it) + (def (each $ it) (function (_ state) (case (it state) {try.#Success [state' [relative it]]} @@ -218,16 +218,16 @@ failure (as_expected failure)))))) -(def: .public monad +(def .public monad (Monad Bytecode) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in it) + (def (in it) (function (_ state) {try.#Success [state [relative#identity it]]})) - (def: (conjoint ^^it) + (def (conjoint ^^it) (function (_ state) (case (^^it state) {try.#Success [state' [left ^it]]} @@ -243,7 +243,7 @@ failure (as_expected failure)))))) -(def: .public (when_continuous it) +(def .public (when_continuous it) (-> (Bytecode Any) (Bytecode Any)) (do ..monad [stack ..stack] @@ -255,7 +255,7 @@ _ (in [])))) -(def: .public (when_acknowledged @ it) +(def .public (when_acknowledged @ it) (-> Label (Bytecode Any) (Bytecode Any)) (do ..monad [?@ (..acknowledged? @)] @@ -267,27 +267,27 @@ _ (in [])))) -(def: .public (failure error) +(def .public (failure error) (-> Text Bytecode) (function (_ _) {try.#Failure error})) -(def: .public (except exception value) +(def .public (except exception value) (All (_ e) (-> (exception.Exception e) e Bytecode)) (..failure (exception.error exception value))) -(def: .public (resolve environment bytecode) +(def .public (resolve environment bytecode) (All (_ a) (-> Environment (Bytecode a) (Resource [Environment (Sequence Exception) Instruction a]))) (function (_ pool) (<| (try|do [[pool environment tracker] [relative output]] (bytecode [pool environment ..fresh])) (try|do [exceptions instruction] (relative (the #known tracker))) (try|in [pool [environment exceptions instruction output]])))) -(def: (step estimator counter) +(def (step estimator counter) (-> Estimator Address (Try Address)) (/address.move (estimator counter) counter)) -(def: (bytecode consumption production registry [estimator bytecode] input) +(def (bytecode consumption production registry [estimator bytecode] input) (All (_ a) (-> U2 U2 Registry [Estimator (-> [a] Instruction)] a (Bytecode Any))) (function (_ [pool environment tracker]) (<| (try|do environment' (|> environment @@ -304,7 +304,7 @@ []]])))) (with_template [<name> <frames>] - [(def: <name> U2 + [(def <name> U2 (|> <frames> //unsigned.u2 try.trusted))] [$0 0] @@ -317,7 +317,7 @@ ) (with_template [<name> <registry>] - [(def: <name> Registry (|> <registry> //unsigned.u2 try.trusted /registry.registry))] + [(def <name> Registry (|> <registry> //unsigned.u2 try.trusted /registry.registry))] [@_ 0] [@0 1] @@ -328,7 +328,7 @@ ) (with_template [<name> <consumption> <production> <registry> <instruction>] - [(def: .public <name> + [(def .public <name> (Bytecode Any) (..bytecode <consumption> <production> @@ -511,7 +511,7 @@ [monitorexit $1 $0 @_ _.monitorexit] ) -(def: discontinuity! +(def discontinuity! (Bytecode Any) (function (_ [pool environment tracker]) (<| (try|do _ (/environment.stack environment)) @@ -522,7 +522,7 @@ []]])))) (with_template [<name> <consumption> <instruction>] - [(def: .public <name> + [(def .public <name> (Bytecode Any) (do ..monad [_ (..bytecode <consumption> $0 @_ <instruction> [])] @@ -538,11 +538,11 @@ [athrow $1 _.athrow] ) -(def: .public (bipush byte) +(def .public (bipush byte) (-> S1 (Bytecode Any)) (..bytecode $0 $1 @_ _.bipush [byte])) -(def: (lifted resource) +(def (lifted resource) (All (_ a) (-> (Resource a) (Bytecode a))) @@ -552,7 +552,7 @@ [..relative#identity output]])))) -(def: .public (string value) +(def .public (string value) (-> //constant.UTF8 (Bytecode Any)) (do ..monad [index (..lifted (//constant/pool.string value))] @@ -572,7 +572,7 @@ ("static" doubleToRawLongBits "manual" [double] long)) (with_template [<name> <type> <constructor> <constant> <wide> <to_lux> <specializations>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> <type> (Bytecode Any)) (case (|> value <to_lux>) (^.with_template [<special> <instruction>] @@ -599,7 +599,7 @@ [+5 _.iconst_5])] ) -(def: (arbitrary_float value) +(def (arbitrary_float value) (-> java/lang/Float (Bytecode Any)) (do ..monad [index (..lifted (//constant/pool.float (//constant.float value)))] @@ -610,16 +610,16 @@ {try.#Failure _} (..bytecode $0 $1 @_ _.ldc_w/float [index])))) -(def: float_bits +(def float_bits (-> java/lang/Float Int) (|>> java/lang/Float::floatToRawIntBits ffi.int_to_long (as Int))) -(def: negative_zero_float_bits +(def negative_zero_float_bits (|> -0.0 (as java/lang/Double) ffi.double_to_float ..float_bits)) -(def: .public (float value) +(def .public (float value) (-> java/lang/Float (Bytecode Any)) (if (i.= ..negative_zero_float_bits (..float_bits value)) @@ -634,7 +634,7 @@ _ (..arbitrary_float value)))) (with_template [<name> <type> <constructor> <constant> <wide> <to_lux> <specializations>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> <type> (Bytecode Any)) (case (|> value <to_lux>) (^.with_template [<special> <instruction>] @@ -651,21 +651,21 @@ [+1 _.lconst_1])] ) -(def: (arbitrary_double value) +(def (arbitrary_double value) (-> java/lang/Double (Bytecode Any)) (do ..monad [index (..lifted (//constant/pool.double (//constant.double (as Frac value))))] (..bytecode $0 $2 @_ _.ldc2_w/double [index]))) -(def: double_bits +(def double_bits (-> java/lang/Double Int) (|>> java/lang/Double::doubleToRawLongBits (as Int))) -(def: negative_zero_double_bits +(def negative_zero_double_bits (..double_bits (as java/lang/Double -0.0))) -(def: .public (double value) +(def .public (double value) (-> java/lang/Double (Bytecode Any)) (if (i.= ..negative_zero_double_bits (..double_bits value)) @@ -682,7 +682,7 @@ (exception.report "ID" (%.nat id))) -(def: (register id) +(def (register id) (-> Nat (Bytecode Register)) (case (//unsigned.u1 id) {try.#Success register} @@ -692,7 +692,7 @@ (..except ..invalid_register [id]))) (with_template [<for> <size> <name> <general> <specials>] - [(def: .public (<name> local) + [(def .public (<name> local) (-> Nat (Bytecode Any)) (with_expansions [<specials>' (template.spliced <specials>)] (`` (case local @@ -732,7 +732,7 @@ ) (with_template [<for> <size> <name> <general> <specials>] - [(def: .public (<name> local) + [(def .public (<name> local) (-> Nat (Bytecode Any)) (with_expansions [<specials>' (template.spliced <specials>)] (`` (case local @@ -772,7 +772,7 @@ ) (with_template [<consumption> <production> <name> <instruction> <input>] - [(def: .public <name> + [(def .public <name> (-> <input> (Bytecode Any)) (..bytecode <consumption> <production> @_ <instruction>))] @@ -796,7 +796,7 @@ (Either Big_Jump Jump)) -(def: (jump @from @to) +(def (jump @from @to) (-> Address Address (Try Any_Jump)) (<| (try|do jump (try#each //signed.value (/address.jump @from @to))) @@ -812,7 +812,7 @@ (exception.report "Label" (%.nat label))) -(def: (resolve_label label resolver) +(def (resolve_label label resolver) (-> Label Resolver (Try [Stack Address])) (case (dictionary.value label resolver) {.#Some [actual {.#Some address}]} @@ -825,7 +825,7 @@ _ (exception.except ..unknown_label [label]))) -(def: (acknowledge_label stack label tracker) +(def (acknowledge_label stack label tracker) (-> Stack Label Tracker Tracker) (case (dictionary.value label (the #known tracker)) {.#Some _} @@ -836,7 +836,7 @@ (revised #known (dictionary.has label [stack {.#None}]) tracker))) (with_template [<consumption> <name> <instruction>] - [(def: .public (<name> label) + [(def .public (<name> label) (-> Label (Bytecode Any)) (let [[estimator bytecode] <instruction>] (function (_ [pool environment tracker]) @@ -886,7 +886,7 @@ ) (with_template [<name> <instruction> <on_long_jump> <on_short_jump>] - [(def: .public (<name> label) + [(def .public (<name> label) (-> Label (Bytecode Any)) (let [[estimator bytecode] <instruction>] (function (_ [pool environment tracker]) @@ -928,7 +928,7 @@ (try|in [..no_exceptions (bytecode (/jump.lifted jump))])] ) -(def: (big_jump jump) +(def (big_jump jump) (-> Any_Jump Big_Jump) (case jump {.#Left big} @@ -939,7 +939,7 @@ (exception: .public invalid_tableswitch) -(def: .public (tableswitch minimum default [at_minimum afterwards]) +(def .public (tableswitch minimum default [at_minimum afterwards]) (-> S4 Label [Label (List Label)] (Bytecode Any)) (let [[estimator bytecode] _.tableswitch] (function (_ [pool environment tracker]) @@ -977,7 +977,7 @@ (exception: .public invalid_lookupswitch) -(def: .public (lookupswitch default cases) +(def .public (lookupswitch default cases) (-> Label (List [S4 Label]) (Bytecode Any)) (let [cases (list.sorted (function (_ [left _] [right _]) (i.< (//signed.value left) @@ -1016,13 +1016,13 @@ (exception.except ..invalid_lookupswitch [])))) []]])))))) -(def: reflection +(def reflection (All (_ category) (-> (Type (<| Return' Value' category)) Text)) (|>> type.reflection reflection.reflection)) (with_template [<consumption> <production> <name> <category> <instruction>] - [(def: .public (<name> class) + [(def .public (<name> class) (-> (Type <category>) (Bytecode Any)) (do ..monad [... TODO: Make sure it's impossible to have indexes greater than U2. @@ -1035,7 +1035,7 @@ [$1 $1 instanceof Object _.instanceof] ) -(def: .public (iinc register increase) +(def .public (iinc register increase) (-> Nat U1 (Bytecode Any)) (do ..monad [register (..register register)] @@ -1045,7 +1045,7 @@ (exception.report "Class" (..reflection class))) -(def: .public (multianewarray class dimensions) +(def .public (multianewarray class dimensions) (-> (Type Object) U1 (Bytecode Any)) (do ..monad [_ (is (Bytecode Any) @@ -1055,7 +1055,7 @@ index (..lifted (//constant/pool.class (//name.internal (..reflection class))))] (..bytecode (//unsigned.lifted/2 dimensions) $1 @_ _.multianewarray [index dimensions]))) -(def: (type_size type) +(def (type_size type) (-> (Type Return) Nat) (cond (same? type.void type) 0 @@ -1068,7 +1068,7 @@ 1)) (with_template [<static?> <name> <instruction> <method>] - [(def: .public (<name> class method type) + [(def .public (<name> class method type) (-> (Type Class) Text (Type Method) (Bytecode Any)) (let [[type_variables inputs output exceptions] (parser.method type)] (do ..monad @@ -1094,7 +1094,7 @@ ) (with_template [<consumption> <name> <1> <2>] - [(def: .public (<name> class field type) + [(def .public (<name> class field type) (-> (Type Class) Text (Type Value) (Bytecode Any)) (do ..monad [index (<| ..lifted @@ -1111,7 +1111,7 @@ ) (with_template [<name> <consumption/1> <1> <consumption/2> <2>] - [(def: .public (<name> class field type) + [(def .public (<name> class field type) (-> (Type Class) Text (Type Value) (Bytecode Any)) (do [! ..monad] [index (<| ..lifted @@ -1133,7 +1133,7 @@ "Start" (|> start /address.value //unsigned.value %.nat) "End" (|> end /address.value //unsigned.value %.nat))) -(def: .public (try @start @end @handler catch) +(def .public (try @start @end @handler catch) (-> Label Label Label (Type Class) (Bytecode Any)) (do ..monad [@catch (..lifted (//constant/pool.class (//name.internal (..reflection catch))))] @@ -1157,7 +1157,7 @@ _.empty]))) []]]}))) -(def: .public (composite pre post) +(def .public (composite pre post) (All (_ pre post) (-> (Bytecode pre) (Bytecode post) (Bytecode post))) (function (_ state) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/address.lux b/stdlib/source/library/lux/target/jvm/bytecode/address.lux index ddb1331dc..5c2dd04d2 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/address.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/address.lux @@ -26,49 +26,49 @@ (primitive .public Address U2 - (def: .public value + (def .public value (-> Address U2) (|>> representation)) - (def: .public start + (def .public start Address (|> 0 ///unsigned.u2 try.trusted abstraction)) - (def: .public (move distance) + (def .public (move distance) (-> U2 (-> Address (Try Address))) (|>> representation (///unsigned.+/2 distance) (at try.functor each (|>> abstraction)))) - (def: with_sign + (def with_sign (-> Address (Try S4)) (|>> representation ///unsigned.value .int ///signed.s4)) - (def: .public (jump from to) + (def .public (jump from to) (-> Address Address (Try Big_Jump)) (do try.monad [from (with_sign from) to (with_sign to)] (///signed.-/4 from to))) - (def: .public (after? reference subject) + (def .public (after? reference subject) (-> Address Address Bit) (n.> (|> reference representation ///unsigned.value) (|> subject representation ///unsigned.value))) - (def: .public equivalence + (def .public equivalence (Equivalence Address) (implementation - (def: (= reference subject) + (def (= reference subject) (at ///unsigned.equivalence = (representation reference) (representation subject))))) - (def: .public writer + (def .public writer (Writer Address) (|>> representation ///unsigned.writer/2)) - (def: .public format + (def .public format (Format Address) (|>> representation ///unsigned.value %.nat)) ) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux index cc3ff123c..14e8d5543 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment.lux @@ -23,7 +23,7 @@ #stack (Maybe Stack)])) (with_template [<name> <limit>] - [(def: .public (<name> type) + [(def .public (<name> type) (-> (Type Method) (Try Environment)) (do try.monad [limit (<limit> type)] @@ -37,13 +37,13 @@ (type: .public Condition (-> Environment (Try Environment))) -(def: .public monoid +(def .public monoid (Monoid Condition) (implementation - (def: identity + (def identity (|>> {try.#Success})) - (def: (composite left right) + (def (composite left right) (function (_ environment) (do try.monad [environment (left environment)] @@ -51,7 +51,7 @@ (exception: .public discontinuity) -(def: .public (stack environment) +(def .public (stack environment) (-> Environment (Try Stack)) (case (the ..#stack environment) {.#Some stack} @@ -60,7 +60,7 @@ {.#None} (exception.except ..discontinuity []))) -(def: .public discontinue +(def .public discontinue (-> Environment Environment) (.has ..#stack {.#None})) @@ -70,7 +70,7 @@ "Expected" (/stack.format expected) "Actual" (/stack.format actual))) -(def: .public (continue expected environment) +(def .public (continue expected environment) (-> Stack Environment (Try [Stack Environment])) (case (the ..#stack environment) {.#Some actual} @@ -81,7 +81,7 @@ {.#None} {try.#Success [expected (.has ..#stack {.#Some expected} environment)]})) -(def: .public (consumes amount) +(def .public (consumes amount) (-> U2 Condition) ... TODO: Revisit this definition once lenses/optics have been implemented, ... since it can probably be simplified with them. @@ -91,7 +91,7 @@ current (/stack.pop amount previous)] (in (.has ..#stack {.#Some current} environment))))) -(def: .public (produces amount) +(def .public (produces amount) (-> U2 Condition) (function (_ environment) (do try.monad @@ -104,7 +104,7 @@ (.has ..#stack {.#Some current}) (.has [..#limit /limit.#stack] limit)))))) -(def: .public (has registry) +(def .public (has registry) (-> Registry Condition) (|>> (revised [..#limit /limit.#registry] (/registry.has registry)) {try.#Success})) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux index 7702e24e7..261e9a5ce 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit.lux @@ -26,7 +26,7 @@ #registry Registry])) (with_template [<name> <registry>] - [(def: .public (<name> type) + [(def .public (<name> type) (-> (Type Method) (Try Limit)) (do try.monad [registry (<registry> type)] @@ -37,21 +37,21 @@ [virtual /registry.virtual] ) -(def: .public length +(def .public length (all n.+ ... u2 max_stack; /stack.length ... u2 max_locals; /registry.length)) -(def: .public equivalence +(def .public equivalence (Equivalence Limit) (all product.equivalence /stack.equivalence /registry.equivalence )) -(def: .public (writer limit) +(def .public (writer limit) (Writer Limit) (all \\format#composite (/stack.writer (the #stack limit)) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux index 6e3642501..3aae9a289 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/registry.lux @@ -25,17 +25,17 @@ (type: .public Register U1) -(def: normal 1) -(def: wide 2) +(def normal 1) +(def wide 2) (primitive .public Registry U2 - (def: .public registry + (def .public registry (-> U2 Registry) (|>> abstraction)) - (def: (minimal type) + (def (minimal type) (-> (Type Method) Nat) (let [[type_variables inputs output exceptions] (/////type/parser.method type)] (|> inputs @@ -47,7 +47,7 @@ (list#mix n.+ 0)))) (with_template [<start> <name>] - [(def: .public <name> + [(def .public <name> (-> (Type Method) (Try Registry)) (|>> ..minimal (n.+ <start>) @@ -58,24 +58,24 @@ [1 virtual] ) - (def: .public equivalence + (def .public equivalence (Equivalence Registry) (at equivalence.functor each (|>> representation) /////unsigned.equivalence)) - (def: .public writer + (def .public writer (Writer Registry) (|>> representation /////unsigned.writer/2)) - (def: .public (has needed) + (def .public (has needed) (-> Registry Registry Registry) (|>> representation (/////unsigned.max/2 (representation needed)) abstraction)) (with_template [<name> <extra>] - [(def: .public <name> + [(def .public <name> (-> Register Registry) (let [extra (|> <extra> /////unsigned.u2 try.trusted)] (|>> /////unsigned.lifted/2 @@ -88,5 +88,5 @@ ) ) -(def: .public length +(def .public length /////unsigned.bytes/2) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux index a3cec4224..59c3c50ce 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/environment/limit/stack.lux @@ -21,7 +21,7 @@ U2 (with_template [<frames> <name>] - [(def: .public <name> + [(def .public <name> Stack (|> <frames> /////unsigned.u2 maybe.trusted abstraction))] @@ -29,22 +29,22 @@ [1 catch] ) - (def: .public equivalence + (def .public equivalence (Equivalence Stack) (at equivalence.functor each (|>> representation) /////unsigned.equivalence)) - (def: .public writer + (def .public writer (Writer Stack) (|>> representation /////unsigned.writer/2)) - (def: stack + (def stack (-> U2 Stack) (|>> abstraction)) (with_template [<op> <name>] - [(def: .public (<name> amount) + [(def .public (<name> amount) (-> U2 (-> Stack (Try Stack))) (|>> representation (<op> amount) @@ -54,16 +54,16 @@ [/////unsigned.-/2 pop] ) - (def: .public (max left right) + (def .public (max left right) (-> Stack Stack Stack) (abstraction (/////unsigned.max/2 (representation left) (representation right)))) - (def: .public format + (def .public format (Format Stack) (|>> representation /////unsigned.value %.nat)) ) -(def: .public length +(def .public length /////unsigned.bytes/2) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index 9345f2ec2..ca4dfcff6 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -44,18 +44,18 @@ (type: .public Estimator (-> Address Size)) -(def: fixed +(def fixed (-> Size Estimator) function.constant) (type: .public Instruction (-> Specification Specification)) -(def: .public empty +(def .public empty Instruction function.identity) -(def: .public result +(def .public result (-> Instruction Specification) (function.on \\format.no_op)) @@ -63,7 +63,7 @@ Nat) (with_template [<size> <name>] - [(def: <name> Size (|> <size> ///unsigned.u2 try.trusted))] + [(def <name> Size (|> <size> ///unsigned.u2 try.trusted))] [1 opcode_size] [1 register_size] @@ -73,14 +73,14 @@ [4 integer_size] ) -(def: (nullary' opcode) +(def (nullary' opcode) (-> Opcode Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value ..opcode_size) offset) (binary.has_8! offset opcode binary)])) -(def: nullary +(def nullary [Estimator (-> Opcode Instruction)] [(..fixed ..opcode_size) (function (_ opcode [size mutation]) @@ -89,7 +89,7 @@ (|>> mutation ((nullary' opcode)))])]) (with_template [<name> <size>] - [(def: <name> + [(def <name> Size (|> ..opcode_size (///unsigned.+/2 <size>) @@ -102,7 +102,7 @@ (with_template [<shift> <name> <inputT> <writer> <unwrap>] [(with_expansions [<private> (template.symbol ["'" <name>])] - (def: (<private> opcode input0) + (def (<private> opcode input0) (-> Opcode <inputT> Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value <shift>) offset) @@ -111,7 +111,7 @@ (<writer> (n.+ (///unsigned.value ..opcode_size) offset) (<unwrap> input0)))])) - (def: <name> + (def <name> [Estimator (-> Opcode <inputT> Instruction)] [(..fixed <shift>) (function (_ opcode input0 [size mutation]) @@ -126,7 +126,7 @@ (with_template [<shift> <name> <inputT> <writer>] [(with_expansions [<private> (template.symbol ["'" <name>])] - (def: (<private> opcode input0) + (def (<private> opcode input0) (-> Opcode <inputT> Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value <shift>) offset) @@ -135,7 +135,7 @@ (<writer> (n.+ (///unsigned.value ..opcode_size) offset) (///signed.value input0)))])) - (def: <name> + (def <name> [Estimator (-> Opcode <inputT> Instruction)] [(..fixed <shift>) (function (_ opcode input0 [size mutation]) @@ -146,13 +146,13 @@ [..size/2 unary/2' S2 binary.has_16!] ) -(def: size/11 +(def size/11 Size (|> ..opcode_size (///unsigned.+/2 ..register_size) try.trusted (///unsigned.+/2 ..byte_size) try.trusted)) -(def: (binary/11' opcode input0 input1) +(def (binary/11' opcode input0 input1) (-> Opcode U1 U1 Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value ..size/11) offset) @@ -163,20 +163,20 @@ (binary.has_8! (n.+ (///unsigned.value ..size/1) offset) (///unsigned.value input1)))])) -(def: binary/11 +(def binary/11 [Estimator (-> Opcode U1 U1 Instruction)] [(..fixed ..size/11) (function (_ opcode input0 input1 [size mutation]) [(n.+ (///unsigned.value ..size/11) size) (|>> mutation ((binary/11' opcode input0 input1)))])]) -(def: size/21 +(def size/21 Size (|> ..opcode_size (///unsigned.+/2 ..index_size) try.trusted (///unsigned.+/2 ..byte_size) try.trusted)) -(def: (binary/21' opcode input0 input1) +(def (binary/21' opcode input0 input1) (-> Opcode U2 U1 Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value ..size/21) offset) @@ -187,21 +187,21 @@ (binary.has_8! (n.+ (///unsigned.value ..size/2) offset) (///unsigned.value input1)))])) -(def: binary/21 +(def binary/21 [Estimator (-> Opcode U2 U1 Instruction)] [(..fixed ..size/21) (function (_ opcode input0 input1 [size mutation]) [(n.+ (///unsigned.value ..size/21) size) (|>> mutation ((binary/21' opcode input0 input1)))])]) -(def: size/211 +(def size/211 Size (|> ..opcode_size (///unsigned.+/2 ..index_size) try.trusted (///unsigned.+/2 ..byte_size) try.trusted (///unsigned.+/2 ..byte_size) try.trusted)) -(def: (trinary/211' opcode input0 input1 input2) +(def (trinary/211' opcode input0 input1 input2) (-> Opcode U2 U1 U1 Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value ..size/211) offset) @@ -214,7 +214,7 @@ (binary.has_8! (n.+ (///unsigned.value ..size/21) offset) (///unsigned.value input2)))])) -(def: trinary/211 +(def trinary/211 [Estimator (-> Opcode U2 U1 U1 Instruction)] [(..fixed ..size/211) (function (_ opcode input0 input1 input2 [size mutation]) @@ -224,12 +224,12 @@ (primitive .public Primitive_Array_Type U1 - (def: code + (def code (-> Primitive_Array_Type U1) (|>> representation)) (with_template [<code> <name>] - [(def: .public <name> + [(def .public <name> (|> <code> ///unsigned.u1 try.trusted abstraction))] [04 t_boolean] @@ -481,7 +481,7 @@ [<input_name>] <inputs>')] - (def: .public <name> + (def .public <name> [Estimator (-> [<input_types>] Instruction)] (let [[estimator <arity>'] <arity>] [estimator @@ -564,7 +564,7 @@ [["B9" invokeinterface [[index (Index (Reference Method))] [count U1] [output_count U1]] [(///index.value index) count (try.trusted (///unsigned.u1 0))]]]] )) -(def: (switch_padding offset) +(def (switch_padding offset) (-> Nat Nat) (let [parameter_start (n.+ (///unsigned.value ..opcode_size) offset)] @@ -572,7 +572,7 @@ (n.- (n.% 4 parameter_start) 4)))) -(def: .public tableswitch +(def .public tableswitch [(-> Nat Estimator) (-> S4 Big_Jump [Big_Jump (List Big_Jump)] Instruction)] (let [estimator (is (-> Nat Estimator) @@ -636,7 +636,7 @@ size) (|>> mutation tableswitch_mutation)]))))])) -(def: .public lookupswitch +(def .public lookupswitch [(-> Nat Estimator) (-> Big_Jump (List [S4 Big_Jump]) Instruction)] (let [case_size (n.+ (///unsigned.value ..integer_size) @@ -694,10 +694,10 @@ size) (|>> mutation lookupswitch_mutation)]))))])) -(def: .public monoid +(def .public monoid (Monoid Instruction) (implementation - (def: identity ..empty) + (def identity ..empty) - (def: (composite left right) + (def (composite left right) (|>> left right)))) diff --git a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux index 7d608a8e5..676930f65 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux @@ -13,17 +13,17 @@ (type: .public Jump S2) -(def: .public equivalence +(def .public equivalence (Equivalence Jump) ///signed.equivalence) -(def: .public writer +(def .public writer (Writer Jump) ///signed.writer/2) (type: .public Big_Jump S4) -(def: .public lifted +(def .public lifted (-> Jump Big_Jump) ///signed.lifted/4) diff --git a/stdlib/source/library/lux/target/jvm/class.lux b/stdlib/source/library/lux/target/jvm/class.lux index f93320b4c..cbbc47502 100644 --- a/stdlib/source/library/lux/target/jvm/class.lux +++ b/stdlib/source/library/lux/target/jvm/class.lux @@ -57,7 +57,7 @@ ["4000" enum] ) -(def: .public equivalence +(def .public equivalence (Equivalence Class) (all product.equivalence //unsigned.equivalence @@ -72,7 +72,7 @@ (sequence.equivalence //method.equivalence) (sequence.equivalence //attribute.equivalence))) -(def: (install_classes this super interfaces) +(def (install_classes this super interfaces) (-> Internal Internal (List Internal) (Resource [(Index //constant.Class) (Index //constant.Class) (Sequence (Index //constant.Class))])) (do [! //pool.monad] @@ -87,7 +87,7 @@ interfaces))] (in [@this @super @interfaces]))) -(def: .public (class version modifier +(def .public (class version modifier this signature super interfaces fields methods attributes) (-> Major (Modifier Class) @@ -127,7 +127,7 @@ {.#None} attributes)]))) -(def: .public (writer class) +(def .public (writer class) (Writer Class) (`` (all binaryF#composite (~~ (with_template [<writer> <slot>] diff --git a/stdlib/source/library/lux/target/jvm/constant.lux b/stdlib/source/library/lux/target/jvm/constant.lux index 8539fbf13..ebeccfaa4 100644 --- a/stdlib/source/library/lux/target/jvm/constant.lux +++ b/stdlib/source/library/lux/target/jvm/constant.lux @@ -36,28 +36,28 @@ (type: .public UTF8 Text) -(def: utf8_writer +(def utf8_writer (Writer UTF8) binaryF.utf8_16) (primitive .public Class (Index UTF8) - (def: .public index + (def .public index (-> Class (Index UTF8)) (|>> representation)) - (def: .public class + (def .public class (-> (Index UTF8) Class) (|>> abstraction)) - (def: .public class_equivalence + (def .public class_equivalence (Equivalence Class) (at equivalence.functor each ..index //index.equivalence)) - (def: class_writer + (def class_writer (Writer Class) (|>> representation //index.writer)) ) @@ -66,10 +66,10 @@ "[1]::[0]" ("static" floatToRawIntBits "manual" [float] int)) -(def: .public float_equivalence +(def .public float_equivalence (Equivalence java/lang/Float) (implementation - (def: (= parameter subject) + (def (= parameter subject) (for @.old ("jvm feq" parameter subject) @@ -85,11 +85,11 @@ (primitive .public (Value kind) kind - (def: .public value + (def .public value (All (_ kind) (-> (Value kind) kind)) (|>> representation)) - (def: .public (value_equivalence Equivalence<kind>) + (def .public (value_equivalence Equivalence<kind>) (All (_ kind) (-> (Equivalence kind) (Equivalence (Value kind)))) @@ -101,7 +101,7 @@ [(type: .public <type> (Value <marker>)) - (def: .public <constructor> + (def .public <constructor> (-> <marker> <type>) (|>> abstraction))] @@ -113,7 +113,7 @@ ) (with_template [<writer_name> <type> <write> <writer>] - [(def: <writer_name> + [(def <writer_name> (Writer <type>) (`` (|>> representation (~~ (template.spliced <write>)) @@ -138,13 +138,13 @@ #name_and_type (Index (Name_And_Type of))])) (with_template [<type> <equivalence> <writer>] - [(def: .public <equivalence> + [(def .public <equivalence> (Equivalence (<type> Any)) (all product.equivalence //index.equivalence //index.equivalence)) - (def: <writer> + (def <writer> (Writer (<type> Any)) (all binaryF.and //index.writer @@ -168,7 +168,7 @@ {#Interface_Method (Reference //category.Method)} {#Name_And_Type (Name_And_Type Any)})) -(def: .public (size constant) +(def .public (size constant) (-> Constant Nat) (case constant (^.or {#Long _} {#Double _}) @@ -177,12 +177,12 @@ _ 1)) -(def: .public equivalence +(def .public equivalence (Equivalence Constant) ... TODO: Delete the explicit "implementation" and use the combinator ... version below as soon as the new format for variants is implemented. (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag> <equivalence>] [[{<tag> reference} {<tag> sample}] @@ -223,7 +223,7 @@ ... ) ) -(def: .public writer +(def .public writer (Writer Constant) (with_expansions [<constants> (these [#UTF8 /tag.utf8 ..utf8_writer] [#Integer /tag.integer ..integer_writer] diff --git a/stdlib/source/library/lux/target/jvm/constant/pool.lux b/stdlib/source/library/lux/target/jvm/constant/pool.lux index b953600bf..787af5c99 100644 --- a/stdlib/source/library/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/library/lux/target/jvm/constant/pool.lux @@ -35,7 +35,7 @@ (type: .public Pool [Index (Sequence [Index Constant])]) -(def: .public equivalence +(def .public equivalence (Equivalence Pool) (product.equivalence //index.equivalence (sequence.equivalence (product.equivalence //index.equivalence @@ -44,10 +44,10 @@ (type: .public (Resource a) (+State Try Pool a)) -(def: .public functor +(def .public functor (Functor Resource) (implementation - (def: (each $ it) + (def (each $ it) (|>> it (pipe.case {try.#Success [state output]} @@ -57,16 +57,16 @@ failure (as_expected failure)))))) -(def: .public monad +(def .public monad (Monad Resource) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in it) + (def (in it) (function (_ state) {try.#Success [state it]})) - (def: (conjoint it) + (def (conjoint it) (function (_ state) (case (it state) {try.#Success [state' it']} @@ -76,7 +76,7 @@ failure (as_expected failure)))))) -(def: try|each +(def try|each (template (_ <binding> <value> <body>) [(case <value> {try.#Success <binding>} @@ -86,11 +86,11 @@ failure (as_expected failure))])) -(def: try|in +(def try|in (template (_ <it>) [{try.#Success <it>}])) -(def: !add +(def !add (template (_ <state> <tag> <equivalence> <value>) [(let [[current pool] <state> <value>' <value>] @@ -120,12 +120,12 @@ (sequence.suffix [current new] pool)] current]))))))])) -(def: /|do +(def /|do (template (_ <state> <body>) [(function (_ <state>) <body>)])) -(def: /|each +(def /|each (template (_ <state> <binding> <value> <body>) [(case (<value> <state>) {try.#Success [<state> <binding>]} @@ -139,7 +139,7 @@ (-> of (Resource (Index of)))) (with_template [<name> <type> <tag> <equivalence>] - [(def: .public (<name> value) + [(def .public (<name> value) (Adder <type>) (<| (/|do %) (!add % <tag> <equivalence> value)))] @@ -151,21 +151,21 @@ [utf8 UTF8 //.#UTF8 text.equivalence] ) -(def: .public (string value) +(def .public (string value) (-> Text (Resource (Index String))) (<| (/|do %) (/|each % @value (utf8 value)) (let [value (//.string @value)]) (!add % //.#String (//.value_equivalence //index.equivalence) value))) -(def: .public (class name) +(def .public (class name) (-> Internal (Resource (Index Class))) (<| (/|do %) (/|each % @name (utf8 (//name.read name))) (let [value (//.class @name)]) (!add % //.#Class //.class_equivalence value))) -(def: .public (descriptor value) +(def .public (descriptor value) (All (_ kind) (-> (Descriptor kind) (Resource (Index (Descriptor kind))))) @@ -178,7 +178,7 @@ [#name UTF8 #descriptor (Descriptor of)])) -(def: .public (name_and_type [name descriptor]) +(def .public (name_and_type [name descriptor]) (All (_ of) (-> (Member of) (Resource (Index (Name_And_Type of))))) (<| (/|do %) @@ -187,7 +187,7 @@ (!add % //.#Name_And_Type //.name_and_type_equivalence [//.#name @name //.#descriptor @descriptor]))) (with_template [<name> <tag> <of>] - [(def: .public (<name> class member) + [(def .public (<name> class member) (-> External (Member <of>) (Resource (Index (Reference <of>)))) (<| (/|do %) (/|each % @class (..class (//name.internal class))) @@ -199,11 +199,11 @@ [interface_method //.#Interface_Method Method] ) -(def: !index +(def !index (template (_ <index>) [(|> <index> //index.value //unsigned.value)])) -(def: .public writer +(def .public writer (Writer Pool) (function (_ [next pool]) (sequence#mix (function (_ [_index post] pre) @@ -211,7 +211,7 @@ (\\format.bits_16 (!index next)) pool))) -(def: .public empty +(def .public empty Pool [(|> 1 //unsigned.u2 try.trusted //index.index) sequence.empty]) diff --git a/stdlib/source/library/lux/target/jvm/constant/tag.lux b/stdlib/source/library/lux/target/jvm/constant/tag.lux index 2ac10790f..58684f493 100644 --- a/stdlib/source/library/lux/target/jvm/constant/tag.lux +++ b/stdlib/source/library/lux/target/jvm/constant/tag.lux @@ -17,15 +17,15 @@ (primitive .public Tag U1 - (def: .public equivalence + (def .public equivalence (Equivalence Tag) (implementation - (def: (= reference sample) + (def (= reference sample) (u1//= (representation reference) (representation sample))))) (with_template [<code> <name>] - [(def: .public <name> + [(def .public <name> Tag (|> <code> ///unsigned.u1 try.trusted abstraction))] @@ -45,7 +45,7 @@ [18 invoke_dynamic] ) - (def: .public writer + (def .public writer (Writer Tag) (|>> representation ///unsigned.writer/1)) ) diff --git a/stdlib/source/library/lux/target/jvm/encoding/name.lux b/stdlib/source/library/lux/target/jvm/encoding/name.lux index 2a322bace..068c11a36 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/name.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/name.lux @@ -7,8 +7,8 @@ [type [primitive (.except)]]]]) -(def: .public internal_separator "/") -(def: .public external_separator ".") +(def .public internal_separator "/") +(def .public external_separator ".") (type: .public External Text) @@ -16,26 +16,26 @@ (primitive .public Internal Text - (def: .public internal + (def .public internal (-> External Internal) (|>> (text.replaced ..external_separator ..internal_separator) abstraction)) - (def: .public read + (def .public read (-> Internal Text) (|>> representation)) - (def: .public external + (def .public external (-> Internal External) (|>> representation (text.replaced ..internal_separator ..external_separator)))) -(def: .public safe +(def .public safe (-> Text External) (|>> ..internal ..external)) -(def: .public (qualify package class) +(def .public (qualify package class) (-> Text External External) (format (..safe package) ..external_separator class)) diff --git a/stdlib/source/library/lux/target/jvm/encoding/signed.lux b/stdlib/source/library/lux/target/jvm/encoding/signed.lux index 822e420b2..b00ff6ba3 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/signed.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/signed.lux @@ -25,21 +25,21 @@ (primitive .public (Signed brand) Int - (def: .public value + (def .public value (-> (Signed Any) Int) (|>> representation)) - (def: .public equivalence + (def .public equivalence (All (_ brand) (Equivalence (Signed brand))) (implementation - (def: (= reference sample) + (def (= reference sample) (i.= (representation reference) (representation sample))))) - (def: .public order + (def .public order (All (_ brand) (Order (Signed brand))) (implementation - (def: equivalence ..equivalence) - (def: (< reference sample) + (def equivalence ..equivalence) + (def (< reference sample) (i.< (representation reference) (representation sample))))) (exception: .public (value_exceeds_the_scope [value Int @@ -53,18 +53,18 @@ (primitive <raw> Any) (type: .public <name> (Signed <raw>))) - (def: .public <size> <bytes>) + (def .public <size> <bytes>) - (def: .public <maximum> + (def .public <maximum> <name> (|> <bytes> (n.* i64.bits_per_byte) -- i64.mask abstraction)) - (def: .public <minimum> + (def .public <minimum> <name> (let [it (representation <maximum>)] (abstraction (-- (i.- it +0))))) - (def: .public <constructor> + (def .public <constructor> (-> Int (Try <name>)) (let [positive (representation <maximum>) negative (i64.not positive)] @@ -77,7 +77,7 @@ (exception.except ..value_exceeds_the_scope [value <size>]))))) (with_template [<abstract_operation> <concrete_operation>] - [(def: .public (<abstract_operation> parameter subject) + [(def .public (<abstract_operation> parameter subject) (-> <name> <name> (Try <name>)) (<constructor> (<concrete_operation> (representation parameter) @@ -93,7 +93,7 @@ ) (with_template [<name> <from> <to>] - [(def: .public <name> + [(def .public <name> (-> <from> <to>) (|>> transmutation))] @@ -102,7 +102,7 @@ ) (with_template [<writer_name> <type> <writer>] - [(def: .public <writer_name> + [(def .public <writer_name> (Writer <type>) (|>> representation <writer>))] diff --git a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux index bdda3b8a5..0d2a16d52 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux @@ -24,22 +24,22 @@ (primitive .public (Unsigned brand) Nat - (def: .public value + (def .public value (-> (Unsigned Any) Nat) (|>> representation)) - (def: .public equivalence + (def .public equivalence (All (_ brand) (Equivalence (Unsigned brand))) (implementation - (def: (= reference sample) + (def (= reference sample) (n.= (representation reference) (representation sample))))) - (def: .public order + (def .public order (All (_ brand) (Order (Unsigned brand))) (implementation - (def: equivalence ..equivalence) - (def: (< reference sample) + (def equivalence ..equivalence) + (def (< reference sample) (n.< (representation reference) (representation sample))))) @@ -65,25 +65,25 @@ (primitive .public <raw> Any) (type: .public <name> (Unsigned <raw>))) - (def: .public <size> <bytes>) + (def .public <size> <bytes>) - (def: .public <maximum> + (def .public <maximum> <name> (|> <bytes> (n.* i64.bits_per_byte) i64.mask abstraction)) - (def: .public (<constructor> value) + (def .public (<constructor> value) (-> Nat (Try <name>)) (if (n.> (representation <maximum>) value) (exception.except ..value_exceeds_the_maximum [(symbol <name>) value <maximum>]) {try.#Success (abstraction value)})) - (def: .public (<+> parameter subject) + (def .public (<+> parameter subject) (-> <name> <name> (Try <name>)) (<constructor> (n.+ (representation parameter) (representation subject)))) - (def: .public (<-> parameter subject) + (def .public (<-> parameter subject) (-> <name> <name> (Try <name>)) (let [parameter' (representation parameter) subject' (representation subject)] @@ -91,7 +91,7 @@ (exception.except ..subtraction_cannot_yield_negative_value [(symbol <name>) parameter subject]) {try.#Success (abstraction (n.- parameter' subject'))}))) - (def: .public (<max> left right) + (def .public (<max> left right) (-> <name> <name> <name>) (abstraction (n.max (representation left) (representation right))))] @@ -102,7 +102,7 @@ ) (with_template [<name> <from> <to>] - [(def: .public <name> + [(def .public <name> (-> <from> <to>) (|>> transmutation))] @@ -111,7 +111,7 @@ ) (with_template [<writer_name> <type> <writer>] - [(def: .public <writer_name> + [(def .public <writer_name> (Writer <type>) (|>> representation <writer>))] diff --git a/stdlib/source/library/lux/target/jvm/field.lux b/stdlib/source/library/lux/target/jvm/field.lux index b41782db2..fa84b191b 100644 --- a/stdlib/source/library/lux/target/jvm/field.lux +++ b/stdlib/source/library/lux/target/jvm/field.lux @@ -41,7 +41,7 @@ ["4000" enum] ) -(def: .public equivalence +(def .public equivalence (Equivalence Field) (all product.equivalence modifier.equivalence @@ -49,7 +49,7 @@ //index.equivalence (sequence.equivalence //attribute.equivalence))) -(def: .public (writer field) +(def .public (writer field) (Writer Field) (`` (all binaryF#composite (~~ (with_template [<writer> <slot>] @@ -61,7 +61,7 @@ [(binaryF.sequence_16 //attribute.writer) #attributes])) ))) -(def: .public (field modifier name with_signature? type attributes) +(def .public (field modifier name with_signature? type attributes) (-> (Modifier Field) UTF8 Bit (Type Value) (Sequence Attribute) (Resource Field)) (do [! //constant/pool.monad] diff --git a/stdlib/source/library/lux/target/jvm/index.lux b/stdlib/source/library/lux/target/jvm/index.lux index e3421fd14..f21318b91 100644 --- a/stdlib/source/library/lux/target/jvm/index.lux +++ b/stdlib/source/library/lux/target/jvm/index.lux @@ -12,27 +12,27 @@ [encoding ["[1][0]" unsigned (.only U2)]]]) -(def: .public length +(def .public length //unsigned.bytes/2) (primitive .public (Index kind) U2 - (def: .public index + (def .public index (All (_ kind) (-> U2 (Index kind))) (|>> abstraction)) - (def: .public value + (def .public value (-> (Index Any) U2) (|>> representation)) - (def: .public equivalence + (def .public equivalence (All (_ kind) (Equivalence (Index kind))) (at equivalence.functor each ..value //unsigned.equivalence)) - (def: .public writer + (def .public writer (All (_ kind) (Writer (Index kind))) (|>> representation //unsigned.writer/2)) ) diff --git a/stdlib/source/library/lux/target/jvm/loader.lux b/stdlib/source/library/lux/target/jvm/loader.lux index ee54b8aef..a16372f06 100644 --- a/stdlib/source/library/lux/target/jvm/loader.lux +++ b/stdlib/source/library/lux/target/jvm/loader.lux @@ -65,7 +65,7 @@ "io" "try" (java/lang/Class java/lang/Object))) (with_expansions [<elemT> (these (java/lang/Class java/lang/Object))] - (def: java/lang/ClassLoader::defineClass + (def java/lang/ClassLoader::defineClass java/lang/reflect/Method (let [signature (|> (ffi.array <elemT> 4) (ffi.write! 0 (as <elemT> @@ -80,7 +80,7 @@ (ffi.class_for java/lang/ClassLoader)) (java/lang/reflect/AccessibleObject::setAccessible true))))) -(def: .public (define class_name bytecode loader) +(def .public (define class_name bytecode loader) (-> Text Binary java/lang/ClassLoader (Try java/lang/Object)) (let [signature (array.of_list (list (as java/lang/Object class_name) @@ -97,11 +97,11 @@ ffi.long_to_int))))] (java/lang/reflect/Method::invoke loader signature java/lang/ClassLoader::defineClass))) -(def: .public (new_library _) +(def .public (new_library _) (-> Any Library) (atom.atom (dictionary.empty text.hash))) -(def: .public (memory library) +(def .public (memory library) (-> Library java/lang/ClassLoader) (with_expansions [<cast> (for @.old (<|) @@ -128,7 +128,7 @@ {.#None} (panic! (exception.error ..unknown [class_name]))))))))) -(def: .public (store name bytecode library) +(def .public (store name bytecode library) (-> Text Binary Library (IO (Try Any))) (do [! io.monad] [library' (atom.read! library)] @@ -138,7 +138,7 @@ [_ (atom.update! (dictionary.has name bytecode) library)] (in {try.#Success []}))))) -(def: .public (load name loader) +(def .public (load name loader) (-> Text java/lang/ClassLoader (IO (Try (java/lang/Class java/lang/Object)))) (java/lang/ClassLoader::loadClass (ffi.as_string name) loader)) diff --git a/stdlib/source/library/lux/target/jvm/magic.lux b/stdlib/source/library/lux/target/jvm/magic.lux index 72f5ef52c..a4064361e 100644 --- a/stdlib/source/library/lux/target/jvm/magic.lux +++ b/stdlib/source/library/lux/target/jvm/magic.lux @@ -12,11 +12,11 @@ (type: .public Magic U4) -(def: .public code +(def .public code Magic (|> (hex "CAFEBABE") //unsigned.u4 try.trusted)) -(def: .public writer +(def .public writer //unsigned.writer/4) diff --git a/stdlib/source/library/lux/target/jvm/method.lux b/stdlib/source/library/lux/target/jvm/method.lux index bdbe58f87..082ede18b 100644 --- a/stdlib/source/library/lux/target/jvm/method.lux +++ b/stdlib/source/library/lux/target/jvm/method.lux @@ -52,7 +52,7 @@ ["1000" synthetic] ) -(def: .public (method modifier name with_signature? type attributes code) +(def .public (method modifier name with_signature? type attributes code) (-> (Modifier Method) UTF8 Bit (Type //category.Method) (List (Resource Attribute)) (Maybe (Bytecode Any)) (Resource Method)) (do [! //pool.monad] @@ -89,7 +89,7 @@ #descriptor @descriptor #attributes attributes]))) -(def: .public equivalence +(def .public equivalence (Equivalence Method) (all product.equivalence //modifier.equivalence @@ -98,7 +98,7 @@ (sequence.equivalence //attribute.equivalence) )) -(def: .public (writer field) +(def .public (writer field) (Writer Method) (`` (all \\format#composite (~~ (with_template [<writer> <slot>] diff --git a/stdlib/source/library/lux/target/jvm/modifier.lux b/stdlib/source/library/lux/target/jvm/modifier.lux index 04db97f3f..1034f5cab 100644 --- a/stdlib/source/library/lux/target/jvm/modifier.lux +++ b/stdlib/source/library/lux/target/jvm/modifier.lux @@ -26,66 +26,66 @@ (primitive .public (Modifier of) //unsigned.U2 - (def: .public code + (def .public code (-> (Modifier Any) //unsigned.U2) (|>> representation)) - (def: .public equivalence + (def .public equivalence (All (_ of) (Equivalence (Modifier of))) (implementation - (def: (= reference sample) + (def (= reference sample) (at //unsigned.equivalence = (representation reference) (representation sample))))) - (def: !wrap + (def !wrap (template (_ value) [(|> value //unsigned.u2 try.trusted abstraction)])) - (def: !unwrap + (def !unwrap (template (_ value) [(|> value representation //unsigned.value)])) - (def: .public (has? sub super) + (def .public (has? sub super) (All (_ of) (-> (Modifier of) (Modifier of) Bit)) (let [sub (!unwrap sub)] (|> (!unwrap super) (i64.and sub) (at i64.equivalence = sub)))) - (def: .public monoid + (def .public monoid (All (_ of) (Monoid (Modifier of))) (implementation - (def: identity + (def identity (!wrap (hex "0000"))) - (def: (composite left right) + (def (composite left right) (!wrap (i64.or (!unwrap left) (!unwrap right)))))) - (def: .public empty + (def .public empty Modifier (at ..monoid identity)) - (def: .public writer + (def .public writer (All (_ of) (Writer (Modifier of))) (|>> representation //unsigned.writer/2)) - (def: modifier + (def modifier (-> Nat Modifier) (|>> !wrap)) ) -(def: .public modifiers +(def .public modifiers (syntax (_ [ofT <code>.any options (<>.many <code>.any)]) (with_symbols [g!modifier g!code] (in (list (` (with_template [(~ g!code) (~ g!modifier)] - [(def: (~' .public) (~ g!modifier) + [(def (~' .public) (~ g!modifier) (..Modifier (~ ofT)) ((~! ..modifier) ((~! number.hex) (~ g!code))))] diff --git a/stdlib/source/library/lux/target/jvm/reflection.lux b/stdlib/source/library/lux/target/jvm/reflection.lux index 8369ce2f0..e09c3d85a 100644 --- a/stdlib/source/library/lux/target/jvm/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/reflection.lux @@ -109,7 +109,7 @@ [cannot_convert_to_a_lux_type] ) -(def: .public (load class_loader name) +(def .public (load class_loader name) (-> java/lang/ClassLoader External (Try (java/lang/Class java/lang/Object))) (case (java/lang/Class::forName name false class_loader) {try.#Failure _} @@ -118,14 +118,14 @@ success success)) -(def: .public (sub? class_loader super sub) +(def .public (sub? class_loader super sub) (-> java/lang/ClassLoader External External (Try Bit)) (do try.monad [super (..load class_loader super) sub (..load class_loader sub)] (in (java/lang/Class::isAssignableFrom sub super)))) -(def: (class' parameter reflection) +(def (class' parameter reflection) (-> (-> java/lang/reflect/Type (Try (/.Type Parameter))) java/lang/reflect/Type (Try (/.Type Class))) @@ -171,7 +171,7 @@ ... else (exception.except ..cannot_convert_to_a_lux_type [reflection]))) -(def: .public (parameter type reflection) +(def .public (parameter type reflection) (-> (-> java/lang/reflect/Type (Try (/.Type Value))) (-> java/lang/reflect/Type (Try (/.Type Parameter)))) (<| (case (ffi.as java/lang/reflect/TypeVariable reflection) @@ -218,7 +218,7 @@ _) (..class' (parameter type) reflection))) -(def: .public (type reflection) +(def .public (type reflection) (-> java/lang/reflect/Type (Try (/.Type Value))) (<| (case (ffi.as java/lang/Class reflection) {.#Some reflection} @@ -245,12 +245,12 @@ ... else (..parameter type reflection))) -(def: .public class +(def .public class (-> java/lang/reflect/Type (Try (/.Type Class))) (..class' (..parameter ..type))) -(def: .public (return reflection) +(def .public (return reflection) (-> java/lang/reflect/Type (Try (/.Type Return))) (with_expansions [<else> (these (..type reflection))] (case (ffi.as java/lang/Class reflection) @@ -286,7 +286,7 @@ (exception.report "Type" (%.type type))) -(def: .public (correspond class type) +(def .public (correspond class type) (-> (java/lang/Class java/lang/Object) Type (Try Mapping)) (case type (pattern {.#Primitive (static array.type_name) (list :member:)}) @@ -346,7 +346,7 @@ [not_a_virtual_field] ) -(def: .public (field field target) +(def .public (field field target) (-> Text (java/lang/Class java/lang/Object) (Try java/lang/reflect/Field)) (case (java/lang/Class::getDeclaredField field target) {try.#Success field} @@ -358,7 +358,7 @@ {try.#Failure _} (exception.except ..unknown_field [field target]))) -(def: .public deprecated? +(def .public deprecated? (-> (array.Array java/lang/annotation/Annotation) Bit) (|>> (array.list {.#None}) (list.all (|>> (ffi.as java/lang/Deprecated))) @@ -366,7 +366,7 @@ not)) (with_template [<name> <exception> <then?> <else?>] - [(def: .public (<name> field class) + [(def .public (<name> field class) (-> Text (java/lang/Class java/lang/Object) (Try [Bit Bit (/.Type Value)])) (do [! try.monad] [fieldJ (..field field class) diff --git a/stdlib/source/library/lux/target/jvm/type.lux b/stdlib/source/library/lux/target/jvm/type.lux index 18c21263c..3734c5e99 100644 --- a/stdlib/source/library/lux/target/jvm/type.lux +++ b/stdlib/source/library/lux/target/jvm/type.lux @@ -43,7 +43,7 @@ #super_interfaces (List (Type Class))])) (with_template [<name> <style>] - [(def: .public (<name> type) + [(def .public (<name> type) (All (_ category) (-> (Type category) (<style> category))) (let [[signature descriptor reflection] (representation type)] <name>))] @@ -52,7 +52,7 @@ [descriptor Descriptor] ) - (def: .public (reflection type) + (def .public (reflection type) (All (_ category) (-> (Type (<| Return' Value' category)) (Reflection (<| Return' Value' category)))) @@ -60,7 +60,7 @@ reflection)) (with_template [<category> <name> <signature> <descriptor> <reflection>] - [(def: .public <name> + [(def .public <name> (Type <category>) (abstraction [<signature> <descriptor> <reflection>]))] @@ -75,28 +75,28 @@ [Primitive char /signature.char /descriptor.char /reflection.char] ) - (def: .public (array type) + (def .public (array type) (-> (Type Value) (Type Array)) (abstraction [(/signature.array (..signature type)) (/descriptor.array (..descriptor type)) (/reflection.array (..reflection type))])) - (def: .public (class name parameters) + (def .public (class name parameters) (-> External (List (Type Parameter)) (Type Class)) (abstraction [(/signature.class name (list#each ..signature parameters)) (/descriptor.class name) (/reflection.class name)])) - (def: .public (declaration name variables) + (def .public (declaration name variables) (-> External (List (Type Var)) (Type Declaration)) (abstraction [(/signature.declaration name (list#each ..signature variables)) (/descriptor.declaration name) (/reflection.declaration name)])) - (def: .public (as_class type) + (def .public (as_class type) (-> (Type Declaration) (Type Class)) (abstraction (let [[signature descriptor reflection] (representation type)] @@ -104,21 +104,21 @@ (/descriptor.as_class descriptor) (/reflection.as_class reflection)]))) - (def: .public wildcard + (def .public wildcard (Type Parameter) (abstraction [/signature.wildcard /descriptor.wildcard /reflection.wildcard])) - (def: .public (var name) + (def .public (var name) (-> Text (Type Var)) (abstraction [(/signature.var name) /descriptor.var /reflection.var])) - (def: .public (lower bound) + (def .public (lower bound) (-> (Type Parameter) (Type Parameter)) (abstraction (let [[signature descriptor reflection] (representation bound)] @@ -126,7 +126,7 @@ (/descriptor.lower descriptor) (/reflection.lower reflection)]))) - (def: .public (upper bound) + (def .public (upper bound) (-> (Type Parameter) (Type Parameter)) (abstraction (let [[signature descriptor reflection] (representation bound)] @@ -134,7 +134,7 @@ (/descriptor.upper descriptor) (/reflection.upper reflection)]))) - (def: .public (method [type_variables inputs output exceptions]) + (def .public (method [type_variables inputs output exceptions]) (-> [(List (Type Var)) (List (Type Value)) (Type Return) @@ -149,21 +149,21 @@ (..descriptor output)]) (as_expected ..void)])) - (def: .public equivalence + (def .public equivalence (All (_ category) (Equivalence (Type category))) (implementation - (def: (= parameter subject) + (def (= parameter subject) (at /signature.equivalence = (..signature parameter) (..signature subject))))) - (def: .public hash + (def .public hash (All (_ category) (Hash (Type category))) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> ..signature (at /signature.hash hash))))) + (def equivalence ..equivalence) + (def hash (|>> ..signature (at /signature.hash hash))))) - (def: .public (primitive? type) + (def .public (primitive? type) (-> (Type Value) (Either (Type Object) (Type Primitive))) (if (`` (or (~~ (with_template [<type>] @@ -180,7 +180,7 @@ (|> type (as (Type Primitive)) {.#Right}) (|> type (as (Type Object)) {.#Left}))) - (def: .public (void? type) + (def .public (void? type) (-> (Type Return) (Either (Type Value) (Type Void))) (if (`` (or (~~ (with_template [<type>] @@ -191,7 +191,7 @@ (|> type (as (Type Value)) {.#Left}))) ) -(def: .public (class? type) +(def .public (class? type) (-> (Type Value) (Maybe External)) (let [repr (|> type ..descriptor /descriptor.descriptor)] (if (and (text.starts_with? /descriptor.class_prefix repr) @@ -206,6 +206,6 @@ (at maybe.monad each (|>> //name.internal //name.external)))) {.#None}))) -(def: .public format +(def .public format (All (_ a) (Format (Type a))) (|>> ..signature /signature.signature)) diff --git a/stdlib/source/library/lux/target/jvm/type/alias.lux b/stdlib/source/library/lux/target/jvm/type/alias.lux index 89e4148c6..0ec86571b 100644 --- a/stdlib/source/library/lux/target/jvm/type/alias.lux +++ b/stdlib/source/library/lux/target/jvm/type/alias.lux @@ -27,11 +27,11 @@ (type: .public Aliasing (Dictionary Text Text)) -(def: .public fresh +(def .public fresh Aliasing (dictionary.empty text.hash)) -(def: (var aliasing) +(def (var aliasing) (-> Aliasing (Parser (Type Var))) (do <>.monad [var //parser.var'] @@ -40,7 +40,7 @@ (maybe.else var) //.var)))) -(def: (class parameter) +(def (class parameter) (-> (Parser (Type Parameter)) (Parser (Type Class))) (|> (do <>.monad [name //parser.class_name @@ -53,7 +53,7 @@ (<>.before (<text>.this //descriptor.class_suffix)))) (with_template [<name> <prefix> <bound> <constructor>] - [(def: <name> + [(def <name> (-> (Parser (Type Class)) (Parser (Type Parameter))) (|>> (<>.after (<text>.this <prefix>)) (at <>.monad each <bound>)))] @@ -62,7 +62,7 @@ [upper //signature.upper_prefix //.upper ..Upper] ) -(def: (parameter aliasing) +(def (parameter aliasing) (-> Aliasing (Parser (Type Parameter))) (<>.rec (function (_ parameter) @@ -75,7 +75,7 @@ class ))))) -(def: (value aliasing) +(def (value aliasing) (-> Aliasing (Parser (Type Value))) (<>.rec (function (_ value) @@ -85,37 +85,37 @@ (//parser.array' value) )))) -(def: (inputs aliasing) +(def (inputs aliasing) (-> Aliasing (Parser (List (Type Value)))) (|> (<>.some (..value aliasing)) (<>.after (<text>.this //signature.arguments_start)) (<>.before (<text>.this //signature.arguments_end)))) -(def: (return aliasing) +(def (return aliasing) (-> Aliasing (Parser (Type Return))) (all <>.either //parser.void (..value aliasing) )) -(def: (exception aliasing) +(def (exception aliasing) (-> Aliasing (Parser (Type Class))) (|> (..class (..parameter aliasing)) (<>.after (<text>.this //signature.exception_prefix)))) -(def: (bound aliasing) +(def (bound aliasing) (-> Aliasing (Parser (Type Class))) (do <>.monad [_ (<text>.this ":")] (..class (..parameter aliasing)))) -(def: (bound_type_var aliasing) +(def (bound_type_var aliasing) (-> Aliasing (Parser (Type Var))) (|> //parser.var_name (at <>.monad each //.var) (<>.before (<>.many (..bound aliasing))))) -(def: .public (method aliasing) +(def .public (method aliasing) (-> Aliasing (-> (Type Method) (Type Method))) (|>> //.signature //signature.signature diff --git a/stdlib/source/library/lux/target/jvm/type/box.lux b/stdlib/source/library/lux/target/jvm/type/box.lux index 08a6e1213..051f45391 100644 --- a/stdlib/source/library/lux/target/jvm/type/box.lux +++ b/stdlib/source/library/lux/target/jvm/type/box.lux @@ -6,7 +6,7 @@ [name (.only External)]]]) (with_template [<name> <box>] - [(def: .public <name> External <box>)] + [(def .public <name> External <box>)] [boolean "java.lang.Boolean"] [byte "java.lang.Byte"] diff --git a/stdlib/source/library/lux/target/jvm/type/descriptor.lux b/stdlib/source/library/lux/target/jvm/type/descriptor.lux index 99b3987d5..3de5b4483 100644 --- a/stdlib/source/library/lux/target/jvm/type/descriptor.lux +++ b/stdlib/source/library/lux/target/jvm/type/descriptor.lux @@ -24,12 +24,12 @@ (primitive .public (Descriptor category) Text - (def: .public descriptor + (def .public descriptor (-> (Descriptor Any) Text) (|>> representation)) (with_template [<sigil> <category> <name>] - [(def: .public <name> + [(def .public <name> (Descriptor <category>) (abstraction <sigil>))] @@ -44,26 +44,26 @@ ["C" Primitive char] ) - (def: .public class_prefix "L") - (def: .public class_suffix ";") + (def .public class_prefix "L") + (def .public class_suffix ";") - (def: .public class + (def .public class (-> External (Descriptor Class)) (|>> ///name.internal ///name.read (text.enclosed [..class_prefix ..class_suffix]) abstraction)) - (def: .public (declaration name) + (def .public (declaration name) (-> External (Descriptor Declaration)) (transmutation (..class name))) - (def: .public as_class + (def .public as_class (-> (Descriptor Declaration) (Descriptor Class)) (|>> transmutation)) (with_template [<name> <category>] - [(def: .public <name> + [(def .public <name> (Descriptor <category>) (transmutation (..class "java.lang.Object")))] @@ -72,24 +72,24 @@ [wildcard Parameter] ) - (def: .public (lower descriptor) + (def .public (lower descriptor) (-> (Descriptor Parameter) (Descriptor Parameter)) ..wildcard) - (def: .public upper + (def .public upper (-> (Descriptor Parameter) (Descriptor Parameter)) (|>> transmutation)) - (def: .public array_prefix "[") + (def .public array_prefix "[") - (def: .public array + (def .public array (-> (Descriptor Value) (Descriptor Array)) (|>> representation (format ..array_prefix) abstraction)) - (def: .public (method [inputs output]) + (def .public (method [inputs output]) (-> [(List (Descriptor Value)) (Descriptor Return)] (Descriptor Method)) @@ -100,13 +100,13 @@ (text.enclosed ["(" ")"])) (representation output)))) - (def: .public equivalence + (def .public equivalence (All (_ category) (Equivalence (Descriptor category))) (implementation - (def: (= parameter subject) + (def (= parameter subject) (text#= (representation parameter) (representation subject))))) - (def: .public class_name + (def .public class_name (-> (Descriptor Object) Internal) (let [prefix_size (text.size ..class_prefix) suffix_size (text.size ..class_suffix)] diff --git a/stdlib/source/library/lux/target/jvm/type/lux.lux b/stdlib/source/library/lux/target/jvm/type/lux.lux index ea7951cee..3490eaed9 100644 --- a/stdlib/source/library/lux/target/jvm/type/lux.lux +++ b/stdlib/source/library/lux/target/jvm/type/lux.lux @@ -38,7 +38,7 @@ (type: .public Mapping (Dictionary Text Type)) -(def: .public fresh +(def .public fresh Mapping (dictionary.empty text.hash)) @@ -46,13 +46,13 @@ (exception.report "Var" (%.text var))) -(def: void +(def void (Parser (Check Type)) (<>.after //parser.void (<>#in (check#in .Any)))) (with_template [<name> <parser> <reflection>] - [(def: <name> + [(def <name> (Parser (Check Type)) (<>.after <parser> (<>#in (check#in {.#Primitive (//reflection.reflection <reflection>) {.#End}}))))] @@ -68,7 +68,7 @@ ) (with_template [<name> <parser> <box>] - [(def: <name> + [(def <name> (Parser (Check Type)) (<>.after <parser> (<>#in (check#in {.#Primitive <box> {.#End}}))))] @@ -83,7 +83,7 @@ [boxed_char //parser.char //box.char] ) -(def: primitive +(def primitive (Parser (Check Type)) (all <>.either ..boolean @@ -96,7 +96,7 @@ ..char )) -(def: boxed_primitive +(def boxed_primitive (Parser (Check Type)) (all <>.either ..boxed_boolean @@ -109,13 +109,13 @@ ..boxed_char )) -(def: wildcard +(def wildcard (Parser (Check Type)) (<>.after //parser.wildcard (<>#in (check#each product.right check.existential)))) -(def: (var mapping) +(def (var mapping) (-> Mapping (Parser (Check Type))) (do <>.monad [var //parser.var'] @@ -126,7 +126,7 @@ {.#Some type} (check#in type))))) -(def: (class' parameter) +(def (class' parameter) (-> (Parser (Check Type)) (Parser (Check Type))) (|> (do <>.monad [name //parser.class_name @@ -141,7 +141,7 @@ (<>.before (<text>.this //descriptor.class_suffix)))) (with_template [<name> <prefix> <constructor>] - [(def: <name> + [(def <name> (-> (Parser (Check Type)) (Parser (Check Type))) (|> (<>.after (<text>.this <prefix>)) ... TODO: Re-enable Lower and Upper, instead of using the simplified limit. @@ -152,7 +152,7 @@ [upper //signature.upper_prefix ..Upper] ) -(def: (parameter mapping) +(def (parameter mapping) (-> Mapping (Parser (Check Type))) (<>.rec (function (_ parameter) @@ -165,11 +165,11 @@ class ))))) -(def: .public class +(def .public class (-> Mapping (Parser (Check Type))) (|>> ..parameter ..class')) -(def: array +(def array (-> (Parser (Check Type)) (Parser (Check Type))) (|>> (<>#each (check#each (function (_ elementT) (case elementT @@ -192,7 +192,7 @@ (|> elementT array.Array .type))))) (<>.after (<text>.this //descriptor.array_prefix)))) -(def: .public (type mapping) +(def .public (type mapping) (-> Mapping (Parser (Check Type))) (<>.rec (function (_ type) @@ -202,7 +202,7 @@ (..array type) )))) -(def: .public (boxed_type mapping) +(def .public (boxed_type mapping) (-> Mapping (Parser (Check Type))) (<>.rec (function (_ type) @@ -212,21 +212,21 @@ (..array type) )))) -(def: .public (return mapping) +(def .public (return mapping) (-> Mapping (Parser (Check Type))) (all <>.either ..void (..type mapping) )) -(def: .public (boxed_return mapping) +(def .public (boxed_return mapping) (-> Mapping (Parser (Check Type))) (all <>.either ..void (..boxed_type mapping) )) -(def: .public (check operation input) +(def .public (check operation input) (All (_ a) (-> (Parser (Check a)) Text (Check a))) (case (<text>.result operation input) {try.#Success check} diff --git a/stdlib/source/library/lux/target/jvm/type/parser.lux b/stdlib/source/library/lux/target/jvm/type/parser.lux index 999cb620f..9eb9db150 100644 --- a/stdlib/source/library/lux/target/jvm/type/parser.lux +++ b/stdlib/source/library/lux/target/jvm/type/parser.lux @@ -23,7 +23,7 @@ ["[1][0]" name (.only External)]]]]) (with_template [<category> <name> <signature> <type>] - [(def: .public <name> + [(def .public <name> (Parser (Type <category>)) (<>.after (<text>.this (//signature.signature <signature>)) (<>#in <type>)))] @@ -40,7 +40,7 @@ [Parameter wildcard //signature.wildcard //.wildcard] ) -(def: .public primitive +(def .public primitive (Parser (Type Primitive)) (all <>.either ..boolean @@ -53,20 +53,20 @@ ..char )) -(def: var/head +(def var/head (format "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "_")) -(def: var/tail +(def var/tail (format var/head "0123456789$")) -(def: class/set +(def class/set (format var/tail //name.internal_separator)) (with_template [<type> <name> <head> <tail> <adapter>] - [(def: .public <name> + [(def .public <name> (Parser <type>) (at <>.functor each <adapter> (<text>.slice (<text>.and! (<text>.one_of! <head>) @@ -76,24 +76,24 @@ [Text var_name var/head var/tail function.identity] ) -(def: .public var' +(def .public var' (Parser Text) (|> ..var_name (<>.after (<text>.this //signature.var_prefix)) (<>.before (<text>.this //descriptor.class_suffix)))) -(def: .public var +(def .public var (Parser (Type Var)) (<>#each //.var ..var')) -(def: .public var? +(def .public var? (-> (Type Value) (Maybe Text)) (|>> //.signature //signature.signature (<text>.result ..var') try.maybe)) -(def: .public name +(def .public name (-> (Type Var) Text) (|>> //.signature //signature.signature @@ -101,7 +101,7 @@ try.trusted)) (with_template [<name> <prefix> <constructor>] - [(def: <name> + [(def <name> (-> (Parser (Type Parameter)) (Parser (Type Parameter))) (|>> (<>.after (<text>.this <prefix>)) (<>#each <constructor>)))] @@ -110,7 +110,7 @@ [upper //signature.upper_prefix //.upper] ) -(def: (class'' parameter) +(def (class'' parameter) (-> (Parser (Type Parameter)) (Parser [External (List (Type Parameter))])) (|> (do <>.monad [name ..class_name @@ -122,17 +122,17 @@ (<>.after (<text>.this //descriptor.class_prefix)) (<>.before (<text>.this //descriptor.class_suffix)))) -(def: class' +(def class' (-> (Parser (Type Parameter)) (Parser (Type Class))) (|>> ..class'' (at <>.monad each (product.uncurried //.class)))) -(def: .public array' +(def .public array' (-> (Parser (Type Value)) (Parser (Type Array))) (|>> (<>.after (<text>.this //descriptor.array_prefix)) (<>#each //.array))) -(def: (parameter' value) +(def (parameter' value) (-> (Parser (Type Value)) (Parser (Type Parameter))) (<>.rec (function (_ parameter) @@ -146,7 +146,7 @@ class ))))) -(def: .public value +(def .public value (Parser (Type Value)) (<>.rec (function (_ value) @@ -155,16 +155,16 @@ (..parameter' value) )))) -(def: .public parameter +(def .public parameter (Parser (Type Parameter)) (..parameter' ..value)) -(def: .public class +(def .public class (Parser (Type Class)) (..class' ..parameter)) (with_template [<name> <prefix> <constructor>] - [(def: .public <name> + [(def .public <name> (-> (Type Value) (Maybe (Type Parameter))) (|>> //.signature //signature.signature @@ -175,39 +175,39 @@ [upper? //signature.upper_prefix //.upper] ) -(def: .public read_class +(def .public read_class (-> (Type Class) [External (List (Type Parameter))]) (|>> //.signature //signature.signature (<text>.result (..class'' ..parameter)) try.trusted)) -(def: .public array +(def .public array (Parser (Type Array)) (..array' ..value)) -(def: .public object +(def .public object (Parser (Type Object)) (all <>.either ..class ..array)) -(def: inputs +(def inputs (|> (<>.some ..value) (<>.after (<text>.this //signature.arguments_start)) (<>.before (<text>.this //signature.arguments_end)))) -(def: .public return +(def .public return (Parser (Type Return)) (<>.either ..void ..value)) -(def: exception +(def exception (Parser (Type Class)) (|> ..class (<>.after (<text>.this //signature.exception_prefix)))) -(def: .public var_declaration +(def .public var_declaration (Parser [(Type Var) (Type Class)]) (do <>.monad [name ..var_name @@ -215,7 +215,7 @@ type ..class] (in [(//.var name) type]))) -(def: .public method +(def .public method (-> (Type Method) [(List (Type Var)) (List (Type Value)) @@ -239,7 +239,7 @@ try.trusted))) (with_template [<name> <category> <parser>] - [(def: .public <name> + [(def .public <name> (-> (Type Value) (Maybe <category>)) (|>> //.signature //signature.signature @@ -259,7 +259,7 @@ [object? (Type Object) ..object] ) -(def: .public declaration' +(def .public declaration' (Parser [External (List (Type Var))]) (|> (<>.and ..class_name (|> (<>.some ..var) @@ -269,7 +269,7 @@ (<>.after (<text>.this //descriptor.class_prefix)) (<>.before (<text>.this //descriptor.class_suffix)))) -(def: .public declaration +(def .public declaration (-> (Type Declaration) [External (List (Type Var))]) (|>> //.signature //signature.signature diff --git a/stdlib/source/library/lux/target/jvm/type/reflection.lux b/stdlib/source/library/lux/target/jvm/type/reflection.lux index 7794fedc3..cfd7be86b 100644 --- a/stdlib/source/library/lux/target/jvm/type/reflection.lux +++ b/stdlib/source/library/lux/target/jvm/type/reflection.lux @@ -18,18 +18,18 @@ (primitive .public (Reflection category) Text - (def: .public reflection + (def .public reflection (-> (Reflection Any) Text) (|>> representation)) - (def: .public equivalence + (def .public equivalence (All (_ category) (Equivalence (Reflection category))) (implementation - (def: (= parameter subject) + (def (= parameter subject) (text#= (representation parameter) (representation subject))))) (with_template [<category> <name> <reflection>] - [(def: .public <name> + [(def .public <name> (Reflection <category>) (abstraction <reflection>))] @@ -44,19 +44,19 @@ [Primitive char "char"] ) - (def: .public class + (def .public class (-> External (Reflection Class)) (|>> abstraction)) - (def: .public (declaration name) + (def .public (declaration name) (-> External (Reflection Declaration)) (transmutation (..class name))) - (def: .public as_class + (def .public as_class (-> (Reflection Declaration) (Reflection Class)) (|>> transmutation)) - (def: .public (array element) + (def .public (array element) (-> (Reflection Value) (Reflection Array)) (let [element' (representation element) elementR (`` (cond (text.starts_with? //descriptor.array_prefix element') @@ -85,7 +85,7 @@ abstraction))) (with_template [<name> <category>] - [(def: .public <name> + [(def .public <name> (Reflection <category>) (transmutation (..class "java.lang.Object")))] @@ -94,11 +94,11 @@ [wildcard Parameter] ) - (def: .public (lower reflection) + (def .public (lower reflection) (-> (Reflection Parameter) (Reflection Parameter)) ..wildcard) - (def: .public upper + (def .public upper (-> (Reflection Parameter) (Reflection Parameter)) (|>> transmutation)) ) diff --git a/stdlib/source/library/lux/target/jvm/type/signature.lux b/stdlib/source/library/lux/target/jvm/type/signature.lux index 610706176..288b0a75e 100644 --- a/stdlib/source/library/lux/target/jvm/type/signature.lux +++ b/stdlib/source/library/lux/target/jvm/type/signature.lux @@ -23,12 +23,12 @@ (primitive .public (Signature category) Text - (def: .public signature + (def .public signature (-> (Signature Any) Text) (|>> representation)) (with_template [<category> <name> <descriptor>] - [(def: .public <name> + [(def .public <name> (Signature <category>) (abstraction (//descriptor.descriptor <descriptor>)))] @@ -43,18 +43,18 @@ [Primitive char //descriptor.char] ) - (def: .public array + (def .public array (-> (Signature Value) (Signature Array)) (|>> representation (format //descriptor.array_prefix) abstraction)) - (def: .public wildcard + (def .public wildcard (Signature Parameter) (abstraction "*")) (with_template [<char> <name>] - [(def: .public <name> <char>)] + [(def .public <name> <char>)] ["T" var_prefix] ["-" lower_prefix] @@ -70,7 +70,7 @@ ) (with_template [<name> <prefix>] - [(def: .public <name> + [(def .public <name> (-> (Signature Parameter) (Signature Parameter)) (|>> representation (format <prefix>) abstraction))] @@ -78,18 +78,18 @@ [upper ..upper_prefix] ) - (def: .public var + (def .public var (-> Text (Signature Var)) (|>> (text.enclosed [..var_prefix //descriptor.class_suffix]) abstraction)) - (def: .public var_name + (def .public var_name (-> (Signature Var) Text) (|>> representation (text.replaced ..var_prefix "") (text.replaced //descriptor.class_suffix ""))) - (def: .public (class name parameters) + (def .public (class name parameters) (-> External (List (Signature Parameter)) (Signature Class)) (abstraction (format //descriptor.class_prefix @@ -106,28 +106,28 @@ ..parameters_end)) //descriptor.class_suffix))) - (def: .public (declaration name variables) + (def .public (declaration name variables) (-> External (List (Signature Var)) (Signature Declaration)) (transmutation (..class name variables))) - (def: class_bound + (def class_bound (|> (..class "java.lang.Object" (list)) ..signature (format ..format_type_parameter_infix))) - (def: var_declaration/1 + (def var_declaration/1 (-> (Signature Var) Text) (|>> ..var_name (text.suffix ..class_bound))) - (def: var_declaration/+ + (def var_declaration/+ (-> (List (Signature Var)) Text) (|>> (list#each ..var_declaration/1) text.together (text.enclosed [..parameters_start ..parameters_end]))) - (def: var_declaration/* + (def var_declaration/* (-> (List (Signature Var)) Text) (|>> (pipe.case {.#End} @@ -136,7 +136,7 @@ it (..var_declaration/+ it)))) - (def: .public (inheritance variables super interfaces) + (def .public (inheritance variables super interfaces) (-> (List (Signature Var)) (Signature Class) (List (Signature Class)) (Signature Inheritance)) (abstraction (format (var_declaration/* variables) @@ -145,11 +145,11 @@ (list#each ..signature) text.together)))) - (def: .public as_class + (def .public as_class (-> (Signature Declaration) (Signature Class)) (|>> transmutation)) - (def: .public (method [type_variables inputs output exceptions]) + (def .public (method [type_variables inputs output exceptions]) (-> [(List (Signature Var)) (List (Signature Value)) (Signature Return) @@ -167,16 +167,16 @@ (list#each (|>> representation (format ..exception_prefix))) text.together)))) - (def: .public equivalence + (def .public equivalence (All (_ category) (Equivalence (Signature category))) (implementation - (def: (= parameter subject) + (def (= parameter subject) (text#= (representation parameter) (representation subject))))) - (def: .public hash + (def .public hash (All (_ category) (Hash (Signature category))) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> representation text#hash)))) + (def equivalence ..equivalence) + (def hash (|>> representation text#hash)))) ) diff --git a/stdlib/source/library/lux/target/jvm/version.lux b/stdlib/source/library/lux/target/jvm/version.lux index 60778c7f7..9b23f8fff 100644 --- a/stdlib/source/library/lux/target/jvm/version.lux +++ b/stdlib/source/library/lux/target/jvm/version.lux @@ -11,14 +11,14 @@ (type: .public Minor Version) (type: .public Major Version) -(def: .public default_minor +(def .public default_minor Minor (|> 0 //unsigned.u2 try.trusted)) (with_template [<number> <name>] - [(def: .public <name> + [(def .public <name> Major (|> <number> //unsigned.u2 @@ -38,5 +38,5 @@ [56 v12] ) -(def: .public writer +(def .public writer //unsigned.writer/2) diff --git a/stdlib/source/library/lux/target/lua.lux b/stdlib/source/library/lux/target/lua.lux index 67986980d..7ac944f82 100644 --- a/stdlib/source/library/lux/target/lua.lux +++ b/stdlib/source/library/lux/target/lua.lux @@ -28,38 +28,38 @@ [primitive (.except)]]]]) ... Added the carriage return for better Windows compatibility. -(def: \n+ +(def \n+ Text (format text.carriage_return text.new_line)) -(def: nested +(def nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] (|>> (format \n+) (text.replaced text.new_line nested_new_line)))) -(def: input_separator ", ") +(def input_separator ", ") (primitive .public (Code brand) Text - (def: .public equivalence + (def .public equivalence (All (_ brand) (Equivalence (Code brand))) (implementation - (def: (= reference subject) + (def (= reference subject) (at text.equivalence = (representation reference) (representation subject))))) - (def: .public hash + (def .public hash (All (_ brand) (Hash (Code brand))) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> representation (at text.hash hash))))) + (def equivalence ..equivalence) + (def hash (|>> representation (at text.hash hash))))) - (def: .public manual + (def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) @@ -85,18 +85,18 @@ [Label [Code]] ) - (def: .public nil + (def .public nil Literal (abstraction "nil")) - (def: .public boolean + (def .public boolean (-> Bit Literal) (|>> (pipe.case #0 "false" #1 "true") abstraction)) - (def: .public int + (def .public int (-> Int Literal) ... Integers must be turned into hexadecimal to avoid quirks in how Lua parses integers. ... In particular, the number -9223372036854775808 will be incorrectly parsed as a float by Lua. @@ -106,7 +106,7 @@ (format "0x") abstraction))) - (def: .public float + (def .public float (-> Frac Literal) (|>> (pipe.cond [(f.= f.positive_infinity)] [(pipe.new "(1.0/0.0)" [])] @@ -121,7 +121,7 @@ [%.frac (text.replaced "+" "")]) abstraction)) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -138,24 +138,24 @@ )) ))) - (def: .public string + (def .public string (-> Text Literal) (|>> ..safe (text.enclosed' text.double_quote) abstraction)) - (def: .public multi + (def .public multi (-> (List Expression) Expression) (|>> (list#each ..code) (text.interposed ..input_separator) abstraction)) - (def: .public array + (def .public array (-> (List Expression) Literal) (|>> (list#each ..code) (text.interposed ..input_separator) (text.enclosed ["{" "}"]) abstraction)) - (def: .public table + (def .public table (-> (List [Text Expression]) Literal) (|>> (list#each (.function (_ [key value]) (format key " = " (representation value)))) @@ -163,21 +163,21 @@ (text.enclosed ["({" "})"]) abstraction)) - (def: .public (item idx array) + (def .public (item idx array) (-> Expression Expression Access) (abstraction (format "(" (representation array) ")[" (representation idx) "]"))) - (def: .public (the field table) + (def .public (the field table) (-> Text Expression Access) (abstraction (format (representation table) "." field))) - (def: .public length + (def .public length (-> Expression Computation) (|>> representation (text.enclosed ["#(" ")"]) abstraction)) - (def: .public (apply args func) + (def .public (apply args func) (-> (List Expression) Expression Computation) (|> args (list#each ..code) @@ -186,7 +186,7 @@ (format (representation func)) abstraction)) - (def: .public (do method args table) + (def .public (do method args table) (-> Text (List Expression) Expression Computation) (|> args (list#each ..code) @@ -196,7 +196,7 @@ abstraction)) (with_template [<op> <name>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (-> Expression Expression Expression) (abstraction (format "(" (representation subject) @@ -229,7 +229,7 @@ ) (with_template [<name> <unary>] - [(def: .public (<name> subject) + [(def .public (<name> subject) (-> Expression Expression) (abstraction (format "(" <unary> " " (representation subject) ")")))] @@ -238,7 +238,7 @@ ) (with_template [<name> <type>] - [(def: .public <name> + [(def .public <name> (-> Text <type>) (|>> abstraction))] @@ -246,66 +246,66 @@ [label Label] ) - (def: .public statement + (def .public statement (-> Expression Statement) (|>> representation abstraction)) - (def: .public (then pre! post!) + (def .public (then pre! post!) (-> Statement Statement Statement) (abstraction (format (representation pre!) \n+ (representation post!)))) - (def: locations + (def locations (-> (List Location) Text) (|>> (list#each ..code) (text.interposed ..input_separator))) - (def: .public (local vars) + (def .public (local vars) (-> (List Var) Statement) (abstraction (format "local " (..locations vars)))) - (def: .public (set vars value) + (def .public (set vars value) (-> (List Location) Expression Statement) (abstraction (format (..locations vars) " = " (representation value)))) - (def: .public (let vars value) + (def .public (let vars value) (-> (List Var) Expression Statement) (abstraction (format "local " (..locations vars) " = " (representation value)))) - (def: .public (local/1 var value) + (def .public (local/1 var value) (-> Var Expression Statement) (abstraction (format "local " (representation var) " = " (representation value)))) - (def: .public (if test then! else!) + (def .public (if test then! else!) (-> Expression Statement Statement Statement) (abstraction (format "if " (representation test) \n+ "then" (..nested (representation then!)) \n+ "else" (..nested (representation else!)) \n+ "end"))) - (def: .public (when test then!) + (def .public (when test then!) (-> Expression Statement Statement) (abstraction (format "if " (representation test) \n+ "then" (..nested (representation then!)) \n+ "end"))) - (def: .public (while test body!) + (def .public (while test body!) (-> Expression Statement Statement) (abstraction (format "while " (representation test) " do" (..nested (representation body!)) \n+ "end"))) - (def: .public (repeat until body!) + (def .public (repeat until body!) (-> Expression Statement Statement) (abstraction (format "repeat" (..nested (representation body!)) \n+ "until " (representation until)))) - (def: .public (for_in vars source body!) + (def .public (for_in vars source body!) (-> (List Var) Expression Statement Statement) (abstraction (format "for " (|> vars @@ -315,7 +315,7 @@ (..nested (representation body!)) \n+ "end"))) - (def: .public (for_step var from to step body!) + (def .public (for_step var from to step body!) (-> Var Expression Expression Expression Statement Statement) (abstraction @@ -326,11 +326,11 @@ (..nested (representation body!)) \n+ "end"))) - (def: .public (return value) + (def .public (return value) (-> Expression Statement) (abstraction (format "return " (representation value)))) - (def: .public (closure args body!) + (def .public (closure args body!) (-> (List Var) Statement Expression) (|> (format "function " (|> args ..locations @@ -341,7 +341,7 @@ abstraction)) (with_template [<name> <code> <binding>] - [(def: .public (<name> name args body!) + [(def .public (<name> name args body!) (-> <binding> (List Var) Statement Statement) (abstraction (format <code> " " (representation name) @@ -355,25 +355,25 @@ [local_function "local function" Var] ) - (def: .public break + (def .public break Statement (abstraction "break")) - (def: .public (set_label label) + (def .public (set_label label) (-> Label Statement) (abstraction (format "::" (representation label) "::"))) - (def: .public (go_to label) + (def .public (go_to label) (-> Label Statement) (abstraction (format "goto " (representation label)))) ... https://www.lua.org/pil/1.3.html - (def: .public (comment commentary on) + (def .public (comment commentary on) (All (_ kind) (-> Text (Code kind) (Code kind))) (abstraction (format "-- " commentary \n+ (representation on)))) ) -(def: arity_inputs +(def arity_inputs (syntax (_ [arity <code>.nat]) (in (case arity 0 (.list) @@ -381,7 +381,7 @@ (enum.range n.enum 0) (list#each (|>> %.nat code.local))))))) -(def: arity_types +(def arity_types (syntax (_ [arity <code>.nat]) (in (list.repeated arity (` ..Expression))))) @@ -390,7 +390,7 @@ <types> (arity_types <arity>) <definitions> (template.spliced <function>+)] (with_template [<function>] - [(`` (def: .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>) + [(`` (def .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>) (-> <types> Computation) (..apply (.list <inputs>) (..var <function>))))] diff --git a/stdlib/source/library/lux/target/php.lux b/stdlib/source/library/lux/target/php.lux index 892b98a25..c7ec0f9f5 100644 --- a/stdlib/source/library/lux/target/php.lux +++ b/stdlib/source/library/lux/target/php.lux @@ -26,48 +26,48 @@ [type [primitive (.except)]]]]) -(def: input_separator ", ") -(def: statement_suffix ";") +(def input_separator ", ") +(def statement_suffix ";") ... Added the carriage return for better Windows compatibility. -(def: \n+ +(def \n+ Text (format text.carriage_return text.new_line)) -(def: nested +(def nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] (|>> (format \n+) (text.replaced text.new_line nested_new_line)))) -(def: block +(def block (-> Text Text) (|>> ..nested (text.enclosed ["{" (format \n+ "}")]))) -(def: group +(def group (-> Text Text) (text.enclosed ["(" ")"])) (primitive .public (Code brand) Text - (def: .public equivalence + (def .public equivalence (All (_ brand) (Equivalence (Code brand))) (implementation - (def: (= reference subject) + (def (= reference subject) (at text.equivalence = (representation reference) (representation subject))))) - (def: .public hash + (def .public hash (All (_ brand) (Hash (Code brand))) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> representation (at text.hash hash))))) + (def equivalence ..equivalence) + (def hash (|>> representation (at text.hash hash))))) - (def: .public manual + (def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) @@ -100,18 +100,18 @@ [#reference? Bit #var Var])) - (def: .public ; + (def .public ; (-> Expression Statement) (|>> representation (text.suffix ..statement_suffix) abstraction)) - (def: .public var + (def .public var (-> Text Var) (|>> (format "$") abstraction)) (with_template [<name> <type>] - [(def: .public <name> + [(def .public <name> (-> Text <type>) (|>> abstraction))] @@ -119,27 +119,27 @@ [label Label] ) - (def: .public (set_label label) + (def .public (set_label label) (-> Label Statement) (abstraction (format (representation label) ":"))) - (def: .public (go_to label) + (def .public (go_to label) (-> Label Statement) (abstraction (format "goto " (representation label) ..statement_suffix))) - (def: .public null + (def .public null Literal (abstraction "NULL")) - (def: .public bool + (def .public bool (-> Bit Literal) (|>> (pipe.case #0 "false" #1 "true") abstraction)) - (def: .public int + (def .public int (-> Int Literal) (.let [to_hex (at n.hex encoded)] (|>> .nat @@ -147,7 +147,7 @@ (format "0x") abstraction))) - (def: .public float + (def .public float (-> Frac Literal) (|>> (pipe.cond [(f.= f.positive_infinity)] [(pipe.new "+INF" [])] @@ -162,7 +162,7 @@ [%.frac]) abstraction)) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -180,27 +180,27 @@ )) ))) - (def: .public string + (def .public string (-> Text Literal) (|>> ..safe (text.enclosed [text.double_quote text.double_quote]) abstraction)) - (def: arguments + (def arguments (-> (List Expression) Text) (|>> (list#each ..code) (text.interposed ..input_separator) ..group)) - (def: .public (apply args func) + (def .public (apply args func) (-> (List Expression) Expression Computation) (|> (format (representation func) (..arguments args)) abstraction)) ... TODO: Remove when no longer using JPHP. - (def: .public (apply' args func) + (def .public (apply' args func) (-> (List Expression) Expression Computation) (apply (list.partial func args) (..constant "call_user_func"))) - (def: parameters + (def parameters (-> (List Argument) Text) (|>> (list#each (function (_ [reference? var]) (.if reference? @@ -210,7 +210,7 @@ ..group)) (with_template [<name> <reference?>] - [(def: .public <name> + [(def .public <name> (-> Var Argument) (|>> [<reference?>]))] @@ -218,7 +218,7 @@ [reference #1] ) - (def: .public (closure uses arguments body!) + (def .public (closure uses arguments body!) (-> (List Argument) (List Argument) Statement Literal) (let [uses (case uses {.#End} @@ -232,7 +232,7 @@ ..group abstraction))) - (def: arity_inputs + (def arity_inputs (syntax (_ [arity <code>.nat]) (in (case arity 0 (.list) @@ -240,7 +240,7 @@ (enum.range n.enum 0) (list#each (|>> %.nat code.local))))))) - (def: arity_types + (def arity_types (syntax (_ [arity <code>.nat]) (in (list.repeated arity (` ..Expression))))) @@ -249,12 +249,12 @@ <inputs> (arity_inputs <arity>) <types> (arity_types <arity>) <definitions> (template.spliced <function>+)] - (def: .public (<apply> function [<inputs>]) + (def .public (<apply> function [<inputs>]) (-> Expression [<types>] Computation) (..apply (.list <inputs>) function)) (with_template [<function>] - [(`` (def: .public (~~ (template.symbol [<function> "/" <arity>])) + [(`` (def .public (~~ (template.symbol [<function> "/" <arity>])) (<apply> (..constant <function>))))] <definitions>))] @@ -309,11 +309,11 @@ ["iconv_substr"] ["substr"]]] ) - (def: .public (key_value key value) + (def .public (key_value key value) (-> Expression Expression Expression) (abstraction (format (representation key) " => " (representation value)))) - (def: .public (array/* values) + (def .public (array/* values) (-> (List Expression) Literal) (|> values (list#each ..code) @@ -322,11 +322,11 @@ (format "array") abstraction)) - (def: .public (array_merge/+ required optionals) + (def .public (array_merge/+ required optionals) (-> Expression (List Expression) Computation) (..apply (list.partial required optionals) (..constant "array_merge"))) - (def: .public (array/** kvs) + (def .public (array/** kvs) (-> (List [Expression Expression]) Literal) (|> kvs (list#each (function (_ [key value]) @@ -336,32 +336,32 @@ (format "array") abstraction)) - (def: .public (new constructor inputs) + (def .public (new constructor inputs) (-> Constant (List Expression) Computation) (|> (format "new " (representation constructor) (arguments inputs)) abstraction)) - (def: .public (the field object) + (def .public (the field object) (-> Text Expression Computation) (|> (format (representation object) "->" field) abstraction)) - (def: .public (do method inputs object) + (def .public (do method inputs object) (-> Text (List Expression) Expression Computation) (|> (format (representation (..the method object)) (..arguments inputs)) abstraction)) - (def: .public (item idx array) + (def .public (item idx array) (-> Expression Expression Access) (|> (format (representation array) "[" (representation idx) "]") abstraction)) - (def: .public (global name) + (def .public (global name) (-> Text Global) (|> (..var "GLOBALS") (..item (..string name)) transmutation)) - (def: .public (? test then else) + (def .public (? test then else) (-> Expression Expression Expression Computation) (|> (format (..group (representation test)) " ? " (..group (representation then)) " : " @@ -370,7 +370,7 @@ abstraction)) (with_template [<name> <op>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (-> Expression Expression Computation) (|> (format (representation subject) " " <op> " " (representation parameter)) ..group @@ -398,7 +398,7 @@ ) (with_template [<unary> <name>] - [(def: .public <name> + [(def .public <name> (-> Computation Computation) (|>> representation (format <unary>) abstraction))] @@ -407,22 +407,22 @@ ["-" opposite] ) - (def: .public (set var value) + (def .public (set var value) (-> Location Expression Computation) (|> (format (representation var) " = " (representation value)) ..group abstraction)) - (def: .public (set! var value) + (def .public (set! var value) (-> Location Expression Statement) (abstraction (format (representation var) " = " (representation value) ";"))) - (def: .public (set? var) + (def .public (set? var) (-> Var Computation) (..apply/1 [var] (..constant "isset"))) (with_template [<name> <modifier>] - [(def: .public <name> + [(def .public <name> (-> Var Statement) (|>> representation (format <modifier> " ") (text.suffix ..statement_suffix) abstraction))] @@ -430,7 +430,7 @@ ) (with_template [<name> <modifier> <location>] - [(def: .public (<name> location value) + [(def .public (<name> location value) (-> <location> Expression Statement) (abstraction (format <modifier> " " (representation location) " = " (representation value) @@ -440,7 +440,7 @@ [define_constant "const" Constant] ) - (def: .public (if test then! else!) + (def .public (if test then! else!) (-> Expression Statement Statement Statement) (abstraction (format "if" (..group (representation test)) " " @@ -448,33 +448,33 @@ " else " (..block (representation else!))))) - (def: .public (when test then!) + (def .public (when test then!) (-> Expression Statement Statement) (abstraction (format "if" (..group (representation test)) " " (..block (representation then!))))) - (def: .public (then pre! post!) + (def .public (then pre! post!) (-> Statement Statement Statement) (abstraction (format (representation pre!) \n+ (representation post!)))) - (def: .public (while test body!) + (def .public (while test body!) (-> Expression Statement Statement) (abstraction (format "while" (..group (representation test)) " " (..block (representation body!))))) - (def: .public (do_while test body!) + (def .public (do_while test body!) (-> Expression Statement Statement) (abstraction (format "do " (..block (representation body!)) " while" (..group (representation test)) ..statement_suffix))) - (def: .public (for_each array value body!) + (def .public (for_each array value body!) (-> Expression Var Statement Statement) (abstraction (format "foreach(" (representation array) @@ -487,14 +487,14 @@ #exception Var #handler Statement])) - (def: (catch except) + (def (catch except) (-> Except Text) (let [declaration (format (representation (.the #class except)) " " (representation (.the #exception except)))] (format "catch" (..group declaration) " " (..block (representation (.the #handler except)))))) - (def: .public (try body! excepts) + (def .public (try body! excepts) (-> Statement (List Except) Statement) (abstraction (format "try " (..block (representation body!)) @@ -504,7 +504,7 @@ (text.interposed \n+))))) (with_template [<name> <keyword>] - [(def: .public <name> + [(def .public <name> (-> Expression Statement) (|>> representation (format <keyword> " ") (text.suffix ..statement_suffix) abstraction))] @@ -513,13 +513,13 @@ [echo "echo"] ) - (def: .public (define name value) + (def .public (define name value) (-> Constant Expression Expression) (..apply/2 (..constant "define") [(|> name representation ..string) value])) - (def: .public (define_function name arguments body!) + (def .public (define_function name arguments body!) (-> Constant (List Argument) Statement Statement) (abstraction (format "function " (representation name) @@ -528,7 +528,7 @@ (..block (representation body!))))) (with_template [<name> <keyword>] - [(def: .public <name> + [(def .public <name> Statement (|> <keyword> (text.suffix ..statement_suffix) @@ -538,18 +538,18 @@ [continue "continue"] ) - (def: .public splat + (def .public splat (-> Expression Expression) (|>> representation (format "...") abstraction)) ) -(def: .public (cond clauses else!) +(def .public (cond clauses else!) (-> (List [Expression Statement]) Statement Statement) (list#mix (function (_ [test then!] next!) (..if test then! next!)) else! (list.reversed clauses))) -(def: .public command_line_arguments +(def .public command_line_arguments Var (..var "argv")) diff --git a/stdlib/source/library/lux/target/python.lux b/stdlib/source/library/lux/target/python.lux index 4e85ea258..54a9dbd9c 100644 --- a/stdlib/source/library/lux/target/python.lux +++ b/stdlib/source/library/lux/target/python.lux @@ -1,6 +1,6 @@ (.using [library - [lux (.except Location Code not or and list if int comment exec try the is) + [lux (.except Location Code not or and list if int comment exec try the is def) ["@" target] ["[0]" ffi] [abstract @@ -27,10 +27,10 @@ [type [primitive (.except)]]]]) -(def: input_separator +(.def input_separator ", ") -(def: expression +(.def expression (-> Text Text) (text.enclosed ["(" ")"])) @@ -43,11 +43,11 @@ (these)) ... Added the carriage return for better Windows compatibility. -(def: \n+ +(.def \n+ Text (format text.carriage_return text.new_line)) -(def: nested +(.def nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] (for @.old (|>> (format \n+) @@ -60,23 +60,23 @@ (primitive .public (Code brand) Text - (def: .public equivalence + (.def .public equivalence (All (_ brand) (Equivalence (Code brand))) (implementation - (def: (= reference subject) + (.def (= reference subject) (at text.equivalence = (representation reference) (representation subject))))) - (def: .public hash + (.def .public hash (All (_ brand) (Hash (Code brand))) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> representation (at text.hash hash))))) + (.def equivalence ..equivalence) + (.def hash (|>> representation (at text.hash hash))))) - (def: .public manual + (.def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (.def .public code (-> (Code Any) Text) (|>> representation)) @@ -113,12 +113,12 @@ [KVar Keyword] ) - (def: .public var + (.def .public var (-> Text SVar) (|>> abstraction)) (with_template [<name> <brand> <prefix>] - [(def: .public <name> + [(.def .public <name> (-> SVar (Var <brand>)) (|>> representation (format <prefix>) abstraction))] @@ -126,26 +126,26 @@ [keyword Keyword "**"] ) - (def: .public none + (.def .public none Literal (abstraction "None")) - (def: .public bool + (.def .public bool (-> Bit Literal) (|>> (pipe.case #0 "False" #1 "True") abstraction)) - (def: .public int + (.def .public int (-> Int Literal) (|>> %.int abstraction)) - (def: .public (long value) + (.def .public (long value) (-> Int Literal) (abstraction (format (%.int value) "L"))) - (def: .public float + (.def .public float (-> Frac Literal) (`` (|>> (pipe.cond (~~ (with_template [<test> <python>] [[<test>] @@ -160,7 +160,7 @@ [%.frac]) abstraction))) - (def: safe + (.def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -177,20 +177,20 @@ )) ))) - (def: .public string + (.def .public string (-> Text Literal) (|>> ..safe (text.enclosed [text.double_quote text.double_quote]) abstraction)) - (def: .public unicode + (.def .public unicode (-> Text Literal) (|>> ..string representation (format "u") abstraction)) - (def: (composite_literal left_delimiter right_delimiter entry_serializer) + (.def (composite_literal left_delimiter right_delimiter entry_serializer) (All (_ a) (-> Text Text (-> a Text) (-> (List a) Literal))) @@ -204,7 +204,7 @@ right_delimiter)))) (with_template [<name> <pre> <post>] - [(def: .public <name> + [(.def .public <name> (-> (List (Expression Any)) Literal) (composite_literal <pre> <post> ..code))] @@ -212,23 +212,23 @@ [list "[" "]"] ) - (def: .public (slice from to list) + (.def .public (slice from to list) (-> (Expression Any) (Expression Any) (Expression Any) Access) (<| abstraction ... ..expression (format (representation list) "[" (representation from) ":" (representation to) "]"))) - (def: .public (slice_from from list) + (.def .public (slice_from from list) (-> (Expression Any) (Expression Any) Access) (<| abstraction ... ..expression (format (representation list) "[" (representation from) ":]"))) - (def: .public dict + (.def .public dict (-> (List [(Expression Any) (Expression Any)]) (Computation Any)) (composite_literal "{" "}" (.function (_ [k v]) (format (representation k) " : " (representation v))))) - (def: .public (apply args func) + (.def .public (apply args func) (-> (List (Expression Any)) (Expression Any) (Computation Any)) (<| abstraction ... ..expression @@ -238,7 +238,7 @@ ")"))) (with_template [<name> <brand> <prefix>] - [(def: .public <name> + [(.def .public <name> (-> (Expression Any) (Expression Any)) (|>> representation (format <prefix>) @@ -248,28 +248,28 @@ [splat_keyword Keyword "**"] ) - (def: .public (the name object) + (.def .public (the name object) (-> Text (Expression Any) Access) (abstraction (format (representation object) "." name))) - (def: .public (do method args object) + (.def .public (do method args object) (-> Text (List (Expression Any)) (Expression Any) (Computation Any)) (|> object (..the method) (..apply args))) - (def: .public (item idx array) + (.def .public (item idx array) (-> (Expression Any) (Expression Any) Access) (abstraction (format (representation array) "[" (representation idx) "]"))) - (def: .public (? test then else) + (.def .public (? test then else) (-> (Expression Any) (Expression Any) (Expression Any) (Computation Any)) (<| abstraction ..expression (format (representation then) " if " (representation test) " else " (representation else)))) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(.def .public (<name> param subject) (-> (Expression Any) (Expression Any) (Computation Any)) (<| abstraction ..expression @@ -301,7 +301,7 @@ ) (with_template [<name> <unary>] - [(def: .public (<name> subject) + [(.def .public (<name> subject) (-> (Expression Any) (Computation Any)) (<| abstraction ... ..expression @@ -311,31 +311,31 @@ [opposite "-"] ) - (def: .public (lambda arguments body) + (.def .public (lambda arguments body) (-> (List (Var Any)) (Expression Any) (Computation Any)) (<| abstraction ..expression (format "lambda " (|> arguments (list#each ..code) (text.interposed ..input_separator)) ": " (representation body)))) - (def: .public (set vars value) + (.def .public (set vars value) (-> (List (Location Any)) (Expression Any) (Statement Any)) (abstraction (format (|> vars (list#each ..code) (text.interposed ..input_separator)) " = " (representation value)))) - (def: .public multi + (.def .public multi (-> (List (Expression Any)) (Expression Any)) (|>> (list#each ..code) (text.interposed ..input_separator) abstraction)) - (def: .public (delete where) + (.def .public (delete where) (-> (Location Any) (Statement Any)) (abstraction (format "del " (representation where)))) - (def: .public (if test then! else!) + (.def .public (if test then! else!) (-> (Expression Any) (Statement Any) (Statement Any) (Statement Any)) (abstraction (format "if " (representation test) ":" @@ -343,13 +343,13 @@ \n+ "else:" (..nested (representation else!))))) - (def: .public (when test then!) + (.def .public (when test then!) (-> (Expression Any) (Statement Any) (Statement Any)) (abstraction (format "if " (representation test) ":" (..nested (representation then!))))) - (def: .public (then pre! post!) + (.def .public (then pre! post!) (-> (Statement Any) (Statement Any) (Statement Any)) (abstraction (format (representation pre!) @@ -357,7 +357,7 @@ (representation post!)))) (with_template [<keyword> <0>] - [(def: .public <0> + [(.def .public <0> (Statement Any) (abstraction <keyword>))] @@ -365,7 +365,7 @@ ["continue" continue] ) - (def: .public (while test body! else!) + (.def .public (while test body! else!) (-> (Expression Any) (Statement Any) (Maybe (Statement Any)) Loop) (abstraction (format "while " (representation test) ":" @@ -378,17 +378,17 @@ {.#None} "")))) - (def: .public (for_in var inputs body!) + (.def .public (for_in var inputs body!) (-> SVar (Expression Any) (Statement Any) Loop) (abstraction (format "for " (representation var) " in " (representation inputs) ":" (..nested (representation body!))))) - (def: .public statement + (.def .public statement (-> (Expression Any) (Statement Any)) (|>> transmutation)) - (def: .public pass + (.def .public pass (Statement Any) (abstraction "pass")) @@ -398,7 +398,7 @@ #exception SVar #handler (Statement Any)])) - (def: .public (try body! excepts) + (.def .public (try body! excepts) (-> (Statement Any) (List Except) (Statement Any)) (abstraction (format "try:" @@ -411,7 +411,7 @@ text.together)))) (with_template [<name> <keyword> <pre>] - [(def: .public (<name> value) + [(.def .public (<name> value) (-> (Expression Any) (Statement Any)) (abstraction (format <keyword> (<pre> (representation value)))))] @@ -421,7 +421,7 @@ [print "print" ..expression] ) - (def: .public (exec globals code) + (.def .public (exec globals code) (-> (Maybe (Expression Any)) (Expression Any) (Statement Any)) (let [extra (case globals {.#Some globals} @@ -432,7 +432,7 @@ (abstraction (format "exec" (representation (..tuple (list.partial code extra))))))) - (def: .public (def name args body) + (.def .public (def name args body) (-> SVar (List (Ex (_ k) (Var k))) (Statement Any) (Statement Any)) (abstraction (format "def " (representation name) @@ -441,17 +441,17 @@ "):" (..nested (representation body))))) - (def: .public (import module_name) + (.def .public (import module_name) (-> Text (Statement Any)) (abstraction (format "import " module_name))) - (def: .public (comment commentary on) + (.def .public (comment commentary on) (All (_ brand) (-> Text (Code brand) (Code brand))) (abstraction (format "# " (text.replaced text.\n "\n" commentary) \n+ (representation on)))) ) -(def: arity_inputs +(.def arity_inputs (syntax (_ [arity <code>.nat]) (in (case arity 0 (.list) @@ -459,7 +459,7 @@ (enum.range n.enum 0) (list#each (|>> %.nat code.local))))))) -(def: arity_types +(.def arity_types (syntax (_ [arity <code>.nat]) (in (list.repeated arity (` (Expression Any)))))) @@ -467,7 +467,7 @@ [(with_expansions [<inputs> (arity_inputs <arity>) <definitions> (template.spliced <function>+)] (with_template [<function>] - [(`` (def: .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>) + [(`` (.def .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>) (-> (~~ (arity_types <arity>)) (Computation Any)) (..apply (.list <inputs>) (..var <function>))))] diff --git a/stdlib/source/library/lux/target/r.lux b/stdlib/source/library/lux/target/r.lux index 4956df9c0..f31a950fe 100644 --- a/stdlib/source/library/lux/target/r.lux +++ b/stdlib/source/library/lux/target/r.lux @@ -49,45 +49,45 @@ [PVar Poly] ) - (def: .public var + (def .public var (-> Text SVar) (|>> abstraction)) - (def: .public var_args + (def .public var_args PVar (abstraction "...")) - (def: .public manual + (def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) - (def: (self_contained code) + (def (self_contained code) (-> Text Expression) (abstraction (format "(" code ")"))) ... Added the carriage return for better Windows compatibility. - (def: \n+ + (def \n+ Text (format text.carriage_return text.new_line)) - (def: nested_new_line + (def nested_new_line (format text.new_line text.tab)) - (def: nested + (def nested (-> Text Text) (|>> (text.replaced text.new_line ..nested_new_line) (format text.carriage_return ..nested_new_line))) - (def: (_block expression) + (def (_block expression) (-> Text Text) (format "{" (nested expression) \n+ "}")) - (def: .public (block expression) + (def .public (block expression) (-> Expression Expression) (abstraction (format "{" @@ -95,7 +95,7 @@ \n+ "}"))) (with_template [<name> <r>] - [(def: .public <name> + [(def .public <name> Expression (abstraction <r>))] @@ -104,25 +104,25 @@ ) (with_template [<name>] - [(def: .public <name> Expression n/a)] + [(def .public <name> Expression n/a)] [not_available] [not_applicable] [no_answer] ) - (def: .public bool + (def .public bool (-> Bit Expression) (|>> (pipe.case #0 "FALSE" #1 "TRUE") abstraction)) - (def: .public int + (def .public int (-> Int Expression) (|>> %.int abstraction)) - (def: .public float + (def .public float (-> Frac Expression) (|>> (pipe.cond [(f.= f.positive_infinity)] [(pipe.new "1.0/0.0" [])] @@ -137,7 +137,7 @@ [%.frac]) ..self_contained)) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -153,23 +153,23 @@ )) ))) - (def: .public string + (def .public string (-> Text Expression) (|>> ..safe %.text abstraction)) - (def: .public (slice from to list) + (def .public (slice from to list) (-> Expression Expression Expression Expression) (..self_contained (format (representation list) "[" (representation from) ":" (representation to) "]"))) - (def: .public (slice_from from list) + (def .public (slice_from from list) (-> Expression Expression Expression) (..self_contained (format (representation list) "[-1" ":-" (representation from) "]"))) - (def: .public (apply args func) + (def .public (apply args func) (-> (List Expression) Expression Expression) (let [func (representation func) spacing (|> " " @@ -184,7 +184,7 @@ ")")))) (with_template [<name> <function>] - [(def: .public (<name> members) + [(def .public (<name> members) (-> (List Expression) Expression) (..apply members (..var <function>)))] @@ -192,13 +192,13 @@ [list "list"] ) - (def: .public named_list + (def .public named_list (-> (List [Text Expression]) Expression) (|>> (list#each (.function (_ [key value]) (abstraction (format key "=" (representation value))))) ..list)) - (def: .public (apply_kw args kw_args func) + (def .public (apply_kw args kw_args func) (-> (List Expression) (List [Text Expression]) Expression Expression) (..self_contained (format (representation func) @@ -209,7 +209,7 @@ kw_args)) ")")))) - (def: arity_inputs + (def arity_inputs (syntax (_ [arity <code>.nat]) (in (case arity 0 (.list) @@ -217,7 +217,7 @@ list.indices (list#each (|>> %.nat code.local))))))) - (def: arity_types + (def arity_types (syntax (_ [arity <code>.nat]) (in (list.repeated arity (` ..Expression))))) @@ -226,12 +226,12 @@ <inputs> (arity_inputs <arity>) <types> (arity_types <arity>) <definitions> (template.spliced <function>+)] - (def: .public (<apply> function [<inputs>]) + (def .public (<apply> function [<inputs>]) (-> Expression [<types>] Expression) (..apply (.list <inputs>) function)) (with_template [<function>] - [(`` (def: .public (~~ (template.symbol [<function> "/" <arity>])) + [(`` (def .public (~~ (template.symbol [<function> "/" <arity>])) (-> [<types>] Expression) (<apply> (..var <function>))))] @@ -245,30 +245,30 @@ [["paste"]]] ) - (def: .public as::integer + (def .public as::integer (-> Expression Expression) (..apply/1 (..var "as.integer"))) - (def: .public (item idx list) + (def .public (item idx list) (-> Expression Expression Expression) (..self_contained (format (representation list) "[[" (representation idx) "]]"))) - (def: .public (if test then else) + (def .public (if test then else) (-> Expression Expression Expression Expression) (abstraction (format "if(" (representation test) ")" " " (.._block (representation then)) " else " (.._block (representation else))))) - (def: .public (when test then) + (def .public (when test then) (-> Expression Expression Expression) (abstraction (format "if(" (representation test) ") {" (.._block (representation then)) \n+ "}"))) - (def: .public (cond clauses else) + (def .public (cond clauses else) (-> (List [Expression Expression]) Expression Expression) (list#mix (.function (_ [test then] next) (if test then next)) @@ -276,7 +276,7 @@ (list.reversed clauses))) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Expression Expression Expression) (..self_contained (format (representation subject) @@ -299,7 +299,7 @@ ) (with_template [<name> <func>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Expression Expression Expression) (..apply (.list subject param) (..var <func>)))] @@ -310,12 +310,12 @@ [bit_ushr "bitwShiftR"] ) - (def: .public (bit_not subject) + (def .public (bit_not subject) (-> Expression Expression) (..apply (.list subject) (..var "bitwNot"))) (with_template [<name> <op>] - [(def: .public <name> + [(def .public <name> (-> Expression Expression) (|>> representation (format <op>) ..self_contained))] @@ -323,23 +323,23 @@ [negate "-"] ) - (def: .public (length list) + (def .public (length list) (-> Expression Expression) (..apply (.list list) (..var "length"))) - (def: .public (range from to) + (def .public (range from to) (-> Expression Expression Expression) (..self_contained (format (representation from) ":" (representation to)))) - (def: .public (function inputs body) + (def .public (function inputs body) (-> (List (Ex (_ k) (Var k))) Expression Expression) (let [args (|> inputs (list#each ..code) (text.interposed ", "))] (..self_contained (format "function(" args ") " (.._block (representation body)))))) - (def: .public (try body warning error finally) + (def .public (try body warning error finally) (-> Expression (Maybe Expression) (Maybe Expression) (Maybe Expression) Expression) (let [optional (is (-> Text (Maybe Expression) (-> Text Text) Text) (.function (_ parameter value preparation) @@ -354,20 +354,20 @@ (optional "finally" finally .._block) ")")))) - (def: .public (while test body) + (def .public (while test body) (-> Expression Expression Expression) (..self_contained (format "while (" (representation test) ") " (.._block (representation body))))) - (def: .public (for_in var inputs body) + (def .public (for_in var inputs body) (-> SVar Expression Expression Expression) (..self_contained (format "for (" (representation var) " in " (representation inputs) ")" (.._block (representation body))))) (with_template [<name> <keyword>] - [(def: .public (<name> message) + [(def .public (<name> message) (-> Expression Expression) (..apply (.list message) (..var <keyword>)))] @@ -375,17 +375,17 @@ [print "print"] ) - (def: .public (set! var value) + (def .public (set! var value) (-> SVar Expression Expression) (..self_contained (format (representation var) " <- " (representation value)))) - (def: .public (set_item! idx value list) + (def .public (set_item! idx value list) (-> Expression Expression SVar Expression) (..self_contained (format (representation list) "[[" (representation idx) "]] <- " (representation value)))) - (def: .public (then pre post) + (def .public (then pre post) (-> Expression Expression Expression) (abstraction (format (representation pre) diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux index ae928f407..d196e2308 100644 --- a/stdlib/source/library/lux/target/ruby.lux +++ b/stdlib/source/library/lux/target/ruby.lux @@ -26,15 +26,15 @@ [type [primitive (.except)]]]]) -(def: input_separator ", ") -(def: statement_suffix ";") +(def input_separator ", ") +(def statement_suffix ";") ... Added the carriage return for better Windows compatibility. -(def: \n+ +(def \n+ Text (format text.carriage_return text.new_line)) -(def: nested +(def nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] (|>> (format \n+) @@ -43,17 +43,17 @@ (primitive .public (Code brand) Text - (def: .public equivalence + (def .public equivalence (All (_ brand) (Equivalence (Code brand))) (implementation - (def: (= reference subject) + (def (= reference subject) (at text.equivalence = (representation reference) (representation subject))))) - (def: .public manual + (def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) @@ -86,7 +86,7 @@ ) (with_template [<var> <prefix> <constructor>] - [(def: .public <constructor> + [(def .public <constructor> (-> Text <var>) (|>> (format <prefix>) abstraction))] @@ -99,7 +99,7 @@ (with_template [<var> <prefix> <modifier> <unpacker>] [(with_template [<name> <input> <output>] - [(def: .public <name> + [(def .public <name> (-> <input> <output>) (|>> representation (format <prefix>) abstraction))] @@ -112,7 +112,7 @@ ) (with_template [<ruby_name> <lux_name>] - [(def: .public <lux_name> + [(def .public <lux_name> GVar (..global <ruby_name>))] @@ -134,31 +134,31 @@ ) (with_template [<ruby_name> <lux_name>] - [(def: .public <lux_name> + [(def .public <lux_name> CVar (..manual <ruby_name>))] ["ARGV" command_line_arguments] ) - (def: .public multi + (def .public multi (-> (List Expression) Expression) (|>> (list#each ..code) (text.interposed ..input_separator) abstraction)) - (def: .public nil + (def .public nil Literal (abstraction "nil")) - (def: .public bool + (def .public bool (-> Bit Literal) (|>> (pipe.case #0 "false" #1 "true") abstraction)) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -176,7 +176,7 @@ ))) (with_template [<format> <name> <type> <prep>] - [(def: .public <name> + [(def .public <name> (-> <type> Literal) (|>> <prep> <format> abstraction))] @@ -185,7 +185,7 @@ [(<|) symbol Text (format ":")] ) - (def: .public float + (def .public float (-> Frac Literal) (|>> (pipe.cond [(f.= f.positive_infinity)] [(pipe.new "(+1.0/0.0)" [])] @@ -200,21 +200,21 @@ [%.frac]) abstraction)) - (def: .public (array_range from to array) + (def .public (array_range from to array) (-> Expression Expression Expression Computation) (|> (format (representation from) ".." (representation to)) (text.enclosed ["[" "]"]) (format (representation array)) abstraction)) - (def: .public array + (def .public array (-> (List Expression) Computation) (|>> (list#each (|>> representation (text.suffix ..input_separator))) text.together (text.enclosed ["[" "]"]) abstraction)) - (def: .public hash + (def .public hash (-> (List [Expression Expression]) Computation) (|>> (list#each (.function (_ [k v]) (format (representation k) " => " (representation v) ..input_separator))) @@ -222,7 +222,7 @@ (text.enclosed ["{" "}"]) abstraction)) - (def: (control_structure content) + (def (control_structure content) (-> Text Text) (format content \n+ "end" ..statement_suffix)) @@ -232,7 +232,7 @@ [#parameters (List Var) #body Statement])) - (def: (block it) + (def (block it) (-> Block Text) (|> (format (|> (.the #parameters it) (list#each (|>> representation)) @@ -241,7 +241,7 @@ (..nested (representation (.the #body it)))) (text.enclosed ["{" "}"]))) - (def: .public (apply arguments block func) + (def .public (apply arguments block func) (-> (List Expression) (Maybe Block) Expression Computation) (let [arguments (|> arguments (list#each (|>> representation)) @@ -263,18 +263,18 @@ (text.enclosed' "|")))))] (abstraction (format (representation func) arguments block)))) - (def: .public (the field object) + (def .public (the field object) (-> Text Expression Access) (abstraction (format (representation object) "." field))) - (def: .public (item idx array) + (def .public (item idx array) (-> Expression Expression Access) (|> (representation idx) (text.enclosed ["[" "]"]) (format (representation array)) abstraction)) - (def: .public (? test then else) + (def .public (? test then else) (-> Expression Expression Expression Computation) (|> (format (representation test) " ? " (representation then) " : " @@ -282,20 +282,20 @@ (text.enclosed ["(" ")"]) abstraction)) - (def: .public statement + (def .public statement (-> Expression Statement) (|>> representation (text.suffix ..statement_suffix) abstraction)) - (def: .public (then pre! post!) + (def .public (then pre! post!) (-> Statement Statement Statement) (abstraction (format (representation pre!) \n+ (representation post!)))) - (def: .public (set vars value) + (def .public (set vars value) (-> (List Location) Expression Statement) (abstraction (format (|> vars @@ -303,7 +303,7 @@ (text.interposed ..input_separator)) " = " (representation value) ..statement_suffix))) - (def: .public (if test then! else!) + (def .public (if test then! else!) (-> Expression Statement Statement Statement) (<| abstraction ..control_structure @@ -313,7 +313,7 @@ (..nested (representation else!))))) (with_template [<name> <control_structure>] - [(def: .public (<name> test then!) + [(def .public (<name> test then!) (-> Expression Statement Statement) (<| abstraction ..control_structure @@ -324,7 +324,7 @@ [while "while"] ) - (def: .public (for_in var array iteration!) + (def .public (for_in var array iteration!) (-> LVar Expression Statement Statement) (<| abstraction ..control_structure @@ -339,7 +339,7 @@ #exception LVar #rescue Statement])) - (def: .public (begin body! rescues) + (def .public (begin body! rescues) (-> Statement (List Rescue) Statement) (<| abstraction ..control_structure @@ -351,22 +351,22 @@ (..nested (representation rescue))))) (text.interposed \n+))))) - (def: .public (catch expectation block) + (def .public (catch expectation block) (-> Expression Block Expression) (<| abstraction (format "catch(" (representation expectation) ") " (..block block)))) - (def: .public (return value) + (def .public (return value) (-> Expression Statement) (abstraction (format "return " (representation value) ..statement_suffix))) - (def: .public (raise message) + (def .public (raise message) (-> Expression Expression) (abstraction (format "raise " (representation message)))) (with_template [<name> <keyword>] - [(def: .public <name> + [(def .public <name> Statement (|> <keyword> (text.suffix ..statement_suffix) @@ -377,11 +377,11 @@ [break "break"] ) - (def: .public initialize + (def .public initialize LVar (..manual "initialize")) - (def: .public (function name args body!) + (def .public (function name args body!) (-> LVar (List LVar) Statement Statement) (<| abstraction ..control_structure @@ -392,7 +392,7 @@ (text.enclosed ["(" ")"])) (..nested (representation body!))))) - (def: .public (lambda name block) + (def .public (lambda name block) (-> (Maybe LVar) Block Literal) (let [proc (format "lambda " (..block block))] (|> (case name @@ -405,7 +405,7 @@ abstraction))) (with_template [<op> <name>] - [(def: .public (<name> parameter subject) + [(def .public (<name> parameter subject) (-> Expression Expression Computation) (abstraction (format "(" (representation subject) " " <op> " " (representation parameter) ")")))] @@ -433,7 +433,7 @@ ) (with_template [<unary> <name>] - [(def: .public (<name> subject) + [(def .public (<name> subject) (-> Expression Computation) (abstraction (format "(" <unary> (representation subject) ")")))] @@ -442,13 +442,13 @@ ["-" opposite] ) - (def: .public (comment commentary on) + (def .public (comment commentary on) (All (_ brand) (-> Text (Code brand) (Code brand))) (abstraction (format "# " (..safe commentary) \n+ (representation on)))) (with_template [<name>] - [(`` (def: .public ((~~ (template.symbol [<name> "/*"])) attributes) + [(`` (def .public ((~~ (template.symbol [<name> "/*"])) attributes) (-> (List Text) Statement) (..statement (..apply (list#each ..string attributes) {.#None} (..manual <name>)))))] @@ -458,30 +458,30 @@ ["attr_accessor"]) ) -(def: .public (do method arguments block object) +(def .public (do method arguments block object) (-> Text (List Expression) (Maybe Block) Expression Computation) (|> object (..the method) (..apply arguments block))) -(def: .public new +(def .public new (-> (List Expression) (Maybe Block) Expression Computation) (..do "new")) -(def: .public (class definition) +(def .public (class definition) (-> Block Computation) (|> (..manual "Class") (..new (list) {.#Some definition}))) -(def: .public (module definition) +(def .public (module definition) (-> Block Computation) (|> (..manual "Module") (..new (list) {.#Some definition}))) -(def: .public (apply_lambda args lambda) +(def .public (apply_lambda args lambda) (-> (List Expression) Expression Computation) (|> lambda (..do "call" args {.#None}))) -(def: arity_inputs +(def arity_inputs (syntax (_ [arity <code>.nat]) (in (case arity 0 (.list) @@ -489,7 +489,7 @@ (enum.range n.enum 0) (list#each (|>> %.nat code.local))))))) -(def: arity_types +(def arity_types (syntax (_ [arity <code>.nat]) (in (list.repeated arity (` ..Expression))))) @@ -499,7 +499,7 @@ <types> (arity_types <arity>) <definitions> (template.spliced <function>+)] (with_template [<function>] - [(`` (def: .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>) + [(`` (def .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>) (-> <types> Computation) (..apply (.list <inputs>) {.#None} (..manual <function>))))] @@ -520,18 +520,18 @@ ["alias_method"]]] ) -(def: .public (throw/1 error) +(def .public (throw/1 error) (-> Expression Statement) (..statement (..apply (list error) {.#None} (..manual "throw")))) -(def: .public (throw/2 tag value) +(def .public (throw/2 tag value) (-> Expression Expression Statement) (..statement (..apply (list tag value) {.#None} (..manual "throw")))) -(def: .public (class_variable_set var value object) +(def .public (class_variable_set var value object) (-> SVar Expression Expression Computation) (..do "class_variable_set" (list (..string (..code var)) value) {.#None} object)) -(def: .public (class_variable_get var object) +(def .public (class_variable_get var object) (-> SVar Expression Computation) (..do "class_variable_get" (list (..string (..code var))) {.#None} object)) diff --git a/stdlib/source/library/lux/target/scheme.lux b/stdlib/source/library/lux/target/scheme.lux index c0632b5be..c3d1722b1 100644 --- a/stdlib/source/library/lux/target/scheme.lux +++ b/stdlib/source/library/lux/target/scheme.lux @@ -22,11 +22,11 @@ [primitive (.except)]]]]) ... Added the carriage return for better Windows compatibility. -(def: \n+ +(def \n+ Text (format text.carriage_return text.new_line)) -(def: nested +(def nested (-> Text Text) (.let [nested_new_line (format text.new_line text.tab)] (text.replaced text.new_line nested_new_line))) @@ -34,17 +34,17 @@ (primitive .public (Code k) Text - (def: .public equivalence + (def .public equivalence (All (_ brand) (Equivalence (Code brand))) (implementation - (def: (= reference subject) + (def (= reference subject) (at text.equivalence = (representation reference) (representation subject))))) - (def: .public hash + (def .public hash (All (_ brand) (Hash (Code brand))) (implementation - (def: equivalence ..equivalence) - (def: hash (|>> representation (at text.hash hash))))) + (def equivalence ..equivalence) + (def hash (|>> representation (at text.hash hash))))) (with_template [<type> <brand> <super>+] [(primitive .public (<brand> brand) Any) @@ -66,19 +66,19 @@ [#mandatory (List Var) #rest (Maybe Var)])) - (def: .public manual + (def .public manual (-> Text Code) (|>> abstraction)) - (def: .public code + (def .public code (-> (Code Any) Text) (|>> representation)) - (def: .public var + (def .public var (-> Text Var) (|>> abstraction)) - (def: (arguments [mandatory rest]) + (def (arguments [mandatory rest]) (-> Arguments (Code Any)) (case rest {.#Some rest} @@ -101,22 +101,22 @@ (text.enclosed ["(" ")"]) abstraction))) - (def: .public nil + (def .public nil Computation (abstraction "'()")) - (def: .public bool + (def .public bool (-> Bit Computation) (|>> (pipe.case #0 "#f" #1 "#t") abstraction)) - (def: .public int + (def .public int (-> Int Computation) (|>> %.int abstraction)) - (def: .public float + (def .public float (-> Frac Computation) (|>> (pipe.cond [(f.= f.positive_infinity)] [(pipe.new "+inf.0" [])] @@ -131,11 +131,11 @@ [%.frac]) abstraction)) - (def: .public positive_infinity Computation (..float f.positive_infinity)) - (def: .public negative_infinity Computation (..float f.negative_infinity)) - (def: .public not_a_number Computation (..float f.not_a_number)) + (def .public positive_infinity Computation (..float f.positive_infinity)) + (def .public negative_infinity Computation (..float f.negative_infinity)) + (def .public not_a_number Computation (..float f.not_a_number)) - (def: safe + (def safe (-> Text Text) (`` (|>> (~~ (with_template [<find> <replace>] [(text.replaced <find> <replace>)] @@ -151,15 +151,15 @@ )) ))) - (def: .public string + (def .public string (-> Text Computation) (|>> ..safe %.text abstraction)) - (def: .public symbol + (def .public symbol (-> Text Computation) (|>> (format "'") abstraction)) - (def: form + (def form (-> (List (Code Any)) Code) (.let [nested_new_line (format \n+ text.tab)] (|>> (pipe.case @@ -174,12 +174,12 @@ (text.enclosed ["(" ")"]) abstraction))))) - (def: .public (apply args func) + (def .public (apply args func) (-> (List Expression) Expression Computation) (..form {.#Item func args})) (with_template [<name> <function>] - [(def: .public (<name> members) + [(def .public (<name> members) (-> (List Expression) Computation) (..apply members (..var <function>)))] @@ -187,25 +187,25 @@ [list/* "list"] ) - (def: .public apply/0 + (def .public apply/0 (-> Expression Computation) (..apply (list))) (with_template [<lux_name> <scheme_name>] - [(def: .public <lux_name> + [(def .public <lux_name> (apply/0 (..var <scheme_name>)))] [newline/0 "newline"] ) (with_template [<apply> <arg>+ <type>+ <function>+] - [(`` (def: .public (<apply> procedure) + [(`` (def .public (<apply> procedure) (-> Expression (~~ (template.spliced <type>+)) Computation) (function (_ (~~ (template.spliced <arg>+))) (..apply (list (~~ (template.spliced <arg>+))) procedure)))) (`` (with_template [<definition> <function>] - [(def: .public <definition> (<apply> (..var <function>)))] + [(def .public <definition> (<apply> (..var <function>)))] (~~ (template.spliced <function>+))))] @@ -269,12 +269,12 @@ ... 1. To carry on, and then, when it's time to compile the compiler ... itself into Scheme, switch from 'invoke' to normal 'vector-ref'. ... Either way, the 'invoke' needs to go away. - (def: .public (vector_ref/2 vector index) + (def .public (vector_ref/2 vector index) (-> Expression Expression Computation) (..form (list (..var "invoke") vector (..symbol "getRaw") index))) (with_template [<lux_name> <scheme_name>] - [(def: .public (<lux_name> param subject) + [(def .public (<lux_name> param subject) (-> Expression Expression Computation) (..apply/2 (..var <scheme_name>) subject param))] @@ -302,7 +302,7 @@ ) (with_template [<lux_name> <scheme_name>] - [(def: .public <lux_name> + [(def .public <lux_name> (-> (List Expression) Computation) (|>> (list.partial (..var <scheme_name>)) ..form))] @@ -311,7 +311,7 @@ ) (with_template [<lux_name> <scheme_name> <var> <pre>] - [(def: .public (<lux_name> bindings body) + [(def .public (<lux_name> bindings body) (-> (List [<var> Expression]) Expression Computation) (..form (list (..var <scheme_name>) (|> bindings @@ -329,21 +329,21 @@ [letrec_values "letrec-values" Arguments ..arguments] ) - (def: .public (if test then else) + (def .public (if test then else) (-> Expression Expression Expression Computation) (..form (list (..var "if") test then else))) - (def: .public (when test then) + (def .public (when test then) (-> Expression Expression Computation) (..form (list (..var "when") test then))) - (def: .public (lambda arguments body) + (def .public (lambda arguments body) (-> Arguments Expression Computation) (..form (list (..var "lambda") (..arguments arguments) body))) - (def: .public (define_function name arguments body) + (def .public (define_function name arguments body) (-> Var Arguments Expression Computation) (..form (list (..var "define") (|> arguments @@ -351,27 +351,27 @@ ..arguments) body))) - (def: .public (define_constant name value) + (def .public (define_constant name value) (-> Var Expression Computation) (..form (list (..var "define") name value))) - (def: .public begin + (def .public begin (-> (List Expression) Computation) (|>> {.#Item (..var "begin")} ..form)) - (def: .public (set! name value) + (def .public (set! name value) (-> Var Expression Computation) (..form (list (..var "set!") name value))) - (def: .public (with_exception_handler handler body) + (def .public (with_exception_handler handler body) (-> Expression Expression Computation) (..form (list (..var "with-exception-handler") handler body))) - (def: .public (call_with_current_continuation body) + (def .public (call_with_current_continuation body) (-> Expression Computation) (..form (list (..var "call-with-current-continuation") body))) - (def: .public (guard variable clauses else body) + (def .public (guard variable clauses else body) (-> Var (List [Expression Expression]) (Maybe Expression) Expression Computation) (..form (list (..var "guard") (..form (|> (case else diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index d0a87c083..071798222 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -49,7 +49,7 @@ #expected_coverage (Set Symbol) #actual_coverage (Set Symbol)])) -(def: (total parameter subject) +(def (total parameter subject) (-> Tally Tally Tally) [#successes (n.+ (the #successes parameter) (the #successes subject)) #failures (n.+ (the #failures parameter) (the #failures subject)) @@ -58,7 +58,7 @@ #actual_coverage (set.union (the #actual_coverage parameter) (the #actual_coverage subject))]) -(def: start +(def start Tally [#successes 0 #failures 0 @@ -66,7 +66,7 @@ #actual_coverage (set.empty symbol.hash)]) (with_template [<name> <category>] - [(def: <name> + [(def <name> Tally (revised <category> .++ ..start))] @@ -80,10 +80,10 @@ (type: .public Test (Random Assertion)) -(def: separator +(def separator text.new_line) -(def: .public (and' left right) +(def .public (and' left right) (-> Assertion Assertion Assertion) (let [[read! write!] (is [(Async [Tally Text]) (async.Resolver [Tally Text])] @@ -97,13 +97,13 @@ io.run!)] read!)) -(def: .public (and left right) +(def .public (and left right) (-> Test Test Test) (do [! random.monad] [left left] (at ! each (..and' left) right))) -(def: (context' description) +(def (context' description) (-> Text Test Test) (random#each (async#each (function (_ [tally documentation]) [tally (|> documentation @@ -112,61 +112,61 @@ (text.interposed ..separator) (format description ..separator))])))) -(def: .public context +(def .public context (-> Text Test Test) (|>> %.text context')) -(def: failure_prefix "[Failure] ") -(def: success_prefix "[Success] ") +(def failure_prefix "[Failure] ") +(def success_prefix "[Success] ") -(def: .public failure +(def .public failure (-> Text Test) (|>> (format ..failure_prefix) [..failure_tally] async#in random#in)) -(def: .public (assertion message condition) +(def .public (assertion message condition) (-> Text Bit Assertion) (<| async#in (if condition [..success_tally (format ..success_prefix message)] [..failure_tally (format ..failure_prefix message)]))) -(def: .public (property message condition) +(def .public (property message condition) (-> Text Bit Test) (random#in (..assertion (%.text message) condition))) -(def: .public (lifted message random) +(def .public (lifted message random) (-> Text (Random Bit) Test) (random#each (..assertion (%.text message)) random)) -(def: pcg_32_magic_inc +(def pcg_32_magic_inc Nat (hex "FEDCBA9876543210")) (type: .public Seed Nat) -(def: .public (seed value test) +(def .public (seed value test) (-> Seed Test Test) (function (_ prng) (let [[_ result] (random.result (random.pcg_32 [..pcg_32_magic_inc value]) test)] [prng result]))) -(def: failed? +(def failed? (-> Tally Bit) (|>> (the #failures) (n.> 0))) -(def: (times_failure seed documentation) +(def (times_failure seed documentation) (-> Seed Text Text) (format documentation ..separator ..separator "Failed with this seed: " (%.nat seed))) (exception: .public must_try_test_at_least_once) -(def: .public (times amount test) +(def .public (times amount test) (-> Nat Test Test) (case amount 0 (..failure (exception.error ..must_try_test_at_least_once [])) @@ -185,7 +185,7 @@ (random.result prng') product.right))))]))))) -(def: (description duration tally) +(def (description duration tally) (-> Duration Tally Text) (let [successes (the #successes tally) failures (the #failures tally) @@ -235,10 +235,10 @@ "Pending definitions to cover" (report missing) "Unexpected definitions covered" (report unexpected)))) -(def: failure_exit_code +1) -(def: success_exit_code +0) +(def failure_exit_code +1) +(def success_exit_code +0) -(def: .public (run! test) +(def .public (run! test) (-> Test (Async Nothing)) (do async.monad [pre (async.future instant.now) @@ -264,15 +264,15 @@ 0 ..success_exit_code _ ..failure_exit_code))))) -(def: definition_separator " & ") +(def definition_separator " & ") -(def: clean_up_marker (text.of_char (hex "05"))) +(def clean_up_marker (text.of_char (hex "05"))) -(def: coverage_format +(def coverage_format (%.Format Symbol) (|>> %.symbol (format ..clean_up_marker))) -(def: (|coverage'| coverage condition) +(def (|coverage'| coverage condition) (-> (List Symbol) Bit Assertion) (let [message (|> coverage (list#each ..coverage_format) @@ -283,12 +283,12 @@ [(revised #actual_coverage (set.union coverage) tally) documentation]))))) -(def: (|coverage| coverage condition) +(def (|coverage| coverage condition) (-> (List Symbol) Bit Test) (|> (..|coverage'| coverage condition) random#in)) -(def: (|for| coverage test) +(def (|for| coverage test) (-> (List Symbol) Test Test) (let [context (|> coverage (list#each ..coverage_format) @@ -299,22 +299,22 @@ documentation])) (..context' context test)))) -(def: (symbol_code symbol) +(def (symbol_code symbol) (-> Symbol Code) (code.tuple (list (code.text (symbol.module symbol)) (code.text (symbol.short symbol))))) -(def: reference +(def reference (syntax (_ [name <code>.symbol]) (do meta.monad [_ (meta.export name)] (in (list (symbol_code name)))))) -(def: coverage_separator +(def coverage_separator Text (text.of_char 31)) -(def: encoded_coverage +(def encoded_coverage (-> (List Text) Text) (list#mix (function (_ short aggregate) (case aggregate @@ -322,7 +322,7 @@ _ (format aggregate ..coverage_separator short))) "")) -(def: (coverage_definitions module encoding) +(def (coverage_definitions module encoding) (-> Text Text (Set Symbol)) (loop (again [remaining encoding output (set.of_list symbol.hash (list))]) @@ -334,7 +334,7 @@ (set.has [module remaining] output)))) (with_template [<macro> <function>] - [(def: .public <macro> + [(def .public <macro> (syntax (_ [coverage (<code>.tuple (<>.many <code>.any)) condition <code>.any]) (let [coverage (list#each (function (_ definition) @@ -349,7 +349,7 @@ [coverage ..|coverage|] ) -(def: .public for +(def .public for (syntax (_ [coverage (<code>.tuple (<>.many <code>.any)) test <code>.any]) (let [coverage (list#each (function (_ definition) @@ -360,7 +360,7 @@ (.list (~+ coverage))) (~ test)))))))) -(def: (covering' module coverage test) +(def (covering' module coverage test) (-> Text Text Test Test) (let [coverage (..coverage_definitions module coverage)] (|> (..context' module test) @@ -370,7 +370,7 @@ (text.replaced (format ..clean_up_marker module symbol.separator) "") (text.replaced ..clean_up_marker ""))])))))) -(def: .public covering +(def .public covering (syntax (_ [module <code>.symbol test <code>.any]) (do meta.monad @@ -392,7 +392,7 @@ (exception.report "Error" (%.text error))) -(def: .public (in_parallel tests) +(def .public (in_parallel tests) (-> (List Test) Test) (case (list.size tests) 0 diff --git a/stdlib/source/library/lux/time.lux b/stdlib/source/library/lux/time.lux index b977ceba1..f7a4ddee9 100644 --- a/stdlib/source/library/lux/time.lux +++ b/stdlib/source/library/lux/time.lux @@ -24,7 +24,7 @@ ["[0]" duration (.only Duration)]]) (with_template [<name> <singular> <plural>] - [(def: .public <name> + [(def .public <name> Nat (.nat (duration.ticks <singular> <plural>)))] @@ -34,7 +34,7 @@ [hours duration.hour duration.day] ) -(def: limit +(def limit Nat (.nat (duration.millis duration.day))) @@ -43,13 +43,13 @@ "Time (in milli-seconds)" (n#encoded time) "Maximum (in milli-seconds)" (n#encoded (-- limit)))) -(def: separator ":") +(def separator ":") -(def: section_parser +(def section_parser (Parser Nat) (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))) -(def: millis_parser +(def millis_parser (Parser Nat) (<>.either (|> (<text>.at_most 3 <text>.decimal) (<>.codec n.decimal) @@ -63,7 +63,7 @@ "Minimum" (n#encoded 0) "Maximum" (n#encoded (-- <maximum>)))) - (def: <parser> + (def <parser> (Parser Nat) (do <>.monad [value <sub_parser>] @@ -79,43 +79,43 @@ (primitive .public Time Nat - (def: .public midnight + (def .public midnight Time (abstraction 0)) - (def: .public (of_millis milli_seconds) + (def .public (of_millis milli_seconds) (-> Nat (Try Time)) (if (n.< ..limit milli_seconds) {try.#Success (abstraction milli_seconds)} (exception.except ..time_exceeds_a_day [milli_seconds]))) - (def: .public millis + (def .public millis (-> Time Nat) (|>> representation)) - (def: .public equivalence + (def .public equivalence (Equivalence Time) (implementation - (def: (= param subject) + (def (= param subject) (n.= (representation param) (representation subject))))) - (def: .public order + (def .public order (Order Time) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< param subject) + (def (< param subject) (n.< (representation param) (representation subject))))) - (`` (def: .public enum + (`` (def .public enum (Enum Time) (implementation - (def: order ..order) + (def order ..order) - (def: succ + (def succ (|>> representation ++ (n.% ..limit) abstraction)) - (def: pred + (def pred (|>> representation (pipe.case 0 ..limit @@ -123,7 +123,7 @@ -- abstraction))))) - (def: .public parser + (def .public parser (Parser Time) (let [millis (is (-> Duration Nat) (|>> duration.millis .nat)) @@ -146,19 +146,19 @@ (n.* utc_millis millis))))))) ) -(def: (padded value) +(def (padded value) (-> Nat Text) (if (n.< 10 value) (text#composite "0" (n#encoded value)) (n#encoded value))) -(def: (positive space duration) +(def (positive space duration) (-> Duration Duration Duration) (if (duration.negative? duration) (duration.composite space duration) duration)) -(def: (millis_format millis) +(def (millis_format millis) (-> Nat Text) (cond (n.= 0 millis) "" (n.< 10 millis) (all text#composite ".00" (n#encoded millis)) @@ -173,7 +173,7 @@ #second Nat #milli_second Nat])) -(def: .public (clock time) +(def .public (clock time) (-> Time Clock) (let [time (|> time ..millis .int duration.of_millis) [hours time] [(duration.ticks duration.hour time) (duration.framed duration.hour time)] @@ -187,7 +187,7 @@ duration.millis .nat)])) -(def: .public (time clock) +(def .public (time clock) (-> Clock (Try Time)) (|> (all duration.composite (duration.up (the #hour clock) duration.hour) @@ -198,7 +198,7 @@ .nat ..of_millis)) -(def: (format time) +(def (format time) (-> Time Text) (let [(open "_[0]") (..clock time)] (all text#composite @@ -207,8 +207,8 @@ ..separator (..padded _#second) (..millis_format _#milli_second)))) -(def: .public codec +(def .public codec (Codec Text Time) (implementation - (def: encoded ..format) - (def: decoded (<text>.result ..parser)))) + (def encoded ..format) + (def decoded (<text>.result ..parser)))) diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux index f01124fac..5a28fc3a0 100644 --- a/stdlib/source/library/lux/time/date.lux +++ b/stdlib/source/library/lux/time/date.lux @@ -28,23 +28,23 @@ ["[1][0]" year (.only Year)] ["[1][0]" month (.only Month)]]) -(def: month_by_number +(def month_by_number (Dictionary Nat Month) (list#mix (function (_ month mapping) (dictionary.has (//month.number month) month mapping)) (dictionary.empty n.hash) //month.year)) -(def: minimum_day +(def minimum_day 1) -(def: (month_days year month) +(def (month_days year month) (-> Year Month Nat) (if (//year.leap? year) (//month.leap_year_days month) (//month.days month))) -(def: (invalid_day? year month day) +(def (invalid_day? year month day) (-> Year Month Nat Bit) (or (n.< ..minimum_day day) (n.> (..month_days year month) day))) @@ -59,14 +59,14 @@ "Year" (at //year.codec encoded year) "Month" (n#encoded (//month.number month)))) -(def: (padded value) +(def (padded value) (-> Nat Text) (let [digits (n#encoded value)] (if (n.< 10 value) (text#composite "0" digits) digits))) -(def: separator +(def separator "-") (primitive .public Date @@ -75,7 +75,7 @@ #month Month #day Nat]) - (def: .public (date year month day_of_month) + (def .public (date year month day_of_month) (-> Year Month Nat (Try Date)) (if (..invalid_day? year month day_of_month) (exception.except ..invalid_day [year month day_of_month]) @@ -85,7 +85,7 @@ #month month #day day_of_month])})) - (def: .public epoch + (def .public epoch Date (try.trusted (..date //year.epoch @@ -93,7 +93,7 @@ ..minimum_day))) (with_template [<name> <type> <field>] - [(def: .public <name> + [(def .public <name> (-> Date <type>) (|>> representation (the <field>)))] @@ -102,10 +102,10 @@ [day_of_month Nat #day] ) - (def: .public equivalence + (def .public equivalence (Equivalence Date) (implementation - (def: (= reference sample) + (def (= reference sample) (let [reference (representation reference) sample (representation sample)] (and (at //year.equivalence = @@ -117,12 +117,12 @@ (n.= (the #day reference) (the #day sample))))))) - (def: .public order + (def .public order (Order Date) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< reference sample) + (def (< reference sample) (let [reference (representation reference) sample (representation sample)] (or (at //year.order < @@ -141,11 +141,11 @@ (the #day sample)))))))))) ) -(def: section_parser +(def section_parser (Parser Nat) (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))) -(def: millis_parser +(def millis_parser (Parser Nat) (<>.either (|> (<text>.at_most 3 <text>.decimal) (<>.codec n.decimal) @@ -159,7 +159,7 @@ "Minimum" (n#encoded <minimum>) "Maximum" (n#encoded <maximum>))) - (def: <parser> + (def <parser> (Parser Nat) (do <>.monad [value ..section_parser] @@ -171,7 +171,7 @@ [1 12 month_parser invalid_month] ) -(def: .public parser +(def .public parser (Parser Date) (do <>.monad [utc_year //year.parser @@ -182,25 +182,25 @@ utc_day ..section_parser] (<>.lifted (..date utc_year month utc_day)))) -(def: (format value) +(def (format value) (-> Date Text) (all text#composite (at //year.codec encoded (..year value)) ..separator (..padded (|> value ..month //month.number)) ..separator (..padded (..day_of_month value)))) -(def: .public codec +(def .public codec (Codec Text Date) (implementation - (def: encoded ..format) - (def: decoded (<text>.result ..parser)))) + (def encoded ..format) + (def decoded (<text>.result ..parser)))) -(def: days_per_leap +(def days_per_leap (|> //year.days (n.* 4) (n.+ 1))) -(def: days_per_century +(def days_per_century (let [leaps_per_century (n./ //year.leap //year.century)] (|> //year.century @@ -208,14 +208,14 @@ (n.+ leaps_per_century) (n.- 1)))) -(def: days_per_era +(def days_per_era (let [centuries_per_era (n./ //year.century //year.era)] (|> centuries_per_era (n.* ..days_per_century) (n.+ 1)))) -(def: days_since_epoch +(def days_since_epoch (let [years::70 70 leaps::70 (n./ //year.leap years::70) @@ -235,17 +235,17 @@ ... 1970/03/01 (n.- january_&_february)))) -(def: first_month_of_civil_year 3) +(def first_month_of_civil_year 3) (with_expansions [<pull> +3 <push> +9] - (def: (internal_month civil_month) + (def (internal_month civil_month) (-> Nat Int) (if (n.< ..first_month_of_civil_year civil_month) (i.+ <push> (.int civil_month)) (i.- <pull> (.int civil_month)))) - (def: (civil_month internal_month) + (def (civil_month internal_month) (-> Int Nat) (.nat (if (i.< +10 internal_month) (i.+ <pull> internal_month) @@ -254,27 +254,27 @@ (with_expansions [<up> +153 <translation> +2 <down> +5] - (def: day_of_year_from_month + (def day_of_year_from_month (-> Nat Int) (|>> ..internal_month (i.* <up>) (i.+ <translation>) (i./ <down>))) - (def: month_from_day_of_year + (def month_from_day_of_year (-> Int Nat) (|>> (i.* <down>) (i.+ <translation>) (i./ <up>) ..civil_month))) -(def: last_era_leap_day +(def last_era_leap_day (.int (-- ..days_per_leap))) -(def: last_era_day +(def last_era_day (.int (-- ..days_per_era))) -(def: (civil_year utc_month utc_year) +(def (civil_year utc_month utc_year) (-> Nat Year Int) (let [... Coercing, because the year is already in external form. utc_year (as Int utc_year)] @@ -283,7 +283,7 @@ utc_year))) ... http://howardhinnant.github.io/date_algorithms.html -(def: .public (days date) +(def .public (days date) (-> Date Int) (let [utc_month (|> date ..month //month.number) civil_year (..civil_year utc_month (..year date)) @@ -307,7 +307,7 @@ (i.- (.int ..days_since_epoch))))) ... http://howardhinnant.github.io/date_algorithms.html -(def: .public (of_days days) +(def .public (of_days days) (-> Int Date) (let [days (i.+ (.int ..days_since_epoch) days) era (|> (if (i.< +0 days) @@ -340,13 +340,13 @@ (maybe.trusted (dictionary.value month ..month_by_number)) day)))) -(def: .public enum +(def .public enum (Enum Date) (implementation - (def: order ..order) + (def order ..order) - (def: succ + (def succ (|>> ..days ++ ..of_days)) - (def: pred + (def pred (|>> ..days -- ..of_days)))) diff --git a/stdlib/source/library/lux/time/day.lux b/stdlib/source/library/lux/time/day.lux index 20b526090..e95975e6e 100644 --- a/stdlib/source/library/lux/time/day.lux +++ b/stdlib/source/library/lux/time/day.lux @@ -29,10 +29,10 @@ {#Friday} {#Saturday})) -(def: .public equivalence +(def .public equivalence (Equivalence Day) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag>] [[{<tag>} {<tag>}] @@ -48,7 +48,7 @@ _ #0)))) -(def: (nat day) +(def (nat day) (-> Day Nat) (case day {#Sunday} 0 @@ -59,20 +59,20 @@ {#Friday} 5 {#Saturday} 6)) -(def: .public order +(def .public order (Order Day) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< reference sample) + (def (< reference sample) (n.< (..nat reference) (..nat sample))))) -(def: .public enum +(def .public enum (Enum Day) (implementation - (def: order ..order) + (def order ..order) - (def: (succ day) + (def (succ day) (case day {#Sunday} {#Monday} {#Monday} {#Tuesday} @@ -82,7 +82,7 @@ {#Friday} {#Saturday} {#Saturday} {#Sunday})) - (def: (pred day) + (def (pred day) (case day {#Monday} {#Sunday} {#Tuesday} {#Monday} @@ -96,10 +96,10 @@ (exception.report "Value" (text.format value))) -(def: .public codec +(def .public codec (Codec Text Day) (implementation - (def: (encoded value) + (def (encoded value) (case value (^.with_template [<tag>] [{<tag>} @@ -111,7 +111,7 @@ [..#Friday] [..#Saturday] [..#Sunday]))) - (def: (decoded value) + (def (decoded value) (case (text#composite "#" value) (^.with_template [<tag>] [(pattern (template.text [<tag>])) @@ -125,7 +125,7 @@ [..#Sunday]) _ (exception.except ..not_a_day_of_the_week [value]))))) -(def: .public week +(def .public week (List Day) (list {#Sunday} {#Monday} @@ -142,7 +142,7 @@ [05 #Thursday] [06 #Friday] [07 #Saturday])] - (def: .public (number day) + (def .public (number day) (-> Day Nat) (case day (^.with_template [<number> <day>] @@ -158,7 +158,7 @@ " ~ " (at n.decimal encoded (..number {#Saturday}))))) - (def: .public (by_number number) + (def .public (by_number number) (-> Nat (Try Day)) (case number (^.with_template [<number> <day>] @@ -170,11 +170,11 @@ (exception.except ..invalid_day [number]))) ) -(def: .public hash +(def .public hash (Hash Day) (implementation - (def: equivalence ..equivalence) - (def: (hash day) + (def equivalence ..equivalence) + (def (hash day) (case day (^.with_template [<prime> <day>] [{<day>} diff --git a/stdlib/source/library/lux/time/duration.lux b/stdlib/source/library/lux/time/duration.lux index 1b37584bf..020ba0275 100644 --- a/stdlib/source/library/lux/time/duration.lux +++ b/stdlib/source/library/lux/time/duration.lux @@ -26,16 +26,16 @@ (primitive .public Duration Int - (def: .public of_millis + (def .public of_millis (-> Int Duration) (|>> abstraction)) - (def: .public millis + (def .public millis (-> Duration Int) (|>> representation)) (with_template [<op> <name>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (-> Duration Duration Duration) (abstraction (<op> (representation param) (representation subject))))] @@ -44,7 +44,7 @@ ) (with_template [<op> <name>] - [(def: .public (<name> scalar) + [(def .public (<name> scalar) (-> Nat Duration Duration) (|>> representation (<op> (.int scalar)) abstraction))] @@ -52,29 +52,29 @@ [i./ down] ) - (def: .public inverse + (def .public inverse (-> Duration Duration) (|>> representation (i.* -1) abstraction)) - (def: .public (ticks param subject) + (def .public (ticks param subject) (-> Duration Duration Int) (i./ (representation param) (representation subject))) - (def: .public equivalence + (def .public equivalence (Equivalence Duration) (implementation - (def: (= param subject) + (def (= param subject) (i.= (representation param) (representation subject))))) - (def: .public order + (def .public order (Order Duration) (implementation - (def: equivalence ..equivalence) - (def: (< param subject) + (def equivalence ..equivalence) + (def (< param subject) (i.< (representation param) (representation subject))))) (with_template [<op> <name>] - [(def: .public <name> + [(def .public <name> (-> Duration Bit) (|>> representation (<op> +0)))] @@ -84,14 +84,14 @@ ) ) -(def: .public empty +(def .public empty (..of_millis +0)) -(def: .public milli_second +(def .public milli_second (..of_millis +1)) (with_template [<name> <scale> <base>] - [(def: .public <name> + [(def .public <name> (..up <scale> <base>))] [second 1,000 milli_second] @@ -103,17 +103,17 @@ [normal_year //year.days day] ) -(def: .public leap_year +(def .public leap_year (..composite ..day ..normal_year)) -(def: .public monoid +(def .public monoid (Monoid Duration) (implementation - (def: identity ..empty) - (def: composite ..composite))) + (def identity ..empty) + (def composite ..composite))) (with_template [<value> <definition>] - [(def: <definition> <value>)] + [(def <definition> <value>)] ["D" day_suffix] ["h" hour_suffix] @@ -125,7 +125,7 @@ ["-" negative_sign] ) -(def: (encoded duration) +(def (encoded duration) (if (at ..equivalence = ..empty duration) (all text#composite ..positive_sign @@ -152,7 +152,7 @@ (if (i.= +0 millis) "" (text#composite (nat#encoded (.nat millis)) ..milli_second_suffix)) )))) -(def: parser +(def parser (Parser Duration) (let [section (is (-> Text Text (Parser Nat)) (function (_ suffix false_suffix) @@ -181,21 +181,21 @@ {.#Left _} (..inverse span) {.#Right _} span))))) -(def: .public codec +(def .public codec (Codec Text Duration) (implementation - (def: encoded ..encoded) - (def: decoded (<text>.result ..parser)))) + (def encoded ..encoded) + (def decoded (<text>.result ..parser)))) -(def: .public (difference from to) +(def .public (difference from to) (-> Duration Duration Duration) (|> from ..inverse (..composite to))) -(def: .public enum +(def .public enum (Enum Duration) (implementation - (def: order ..order) - (def: succ + (def order ..order) + (def succ (..composite ..milli_second)) - (def: pred + (def pred (..composite (..inverse ..milli_second))))) diff --git a/stdlib/source/library/lux/time/instant.lux b/stdlib/source/library/lux/time/instant.lux index daa4b8c2e..5f11765f0 100644 --- a/stdlib/source/library/lux/time/instant.lux +++ b/stdlib/source/library/lux/time/instant.lux @@ -33,63 +33,63 @@ (primitive .public Instant Int - (def: .public of_millis + (def .public of_millis (-> Int Instant) (|>> abstraction)) - (def: .public millis + (def .public millis (-> Instant Int) (|>> representation)) - (def: .public (span from to) + (def .public (span from to) (-> Instant Instant Duration) (duration.of_millis (i.- (representation from) (representation to)))) - (def: .public (after duration instant) + (def .public (after duration instant) (-> Duration Instant Instant) (abstraction (i.+ (duration.millis duration) (representation instant)))) - (def: .public (relative instant) + (def .public (relative instant) (-> Instant Duration) (|> instant representation duration.of_millis)) - (def: .public (absolute offset) + (def .public (absolute offset) (-> Duration Instant) (|> offset duration.millis abstraction)) - (def: .public equivalence + (def .public equivalence (Equivalence Instant) (implementation - (def: (= param subject) + (def (= param subject) (at i.equivalence = (representation param) (representation subject))))) - (def: .public order + (def .public order (Order Instant) (implementation - (def: equivalence ..equivalence) - (def: (< param subject) + (def equivalence ..equivalence) + (def (< param subject) (at i.order < (representation param) (representation subject))))) - (`` (def: .public enum + (`` (def .public enum (Enum Instant) (implementation - (def: order ..order) + (def order ..order) (~~ (with_template [<name>] - [(def: <name> + [(def <name> (|>> representation (at i.enum <name>) abstraction))] [succ] [pred] ))))) ) -(def: .public epoch +(def .public epoch Instant (..of_millis +0)) -(def: millis_per_day +(def millis_per_day (duration.ticks duration.milli_second duration.day)) -(def: (date_time instant) +(def (date_time instant) (-> Instant [Date Duration]) (let [offset (..millis instant) bce? (i.< +0 offset) @@ -103,13 +103,13 @@ (duration.of_millis day_time)])) (with_template [<value> <definition>] - [(def: <definition> Text <value>)] + [(def <definition> Text <value>)] ["T" date_suffix] ["Z" time_suffix] ) -(def: (clock_time duration) +(def (clock_time duration) (-> Duration Time) (|> (if (at duration.order < duration.empty duration) (duration.composite duration.day duration) @@ -119,7 +119,7 @@ //.of_millis try.trusted)) -(def: (format instant) +(def (format instant) (-> Instant Text) (let [[date time] (..date_time instant) time (..clock_time time)] @@ -127,7 +127,7 @@ (at date.codec encoded date) ..date_suffix (at //.codec encoded time) ..time_suffix))) -(def: parser +(def parser (Parser Instant) (do [! <>.monad] [days (at ! each date.days date.parser) @@ -142,13 +142,13 @@ (duration.composite (duration.up time duration.milli_second)) ..absolute)))) -(def: .public codec +(def .public codec (Codec Text Instant) (implementation - (def: encoded ..format) - (def: decoded (<text>.result ..parser)))) + (def encoded ..format) + (def decoded (<text>.result ..parser)))) -(def: .public now +(def .public now (IO Instant) (io (..of_millis (for @.old ("jvm invokestatic:java.lang.System:currentTimeMillis:") @.jvm (|> ("jvm member invoke static" [] "java.lang.System" "currentTimeMillis" []) @@ -189,7 +189,7 @@ )))) (with_template [<field> <type> <post_processing>] - [(def: .public (<field> instant) + [(def .public (<field> instant) (-> Instant <type>) (let [[date time] (..date_time instant)] (|> <field> <post_processing>)))] @@ -198,7 +198,7 @@ [time Time ..clock_time] ) -(def: .public (day_of_week instant) +(def .public (day_of_week instant) (-> Instant Day) (let [offset (..relative instant) days (duration.ticks duration.day offset) @@ -222,7 +222,7 @@ +6 {day.#Saturday} _ (undefined)))) -(def: .public (of_date_time date time) +(def .public (of_date_time date time) (-> Date Time Instant) (|> (date.days date) (i.* (duration.millis duration.day)) diff --git a/stdlib/source/library/lux/time/month.lux b/stdlib/source/library/lux/time/month.lux index 8dd48ba4d..148da6b30 100644 --- a/stdlib/source/library/lux/time/month.lux +++ b/stdlib/source/library/lux/time/month.lux @@ -34,10 +34,10 @@ {#November} {#December})) -(def: .public equivalence +(def .public equivalence (Equivalence Month) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag>] [[{<tag>} {<tag>}] @@ -70,7 +70,7 @@ [10 #October] [11 #November] [12 #December])] - (def: .public (number month) + (def .public (number month) (-> Month Nat) (case month (^.with_template [<number> <month>] @@ -86,7 +86,7 @@ " ~ " (at n.decimal encoded (..number {#December}))))) - (def: .public (by_number number) + (def .public (by_number number) (-> Nat (Try Month)) (case number (^.with_template [<number> <month>] @@ -98,11 +98,11 @@ (exception.except ..invalid_month [number]))) ) -(def: .public hash +(def .public hash (Hash Month) (implementation - (def: equivalence ..equivalence) - (def: (hash month) + (def equivalence ..equivalence) + (def (hash month) (case month (^.with_template [<prime> <month>] [{<month>} @@ -120,21 +120,21 @@ [31 #November] [37 #December]))))) -(def: .public order +(def .public order (Order Month) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< reference sample) + (def (< reference sample) (n.< (..number reference) (..number sample))))) -(def: .public enum +(def .public enum (Enum Month) (implementation - (def: order ..order) + (def order ..order) - (def: (succ month) + (def (succ month) (case month {#January} {#February} {#February} {#March} @@ -149,7 +149,7 @@ {#November} {#December} {#December} {#January})) - (def: (pred month) + (def (pred month) (case month {#February} {#January} {#March} {#February} @@ -164,7 +164,7 @@ {#December} {#November} {#January} {#December})))) -(def: .public (days month) +(def .public (days month) (-> Month Nat) (case month (^.with_template [<days> <month>] @@ -186,13 +186,13 @@ [30 #November] [31 #December]))) -(def: .public (leap_year_days month) +(def .public (leap_year_days month) (-> Month Nat) (case month {#February} (++ (..days month)) _ (..days month))) -(def: .public year +(def .public year (List Month) (list {#January} {#February} @@ -211,10 +211,10 @@ (exception.report "Value" (text.format value))) -(def: .public codec +(def .public codec (Codec Text Month) (implementation - (def: (encoded value) + (def (encoded value) (case value (^.with_template [<tag>] [{<tag>} @@ -231,7 +231,7 @@ [..#October] [..#November] [..#December]))) - (def: (decoded value) + (def (decoded value) (case (text#composite "#" value) (^.with_template [<tag>] [(pattern (template.text [<tag>])) diff --git a/stdlib/source/library/lux/time/year.lux b/stdlib/source/library/lux/time/year.lux index 244c8417f..70e93aa19 100644 --- a/stdlib/source/library/lux/time/year.lux +++ b/stdlib/source/library/lux/time/year.lux @@ -20,13 +20,13 @@ [type [primitive (.except)]]]]) -(def: (internal year) +(def (internal year) (-> Int Int) (if (i.< +0 year) (++ year) year)) -(def: (external year) +(def (external year) (-> Int Int) (if (i.> +0 year) year @@ -38,22 +38,22 @@ (primitive .public Year Int - (def: .public (year value) + (def .public (year value) (-> Int (Try Year)) (case value +0 (exception.except ..there_is_no_year_0 []) _ {try.#Success (abstraction (..internal value))})) - (def: .public value + (def .public value (-> Year Int) (|>> representation ..external)) - (def: .public epoch + (def .public epoch Year (abstraction +1970)) ) -(def: .public days +(def .public days Nat 365) @@ -61,7 +61,7 @@ Nat) (with_template [<period> <name>] - [(def: .public <name> + [(def .public <name> Period <period>)] @@ -70,25 +70,25 @@ [400 era] ) -(def: (divisible? factor input) +(def (divisible? factor input) (-> Int Int Bit) (|> input (i.% factor) (i.= +0))) ... https://en.wikipedia.org/wiki/Leap_year#Algorithm -(def: .public (leap? year) +(def .public (leap? year) (-> Year Bit) (let [year (|> year ..value ..internal)] (and (..divisible? (.int ..leap) year) (or (not (..divisible? (.int ..century) year)) (..divisible? (.int ..era) year))))) -(def: (with_year_0_leap year days) +(def (with_year_0_leap year days) (let [after_year_0? (i.> +0 year)] (if after_year_0? (i.+ +1 days) days))) -(def: .public (leaps year) +(def .public (leaps year) (-> Year Int) (let [year (|> year ..value ..internal) limit (if (i.> +0 year) @@ -104,14 +104,14 @@ )) (..with_year_0_leap year))))) -(def: (encoded year) +(def (encoded year) (-> Year Text) (let [year (..value year)] (if (i.< +0 year) (i#encoded year) (n#encoded (.nat year))))) -(def: .public parser +(def .public parser (Parser Year) (do [! <>.monad] [sign (<>.or (<text>.this "-") (in [])) @@ -121,22 +121,22 @@ {.#Left _} (i.* -1 raw_year) {.#Right _} raw_year))))) -(def: .public codec +(def .public codec (Codec Text Year) (implementation - (def: encoded ..encoded) - (def: decoded (<text>.result ..parser)))) + (def encoded ..encoded) + (def decoded (<text>.result ..parser)))) -(def: .public equivalence +(def .public equivalence (Equivalence Year) (implementation - (def: (= reference subject) + (def (= reference subject) (i.= (..value reference) (..value subject))))) -(def: .public order +(def .public order (Order Year) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< reference subject) + (def (< reference subject) (i.< (..value reference) (..value subject))))) diff --git a/stdlib/source/library/lux/tool/compiler/arity.lux b/stdlib/source/library/lux/tool/compiler/arity.lux index c1e2796c3..14e73f0c1 100644 --- a/stdlib/source/library/lux/tool/compiler/arity.lux +++ b/stdlib/source/library/lux/tool/compiler/arity.lux @@ -9,7 +9,7 @@ Nat) (with_template [<comparison> <name>] - [(def: .public <name> (-> Arity Bit) (<comparison> 1))] + [(def .public <name> (-> Arity Bit) (<comparison> 1))] [n.< nullary?] [n.= unary?] diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux index 2f4f943f9..8ad59fc2e 100644 --- a/stdlib/source/library/lux/tool/compiler/default/init.lux +++ b/stdlib/source/library/lux/tool/compiler/default/init.lux @@ -53,7 +53,7 @@ ["[0]" descriptor] ["[0]" document]]]]]]) -(def: .public (state target module configuration expander host_analysis host generate generation_bundle) +(def .public (state target module configuration expander host_analysis host generate generation_bundle) (All (_ anchor expression directive) (-> Target descriptor.Module @@ -77,7 +77,7 @@ ///directive.#generation [///directive.#state generation_state ///directive.#phase generate]]])) -(def: .public (with_default_directives expander host_analysis program anchorT,expressionT,directiveT extender) +(def .public (with_default_directives expander host_analysis program anchorT,expressionT,directiveT extender) (All (_ anchor expression directive) (-> Expander ///analysis.Bundle @@ -94,13 +94,13 @@ (type: Reader (-> Source (Either [Source Text] [Source Code]))) -(def: (reader current_module aliases [location offset source_code]) +(def (reader current_module aliases [location offset source_code]) (-> descriptor.Module Aliases Source (///analysis.Operation Reader)) (function (_ [bundle state]) {try.#Success [[bundle state] (///syntax.parse current_module aliases ("lux text size" source_code))]})) -(def: (read source reader) +(def (read source reader) (-> Source Reader (///analysis.Operation [Source Code])) (function (_ [bundle compiler]) (case (reader source) @@ -122,7 +122,7 @@ [(///generation.Buffer directive) Registry]) -(def: (begin dependencies hash input) +(def (begin dependencies hash input) (-> (List descriptor.Module) Nat ///.Input (All (_ anchor expression directive) (///directive.Operation anchor expression directive @@ -139,7 +139,7 @@ (in [source [///generation.empty_buffer registry.empty]]))))) -(def: (end module) +(def (end module) (-> descriptor.Module (All (_ anchor expression directive) (///directive.Operation anchor expression directive [.Module (Payload directive)]))) @@ -158,7 +158,7 @@ final_registry]]))) ... TODO: Inline ASAP -(def: (get_current_payload _) +(def (get_current_payload _) (All (_ directive) (-> (Payload directive) (All (_ anchor expression) @@ -172,7 +172,7 @@ (in [buffer registry]))) ... TODO: Inline ASAP -(def: (process_directive wrapper archive expander pre_payoad code) +(def (process_directive wrapper archive expander pre_payoad code) (All (_ directive) (-> ///phase.Wrapper Archive Expander (Payload directive) Code (All (_ anchor expression) @@ -189,7 +189,7 @@ post_payload (..get_current_payload pre_payoad)] (in [requirements post_payload]))) -(def: (iteration' wrapper archive expander reader source pre_payload) +(def (iteration' wrapper archive expander reader source pre_payload) (All (_ directive) (-> ///phase.Wrapper Archive Expander Reader Source (Payload directive) (All (_ anchor expression) @@ -201,7 +201,7 @@ [requirements post_payload] (process_directive wrapper archive expander pre_payload code)] (in [source requirements post_payload]))) -(def: (iteration wrapper archive expander module source pre_payload aliases) +(def (iteration wrapper archive expander module source pre_payload aliases) (All (_ directive) (-> ///phase.Wrapper Archive Expander descriptor.Module Source (Payload directive) Aliases (All (_ anchor expression) @@ -220,18 +220,18 @@ {try.#Success [state {.#None}]} (exception.with ///.cannot_compile module {try.#Failure error})))))) -(def: (default_dependencies prelude input) +(def (default_dependencies prelude input) (-> descriptor.Module ///.Input (List descriptor.Module)) (list.partial descriptor.runtime (if (text#= prelude (the ///.#module input)) (list) (list prelude)))) -(def: module_aliases +(def module_aliases (-> .Module Aliases) (|>> (the .#module_aliases) (dictionary.of_list text.hash))) -(def: .public (compiler wrapper expander prelude write_directive) +(def .public (compiler wrapper expander prelude write_directive) (All (_ anchor expression directive) (-> ///phase.Wrapper Expander descriptor.Module (-> directive Binary) (Instancer (///directive.State+ anchor expression directive) .Module))) diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index e999ae79d..07a7b4c0f 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -87,7 +87,7 @@ (Async (Try a))) ... TODO: Get rid of this - (def: monad + (def monad (as (Monad Action) (try.with async.monad))) @@ -95,7 +95,7 @@ <State+> (these (///directive.State+ <type_vars>)) <Bundle> (these (///generation.Bundle <type_vars>))] - (def: (writer //) + (def (writer //) (All (_ a) (-> (Writer a) (Writer [(module.Module a) Registry]))) @@ -107,7 +107,7 @@ registry.writer )) - (def: (cache_module context platform @module key format entry) + (def (cache_module context platform @module key format entry) (All (_ <type_vars> document) (-> context.Context <Platform> module.ID (Key document) (Writer document) (archive.Entry document) (Async (Try Any)))) @@ -141,20 +141,20 @@ (cache/module.cache! system context @module)))))) ... TODO: Inline ASAP - (def: initialize_buffer! + (def initialize_buffer! (All (_ <type_vars>) (///generation.Operation <type_vars> Any)) (///generation.set_buffer ///generation.empty_buffer)) ... TODO: Inline ASAP - (def: (compile_runtime! platform) + (def (compile_runtime! platform) (All (_ <type_vars>) (-> <Platform> (///generation.Operation <type_vars> [Registry Output]))) (do ///phase.monad [_ ..initialize_buffer!] (the #runtime platform))) - (def: runtime_descriptor + (def runtime_descriptor Descriptor [descriptor.#hash 0 descriptor.#name descriptor.runtime @@ -162,17 +162,17 @@ descriptor.#references (set.empty text.hash) descriptor.#state {.#Compiled}]) - (def: runtime_document + (def runtime_document (Document .Module) (document.document $.key (moduleA.empty 0))) - (def: runtime_module + (def runtime_module (module.Module .Module) [module.#id module.runtime module.#descriptor runtime_descriptor module.#document runtime_document]) - (def: (process_runtime archive platform) + (def (process_runtime archive platform) (All (_ <type_vars>) (-> Archive <Platform> (///directive.Operation <type_vars> @@ -188,7 +188,7 @@ (archive.has descriptor.runtime entry archive))))] (in [archive entry]))) - (def: (initialize_state extender + (def (initialize_state extender [analysers synthesizers generators @@ -222,7 +222,7 @@ (///phase.result' state) (at try.monad each product.left))) - (def: (phase_wrapper archive platform state) + (def (phase_wrapper archive platform state) (All (_ <type_vars>) (-> Archive <Platform> <State+> (Try [<State+> ///phase.Wrapper]))) (|> archive @@ -230,7 +230,7 @@ ///directive.lifted_generation (///phase.result' state))) - (def: (complete_extensions host_directive_bundle phase_wrapper [analysers synthesizers generators directives]) + (def (complete_extensions host_directive_bundle phase_wrapper [analysers synthesizers generators directives]) (All (_ <type_vars>) (-> (-> ///phase.Wrapper (///directive.Bundle <type_vars>)) ///phase.Wrapper @@ -247,7 +247,7 @@ generators (dictionary.composite directives (host_directive_bundle phase_wrapper))]) - (def: .public (initialize context module expander host_analysis platform generation_bundle host_directive_bundle program anchorT,expressionT,directiveT extender + (def .public (initialize context module expander host_analysis platform generation_bundle host_directive_bundle program anchorT,expressionT,directiveT extender import compilation_sources compilation_configuration) (All (_ <type_vars>) (-> context.Context @@ -300,10 +300,10 @@ [phase_wrapper state] (with_missing_extensions platform program state)] (in [state archive phase_wrapper]))))) - (def: compilation_log_separator + (def compilation_log_separator (format text.new_line text.tab)) - (def: (module_compilation_log module) + (def (module_compilation_log module) (All (_ <type_vars>) (-> descriptor.Module <State+> Text)) (|>> (the [extension.#state @@ -315,7 +315,7 @@ (format left ..compilation_log_separator right)) module))) - (def: with_reset_log + (def with_reset_log (All (_ <type_vars>) (-> <State+> <State+>)) (has [extension.#state @@ -325,7 +325,7 @@ ///generation.#log] sequence.empty)) - (def: empty + (def empty (Set descriptor.Module) (set.empty text.hash)) @@ -337,13 +337,13 @@ [#depends_on Mapping #depended_by Mapping])) - (def: independence + (def independence Dependence (let [empty (dictionary.empty text.hash)] [#depends_on empty #depended_by empty])) - (def: (depend module import dependence) + (def (depend module import dependence) (-> descriptor.Module descriptor.Module Dependence Dependence) (let [transitive_dependency (is (-> (-> Dependence Mapping) descriptor.Module (Set descriptor.Module)) (function (_ lens module) @@ -375,7 +375,7 @@ [module transitive_depends_on] [import transitive_depended_by]))))) - (def: (circular_dependency? module import dependence) + (def (circular_dependency? module import dependence) (-> descriptor.Module descriptor.Module Dependence Bit) (let [dependence? (is (-> descriptor.Module (-> Dependence Mapping) descriptor.Module Bit) (function (_ from relationship to) @@ -403,7 +403,7 @@ "Importer" (%.text importer) "Duplicates" (%.list %.text (set.list duplicates)))) - (def: (verify_dependencies importer importee dependence) + (def (verify_dependencies importer importee dependence) (-> descriptor.Module descriptor.Module Dependence (Try Any)) (cond (text#= importer importee) (exception.except ..module_cannot_import_itself [importer]) @@ -418,7 +418,7 @@ (exception.report "Extension" (%.text extension))) - (def: (with_extensions from to) + (def (with_extensions from to) (All (_ state input output) (-> (extension.Bundle state input output) (extension.Bundle state input output) @@ -440,7 +440,7 @@ (dictionary.entries from)))) (with_template [<name> <path>] - [(def: (<name> from state) + [(def (<name> from state) (All (_ <type_vars>) (-> <State+> <State+> (Try <State+>))) (do try.monad @@ -453,7 +453,7 @@ [with_directive_extensions [extension.#bundle]] ) - (def: (with_all_extensions from state) + (def (with_all_extensions from state) (All (_ <type_vars>) (-> <State+> <State+> (Try <State+>))) (do try.monad @@ -490,7 +490,7 @@ Lux_Pending (..Pending <State+>) Lux_Importer (..Importer <State+>) Lux_Compiler (..Compiler <State+>)] - (def: (parallel initial) + (def (parallel initial) (All (_ <type_vars>) (-> Lux_Context (-> Lux_Compiler Lux_Importer))) @@ -582,7 +582,7 @@ return))))) ... TODO: Find a better way, as this only works for the Lux compiler. - (def: (updated_state archive extended_states state) + (def (updated_state archive extended_states state) (All (_ <type_vars>) (-> Archive (List <State+>) <State+> (Try <State+>))) (do [! try.monad] @@ -617,7 +617,7 @@ state (monad.mix ! with_all_extensions state extended_states)] (in (with_modules state)))) - (def: (set_current_module module state) + (def (set_current_module module state) (All (_ <type_vars>) (-> descriptor.Module <State+> <State+>)) (|> (///directive.set_current_module module) @@ -628,7 +628,7 @@ ... TODO: Come up with a less hacky way to prevent duplicate imports. ... This currently assumes that all imports will be specified once in a single .using form. ... This might not be the case in the future. - (def: (with_new_dependencies new_dependencies all_dependencies) + (def (with_new_dependencies new_dependencies all_dependencies) (-> (List descriptor.Module) (Set descriptor.Module) [(Set descriptor.Module) (Set descriptor.Module)]) (let [[all_dependencies duplicates _] (is [(Set descriptor.Module) (Set descriptor.Module) Bit] (list#mix (function (_ new [all duplicates seen_prelude?]) @@ -644,7 +644,7 @@ new_dependencies))] [all_dependencies duplicates])) - (def: (any|after_imports customs import! module duplicates new_dependencies archive) + (def (any|after_imports customs import! module duplicates new_dependencies archive) (All (_ <type_vars> state document object) (-> (List ///.Custom) (..Importer state) descriptor.Module (Set descriptor.Module) (List descriptor.Module) Archive @@ -667,7 +667,7 @@ (list#each product.right archive,state/*)]))) (async#in (exception.except ..cannot_import_twice [module duplicates]))))) - (def: (lux|after_imports customs import! module duplicates new_dependencies [archive state]) + (def (lux|after_imports customs import! module duplicates new_dependencies [archive state]) (All (_ <type_vars>) (-> (List ///.Custom) Lux_Importer descriptor.Module (Set descriptor.Module) (List descriptor.Module) Lux_Context Lux_Return)) (do (try.with async.monad) @@ -679,7 +679,7 @@ {.#Item _} (try.trusted (..updated_state archive state/* state)))]))) - (def: (next_compilation module [archive state] compilation) + (def (next_compilation module [archive state] compilation) (All (_ <type_vars>) (-> descriptor.Module Lux_Context (///.Compilation <State+> .Module Any) (Try [<State+> (Either (///.Compilation <State+> .Module Any) @@ -693,14 +693,14 @@ product.left) archive)) - (def: (compiler phase_wrapper expander platform) + (def (compiler phase_wrapper expander platform) (All (_ <type_vars>) (-> ///phase.Wrapper Expander <Platform> (///.Compiler <State+> .Module Any))) (let [instancer (//init.compiler phase_wrapper expander syntax.prelude (the #write platform))] (instancer $.key (list)))) - (def: (custom_compiler import context platform compilation_sources compiler + (def (custom_compiler import context platform compilation_sources compiler custom_key custom_format custom_compilation) (All (_ <type_vars> state document object) @@ -741,7 +741,7 @@ [_ (cache/archive.cache! (the #file_system platform) context archive)] (async#in {try.#Failure error}))))))) - (def: (lux_compiler import context platform compilation_sources compiler compilation) + (def (lux_compiler import context platform compilation_sources compiler compilation) (All (_ <type_vars>) (-> Import context.Context <Platform> (List _io.Context) (///.Compiler <State+> .Module Any) (///.Compilation <State+> .Module Any) @@ -791,20 +791,20 @@ [_ (cache/archive.cache! (the #file_system platform) context archive)] (async#in {try.#Failure error}))))))) - (for @.old (these (def: Fake_State + (for @.old (these (def Fake_State Type {.#Primitive (%.nat (static.random_nat)) (list)}) - (def: Fake_Document + (def Fake_Document Type {.#Primitive (%.nat (static.random_nat)) (list)}) - (def: Fake_Object + (def Fake_Object Type {.#Primitive (%.nat (static.random_nat)) (list)})) (these)) - (def: (serial_compiler import context platform compilation_sources compiler) + (def (serial_compiler import context platform compilation_sources compiler) (All (_ <type_vars>) (-> Import context.Context <Platform> (List _io.Context) (///.Compiler <State+> .Module Any) Lux_Compiler)) @@ -836,7 +836,7 @@ all_customs importer import! @module [archive custom_state] module)] (in [archive' lux_state])))))))) - (def: .public Custom + (def .public Custom Type (type (-> (List Text) (Try ///.Custom)))) @@ -847,7 +847,7 @@ "Expected Type" (%.type ..Custom) "Actual Type" (%.type type))) - (def: (custom import! it) + (def (custom import! it) (All (_ <type_vars>) (-> Lux_Importer compiler.Compiler (Async (Try [Lux_Context (List Text) Any])))) (let [/#definition (the compiler.#definition it) @@ -868,7 +868,7 @@ {try.#Success [context (the compiler.#parameters it) /#value]} (exception.except ..invalid_custom_compiler [/#definition /#type])))))) - (def: .public (compile lux_compiler phase_wrapper import file_context expander platform compilation context) + (def .public (compile lux_compiler phase_wrapper import file_context expander platform compilation context) (All (_ <type_vars>) (-> (-> Any ..Custom) ///phase.Wrapper Import context.Context Expander <Platform> Compilation Lux_Context Lux_Return)) (let [[host_dependencies libraries compilers sources target module configuration] compilation diff --git a/stdlib/source/library/lux/tool/compiler/language/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux.lux index 084348037..7f601efff 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux.lux @@ -20,7 +20,7 @@ ... TODO: Remove #module_hash, #imports & #module_state ASAP. ... TODO: Not just from this parser, but from the lux.Module type. -(def: .public writer +(def .public writer (Writer .Module) (let [definition (is (Writer Definition) (all _.and _.bit _.type _.any)) @@ -52,7 +52,7 @@ ... #module_state _.any))) -(def: .public parser +(def .public parser (Parser .Module) (let [definition (is (Parser Definition) (all <>.and @@ -98,7 +98,7 @@ ... #module_state (at <>.monad in {.#Cached})))) -(def: .public key +(def .public key (Key .Module) (key.key [signature.#name (symbol ..compiler) signature.#version version.latest] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux index 471431654..0a1b71dab 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux @@ -72,17 +72,17 @@ (type: .public Match (Match' Analysis)) -(def: (branch_equivalence equivalence) +(def (branch_equivalence equivalence) (-> (Equivalence Analysis) (Equivalence Branch)) (implementation - (def: (= [reference_pattern reference_body] [sample_pattern sample_body]) + (def (= [reference_pattern reference_body] [sample_pattern sample_body]) (and (at /pattern.equivalence = reference_pattern sample_pattern) (at equivalence = reference_body sample_body))))) -(def: .public equivalence +(def .public equivalence (Equivalence Analysis) (implementation - (def: (= reference sample) + (def (= reference sample) (.case [reference sample] [{#Simple reference} {#Simple sample}] (at /simple.equivalence = reference sample) @@ -115,19 +115,19 @@ false)))) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [{<tag> content}]))] [case ..#Case] ) -(def: .public unit +(def .public unit (template (unit) [{..#Simple {/simple.#Unit}}])) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> value) [{..#Simple {<tag> value}}]))] @@ -145,7 +145,7 @@ (type: .public (Reification c) [c (List c)]) -(def: .public no_op +(def .public no_op (template (no_op value) [(|> 1 {variable.#Local} @@ -154,14 +154,14 @@ {..#Function (list)} {..#Apply value})])) -(def: .public (reified [abstraction inputs]) +(def .public (reified [abstraction inputs]) (-> (Reification Analysis) Analysis) (list#mix (function (_ input abstraction') {#Apply input abstraction'}) abstraction inputs)) -(def: .public (reification analysis) +(def .public (reification analysis) (-> Analysis (Reification Analysis)) (loop (again [abstraction analysis inputs (is (List Analysis) @@ -174,7 +174,7 @@ [abstraction inputs]))) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (syntax (_ [content <code>.any]) (in (list (` (.<| {..#Reference} <tag> @@ -188,7 +188,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(.<| {..#Structure} {<tag>} @@ -198,7 +198,7 @@ [tuple /complex.#Tuple] ) -(def: .public (format analysis) +(def .public (format analysis) (Format Analysis) (.case analysis {#Simple it} @@ -255,7 +255,7 @@ [Bundle extension.Bundle] ) -(def: .public (with_source_code source action) +(def .public (with_source_code source action) (All (_ a) (-> Source (Operation a) (Operation a))) (function (_ [bundle state]) (let [old_source (the .#source state)] @@ -267,13 +267,13 @@ failure failure)))) -(def: .public (with_current_module name) +(def .public (with_current_module name) (All (_ a) (-> Text (Operation a) (Operation a))) (extension.localized (the .#current_module) (has .#current_module) (function.constant {.#Some name}))) -(def: .public (with_location location action) +(def .public (with_location location action) (All (_ a) (-> Location (Operation a) (Operation a))) (if (text#= "" (product.left location)) action @@ -287,17 +287,17 @@ failure failure))))) -(def: (located location error) +(def (located location error) (-> Location Text Text) (%.format (%.location location) text.new_line error)) -(def: .public (failure error) +(def .public (failure error) (-> Text Operation) (function (_ [bundle state]) {try.#Failure (located (the .#location state) error)})) -(def: .public (of_try it) +(def .public (of_try it) (All (_ a) (-> (Try a) (Operation a))) (function (_ [bundle state]) (.case it @@ -307,17 +307,17 @@ {try.#Success it} {try.#Success [[bundle state] it]}))) -(def: .public (except exception parameters) +(def .public (except exception parameters) (All (_ e) (-> (Exception e) e Operation)) (..failure (exception.error exception parameters))) -(def: .public (assertion exception parameters condition) +(def .public (assertion exception parameters condition) (All (_ e) (-> (Exception e) e Bit (Operation Any))) (if condition (at phase.monad in []) (..except exception parameters))) -(def: .public (with_exception exception message action) +(def .public (with_exception exception message action) (All (_ e o) (-> (Exception e) e (Operation o) (Operation o))) (function (_ bundle,state) (.case (exception.with exception message @@ -329,14 +329,14 @@ success success))) -(def: .public (set_state state) +(def .public (set_state state) (-> .Lux (Operation Any)) (function (_ [bundle _]) {try.#Success [[bundle state] []]})) (with_template [<name> <type> <field> <value>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> <type> (Operation Any)) (extension.update (has <field> <value>)))] @@ -345,32 +345,32 @@ [set_location Location .#location value] ) -(def: .public (location file) +(def .public (location file) (-> Text Location) [file 1 0]) -(def: .public (source file code) +(def .public (source file code) (-> Text Text Source) [(location file) 0 code]) -(def: dummy_source +(def dummy_source Source [location.dummy 0 ""]) -(def: type_context +(def type_context Type_Context [.#ex_counter 0 .#var_counter 0 .#var_bindings (list)]) -(def: .public (info version host configuration) +(def .public (info version host configuration) (-> Version Text Configuration Info) [.#target host .#version (version.format version) .#mode {.#Build} .#configuration configuration]) -(def: .public (state info) +(def .public (state info) (-> Info Lux) [.#info info .#source ..dummy_source diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/complex.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/complex.lux index b2dbbbb79..bca0b70e3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/complex.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/complex.lux @@ -31,28 +31,28 @@ (type: .public Tag Nat) -(def: .public (tag right? lefts) +(def .public (tag right? lefts) (-> Bit Nat Tag) (if right? (++ lefts) lefts)) -(def: .public (lefts right? tag) +(def .public (lefts right? tag) (-> Bit Tag Nat) (if right? (-- tag) tag)) -(def: .public (choice multiplicity pick) +(def .public (choice multiplicity pick) (-> Nat Tag [Nat Bit]) (let [right? (n.= (-- multiplicity) pick)] [(..lefts right? pick) right?])) -(def: .public (equivalence (open "/#[0]")) +(def .public (equivalence (open "/#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Complex a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Variant [reference_lefts reference_right? reference_value]} {#Variant [sample_lefts sample_right? sample_value]}] @@ -66,13 +66,13 @@ _ false)))) -(def: .public (hash super) +(def .public (hash super) (All (_ a) (-> (Hash a) (Hash (Complex a)))) (implementation - (def: equivalence + (def equivalence (..equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value {#Variant [lefts right? value]} (all n.* 2 @@ -85,7 +85,7 @@ (at (list.hash super) hash members)) )))) -(def: .public (format %it it) +(def .public (format %it it) (All (_ a) (-> (Format a) (Format (Complex a)))) (case it {#Variant [lefts right? it]} diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux index e37943c08..a54acd867 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/coverage.lux @@ -58,7 +58,7 @@ (type: .public Variant (Variant' Coverage)))) -(def: .public (minimum [max cases]) +(def .public (minimum [max cases]) (-> Variant Nat) (maybe.else (|> cases dictionary.keys @@ -66,11 +66,11 @@ ++) max)) -(def: .public (maximum [max cases]) +(def .public (maximum [max cases]) (-> Variant Nat) (maybe.else n#top max)) -(def: (alternatives coverage) +(def (alternatives coverage) (-> Coverage (List Coverage)) (case coverage {#Alt left right} @@ -79,10 +79,10 @@ _ (list coverage))) -(def: .public equivalence +(def .public equivalence (Equivalence Coverage) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Exhaustive} {#Exhaustive}] #1 @@ -120,7 +120,7 @@ (open: "/#[0]" ..equivalence) -(def: .public (format value) +(def .public (format value) (%.Format Coverage) (case value {#Bit it} @@ -162,7 +162,7 @@ "Expected size" ">= 2" "Actual size" (%.nat size))) -(def: .public (coverage pattern) +(def .public (coverage pattern) (-> Pattern (Try Coverage)) (case pattern (^.or {//pattern.#Simple {//simple.#Unit}} @@ -222,7 +222,7 @@ (|> (dictionary.empty n.hash) (dictionary.has idx value_coverage))})))) -(def: (xor left right) +(def (xor left right) (-> Bit Bit Bit) (or (and left (not right)) (and (not left) right))) @@ -245,7 +245,7 @@ "Expected cases" (%.nat expected) "Mismatched cases" (%.nat mismatched))) -(def: .public (exhaustive? coverage) +(def .public (exhaustive? coverage) (-> Coverage Bit) (case coverage {#Exhaustive} @@ -258,7 +258,7 @@ ... necessary to merge them all to figure out if the entire ... pattern-matching expression is exhaustive and whether it contains ... redundant patterns. -(def: .public (composite addition so_far) +(def .public (composite addition so_far) (-> Coverage Coverage (Try Coverage)) (with_expansions [<redundancy> (exception.except ..redundancy [so_far addition]) <alternatively> {try.#Success {#Alt addition so_far}} diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux index 2cc4503d9..69efc223d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux @@ -38,11 +38,11 @@ (type: .public Eval (-> Archive Type Code (Operation Any))) -(def: evals +(def evals (Atom (Dictionary module.ID Nat)) (atom.atom (dictionary.empty n.hash))) -(def: .public (evaluator expander synthesis_state generation_state generate) +(def .public (evaluator expander synthesis_state generation_state generate) (All (_ anchor expression artifact) (-> Expander synthesis.State+ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux index 06489b706..cecf9c460 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/inference.lux @@ -54,7 +54,7 @@ [invalid_type_application] ) -(def: .public (quantified @var @parameter :it:) +(def .public (quantified @var @parameter :it:) (-> check.Var Nat Type Type) (case :it: {.#Primitive name co_variant} @@ -93,7 +93,7 @@ ... tagged variants). ... But, so long as the type being used for the inference can be treated ... as a function type, this method of inference should work. -(def: (general' vars archive analyse inferT args) +(def (general' vars archive analyse inferT args) (-> (List check.Var) Archive Phase Type (List Code) (Operation [Type_Context (List check.Var) Type (List Analysis)])) (case args {.#End} @@ -154,7 +154,7 @@ (/.except ..cannot_infer [inferT args])) )) -(def: .public (general archive analyse inferT args) +(def .public (general archive analyse inferT args) (-> Archive Phase Type (List Code) (Operation [Type (List Analysis)])) (do [! phase.monad] [[just_before vars :inference: terms] (general' (list) archive analyse inferT args)] @@ -188,7 +188,7 @@ ... (in [:inference: terms]))) )) -(def: (with_recursion @self recursion) +(def (with_recursion @self recursion) (-> Nat Type Type Type) (function (again it) (case it @@ -216,14 +216,14 @@ _ it))) -(def: parameters +(def parameters (-> Nat (List Type)) (|>> list.indices (list#each (|>> (n.* 2) ++ {.#Parameter})) list.reversed)) (with_template [<name> <types> <inputs> <exception> <when> <then>] - [(`` (def: .public (<name> (~~ (template.spliced <inputs>)) complex) + [(`` (def .public (<name> (~~ (template.spliced <inputs>)) complex) (-> (~~ (template.spliced <types>)) Type (Operation Type)) (loop (again [depth 0 it complex]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux index 7ca7b9158..e66c897e9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/macro.lux @@ -32,7 +32,7 @@ (type: .public Expander (-> Macro (List Code) Lux (Try (Try [Lux (List Code)])))) -(def: .public (expansion expander name macro inputs) +(def .public (expansion expander name macro inputs) (-> Expander Symbol Macro (List Code) (Meta (List Code))) (function (_ state) (do try.monad @@ -44,7 +44,7 @@ _ output)))) -(def: .public (single_expansion expander name macro inputs) +(def .public (single_expansion expander name macro inputs) (-> Expander Symbol Macro (List Code) (Meta Code)) (do meta.monad [expansion (..expansion expander name macro inputs)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux index 6c325986d..a2f23afd5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/module.lux @@ -69,7 +69,7 @@ {.#Compiled} "Compiled" {.#Cached} "Cached"))) -(def: .public (empty hash) +(def .public (empty hash) (-> Nat Module) [.#module_hash hash .#module_aliases (list) @@ -77,7 +77,7 @@ .#imports (list) .#module_state {.#Active}]) -(def: .public (import module) +(def .public (import module) (-> Text (Operation Any)) (///extension.lifted (do ///.monad @@ -92,7 +92,7 @@ state) []]})))) -(def: .public (alias alias module) +(def .public (alias alias module) (-> Text Text (Operation Any)) (///extension.lifted (do ///.monad @@ -104,7 +104,7 @@ state) []]})))) -(def: .public (exists? module) +(def .public (exists? module) (-> Text (Operation Bit)) (///extension.lifted (function (_ state) @@ -115,7 +115,7 @@ [state] {try.#Success})))) -(def: .public (define name definition) +(def .public (define name definition) (-> Text Global (Operation Any)) (///extension.lifted (do ///.monad @@ -137,7 +137,7 @@ ((///extension.up (/.except ..cannot_define_more_than_once [[self_name name] already_existing])) state)))))) -(def: .public (create hash name) +(def .public (create hash name) (-> Nat Text (Operation Any)) (///extension.lifted (function (_ state) @@ -146,7 +146,7 @@ state) []]}))) -(def: .public (with hash name action) +(def .public (with hash name action) (All (_ a) (-> Nat Text (Operation a) (Operation [Module a]))) (do ///.monad [_ (..create hash name) @@ -156,7 +156,7 @@ (in [module output]))) (with_template [<setter> <asker> <tag>] - [(def: .public (<setter> module_name) + [(def .public (<setter> module_name) (-> Text (Operation Any)) (///extension.lifted (function (_ state) @@ -177,7 +177,7 @@ ((///extension.up (/.except ..unknown_module module_name)) state))))) - (def: .public (<asker> module_name) + (def .public (<asker> module_name) (-> Text (Operation Bit)) (///extension.lifted (function (_ state) @@ -197,7 +197,7 @@ [set_cached cached? .#Cached] ) -(def: .public (declare_labels record? labels exported? type) +(def .public (declare_labels record? labels exported? type) (-> Bit (List Label) Bit Type (Operation Any)) (do [! ///.monad] [self_name (///extension.lifted meta.current_module_name) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/pattern.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/pattern.lux index ef3350d56..841a39b77 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/pattern.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/pattern.lux @@ -23,10 +23,10 @@ {#Complex (Complex Pattern)} {#Bind Register}))) -(def: .public equivalence +(def .public equivalence (Equivalence Pattern) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Simple reference} {#Simple sample}] (at //simple.equivalence = reference sample) @@ -40,7 +40,7 @@ _ false)))) -(def: .public (format it) +(def .public (format it) (%.Format Pattern) (case it {#Simple it} @@ -53,7 +53,7 @@ (//variable.format {//variable.#Local it}))) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(.<| {..#Complex} <tag> @@ -63,12 +63,12 @@ [tuple {//complex.#Tuple}] ) -(def: .public unit +(def .public unit (template (unit) [{..#Simple {//simple.#Unit}}])) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [{..#Simple {<tag> content}}]))] @@ -80,6 +80,6 @@ [text //simple.#Text] ) -(def: .public bind +(def .public bind (template (bind register) [{..#Bind register}])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux index 2fa60d94f..7491c9f00 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/scope.lux @@ -29,13 +29,13 @@ (type: Foreign (Bindings Text [Type Variable])) -(def: (local? name scope) +(def (local? name scope) (-> Text Scope Bit) (|> scope (the [.#locals .#mappings]) (plist.contains? name))) -(def: (local name scope) +(def (local name scope) (-> Text Scope (Maybe [Type Variable])) (|> scope (the [.#locals .#mappings]) @@ -43,13 +43,13 @@ (maybe#each (function (_ [type value]) [type {variable.#Local value}])))) -(def: (captured? name scope) +(def (captured? name scope) (-> Text Scope Bit) (|> scope (the [.#captured .#mappings]) (plist.contains? name))) -(def: (captured name scope) +(def (captured name scope) (-> Text Scope (Maybe [Type Variable])) (loop (again [idx 0 mappings (the [.#captured .#mappings] scope)]) @@ -62,12 +62,12 @@ {.#End} {.#None}))) -(def: (reference? name scope) +(def (reference? name scope) (-> Text Scope Bit) (or (local? name scope) (captured? name scope))) -(def: (reference name scope) +(def (reference name scope) (-> Text Scope (Maybe [Type Variable])) (case (..local name scope) {.#Some type} @@ -76,7 +76,7 @@ _ (..captured name scope))) -(def: .public (variable name) +(def .public (variable name) (-> Text (Operation (Maybe [Type Variable]))) (extension.lifted (function (_ state) @@ -109,7 +109,7 @@ (exception: .public no_scope) (exception: .public drained) -(def: .public (with_local [name type] action) +(def .public (with_local [name type] action) (All (_ a) (-> [Text Type] (Operation a) (Operation a))) (function (_ [bundle state]) (case (the .#scopes state) @@ -140,7 +140,7 @@ _ (exception.except ..no_scope [])))) -(def: empty +(def empty Scope (let [bindings (is Bindings [.#counter 0 @@ -150,7 +150,7 @@ .#locals bindings .#captured bindings])) -(def: .public (reset action) +(def .public (reset action) (All (_ a) (-> (Operation a) (Operation a))) (function (_ [bundle state]) (case (action [bundle (has .#scopes (list ..empty) state)]) @@ -161,7 +161,7 @@ failure failure))) -(def: .public (with action) +(def .public (with action) (All (_ a) (-> (Operation a) (Operation [Scope a]))) (function (_ [bundle state]) (case (action [bundle (revised .#scopes (|>> {.#Item ..empty}) state)]) @@ -177,7 +177,7 @@ {try.#Failure error} {try.#Failure error}))) -(def: .public next +(def .public next (Operation Register) (extension.lifted (function (_ state) @@ -188,7 +188,7 @@ {.#End} (exception.except ..no_scope []))))) -(def: .public environment +(def .public environment (-> Scope (Environment Variable)) (|>> (the [.#captured .#mappings]) (list#each (function (_ [_ [_ ref]]) ref)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/simple.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/simple.lux index 8a2fbd7d5..25ba7b1bd 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/simple.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/simple.lux @@ -26,10 +26,10 @@ {#Frac Frac} {#Text Text})) -(def: .public equivalence +(def .public equivalence (Equivalence Simple) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Unit} {#Unit}] true @@ -47,7 +47,7 @@ _ false)))) -(def: .public (format it) +(def .public (format it) (Format Simple) (case it {#Unit} diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/type.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/type.lux index dba3ad176..007289a0a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/type.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/type.lux @@ -26,7 +26,7 @@ [/// ["[0]" phase]]]]) -(def: .public (check action) +(def .public (check action) (All (_ a) (-> (Check a) (Operation a))) (function (_ (^.let stateE [bundle state])) (case (action (the .#type_context state)) @@ -37,10 +37,10 @@ {try.#Failure error} ((/.failure error) stateE)))) -(def: prefix +(def prefix (format (%.symbol (symbol ..type)) "#")) -(def: .public (existential? type) +(def .public (existential? type) (-> Type Bit) (case type {.#Primitive actual {.#End}} @@ -49,28 +49,28 @@ _ false)) -(def: (existential' module id) +(def (existential' module id) (-> Text Nat Type) {.#Primitive (format ..prefix module "#" (%.nat id)) (list)}) -(def: .public existential +(def .public existential (Operation Type) (do phase.monad [module (extension.lifted meta.current_module_name) id (extension.lifted meta.seed)] (in (..existential' module id)))) -(def: .public (expecting expected) +(def .public (expecting expected) (All (_ a) (-> Type (Operation a) (Operation a))) (extension.localized (the .#expected) (has .#expected) (function.constant {.#Some expected}))) -(def: .public fresh +(def .public fresh (All (_ a) (-> (Operation a) (Operation a))) (extension.localized (the .#type_context) (has .#type_context) (function.constant check.fresh_context))) -(def: .public (inference actualT) +(def .public (inference actualT) (-> Type (Operation Any)) (do phase.monad [module (extension.lifted meta.current_module_name) @@ -112,7 +112,7 @@ ... (in it))) ))) -(def: .public (with_var it) +(def .public (with_var it) (All (_ a) (-> (-> [check.Var Type] (Operation a)) (Operation a))) @@ -123,7 +123,7 @@ _ (..check (check.forget! @it))] (in it))) -(def: .public (inferring action) +(def .public (inferring action) (All (_ a) (-> (Operation a) (Operation [Type a]))) (<| ..with_var (function (_ [@it :it:])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux index afe5c1aa8..2682f80d8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux @@ -45,12 +45,12 @@ [#imports (List Import) #referrals (List Code)])) -(def: .public no_requirements +(def .public no_requirements Requirements [#imports (list) #referrals (list)]) -(def: .public (merge_requirements left right) +(def .public (merge_requirements left right) (-> Requirements Requirements Requirements) [#imports (list#composite (the #imports left) (the #imports right)) #referrals (list#composite (the #referrals left) (the #referrals right))]) @@ -67,7 +67,7 @@ ) (with_template [<name> <component> <phase>] - [(def: .public <name> + [(def .public <name> (All (_ anchor expression directive) (Operation anchor expression directive <phase>)) (function (_ [bundle state]) @@ -79,7 +79,7 @@ ) (with_template [<name> <component> <operation>] - [(def: .public <name> + [(def .public <name> (All (_ anchor expression directive output) (-> (<operation> output) (Operation anchor expression directive output))) @@ -92,7 +92,7 @@ [lifted_generation ..#generation (generation.Operation anchor expression directive)] ) -(def: .public (set_current_module module) +(def .public (set_current_module module) (All (_ anchor expression directive) (-> Module (Operation anchor expression directive Any))) (do phase.monad diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux index a978ccd16..8bc9502fc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/generation.lux @@ -96,7 +96,7 @@ [Extender extension.Extender] ) -(def: .public (state host module) +(def .public (state host module) (All (_ anchor expression directive) (-> (Host expression directive) descriptor.Module @@ -112,7 +112,7 @@ #log sequence.empty #interim_artifacts (list)]) -(def: .public empty_buffer +(def .public empty_buffer Buffer sequence.empty) @@ -121,7 +121,7 @@ <set> <get> <get_type> <exception>] [(exception: .public <exception>) - (def: .public <with_declaration> + (def .public <with_declaration> (All (_ anchor expression directive output) <with_type>) (function (_ body) (function (_ [bundle state]) @@ -133,7 +133,7 @@ {try.#Failure error} {try.#Failure error})))) - (def: .public <get> + (def .public <get> (All (_ anchor expression directive) (Operation anchor expression directive <get_type>)) (function (_ (^.let stateE [bundle state])) @@ -144,7 +144,7 @@ {.#None} (exception.except <exception> [])))) - (def: .public (<set> value) + (def .public (<set> value) (All (_ anchor expression directive) (-> <get_type> (Operation anchor expression directive Any))) (function (_ [bundle state]) @@ -166,20 +166,20 @@ set_buffer buffer (Buffer directive) no_active_buffer] ) -(def: .public get_registry +(def .public get_registry (All (_ anchor expression directive) (Operation anchor expression directive Registry)) (function (_ (^.let stateE [bundle state])) {try.#Success [stateE (the #registry state)]})) -(def: .public (set_registry value) +(def .public (set_registry value) (All (_ anchor expression directive) (-> Registry (Operation anchor expression directive Any))) (function (_ [bundle state]) {try.#Success [[bundle (has #registry value state)] []]})) -(def: .public next +(def .public next (All (_ anchor expression directive) (Operation anchor expression directive Nat)) (do phase.monad @@ -187,22 +187,22 @@ _ (extension.update (revised #counter ++))] (in count))) -(def: .public (symbol prefix) +(def .public (symbol prefix) (All (_ anchor expression directive) (-> Text (Operation anchor expression directive Text))) (at phase.monad each (|>> %.nat (format prefix)) ..next)) -(def: .public (enter_module module) +(def .public (enter_module module) (All (_ anchor expression directive) (-> descriptor.Module (Operation anchor expression directive Any))) (extension.update (has #module module))) -(def: .public module +(def .public module (All (_ anchor expression directive) (Operation anchor expression directive descriptor.Module)) (extension.read (the #module))) -(def: .public (evaluate! label code) +(def .public (evaluate! label code) (All (_ anchor expression directive) (-> unit.ID [(Maybe unit.ID) expression] (Operation anchor expression directive Any))) (function (_ (^.let state+ [bundle state])) @@ -213,7 +213,7 @@ {try.#Failure error} (exception.except ..cannot_interpret [error])))) -(def: .public (execute! code) +(def .public (execute! code) (All (_ anchor expression directive) (-> directive (Operation anchor expression directive Any))) (function (_ (^.let state+ [bundle state])) @@ -224,7 +224,7 @@ {try.#Failure error} (exception.except ..cannot_interpret error)))) -(def: .public (define! context custom code) +(def .public (define! context custom code) (All (_ anchor expression directive) (-> unit.ID (Maybe Text) [(Maybe unit.ID) expression] (Operation anchor expression directive [Text Any directive]))) (function (_ (^.let stateE [bundle state])) @@ -235,7 +235,7 @@ {try.#Failure error} (exception.except ..cannot_interpret error)))) -(def: .public (save! artifact_id custom code) +(def .public (save! artifact_id custom code) (All (_ anchor expression directive) (-> artifact.ID (Maybe Text) directive (Operation anchor expression directive Any))) (do [! phase.monad] @@ -251,7 +251,7 @@ (phase.except ..no_buffer_for_saving_code [artifact_id])))) (with_template [<type> <mandatory?> <inputs> <input_types> <name> <artifact>] - [(`` (def: .public (<name> it (~~ (template.spliced <inputs>)) dependencies) + [(`` (def .public (<name> it (~~ (template.spliced <inputs>)) dependencies) (All (_ anchor expression directive) (-> <type> (~~ (template.spliced <input_types>)) (Set unit.ID) (Operation anchor expression directive artifact.ID))) (function (_ (^.let stateE [bundle state])) @@ -274,7 +274,7 @@ "Module" (symbol.module name) "Known Definitions" (exception.listing product.left known_definitions))) -(def: .public (remember archive name) +(def .public (remember archive name) (All (_ anchor expression directive) (-> Archive Symbol (Operation anchor expression directive unit.ID))) (function (_ (^.let stateE [bundle state])) @@ -293,7 +293,7 @@ {.#Some id} {try.#Success [stateE [@module id]]}))))) -(def: .public (definition archive name) +(def .public (definition archive name) (All (_ anchor expression directive) (-> Archive Symbol (Operation anchor expression directive [unit.ID (Maybe category.Definition)]))) (function (_ (^.let stateE [bundle state])) @@ -314,7 +314,7 @@ (exception: .public no_context) -(def: .public (module_id module archive) +(def .public (module_id module archive) (All (_ anchor expression directive) (-> descriptor.Module Archive (Operation anchor expression directive module.ID))) (function (_ (^.let stateE [bundle state])) @@ -322,7 +322,7 @@ [@module (archive.id module archive)] (in [stateE @module])))) -(def: .public (context archive) +(def .public (context archive) (All (_ anchor expression directive) (-> Archive (Operation anchor expression directive unit.ID))) (function (_ (^.let stateE [bundle state])) @@ -335,7 +335,7 @@ [@module (archive.id (the #module state) archive)] (in [stateE [@module id]]))))) -(def: .public (with_context @artifact body) +(def .public (with_context @artifact body) (All (_ anchor expression directive a) (-> artifact.ID (Operation anchor expression directive a) @@ -346,7 +346,7 @@ (in [[bundle' (has #context (the #context state) state')] output])))) -(def: .public (with_registry_shift shift body) +(def .public (with_registry_shift shift body) (All (_ anchor expression directive a) (-> Nat (Operation anchor expression directive a) @@ -357,7 +357,7 @@ (in [[bundle' (has #registry_shift (the #registry_shift state) state')] output])))) -(def: .public (with_new_context archive dependencies body) +(def .public (with_new_context archive dependencies body) (All (_ anchor expression directive a) (-> Archive (Set unit.ID) (Operation anchor expression directive a) (Operation anchor expression directive [unit.ID a]))) @@ -374,7 +374,7 @@ [[@module @artifact] output]]))))) -(def: .public (log! message) +(def .public (log! message) (All (_ anchor expression directive a) (-> Text (Operation anchor expression directive Any))) (function (_ [bundle state]) @@ -382,7 +382,7 @@ (revised #log (sequence.suffix message) state)] []]})) -(def: .public (with_interim_artifacts archive body) +(def .public (with_interim_artifacts archive body) (All (_ anchor expression directive a) (-> Archive (Operation anchor expression directive a) (Operation anchor expression directive [(List unit.ID) a]))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux index 83cf9fb35..1c621d0ff 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis.lux @@ -40,7 +40,7 @@ (exception.report "Syntax" (%.code syntax))) -(def: variant_analysis +(def variant_analysis (template (_ analysis archive tag values) ... (-> Phase Archive Symbol (List Code) (Operation Analysis)) [(case values @@ -50,7 +50,7 @@ _ (/complex.variant analysis tag archive (code.tuple values)))])) -(def: sum_analysis +(def sum_analysis (template (_ analysis archive lefts right? values) ... (-> Phase Archive Nat Bit (List Code) (Operation Analysis)) [(case values @@ -60,7 +60,7 @@ _ (/complex.sum analysis lefts right? archive (code.tuple values)))])) -(def: case_analysis +(def case_analysis (template (_ analysis archive input branches code) ... (-> Phase Archive Code (List Code) Code (Operation Analysis)) [(case (list.pairs branches) @@ -70,7 +70,7 @@ {.#None} (//.except ..invalid [code]))])) -(def: apply_analysis +(def apply_analysis (template (_ expander analysis archive functionC argsC+) ... (-> Expander Phase Archive Code (List Code) (Operation Analysis)) [(do [! //.monad] @@ -92,7 +92,7 @@ _ (/function.apply analysis argsC+ functionT functionA archive functionC)))])) -(def: .public (phase expander) +(def .public (phase expander) (-> Expander Phase) (function (analysis archive code) (<| (let [[location code'] code]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux index a16d7c410..728eb24ec 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case.lux @@ -71,7 +71,7 @@ (exception: .public empty_branches) -(def: (quantified envs baseT) +(def (quantified envs baseT) (-> (List (List Type)) Type Type) (.case envs {.#End} @@ -87,7 +87,7 @@ ... type-variables or quantifications. ... This function makes it easier for "case" analysis to properly ... type-check the input with respect to the patterns. -(def: .public (tuple :it:) +(def .public (tuple :it:) (-> Type (Check [(List check.Var) Type])) (loop (again [envs (is (List (List Type)) (list)) @@ -149,7 +149,7 @@ _ (at check.monad in [(list) (..quantified envs :it:)])))) -(def: (simple_pattern_analysis type :input: location output next) +(def (simple_pattern_analysis type :input: location output next) (All (_ a) (-> Type Type Location Pattern (Operation a) (Operation [Pattern a]))) (/.with_location location (do ///.monad @@ -157,7 +157,7 @@ outputA next] (in [output outputA])))) -(def: (tuple_pattern_analysis pattern_analysis :input: sub_patterns next) +(def (tuple_pattern_analysis pattern_analysis :input: sub_patterns next) (All (_ a) (-> (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a])) Type (List Code) (Operation a) (Operation [Pattern a]))) @@ -224,7 +224,7 @@ ... body expressions. ... That is why the body must be analysed in the context of the ... pattern, and not separately. -(def: (pattern_analysis num_tags :input: pattern next) +(def (pattern_analysis num_tags :input: pattern next) (All (_ a) (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a]))) (.case pattern [location {.#Symbol ["" name]}] @@ -337,7 +337,7 @@ (/.except ..invalid [pattern]) )) -(def: .public (case analyse branches archive inputC) +(def .public (case analyse branches archive inputC) (-> Phase (List [Code Code]) Phase) (.case branches {.#Item [patternH bodyH] branchesT} diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux index 231c3e374..e0c2a8b41 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/complex.lux @@ -99,7 +99,7 @@ list#conjoint code.tuple)))) -(def: .public (sum analyse lefts right? archive) +(def .public (sum analyse lefts right? archive) (-> Phase Nat Bit Phase) (let [tag (/complex.tag right? lefts)] (function (again valueC) @@ -170,7 +170,7 @@ _ (/.except ..invalid_variant_type [expectedT lefts right? valueC]))))))) -(def: .public (variant analyse tag archive valueC) +(def .public (variant analyse tag archive valueC) (-> Phase Symbol Phase) (do [! ///.monad] [tag (///extension.lifted (meta.normal tag)) @@ -188,7 +188,7 @@ _ (..sum analyse lefts right? archive valueC)))) -(def: (typed_product analyse expectedT archive members) +(def (typed_product analyse expectedT archive members) (-> Phase Type Archive (List Code) (Operation Analysis)) (<| (let [! ///.monad]) (at ! each (|>> /.tuple)) @@ -219,7 +219,7 @@ _ (/.except ..cannot_analyse_tuple [expectedT members]))))) -(def: .public (product analyse archive membersC) +(def .public (product analyse archive membersC) (-> Phase Archive (List Code) (Operation Analysis)) (do [! ///.monad] [expectedT (///extension.lifted meta.expected_type)] @@ -290,7 +290,7 @@ ... records, so they must be normalized for further analysis. ... Normalization just means that all the tags get resolved to their ... canonical form (with their corresponding module identified). -(def: .public (normal pattern_matching? record) +(def .public (normal pattern_matching? record) (-> Bit (List Code) (Operation (Maybe (List [Symbol Code])))) (loop (again [input record output (is (List [Symbol Code]) @@ -314,7 +314,7 @@ _ (///#in {.#None})))) -(def: (local_binding? name) +(def (local_binding? name) (-> Text (Meta Bit)) (at meta.monad each (list.any? (list.any? (|>> product.left (text#= name)))) @@ -323,7 +323,7 @@ ... Lux already possesses the means to analyse tuples, so ... re-implementing the same functionality for records makes no sense. ... Records, thus, get transformed into tuples by ordering the elements. -(def: (order' head_k record) +(def (order' head_k record) (-> Symbol (List [Symbol Code]) (Operation (Maybe [Nat (List Code) Type]))) (do [! ///.monad] [slotH' (///extension.lifted @@ -363,7 +363,7 @@ {try.#Failure error} (in {.#None})))) -(def: .public (order pattern_matching? record) +(def .public (order pattern_matching? record) (-> Bit (List [Symbol Code]) (Operation (Maybe [Nat (List Code) Type]))) (case record ... empty_record = empty_tuple = unit/any = [] @@ -385,7 +385,7 @@ _ (order' head_k record)))) -(def: .public (record analyse archive members) +(def .public (record analyse archive members) (-> Phase Archive (List Code) (Operation Analysis)) (case members (pattern (list)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux index 4cc07333a..3b3a319d3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/function.lux @@ -53,7 +53,7 @@ (format (%.nat idx) " " (%.code argC)))) (text.interposed text.new_line)))) -(def: .public (function analyse function_name arg_name archive body) +(def .public (function analyse function_name arg_name archive body) (-> Phase Text Text Phase) (do [! ///.monad] [expectedT (///extension.lifted meta.expected_type)] @@ -134,7 +134,7 @@ (/.failure "") ))))) -(def: .public (apply analyse argsC+ :function: functionA archive functionC) +(def .public (apply analyse argsC+ :function: functionA archive functionC) (-> Phase (List Code) Type Analysis Phase) (|> (/inference.general archive analyse :function: argsC+) (///#each (|>> product.right [functionA] /.reified)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux index 232954fff..cb4011c73 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/reference.lux @@ -38,7 +38,7 @@ (exception.report "Label" (%.symbol definition))) -(def: (definition def_name) +(def (definition def_name) (-> Symbol (Operation Analysis)) (with_expansions [<return> (in (|> def_name ///reference.constant {/.#Reference}))] (do [! ///.monad] @@ -83,7 +83,7 @@ {.#Slot _} (/.except ..labels_are_not_definitions [def_name]))))) -(def: (variable var_name) +(def (variable var_name) (-> Text (Operation (Maybe Analysis))) (do [! ///.monad] [?var (/scope.variable var_name)] @@ -96,7 +96,7 @@ {.#None} (in {.#None})))) -(def: .public (reference it) +(def .public (reference it) (-> Symbol (Operation Analysis)) (case it ["" simple_name] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/simple.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/simple.lux index a5e7a9d08..416780c05 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/simple.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/simple.lux @@ -12,7 +12,7 @@ ["[1]" phase]]]]) (with_template [<name> <type> <tag>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> <type> (Operation Analysis)) (do ///.monad [_ (/type.inference <type>)] @@ -26,7 +26,7 @@ [text .Text /simple.#Text] ) -(def: .public unit +(def .public unit (Operation Analysis) (do ///.monad [_ (/type.inference .Any)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux index 41f270408..6669776fa 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/directive.lux @@ -43,7 +43,7 @@ (type: Eval (-> Type Code (Meta Any))) -(def: (meta_eval archive bundle compiler_eval) +(def (meta_eval archive bundle compiler_eval) (-> Archive ///analysis.Bundle evaluation.Eval Eval) (function (_ type code lux) @@ -54,7 +54,7 @@ {try.#Failure error} {try.#Failure error}))) -(def: (requiring phase archive expansion) +(def (requiring phase archive expansion) (All (_ anchor expression directive) (-> (Phase anchor expression directive) Archive (List Code) (Operation anchor expression directive /.Requirements))) @@ -75,7 +75,7 @@ {try.#Failure error}))))) (with_expansions [<lux_def_module> (these [|form_location| {.#Form (list.partial [|text_location| {.#Text "lux def module"}] annotations)}])] - (def: .public (phase wrapper expander) + (def .public (phase wrapper expander) (-> //.Wrapper Expander Phase) (let [analysis (//analysis.phase expander)] (function (again archive code) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux index f04b95a6e..2f7e4ad0f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension.lux @@ -29,12 +29,12 @@ (type: .public (Extension a) [Name (List a)]) -(def: .public equivalence +(def .public equivalence (All (_ a) (-> (Equivalence a) (Equivalence (Extension a)))) (|>> list.equivalence (product.equivalence text.equivalence))) -(def: .public hash +(def .public hash (All (_ a) (-> (Hash a) (Hash (Extension a)))) (|>> list.hash (product.hash text.hash))) @@ -48,7 +48,7 @@ (type: .public (Bundle s i o) <Bundle>)) -(def: .public empty +(def .public empty Bundle (dictionary.empty text.hash)) @@ -94,7 +94,7 @@ (type: .public (Extender s i o) (-> Any (Handler s i o))) -(def: .public (install extender name handler) +(def .public (install extender name handler) (All (_ s i o) (-> (Extender s i o) Name (Handler s i o) (Operation s i o Any))) (function (_ [bundle state]) @@ -106,7 +106,7 @@ {try.#Failure _} (exception.except ..cannot_overwrite name)))) -(def: .public (with extender extensions) +(def .public (with extender extensions) (All (_ s i o) (-> Extender (Bundle s i o) (Operation s i o Any))) (|> extensions @@ -116,7 +116,7 @@ (..install extender extension handle)) []))) -(def: .public (apply archive phase [name parameters]) +(def .public (apply archive phase [name parameters]) (All (_ s i o) (-> Archive (Phase s i o) (Extension i) (Operation s i o o))) (function (_ (^.let stateE [bundle state])) @@ -128,7 +128,7 @@ {.#None} (exception.except ..unknown [name bundle])))) -(def: .public (localized get set transform) +(def .public (localized get set transform) (All (_ s s' i o v) (-> (-> s s') (-> s' s s) (-> s' s') (-> (Operation s i o v) (Operation s i o v)))) @@ -142,7 +142,7 @@ {try.#Failure error} {try.#Failure error}))))) -(def: .public (temporary transform) +(def .public (temporary transform) (All (_ s i o v) (-> (-> s s) (-> (Operation s i o v) (Operation s i o v)))) @@ -155,24 +155,24 @@ {try.#Failure error} {try.#Failure error})))) -(def: .public (with_state state) +(def .public (with_state state) (All (_ s i o v) (-> s (-> (Operation s i o v) (Operation s i o v)))) (..temporary (function.constant state))) -(def: .public (read get) +(def .public (read get) (All (_ s i o v) (-> (-> s v) (Operation s i o v))) (function (_ [bundle state]) {try.#Success [[bundle state] (get state)]})) -(def: .public (update transform) +(def .public (update transform) (All (_ s i o) (-> (-> s s) (Operation s i o Any))) (function (_ [bundle state]) {try.#Success [[bundle (transform state)] []]})) -(def: .public (lifted action) +(def .public (lifted action) (All (_ s i o v) (-> (//.Operation s v) (Operation s i o v))) (function (_ [bundle state]) @@ -183,7 +183,7 @@ {try.#Failure error} {try.#Failure error}))) -(def: .public (up it) +(def .public (up it) (All (_ s i o v) (-> (Operation s i o v) (//.Operation s v))) (function (_ state) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis.lux index 24f8bc5bf..e11214c8b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis.lux @@ -10,7 +10,7 @@ ["[0]" / ["[1][0]" lux]]) -(def: .public (bundle eval host_specific) +(def .public (bundle eval host_specific) (-> Eval Bundle Bundle) (dictionary.composite host_specific (/lux.bundle eval))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/common_lisp.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/common_lisp.lux index 6ff29f42e..962ad9aea 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/common_lisp.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/common_lisp.lux @@ -28,7 +28,7 @@ [/// ["[0]" phase]]]]]]) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "common_lisp") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux index 8342ce912..71082e284 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux @@ -26,7 +26,7 @@ [/// ["[0]" phase]]]]]) -(def: array::new +(def array::new Handler (custom [<code>.any @@ -41,7 +41,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list lengthA)}))))])) -(def: array::length +(def array::length Handler (custom [<code>.any @@ -56,7 +56,7 @@ _ (analysis/type.inference Nat)] (in {analysis.#Extension extension (list arrayA)}))))])) -(def: array::read +(def array::read Handler (custom [(<>.and <code>.any <code>.any) @@ -73,7 +73,7 @@ _ (analysis/type.inference :read:)] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: array::write +(def array::write Handler (custom [(all <>.and <code>.any <code>.any <code>.any) @@ -92,7 +92,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) -(def: array::delete +(def array::delete Handler (custom [(all <>.and <code>.any <code>.any) @@ -109,7 +109,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: bundle::array +(def bundle::array Bundle (<| (bundle.prefix "array") (|> bundle.empty @@ -120,7 +120,7 @@ (bundle.install "delete" array::delete) ))) -(def: object::new +(def object::new Handler (custom [(all <>.and <code>.any (<code>.tuple (<>.some <code>.any))) @@ -132,7 +132,7 @@ _ (analysis/type.inference .Any)] (in {analysis.#Extension extension (list.partial constructorA inputsA)})))])) -(def: object::get +(def object::get Handler (custom [(all <>.and <code>.text <code>.any) @@ -144,7 +144,7 @@ (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <code>.text <code>.any (<code>.tuple (<>.some <code>.any))) @@ -158,7 +158,7 @@ objectA inputsA)})))])) -(def: bundle::object +(def bundle::object Bundle (<| (bundle.prefix "object") (|> bundle.empty @@ -171,7 +171,7 @@ (bundle.install "undefined?" (/.unary Any Bit)) ))) -(def: js::constant +(def js::constant Handler (custom [<code>.text @@ -180,7 +180,7 @@ [_ (analysis/type.inference Any)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: js::apply +(def js::apply Handler (custom [(all <>.and <code>.any (<code>.tuple (<>.some <code>.any))) @@ -192,7 +192,7 @@ _ (analysis/type.inference Any)] (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))])) -(def: js::type_of +(def js::type_of Handler (custom [<code>.any @@ -203,7 +203,7 @@ _ (analysis/type.inference .Text)] (in {analysis.#Extension extension (list objectA)})))])) -(def: js::function +(def js::function Handler (custom [(all <>.and <code>.nat <code>.any) @@ -217,7 +217,7 @@ (in {analysis.#Extension extension (list (analysis.nat arity) abstractionA)})))])) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "js") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux index e285ff15a..645d0366c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/jvm.lux @@ -176,7 +176,7 @@ (exception.report "Class" (%.text class))) -(def: (ensure_fresh_class! class_loader name) +(def (ensure_fresh_class! class_loader name) (-> java/lang/ClassLoader External (Operation Any)) (do phase.monad [class (phase.lifted (reflection!.load class_loader name))] @@ -186,20 +186,20 @@ reflection!.deprecated? not)))) -(def: reflection +(def reflection (All (_ category) (-> (Type (<| Return' Value' category)) Text)) (|>> jvm.reflection reflection.reflection)) -(def: signature (|>> jvm.signature signature.signature)) +(def signature (|>> jvm.signature signature.signature)) -(def: object_class +(def object_class External "java.lang.Object") ... TODO: Get rid of this with_template block and use the definition in ... lux/ffi.jvm.lux ASAP (with_template [<name> <class>] - [(def: .public <name> + [(def .public <name> .Type {.#Primitive <class> {.#End}})] @@ -230,7 +230,7 @@ [#class External #member Text])) -(def: member +(def member (Parser Member) (all <>.and <code>.text <code>.text)) @@ -299,7 +299,7 @@ [unknown_type_var] ) -(def: bundle::conversion +(def bundle::conversion Bundle (<| (///bundle.prefix "conversion") (|> ///bundle.empty @@ -329,7 +329,7 @@ ))) (with_template [<name> <prefix> <type>] - [(def: <name> + [(def <name> Bundle (<| (///bundle.prefix (reflection.reflection <prefix>)) (|> ///bundle.empty @@ -353,7 +353,7 @@ ) (with_template [<name> <prefix> <type>] - [(def: <name> + [(def <name> Bundle (<| (///bundle.prefix (reflection.reflection <prefix>)) (|> ///bundle.empty @@ -370,7 +370,7 @@ [bundle::double reflection.double ..double] ) -(def: bundle::char +(def bundle::char Bundle (<| (///bundle.prefix (reflection.reflection reflection.char)) (|> ///bundle.empty @@ -378,7 +378,7 @@ (///bundle.install "<" (//lux.binary ..char ..char Bit)) ))) -(def: .public boxes +(def .public boxes (Dictionary External [External (Type Primitive)]) (|> (list [(reflection.reflection reflection.boolean) [box.boolean jvm.boolean]] [(reflection.reflection reflection.byte) [box.byte jvm.byte]] @@ -390,11 +390,11 @@ [(reflection.reflection reflection.char) [box.char jvm.char]]) (dictionary.of_list text.hash))) -(def: lux_array_type +(def lux_array_type (template (_ :read: :write:) [{.#Primitive (static array.type_name) (list {.#Apply :write: {.#Apply :read: _Mutable}})}])) -(def: (jvm_type luxT) +(def (jvm_type luxT) (-> .Type (Operation (Type Value))) (case luxT {.#Named name anonymousT} @@ -446,7 +446,7 @@ _ (/////analysis.except ..non_jvm_type luxT))) -(def: (jvm_array_type objectT) +(def (jvm_array_type objectT) (-> .Type (Operation (Type Array))) (do phase.monad [objectJ (jvm_type objectT)] @@ -455,7 +455,7 @@ (<text>.result parser.array) phase.lifted))) -(def: (primitive_array_length_handler primitive_type) +(def (primitive_array_length_handler primitive_type) (-> (Type Primitive) Handler) (function (_ extension_name analyse archive args) (case args @@ -471,7 +471,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: array::length::object +(def array::length::object Handler (function (_ extension_name analyse archive args) (case args @@ -493,7 +493,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: (new_primitive_array_handler primitive_type) +(def (new_primitive_array_handler primitive_type) (-> (Type Primitive) Handler) (function (_ extension_name analyse archive args) (case args @@ -508,7 +508,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: array::new::object +(def array::new::object Handler (function (_ extension_name analyse archive args) (case args @@ -530,7 +530,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: (check_parameter objectT) +(def (check_parameter objectT) (-> .Type (Operation (Type Parameter))) (case objectT (pattern (lux_array_type elementT _)) @@ -591,7 +591,7 @@ _ (/////analysis.except ..non_parameter objectT))) -(def: (check_jvm objectT) +(def (check_jvm objectT) (-> .Type (Operation (Type Value))) (case objectT {.#Primitive name {.#End}} @@ -660,7 +660,7 @@ (check_parameter objectT))) (with_template [<name> <category> <parser>] - [(def: .public (<name> mapping typeJ) + [(def .public (<name> mapping typeJ) (-> Mapping (Type <category>) (Operation .Type)) (case (|> typeJ ..signature (<text>.result (<parser> mapping))) {try.#Success check} @@ -675,7 +675,7 @@ [reflection_return Return luxT.return] ) -(def: (check_object objectT) +(def (check_object objectT) (-> .Type (Operation [External .Type])) (do [! phase.monad] [:object: (check_jvm objectT) @@ -686,13 +686,13 @@ [:object: (reflection_type luxT.fresh :object:)] (phase#in [name :object:]))))) -(def: (check_return type) +(def (check_return type) (-> .Type (Operation (Type Return))) (if (same? .Any type) (phase#in jvm.void) (check_jvm type))) -(def: (read_primitive_array_handler lux_type jvm_type) +(def (read_primitive_array_handler lux_type jvm_type) (-> .Type (Type Primitive) Handler) (function (_ extension_name analyse archive args) (case args @@ -709,7 +709,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) -(def: array::read::object +(def array::read::object Handler (function (_ extension_name analyse archive args) (case args @@ -734,7 +734,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) -(def: (write_primitive_array_handler lux_type jvm_type) +(def (write_primitive_array_handler lux_type jvm_type) (-> .Type (Type Primitive) Handler) (let [array_type {.#Primitive (|> (jvm.array jvm_type) ..reflection) (list)}] @@ -756,7 +756,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 3 (list.size args)]))))) -(def: array::write::object +(def array::write::object Handler (function (_ extension_name analyse archive args) (case args @@ -784,7 +784,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 3 (list.size args)])))) -(def: bundle::array +(def bundle::array Bundle (<| (///bundle.prefix "array") (|> ///bundle.empty @@ -834,7 +834,7 @@ (///bundle.install "object" array::write::object)))) ))) -(def: object::null +(def object::null Handler (function (_ extension_name analyse archive args) (case args @@ -848,7 +848,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 0 (list.size args)])))) -(def: object::null? +(def object::null? Handler (function (_ extension_name analyse archive args) (case args @@ -863,7 +863,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: object::synchronized +(def object::synchronized Handler (function (_ extension_name analyse archive args) (case args @@ -878,7 +878,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) -(def: (object::throw class_loader) +(def (object::throw class_loader) (-> java/lang/ClassLoader Handler) (function (_ extension_name analyse archive args) (case args @@ -898,7 +898,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: (object::class class_loader) +(def (object::class class_loader) (-> java/lang/ClassLoader Handler) (function (_ extension_name analyse archive args) (case args @@ -917,7 +917,7 @@ _ (/////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: (object::instance? class_loader) +(def (object::instance? class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and <code>.text <code>.any) @@ -933,7 +933,7 @@ (in {/////analysis.#Extension extension_name (list (/////analysis.text sub_class) objectA)}) (/////analysis.except cannot_possibly_be_an_instance (format sub_class " !<= " object_class)))))])) -(def: (class_candidate_parents class_loader source_name fromT target_name target_class) +(def (class_candidate_parents class_loader source_name fromT target_name target_class) (-> java/lang/ClassLoader External .Type External (java/lang/Class java/lang/Object) (Operation (List [[Text .Type] Bit]))) (do [! phase.monad] [source_class (phase.lifted (reflection!.load class_loader source_name)) @@ -956,7 +956,7 @@ (array.list {.#None} (java/lang/Class::getGenericInterfaces source_class))} (array.list {.#None} (java/lang/Class::getGenericInterfaces source_class))))))) -(def: (inheritance_candidate_parents class_loader fromT target_class toT fromC) +(def (inheritance_candidate_parents class_loader fromT target_class toT fromC) (-> java/lang/ClassLoader .Type (java/lang/Class java/lang/Object) .Type Code (Operation (List [[Text .Type] Bit]))) (case fromT (pattern {.#Primitive _ (list.partial self_classT super_classT super_interfacesT+)}) @@ -972,7 +972,7 @@ _ (/////analysis.except ..cannot_cast [fromT toT fromC]))) -(def: (object::cast class_loader) +(def (object::cast class_loader) (-> java/lang/ClassLoader Handler) (function (_ extension_name analyse archive args) (case args @@ -1036,7 +1036,7 @@ _ (/////analysis.except ///.invalid_syntax [extension_name %.code args])))) -(def: (bundle::object class_loader) +(def (bundle::object class_loader) (-> java/lang/ClassLoader Bundle) (<| (///bundle.prefix "object") (|> ///bundle.empty @@ -1049,7 +1049,7 @@ (///bundle.install "cast" (object::cast class_loader)) ))) -(def: (get::static class_loader) +(def (get::static class_loader) (-> java/lang/ClassLoader Handler) (..custom [..member @@ -1069,7 +1069,7 @@ (/////analysis.text field) (/////analysis.text (..signature fieldJT)))))))])) -(def: (put::static class_loader) +(def (put::static class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..member <code>.any) @@ -1094,7 +1094,7 @@ (/////analysis.text (..signature fieldJT)) valueA)))))])) -(def: (get::virtual class_loader) +(def (get::virtual class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..member <code>.any) @@ -1119,7 +1119,7 @@ (/////analysis.text (..signature fieldJT)) objectA)))))])) -(def: (put::virtual class_loader) +(def (put::virtual class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..member <code>.any <code>.any) @@ -1157,7 +1157,7 @@ {#Special} {#Interface})) -(def: (de_aliased aliasing) +(def (de_aliased aliasing) (-> Aliasing (Type Value) (Type Value)) (function (again it) (`` (<| (case (parser.var? it) @@ -1185,7 +1185,7 @@ )) it)))) -(def: (check_method aliasing class method_name method_style inputsJT method) +(def (check_method aliasing class method_name method_style inputsJT method) (-> Aliasing (java/lang/Class java/lang/Object) Text Method_Style (List (Type Value)) java/lang/reflect/Method (Operation Bit)) (do phase.monad [parameters (|> (java/lang/reflect/Method::getGenericParameterTypes method) @@ -1219,7 +1219,7 @@ same_special? same_inputs?)))) -(def: (check_constructor aliasing class inputsJT constructor) +(def (check_constructor aliasing class inputsJT constructor) (-> Aliasing (java/lang/Class java/lang/Object) (List (Type Value)) (java/lang/reflect/Constructor java/lang/Object) (Operation Bit)) (do phase.monad [parameters (|> (java/lang/reflect/Constructor::getGenericParameterTypes constructor) @@ -1232,11 +1232,11 @@ (jvm#= expectedJC (de_aliased aliasing actualJC))) (list.zipped_2 parameters inputsJT)))))) -(def: index_parameter +(def index_parameter (-> Nat .Type) (|>> (n.* 2) ++ {.#Parameter})) -(def: (jvm_type_var_mapping owner_tvars method_tvars) +(def (jvm_type_var_mapping owner_tvars method_tvars) (-> (List Text) (List Text) [(List .Type) Mapping]) (let [jvm_tvars (list#composite owner_tvars method_tvars) lux_tvars (|> jvm_tvars @@ -1250,12 +1250,12 @@ mapping (dictionary.of_list text.hash lux_tvars)] [owner_tvarsT mapping])) -(def: (lux_class it) +(def (lux_class it) (-> (java/lang/Class java/lang/Object) (Type Class)) (jvm.class (java/lang/Class::getName it) (list))) (with_template [<name> <type> <params>] - [(`` (def: <name> + [(`` (def <name> (-> (<type> (~~ (template.spliced <params>))) (List (Type Class))) (|>> (~~ (template.symbol [<type> "::getExceptionTypes"])) (array.list {.#None}) @@ -1265,7 +1265,7 @@ [concrete_constructor_exceptions java/lang/reflect/Constructor [java/lang/Object]] ) -(def: (return_type it) +(def (return_type it) (-> java/lang/reflect/Method (Try (Type Return))) (reflection!.return (case (java/lang/reflect/Method::getGenericReturnType it) @@ -1275,7 +1275,7 @@ {.#None} (java/lang/reflect/Method::getReturnType it)))) -(def: (method_signature method_style method) +(def (method_signature method_style method) (-> Method_Style java/lang/reflect/Method (Operation Method_Signature)) (let [owner (java/lang/reflect/Method::getDeclaringClass method) owner_tvars (case method_style @@ -1323,7 +1323,7 @@ concrete_exceptions generic_exceptions)])))) -(def: (constructor_signature constructor) +(def (constructor_signature constructor) (-> (java/lang/reflect/Constructor java/lang/Object) (Operation Method_Signature)) (let [owner (java/lang/reflect/Constructor::getDeclaringClass constructor) owner_tvars (|> (java/lang/Class::getTypeParameters owner) @@ -1362,7 +1362,7 @@ {#Hint Method_Signature})) (with_template [<name> <tag>] - [(def: <name> + [(def <name> (-> Evaluation (Maybe Method_Signature)) (|>> (pipe.case {<tag> output} @@ -1376,7 +1376,7 @@ ) (with_template [<name> <type> <method>] - [(def: <name> + [(def <name> (-> <type> (List (Type Var))) (|>> <method> (array.list {.#None}) @@ -1387,13 +1387,13 @@ [method_type_variables java/lang/reflect/Method java/lang/reflect/Method::getTypeParameters] ) -(def: (aliasing expected actual) +(def (aliasing expected actual) (-> (List (Type Var)) (List (Type Var)) Aliasing) (|> (list.zipped_2 (list#each parser.name actual) (list#each parser.name expected)) (dictionary.of_list text.hash))) -(def: (family_tree' it) +(def (family_tree' it) (-> (java/lang/Class java/lang/Object) (List (java/lang/Class java/lang/Object))) (let [interfaces (array.list {.#None} (java/lang/Class::getInterfaces it)) @@ -1408,7 +1408,7 @@ list#conjoint (list.partial it)))) -(def: family_tree +(def family_tree (-> (java/lang/Class java/lang/Object) (List (java/lang/Class java/lang/Object))) (|>> ..family_tree' @@ -1418,7 +1418,7 @@ (dictionary.empty text.hash)) dictionary.values)) -(def: (all_declared_methods it) +(def (all_declared_methods it) (-> (java/lang/Class java/lang/Object) (List java/lang/reflect/Method)) (|> it @@ -1426,7 +1426,7 @@ (list#each (|>> java/lang/Class::getDeclaredMethods (array.list {.#None}))) list#conjoint)) -(def: (method_candidate allow_inheritance? class_loader actual_class_tvars class_name actual_method_tvars method_name method_style inputsJT) +(def (method_candidate allow_inheritance? class_loader actual_class_tvars class_name actual_method_tvars method_name method_style inputsJT) (-> Bit java/lang/ClassLoader (List (Type Var)) External (List (Type Var)) Text Method_Style (List (Type Value)) (Operation Method_Signature)) (do [! phase.monad] [class (phase.lifted (reflection!.load class_loader class_name)) @@ -1458,10 +1458,10 @@ (in method) (/////analysis.except ..too_many_candidates [actual_class_tvars class_name method_name actual_method_tvars inputsJT (list.partial method alternatives)]))))) -(def: constructor_method +(def constructor_method "<init>") -(def: (constructor_candidate class_loader actual_class_tvars class_name actual_method_tvars inputsJT) +(def (constructor_candidate class_loader actual_class_tvars class_name actual_method_tvars inputsJT) (-> java/lang/ClassLoader (List (Type Var)) External (List (Type Var)) (List (Type Value)) (Operation Method_Signature)) (do [! phase.monad] [class (phase.lifted (reflection!.load class_loader class_name)) @@ -1491,7 +1491,7 @@ (/////analysis.except ..too_many_candidates [actual_class_tvars class_name ..constructor_method actual_method_tvars inputsJT candidates])))) (with_template [<name> <category> <parser>] - [(def: .public <name> + [(def .public <name> (Parser (Type <category>)) (<text>.then <parser> <code>.text))] @@ -1501,21 +1501,21 @@ [return Return parser.return] ) -(def: input +(def input (Parser (Typed Code)) (<code>.tuple (<>.and ..type <code>.any))) -(def: (decorate_inputs typesT inputsA) +(def (decorate_inputs typesT inputsA) (-> (List (Type Value)) (List Analysis) (List Analysis)) (|> inputsA (list.zipped_2 (list#each (|>> ..signature /////analysis.text) typesT)) (list#each (function (_ [type value]) (/////analysis.tuple (list type value)))))) -(def: type_vars +(def type_vars (<code>.tuple (<>.some ..var))) -(def: (invoke::static class_loader) +(def (invoke::static class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..type_vars ..member ..type_vars (<>.some ..input)) @@ -1533,7 +1533,7 @@ (/////analysis.text (..signature outputJT)) (decorate_inputs argsT argsA))})))])) -(def: (invoke::virtual class_loader) +(def (invoke::virtual class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..type_vars ..member ..type_vars <code>.any (<>.some ..input)) @@ -1558,7 +1558,7 @@ objectA (decorate_inputs argsT argsA))})))])) -(def: (invoke::special class_loader) +(def (invoke::special class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..type_vars ..member ..type_vars <code>.any (<>.some ..input)) @@ -1583,7 +1583,7 @@ objectA (decorate_inputs argsT argsA))})))])) -(def: (invoke::interface class_loader) +(def (invoke::interface class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..type_vars ..member ..type_vars <code>.any (<>.some ..input)) @@ -1612,7 +1612,7 @@ objectA (decorate_inputs argsT argsA))})))])) -(def: (invoke::constructor class_loader) +(def (invoke::constructor class_loader) (-> java/lang/ClassLoader Handler) (..custom [(all <>.and ..type_vars <code>.text ..type_vars (<>.some ..input)) @@ -1627,7 +1627,7 @@ (in {/////analysis.#Extension extension_name (list.partial (/////analysis.text (..signature (jvm.class class (list)))) (decorate_inputs argsT argsA))})))])) -(def: (bundle::member class_loader) +(def (bundle::member class_loader) (-> java/lang/ClassLoader Bundle) (<| (///bundle.prefix "member") (|> ///bundle.empty @@ -1652,32 +1652,32 @@ (type: .public (Annotation_Parameter a) [Text a]) -(def: annotation_parameter +(def annotation_parameter (Parser (Annotation_Parameter Code)) (<code>.tuple (<>.and <code>.text <code>.any))) (type: .public (Annotation a) [Text (List (Annotation_Parameter a))]) -(def: .public annotation +(def .public annotation (Parser (Annotation Code)) (<code>.form (<>.and <code>.text (<>.some ..annotation_parameter)))) -(def: .public argument +(def .public argument (Parser Argument) (<code>.tuple (<>.and <code>.text ..type))) -(def: (annotation_parameter_analysis [name value]) +(def (annotation_parameter_analysis [name value]) (-> (Annotation_Parameter Analysis) Analysis) (/////analysis.tuple (list (/////analysis.text name) value))) -(def: (annotation_analysis [name parameters]) +(def (annotation_analysis [name parameters]) (-> (Annotation Analysis) Analysis) (/////analysis.tuple (list.partial (/////analysis.text name) (list#each annotation_parameter_analysis parameters)))) (with_template [<name> <category>] - [(def: <name> + [(def <name> (-> (Type <category>) Analysis) (|>> ..signature /////analysis.text))] @@ -1687,18 +1687,18 @@ [return_analysis Return] ) -(def: (typed_analysis [type term]) +(def (typed_analysis [type term]) (-> (Typed Analysis) Analysis) (/////analysis.tuple (list (value_analysis type) term))) -(def: (argument_analysis [argument argumentJT]) +(def (argument_analysis [argument argumentJT]) (-> Argument Analysis) (/////analysis.tuple (list (/////analysis.text argument) (value_analysis argumentJT)))) (with_template [<name> <only> <methods>] - [(def: (<name> [type class]) + [(def (<name> [type class]) (-> [(Type Class) (java/lang/Class java/lang/Object)] (Try (List [(Type Class) Text (Type Method)]))) (|> class @@ -1734,10 +1734,10 @@ ..all_declared_methods] ) -(def: jvm_package_separator ".") +(def jvm_package_separator ".") (with_template [<name> <methods>] - [(def: (<name> class_loader) + [(def (<name> class_loader) (-> java/lang/ClassLoader (List (Type Class)) (Try (List [(Type Class) Text (Type Method)]))) (|>> (monad.each try.monad (function (_ type) (|> type @@ -1776,12 +1776,12 @@ (type: .public Finality Bit) (type: .public Strictness Bit) -(def: .public public_tag "public") -(def: .public private_tag "private") -(def: .public protected_tag "protected") -(def: .public default_tag "default") +(def .public public_tag "public") +(def .public private_tag "private") +(def .public protected_tag "protected") +(def .public default_tag "default") -(def: .public visibility' +(def .public visibility' (<text>.Parser Visibility) (all <>.or (<text>.this ..public_tag) @@ -1790,11 +1790,11 @@ (<text>.this ..default_tag) )) -(def: .public visibility +(def .public visibility (Parser Visibility) (<text>.then ..visibility' <code>.text)) -(def: .public (visibility_analysis visibility) +(def .public (visibility_analysis visibility) (-> Visibility Analysis) (/////analysis.text (case visibility {#Public} ..public_tag @@ -1805,7 +1805,7 @@ (type: Exception (Type Class)) -(def: .public parameter_types +(def .public parameter_types (-> (List (Type Var)) (Check (List [(Type Var) .Type]))) (monad.each check.monad (function (_ parameterJ) @@ -1822,9 +1822,9 @@ (Type Return) (List Exception)]) -(def: .public abstract_tag "abstract") +(def .public abstract_tag "abstract") -(def: .public abstract_method_definition +(def .public abstract_method_definition (Parser (Abstract_Method Code)) (<| <code>.form (<>.after (<code>.this_text ..abstract_tag)) @@ -1837,7 +1837,7 @@ ..return (<code>.tuple (<>.some ..class))))) -(def: (method_mapping of_class parameters) +(def (method_mapping of_class parameters) (-> Mapping (List (Type Var)) (Check Mapping)) (|> parameters ..parameter_types @@ -1845,11 +1845,11 @@ (dictionary.has (parser.name parameterJ) parameterT mapping)) of_class)))) -(def: class_mapping +(def class_mapping (-> (List (Type Var)) (Check Mapping)) (..method_mapping luxT.fresh)) -(def: .public (analyse_abstract_method analyse archive method) +(def .public (analyse_abstract_method analyse archive method) (-> Phase Archive (Abstract_Method Code) (Operation Analysis)) (let [[method_name visibility annotations vars arguments return exceptions] method] (do [! phase.monad] @@ -1884,9 +1884,9 @@ (List (Typed a)) a]) -(def: .public constructor_tag "init") +(def .public constructor_tag "init") -(def: .public constructor_definition +(def .public constructor_definition (Parser (Constructor Code)) (<| <code>.form (<>.after (<code>.this_text ..constructor_tag)) @@ -1901,7 +1901,7 @@ (<code>.tuple (<>.some ..input)) <code>.any))) -(def: .public (analyse_constructor_method analyse archive selfT mapping method) +(def .public (analyse_constructor_method analyse archive selfT mapping method) (-> Phase Archive .Type Mapping (Constructor Code) (Operation Analysis)) (let [[visibility strict_fp? annotations vars exceptions @@ -1964,9 +1964,9 @@ (List Exception) a]) -(def: .public virtual_tag "virtual") +(def .public virtual_tag "virtual") -(def: .public virtual_method_definition +(def .public virtual_method_definition (Parser (Virtual_Method Code)) (<| <code>.form (<>.after (<code>.this_text ..virtual_tag)) @@ -1992,7 +1992,7 @@ #arguments (List (Type Value)) #return (Type Return)])) -(def: .public method_declaration +(def .public method_declaration (Parser (Method_Declaration Code)) (<code>.form (all <>.and @@ -2004,7 +2004,7 @@ ..return ))) -(def: .public (analyse_virtual_method analyse archive selfT mapping method) +(def .public (analyse_virtual_method analyse archive selfT mapping method) (-> Phase Archive .Type Mapping (Virtual_Method Code) (Operation Analysis)) (let [[method_name visibility final? strict_fp? annotations vars @@ -2062,9 +2062,9 @@ (List Exception) a]) -(def: .public static_tag "static") +(def .public static_tag "static") -(def: .public static_method_definition +(def .public static_method_definition (Parser (Static_Method Code)) (<| <code>.form (<>.after (<code>.this_text ..static_tag)) @@ -2079,7 +2079,7 @@ (<code>.tuple (<>.some ..class)) <code>.any))) -(def: .public (analyse_static_method analyse archive mapping method) +(def .public (analyse_static_method analyse archive mapping method) (-> Phase Archive Mapping (Static_Method Code) (Operation Analysis)) (let [[method_name visibility strict_fp? annotations vars @@ -2136,9 +2136,9 @@ (List (Type Class)) a]) -(def: .public overriden_tag "override") +(def .public overriden_tag "override") -(def: .public overriden_method_definition +(def .public overriden_method_definition (Parser (Overriden_Method Code)) (<| <code>.form (<>.after (<code>.this_text ..overriden_tag)) @@ -2169,7 +2169,7 @@ "Expected" (%.nat expected) "Actual" (%.nat actual))) -(def: (override_mapping mapping supers parent_type) +(def (override_mapping mapping supers parent_type) (-> Mapping (List (Type Class)) (Type Class) (Operation (List [Text .Type]))) (let [[parent_name parent_parameters] (parser.read_class parent_type)] (case (list.one (function (_ super) @@ -2195,7 +2195,7 @@ {.#None} (phase.lifted (exception.except ..unknown_super [parent_name supers]))))) -(def: .public (with_override_mapping supers parent_type mapping) +(def .public (with_override_mapping supers parent_type mapping) (-> (List (Type Class)) (Type Class) Mapping (Operation Mapping)) (do phase.monad [override_mapping (..override_mapping mapping supers parent_type)] @@ -2204,7 +2204,7 @@ mapping override_mapping)))) -(def: .public (hidden_method_body arity bodyA) +(def .public (hidden_method_body arity bodyA) (-> Nat Analysis Analysis) (<| /////analysis.tuple (list (/////analysis.unit)) @@ -2236,7 +2236,7 @@ (/////analysis.tuple (list forced_refencing bodyA))] (list)]})))) -(def: (with_fake_parameter#pattern it) +(def (with_fake_parameter#pattern it) (-> pattern.Pattern pattern.Pattern) (case it {pattern.#Simple _} @@ -2254,7 +2254,7 @@ {pattern.#Bind it} {pattern.#Bind (++ it)})) -(def: (with_fake_parameter it) +(def (with_fake_parameter it) (-> Analysis Analysis) (case it {/////analysis.#Simple _} @@ -2304,7 +2304,7 @@ {/////analysis.#Extension name (list#each with_fake_parameter parameters)})) -(def: .public (analyse_overriden_method analyse archive selfT mapping supers method) +(def .public (analyse_overriden_method analyse archive selfT mapping supers method) (-> Phase Archive .Type Mapping (List (Type Class)) (Overriden_Method Code) (Operation Analysis)) (let [[parent_type method_name strict_fp? annotations vars @@ -2356,13 +2356,13 @@ _ bodyA))} )))))) -(def: (matched? [sub sub_method subJT] [super super_method superJT]) +(def (matched? [sub sub_method subJT] [super super_method superJT]) (-> [(Type Class) Text (Type Method)] [(Type Class) Text (Type Method)] Bit) (and (at descriptor.equivalence = (jvm.descriptor super) (jvm.descriptor sub)) (text#= super_method sub_method) (jvm#= superJT subJT))) -(def: (mismatched_methods super_set sub_set) +(def (mismatched_methods super_set sub_set) (-> (List [(Type Class) Text (Type Method)]) (List [(Type Class) Text (Type Method)]) (List [(Type Class) Text (Type Method)])) @@ -2382,7 +2382,7 @@ "Actual (amount)" (%.nat (list.size actual)) "Actual (parameters)" (exception.listing ..signature actual))) -(def: (super_aliasing class_loader class) +(def (super_aliasing class_loader class) (-> java/lang/ClassLoader (Type Class) (Operation Aliasing)) (do phase.monad [.let [[name actual_parameters] (parser.read_class class)] @@ -2403,13 +2403,13 @@ mapping)) alias.fresh))))) -(def: (anonymous_class_name module id) +(def (anonymous_class_name module id) (-> Module Nat Text) (let [global (text.replaced .module_separator ..jvm_package_separator module) local (format "anonymous-class" (%.nat id))] (format global ..jvm_package_separator local))) -(def: .public (require_complete_method_concretion class_loader supers methods) +(def .public (require_complete_method_concretion class_loader supers methods) (-> java/lang/ClassLoader (List (Type Class)) (List (Overriden_Method Code)) (Operation Any)) (do [! phase.monad] [required_abstract_methods (phase.lifted (all_abstract_methods class_loader supers)) @@ -2457,10 +2457,10 @@ {#Overriden_Method (..Overriden_Method a)} {#Abstract_Method (..Abstract_Method a)})) -(def: class_name +(def class_name (|>> parser.read_class product.left name.internal)) -(def: (mock_class [name parameters] super interfaces fields methods modifier) +(def (mock_class [name parameters] super interfaces fields methods modifier) (-> Declaration (Type Class) (List (Type Class)) (List (Resource field.Field)) (List (Resource method.Method)) (Modifier class.Class) (Try [External Binary])) @@ -2481,7 +2481,7 @@ methods sequence.empty)))) -(def: constant::modifier +(def constant::modifier (Modifier field.Field) (all modifier#composite field.public @@ -2489,7 +2489,7 @@ field.final )) -(def: (field_definition field) +(def (field_definition field) (-> Field (Resource field.Field)) (case field ... TODO: Handle annotations. @@ -2521,7 +2521,7 @@ (field.field (modifier#composite visibility state) name #1 type sequence.empty))) -(def: method_privacy +(def method_privacy (-> ffi.Privacy (Modifier method.Method)) (|>> (pipe.case {ffi.#PublicP} method.public @@ -2529,10 +2529,10 @@ {ffi.#ProtectedP} method.protected {ffi.#DefaultP} modifier.empty))) -(def: constructor_name +(def constructor_name "<init>") -(def: (mock_value valueT) +(def (mock_value valueT) (-> (Type Value) (Bytecode Any)) (case (jvm.primitive? valueT) {.#Left classT} @@ -2551,7 +2551,7 @@ ... jvm.boolean jvm.byte jvm.short jvm.int jvm.char _.iconst_0))) -(def: (mock_return :return:) +(def (mock_return :return:) (-> (Type Return) (Bytecode Any)) (case (jvm.void? :return:) {.#Right :return:} @@ -2577,7 +2577,7 @@ ... jvm.boolean jvm.byte jvm.short jvm.int jvm.char _.ireturn))))) -(def: (mock_method super method) +(def (mock_method super method) (-> (Type Class) (Method_Definition Code) (Resource method.Method)) (case method {#Constructor [privacy strict_floating_point? annotations variables exceptions @@ -2655,7 +2655,7 @@ {.#None}) )) -(def: (mock declaration super interfaces inheritance fields methods) +(def (mock declaration super interfaces inheritance fields methods) (-> Declaration (Type Class) (List (Type Class)) (Modifier class.Class) (List ..Field) (List (Method_Definition Code)) @@ -2665,7 +2665,7 @@ (list#each (..mock_method super) methods) inheritance)) -(def: (class::anonymous class_loader host) +(def (class::anonymous class_loader host) (-> java/lang/ClassLoader runtime.Host Handler) (..custom [(all <>.and @@ -2720,14 +2720,14 @@ (/////analysis.tuple (list#each typed_analysis constructor_argsA+)) (/////analysis.tuple methodsA))})))])) -(def: (bundle::class class_loader host) +(def (bundle::class class_loader host) (-> java/lang/ClassLoader runtime.Host Bundle) (<| (///bundle.prefix "class") (|> ///bundle.empty (///bundle.install "anonymous" (class::anonymous class_loader host)) ))) -(def: .public (bundle class_loader host) +(def .public (bundle class_loader host) (-> java/lang/ClassLoader runtime.Host Bundle) (<| (///bundle.prefix "jvm") (|> ///bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux index fa08d5be0..3b58108c8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux @@ -26,19 +26,19 @@ [/// ["[0]" phase]]]]]) -(def: Nil +(def Nil (for @.lua ffi.Nil Any)) -(def: Object +(def Object (for @.lua (type (ffi.Object Any)) Any)) -(def: Function +(def Function (for @.lua ffi.Function Any)) -(def: array::new +(def array::new Handler (custom [<code>.any @@ -53,7 +53,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list lengthA)}))))])) -(def: array::length +(def array::length Handler (custom [<code>.any @@ -68,7 +68,7 @@ _ (analysis/type.inference Nat)] (in {analysis.#Extension extension (list arrayA)}))))])) -(def: array::read +(def array::read Handler (custom [(<>.and <code>.any <code>.any) @@ -85,7 +85,7 @@ _ (analysis/type.inference :read:)] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: array::write +(def array::write Handler (custom [(all <>.and <code>.any <code>.any <code>.any) @@ -104,7 +104,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) -(def: array::delete +(def array::delete Handler (custom [(all <>.and <code>.any <code>.any) @@ -121,7 +121,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: bundle::array +(def bundle::array Bundle (<| (bundle.prefix "array") (|> bundle.empty @@ -132,7 +132,7 @@ (bundle.install "delete" array::delete) ))) -(def: object::get +(def object::get Handler (custom [(all <>.and <code>.text <code>.any) @@ -144,7 +144,7 @@ (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <code>.text <code>.any (<code>.tuple (<>.some <code>.any))) @@ -158,7 +158,7 @@ objectA inputsA)})))])) -(def: bundle::object +(def bundle::object Bundle (<| (bundle.prefix "object") (|> bundle.empty @@ -169,7 +169,7 @@ ))) (with_template [<name> <fromT> <toT>] - [(def: <name> + [(def <name> Handler (custom [<code>.any @@ -184,7 +184,7 @@ [utf8::decode (array.Array (I64 Any)) Text] ) -(def: bundle::utf8 +(def bundle::utf8 Bundle (<| (bundle.prefix "utf8") (|> bundle.empty @@ -192,7 +192,7 @@ (bundle.install "decode" utf8::decode) ))) -(def: lua::constant +(def lua::constant Handler (custom [<code>.text @@ -201,7 +201,7 @@ [_ (analysis/type.inference Any)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: lua::apply +(def lua::apply Handler (custom [(all <>.and <code>.any (<code>.tuple (<>.some <code>.any))) @@ -213,7 +213,7 @@ _ (analysis/type.inference Any)] (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))])) -(def: lua::power +(def lua::power Handler (custom [(all <>.and <code>.any <code>.any) @@ -226,7 +226,7 @@ _ (analysis/type.inference Frac)] (in {analysis.#Extension extension (list powerA baseA)})))])) -(def: lua::import +(def lua::import Handler (custom [<code>.text @@ -235,7 +235,7 @@ [_ (analysis/type.inference ..Object)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: lua::function +(def lua::function Handler (custom [(all <>.and <code>.nat <code>.any) @@ -248,7 +248,7 @@ (in {analysis.#Extension extension (list (analysis.nat arity) abstractionA)})))])) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "lua") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux index f261cbcad..f201ff72b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux @@ -35,7 +35,7 @@ [meta [archive (.only Archive)]]]]]]) -(def: .public (custom [syntax handler]) +(def .public (custom [syntax handler]) (All (_ s) (-> [(Parser s) (-> Text Phase Archive s (Operation Analysis))] @@ -48,7 +48,7 @@ {try.#Failure _} (////analysis.except ///.invalid_syntax [extension_name %.code args])))) -(def: (simple inputsT+ outputT) +(def (simple inputsT+ outputT) (-> (List Type) Type Handler) (let [num_expected (list.size inputsT+)] (function (_ extension_name analyse archive args) @@ -64,19 +64,19 @@ (in {////analysis.#Extension extension_name argsA})) (////analysis.except ///.incorrect_arity [extension_name num_expected num_actual])))))) -(def: .public (nullary valueT) +(def .public (nullary valueT) (-> Type Handler) (simple (list) valueT)) -(def: .public (unary inputT outputT) +(def .public (unary inputT outputT) (-> Type Type Handler) (simple (list inputT) outputT)) -(def: .public (binary subjectT paramT outputT) +(def .public (binary subjectT paramT outputT) (-> Type Type Type Handler) (simple (list subjectT paramT) outputT)) -(def: .public (trinary subjectT param0T param1T outputT) +(def .public (trinary subjectT param0T param1T outputT) (-> Type Type Type Type Handler) (simple (list subjectT param0T param1T) outputT)) @@ -86,7 +86,7 @@ (exception.report "Text" (%.text text))) - (def: text_char + (def text_char (Parser text.Char) (do <>.monad [raw <code>.text] @@ -94,7 +94,7 @@ 1 (in (|> raw (text.char 0) maybe.trusted)) _ (<>.failure (exception.error ..char_text_must_be_size_1 [raw]))))) - (def: lux::syntax_char_case! + (def lux::syntax_char_case! (..custom [(all <>.and <code>.any @@ -123,7 +123,7 @@ {////analysis.#Extension extension_name}))))]))) ... "lux is" represents reference/pointer equality. -(def: lux::is +(def lux::is Handler (function (_ extension_name analyse archive args) (<| typeA.with_var @@ -133,7 +133,7 @@ ... "lux try" provides a simple way to interact with the host platform's ... error_handling facilities. -(def: lux::try +(def lux::try Handler (function (_ extension_name analyse archive args) (case args @@ -150,7 +150,7 @@ _ (////analysis.except ///.incorrect_arity [extension_name 1 (list.size args)])))) -(def: lux::in_module +(def lux::in_module Handler (function (_ extension_name analyse archive argsC+) (case argsC+ @@ -161,7 +161,7 @@ _ (////analysis.except ///.invalid_syntax [extension_name %.code argsC+])))) -(def: (lux::type::check eval) +(def (lux::type::check eval) (-> Eval Handler) (function (_ extension_name analyse archive args) (case args @@ -176,7 +176,7 @@ _ (////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) -(def: (lux::type::as eval) +(def (lux::type::as eval) (-> Eval Handler) (function (_ extension_name analyse archive args) (case args @@ -192,7 +192,7 @@ _ (////analysis.except ///.incorrect_arity [extension_name 2 (list.size args)])))) -(def: (caster input output) +(def (caster input output) (-> Type Type Handler) (..custom [<code>.any @@ -206,7 +206,7 @@ (exception.report "Symbol" (%.symbol symbol))) -(def: lux::macro +(def lux::macro Handler (..custom [<code>.any @@ -230,7 +230,7 @@ (<| (typeA.expecting input_type) (phase archive valueC))))])) -(def: (bundle::lux eval) +(def (bundle::lux eval) (-> Eval Bundle) (|> ///bundle.empty (///bundle.install "syntax char case!" lux::syntax_char_case!) @@ -242,7 +242,7 @@ (///bundle.install "type check type" (..caster .Type .Type)) (///bundle.install "in-module" lux::in_module))) -(def: bundle::io +(def bundle::io Bundle (<| (///bundle.prefix "io") (|> ///bundle.empty @@ -250,10 +250,10 @@ (///bundle.install "error" (unary Text Nothing)) (///bundle.install "exit" (unary Int Nothing))))) -(def: I64* +(def I64* (type (I64 Any))) -(def: bundle::i64 +(def bundle::i64 Bundle (<| (///bundle.prefix "i64") (|> ///bundle.empty @@ -272,7 +272,7 @@ (///bundle.install "f64" (unary Int Frac)) (///bundle.install "char" (unary Int Text))))) -(def: bundle::f64 +(def bundle::f64 Bundle (<| (///bundle.prefix "f64") (|> ///bundle.empty @@ -287,7 +287,7 @@ (///bundle.install "encode" (unary Frac Text)) (///bundle.install "decode" (unary Text (type (Maybe Frac))))))) -(def: bundle::text +(def bundle::text Bundle (<| (///bundle.prefix "text") (|> ///bundle.empty @@ -300,7 +300,7 @@ (///bundle.install "clip" (trinary Nat Nat Text Text)) ))) -(def: .public (bundle eval) +(def .public (bundle eval) (-> Eval Bundle) (<| (///bundle.prefix "lux") (|> ///bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux index 5512587e7..d2f402d79 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux @@ -28,7 +28,7 @@ [/// ["[0]" phase]]]]]]) -(def: array::new +(def array::new Handler (custom [<c>.any @@ -41,7 +41,7 @@ _ (analysis/type.infer (type (Array :var:)))] (in {analysis.#Extension extension (list lengthA)}))))])) -(def: array::length +(def array::length Handler (custom [<c>.any @@ -54,7 +54,7 @@ _ (analysis/type.infer Nat)] (in {analysis.#Extension extension (list arrayA)}))))])) -(def: array::read +(def array::read Handler (custom [(<>.and <c>.any <c>.any) @@ -69,7 +69,7 @@ _ (analysis/type.infer :var:)] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: array::write +(def array::write Handler (custom [(all <>.and <c>.any <c>.any <c>.any) @@ -86,7 +86,7 @@ _ (analysis/type.infer (type (Array :var:)))] (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) -(def: array::delete +(def array::delete Handler (custom [(all <>.and <c>.any <c>.any) @@ -101,7 +101,7 @@ _ (analysis/type.infer (type (Array :var:)))] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: bundle::array +(def bundle::array Bundle (<| (bundle.prefix "array") (|> bundle.empty @@ -112,19 +112,19 @@ (bundle.install "delete" array::delete) ))) -(def: Null +(def Null (for @.php ffi.Null Any)) -(def: Object +(def Object (for @.php (type (ffi.Object Any)) Any)) -(def: Function +(def Function (for @.php ffi.Function Any)) -(def: object::new +(def object::new Handler (custom [(all <>.and <c>.text (<>.some <c>.any)) @@ -134,7 +134,7 @@ _ (analysis/type.infer .Any)] (in {analysis.#Extension extension (list.partial (analysis.text constructor) inputsA)})))])) -(def: object::get +(def object::get Handler (custom [(all <>.and <c>.text <c>.any) @@ -146,7 +146,7 @@ (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <c>.text <c>.any (<>.some <c>.any)) @@ -160,7 +160,7 @@ objectA inputsA)})))])) -(def: bundle::object +(def bundle::object Bundle (<| (bundle.prefix "object") (|> bundle.empty @@ -171,7 +171,7 @@ (bundle.install "null?" (/.unary Any Bit)) ))) -(def: php::constant +(def php::constant Handler (custom [<c>.text @@ -180,7 +180,7 @@ [_ (analysis/type.infer Any)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: php::apply +(def php::apply Handler (custom [(all <>.and <c>.any (<>.some <c>.any)) @@ -192,7 +192,7 @@ _ (analysis/type.infer Any)] (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))])) -(def: php::pack +(def php::pack Handler (custom [(all <>.and <c>.any <c>.any) @@ -205,7 +205,7 @@ _ (analysis/type.infer Text)] (in {analysis.#Extension extension (list formatA dataA)})))])) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "php") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux index aa2944967..96d175553 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux @@ -26,7 +26,7 @@ [/// ["[0]" phase]]]]]) -(def: array::new +(def array::new Handler (custom [<code>.any @@ -41,7 +41,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list lengthA)}))))])) -(def: array::length +(def array::length Handler (custom [<code>.any @@ -56,7 +56,7 @@ _ (analysis/type.inference Nat)] (in {analysis.#Extension extension (list arrayA)}))))])) -(def: array::read +(def array::read Handler (custom [(<>.and <code>.any <code>.any) @@ -73,7 +73,7 @@ _ (analysis/type.inference :read:)] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: array::write +(def array::write Handler (custom [(all <>.and <code>.any <code>.any <code>.any) @@ -92,7 +92,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) -(def: array::delete +(def array::delete Handler (custom [(all <>.and <code>.any <code>.any) @@ -109,7 +109,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: bundle::array +(def bundle::array Bundle (<| (bundle.prefix "array") (|> bundle.empty @@ -120,23 +120,23 @@ (bundle.install "delete" array::delete) ))) -(def: None +(def None (for @.python ffi.None Any)) -(def: Object +(def Object (for @.python (type (ffi.Object Any)) Any)) -(def: Function +(def Function (for @.python ffi.Function Any)) -(def: Dict +(def Dict (for @.python ffi.Dict Any)) -(def: object::get +(def object::get Handler (custom [(all <>.and <code>.text <code>.any) @@ -148,7 +148,7 @@ (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <code>.text <code>.any (<code>.tuple (<>.some <code>.any))) @@ -162,7 +162,7 @@ objectA inputsA)})))])) -(def: bundle::object +(def bundle::object Bundle (<| (bundle.prefix "object") (|> bundle.empty @@ -172,7 +172,7 @@ (bundle.install "none?" (/.unary Any Bit)) ))) -(def: python::constant +(def python::constant Handler (custom [<code>.text @@ -181,7 +181,7 @@ [_ (analysis/type.inference Any)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: python::import +(def python::import Handler (custom [<code>.text @@ -190,7 +190,7 @@ [_ (analysis/type.inference ..Object)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: python::apply +(def python::apply Handler (custom [(all <>.and <code>.any (<code>.tuple (<>.some <code>.any))) @@ -202,7 +202,7 @@ _ (analysis/type.inference Any)] (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))])) -(def: python::function +(def python::function Handler (custom [(all <>.and <code>.nat <code>.any) @@ -215,7 +215,7 @@ (in {analysis.#Extension extension (list (analysis.nat arity) abstractionA)})))])) -(def: python::exec +(def python::exec Handler (custom [(all <>.and <code>.any <code>.any) @@ -228,7 +228,7 @@ _ (analysis/type.inference .Any)] (in {analysis.#Extension extension (list codeA globalsA)})))])) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "python") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/r.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/r.lux index c9e983ddd..5e2f27c47 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/r.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/r.lux @@ -28,7 +28,7 @@ [/// ["[0]" phase]]]]]]) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "r") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux index 01895a3e7..c75faf63a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux @@ -26,7 +26,7 @@ [/// ["[0]" phase]]]]]) -(def: array::new +(def array::new Handler (custom [<code>.any @@ -41,7 +41,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list lengthA)}))))])) -(def: array::length +(def array::length Handler (custom [<code>.any @@ -56,7 +56,7 @@ _ (analysis/type.inference Nat)] (in {analysis.#Extension extension (list arrayA)}))))])) -(def: array::read +(def array::read Handler (custom [(<>.and <code>.any <code>.any) @@ -73,7 +73,7 @@ _ (analysis/type.inference :read:)] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: array::write +(def array::write Handler (custom [(all <>.and <code>.any <code>.any <code>.any) @@ -92,7 +92,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) -(def: array::delete +(def array::delete Handler (custom [(all <>.and <code>.any <code>.any) @@ -109,7 +109,7 @@ _ (analysis/type.inference (type (array.Array' :read: :write:)))] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: bundle::array +(def bundle::array Bundle (<| (bundle.prefix "array") (|> bundle.empty @@ -120,19 +120,19 @@ (bundle.install "delete" array::delete) ))) -(def: Nil +(def Nil (for @.ruby ffi.Nil Any)) -(def: Object +(def Object (for @.ruby (type (ffi.Object Any)) Any)) -(def: Function +(def Function (for @.ruby ffi.Function Any)) -(def: object::get +(def object::get Handler (custom [(all <>.and <code>.text <code>.any) @@ -144,7 +144,7 @@ (in {analysis.#Extension extension (list (analysis.text fieldC) objectA)})))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <code>.text <code>.any (<code>.tuple (<>.some <code>.any))) @@ -158,7 +158,7 @@ objectA inputsA)})))])) -(def: bundle::object +(def bundle::object Bundle (<| (bundle.prefix "object") (|> bundle.empty @@ -168,7 +168,7 @@ (bundle.install "nil?" (/.unary Any Bit)) ))) -(def: ruby::constant +(def ruby::constant Handler (custom [<code>.text @@ -177,7 +177,7 @@ [_ (analysis/type.inference Any)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: ruby::apply +(def ruby::apply Handler (custom [(all <>.and <code>.any (<code>.tuple (<>.some <code>.any))) @@ -189,7 +189,7 @@ _ (analysis/type.inference Any)] (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))])) -(def: ruby::import +(def ruby::import Handler (custom [<code>.text @@ -198,7 +198,7 @@ [_ (analysis/type.inference Bit)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "ruby") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux index e0ba7f433..b76766cf7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux @@ -28,7 +28,7 @@ [/// ["[0]" phase]]]]]]) -(def: array::new +(def array::new Handler (custom [<c>.any @@ -41,7 +41,7 @@ _ (analysis/type.infer (type (Array :var:)))] (in {analysis.#Extension extension (list lengthA)}))))])) -(def: array::length +(def array::length Handler (custom [<c>.any @@ -54,7 +54,7 @@ _ (analysis/type.infer Nat)] (in {analysis.#Extension extension (list arrayA)}))))])) -(def: array::read +(def array::read Handler (custom [(<>.and <c>.any <c>.any) @@ -69,7 +69,7 @@ _ (analysis/type.infer :var:)] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: array::write +(def array::write Handler (custom [(all <>.and <c>.any <c>.any <c>.any) @@ -86,7 +86,7 @@ _ (analysis/type.infer (type (Array :var:)))] (in {analysis.#Extension extension (list indexA valueA arrayA)}))))])) -(def: array::delete +(def array::delete Handler (custom [(all <>.and <c>.any <c>.any) @@ -101,7 +101,7 @@ _ (analysis/type.infer (type (Array :var:)))] (in {analysis.#Extension extension (list indexA arrayA)}))))])) -(def: bundle::array +(def bundle::array Bundle (<| (bundle.prefix "array") (|> bundle.empty @@ -112,15 +112,15 @@ (bundle.install "delete" array::delete) ))) -(def: Nil +(def Nil (for @.scheme ffi.Nil Any)) -(def: Function +(def Function (for @.scheme ffi.Function Any)) -(def: bundle::object +(def bundle::object Bundle (<| (bundle.prefix "object") (|> bundle.empty @@ -128,7 +128,7 @@ (bundle.install "nil?" (/.unary Any Bit)) ))) -(def: scheme::constant +(def scheme::constant Handler (custom [<c>.text @@ -137,7 +137,7 @@ [_ (analysis/type.infer Any)] (in {analysis.#Extension extension (list (analysis.text name))})))])) -(def: scheme::apply +(def scheme::apply Handler (custom [(all <>.and <c>.any (<>.some <c>.any)) @@ -149,7 +149,7 @@ _ (analysis/type.infer Any)] (in {analysis.#Extension extension (list.partial abstractionA inputsA)})))])) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "scheme") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux index 3510a9f9e..1e2674dc4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/bundle.lux @@ -11,17 +11,17 @@ ["[0]" dictionary (.only Dictionary)]]]]] [// (.only Handler Bundle)]) -(def: .public empty +(def .public empty Bundle (dictionary.empty text.hash)) -(def: .public (install name anonymous) +(def .public (install name anonymous) (All (_ s i o) (-> Text (Handler s i o) (-> (Bundle s i o) (Bundle s i o)))) (dictionary.has name anonymous)) -(def: .public (prefix prefix) +(def .public (prefix prefix) (All (_ s i o) (-> Text (-> (Bundle s i o) (Bundle s i o)))) (|>> dictionary.entries diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux index 41076ca66..960e51493 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/jvm.lux @@ -90,17 +90,17 @@ (type: Operation (directive.Operation Anchor (Bytecode Any) Definition)) -(def: signature (|>> type.signature signature.signature)) -(def: reflection (|>> type.reflection reflection.reflection)) +(def signature (|>> type.signature signature.signature)) +(def reflection (|>> type.reflection reflection.reflection)) (type: Declaration [Text (List (Type Var))]) -(def: declaration +(def declaration (Parser Declaration) (<code>.form (<>.and <code>.text (<>.some jvm.var)))) -(def: method_privacy +(def method_privacy (-> ffi.Privacy (Modifier method.Method)) (|>> (pipe.case {ffi.#PublicP} method.public @@ -108,7 +108,7 @@ {ffi.#ProtectedP} method.protected {ffi.#DefaultP} modifier.empty))) -(def: visibility' +(def visibility' (<text>.Parser (Modifier field.Field)) (`` (all <>.either (~~ (with_template [<label> <modifier>] @@ -119,11 +119,11 @@ ["protected" field.protected] ["default" modifier.empty]))))) -(def: visibility +(def visibility (Parser (Modifier field.Field)) (<text>.then ..visibility' <code>.text)) -(def: inheritance +(def inheritance (Parser (Modifier class.Class)) (`` (all <>.either (~~ (with_template [<label> <modifier>] @@ -133,7 +133,7 @@ ["abstract" class.abstract] ["default" modifier.empty]))))) -(def: state +(def state (Parser (Modifier field.Field)) (`` (all <>.either (~~ (with_template [<label> <modifier>] @@ -145,18 +145,18 @@ (type: Annotation Any) -(def: annotation +(def annotation (Parser Annotation) <code>.any) -(def: field_type +(def field_type (Parser (Type Value)) (<text>.then parser.value <code>.text)) (type: Constant [Text (List Annotation) (Type Value) Code]) -(def: constant +(def constant (Parser Constant) (<| <code>.form (<>.after (<code>.this_text "constant")) @@ -170,7 +170,7 @@ (type: Variable [Text (Modifier field.Field) (Modifier field.Field) Bit (List Annotation) (Type Value)]) -(def: variable +(def variable (Parser Variable) (<| <code>.form (<>.after (<code>.this_text "variable")) @@ -188,7 +188,7 @@ {#Constant Constant} {#Variable Variable})) -(def: field +(def field (Parser Field) (all <>.or ..constant @@ -203,7 +203,7 @@ {#Overriden_Method (jvm.Overriden_Method a)} {#Abstract_Method (jvm.Abstract_Method a)})) -(def: method +(def method (Parser (Method_Definition Code)) (all <>.or jvm.constructor_definition @@ -213,18 +213,18 @@ jvm.abstract_method_definition )) -(def: $Object +(def $Object (Type Class) (type.class "java.lang.Object" (list))) -(def: constant::modifier +(def constant::modifier (Modifier field.Field) (all modifier#composite field.public field.static field.final)) -(def: (field_definition field) +(def (field_definition field) (-> Field (Resource field.Field)) (case field ... TODO: Handle annotations. @@ -261,16 +261,16 @@ state) name #1 type sequence.empty))) -(def: annotation_parameter_synthesis +(def annotation_parameter_synthesis (<synthesis>.Parser (jvm.Annotation_Parameter Synthesis)) (<synthesis>.tuple (<>.and <synthesis>.text <synthesis>.any))) -(def: annotation_synthesis +(def annotation_synthesis (<synthesis>.Parser (jvm.Annotation Synthesis)) (<synthesis>.tuple (<>.and <synthesis>.text (<>.some ..annotation_parameter_synthesis)))) (with_template [<name> <type> <text>] - [(def: <name> + [(def <name> (<synthesis>.Parser (Type <type>)) (<text>.then <text> <synthesis>.text))] @@ -280,15 +280,15 @@ [return_type_synthesis Return parser.return] ) -(def: argument_synthesis +(def argument_synthesis (<synthesis>.Parser Argument) (<synthesis>.tuple (<>.and <synthesis>.text ..value_type_synthesis))) -(def: input_synthesis +(def input_synthesis (<synthesis>.Parser (Typed Synthesis)) (<synthesis>.tuple (<>.and ..value_type_synthesis <synthesis>.any))) -(def: (method_body arity) +(def (method_body arity) (-> Nat (<synthesis>.Parser Synthesis)) (<| (<>#each (function (_ [env offset inits it]) it)) (<synthesis>.function 1) @@ -300,7 +300,7 @@ <synthesis>.any) <synthesis>.any))) -(def: constructor_synthesis +(def constructor_synthesis (<synthesis>.Parser (jvm.Constructor Synthesis)) (<| <synthesis>.tuple (<>.after (<synthesis>.this_text jvm.constructor_tag)) @@ -319,7 +319,7 @@ (..method_body (list.size args)))) ))) -(def: overriden_method_synthesis +(def overriden_method_synthesis (<synthesis>.Parser (jvm.Overriden_Method Synthesis)) (<| <synthesis>.tuple (<>.after (<synthesis>.this_text jvm.overriden_tag)) @@ -339,7 +339,7 @@ (..method_body (list.size args)))) ))) -(def: virtual_method_synthesis +(def virtual_method_synthesis (<synthesis>.Parser (jvm.Virtual_Method Synthesis)) (<| <synthesis>.tuple (<>.after (<synthesis>.this_text jvm.virtual_tag)) @@ -360,7 +360,7 @@ (..method_body (list.size args)))) ))) -(def: static_method_synthesis +(def static_method_synthesis (<synthesis>.Parser (jvm.Static_Method Synthesis)) (<| <synthesis>.tuple (<>.after (<synthesis>.this_text jvm.static_tag)) @@ -379,7 +379,7 @@ (..method_body (list.size args)))) ))) -(def: abstract_method_synthesis +(def abstract_method_synthesis (<synthesis>.Parser (jvm.Abstract_Method Synthesis)) (<| <synthesis>.tuple (<>.after (<synthesis>.this_text jvm.abstract_tag)) @@ -393,7 +393,7 @@ (<synthesis>.tuple (<>.some ..class_type_synthesis)) ))) -(def: method_synthesis +(def method_synthesis (<synthesis>.Parser (Method_Definition Synthesis)) (all <>.or ..constructor_synthesis @@ -403,15 +403,15 @@ ..abstract_method_synthesis )) -(def: composite +(def composite (-> (List (Bytecode Any)) (Bytecode Any)) (|>> list.reversed (list#mix _.composite (_#in [])))) -(def: constructor_name +(def constructor_name "<init>") -(def: (method_argument lux_register argumentT jvm_register) +(def (method_argument lux_register argumentT jvm_register) (-> Register (Type Value) Register [Register (Bytecode Any)]) (case (type.primitive? argumentT) {.#Left argumentT} @@ -444,7 +444,7 @@ ... (at type.equivalence = type.double argumentT) (wrap_primitive 2 _.dload type.double)))))) -(def: .public (method_arguments offset types) +(def .public (method_arguments offset types) (-> Nat (List (Type Value)) (Bytecode Any)) (|> types list.enumeration @@ -454,7 +454,7 @@ (is [Register (Bytecode Any)] [offset (_#in [])])) product.right)) -(def: (constructor_method_generation archive super_class method) +(def (constructor_method_generation archive super_class method) (-> Archive (Type Class) (jvm.Constructor Synthesis) (Operation (Resource Method))) (<| (let [[privacy strict_floating_point? annotations method_tvars exceptions self arguments constructor_argumentsS @@ -489,7 +489,7 @@ _.return )}))))) -(def: (method_return returnT) +(def (method_return returnT) (-> (Type Return) (Bytecode Any)) (case (type.void? returnT) {.#Right returnT} @@ -527,7 +527,7 @@ ... (at type.equivalence = type.double returnT) (unwrap_primitive _.dreturn type.double))))))) -(def: (overriden_method_generation archive method) +(def (overriden_method_generation archive method) (-> Archive (jvm.Overriden_Method Synthesis) (Operation (Resource Method))) (do [! phase.monad] [.let [[super method_name strict_floating_point? annotations @@ -554,7 +554,7 @@ bodyG (method_return returnJ))})))))) -(def: (virtual_method_generation archive method) +(def (virtual_method_generation archive method) (-> Archive (jvm.Virtual_Method Synthesis) (Operation (Resource Method))) (do [! phase.monad] [.let [[method_name privacy final? strict_floating_point? annotations method_tvars @@ -581,7 +581,7 @@ bodyG (method_return returnJ))})))))) -(def: (static_method_generation archive method) +(def (static_method_generation archive method) (-> Archive (jvm.Static_Method Synthesis) (Operation (Resource Method))) (do [! phase.monad] [.let [[method_name privacy strict_floating_point? annotations method_tvars @@ -606,7 +606,7 @@ bodyG (method_return returnJ))})))))) -(def: (abstract_method_generation method) +(def (abstract_method_generation method) (-> (jvm.Abstract_Method Synthesis) (Resource Method)) (let [[name privacy annotations variables arguments return exceptions] method] @@ -618,7 +618,7 @@ (list) {.#None}))) -(def: (method_generation archive super_class method) +(def (method_generation archive super_class method) (-> Archive (Type Class) (Method_Definition Synthesis) (Operation (Resource Method))) (case method {#Constructor method} @@ -636,7 +636,7 @@ {#Abstract_Method method} (at phase.monad in (..abstract_method_generation method)))) -(def: (method_definition archive super interfaces [mapping selfT] [analyse synthesize generate]) +(def (method_definition archive super interfaces [mapping selfT] [analyse synthesize generate]) (-> Archive (Type Class) (List (Type Class)) @@ -676,10 +676,10 @@ methodG (method_generation archive super methodS')] (in [dependencies methodG])))) -(def: class_name +(def class_name (|>> parser.read_class product.left name.internal)) -(def: (mock_class [name parameters] super interfaces fields methods modifier) +(def (mock_class [name parameters] super interfaces fields methods modifier) (-> Declaration (Type Class) (List (Type Class)) (List (Resource field.Field)) (List (Resource method.Method)) (Modifier class.Class) (Try [External Binary])) @@ -700,7 +700,7 @@ methods sequence.empty)))) -(def: (mock_value valueT) +(def (mock_value valueT) (-> (Type Value) (Bytecode Any)) (case (type.primitive? valueT) {.#Left classT} @@ -719,7 +719,7 @@ ... type.boolean type.byte type.short type.int type.char _.iconst_0))) -(def: (mock_return returnT) +(def (mock_return returnT) (-> (Type Return) (Bytecode Any)) (case (type.void? returnT) {.#Right returnT} @@ -745,7 +745,7 @@ ... type.boolean type.byte type.short type.int type.char _.ireturn))))) -(def: (mock_method super method) +(def (mock_method super method) (-> (Type Class) (Method_Definition Code) (Resource method.Method)) (case method {#Constructor [privacy strict_floating_point? annotations variables exceptions @@ -823,7 +823,7 @@ {.#None}) )) -(def: (mock declaration super interfaces inheritance fields methods) +(def (mock declaration super interfaces inheritance fields methods) (-> Declaration (Type Class) (List (Type Class)) (Modifier class.Class) (List ..Field) (List (Method_Definition Code)) @@ -834,7 +834,7 @@ inheritance)) (with_template [<name> <type> <parser>] - [(def: <name> + [(def <name> (Parser <type>) (do [! <>.monad] [raw <code>.text] @@ -843,7 +843,7 @@ [class_declaration [External (List (Type Var))] parser.declaration'] ) -(def: (save_class! name bytecode dependencies) +(def (save_class! name bytecode dependencies) (-> Text Binary (Set unit.ID) (Operation Any)) (directive.lifted_generation (do [! phase.monad] @@ -854,7 +854,7 @@ _ (generation.log! (format "JVM Class " name))] (in [])))) -(def: jvm::class +(def jvm::class (Handler Anchor (Bytecode Any) Definition) (/.custom [(all <>.and @@ -919,7 +919,7 @@ _ (..save_class! name bytecode all_dependencies)] (in directive.no_requirements)))])) -(def: (method_declaration (open "/[0]")) +(def (method_declaration (open "/[0]")) (-> (jvm.Method_Declaration Code) (Resource Method)) (let [type (type.method [/#type_variables /#arguments /#return /#exceptions])] (method.method (all modifier#composite @@ -930,7 +930,7 @@ (list) {.#None}))) -(def: jvm::class::interface +(def jvm::class::interface (Handler Anchor (Bytecode Any) Definition) (/.custom [(all <>.and @@ -968,7 +968,7 @@ (import java/lang/ClassLoader "[1]::[0]") -(def: .public (bundle class_loader extender) +(def .public (bundle class_loader extender) (-> java/lang/ClassLoader Extender (Bundle Anchor (Bytecode Any) Definition)) (<| (bundle.prefix "jvm") (|> bundle.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux index 47b487dea..a8117080a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux @@ -56,7 +56,7 @@ [dependency ["[1]/[0]" artifact]]]]]]]]) -(def: .public (custom [syntax handler]) +(def .public (custom [syntax handler]) (All (_ anchor expression directive s) (-> [(Parser s) (-> Text @@ -73,13 +73,13 @@ {try.#Failure error} (phase.except ///.invalid_syntax [extension_name %.code inputs])))) -(def: (context [@module @artifact]) +(def (context [@module @artifact]) (-> unit.ID unit.ID) ... TODO: Find a better way that doesn't rely on clever tricks. [@module (n.- (++ @artifact) 0)]) ... TODO: Inline "evaluate!'" into "evaluate!" ASAP -(def: (evaluate!' archive generate code//type codeS) +(def (evaluate!' archive generate code//type codeS) (All (_ anchor expression directive) (-> Archive (/////generation.Phase anchor expression directive) @@ -95,7 +95,7 @@ codeV (/////generation.evaluate! (..context [@module id]) [{.#None} codeG])] (in [code//type codeG codeV])))) -(def: .public (evaluate! archive type codeC) +(def .public (evaluate! archive type codeC) (All (_ anchor expression directive) (-> Archive Type Code (Operation anchor expression directive [Type expression Any]))) (do phase.monad @@ -113,7 +113,7 @@ (evaluate!' archive generate type codeS))) ... TODO: Inline "definition'" into "definition" ASAP -(def: (definition' archive generate [module name] code//type codeS) +(def (definition' archive generate [module name] code//type codeS) (All (_ anchor expression directive) (-> Archive (/////generation.Phase anchor expression directive) @@ -140,7 +140,7 @@ _ (/////generation.save! @self {.#None} directive)] (in [code//type codeG value])))) -(def: (definition archive name expected codeC) +(def (definition archive name expected codeC) (All (_ anchor expression directive) (-> Archive Symbol (Maybe Type) Code (Operation anchor expression directive [Type expression Any]))) @@ -171,7 +171,7 @@ (with_template [<full> <partial> <learn>] [... TODO: Inline "<partial>" into "<full>" ASAP - (def: (<partial> archive generate extension codeT codeS) + (def (<partial> archive generate extension codeT codeS) (All (_ anchor expression directive) (-> Archive (/////generation.Phase anchor expression directive) @@ -193,7 +193,7 @@ _ (/////generation.save! @self {.#None} directive)] (in [codeG value]))))) - (def: .public (<full> archive extension codeT codeC) + (def .public (<full> archive extension codeT codeC) (All (_ anchor expression directive) (-> Archive Text Type Code (Operation anchor expression directive [expression Any]))) @@ -218,7 +218,7 @@ ) ... TODO: Get rid of this function ASAP. -(def: (refresh expander host_analysis) +(def (refresh expander host_analysis) (All (_ anchor expression directive) (-> Expander /////analysis.Bundle (Operation anchor expression directive Any))) (do phase.monad @@ -236,13 +236,13 @@ (dictionary.composite (///analysis.bundle eval host_analysis)))])) state)]))) -(def: (announce_definition! short type) +(def (announce_definition! short type) (All (_ anchor expression directive) (-> Text Type (Operation anchor expression directive Any))) (/////directive.lifted_generation (/////generation.log! (format short " : " (%.type type))))) -(def: (lux::def expander host_analysis) +(def (lux::def expander host_analysis) (-> Expander /////analysis.Bundle Handler) (function (_ extension_name phase archive inputsC+) (case inputsC+ @@ -262,7 +262,7 @@ _ (phase.except ///.invalid_syntax [extension_name %.code inputsC+])))) -(def: (announce_labels! labels owner) +(def (announce_labels! labels owner) (All (_ anchor expression directive) (-> (List Text) Type (Operation anchor expression directive (List Any)))) (/////directive.lifted_generation @@ -271,7 +271,7 @@ (/////generation.log! (format tag " : Tag of " (%.type owner)))) labels))) -(def: (def::type_tagged expander host_analysis) +(def (deftype_tagged expander host_analysis) (-> Expander /////analysis.Bundle Handler) (..custom [(all <>.and <code>.local <code>.any @@ -309,13 +309,13 @@ _ (..announce_labels! labels (as Type value))] (in /////directive.no_requirements)))])) -(def: imports +(def imports (Parser (List Import)) (|> (<code>.tuple (<>.and <code>.text <code>.text)) <>.some <code>.tuple)) -(def: def::module +(def defmodule Handler (..custom [..imports @@ -346,7 +346,7 @@ "Alias" (%.symbol local) "Label" (%.symbol foreign))) -(def: (define_alias alias original) +(def (define_alias alias original) (-> Text Symbol (/////analysis.Operation Any)) (do phase.monad [current_module (///.lifted meta.current_module_name) @@ -363,7 +363,7 @@ {.#Slot _}) (phase.except ..cannot_alias_a_label [[current_module alias] original])))) -(def: def::alias +(def defalias Handler (..custom [(all <>.and <code>.local <code>.symbol) @@ -377,7 +377,7 @@ ... TODO: Stop requiring these types and the "swapped" function below to make types line-up. (with_template [<name> <anonymous>] - [(def: <name> + [(def <name> Type (with_expansions [<original> binary.Binary] (let [_ <original>] @@ -388,7 +388,7 @@ [Binary|DEFAULT (type (array.Array (I64 Any)))] ) -(def: (swapped original replacement) +(def (swapped original replacement) (-> Type Type Type Type) (function (again type) (if (type#= original type) @@ -420,7 +420,7 @@ {.#Named name (again anonymous)})))) (with_template [<description> <mame> <def_type> <type> <scope> <definer>] - [(def: (<mame> [anchorT expressionT directiveT] extender) + [(def (<mame> [anchorT expressionT directiveT] extender) (All (_ anchor expression directive) (-> [Type Type Type] Extender (Handler anchor expression directive))) @@ -459,22 +459,22 @@ (phase.except ///.invalid_syntax [extension_name %.code inputsC+]))))] ["Analysis" - def::analysis + defanalysis /////analysis.Handler /////analysis.Handler /////directive.lifted_analysis ..analyser] ["Synthesis" - def::synthesis + defsynthesis /////synthesis.Handler /////synthesis.Handler /////directive.lifted_synthesis ..synthesizer] ["Generation" - def::generation + defgeneration (/////generation.Handler anchorT expressionT directiveT) (/////generation.Handler anchor expression directive) /////directive.lifted_generation ..generator] ["Directive" - def::directive + defdirective (/////directive.Handler anchorT expressionT directiveT) (/////directive.Handler anchor expression directive) (<|) ..directive] @@ -482,8 +482,8 @@ ... TODO; Both "prepare-program" and "define-program" exist only ... because the old compiler couldn't handle a fully-inlined definition -... for "def::program". Inline them ASAP. -(def: (prepare_program archive analyse synthesize programC) +... for "defprogram". Inline them ASAP. +(def (prepare_program archive analyse synthesize programC) (All (_ anchor expression directive output) (-> Archive /////analysis.Phase @@ -499,7 +499,7 @@ (/////directive.lifted_synthesis (synthesize archive programA)))) -(def: (define_program archive @module generate program programS) +(def (define_program archive @module generate program programS) (All (_ anchor expression directive output) (-> Archive module.ID @@ -514,7 +514,7 @@ @self (/////generation.learn [/////program.name {.#None}] true (list#mix set.has dependencies interim_artifacts))] (/////generation.save! @self {.#None} (program [@module @self] programG)))) -(def: (def::program program) +(def (defprogram program) (All (_ anchor expression directive) (-> (Program expression directive) (Handler anchor expression directive))) (function (handler extension_name phase archive inputsC+) @@ -536,7 +536,7 @@ _ (phase.except ///.invalid_syntax [extension_name %.code inputsC+])))) -(def: (bundle::def expander host_analysis program anchorT,expressionT,directiveT extender) +(def (bundle::def expander host_analysis program anchorT,expressionT,directiveT extender) (All (_ anchor expression directive) (-> Expander /////analysis.Bundle @@ -546,17 +546,17 @@ (Bundle anchor expression directive))) (<| (///bundle.prefix "def") (|> ///bundle.empty - (dictionary.has "module" def::module) - (dictionary.has "alias" def::alias) - (dictionary.has "type tagged" (def::type_tagged expander host_analysis)) - (dictionary.has "analysis" (def::analysis anchorT,expressionT,directiveT extender)) - (dictionary.has "synthesis" (def::synthesis anchorT,expressionT,directiveT extender)) - (dictionary.has "generation" (def::generation anchorT,expressionT,directiveT extender)) - (dictionary.has "directive" (def::directive anchorT,expressionT,directiveT extender)) - (dictionary.has "program" (def::program program)) + (dictionary.has "module" defmodule) + (dictionary.has "alias" defalias) + (dictionary.has "type tagged" (deftype_tagged expander host_analysis)) + (dictionary.has "analysis" (defanalysis anchorT,expressionT,directiveT extender)) + (dictionary.has "synthesis" (defsynthesis anchorT,expressionT,directiveT extender)) + (dictionary.has "generation" (defgeneration anchorT,expressionT,directiveT extender)) + (dictionary.has "directive" (defdirective anchorT,expressionT,directiveT extender)) + (dictionary.has "program" (defprogram program)) ))) -(def: .public (bundle expander host_analysis program anchorT,expressionT,directiveT extender) +(def .public (bundle expander host_analysis program anchorT,expressionT,directiveT extender) (All (_ anchor expression directive) (-> Expander /////analysis.Bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp.lux index 7ef89329d..246b7455e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp.lux @@ -12,7 +12,7 @@ [common_lisp [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux index c0c04d708..51ed09e66 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/common.lux @@ -38,7 +38,7 @@ [/// ["[1]" phase]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -51,12 +51,12 @@ {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -(def: !unary +(def !unary (template (_ function) (|>> list _.apply (|> (_.constant function))))) ... ... TODO: Get rid of this ASAP -... (def: lux::syntax_char_case! +... (def lux::syntax_char_case! ... (..custom [(all <>.and ... <s>.any ... <s>.any @@ -81,7 +81,7 @@ ... elseG ... conditionalsG))))))])) -(def: lux_procs +(def lux_procs Bundle (|> /.empty ... (/.install "syntax char case!" lux::syntax_char_case!) @@ -89,12 +89,12 @@ ... (/.install "try" (unary //runtime.lux//try)) )) -... (def: (capped operation parameter subject) +... (def (capped operation parameter subject) ... (-> (-> Expression Expression Expression) ... (-> Expression Expression Expression)) ... (//runtime.i64//64 (operation parameter subject))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -114,7 +114,7 @@ (/.install "char" (unary (|>> _.code_char/1 _.string/1))) ))) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -130,19 +130,19 @@ ... (/.install "decode" (unary //runtime.f64//decode)) ))) -(def: (text//index [offset sub text]) +(def (text//index [offset sub text]) (Trinary (Expression Any)) (//runtime.text//index offset sub text)) -(def: (text//clip [offset length text]) +(def (text//clip [offset length text]) (Trinary (Expression Any)) (//runtime.text//clip offset length text)) -(def: (text//char [index text]) +(def (text//char [index text]) (Binary (Expression Any)) (_.char_code/1 (_.char/2 [text index]))) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -156,12 +156,12 @@ (/.install "clip" (trinary ..text//clip)) ))) -(def: (io//log! message) +(def (io//log! message) (Unary (Expression Any)) (_.progn (list (_.write_line/1 message) //runtime.unit))) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty @@ -169,7 +169,7 @@ (/.install "error" (unary _.error/1)) ))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/host.lux index 79e422867..a68ac7532 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/common_lisp/host.lux @@ -8,7 +8,7 @@ [common_lisp [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "common_lisp") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js.lux index 5b4f0979a..e3b3165e9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js.lux @@ -12,7 +12,7 @@ [js [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux index f83d48372..8f07958c0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/common.lux @@ -39,7 +39,7 @@ [/// ["[1]" phase (.open: "[1]#[0]" monad)]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -55,7 +55,7 @@ ... [Procedures] ... [[Bits]] (with_template [<name> <op>] - [(def: (<name> [paramG subjectG]) + [(def (<name> [paramG subjectG]) (Binary Expression) (<op> subjectG (//runtime.i64::number paramG)))] @@ -64,7 +64,7 @@ ) ... [[Numbers]] -(def: f64//decode +(def f64//decode (Unary Expression) (|>> list (_.apply (_.var "parseFloat")) @@ -72,33 +72,33 @@ (_.closure (list)) //runtime.lux//try)) -(def: i64::char +(def i64::char (Unary Expression) (|>> //runtime.i64::number (list) (_.apply (_.var "String.fromCharCode")))) ... [[Text]] -(def: (text//concat [leftG rightG]) +(def (text//concat [leftG rightG]) (Binary Expression) (|> leftG (_.do "concat" (list rightG)))) -(def: (text//clip [startG endG subjectG]) +(def (text//clip [startG endG subjectG]) (Trinary Expression) (//runtime.text//clip startG endG subjectG)) -(def: (text//index [startG partG subjectG]) +(def (text//index [startG partG subjectG]) (Trinary Expression) (//runtime.text//index startG partG subjectG)) ... [[IO]] -(def: (io//log messageG) +(def (io//log messageG) (Unary Expression) (all _., (//runtime.io//log messageG) //runtime.unit)) -(def: .public (statement expression archive synthesis) +(def .public (statement expression archive synthesis) Phase! (case synthesis ... TODO: Get rid of this ASAP @@ -148,7 +148,7 @@ )) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <s>.any <s>.any @@ -179,14 +179,14 @@ {.#Some else!})))))])) ... [Bundles] -(def: lux_procs +(def lux_procs Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) (/.install "is" (binary (product.uncurried _.=))) (/.install "try" (unary //runtime.lux//try)))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -206,7 +206,7 @@ (/.install "char" (unary i64::char)) ))) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -221,7 +221,7 @@ (/.install "encode" (unary (_.do "toString" (list)))) (/.install "decode" (unary f64//decode))))) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -234,14 +234,14 @@ (/.install "clip" (trinary text//clip)) ))) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty (/.install "log" (unary io//log)) (/.install "error" (unary //runtime.io//error))))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux index 0c3a868ae..5d15df243 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/js/host.lux @@ -31,28 +31,28 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: array::new +(def array::new (Unary Expression) (|>> (_.the //runtime.i64_low_field) list (_.new (_.var "Array")))) -(def: array::length +(def array::length (Unary Expression) (|>> (_.the "length") //runtime.i64::of_number)) -(def: (array::read [indexG arrayG]) +(def (array::read [indexG arrayG]) (Binary Expression) (_.at (_.the //runtime.i64_low_field indexG) arrayG)) -(def: (array::write [indexG valueG arrayG]) +(def (array::write [indexG valueG arrayG]) (Trinary Expression) (//runtime.array//write indexG valueG arrayG)) -(def: (array::delete [indexG arrayG]) +(def (array::delete [indexG arrayG]) (Binary Expression) (//runtime.array//delete indexG arrayG)) -(def: array +(def array Bundle (<| (/.prefix "array") (|> /.empty @@ -63,7 +63,7 @@ (/.install "delete" (binary array::delete)) ))) -(def: object::new +(def object::new (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [constructorS inputsS]) @@ -72,7 +72,7 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.new constructorG inputsG))))])) -(def: object::get +(def object::get Handler (custom [(all <>.and <s>.text <s>.any) @@ -81,7 +81,7 @@ [objectG (phase archive objectS)] (in (_.the fieldS objectG))))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <s>.text <s>.any (<>.some <s>.any)) @@ -92,14 +92,14 @@ (in (_.do methodS inputsG objectG))))])) (with_template [<!> <?> <unit>] - [(def: <!> (Nullary Expression) (function.constant <unit>)) - (def: <?> (Unary Expression) (_.= <unit>))] + [(def <!> (Nullary Expression) (function.constant <unit>)) + (def <?> (Unary Expression) (_.= <unit>))] [object::null object::null? _.null] [object::undefined object::undefined? _.undefined] ) -(def: object +(def object Bundle (<| (/.prefix "object") (|> /.empty @@ -112,13 +112,13 @@ (/.install "undefined?" (unary object::undefined?)) ))) -(def: js::constant +(def js::constant (custom [<s>.text (function (_ extension phase archive name) (at ////////phase.monad in (_.var name)))])) -(def: js::apply +(def js::apply (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [abstractionS inputsS]) @@ -127,7 +127,7 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply abstractionG inputsG))))])) -(def: js::function +(def js::function (custom [(all <>.and <s>.i64 <s>.any) (function (_ extension phase archive [arity abstractionS]) @@ -147,7 +147,7 @@ 1 (_.apply g!abstraction g!inputs) _ (_.apply_1 g!abstraction (_.array g!inputs)))))))))])) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "js") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm.lux index f53409c26..8f05447f9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm.lux @@ -12,7 +12,7 @@ [jvm [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (all dictionary.composite /common.bundle diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux index 44e2b7c41..febd59454 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/common.lux @@ -43,7 +43,7 @@ [meta [archive (.only Archive)]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text Phase Archive s (Operation (Bytecode Any)))] @@ -56,29 +56,29 @@ {try.#Failure error} (/////.except /////extension.invalid_syntax [extension_name synthesis.%synthesis input])))) -(def: $Boolean (type.class "java.lang.Boolean" (list))) -(def: $Double (type.class "java.lang.Double" (list))) -(def: $Character (type.class "java.lang.Character" (list))) -(def: $String (type.class "java.lang.String" (list))) -(def: $CharSequence (type.class "java.lang.CharSequence" (list))) -(def: $Object (type.class "java.lang.Object" (list))) -(def: $PrintStream (type.class "java.io.PrintStream" (list))) -(def: $System (type.class "java.lang.System" (list))) -(def: $Error (type.class "java.lang.Error" (list))) - -(def: lux_int +(def $Boolean (type.class "java.lang.Boolean" (list))) +(def $Double (type.class "java.lang.Double" (list))) +(def $Character (type.class "java.lang.Character" (list))) +(def $String (type.class "java.lang.String" (list))) +(def $CharSequence (type.class "java.lang.CharSequence" (list))) +(def $Object (type.class "java.lang.Object" (list))) +(def $PrintStream (type.class "java.io.PrintStream" (list))) +(def $System (type.class "java.lang.System" (list))) +(def $Error (type.class "java.lang.Error" (list))) + +(def lux_int (Bytecode Any) (all _.composite _.i2l (///value.wrap type.long))) -(def: jvm_int +(def jvm_int (Bytecode Any) (all _.composite (///value.unwrap type.long) _.l2i)) -(def: (predicate bytecode) +(def (predicate bytecode) (-> (-> Label (Bytecode Any)) (Bytecode Any)) (do _.monad @@ -94,7 +94,7 @@ ))) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <synthesis>.any <synthesis>.any @@ -138,21 +138,21 @@ (_.set_label @end)) )))))])) -(def: (lux::is [referenceG sampleG]) +(def (lux::is [referenceG sampleG]) (Binary (Bytecode Any)) (all _.composite referenceG sampleG (..predicate _.if_acmpeq))) -(def: (lux::try riskyG) +(def (lux::try riskyG) (Unary (Bytecode Any)) (all _.composite riskyG (_.checkcast ///function.class) ///runtime.try)) -(def: bundle::lux +(def bundle::lux Bundle (|> (is Bundle /////bundle.empty) (/////bundle.install "syntax char case!" ..lux::syntax_char_case!) @@ -160,7 +160,7 @@ (/////bundle.install "try" (unary ..lux::try)))) (with_template [<name> <op>] - [(def: (<name> [maskG inputG]) + [(def (<name> [maskG inputG]) (Binary (Bytecode Any)) (all _.composite inputG (///value.unwrap type.long) @@ -173,7 +173,7 @@ ) (with_template [<name> <op>] - [(def: (<name> [shiftG inputG]) + [(def (<name> [shiftG inputG]) (Binary (Bytecode Any)) (all _.composite inputG (///value.unwrap type.long) @@ -185,7 +185,7 @@ ) (with_template [<name> <type> <op>] - [(def: (<name> [paramG subjectG]) + [(def (<name> [paramG subjectG]) (Binary (Bytecode Any)) (all _.composite subjectG (///value.unwrap <type>) @@ -207,7 +207,7 @@ (with_template [<eq> <lt> <type> <cmp>] [(with_template [<name> <reference>] - [(def: (<name> [paramG subjectG]) + [(def (<name> [paramG subjectG]) (Binary (Bytecode Any)) (all _.composite subjectG (///value.unwrap <type>) @@ -223,12 +223,12 @@ [f64::= f64::< type.double _.dcmpg] ) -(def: (::toString class from) +(def (::toString class from) (-> (Type Class) (Type Primitive) (Bytecode Any)) (_.invokestatic class "toString" (type.method [(list) (list from) ..$String (list)]))) (with_template [<name> <prepare> <transform>] - [(def: (<name> inputG) + [(def (<name> inputG) (Unary (Bytecode Any)) (all _.composite inputG @@ -263,7 +263,7 @@ ///runtime.decode_frac] ) -(def: bundle::i64 +(def bundle::i64 Bundle (<| (/////bundle.prefix "i64") (|> (is Bundle /////bundle.empty) @@ -282,7 +282,7 @@ (/////bundle.install "f64" (unary ..i64::f64)) (/////bundle.install "char" (unary ..i64::char))))) -(def: bundle::f64 +(def bundle::f64 Bundle (<| (/////bundle.prefix "f64") (|> (is Bundle /////bundle.empty) @@ -297,7 +297,7 @@ (/////bundle.install "encode" (unary ..f64::encode)) (/////bundle.install "decode" (unary ..f64::decode))))) -(def: (text::size inputG) +(def (text::size inputG) (Unary (Bytecode Any)) (all _.composite inputG @@ -305,10 +305,10 @@ (_.invokevirtual ..$String "length" (type.method [(list) (list) type.int (list)])) ..lux_int)) -(def: no_op (Bytecode Any) (_#in [])) +(def no_op (Bytecode Any) (_#in [])) (with_template [<name> <pre_subject> <pre_param> <op> <post>] - [(def: (<name> [paramG subjectG]) + [(def (<name> [paramG subjectG]) (Binary (Bytecode Any)) (all _.composite subjectG <pre_subject> @@ -326,14 +326,14 @@ ..lux_int] ) -(def: (text::concat [leftG rightG]) +(def (text::concat [leftG rightG]) (Binary (Bytecode Any)) (all _.composite leftG (_.checkcast $String) rightG (_.checkcast $String) (_.invokevirtual ..$String "concat" (type.method [(list) (list ..$String) ..$String (list)])))) -(def: (text::clip [offset! length! subject!]) +(def (text::clip [offset! length! subject!]) (Trinary (Bytecode Any)) (all _.composite subject! (_.checkcast $String) @@ -343,8 +343,8 @@ _.iadd (_.invokevirtual ..$String "substring" (type.method [(list) (list type.int type.int) ..$String (list)])))) -(def: index_method (type.method [(list) (list ..$String type.int) type.int (list)])) -(def: (text::index [startG partG textG]) +(def index_method (type.method [(list) (list ..$String type.int) type.int (list)])) +(def (text::index [startG partG textG]) (Trinary (Bytecode Any)) (do _.monad [@not_found _.new_label @@ -365,7 +365,7 @@ ///runtime.none_injection (_.set_label @end)))) -(def: bundle::text +(def bundle::text Bundle (<| (/////bundle.prefix "text") (|> (is Bundle /////bundle.empty) @@ -377,8 +377,8 @@ (/////bundle.install "char" (binary ..text::char)) (/////bundle.install "clip" (trinary ..text::clip))))) -(def: string_method (type.method [(list) (list ..$String) type.void (list)])) -(def: (io::log messageG) +(def string_method (type.method [(list) (list ..$String) type.void (list)])) +(def (io::log messageG) (Unary (Bytecode Any)) (all _.composite (_.getstatic ..$System "out" ..$PrintStream) @@ -387,7 +387,7 @@ (_.invokevirtual ..$PrintStream "println" ..string_method) ///runtime.unit)) -(def: (io::error messageG) +(def (io::error messageG) (Unary (Bytecode Any)) (all _.composite (_.new ..$Error) @@ -397,14 +397,14 @@ (_.invokespecial ..$Error "<init>" ..string_method) _.athrow)) -(def: bundle::io +(def bundle::io Bundle (<| (/////bundle.prefix "io") (|> (is Bundle /////bundle.empty) (/////bundle.install "log" (unary ..io::log)) (/////bundle.install "error" (unary ..io::error))))) -(def: .public bundle +(def .public bundle Bundle (<| (/////bundle.prefix "lux") (|> bundle::lux diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux index e08b2aba8..a13cef376 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/jvm/host.lux @@ -81,7 +81,7 @@ ["[1]/[0]" artifact]]]]]]]]) (with_template [<name> <0>] - [(def: <name> + [(def <name> (Bytecode Any) (all _.composite _.l2i @@ -93,7 +93,7 @@ ) (with_template [<conversion> <name>] - [(def: (<name> inputG) + [(def (<name> inputG) (Unary (Bytecode Any)) (if (same? _.nop <conversion>) inputG @@ -133,7 +133,7 @@ [_.i2l conversion::short_to_long] ) -(def: bundle::conversion +(def bundle::conversion Bundle (<| (/////bundle.prefix "conversion") (|> (is Bundle /////bundle.empty) @@ -170,7 +170,7 @@ ))) (with_template [<name> <op>] - [(def: (<name> [parameter! subject!]) + [(def (<name> [parameter! subject!]) (Binary (Bytecode Any)) (all _.composite subject! @@ -214,12 +214,12 @@ [double::% _.drem] ) -(def: $Boolean (type.class box.boolean (list))) -(def: falseG (_.getstatic ..$Boolean "FALSE" ..$Boolean)) -(def: trueG (_.getstatic ..$Boolean "TRUE" ..$Boolean)) +(def $Boolean (type.class box.boolean (list))) +(def falseG (_.getstatic ..$Boolean "FALSE" ..$Boolean)) +(def trueG (_.getstatic ..$Boolean "TRUE" ..$Boolean)) (with_template [<name> <op>] - [(def: (<name> [reference subject]) + [(def (<name> [reference subject]) (Binary (Bytecode Any)) (do _.monad [@then _.new_label @@ -242,7 +242,7 @@ ) (with_template [<name> <op> <reference>] - [(def: (<name> [reference subject]) + [(def (<name> [reference subject]) (Binary (Bytecode Any)) (do _.monad [@then _.new_label @@ -269,7 +269,7 @@ [double::< _.dcmpg -1] ) -(def: bundle::int +(def bundle::int Bundle (<| (/////bundle.prefix (reflection.reflection reflection.int)) (|> (is Bundle /////bundle.empty) @@ -288,7 +288,7 @@ (/////bundle.install "ushr" (binary int::ushr)) ))) -(def: bundle::long +(def bundle::long Bundle (<| (/////bundle.prefix (reflection.reflection reflection.long)) (|> (is Bundle /////bundle.empty) @@ -307,7 +307,7 @@ (/////bundle.install "ushr" (binary long::ushr)) ))) -(def: bundle::float +(def bundle::float Bundle (<| (/////bundle.prefix (reflection.reflection reflection.float)) (|> (is Bundle /////bundle.empty) @@ -320,7 +320,7 @@ (/////bundle.install "<" (binary float::<)) ))) -(def: bundle::double +(def bundle::double Bundle (<| (/////bundle.prefix (reflection.reflection reflection.double)) (|> (is Bundle /////bundle.empty) @@ -333,7 +333,7 @@ (/////bundle.install "<" (binary double::<)) ))) -(def: bundle::char +(def bundle::char Bundle (<| (/////bundle.prefix (reflection.reflection reflection.char)) (|> (is Bundle /////bundle.empty) @@ -342,7 +342,7 @@ ))) (with_template [<name> <category> <parser>] - [(def: .public <name> + [(def .public <name> (Parser (Type <category>)) (<text>.then <parser> <synthesis>.text))] @@ -353,12 +353,12 @@ [return Return parser.return] ) -(def: reflection +(def reflection (All (_ category) (-> (Type (<| Return' Value' category)) Text)) (|>> type.reflection reflection.reflection)) -(def: signature +(def signature (All (_ category) (-> (Type category) Text)) (|>> type.signature signature.signature)) @@ -367,7 +367,7 @@ (exception.report "JVM Type" (..signature arrayJT))) -(def: .public object_array +(def .public object_array (Parser (Type Object)) (do <>.monad [arrayJT (<text>.then parser.array <synthesis>.text)] @@ -383,7 +383,7 @@ {.#None} (undefined)))) -(def: (primitive_array_length_handler jvm_primitive) +(def (primitive_array_length_handler jvm_primitive) (-> (Type Primitive) Handler) (..custom [<synthesis>.any @@ -395,7 +395,7 @@ (_.checkcast (type.array jvm_primitive)) _.arraylength))))])) -(def: array::length::object +(def array::length::object Handler (..custom [(all <>.and ..object_array <synthesis>.any) @@ -407,7 +407,7 @@ (_.checkcast (type.array elementJT)) _.arraylength))))])) -(def: (new_primitive_array_handler jvm_primitive) +(def (new_primitive_array_handler jvm_primitive) (-> Primitive_Array_Type Handler) (..custom [<synthesis>.any @@ -418,7 +418,7 @@ lengthG (_.newarray jvm_primitive)))))])) -(def: array::new::object +(def array::new::object Handler (..custom [(all <>.and ..object <synthesis>.any) @@ -429,7 +429,7 @@ lengthG (_.anewarray objectJT)))))])) -(def: (read_primitive_array_handler jvm_primitive loadG) +(def (read_primitive_array_handler jvm_primitive loadG) (-> (Type Primitive) (Bytecode Any) Handler) (..custom [(all <>.and <synthesis>.any <synthesis>.any) @@ -443,7 +443,7 @@ idxG loadG))))])) -(def: array::read::object +(def array::read::object Handler (..custom [(all <>.and ..object_array <synthesis>.any <synthesis>.any) @@ -457,7 +457,7 @@ idxG _.aaload))))])) -(def: (write_primitive_array_handler jvm_primitive storeG) +(def (write_primitive_array_handler jvm_primitive storeG) (-> (Type Primitive) (Bytecode Any) Handler) (..custom [(all <>.and <synthesis>.any <synthesis>.any <synthesis>.any) @@ -474,7 +474,7 @@ valueG storeG))))])) -(def: array::write::object +(def array::write::object Handler (..custom [(all <>.and ..object_array <synthesis>.any <synthesis>.any <synthesis>.any) @@ -491,7 +491,7 @@ valueG _.aastore))))])) -(def: bundle::array +(def bundle::array Bundle (<| (/////bundle.prefix "array") (|> /////bundle.empty @@ -541,11 +541,11 @@ (/////bundle.install "object" array::write::object)))) ))) -(def: (object::null _) +(def (object::null _) (Nullary (Bytecode Any)) _.aconst_null) -(def: (object::null? objectG) +(def (object::null? objectG) (Unary (Bytecode Any)) (do _.monad [@then _.new_label @@ -559,7 +559,7 @@ ..trueG (_.set_label @end)))) -(def: (object::synchronized [monitorG exprG]) +(def (object::synchronized [monitorG exprG]) (Binary (Bytecode Any)) (all _.composite monitorG @@ -569,16 +569,16 @@ _.swap _.monitorexit)) -(def: (object::throw exceptionG) +(def (object::throw exceptionG) (Unary (Bytecode Any)) (all _.composite exceptionG _.athrow)) -(def: $Class (type.class "java.lang.Class" (list))) -(def: $String (type.class "java.lang.String" (list))) +(def $Class (type.class "java.lang.Class" (list))) +(def $String (type.class "java.lang.String" (list))) -(def: object::class +(def object::class Handler (..custom [<synthesis>.text @@ -589,7 +589,7 @@ (_.string class) (_.invokestatic ..$Class "forName" (type.method [(list) (list ..$String) ..$Class (list)]))))))])) -(def: object::instance? +(def object::instance? Handler (..custom [(all <>.and <synthesis>.text <synthesis>.any) @@ -601,7 +601,7 @@ (_.instanceof (type.class class (list))) (///value.wrap type.boolean)))))])) -(def: object::cast +(def object::cast Handler (..custom [(all <>.and <synthesis>.text <synthesis>.text <synthesis>.any) @@ -632,7 +632,7 @@ ... else valueG)))))])) -(def: bundle::object +(def bundle::object Bundle (<| (/////bundle.prefix "object") (|> (is Bundle /////bundle.empty) @@ -645,17 +645,17 @@ (/////bundle.install "cast" object::cast) ))) -(def: get::static +(def get::static Handler (..custom [(all <>.and <synthesis>.text <synthesis>.text ..value) (function (_ extension_name generate archive [class field :unboxed:]) (at //////.monad in (_.getstatic (type.class class (list)) field :unboxed:)))])) -(def: unitG +(def unitG (_.string synthesis.unit)) -(def: put::static +(def put::static Handler (..custom [(all <>.and <synthesis>.text <synthesis>.text ..value <synthesis>.any) @@ -673,7 +673,7 @@ (_.putstatic (type.class class (list)) field :unboxed:) ..unitG))))])) -(def: get::virtual +(def get::virtual Handler (..custom [(all <>.and <synthesis>.text <synthesis>.text ..value <synthesis>.any) @@ -687,7 +687,7 @@ (_.checkcast :class:) getG))))])) -(def: put::virtual +(def put::virtual Handler (..custom [(all <>.and <synthesis>.text <synthesis>.text ..value <synthesis>.any <synthesis>.any) @@ -714,11 +714,11 @@ (type: Input (Typed Synthesis)) -(def: input +(def input (Parser Input) (<synthesis>.tuple (<>.and ..value <synthesis>.any))) -(def: (generate_input generate archive [valueT valueS]) +(def (generate_input generate archive [valueT valueS]) (-> Phase Archive Input (Operation (Typed (Bytecode Any)))) (do //////.monad [valueG (generate archive valueS)] @@ -731,7 +731,7 @@ valueG (_.checkcast valueT))])))) -(def: (prepare_output outputT) +(def (prepare_output outputT) (-> (Type Return) (Bytecode Any)) (case (type.void? outputT) {.#Right outputT} @@ -740,7 +740,7 @@ {.#Left outputT} (_#in []))) -(def: invoke::static +(def invoke::static Handler (..custom [(all <>.and ..class <synthesis>.text ..return (<>.some ..input)) @@ -753,7 +753,7 @@ (prepare_output outputT)))))])) (with_template [<check_cast?> <name> <invoke>] - [(def: <name> + [(def <name> Handler (..custom [(all <>.and ..class <synthesis>.text ..return <synthesis>.any (<>.some ..input)) @@ -775,7 +775,7 @@ [#1 invoke::interface _.invokeinterface] ) -(def: invoke::constructor +(def invoke::constructor Handler (..custom [(all <>.and ..class (<>.some ..input)) @@ -788,7 +788,7 @@ (monad.each _.monad product.right inputsTG) (_.invokespecial class "<init>" (type.method [(list) (list#each product.left inputsTG) type.void (list)]))))))])) -(def: bundle::member +(def bundle::member Bundle (<| (/////bundle.prefix "member") (|> (is Bundle /////bundle.empty) @@ -809,19 +809,19 @@ (/////bundle.install "constructor" invoke::constructor)))) ))) -(def: annotation_parameter +(def annotation_parameter (Parser (/.Annotation_Parameter Synthesis)) (<synthesis>.tuple (<>.and <synthesis>.text <synthesis>.any))) -(def: annotation +(def annotation (Parser (/.Annotation Synthesis)) (<synthesis>.tuple (<>.and <synthesis>.text (<>.some ..annotation_parameter)))) -(def: argument +(def argument (Parser Argument) (<synthesis>.tuple (<>.and <synthesis>.text ..value))) -(def: .public (hidden_method_body arity body) +(def .public (hidden_method_body arity body) (-> Nat Synthesis Synthesis) (with_expansions [<oops> (panic! (%.format (%.nat arity) " " (synthesis.%synthesis body)))] (case [arity body] @@ -847,7 +847,7 @@ _ <oops>))) -(def: (without_fake_parameter#path without_fake_parameter) +(def (without_fake_parameter#path without_fake_parameter) (-> (-> Synthesis Synthesis) (-> Path Path)) (function (again it) @@ -881,7 +881,7 @@ {synthesis.#Then it} {synthesis.#Then (without_fake_parameter it)}))) -(def: .public (without_fake_parameter it) +(def .public (without_fake_parameter it) (-> Synthesis Synthesis) (case it {synthesis.#Simple _} @@ -970,7 +970,7 @@ {synthesis.#Extension name parameters} {synthesis.#Extension name (list#each without_fake_parameter parameters)})) -(def: overriden_method_definition +(def overriden_method_definition (Parser [(Environment Synthesis) (/.Overriden_Method Synthesis)]) (<synthesis>.tuple (do <>.monad [_ (<synthesis>.this_text /.overriden_tag) @@ -998,7 +998,7 @@ 0 (without_fake_parameter body) _ body))]])))) -(def: (normalize_path normalize) +(def (normalize_path normalize) (-> (-> Synthesis Synthesis) (-> Path Path)) (function (again path) @@ -1035,7 +1035,7 @@ (type: Mapping (Dictionary Synthesis Variable)) -(def: (normalize_method_body mapping) +(def (normalize_method_body mapping) (-> Mapping Synthesis Synthesis) (function (again body) (case body @@ -1099,17 +1099,17 @@ {synthesis.#Extension [name inputsS+]} {synthesis.#Extension [name (list#each again inputsS+)]}))) -(def: $Object +(def $Object (type.class "java.lang.Object" (list))) -(def: (anonymous_init_method env inputsTI) +(def (anonymous_init_method env inputsTI) (-> (Environment Synthesis) (List (Typed (Bytecode Any))) (Type category.Method)) (type.method [(list) (list.repeated (n.+ (list.size inputsTI) (list.size env)) ..$Object) type.void (list)])) -(def: (with_anonymous_init class env super_class inputsTG) +(def (with_anonymous_init class env super_class inputsTG) (-> (Type category.Class) (Environment Synthesis) (Type category.Class) (List (Typed (Bytecode Any))) (Resource Method)) (let [inputs_offset (list.size inputsTG) inputs! (|> inputsTG @@ -1144,7 +1144,7 @@ store_captured! _.return)}))) -(def: (anonymous_instance generate archive class env inputsTI) +(def (anonymous_instance generate archive class env inputsTI) (-> Phase Archive (Type category.Class) (Environment Synthesis) (List (Typed (Bytecode Any))) (Operation (Bytecode Any))) (do [! //////.monad] [captureG+ (monad.each ! (generate archive) env)] @@ -1158,7 +1158,7 @@ (monad.all _.monad captureG+) (_.invokespecial class "<init>" (anonymous_init_method env inputsTI)))))) -(def: (returnG returnT) +(def (returnG returnT) (-> (Type Return) (Bytecode Any)) (case (type.void? returnT) {.#Right returnT} @@ -1196,14 +1196,14 @@ ... (at type.equivalence = type.double returnT) (unwrap_primitive _.dreturn type.double))))))) -(def: (method_dependencies archive method) +(def (method_dependencies archive method) (-> Archive (/.Overriden_Method Synthesis) (Operation (Set unit.ID))) (let [[_super _name _strict_fp? _annotations _t_vars _this _arguments _return _exceptions bodyS] method] (cache/artifact.dependencies archive bodyS))) -(def: (anonymous_dependencies archive inputsTS overriden_methods) +(def (anonymous_dependencies archive inputsTS overriden_methods) (-> Archive (List Input) (List [(Environment Synthesis) (/.Overriden_Method Synthesis)]) (Operation (Set unit.ID))) (do [! //////.monad] @@ -1218,7 +1218,7 @@ all_closure_dependencies all_method_dependencies))))) -(def: (prepare_argument lux_register argumentT jvm_register) +(def (prepare_argument lux_register argumentT jvm_register) (-> Register (Type Value) Register [Register (Bytecode Any)]) (case (type.primitive? argumentT) {.#Left argumentT} @@ -1251,7 +1251,7 @@ ... (at type.equivalence = type.double argumentT) (wrap_primitive 2 _.dload type.double)))))) -(def: .public (prepare_arguments offset types) +(def .public (prepare_arguments offset types) (-> Nat (List (Type Value)) (Bytecode Any)) (|> types list.enumeration @@ -1266,7 +1266,7 @@ (_#in [])])) product.right)) -(def: (normalized_method global_mapping [environment method]) +(def (normalized_method global_mapping [environment method]) (-> Mapping [(Environment Synthesis) (/.Overriden_Method Synthesis)] (/.Overriden_Method Synthesis)) (let [[ownerT name strict_fp? annotations vars self_name arguments returnT exceptionsT body] method @@ -1283,7 +1283,7 @@ self_name arguments returnT exceptionsT (normalize_method_body local_mapping body)])) -(def: (total_environment overriden_methods) +(def (total_environment overriden_methods) (-> (List [(Environment Synthesis) (/.Overriden_Method Synthesis)]) (List Synthesis)) (|> overriden_methods @@ -1295,7 +1295,7 @@ (set.of_list synthesis.hash) set.list)) -(def: (global_mapping total_environment) +(def (global_mapping total_environment) (-> (List Synthesis) Mapping) (|> total_environment ... Give them names as "foreign" variables. @@ -1304,7 +1304,7 @@ [capture {//////variable.#Foreign id}])) (dictionary.of_list synthesis.hash))) -(def: (method_definition phase archive artifact_id method) +(def (method_definition phase archive artifact_id method) (-> Phase Archive artifact.ID (/.Overriden_Method Synthesis) (Operation (Resource Method))) (let [[ownerT name strict_fp? annotations vars self_name arguments returnT exceptionsT bodyS] method] (do //////.monad @@ -1326,7 +1326,7 @@ bodyG (returnG returnT))}))))) -(def: class::anonymous +(def class::anonymous Handler (..custom [(all <>.and @@ -1366,14 +1366,14 @@ _ (//////generation.save! artifact_id {.#None} artifact)] (anonymous_instance generate archive class total_environment inputsTI)))])) -(def: bundle::class +(def bundle::class Bundle (<| (/////bundle.prefix "class") (|> (is Bundle /////bundle.empty) (/////bundle.install "anonymous" class::anonymous) ))) -(def: .public bundle +(def .public bundle Bundle (<| (/////bundle.prefix "jvm") (|> ..bundle::conversion diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua.lux index bae90fe1b..8860a5568 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua.lux @@ -12,7 +12,7 @@ [lua [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux index c454fc422..14c293e39 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux @@ -43,7 +43,7 @@ [/// ["[1]" phase (.open: "[1]#[0]" monad)]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -56,11 +56,11 @@ {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -(def: !unary +(def !unary (template (_ function) [(|>> list _.apply (|> (_.var function)))])) -(def: .public (statement expression archive synthesis) +(def .public (statement expression archive synthesis) Phase! (case synthesis ... TODO: Get rid of this ASAP @@ -112,7 +112,7 @@ )) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <s>.any <s>.any @@ -141,14 +141,14 @@ (//case.case! statement phase archive) (at /////.monad each (|>> (as Expression)))))])) -(def: lux_procs +(def lux_procs Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) (/.install "is" (binary (product.uncurried _.=))) (/.install "try" (unary //runtime.lux//try)))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -168,11 +168,11 @@ (/.install "char" (unary (function (_ it) (_.apply (list it) (_.var "utf8.char"))))) ))) -(def: f64//decode +(def f64//decode (Unary Expression) (|>> list _.apply (|> (_.var "tonumber")) _.return (_.closure (list)) //runtime.lux//try)) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -187,19 +187,19 @@ (/.install "encode" (unary (function (_ it) (_.apply (list (_.string "%.17g") it) (_.var "string.format"))))) (/.install "decode" (unary ..f64//decode))))) -(def: (text//char [paramO subjectO]) +(def (text//char [paramO subjectO]) (Binary Expression) (//runtime.text//char (_.+ (_.int +1) paramO) subjectO)) -(def: (text//clip [paramO extraO subjectO]) +(def (text//clip [paramO extraO subjectO]) (Trinary Expression) (//runtime.text//clip subjectO paramO extraO)) -(def: (text//index [startO partO textO]) +(def (text//index [startO partO textO]) (Trinary Expression) (//runtime.text//index textO partO startO)) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -215,19 +215,19 @@ (/.install "clip" (trinary ..text//clip)) ))) -(def: (io//log! messageO) +(def (io//log! messageO) (Unary Expression) (|> (_.apply (list messageO) (_.var "print")) (_.or //runtime.unit))) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty (/.install "log" (unary ..io//log!)) (/.install "error" (unary (!unary "error")))))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux index 4ed8013ca..6d8a3bf73 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/host.lux @@ -34,27 +34,27 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: array::new +(def array::new (Unary Expression) (|>> ["n"] list _.table)) -(def: array::length +(def array::length (Unary Expression) (_.the "n")) -(def: (array::read [indexG arrayG]) +(def (array::read [indexG arrayG]) (Binary Expression) (_.item (_.+ (_.int +1) indexG) arrayG)) -(def: (array::write [indexG valueG arrayG]) +(def (array::write [indexG valueG arrayG]) (Trinary Expression) (//runtime.array//write indexG valueG arrayG)) -(def: (array::delete [indexG arrayG]) +(def (array::delete [indexG arrayG]) (Binary Expression) (//runtime.array//write indexG _.nil arrayG)) -(def: array +(def array Bundle (<| (/.prefix "array") (|> /.empty @@ -65,7 +65,7 @@ (/.install "delete" (binary array::delete)) ))) -(def: object::get +(def object::get Handler (custom [(all <>.and <s>.text <s>.any) @@ -74,7 +74,7 @@ [objectG (phase archive objectS)] (in (_.the fieldS objectG))))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <s>.text <s>.any (<>.some <s>.any)) @@ -85,13 +85,13 @@ (in (_.do methodS inputsG objectG))))])) (with_template [<!> <?> <unit>] - [(def: <!> (Nullary Expression) (function.constant <unit>)) - (def: <?> (Unary Expression) (_.= <unit>))] + [(def <!> (Nullary Expression) (function.constant <unit>)) + (def <?> (Unary Expression) (_.= <unit>))] [object::nil object::nil? _.nil] ) -(def: object +(def object Bundle (<| (/.prefix "object") (|> /.empty @@ -101,10 +101,10 @@ (/.install "nil?" (unary object::nil?)) ))) -(def: $input +(def $input (_.var "input")) -(def: utf8::encode +(def utf8::encode (custom [<s>.any (function (_ extension phase archive inputS) @@ -116,7 +116,7 @@ (_.var "string.byte"))) (_.var "table.pack")))))))])) -(def: utf8::decode +(def utf8::decode (custom [<s>.any (function (_ extension phase archive inputS) @@ -126,7 +126,7 @@ (_.var "table.unpack"))) (_.var "string.char")))))])) -(def: utf8 +(def utf8 Bundle (<| (/.prefix "utf8") (|> /.empty @@ -134,13 +134,13 @@ (/.install "decode" utf8::decode) ))) -(def: lua::constant +(def lua::constant (custom [<s>.text (function (_ extension phase archive name) (at ////////phase.monad in (_.var name)))])) -(def: lua::apply +(def lua::apply (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [abstractionS inputsS]) @@ -149,7 +149,7 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply inputsG abstractionG))))])) -(def: lua::power +(def lua::power (custom [(all <>.and <s>.any <s>.any) (function (_ extension phase archive [powerS baseS]) @@ -158,14 +158,14 @@ baseG (phase archive baseS)] (in (_.^ powerG baseG))))])) -(def: lua::import +(def lua::import (custom [<s>.text (function (_ extension phase archive module) (at ////////phase.monad in (_.require/1 (_.string module))))])) -(def: lua::function +(def lua::function (custom [(all <>.and <s>.i64 <s>.any) (function (_ extension phase archive [arity abstractionS]) @@ -184,7 +184,7 @@ 1 (_.apply g!inputs abstractionG) _ (_.apply (list (_.array g!inputs)) abstractionG))))))])) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lua") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php.lux index d36dc5557..4d9c8ab95 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php.lux @@ -12,7 +12,7 @@ [php [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux index 384736271..02ecee4d4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/common.lux @@ -38,7 +38,7 @@ [/// ["[1]" phase]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -51,12 +51,12 @@ {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -(def: !unary +(def !unary (template (_ function) (|>> list _.apply (|> (_.constant function))))) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <s>.any <s>.any @@ -98,7 +98,7 @@ _ (generation.save! context_artifact directive)] (in (_.apply (list.partial inputG foreigns) @expression))))])) -(def: lux_procs +(def lux_procs Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) @@ -106,11 +106,11 @@ (/.install "try" (unary //runtime.lux//try)) )) -(def: (left_shifted [parameter subject]) +(def (left_shifted [parameter subject]) (Binary Expression) (_.bit_shl (_.% (_.int +64) parameter) subject)) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -131,15 +131,15 @@ (/.install "char" (unary //runtime.i64//char)) ))) -(def: (f64//% [parameter subject]) +(def (f64//% [parameter subject]) (Binary Expression) (_.fmod/2 [subject parameter])) -(def: (f64//encode subject) +(def (f64//encode subject) (Unary Expression) (_.number_format/2 [subject (_.int +17)])) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -154,15 +154,15 @@ (/.install "encode" (unary ..f64//encode)) (/.install "decode" (unary //runtime.f64//decode))))) -(def: (text//clip [paramO extraO subjectO]) +(def (text//clip [paramO extraO subjectO]) (Trinary Expression) (//runtime.text//clip paramO extraO subjectO)) -(def: (text//index [startO partO textO]) +(def (text//index [startO partO textO]) (Trinary Expression) (//runtime.text//index textO partO startO)) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -175,14 +175,14 @@ (/.install "clip" (trinary ..text//clip)) ))) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty (/.install "log" (unary //runtime.io//log!)) (/.install "error" (unary //runtime.io//throw!))))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux index 535f01072..d63c2c626 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/php/host.lux @@ -34,23 +34,23 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: (array::new size) +(def (array::new size) (Unary Expression) (//runtime.tuple//make size (_.array_fill/3 [(_.int +0) size _.null]))) -(def: (array::read [indexG arrayG]) +(def (array::read [indexG arrayG]) (Binary Expression) (_.item indexG arrayG)) -(def: (array::write [indexG valueG arrayG]) +(def (array::write [indexG valueG arrayG]) (Trinary Expression) (//runtime.array//write indexG valueG arrayG)) -(def: (array::delete [indexG arrayG]) +(def (array::delete [indexG arrayG]) (Binary Expression) (//runtime.array//write indexG _.null arrayG)) -(def: array +(def array Bundle (<| (/.prefix "array") (|> /.empty @@ -61,7 +61,7 @@ (/.install "delete" (binary array::delete)) ))) -(def: object::new +(def object::new (custom [(all <>.and <s>.text (<>.some <s>.any)) (function (_ extension phase archive [constructor inputsS]) @@ -69,7 +69,7 @@ [inputsG (monad.each ! (phase archive) inputsS)] (in (_.new (_.constant constructor) inputsG))))])) -(def: object::get +(def object::get Handler (custom [(all <>.and <s>.text <s>.any) @@ -78,7 +78,7 @@ [objectG (phase archive objectS)] (in (_.the fieldS objectG))))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <s>.text <s>.any (<>.some <s>.any)) @@ -89,13 +89,13 @@ (in (_.do methodS inputsG objectG))))])) (with_template [<!> <?> <unit>] - [(def: <!> (Nullary Expression) (function.constant <unit>)) - (def: <?> (Unary Expression) (_.=== <unit>))] + [(def <!> (Nullary Expression) (function.constant <unit>)) + (def <?> (Unary Expression) (_.=== <unit>))] [object::null object::null? _.null] ) -(def: object +(def object Bundle (<| (/.prefix "object") (|> /.empty @@ -106,13 +106,13 @@ (/.install "null?" (unary object::null?)) ))) -(def: php::constant +(def php::constant (custom [<s>.text (function (_ extension phase archive name) (at ////////phase.monad in (_.constant name)))])) -(def: php::apply +(def php::apply (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [abstractionS inputsS]) @@ -121,7 +121,7 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply inputsG abstractionG))))])) -(def: php::pack +(def php::pack (custom [(all <>.and <s>.any <s>.any) (function (_ extension phase archive [formatS dataS]) @@ -130,7 +130,7 @@ dataG (phase archive dataS)] (in (_.pack/2 [formatG (_.splat dataG)]))))])) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "php") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python.lux index 7b0c7cc9b..bb9e2638d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python.lux @@ -12,7 +12,7 @@ [python [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux index ef6d301bc..3335bf992 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux @@ -45,7 +45,7 @@ [/// ["[1]" phase (.open: "[1]#[0]" monad)]]]]]) -(def: .public (statement expression archive synthesis) +(def .public (statement expression archive synthesis) Phase! (case synthesis ... TODO: Get rid of this ASAP @@ -88,7 +88,7 @@ (/////#each _.return (//function.function statement expression archive abstraction)) )) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -102,7 +102,7 @@ (/////.except extension.invalid_syntax [extension_name %synthesis input])))) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <synthesis>.any <synthesis>.any @@ -156,19 +156,19 @@ else! conditionals!))))))])) -(def: lux_procs +(def lux_procs Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) (/.install "is" (binary (product.uncurried _.is))) (/.install "try" (unary //runtime.lux::try)))) -(def: (capped operation parameter subject) +(def (capped operation parameter subject) (-> (-> (Expression Any) (Expression Any) (Expression Any)) (-> (Expression Any) (Expression Any) (Expression Any))) (//runtime.i64::64 (operation parameter subject))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -189,7 +189,7 @@ (/.install "char" (unary //runtime.i64::char)) ))) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -206,15 +206,15 @@ (/.install "encode" (unary _.repr/1)) (/.install "decode" (unary //runtime.f64::decode))))) -(def: (text::clip [paramO extraO subjectO]) +(def (text::clip [paramO extraO subjectO]) (Trinary (Expression Any)) (//runtime.text::clip paramO extraO subjectO)) -(def: (text::index [startO partO textO]) +(def (text::index [startO partO textO]) (Trinary (Expression Any)) (//runtime.text::index startO partO textO)) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -227,14 +227,14 @@ (/.install "clip" (trinary ..text::clip)) ))) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty (/.install "log" (unary //runtime.io::log!)) (/.install "error" (unary //runtime.io::throw!))))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux index 7ec9d1083..1c1f170ce 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/python/host.lux @@ -33,29 +33,29 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: (array::new size) +(def (array::new size) (Unary (Expression Any)) (|> (list _.none) _.list (_.* size))) -(def: array::length +(def array::length (Unary (Expression Any)) (|>> _.len/1 //runtime.i64::64)) -(def: (array::read [indexG arrayG]) +(def (array::read [indexG arrayG]) (Binary (Expression Any)) (_.item indexG arrayG)) -(def: (array::write [indexG valueG arrayG]) +(def (array::write [indexG valueG arrayG]) (Trinary (Expression Any)) (//runtime.array::write indexG valueG arrayG)) -(def: (array::delete [indexG arrayG]) +(def (array::delete [indexG arrayG]) (Binary (Expression Any)) (//runtime.array::write indexG _.none arrayG)) -(def: array +(def array Bundle (<| (/.prefix "array") (|> /.empty @@ -66,7 +66,7 @@ (/.install "delete" (binary array::delete)) ))) -(def: object::get +(def object::get Handler (custom [(all <>.and <s>.text <s>.any) @@ -75,7 +75,7 @@ [objectG (phase archive objectS)] (in (_.the fieldS objectG))))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <s>.text <s>.any (<>.some <s>.any)) @@ -86,13 +86,13 @@ (in (_.do methodS inputsG objectG))))])) (with_template [<!> <?> <unit>] - [(def: <!> (Nullary (Expression Any)) (function.constant <unit>)) - (def: <?> (Unary (Expression Any)) (_.= <unit>))] + [(def <!> (Nullary (Expression Any)) (function.constant <unit>)) + (def <?> (Unary (Expression Any)) (_.= <unit>))] [object::none object::none? _.none] ) -(def: object +(def object Bundle (<| (/.prefix "object") (|> /.empty @@ -102,7 +102,7 @@ (/.install "none?" (unary object::none?)) ))) -(def: python::constant +(def python::constant (custom [<s>.text (function (_ extension phase archive name) @@ -110,7 +110,7 @@ [] (in (_.var name))))])) -(def: python::import +(def python::import (custom [<s>.text (function (_ extension phase archive module) @@ -118,7 +118,7 @@ [] (in (_.apply (list (_.string module)) (_.var "__import__")))))])) -(def: python::apply +(def python::apply (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [abstractionS inputsS]) @@ -127,7 +127,7 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply inputsG abstractionG))))])) -(def: python::function +(def python::function (custom [(all <>.and <s>.i64 <s>.any) (function (_ extension phase archive [arity abstractionS]) @@ -144,7 +144,7 @@ 1 (_.apply g!inputs abstractionG) _ (_.apply (list (_.list g!inputs)) abstractionG))))))])) -(def: python::exec +(def python::exec (custom [(all <>.and <s>.any <s>.any) (function (_ extension phase archive [codeS globalsS]) @@ -153,7 +153,7 @@ globalsG (phase archive globalsS)] (in (//runtime.lux::exec codeG globalsG))))])) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "python") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r.lux index 1fbf60948..487b9958b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r.lux @@ -12,7 +12,7 @@ [r [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux index facbc2e58..cdcfb555b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/common.lux @@ -38,7 +38,7 @@ [/// ["[1]" phase]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -51,12 +51,12 @@ {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -... (def: !unary +... (def !unary ... (template (_ function) ... (|>> list _.apply (|> (_.constant function))))) ... ... ... TODO: Get rid of this ASAP -... ... (def: lux::syntax_char_case! +... ... (def lux::syntax_char_case! ... ... (..custom [(all <>.and ... ... <s>.any ... ... <s>.any @@ -81,7 +81,7 @@ ... ... elseG ... ... conditionalsG))))))])) -... (def: lux_procs +... (def lux_procs ... Bundle ... (|> /.empty ... ... (/.install "syntax char case!" lux::syntax_char_case!) @@ -89,12 +89,12 @@ ... ... (/.install "try" (unary //runtime.lux//try)) ... )) -... ... (def: (capped operation parameter subject) +... ... (def (capped operation parameter subject) ... ... (-> (-> Expression Expression Expression) ... ... (-> Expression Expression Expression)) ... ... (//runtime.i64//64 (operation parameter subject))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -114,7 +114,7 @@ (/.install "char" (unary (|>> //runtime.i64_low _.intToUtf8/1))) ))) -... (def: f64_procs +... (def f64_procs ... Bundle ... (<| (/.prefix "f64") ... (|> /.empty @@ -130,19 +130,19 @@ ... ... (/.install "decode" (unary //runtime.f64//decode)) ... ))) -... (def: (text//index [offset sub text]) +... (def (text//index [offset sub text]) ... (Trinary (Expression Any)) ... (//runtime.text//index offset sub text)) -... (def: (text//clip [offset length text]) +... (def (text//clip [offset length text]) ... (Trinary (Expression Any)) ... (//runtime.text//clip offset length text)) -... (def: (text//char [index text]) +... (def (text//char [index text]) ... (Binary (Expression Any)) ... (_.char_code/1 (_.char/2 [text index]))) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -155,12 +155,12 @@ ... (/.install "clip" (trinary ..text//clip)) ))) -... (def: (io//log! message) +... (def (io//log! message) ... (Unary (Expression Any)) ... (_.progn (list (_.write_line/1 message) ... //runtime.unit))) -... (def: io_procs +... (def io_procs ... Bundle ... (<| (/.prefix "io") ... (|> /.empty @@ -168,7 +168,7 @@ ... (/.install "error" (unary _.error/1)) ... ))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/host.lux index 8facd6a1a..3fa89672c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/r/host.lux @@ -34,7 +34,7 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "r") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby.lux index aa8f8e7b3..180444525 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby.lux @@ -12,7 +12,7 @@ [ruby [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux index 6cdacfa40..0537a3539 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/common.lux @@ -43,7 +43,7 @@ [/// ["[1]" phase (.open: "[1]#[0]" monad)]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -56,7 +56,7 @@ {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -(def: .public (statement expression archive synthesis) +(def .public (statement expression archive synthesis) Phase! (case synthesis ... TODO: Get rid of this ASAP @@ -101,7 +101,7 @@ )) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <s>.any <s>.any @@ -142,7 +142,7 @@ else! conditionals!))))))])) -(def: lux_procs +(def lux_procs Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) @@ -150,7 +150,7 @@ (_.do "equal?" (list reference) {.#None} subject)))) (/.install "try" (unary //runtime.lux//try)))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -173,7 +173,7 @@ (/.install "char" (unary //runtime.i64::char)) ))) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -189,19 +189,19 @@ (/.install "encode" (unary (_.do "to_s" (list) {.#None}))) (/.install "decode" (unary //runtime.f64//decode))))) -(def: (text//char [subjectO paramO]) +(def (text//char [subjectO paramO]) (Binary Expression) (//runtime.text//char subjectO paramO)) -(def: (text//clip [paramO extraO subjectO]) +(def (text//clip [paramO extraO subjectO]) (Trinary Expression) (//runtime.text//clip paramO extraO subjectO)) -(def: (text//index [startO partO textO]) +(def (text//index [startO partO textO]) (Trinary Expression) (//runtime.text//index textO partO startO)) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -214,16 +214,16 @@ (/.install "clip" (trinary text//clip)) ))) -(def: (io//log! messageG) +(def (io//log! messageG) (Unary Expression) (|> (_.print/2 messageG (_.string text.new_line)) (_.or //runtime.unit))) -(def: io//error! +(def io//error! (Unary Expression) _.raise) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty @@ -231,7 +231,7 @@ (/.install "error" (unary ..io//error!)) ))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux index 89638f972..ce451a263 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/ruby/host.lux @@ -34,27 +34,27 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: (array::new [size]) +(def (array::new [size]) (Unary Expression) (_.do "new" (list size) {.#None} (is _.CVar (_.manual "Array")))) -(def: array::length +(def array::length (Unary Expression) (_.the "size")) -(def: (array::read [indexG arrayG]) +(def (array::read [indexG arrayG]) (Binary Expression) (_.item indexG arrayG)) -(def: (array::write [indexG valueG arrayG]) +(def (array::write [indexG valueG arrayG]) (Trinary Expression) (//runtime.array//write indexG valueG arrayG)) -(def: (array::delete [indexG arrayG]) +(def (array::delete [indexG arrayG]) (Binary Expression) (//runtime.array//write indexG _.nil arrayG)) -(def: array +(def array Bundle (<| (/.prefix "array") (|> /.empty @@ -65,7 +65,7 @@ (/.install "delete" (binary array::delete)) ))) -(def: object::get +(def object::get Handler (custom [(all <>.and <s>.text <s>.any) @@ -74,7 +74,7 @@ [objectG (phase archive objectS)] (in (_.the fieldS objectG))))])) -(def: object::do +(def object::do Handler (custom [(all <>.and <s>.text <s>.any (<>.some <s>.any)) @@ -85,13 +85,13 @@ (in (_.do methodS inputsG {.#None} objectG))))])) (with_template [<!> <?> <unit>] - [(def: <!> (Nullary Expression) (function.constant <unit>)) - (def: <?> (Unary Expression) (_.= <unit>))] + [(def <!> (Nullary Expression) (function.constant <unit>)) + (def <?> (Unary Expression) (_.= <unit>))] [object::nil object::nil? _.nil] ) -(def: object +(def object Bundle (<| (/.prefix "object") (|> /.empty @@ -101,13 +101,13 @@ (/.install "nil?" (unary object::nil?)) ))) -(def: ruby::constant +(def ruby::constant (custom [<s>.text (function (_ extension phase archive name) (at ////////phase.monad in (is _.CVar (_.manual name))))])) -(def: ruby::apply +(def ruby::apply (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [abstractionS inputsS]) @@ -116,14 +116,14 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply inputsG {.#None} abstractionG))))])) -(def: ruby::import +(def ruby::import (custom [<s>.text (function (_ extension phase archive module) (at ////////phase.monad in (_.require/1 (_.string module))))])) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "ruby") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme.lux index 7bca45f93..fdca305d2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme.lux @@ -12,7 +12,7 @@ [scheme [runtime (.only Bundle)]]]]]) -(def: .public bundle +(def .public bundle Bundle (dictionary.composite /common.bundle /host.bundle)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux index 5d4801be1..20d9da33e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/common.lux @@ -38,7 +38,7 @@ [/// ["[1]" phase]]]]]) -(def: .public (custom [parser handler]) +(def .public (custom [parser handler]) (All (_ s) (-> [(Parser s) (-> Text (Generator s))] @@ -51,12 +51,12 @@ {try.#Failure error} (/////.except extension.invalid_syntax [extension_name %synthesis input])))) -(def: !unary +(def !unary (template (_ function) (|>> list _.apply (|> (_.constant function))))) ... TODO: Get rid of this ASAP -(def: lux::syntax_char_case! +(def lux::syntax_char_case! (..custom [(all <>.and <s>.any <s>.any @@ -81,7 +81,7 @@ elseG conditionalsG)))))])) -(def: lux_procs +(def lux_procs Bundle (|> /.empty (/.install "syntax char case!" lux::syntax_char_case!) @@ -89,12 +89,12 @@ (/.install "try" (unary //runtime.lux//try)) )) -(def: (capped operation parameter subject) +(def (capped operation parameter subject) (-> (-> Expression Expression Expression) (-> Expression Expression Expression)) (//runtime.i64//64 (operation parameter subject))) -(def: i64_procs +(def i64_procs Bundle (<| (/.prefix "i64") (|> /.empty @@ -114,7 +114,7 @@ (/.install "char" (unary (|>> _.integer->char/1 (_.make_string/2 (_.int +1))))) ))) -(def: f64_procs +(def f64_procs Bundle (<| (/.prefix "f64") (|> /.empty @@ -129,15 +129,15 @@ (/.install "encode" (unary _.number->string/1)) (/.install "decode" (unary //runtime.f64//decode))))) -(def: (text//index [offset sub text]) +(def (text//index [offset sub text]) (Trinary Expression) (//runtime.text//index offset sub text)) -(def: (text//clip [paramO extraO subjectO]) +(def (text//clip [paramO extraO subjectO]) (Trinary Expression) (//runtime.text//clip paramO extraO subjectO)) -(def: text_procs +(def text_procs Bundle (<| (/.prefix "text") (|> /.empty @@ -150,13 +150,13 @@ (/.install "clip" (trinary ..text//clip)) ))) -(def: (io//log! message) +(def (io//log! message) (Unary Expression) (_.begin (list (_.display/1 message) (_.display/1 (_.string text.new_line)) //runtime.unit))) -(def: io_procs +(def io_procs Bundle (<| (/.prefix "io") (|> /.empty @@ -164,7 +164,7 @@ (/.install "error" (unary _.raise/1)) ))) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "lux") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux index 862df2607..a3989de9f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/scheme/host.lux @@ -34,27 +34,27 @@ ["//[1]" /// ["[1][0]" phase]]]]]]) -(def: (array::new size) +(def (array::new size) (Unary Expression) (_.make_vector/2 size _.nil)) -(def: array::length +(def array::length (Unary Expression) _.vector_length/1) -(def: (array::read [indexG arrayG]) +(def (array::read [indexG arrayG]) (Binary Expression) (_.vector_ref/2 arrayG indexG)) -(def: (array::write [indexG valueG arrayG]) +(def (array::write [indexG valueG arrayG]) (Trinary Expression) (//runtime.array//write indexG valueG arrayG)) -(def: (array::delete [indexG arrayG]) +(def (array::delete [indexG arrayG]) (Binary Expression) (//runtime.array//write indexG _.nil arrayG)) -(def: array +(def array Bundle (<| (/.prefix "array") (|> /.empty @@ -66,13 +66,13 @@ ))) (with_template [<!> <?> <unit>] - [(def: <!> (Nullary Expression) (function.constant <unit>)) - (def: <?> (Unary Expression) (_.eq?/2 <unit>))] + [(def <!> (Nullary Expression) (function.constant <unit>)) + (def <?> (Unary Expression) (_.eq?/2 <unit>))] [object::nil object::nil? _.nil] ) -(def: object +(def object Bundle (<| (/.prefix "object") (|> /.empty @@ -80,7 +80,7 @@ (/.install "nil?" (unary object::nil?)) ))) -(def: scheme::constant +(def scheme::constant (custom [<s>.text (function (_ extension phase archive name) @@ -88,7 +88,7 @@ [] (in (_.var name))))])) -(def: scheme::apply +(def scheme::apply (custom [(all <>.and <s>.any (<>.some <s>.any)) (function (_ extension phase archive [abstractionS inputsS]) @@ -97,7 +97,7 @@ inputsG (monad.each ! (phase archive) inputsS)] (in (_.apply inputsG abstractionG))))])) -(def: .public bundle +(def .public bundle Bundle (<| (/.prefix "scheme") (|> /.empty diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/synthesis.lux index dbaa7282b..fcfa9b7ea 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/synthesis.lux @@ -6,6 +6,6 @@ [/// [synthesis (.only Bundle)]]]) -(def: .public bundle +(def .public bundle Bundle bundle.empty) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux index e016f9109..e31b13851 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp.lux @@ -25,7 +25,7 @@ [reference (.only) [variable (.only)]]]]]]]) -(def: .public (generate archive synthesis) +(def .public (generate archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux index 553bb6734..671b46045 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/case.lux @@ -37,15 +37,15 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public register +(def .public register (-> Register Var/1) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register Var/1) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueG (expression archive valueS) @@ -53,7 +53,7 @@ (in (_.let (list [(..register register) valueG]) (list bodyG))))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testG (expression archive testS) @@ -61,7 +61,7 @@ elseG (expression archive elseS)] (in (_.if testG thenG elseG)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueG (expression archive valueS)] @@ -76,38 +76,38 @@ valueG pathP)))) -(def: @savepoint (_.var "lux_pm_savepoint")) -(def: @cursor (_.var "lux_pm_cursor")) -(def: @temp (_.var "lux_pm_temp")) -(def: @variant (_.var "lux_pm_variant")) +(def @savepoint (_.var "lux_pm_savepoint")) +(def @cursor (_.var "lux_pm_cursor")) +(def @temp (_.var "lux_pm_temp")) +(def @variant (_.var "lux_pm_variant")) -(def: (push! value) +(def (push! value) (-> (Expression Any) (Expression Any)) (_.setq @cursor (_.cons/2 [value @cursor]))) -(def: pop! +(def pop! (Expression Any) (_.setq @cursor (_.cdr/1 @cursor))) -(def: peek +(def peek (Expression Any) (_.car/1 @cursor)) -(def: save! +(def save! (Expression Any) (_.setq @savepoint (_.cons/2 [@cursor @savepoint]))) -(def: restore! +(def restore! (List (Expression Any)) (list (_.setq @cursor (_.car/1 @savepoint)) (_.setq @savepoint (_.cdr/1 @savepoint)))) -(def: (multi_pop! pops) +(def (multi_pop! pops) (-> Nat (Expression Any)) (_.setq @cursor (_.nthcdr/2 [(_.int (.int pops)) @cursor]))) (with_template [<name> <flag> <prep>] - [(def: (<name> @fail simple? idx next!) + [(def (<name> @fail simple? idx next!) (-> _.Tag Bit Nat (Maybe (Expression Any)) (Expression Any)) (.let [<failure_condition> (_.eq/2 [@variant @temp])] (_.let (list [@variant ..peek]) @@ -129,7 +129,7 @@ [right_choice (_.string "") ++] ) -(def: (alternation @otherwise pre! post!) +(def (alternation @otherwise pre! post!) (-> _.Tag (Expression Any) (Expression Any) (Expression Any)) (_.tagbody (all list#composite (list ..save! @@ -138,7 +138,7 @@ ..restore! (list post!)))) -(def: (pattern_matching' expression archive) +(def (pattern_matching' expression archive) (Generator [Var/1 _.Tag _.Tag Path]) (function (again [$output @done @fail pathP]) (.case pathP @@ -230,7 +230,7 @@ post! (again [$output @done @fail postP])] (in (_.progn (list pre! post!))))))) -(def: (pattern_matching $output expression archive pathP) +(def (pattern_matching $output expression archive pathP) (-> Var/1 (Generator Path)) (do [! ///////phase.monad] [@done (at ! each (|>> %.nat (format "lux_case_done") _.tag) /////generation.next) @@ -242,7 +242,7 @@ (_.error/1 (_.string ////synthesis/case.pattern_matching_error)) @done))))) -(def: .public (case expression archive [valueS pathP]) +(def .public (case expression archive [valueS pathP]) (Generator [Synthesis Path]) (do [! ///////phase.monad] [initG (expression archive valueS) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension.lux index 90acc3cef..eac649c9c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension.lux @@ -9,6 +9,6 @@ [/ ["[0]" common]]) -(def: .public bundle +(def .public bundle Bundle common.bundle) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux index 36e3a4a95..e0e2a756d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/extension/common.lux @@ -23,26 +23,26 @@ [extension ["[0]" bundle]]]]]) -(def: lux_procs +(def lux_procs Bundle (|> bundle.empty (bundle.install "is" (binary (product.uncurried _.eq))) (bundle.install "try" (unary ///runtime.lux//try)))) -(def: (i64//left_shifted [paramG subjectG]) +(def (i64//left_shifted [paramG subjectG]) (Binary (Expression Any)) (_.ash (_.rem (_.int +64) paramG) subjectG)) -(def: (i64//arithmetic_right_shifted [paramG subjectG]) +(def (i64//arithmetic_right_shifted [paramG subjectG]) (Binary (Expression Any)) (_.ash (|> paramG (_.rem (_.int +64)) (_.* (_.int -1))) subjectG)) -(def: (i64//logic_right_shifted [paramG subjectG]) +(def (i64//logic_right_shifted [paramG subjectG]) (Binary (Expression Any)) (///runtime.i64//logic_right_shifted (_.rem (_.int +64) paramG) subjectG)) -(def: i64_procs +(def i64_procs Bundle (<| (bundle.prefix "i64") (|> bundle.empty @@ -64,7 +64,7 @@ (bundle.install "char" (unary (|>> _.code_char/1 _.string/1))) ))) -(def: f64_procs +(def f64_procs Bundle (<| (bundle.prefix "f64") (|> bundle.empty @@ -85,21 +85,21 @@ (///runtime.some @temp) ///runtime.none))))))))) -(def: (text//< [paramG subjectG]) +(def (text//< [paramG subjectG]) (Binary (Expression Any)) (|> (_.string< paramG subjectG) _.null/1 _.not/1)) -(def: (text//clip [paramO extraO subjectO]) +(def (text//clip [paramO extraO subjectO]) (Trinary (Expression Any)) (///runtime.text//clip subjectO paramO extraO)) -(def: (text//index [startO partO textO]) +(def (text//index [startO partO textO]) (Trinary (Expression Any)) (///runtime.text//index textO partO startO)) -(def: text_procs +(def text_procs Bundle (<| (bundle.prefix "text") (|> bundle.empty @@ -112,13 +112,13 @@ (bundle.install "clip" (trinary text//clip)) ))) -(def: (void code) +(def (void code) (-> (Expression Any) (Expression Any)) (all _.progn code ///runtime.unit)) -(def: io_procs +(def io_procs Bundle (<| (bundle.prefix "io") (|> bundle.empty @@ -126,7 +126,7 @@ (bundle.install "error" (unary _.error/1)) ))) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux index 29ed270dd..9029be0ed 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/function.lux @@ -29,18 +29,18 @@ [reference [variable (.only Register Variable)]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Application Synthesis)) (do [! ///////phase.monad] [functionG (expression archive functionS) argsG+ (monad.each ! (expression archive) argsS+)] (in (_.funcall/+ [functionG argsG+])))) -(def: capture +(def capture (-> Register Var/1) (|>> (///reference.foreign //reference.system) as_expected)) -(def: (with_closure inits function_definition) +(def (with_closure inits function_definition) (-> (List (Expression Any)) (Expression Any) (Operation (Expression Any))) (case inits {.#End} @@ -55,10 +55,10 @@ function_definition]]) (_.funcall/+ [(_.function/1 @closure) inits])))))) -(def: input +(def input (|>> ++ //case.register)) -(def: .public (function expression archive [environment arity bodyS]) +(def .public (function expression archive [environment arity bodyS]) (Generator (Abstraction Synthesis)) (do [! ///////phase.monad] [@scope (at ! each (|>> %.nat (format "function_scope") _.tag) /////generation.next) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux index 7d6e7a6e7..f71d3e18b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/loop.lux @@ -32,7 +32,7 @@ [reference [variable (.only Register)]]]]]]]) -(def: .public (scope expression archive [start initsS+ bodyS]) +(def .public (scope expression archive [start initsS+ bodyS]) (Generator (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -58,7 +58,7 @@ (_.setq @output bodyG))) @output)))))) -(def: .public (again expression archive argsS+) +(def .public (again expression archive argsS+) (Generator (List Synthesis)) (do [! ///////phase.monad] [[tag offset] /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/primitive.lux index 43a98c287..419179137 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/primitive.lux @@ -4,18 +4,18 @@ [target ["_" common_lisp (.only Expression)]]]]) -(def: .public bit +(def .public bit (-> Bit (Expression Any)) _.bool) -(def: .public i64 +(def .public i64 (-> (I64 Any) (Expression Any)) (|>> .int _.int)) -(def: .public f64 +(def .public f64 (-> Frac (Expression Any)) _.double) -(def: .public text +(def .public text (-> Text (Expression Any)) _.string) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/reference.lux index b64f9ecbb..7b2dcab79 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System (Expression Any)) (implementation - (def: constant _.var) - (def: variable _.var))) + (def constant _.var) + (def variable _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux index e5b54688c..a924fbe8f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/runtime.lux @@ -38,7 +38,7 @@ [archive (.only Output Archive) ["[0]" artifact (.only Registry)]]]]]]) -(def: module_id +(def module_id 0) (with_template [<name> <base>] @@ -54,40 +54,40 @@ (type: .public (Generator i) (-> Phase Archive i (Operation (Expression Any)))) -(def: .public unit +(def .public unit (_.string /////synthesis.unit)) -(def: (flag value) +(def (flag value) (-> Bit Literal) (if value (_.string "") _.nil)) -(def: (variant' tag last? value) +(def (variant' tag last? value) (-> (Expression Any) (Expression Any) (Expression Any) (Computation Any)) (_.list/* (list tag last? value))) -(def: .public (variant [lefts right? value]) +(def .public (variant [lefts right? value]) (-> (Variant (Expression Any)) (Computation Any)) (variant' (_.int (.int lefts)) (flag right?) value)) -(def: .public none +(def .public none (Computation Any) (|> ..unit [0 #0] ..variant)) -(def: .public some +(def .public some (-> (Expression Any) (Computation Any)) (|>> [1 #1] ..variant)) -(def: .public left +(def .public left (-> (Expression Any) (Computation Any)) (|>> [0 #0] ..variant)) -(def: .public right +(def .public right (-> (Expression Any) (Computation Any)) (|>> [1 #1] ..variant)) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -100,7 +100,7 @@ list.together))] (~ body)))))))) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -114,11 +114,11 @@ {.#Left name} (let [g!name (code.local name) code_nameC (code.local (format "@" name))] - (in (list (` (def: .public (~ g!name) + (in (list (` (def .public (~ g!name) _.Var/1 (~ runtime_name))) - (` (def: (~ code_nameC) + (` (def (~ code_nameC) (_.Expression Any) (_.defparameter (~ runtime_name) (~ code))))))) @@ -129,11 +129,11 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` (_.Expression Any))) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) (_.Computation Any)) (_.call/* (~ runtime_name) (list (~+ inputsC))))) - (` (def: (~ code_nameC) + (` (def (~ code_nameC) (_.Expression Any) (..with_vars [(~+ inputsC)] (_.defun (~ runtime_name) (_.args (list (~+ inputsC))) @@ -159,18 +159,18 @@ (list (_.reverse/1 inputs) ..none)])))) -(def: runtime//lux +(def runtime//lux (List (Expression Any)) (list @lux//try @lux//program_args)) -(def: last_index +(def last_index (|>> _.length/1 [(_.int +1)] _.-/2)) (with_expansions [<recur> (these (all _.then (_.; (_.set lefts (_.-/2 [last_index_right lefts]))) (_.; (_.set tuple (_.nth last_index_right tuple)))))] - (def: !recur + (def !recur (template (_ <side>) (<side> (_.-/2 [last_index_right lefts]) (_.elt/2 [tuple last_index_right])))) @@ -223,7 +223,7 @@ no_match!))))))) -(def: runtime//adt +(def runtime//adt (List (Expression Any)) (list @tuple//left @tuple//right @@ -240,7 +240,7 @@ [(_.*/2 [(_.int -1) shift])] _.ash/2 [mask] _.logand/2)))) -(def: runtime//i64 +(def runtime//i64 (List (Expression Any)) (list @i64//right_shifted)) @@ -254,7 +254,7 @@ (..some index) ..none))))) -(def: runtime//text +(def runtime//text (List (Expression Any)) (list @text//index @text//clip)) @@ -270,11 +270,11 @@ (_.call/* (_.var "excl:exit") (list code))) (_.call/* (_.var "cl-user::quit") (list code))))) -(def: runtime//io +(def runtime//io (List (Expression Any)) (list @io//exit)) -(def: runtime +(def runtime (_.progn (all list#composite runtime//adt runtime//lux @@ -282,7 +282,7 @@ runtime//text runtime//io))) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux index b14e852b1..05ed5efea 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/common_lisp/structure.lux @@ -14,7 +14,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple expression archive elemsS+) +(def .public (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -28,7 +28,7 @@ (monad.each ///////phase.monad (expression archive)) (///////phase#each _.vector/*)))) -(def: .public (variant expression archive [lefts right? valueS]) +(def .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux index 78d2d4295..680957008 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux @@ -21,17 +21,17 @@ [/// ["[1]" phase]]]]) -(def: Vector +(def Vector (syntax (_ [size <code>.nat elemT <code>.any]) (in (list (` [(~+ (list.repeated size elemT))]))))) -(def: Arity +(def Arity (template (_ arity) [(All (_ of) (-> (Vector arity of) of))])) -(def: arity +(def arity (syntax (_ [arity <code>.nat]) (with_symbols [g!_ g!extension g!name g!phase g!archive g!inputs g!anchor g!expression g!directive] (do [! meta.monad] @@ -58,7 +58,7 @@ (with_template [<arity> <type> <term>] [(type: .public <type> (Arity <arity>)) - (def: .public <term> (arity <arity>))] + (def .public <term> (arity <arity>))] [0 Nullary nullary] [1 Unary unary] @@ -69,7 +69,7 @@ (type: .public (Variadic of) (-> (List of) of)) -(def: .public (variadic extension) +(def .public (variadic extension) (All (_ anchor expression directive) (-> (Variadic expression) (generation.Handler anchor expression directive))) (function (_ extension_name) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux index a5471f9b6..5d6b92824 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js.lux @@ -34,7 +34,7 @@ (exception: .public cannot_recur_as_an_expression) -(def: (expression archive synthesis) +(def (expression archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] @@ -84,6 +84,6 @@ {synthesis.#Extension extension} (///extension.apply archive expression extension))) -(def: .public generate +(def .public generate Phase ..expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux index aa18b4348..2e48dea7c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/case.lux @@ -36,11 +36,11 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public register +(def .public register (-> Register Var) (|>> (///reference.local //reference.system) as_expected)) -(def: .public (exec expression archive [this that]) +(def .public (exec expression archive [this that]) (Generator [Synthesis Synthesis]) (do ///////phase.monad [this (expression archive this) @@ -48,7 +48,7 @@ (in (|> (_.array (list this that)) (_.at (_.int +1)))))) -(def: .public (exec! statement expression archive [this that]) +(def .public (exec! statement expression archive [this that]) (Generator! [Synthesis Synthesis]) (do ///////phase.monad [this (expression archive this) @@ -57,7 +57,7 @@ (_.statement this) that)))) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -67,7 +67,7 @@ (_.return bodyO)) (list valueO))))) -(def: .public (let! statement expression archive [valueS register bodyS]) +(def .public (let! statement expression archive [valueS register bodyS]) (Generator! [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -76,7 +76,7 @@ (_.define (..register register) valueO) bodyO)))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -84,7 +84,7 @@ elseO (expression archive elseS)] (in (_.? testO thenO elseO)))) -(def: .public (if! statement expression archive [testS thenS elseS]) +(def .public (if! statement expression archive [testS thenS elseS]) (Generator! [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -94,7 +94,7 @@ thenO elseO)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] @@ -106,51 +106,51 @@ valueO (list.reversed pathP))))) -(def: @savepoint (_.var "lux_pm_cursor_savepoint")) -(def: @cursor (_.var "lux_pm_cursor")) -(def: @temp (_.var "lux_pm_temp")) +(def @savepoint (_.var "lux_pm_cursor_savepoint")) +(def @cursor (_.var "lux_pm_cursor")) +(def @temp (_.var "lux_pm_temp")) -(def: (push_cursor! value) +(def (push_cursor! value) (-> Expression Statement) (_.statement (|> @cursor (_.do "push" (list value))))) -(def: peek_and_pop_cursor +(def peek_and_pop_cursor Expression (|> @cursor (_.do "pop" (list)))) -(def: pop_cursor! +(def pop_cursor! Statement (_.statement ..peek_and_pop_cursor)) -(def: length +(def length (|>> (_.the "length"))) -(def: last_index +(def last_index (|>> ..length (_.- (_.i32 +1)))) -(def: peek_cursor +(def peek_cursor Expression (|> @cursor (_.at (last_index @cursor)))) -(def: save_cursor! +(def save_cursor! Statement (.let [cursor (|> @cursor (_.do "slice" (list)))] (_.statement (|> @savepoint (_.do "push" (list cursor)))))) -(def: restore_cursor! +(def restore_cursor! Statement (_.set @cursor (|> @savepoint (_.do "pop" (list))))) -(def: fail_pm! _.break) +(def fail_pm! _.break) -(def: (multi_pop_cursor! pops) +(def (multi_pop_cursor! pops) (-> Nat Statement) (.let [popsJS (_.i32 (.int pops))] (_.statement (|> @cursor (_.do "splice" (list (|> @cursor ..length (_.- popsJS)) popsJS)))))) (with_template [<name> <flag>] - [(def: (<name> simple? idx) + [(def (<name> simple? idx) (-> Bit Nat Statement) (all _.then (_.set @temp (//runtime.sum//get ..peek_cursor <flag> @@ -166,7 +166,7 @@ [right_choice //runtime.unit] ) -(def: (alternation pre! post!) +(def (alternation pre! post!) (-> Statement Statement Statement) (all _.then (_.do_while (_.boolean false) @@ -177,7 +177,7 @@ ..restore_cursor! post!))) -(def: (optimized_pattern_matching again pathP) +(def (optimized_pattern_matching again pathP) (-> (-> Path (Operation Statement)) (-> Path (Operation (Maybe Statement)))) (.case pathP @@ -233,7 +233,7 @@ _ (///////phase#in {.#None}))) -(def: (pattern_matching' statement expression archive) +(def (pattern_matching' statement expression archive) (-> Phase! Phase Archive (-> Path (Operation Statement))) (function (again pathP) @@ -318,7 +318,7 @@ ([/////synthesis.path/seq _.then] [/////synthesis.path/alt ..alternation])))))) -(def: (pattern_matching statement expression archive pathP) +(def (pattern_matching statement expression archive pathP) (-> Phase! Phase Archive Path (Operation Statement)) (do ///////phase.monad [pattern_matching! (pattern_matching' statement expression archive pathP)] @@ -327,7 +327,7 @@ pattern_matching!) (_.throw (_.string ////synthesis/case.pattern_matching_error)))))) -(def: .public (case! statement expression archive [valueS pathP]) +(def .public (case! statement expression archive [valueS pathP]) (Generator! [Synthesis Path]) (do ///////phase.monad [stack_init (expression archive valueS) @@ -338,7 +338,7 @@ (_.define @savepoint (_.array (list))) pattern_matching!)))) -(def: .public (case statement expression archive [valueS pathP]) +(def .public (case statement expression archive [valueS pathP]) (-> Phase! (Generator [Synthesis Path])) (do ///////phase.monad [pattern_matching! (..case! statement expression archive [valueS pathP])] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux index 58b0e104a..c7c5226ac 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/function.lux @@ -33,18 +33,18 @@ [dependency ["[1]" artifact]]]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Reification Synthesis)) (do [! ///////phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply functionO argsO+)))) -(def: capture +(def capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: (with_closure @self inits body!) +(def (with_closure @self inits body!) (-> Var (List Expression) Statement [Statement Expression]) (case inits {.#End} @@ -58,20 +58,20 @@ (_.return (_.function @self (list) body!))) (_.apply @self inits)])) -(def: @curried +(def @curried (_.var "curried")) -(def: input +(def input (|>> ++ //case.register)) -(def: @@arguments +(def @@arguments (_.var "arguments")) -(def: (@scope function_name) +(def (@scope function_name) (-> unit.ID Text) (format (///reference.artifact function_name) "_scope")) -(def: .public (function statement expression archive [environment arity bodyS]) +(def .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Generator (Abstraction Synthesis))) (do [! ///////phase.monad] [dependencies (cache.dependencies archive bodyS) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux index de5ee0616..eb9d60063 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/loop.lux @@ -25,15 +25,15 @@ [reference [variable (.only Register)]]]]]) -(def: @scope +(def @scope (-> Nat Text) (|>> %.nat (format "scope"))) -(def: $iteration +(def $iteration (-> Nat Var) (|>> %.nat (format "iteration") _.var)) -(def: (setup $iteration initial? offset bindings body) +(def (setup $iteration initial? offset bindings body) (-> Var Bit Register (List Expression) Statement Statement) (case bindings (pattern (list)) @@ -60,7 +60,7 @@ (list#mix _.then body) (_.then (_.define $iteration (_.array bindings)))))) -(def: .public (scope! statement expression archive [start initsS+ bodyS]) +(def .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -82,7 +82,7 @@ (_.do_while (_.boolean true) body!))))))) -(def: .public (scope statement expression archive [start initsS+ bodyS]) +(def .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop @@ -95,10 +95,10 @@ [loop! (scope! statement expression archive [start initsS+ bodyS])] (in (_.apply (_.closure (list) loop!) (list)))))) -(def: @temp +(def @temp (_.var "lux_again_values")) -(def: .public (again! statement expression archive argsS+) +(def .public (again! statement expression archive argsS+) (Generator! (List Synthesis)) (do [! ///////phase.monad] [[offset @scope] /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/primitive.lux index aa45d7b64..19dd18af2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/primitive.lux @@ -6,16 +6,16 @@ ["[0]" // ["[1][0]" runtime]]) -(def: .public bit +(def .public bit _.boolean) -(def: .public (i64 value) +(def .public (i64 value) (-> (I64 Any) Computation) (//runtime.i64 (|> value //runtime.high .int _.i32) (|> value //runtime.low .int _.i32))) -(def: .public f64 +(def .public f64 _.number) -(def: .public text +(def .public text _.string) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux index 8a042db48..6cca81aeb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System Expression) (implementation - (def: constant' _.var) - (def: variable' _.var))) + (def constant' _.var) + (def variable' _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux index 0bda3304e..41da758da 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/runtime.lux @@ -58,30 +58,30 @@ (type: .public (Generator! i) (-> Phase! Phase Archive i (Operation Statement))) -(def: .public high +(def .public high (-> (I64 Any) (I64 Any)) (i64.right_shifted 32)) -(def: .public low +(def .public low (-> (I64 Any) (I64 Any)) (let [mask (-- (i64.left_shifted 32 1))] (|>> (i64.and mask)))) -(def: .public unit +(def .public unit Computation (_.string /////synthesis.unit)) -(def: .public (flag value) +(def .public (flag value) (-> Bit Computation) (if value (_.string "") _.null)) -(def: (feature name definition) +(def (feature name definition) (-> Var (-> Var Expression) Statement) (_.define name (definition name))) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -94,7 +94,7 @@ list.together))] (~ body)))))))) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -104,11 +104,11 @@ (case declaration {.#Left name} (let [g!name (code.local name)] - (in (list (` (def: .public (~ g!name) + (in (list (` (def .public (~ g!name) Var (~ runtime_name))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..feature (~ runtime_name) (function ((~ g!_) (~ g!name)) @@ -118,11 +118,11 @@ (let [g!name (code.local name) inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` _.Expression)) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply (~ runtime_name) (list (~+ inputsC))))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..feature (~ runtime_name) (function ((~ g!_) (~ g!_)) @@ -130,15 +130,15 @@ (_.function (~ g!_) (list (~+ inputsC)) (~ code))))))))))))))) -(def: length +(def length (-> Expression Computation) (_.the "length")) -(def: last_index +(def last_index (-> Expression Computation) (|>> ..length (_.- (_.i32 +1)))) -(def: (last_element tuple) +(def (last_element tuple) (_.at (..last_index tuple) tuple)) @@ -170,9 +170,9 @@ (_.return (_.do "slice" (list right_index) tuple))) ))))) -(def: .public variant_tag_field "_lux_tag") -(def: .public variant_flag_field "_lux_flag") -(def: .public variant_value_field "_lux_value") +(def .public variant_tag_field "_lux_tag") +(def .public variant_flag_field "_lux_flag") +(def .public variant_value_field "_lux_value") (runtime: variant//new (let [@this (_.var "this")] @@ -184,7 +184,7 @@ (_.set (_.the ..variant_value_field @this) value) ))))) -(def: .public (variant tag last? value) +(def .public (variant tag last? value) (-> Expression Expression Expression Computation) (_.new ..variant//new (list tag last? value))) @@ -216,23 +216,23 @@ actual::value))) mismatch!))) -(def: left +(def left (-> Expression Computation) (..variant (_.i32 +0) (flag #0))) -(def: right +(def right (-> Expression Computation) (..variant (_.i32 +0) (flag #1))) -(def: none +(def none Computation (..left ..unit)) -(def: some +(def some (-> Expression Computation) ..right) -(def: runtime//structure +(def runtime//structure Statement (all _.then @tuple//left @@ -258,15 +258,15 @@ output))))) (_.return output)))) -(def: runtime//lux +(def runtime//lux Statement (all _.then @lux//try @lux//program_args )) -(def: .public i64_low_field Text "_lux_low") -(def: .public i64_high_field Text "_lux_high") +(def .public i64_low_field Text "_lux_low") +(def .public i64_high_field Text "_lux_high") (runtime: i64::new (let [@this (_.var "this")] @@ -277,7 +277,7 @@ (_.set (_.the ..i64_low_field @this) low) ))))) -(def: .public (i64 high low) +(def .public (i64 high low) (-> Expression Expression Computation) (_.new ..i64::new (list high low))) @@ -297,16 +297,16 @@ (_.return (..i64 (_.bit_not (_.the ..i64_high_field value)) (_.bit_not (_.the ..i64_low_field value))))) -(def: (cap_shift! shift) +(def (cap_shift! shift) (-> Var Statement) (_.set shift (|> shift (_.bit_and (_.i32 +63))))) -(def: (no_shift! shift input) +(def (no_shift! shift input) (-> Var Var (-> Expression Expression)) (_.? (|> shift (_.= (_.i32 +0))) input)) -(def: small_shift? +(def small_shift? (-> Var Expression) (|>> (_.< (_.i32 +32)))) @@ -352,7 +352,7 @@ (..i64 (_.i32 +0) (|> input (_.the ..i64_high_field) (_.logic_right_shift (_.- (_.i32 +32) shift)))))))) -(def: runtime//bit +(def runtime//bit Statement (all _.then @i64::and @@ -536,12 +536,12 @@ (negative? (i64::- parameter subject)))) )))) -(def: (i64::<= param subject) +(def (i64::<= param subject) (-> Expression Expression Expression) (|> (i64::< param subject) (_.or (i64::= param subject)))) -(def: negative? +(def negative? (i64::< i64::zero)) (runtime: (i64::/ parameter subject) @@ -626,7 +626,7 @@ (i64::* parameter))] (_.return (i64::- flat subject)))) -(def: runtime//i64 +(def runtime//i64 Statement (all _.then ..runtime//bit @@ -675,7 +675,7 @@ (_.throw (_.string "[Lux Error] Cannot get char from text.")) (_.return (i64::of_number result)))))) -(def: runtime//text +(def runtime//text Statement (all _.then @text//index @@ -704,7 +704,7 @@ (runtime: (io//error message) (_.throw message)) -(def: runtime//io +(def runtime//io Statement (all _.then @io//log @@ -729,7 +729,7 @@ (_.statement (_.delete (_.at field object))) (_.return object))) -(def: runtime//js +(def runtime//js Statement (all _.then @js//get @@ -747,14 +747,14 @@ (_.statement (_.delete (_.at (_.the ..i64_low_field idx) array))) (_.return array))) -(def: runtime//array +(def runtime//array Statement (all _.then @array//write @array//delete )) -(def: runtime +(def runtime Statement (all _.then runtime//structure @@ -766,10 +766,10 @@ runtime//lux )) -(def: module_id +(def module_id 0) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux index 14e911912..9fdbc4592 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/js/structure.lux @@ -15,7 +15,7 @@ ["//[1]" /// (.only) ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple generate archive elemsS+) +(def .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -29,7 +29,7 @@ [elemsT+ (monad.each ! (generate archive) elemsS+)] (in (_.array elemsT+))))) -(def: .public (variant generate archive [lefts right? valueS]) +(def .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (///////phase#each (//runtime.variant (_.i32 (.int lefts)) (//runtime.flag right?)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux index a23f31e36..0a8c1c026 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm.lux @@ -21,7 +21,7 @@ ["[0]" reference] ["[1]" phase (.open: "[1]#[0]" monad)]]]]]) -(def: .public (generate archive synthesis) +(def .public (generate archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux index 73ec8260e..0ae4da146 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/case.lux @@ -39,7 +39,7 @@ [reference [variable (.only Register)]]]]]) -(def: (pop_alt stack_depth) +(def (pop_alt stack_depth) (-> Nat (Bytecode Any)) (.case stack_depth 0 (_#in []) @@ -50,27 +50,27 @@ _.pop2 (pop_alt (n.- 2 stack_depth))))) -(def: int +(def int (-> (I64 Any) (Bytecode Any)) (|>> .i64 i32.i32 _.int)) -(def: long +(def long (-> (I64 Any) (Bytecode Any)) (|>> .int _.long)) -(def: peek +(def peek (Bytecode Any) (all _.composite _.dup (//runtime.get //runtime.stack_head))) -(def: pop +(def pop (Bytecode Any) (all _.composite (//runtime.get //runtime.stack_tail) (_.checkcast //type.stack))) -(def: (left_projection lefts) +(def (left_projection lefts) (-> Nat (Bytecode Any)) (all _.composite (_.checkcast //type.tuple) @@ -82,25 +82,25 @@ lefts //runtime.left_projection))) -(def: (right_projection lefts) +(def (right_projection lefts) (-> Nat (Bytecode Any)) (all _.composite (_.checkcast //type.tuple) (..int lefts) //runtime.right_projection)) -(def: equals@Object +(def equals@Object (.let [class (type.class "java.lang.Object" (list)) method (type.method [(list) (list //type.value) type.boolean (list)])] (_.invokevirtual class "equals" method))) -(def: (path|bind register) +(def (path|bind register) (-> Register (Operation (Bytecode Any))) (operation#in (all _.composite ..peek (_.astore register)))) -(def: (path|bit_fork again @else [when thenP elseP]) +(def (path|bit_fork again @else [when thenP elseP]) (-> (-> Path (Operation (Bytecode Any))) Label [Bit Path (Maybe Path)] (Operation (Bytecode Any))) @@ -124,7 +124,7 @@ else!))))) (with_template [<name> <type> <unwrap> <dup> <pop> <test> <comparison> <if>] - [(def: (<name> again @else cons) + [(def (<name> again @else cons) (-> (-> Path (Operation (Bytecode Any))) Label (Fork <type> Path) (Operation (Bytecode Any))) @@ -157,7 +157,7 @@ [path|text_fork Text (at _.monad in []) _.dup _.pop _.string ..equals@Object _.ifeq] ) -(def: (path' stack_depth @else @end phase archive) +(def (path' stack_depth @else @end phase archive) (-> Nat Label Label (Generator Path)) (function (again path) (.case path @@ -242,7 +242,7 @@ right!))) ))) -(def: (path @end phase archive path) +(def (path @end phase archive path) (-> Label (Generator Path)) (do phase.monad [@else //runtime.forge_label @@ -257,7 +257,7 @@ )) )))) -(def: .public (if phase archive [testS thenS elseS]) +(def .public (if phase archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do phase.monad [test! (phase archive testS) @@ -277,7 +277,7 @@ (<| (_.when_acknowledged @end) (_.set_label @end))))))) -(def: .public (exec phase archive [this that]) +(def .public (exec phase archive [this that]) (Generator [Synthesis Synthesis]) (do phase.monad [this! (phase archive this) @@ -287,7 +287,7 @@ _.pop that!)))) -(def: .public (let phase archive [inputS register bodyS]) +(def .public (let phase archive [inputS register bodyS]) (Generator [Synthesis Register Synthesis]) (do phase.monad [input! (phase archive inputS) @@ -297,7 +297,7 @@ (_.astore register) body!)))) -(def: .public (get phase archive [path recordS]) +(def .public (get phase archive [path recordS]) (Generator [(List Member) Synthesis]) (do phase.monad [record! (phase archive recordS)] @@ -311,7 +311,7 @@ record! (list.reversed path))))) -(def: .public (case phase archive [valueS path]) +(def .public (case phase archive [valueS path]) (Generator [Synthesis Path]) (do phase.monad [@end //runtime.forge_label diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux index f86e61b14..5f07e5300 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/debug.lux @@ -13,9 +13,9 @@ [world ["[0]" file (.only File)]]]]) -(def: extension ".class") +(def extension ".class") -(def: .public (write_class! name bytecode) +(def .public (write_class! name bytecode) (-> Text Binary (IO Text)) (let [file_path (format name ..extension)] (do io.monad diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux index a87be42cc..a4147be81 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function.lux @@ -67,7 +67,7 @@ [reference [variable (.only Register)]]]]]]) -(def: .public (with generate archive @begin class environment arity body) +(def .public (with generate archive @begin class environment arity body) (-> Phase Archive Label External (Environment Synthesis) Arity (Bytecode Any) (Operation [(List (Resource Field)) (List (Resource Method)) @@ -90,21 +90,21 @@ [instance (/new.instance generate archive classT environment arity)] (in [fields methods instance])))) -(def: modifier +(def modifier (Modifier Class) (all modifier#composite class.public class.final)) -(def: this_offset 1) +(def this_offset 1) -(def: internal +(def internal (All (_ category) (-> (Type (<| Return' Value' category)) Internal)) (|>> type.reflection reflection.reflection name.internal)) -(def: .public (abstraction generate archive [environment arity bodyS]) +(def .public (abstraction generate archive [environment arity bodyS]) (Generator Abstraction) (do phase.monad [dependencies (cache/artifact.dependencies archive bodyS) @@ -127,7 +127,7 @@ _ (generation.save! (product.right function_context) {.#None} bytecode)] (in instance))) -(def: (apply/?' generate archive [abstractionG inputsS]) +(def (apply/?' generate archive [abstractionG inputsS]) (Generator [(Bytecode Any) (List Synthesis)]) (do [! phase.monad] [inputsG (monad.each ! (generate archive) inputsS)] @@ -144,13 +144,13 @@ )))) )))) -(def: (apply/? generate archive [abstractionS inputsS]) +(def (apply/? generate archive [abstractionS inputsS]) (Generator Apply) (do [! phase.monad] [abstractionG (generate archive abstractionS)] (apply/?' generate archive [abstractionG inputsS]))) -(def: (apply/= generate archive [$abstraction @abstraction arity inputsS]) +(def (apply/= generate archive [$abstraction @abstraction arity inputsS]) (Generator [Symbol unit.ID Arity (List Synthesis)]) (do [! phase.monad] [.let [:abstraction: (type.class (//runtime.class_name @abstraction) (list))] @@ -162,13 +162,13 @@ (/implementation.call :abstraction: arity) )))) -(def: (apply/> generate archive [$abstraction @abstraction arity inputsS]) +(def (apply/> generate archive [$abstraction @abstraction arity inputsS]) (Generator [Symbol unit.ID Arity (List Synthesis)]) (do [! phase.monad] [=G (apply/= generate archive [$abstraction @abstraction arity (list.first arity inputsS)])] (apply/?' generate archive [=G (list.after arity inputsS)]))) -(def: .public (apply generate archive [abstractionS inputsS]) +(def .public (apply generate archive [abstractionS inputsS]) (Generator Apply) (case abstractionS (pattern (synthesis.constant $abstraction)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/abstract.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/abstract.lux index feebb5be2..cf462455e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/abstract.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/abstract.lux @@ -13,13 +13,13 @@ [constant ["[0]" arity]]]]) -... (def: .public artifact_id +... (def .public artifact_id ... 1) -(def: .public class +(def .public class ... (type.class (%.nat artifact_id) (list)) (type.class "library.lux.Function" (list))) -(def: .public init +(def .public init (Type Method) (type.method [(list) (list arity.type) type.void (list)])) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux index 4aea4dc4f..dcbaef747 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant.lux @@ -13,7 +13,7 @@ [constant [pool (.only Resource)]]]]]]) -(def: modifier +(def modifier (Modifier Field) (all modifier#composite field.public @@ -21,6 +21,6 @@ field.final )) -(def: .public (constant name type) +(def .public (constant name type) (-> Text (Type Value) (Resource Field)) (field.field ..modifier name #0 type (sequence.sequence))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant/arity.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant/arity.lux index 1edd1ce40..3892b9ef0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant/arity.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/constant/arity.lux @@ -10,7 +10,7 @@ [///////// [arity (.only Arity)]]]) -(def: .public minimum Arity 1) -(def: .public maximum Arity 8) +(def .public minimum Arity 1) +(def .public maximum Arity 8) -(def: .public type type.int) +(def .public type type.int) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux index 737c6ac4b..0ae3854a7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable.lux @@ -21,34 +21,34 @@ [reference [variable (.only Register)]]]]) -(def: .public type ////type.value) +(def .public type ////type.value) -(def: .public (get class name) +(def .public (get class name) (-> (Type Class) Text (Bytecode Any)) (all _.composite ////reference.this (_.getfield class name ..type) )) -(def: .public (put naming class register value) +(def .public (put naming class register value) (-> (-> Register Text) (Type Class) Register (Bytecode Any) (Bytecode Any)) (all _.composite ////reference.this value (_.putfield class (naming register) ..type))) -(def: modifier +(def modifier (Modifier Field) (all modifier#composite field.private field.final )) -(def: .public (variable name type) +(def .public (variable name type) (-> Text (Type Value) (Resource Field)) (field.field ..modifier name #0 type (sequence.sequence))) -(def: .public (variables naming amount) +(def .public (variables naming amount) (-> (-> Register Text) Nat (List (Resource Field))) (|> amount list.indices diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/count.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/count.lux index 90f8426d7..e84776579 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/count.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/count.lux @@ -13,20 +13,20 @@ ["[0]" //// ["[1][0]" abstract]]) -(def: .public field "partials") -(def: .public type type.int) +(def .public field "partials") +(def .public type type.int) -(def: .public initial +(def .public initial (Bytecode Any) (|> +0 signed.s1 try.trusted _.bipush)) -(def: this +(def this _.aload_0) -(def: .public value +(def .public value (Bytecode Any) (all _.composite ..this diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux index 545cf8396..f403f723c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/foreign.lux @@ -22,18 +22,18 @@ [reference [variable (.only Register)]]]]]]) -(def: .public (closure environment) +(def .public (closure environment) (-> (Environment Synthesis) (List (Type Value))) (list.repeated (list.size environment) //.type)) -(def: .public (get class register) +(def .public (get class register) (-> (Type Class) Register (Bytecode Any)) (//.get class (/////reference.foreign_name register))) -(def: .public (put class register value) +(def .public (put class register value) (-> (Type Class) Register (Bytecode Any) (Bytecode Any)) (//.put /////reference.foreign_name class register value)) -(def: .public variables +(def .public variables (-> (Environment Synthesis) (List (Resource Field))) (|>> list.size (//.variables /////reference.foreign_name))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux index 1684e6f8c..36d83b0f1 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial.lux @@ -29,7 +29,7 @@ [reference [variable (.only Register)]]]]]]) -(def: .public (initial amount) +(def .public (initial amount) (-> Nat (Bytecode Any)) (all _.composite (|> _.aconst_null @@ -37,19 +37,19 @@ (monad.all _.monad)) (_#in []))) -(def: .public (get class register) +(def .public (get class register) (-> (Type Class) Register (Bytecode Any)) (//.get class (/////reference.partial_name register))) -(def: .public (put class register value) +(def .public (put class register value) (-> (Type Class) Register (Bytecode Any) (Bytecode Any)) (//.put /////reference.partial_name class register value)) -(def: .public variables +(def .public variables (-> Arity (List (Resource Field))) (|>> (n.- ///arity.minimum) (//.variables /////reference.partial_name))) -(def: .public (new arity) +(def .public (new arity) (-> Arity (Bytecode Any)) (if (arity.multiary? arity) (all _.composite diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux index 1301e055c..3e8e0e065 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method.lux @@ -6,7 +6,7 @@ ["[0]" modifier (.only Modifier) (.open: "[1]#[0]" monoid)] ["[0]" method (.only Method)]]]]]) -(def: .public modifier +(def .public modifier (Modifier Method) (all modifier#composite method.public diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux index 69e7d5332..8b03c7ae8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/apply.lux @@ -48,13 +48,13 @@ [reference [variable (.only Register)]]]]]]]) -(def: (increment by) +(def (increment by) (-> Nat (Bytecode Any)) (all _.composite (<| _.int .i64 by) _.iadd)) -(def: (inputs offset amount) +(def (inputs offset amount) (-> Register Nat (Bytecode Any)) (all _.composite (|> amount @@ -63,7 +63,7 @@ (_#in []) )) -(def: (apply offset amount) +(def (apply offset amount) (-> Register Nat (Bytecode Any)) (let [arity (n.min amount ///arity.maximum)] (all _.composite @@ -76,9 +76,9 @@ (_#in [])) ))) -(def: this_offset 1) +(def this_offset 1) -(def: .public (method class environment function_arity @begin body apply_arity) +(def .public (method class environment function_arity @begin body apply_arity) (-> (Type Class) (Environment Synthesis) Arity Label (Bytecode Any) Arity (Resource Method)) (let [num_partials (-- function_arity) over_extent (i.- (.int apply_arity) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux index 5554117e6..84ad5a397 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/implementation.lux @@ -26,22 +26,22 @@ [archive ["[0]" unit]]]]]]) -(def: .public name "impl") +(def .public name "impl") -(def: .public (type :it: arity) +(def .public (type :it: arity) (-> (Type Class) Arity (Type category.Method)) (type.method [(list) (list.partial :it: (list.repeated arity ////type.value)) ////type.value (list)])) -(def: modifier +(def modifier (all modifier#composite method.static //.modifier )) -(def: .public (method :it: arity @begin body) +(def .public (method :it: arity @begin body) (-> (Type Class) Arity Label (Bytecode Any) (Resource Method)) (method.method ..modifier ..name @@ -53,6 +53,6 @@ (_.when_continuous _.areturn) )})) -(def: .public (call :it: arity) +(def .public (call :it: arity) (-> (Type Class) Arity (Bytecode Any)) (_.invokestatic :it: ..name (..type :it: arity))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux index c3cea9bf2..934e7c561 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/init.lux @@ -42,13 +42,13 @@ [reference [variable (.only Register)]]]]]]]) -(def: .public name "<init>") +(def .public name "<init>") -(def: (partials arity) +(def (partials arity) (-> Arity (List (Type Value))) (list.repeated (-- arity) ////type.value)) -(def: .public (type environment arity) +(def .public (type environment arity) (-> (Environment Synthesis) Arity (Type category.Method)) (type.method [(list) (list#composite (///foreign.closure environment) @@ -58,13 +58,13 @@ type.void (list)])) -(def: no_partials +(def no_partials (|> +0 signed.s1 try.trusted _.bipush)) -(def: .public (super environment_size arity) +(def .public (super environment_size arity) (-> Nat Arity (Bytecode Any)) (let [arity_register (++ environment_size)] (all _.composite @@ -73,7 +73,7 @@ (_.iload arity_register)) (_.invokespecial ///abstract.class ..name ///abstract.init)))) -(def: (store_all amount put offset) +(def (store_all amount put offset) (-> Nat (-> Register (Bytecode Any) (Bytecode Any)) (-> Register Register) @@ -84,7 +84,7 @@ (_.aload (offset register))))) (monad.all _.monad))) -(def: .public (method class environment arity) +(def .public (method class environment arity) (-> (Type Class) (Environment Synthesis) Arity (Resource Method)) (let [environment_size (list.size environment) offset_foreign (is (-> Register Register) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux index b9b1e99a8..7cfe7943e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/new.lux @@ -43,7 +43,7 @@ ["[0]" arity (.only Arity)] ["[0]" phase]]]]]]) -(def: .public (instance' foreign_setup class environment arity) +(def .public (instance' foreign_setup class environment arity) (-> (List (Bytecode Any)) (Type Class) (Environment Synthesis) Arity (Bytecode Any)) (all _.composite (_.new class) @@ -52,13 +52,13 @@ (///partial.new arity) (_.invokespecial class //init.name (//init.type environment arity)))) -(def: .public (instance generate archive class environment arity) +(def .public (instance generate archive class environment arity) (-> Phase Archive (Type Class) (Environment Synthesis) Arity (Operation (Bytecode Any))) (do [! phase.monad] [foreign* (monad.each ! (generate archive) environment)] (in (instance' foreign* class environment arity)))) -(def: .public (method class environment arity) +(def .public (method class environment arity) (-> (Type Class) (Environment Synthesis) Arity (Resource Method)) (let [after_this (is (-> Nat Nat) (n.+ 1)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux index 51ceaf844..16909a692 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/method/reset.lux @@ -26,19 +26,19 @@ [/// ["[0]" arity (.only Arity)]]]]]]) -(def: .public name "reset") +(def .public name "reset") -(def: .public (type class) +(def .public (type class) (-> (Type Class) (Type category.Method)) (type.method [(list) (list) class (list)])) -(def: (current_environment class) +(def (current_environment class) (-> (Type Class) (Environment Synthesis) (List (Bytecode Any))) (|>> list.size list.indices (list#each (///foreign.get class)))) -(def: .public (method class environment arity) +(def .public (method class environment arity) (-> (Type Class) (Environment Synthesis) Arity (Resource Method)) (method.method //.modifier ..name #0 (..type class) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux index eb8478a41..2196d5c3e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux @@ -61,10 +61,10 @@ (import java/lang/ClassLoader "[1]::[0]") -(def: value::modifier (all modifier#composite field.public field.final field.static)) +(def value::modifier (all modifier#composite field.public field.final field.static)) -(def: init::type (type.method [(list) (list) type.void (list)])) -(def: init::modifier (all modifier#composite method.public method.static method.strict)) +(def init::type (type.method [(list) (list) type.void (list)])) +(def init::modifier (all modifier#composite method.public method.static method.strict)) (exception: .public (cannot_load [class Text error Text]) @@ -84,7 +84,7 @@ (exception.report "Class" class)) -(def: (class_value class_name class) +(def (class_value class_name class) (-> Text (java/lang/Class java/lang/Object) (Try Any)) (case (java/lang/Class::getField //value.field class) {try.#Success field} @@ -103,10 +103,10 @@ {try.#Failure error} (exception.except ..invalid_field [class_name //value.field error]))) -(def: class_path_separator +(def class_path_separator ".") -(def: (evaluate! library loader eval_class [@it valueG]) +(def (evaluate! library loader eval_class [@it valueG]) (-> Library java/lang/ClassLoader Text [(Maybe unit.ID) (Bytecode Any)] (Try [Any Definition])) (let [bytecode_name (text.replaced class_path_separator .module_separator eval_class) :value: (case @it @@ -139,7 +139,7 @@ (in [value [eval_class bytecode]]))))) -(def: (execute! library loader [class_name class_bytecode]) +(def (execute! library loader [class_name class_bytecode]) (-> Library java/lang/ClassLoader Definition (Try Any)) (io.run! (do (try.with io.monad) [existing_class? (|> (atom.read! library) @@ -152,7 +152,7 @@ (loader.store class_name class_bytecode library))] (loader.load class_name loader)))) -(def: (define! library loader context custom @it,valueG) +(def (define! library loader context custom @it,valueG) (-> Library java/lang/ClassLoader unit.ID (Maybe Text) [(Maybe unit.ID) (Bytecode Any)] (Try [Text Any Definition])) (let [class_name (maybe.else (//runtime.class_name context) custom)] @@ -160,30 +160,30 @@ [[value definition] (evaluate! library loader class_name @it,valueG)] (in [class_name value definition])))) -(def: .public host +(def .public host (IO [java/lang/ClassLoader //runtime.Host]) (io (let [library (loader.new_library []) loader (loader.memory library)] [loader (is //runtime.Host (implementation - (def: (evaluate context @it,valueG) + (def (evaluate context @it,valueG) (at try.monad each product.left (..evaluate! library loader (format "E" (//runtime.class_name context)) @it,valueG))) - (def: execute + (def execute (..execute! library loader)) - (def: define + (def define (..define! library loader)) - (def: (ingest context bytecode) + (def (ingest context bytecode) [(//runtime.class_name context) bytecode]) - (def: (re_learn context custom [_ bytecode]) + (def (re_learn context custom [_ bytecode]) (io.run! (loader.store (maybe.else (//runtime.class_name context) custom) bytecode library))) - (def: (re_load context custom [directive_name bytecode]) + (def (re_load context custom [directive_name bytecode]) (io.run! (do (try.with io.monad) [.let [class_name (maybe.else (//runtime.class_name context) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux index f06d37da3..741098438 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/loop.lux @@ -26,7 +26,7 @@ [reference [variable (.only Register)]]]]]) -(def: (invariant? register changeS) +(def (invariant? register changeS) (-> Register Synthesis Bit) (case changeS (pattern (synthesis.variable/local var)) @@ -35,10 +35,10 @@ _ false)) -(def: no_op +(def no_op (_#in [])) -(def: .public (again translate archive updatesS) +(def .public (again translate archive updatesS) (Generator (List Synthesis)) (do [! phase.monad] [[@begin offset] generation.anchor @@ -72,7 +72,7 @@ (monad.all _.monad)) (_.goto @begin))))) -(def: .public (scope translate archive [offset initsS+ iterationS]) +(def .public (scope translate archive [offset initsS+ iterationS]) (Generator [Nat (List Synthesis) Synthesis]) (do [! phase.monad] [@begin //runtime.forge_label diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux index 90c3044ae..772482ec8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/primitive.lux @@ -20,18 +20,18 @@ ["[0]" // ["[1][0]" runtime]]) -(def: $Boolean (type.class "java.lang.Boolean" (list))) -(def: $Long (type.class "java.lang.Long" (list))) -(def: $Double (type.class "java.lang.Double" (list))) +(def $Boolean (type.class "java.lang.Boolean" (list))) +(def $Long (type.class "java.lang.Long" (list))) +(def $Double (type.class "java.lang.Double" (list))) -(def: .public (bit value) +(def .public (bit value) (-> Bit (Bytecode Any)) (_.getstatic $Boolean (if value "TRUE" "FALSE") $Boolean)) -(def: wrap_i64 +(def wrap_i64 (_.invokestatic $Long "valueOf" (type.method [(list) (list type.long) $Long (list)]))) -(def: .public (i64 value) +(def .public (i64 value) (-> (I64 Any) (Bytecode Any)) (case (.int value) (^.with_template [<int> <instruction>] @@ -77,18 +77,18 @@ [_ (_.long value)] ..wrap_i64))))) -(def: wrap_f64 +(def wrap_f64 (_.invokestatic $Double "valueOf" (type.method [(list) (list type.double) $Double (list)]))) (import java/lang/Double "[1]::[0]" ("static" doubleToRawLongBits "manual" [double] int)) -(def: d0_bits +(def d0_bits Int (java/lang/Double::doubleToRawLongBits +0.0)) -(def: .public (f64 value) +(def .public (f64 value) (-> Frac (Bytecode Any)) (case value (^.with_template [<int> <instruction>] @@ -129,5 +129,5 @@ [_ constantI] ..wrap_f64)))) -(def: .public text +(def .public text _.string) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux index a81896178..8a374a859 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/program.lux @@ -33,19 +33,19 @@ ["[1][0]" runtime (.only Definition)] ["[1][0]" function/abstract]]) -(def: ^Object +(def ^Object (type.class "java.lang.Object" (list))) -(def: ^String +(def ^String (type.class "java.lang.String" (list))) -(def: ^Args +(def ^Args (type.array ^String)) -(def: main::type +(def main::type (type.method [(list) (list ..^Args) type.void (list)])) -(def: main::modifier +(def main::modifier (Modifier Method) (all modifier#composite method.public @@ -53,29 +53,29 @@ method.strict )) -(def: program::modifier +(def program::modifier (Modifier Class) (all modifier#composite class.public class.final )) -(def: list:end +(def list:end //runtime.none_injection) -(def: amount_of_inputs +(def amount_of_inputs (Bytecode Any) (all _.composite _.aload_0 _.arraylength)) -(def: decrease +(def decrease (Bytecode Any) (all _.composite _.iconst_1 _.isub)) -(def: head +(def head (Bytecode Any) (all _.composite _.dup @@ -86,7 +86,7 @@ _.dup_x2 _.pop)) -(def: pair +(def pair (Bytecode Any) (let [empty_pair (all _.composite _.iconst_2 @@ -109,9 +109,9 @@ (set_side! _.iconst_1) ... P ))) -(def: list:item //runtime.right_injection) +(def list:item //runtime.right_injection) -(def: input_list +(def input_list (Bytecode Any) (do _.monad [@loop _.new_label @@ -131,17 +131,17 @@ (_.set_label @end) _.pop))) -(def: feed_inputs +(def feed_inputs //runtime.apply) -(def: run_io +(def run_io (Bytecode Any) (all _.composite (_.checkcast //function/abstract.class) //runtime.unit //runtime.apply)) -(def: .public (program artifact_name context program) +(def .public (program artifact_name context program) (-> (-> unit.ID Text) (Program (Bytecode Any) Definition)) (let [super_class (|> ..^Object type.reflection reflection.reflection name.internal) main (method.method ..main::modifier "main" diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux index b2c6f47ba..fe905d1bc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/reference.lux @@ -26,12 +26,12 @@ [meta [archive (.only Archive)]]]]]]) -(def: .public this +(def .public this (Bytecode Any) _.aload_0) (with_template [<name> <prefix>] - [(def: .public <name> + [(def .public <name> (-> Register Text) (|>> %.nat (format <prefix>)))] @@ -39,7 +39,7 @@ [partial_name "p"] ) -(def: (foreign archive variable) +(def (foreign archive variable) (-> Archive Register (Operation (Bytecode Any))) (do [! ////.monad] [bytecode_name (at ! each //runtime.class_name @@ -50,7 +50,7 @@ (..foreign_name variable) //type.value))))) -(def: .public (variable archive variable) +(def .public (variable archive variable) (-> Archive Variable (Operation (Bytecode Any))) (case variable {variable.#Local variable} @@ -59,7 +59,7 @@ {variable.#Foreign variable} (..foreign archive variable))) -(def: .public (constant archive name) +(def .public (constant archive name) (-> Archive Symbol (Operation (Bytecode Any))) (do ////.monad [[@definition |abstraction|] (generation.definition archive name) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux index 6331379f2..b52d18de3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux @@ -89,24 +89,24 @@ (type: .public Host (generation.Host (Bytecode Any) Definition)) -(def: .public (class_name [module id]) +(def .public (class_name [module id]) (-> unit.ID Text) (format lux_context "." (%.nat version.latest) "." (%.nat module) "." (%.nat id))) -(def: artifact_id +(def artifact_id 0) -(def: .public class +(def .public class (type.class (class_name [0 ..artifact_id]) (list))) -(def: procedure +(def procedure (-> Text (Type category.Method) (Bytecode Any)) (_.invokestatic ..class)) -(def: modifier +(def modifier (Modifier Method) (all modifier#composite method.public @@ -114,17 +114,17 @@ method.strict )) -(def: this +(def this (Bytecode Any) _.aload_0) -(def: .public (get index) +(def .public (get index) (-> (Bytecode Any) (Bytecode Any)) (all _.composite index _.aaload)) -(def: (set! index value) +(def (set! index value) (-> (Bytecode Any) (Bytecode Any) (Bytecode Any)) (all _.composite ... A @@ -134,17 +134,17 @@ _.aastore ... A )) -(def: .public unit (_.string synthesis.unit)) +(def .public unit (_.string synthesis.unit)) -(def: variant::name "variant") -(def: variant::type (type.method [(list) (list //type.lefts //type.right? //type.value) //type.variant (list)])) -(def: .public variant (..procedure ..variant::name ..variant::type)) +(def variant::name "variant") +(def variant::type (type.method [(list) (list //type.lefts //type.right? //type.value) //type.variant (list)])) +(def .public variant (..procedure ..variant::name ..variant::type)) -(def: variant_lefts _.iconst_0) -(def: variant_right? _.iconst_1) -(def: variant_value _.iconst_2) +(def variant_lefts _.iconst_0) +(def variant_right? _.iconst_1) +(def variant_value _.iconst_2) -(def: variant::method +(def variant::method (let [new_variant (all _.composite _.iconst_3 (_.anewarray //type.value)) @@ -163,10 +163,10 @@ (..set! ..variant_value $value) ... A[3] _.areturn)}))) -(def: .public left_right? _.aconst_null) -(def: .public right_right? ..unit) +(def .public left_right? _.aconst_null) +(def .public right_right? ..unit) -(def: .public left_injection +(def .public left_injection (Bytecode Any) (all _.composite _.iconst_0 @@ -175,7 +175,7 @@ _.pop2 ..variant)) -(def: .public right_injection +(def .public right_injection (Bytecode Any) (all _.composite _.iconst_0 @@ -184,9 +184,9 @@ _.pop2 ..variant)) -(def: .public some_injection ..right_injection) +(def .public some_injection ..right_injection) -(def: .public none_injection +(def .public none_injection (Bytecode Any) (all _.composite _.iconst_0 @@ -194,7 +194,7 @@ ..unit ..variant)) -(def: (risky $unsafe) +(def (risky $unsafe) (-> (Bytecode Any) (Bytecode Any)) (do _.monad [@try _.new_label @@ -210,11 +210,11 @@ _.areturn ))) -(def: decode_frac::name "decode_frac") -(def: decode_frac::type (type.method [(list) (list //type.text) //type.variant (list)])) -(def: .public decode_frac (..procedure ..decode_frac::name ..decode_frac::type)) +(def decode_frac::name "decode_frac") +(def decode_frac::type (type.method [(list) (list //type.text) //type.variant (list)])) +(def .public decode_frac (..procedure ..decode_frac::name ..decode_frac::type)) -(def: decode_frac::method +(def decode_frac::method (method.method ..modifier ..decode_frac::name #0 ..decode_frac::type (list) @@ -226,7 +226,7 @@ (//value.wrap type.double) ))})) -(def: .public log! +(def .public log! (Bytecode Any) (let [^PrintStream (type.class "java.io.PrintStream" (list)) ^System (type.class "java.lang.System" (list)) @@ -237,8 +237,8 @@ out (_.string "LUX LOG: ") (print! "print") out _.swap (print! "println")))) -(def: exception_constructor (type.method [(list) (list //type.text) type.void (list)])) -(def: (illegal_state_exception message) +(def exception_constructor (type.method [(list) (list //type.text) type.void (list)])) +(def (illegal_state_exception message) (-> Text (Bytecode Any)) (let [^IllegalStateException (type.class "java.lang.IllegalStateException" (list))] (all _.composite @@ -247,10 +247,10 @@ (_.string message) (_.invokespecial ^IllegalStateException "<init>" ..exception_constructor)))) -(def: failure::type +(def failure::type (type.method [(list) (list) type.void (list)])) -(def: (failure name message) +(def (failure name message) (-> Text Text (Resource Method)) (method.method ..modifier name #0 ..failure::type @@ -260,20 +260,20 @@ (..illegal_state_exception message) _.athrow)})) -(def: pm_failure::name "pm_failure") -(def: .public pm_failure (..procedure ..pm_failure::name ..failure::type)) +(def pm_failure::name "pm_failure") +(def .public pm_failure (..procedure ..pm_failure::name ..failure::type)) -(def: pm_failure::method +(def pm_failure::method (..failure ..pm_failure::name "Invalid expression for pattern-matching.")) -(def: .public stack_head _.iconst_0) -(def: .public stack_tail _.iconst_1) +(def .public stack_head _.iconst_0) +(def .public stack_tail _.iconst_1) -(def: push::name "push") -(def: push::type (type.method [(list) (list //type.stack //type.value) //type.stack (list)])) -(def: .public push (..procedure ..push::name ..push::type)) +(def push::name "push") +(def push::type (type.method [(list) (list //type.stack //type.value) //type.stack (list)])) +(def .public push (..procedure ..push::name ..push::type)) -(def: push::method +(def push::method (method.method ..modifier ..push::name #0 ..push::type (list) @@ -289,11 +289,11 @@ (..set! ..stack_tail $tail) _.areturn))})) -(def: case::name "case") -(def: case::type (type.method [(list) (list //type.variant //type.lefts //type.right?) //type.value (list)])) -(def: .public case (..procedure ..case::name ..case::type)) +(def case::name "case") +(def case::type (type.method [(list) (list //type.variant //type.lefts //type.right?) //type.value (list)])) +(def .public case (..procedure ..case::name ..case::type)) -(def: case::method +(def case::method (method.method ..modifier ..case::name #0 ..case::type (list) @@ -370,15 +370,15 @@ _.areturn ))})) -(def: projection_type (type.method [(list) (list //type.tuple //type.offset) //type.value (list)])) +(def projection_type (type.method [(list) (list //type.tuple //type.offset) //type.value (list)])) -(def: left_projection::name "left") -(def: .public left_projection (..procedure ..left_projection::name ..projection_type)) +(def left_projection::name "left") +(def .public left_projection (..procedure ..left_projection::name ..projection_type)) -(def: right_projection::name "right") -(def: .public right_projection (..procedure ..right_projection::name ..projection_type)) +(def right_projection::name "right") +(def .public right_projection (..procedure ..right_projection::name ..projection_type)) -(def: projection::method2 +(def projection::method2 [(Resource Method) (Resource Method)] (let [$tuple _.aload_0 $tuple::size (all _.composite @@ -465,23 +465,23 @@ [left_projection::method right_projection::method])) -(def: .public apply::name "apply") +(def .public apply::name "apply") -(def: .public (apply::type arity) +(def .public (apply::type arity) (-> Arity (Type category.Method)) (type.method [(list) (list.repeated arity //type.value) //type.value (list)])) -(def: .public apply +(def .public apply (_.invokevirtual //function.class ..apply::name (..apply::type 1))) -(def: try::name "try") -(def: try::type (type.method [(list) (list //function.class) //type.variant (list)])) -(def: .public try (..procedure ..try::name ..try::type)) +(def try::name "try") +(def try::type (type.method [(list) (list //function.class) //type.variant (list)])) +(def .public try (..procedure ..try::name ..try::type)) -(def: false _.iconst_0) -(def: true _.iconst_1) +(def false _.iconst_0) +(def true _.iconst_1) -(def: try::method +(def try::method (method.method ..modifier ..try::name #0 ..try::type (list) @@ -531,14 +531,14 @@ _.areturn ))})) -(def: reflection +(def reflection (All (_ category) (-> (Type (<| Return' Value' category)) Text)) (|>> type.reflection reflection.reflection)) -(def: ^Object (type.class "java.lang.Object" (list))) +(def ^Object (type.class "java.lang.Object" (list))) -(def: generate_runtime +(def generate_runtime (Operation [artifact.ID (Maybe Text) Binary]) (let [class (..reflection ..class) modifier (is (Modifier Class) @@ -571,7 +571,7 @@ _ (generation.save! ..artifact_id {.#None} [class bytecode])] (in [..artifact_id {.#None} bytecode])))) -(def: generate_function +(def generate_function (Operation Any) (let [apply::method+ (|> (enum.range n.enum (++ //function/arity.minimum) @@ -634,7 +634,7 @@ ] (in [])))) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ////.monad [runtime_payload ..generate_runtime @@ -650,7 +650,7 @@ ... function_payload )]))) -(def: .public forge_label +(def .public forge_label (Operation Label) (let [shift (n./ 4 i64.width)] ... This shift is done to avoid the possibility of forged labels diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux index f4b885825..ec2c60d9f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/structure.lux @@ -28,7 +28,7 @@ [/// ["[0]" phase]]]]) -(def: .public (tuple phase archive membersS) +(def .public (tuple phase archive membersS) (Generator (Tuple Synthesis)) (case membersS {.#End} @@ -54,7 +54,7 @@ _ (_.anewarray //type.value)] (monad.all ! membersI)))))) -(def: .public (lefts lefts) +(def .public (lefts lefts) (-> Nat (Bytecode Any)) (case lefts 0 _.iconst_0 @@ -75,13 +75,13 @@ {try.#Failure _} (_.int (.i64 lefts)))))) -(def: .public (right? right?) +(def .public (right? right?) (-> Bit (Bytecode Any)) (if right? //runtime.right_right? //runtime.left_right?)) -(def: .public (variant phase archive [lefts right? valueS]) +(def .public (variant phase archive [lefts right? valueS]) (Generator (Variant Synthesis)) (do phase.monad [valueI (phase archive valueS)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/type.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/type.lux index 2cf2cfe5e..974fa4925 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/type.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/type.lux @@ -5,19 +5,19 @@ [jvm ["[0]" type]]]]]) -(def: .public frac (type.class "java.lang.Double" (list))) -(def: .public text (type.class "java.lang.String" (list))) +(def .public frac (type.class "java.lang.Double" (list))) +(def .public text (type.class "java.lang.String" (list))) -(def: .public value (type.class "java.lang.Object" (list))) +(def .public value (type.class "java.lang.Object" (list))) -(def: .public lefts type.int) -(def: .public right? ..value) -(def: .public variant (type.array ..value)) +(def .public lefts type.int) +(def .public right? ..value) +(def .public variant (type.array ..value)) -(def: .public offset type.int) -(def: .public index ..offset) -(def: .public tuple (type.array ..value)) +(def .public offset type.int) +(def .public index ..offset) +(def .public tuple (type.array ..value)) -(def: .public stack (type.array ..value)) +(def .public stack (type.array ..value)) -(def: .public error (type.class "java.lang.Throwable" (list))) +(def .public error (type.class "java.lang.Throwable" (list))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/value.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/value.lux index 9cd5f6d93..d4f8b9a93 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/value.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/value.lux @@ -8,10 +8,10 @@ [category (.only Primitive)] ["[0]" box]]]]]]) -(def: .public field "value") +(def .public field "value") (with_template [<name> <boolean> <byte> <short> <int> <long> <float> <double> <char>] - [(def: (<name> type) + [(def (<name> type) (-> (Type Primitive) Text) (`` (cond (~~ (with_template [<type> <output>] [(type#= <type> type) <output>] @@ -35,13 +35,13 @@ "longValue" "floatValue" "doubleValue" "charValue"] ) -(def: .public (wrap type) +(def .public (wrap type) (-> (Type Primitive) (Bytecode Any)) (let [wrapper (type.class (primitive_wrapper type) (list))] (_.invokestatic wrapper "valueOf" (type.method [(list) (list type) wrapper (list)])))) -(def: .public (unwrap type) +(def .public (unwrap type) (-> (Type Primitive) (Bytecode Any)) (let [wrapper (type.class (primitive_wrapper type) (list))] (all _.composite diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux index 669e1667b..f0965920a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua.lux @@ -34,7 +34,7 @@ (exception: .public cannot_recur_as_an_expression) -(def: (expression archive synthesis) +(def (expression archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] @@ -84,6 +84,6 @@ {synthesis.#Extension extension} (///extension.apply archive expression extension))) -(def: .public generate +(def .public generate Phase ..expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux index 7ade9486a..418694f74 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux @@ -34,15 +34,15 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public register +(def .public register (-> Register Var) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (exec expression archive [this that]) +(def .public (exec expression archive [this that]) (Generator [Synthesis Synthesis]) (do ///////phase.monad [this (expression archive this) @@ -50,7 +50,7 @@ (in (|> (_.array (list this that)) (_.item (_.int +2)))))) -(def: .public (exec! statement expression archive [this that]) +(def .public (exec! statement expression archive [this that]) (Generator! [Synthesis Synthesis]) (do [! ///////phase.monad] [this (expression archive this) @@ -60,7 +60,7 @@ (_.set (list $dummy) this) that)))) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -71,7 +71,7 @@ (_.closure (list (..register register))) (_.apply (list valueO)))))) -(def: .public (let! statement expression archive [valueS register bodyS]) +(def .public (let! statement expression archive [valueS register bodyS]) (Generator! [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -80,7 +80,7 @@ (_.local/1 (..register register) valueO) bodyO)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] @@ -92,7 +92,7 @@ valueO (list.reversed pathP))))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -104,7 +104,7 @@ (_.closure (list)) (_.apply (list)))))) -(def: .public (if! statement expression archive [testS thenS elseS]) +(def .public (if! statement expression archive [testS thenS elseS]) (Generator! [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -114,27 +114,27 @@ thenO elseO)))) -(def: @savepoint (_.var "lux_pm_savepoint")) -(def: @cursor (_.var "lux_pm_cursor")) -(def: @temp (_.var "lux_pm_temp")) +(def @savepoint (_.var "lux_pm_savepoint")) +(def @cursor (_.var "lux_pm_cursor")) +(def @temp (_.var "lux_pm_temp")) -(def: (push! value) +(def (push! value) (-> Expression Statement) (_.statement (|> (_.var "table.insert") (_.apply (list @cursor value))))) -(def: peek_and_pop +(def peek_and_pop Expression (|> (_.var "table.remove") (_.apply (list @cursor)))) -(def: pop! +(def pop! Statement (_.statement ..peek_and_pop)) -(def: peek +(def peek Expression (_.item (_.length @cursor) @cursor)) -(def: save! +(def save! Statement (_.statement (|> (_.var "table.insert") (_.apply (list @savepoint @@ -145,14 +145,14 @@ (_.table (list))) (_.var "table.move"))))))) -(def: restore! +(def restore! Statement (_.set (list @cursor) (|> (_.var "table.remove") (_.apply (list @savepoint))))) -(def: fail! _.break) +(def fail! _.break) (with_template [<name> <flag>] - [(def: (<name> simple? idx) + [(def (<name> simple? idx) (-> Bit Nat Statement) (all _.then (_.set (list @temp) (//runtime.sum//get ..peek <flag> @@ -168,7 +168,7 @@ [right_choice //runtime.unit] ) -(def: (alternation pre! post!) +(def (alternation pre! post!) (-> Statement Statement Statement) (all _.then (_.while (_.boolean true) @@ -179,7 +179,7 @@ ..restore! post!))) -(def: (pattern_matching' statement expression archive) +(def (pattern_matching' statement expression archive) (-> Phase! Phase Archive Path (Operation Statement)) (function (again pathP) (.case pathP @@ -261,7 +261,7 @@ ([/////synthesis.path/seq _.then] [/////synthesis.path/alt ..alternation])))) -(def: (pattern_matching statement expression archive pathP) +(def (pattern_matching statement expression archive pathP) (-> Phase! Phase Archive Path (Operation Statement)) (do ///////phase.monad [pattern_matching! (pattern_matching' statement expression archive pathP)] @@ -270,7 +270,7 @@ pattern_matching!) (_.statement (|> (_.var "error") (_.apply (list (_.string ////synthesis/case.pattern_matching_error))))))))) -(def: .public dependencies +(def .public dependencies (-> Path (List Var)) (|>> ////synthesis/case.storage (the ////synthesis/case.#dependencies) @@ -283,7 +283,7 @@ {///////variable.#Foreign register} (..capture register)))))) -(def: .public (case! statement expression archive [valueS pathP]) +(def .public (case! statement expression archive [valueS pathP]) (Generator! [Synthesis Path]) (do ///////phase.monad [stack_init (expression archive valueS) @@ -294,7 +294,7 @@ (_.local/1 @savepoint (_.array (list))) pattern_matching!)))) -(def: .public (case statement expression archive [valueS pathP]) +(def .public (case statement expression archive [valueS pathP]) (-> Phase! (Generator [Synthesis Path])) (|> [valueS pathP] (..case! statement expression archive) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux index 79bba0796..3454cfe52 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux @@ -33,18 +33,18 @@ [reference [variable (.only Register Variable)]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Reification Synthesis)) (do [! ///////phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply argsO+ functionO)))) -(def: capture +(def capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: (with_closure inits @self @args body!) +(def (with_closure inits @self @args body!) (-> (List Expression) Var (List Var) Statement [Statement Expression]) (case inits {.#End} @@ -60,14 +60,14 @@ (_.return @self))) (_.apply inits @self)]))) -(def: input +(def input (|>> ++ //case.register)) -(def: (@scope function_name) +(def (@scope function_name) (-> unit.ID Label) (_.label (format (///reference.artifact function_name) "_scope"))) -(def: .public (function statement expression archive [environment arity bodyS]) +(def .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Generator (Abstraction Synthesis))) (do [! ///////phase.monad] [dependencies (cache.dependencies archive bodyS) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux index 71654a483..4878f0b72 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux @@ -33,11 +33,11 @@ [reference [variable (.only Register)]]]]]]) -(def: @scope +(def @scope (-> Nat Label) (|>> %.nat (format "scope") _.label)) -(def: (setup initial? offset bindings as_expression? body) +(def (setup initial? offset bindings as_expression? body) (-> Bit Register (List Expression) Bit Statement Statement) (let [variables (|> bindings list.enumeration @@ -50,7 +50,7 @@ (_.set variables (_.multi bindings))) body)))) -(def: .public (scope! statement expression archive as_expression? [start initsS+ bodyS]) +(def .public (scope! statement expression archive as_expression? [start initsS+ bodyS]) ... (Generator! (Scope Synthesis)) (-> Phase! Phase Archive Bit (Scope Synthesis) (Operation [(List Expression) Statement])) @@ -74,7 +74,7 @@ (_.set_label @scope) body!))])))) -(def: .public (scope statement expression archive [start initsS+ bodyS]) +(def .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop @@ -115,7 +115,7 @@ _ (/////generation.save! artifact_id {.#None} directive)] (in (_.apply initsO+ instantiation))))) -(def: .public (again! statement expression archive argsS+) +(def .public (again! statement expression archive argsS+) (Generator! (List Synthesis)) (do [! ///////phase.monad] [[offset @scope] /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/primitive.lux index ff40f0f26..d6104a879 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/primitive.lux @@ -5,7 +5,7 @@ ["_" lua (.only Literal)]]]]) (with_template [<name> <type> <implementation>] - [(def: .public <name> + [(def .public <name> (-> <type> Literal) <implementation>)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux index d98a16050..47df3bed5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System Expression) (implementation - (def: constant' _.var) - (def: variable' _.var))) + (def constant' _.var) + (def variable' _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux index b97413f9b..a287bf380 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux @@ -58,52 +58,52 @@ (type: .public (Generator! i) (-> Phase! Phase Archive i (Operation Statement))) -(def: .public unit +(def .public unit (_.string /////synthesis.unit)) -(def: (flag value) +(def (flag value) (-> Bit Literal) (if value ..unit _.nil)) -(def: .public variant_tag_field "_lux_tag") -(def: .public variant_flag_field "_lux_flag") -(def: .public variant_value_field "_lux_value") +(def .public variant_tag_field "_lux_tag") +(def .public variant_flag_field "_lux_flag") +(def .public variant_value_field "_lux_value") -(def: (variant' tag last? value) +(def (variant' tag last? value) (-> Expression Expression Expression Literal) (_.table (list [..variant_tag_field tag] [..variant_flag_field last?] [..variant_value_field value]))) -(def: .public (variant tag last? value) +(def .public (variant tag last? value) (-> Nat Bit Expression Literal) (variant' (_.int (.int tag)) (flag last?) value)) -(def: .public left +(def .public left (-> Expression Literal) (..variant 0 #0)) -(def: .public right +(def .public right (-> Expression Literal) (..variant 0 #1)) -(def: .public none +(def .public none Literal (..left ..unit)) -(def: .public some +(def .public some (-> Expression Literal) ..right) -(def: (feature name definition) +(def (feature name definition) (-> Var (-> Var Statement) Statement) (definition name)) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -116,10 +116,10 @@ list.together))] (~ body)))))))) -(def: module_id +(def module_id 0) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -133,11 +133,11 @@ {.#Left name} (macro.with_symbols [g!_] (let [g!name (code.local name)] - (in (list (` (def: .public (~ g!name) + (in (list (` (def .public (~ g!name) Var (~ runtime_name))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..feature (~ runtime_name) (function ((~ g!_) (~ g!name)) @@ -149,11 +149,11 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` _.Expression)) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply (list (~+ inputsC)) (~ runtime_name)))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..feature (~ runtime_name) (function ((~ g!_) (~ g!_)) @@ -161,11 +161,11 @@ (_.function (~ g!_) (list (~+ inputsC)) (~ code))))))))))))))))) -(def: (item index table) +(def (item index table) (-> Expression Expression Location) (_.item (_.+ (_.int +1) index) table)) -(def: last_index +(def last_index (|>> _.length (_.- (_.int +1)))) (with_expansions [<recur> (these (all _.then @@ -228,7 +228,7 @@ actual::value))) mismatch!))) -(def: runtime//adt +(def runtime//adt Statement (all _.then @tuple//left @@ -255,14 +255,14 @@ tail))))) (_.return tail)))) -(def: runtime//lux +(def runtime//lux Statement (all _.then @lux//try @lux//program_args )) -(def: cap_shift +(def cap_shift (_.% (_.int +64))) (runtime: (i64//left_shifted param subject) @@ -296,7 +296,7 @@ (_.return (_.- (|> subject (..i64//division param) (_.* param)) subject))) -(def: runtime//i64 +(def runtime//i64 Statement (all _.then @i64//left_shifted @@ -305,26 +305,26 @@ @i64//remainder )) -(def: (find_byte_index subject param start) +(def (find_byte_index subject param start) (-> Expression Expression Expression Expression) (_.apply (list subject param start (_.boolean #1)) (_.var "string.find"))) -(def: (char_index subject byte_index) +(def (char_index subject byte_index) (-> Expression Expression Expression) (_.apply (list subject (_.int +1) byte_index) (_.var "utf8.len"))) -(def: (byte_index subject char_index) +(def (byte_index subject char_index) (-> Expression Expression Expression) (_.apply (list subject (_.+ (_.int +1) char_index)) (_.var "utf8.offset"))) -(def: lux_index +(def lux_index (-> Expression Expression) (_.- (_.int +1))) ... TODO: Remove this once the Lua compiler becomes self-hosted. -(def: on_rembulan? +(def on_rembulan? (_.= (_.string "Lua 5.3") (_.var "_VERSION"))) @@ -393,7 +393,7 @@ <rembulan> <normal>)))) -(def: runtime//text +(def runtime//text Statement (all _.then @text//index @@ -407,13 +407,13 @@ (_.set (list (..item idx array)) value) (_.return array))) -(def: runtime//array +(def runtime//array Statement (all _.then @array//write )) -(def: runtime +(def runtime Statement (all _.then ..runtime//adt @@ -423,7 +423,7 @@ ..runtime//array )) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux index 65ed33699..128bedbbe 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux @@ -15,7 +15,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple phase archive elemsS+) +(def .public (tuple phase archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -29,7 +29,7 @@ (monad.each ///////phase.monad (phase archive)) (///////phase#each _.array)))) -(def: .public (variant phase archive [lefts right? valueS]) +(def .public (variant phase archive [lefts right? valueS]) (Generator (Variant Synthesis)) (///////phase#each (//runtime.variant lefts right?) (phase archive valueS))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux index dea69708f..5a1e5294c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php.lux @@ -29,7 +29,7 @@ [reference (.only) [variable (.only)]]]]]]]) -(def: (statement expression archive synthesis) +(def (statement expression archive synthesis) Phase! (case synthesis (^.with_template [<tag>] @@ -67,7 +67,7 @@ (exception: .public cannot_recur_as_an_expression) -(def: .public (expression archive synthesis) +(def .public (expression archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] @@ -104,6 +104,6 @@ {////synthesis.#Extension extension} (///extension.apply archive expression extension))) -(def: .public generate +(def .public generate Phase ..expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux index f9ea165c8..da294881a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/case.lux @@ -36,15 +36,15 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public register +(def .public register (-> Register Var) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueG (expression archive valueS) @@ -54,7 +54,7 @@ _.array/* (_.item (_.int +1)))))) -(def: .public (let! statement expression archive [valueS register bodyS]) +(def .public (let! statement expression archive [valueS register bodyS]) (Generator! [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -63,7 +63,7 @@ (_.set! (..register register) valueO) body!)))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testG (expression archive testS) @@ -71,7 +71,7 @@ elseG (expression archive elseS)] (in (_.? testG thenG elseG)))) -(def: .public (if! statement expression archive [testS thenS elseS]) +(def .public (if! statement expression archive [testS thenS elseS]) (Generator! [Synthesis Synthesis Synthesis]) (do ///////phase.monad [test! (expression archive testS) @@ -81,7 +81,7 @@ then! else!)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueG (expression archive valueS)] @@ -96,46 +96,46 @@ valueG (list.reversed pathP))))) -(def: @savepoint (_.var "lux_pm_savepoint")) -(def: @cursor (_.var "lux_pm_cursor")) -(def: @temp (_.var "lux_pm_temp")) +(def @savepoint (_.var "lux_pm_savepoint")) +(def @cursor (_.var "lux_pm_cursor")) +(def @temp (_.var "lux_pm_temp")) -(def: (push! value) +(def (push! value) (-> Expression Statement) (_.; (_.array_push/2 [@cursor value]))) -(def: peek_and_pop +(def peek_and_pop Expression (_.array_pop/1 @cursor)) -(def: pop! +(def pop! Statement (_.; ..peek_and_pop)) -(def: peek +(def peek Expression (_.item (|> @cursor _.count/1 (_.- (_.int +1))) @cursor)) -(def: save! +(def save! Statement (.let [cursor (_.array_slice/2 [@cursor (_.int +0)])] (_.; (_.array_push/2 [@savepoint cursor])))) -(def: restore! +(def restore! Statement (_.set! @cursor (_.array_pop/1 @savepoint))) -(def: fail! _.break) +(def fail! _.break) -(def: (multi_pop! pops) +(def (multi_pop! pops) (-> Nat Statement) (_.; (_.array_splice/3 [@cursor (_.int +0) (_.int (i.* -1 (.int pops)))]))) (with_template [<name> <flag> <prep>] - [(def: (<name> simple? idx) + [(def (<name> simple? idx) (-> Bit Nat Statement) (all _.then (_.set! @temp (|> idx <prep> .int _.int (//runtime.sum//get ..peek <flag>))) @@ -150,7 +150,7 @@ [right_choice (_.string "") ++] ) -(def: (alternation pre! post!) +(def (alternation pre! post!) (-> Statement Statement Statement) (all _.then (_.do_while (_.bool false) @@ -161,7 +161,7 @@ ..restore! post!))) -(def: (pattern_matching' statement expression archive) +(def (pattern_matching' statement expression archive) (Generator! Path) (function (again pathP) (.case pathP @@ -250,7 +250,7 @@ ([/////synthesis.path/seq _.then] [/////synthesis.path/alt ..alternation])))) -(def: (pattern_matching statement expression archive pathP) +(def (pattern_matching statement expression archive pathP) (Generator! Path) (do ///////phase.monad [iteration! (pattern_matching' statement expression archive pathP)] @@ -259,7 +259,7 @@ iteration!) (_.throw (_.new (_.constant "Exception") (list (_.string ////synthesis/case.pattern_matching_error)))))))) -(def: .public dependencies +(def .public dependencies (-> Path (List Var)) (|>> ////synthesis/case.storage (the ////synthesis/case.#dependencies) @@ -272,7 +272,7 @@ {///////variable.#Foreign register} (..capture register)))))) -(def: .public (case! statement expression archive [valueS pathP]) +(def .public (case! statement expression archive [valueS pathP]) (Generator! [Synthesis Path]) (do ///////phase.monad [stack_init (expression archive valueS) @@ -282,7 +282,7 @@ (_.set! @savepoint (_.array/* (list))) pattern_matching!)))) -(def: .public (case statement expression archive [valueS pathP]) +(def .public (case statement expression archive [valueS pathP]) (-> Phase! (Generator [Synthesis Path])) (do [! ///////phase.monad] [[[case_module case_artifact] case!] (/////generation.with_new_context archive diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension.lux index 90acc3cef..eac649c9c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension.lux @@ -9,6 +9,6 @@ [/ ["[0]" common]]) -(def: .public bundle +(def .public bundle Bundle common.bundle) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux index e569c80b2..fd5202409 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/extension/common.lux @@ -24,13 +24,13 @@ [extension ["[0]" bundle]]]]]) -(def: lux_procs +(def lux_procs Bundle (|> bundle.empty (bundle.install "is" (binary (product.uncurried _.=))) (bundle.install "try" (unary ///runtime.lux//try)))) -(def: i64_procs +(def i64_procs Bundle (<| (bundle.prefix "i64") (|> bundle.empty @@ -45,7 +45,7 @@ (bundle.install "-" (binary (product.uncurried _.-))) ))) -(def: int_procs +(def int_procs Bundle (<| (bundle.prefix "int") (|> bundle.empty @@ -56,7 +56,7 @@ (bundle.install "frac" (unary _.floatval/1)) (bundle.install "char" (unary _.chr/1))))) -(def: frac_procs +(def frac_procs Bundle (<| (bundle.prefix "frac") (|> bundle.empty @@ -72,11 +72,11 @@ (bundle.install "decode" (unary (|>> _.floatval/1 ///runtime.some))) ))) -(def: (text//index [startO partO textO]) +(def (text//index [startO partO textO]) (Trinary (Expression Any)) (///runtime.text//index textO partO startO)) -(def: text_procs +(def text_procs Bundle (<| (bundle.prefix "text") (|> bundle.empty @@ -91,7 +91,7 @@ (_.substr/3 [text from (_.- from to)])))) ))) -(def: io_procs +(def io_procs Bundle (<| (bundle.prefix "io") (|> bundle.empty @@ -100,7 +100,7 @@ (bundle.install "exit" (unary _.exit/1)) (bundle.install "current-time" (nullary (|>> _.time/0 (_.* (_.int +1,000)))))))) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux index b0c6a19a0..5a07d5032 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/function.lux @@ -29,25 +29,25 @@ [reference [variable (.only Register Variable)]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Application Synthesis)) (do [! ///////phase.monad] [functionG (expression archive functionS) argsG+ (monad.each ! (expression archive) argsS+)] (in (_.apply' argsG+ functionG)))) -(def: capture +(def capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: input +(def input (|>> ++ //case.register)) -(def: (@scope function_name) +(def (@scope function_name) (-> Context Label) (_.label (format (///reference.artifact function_name) "_scope"))) -(def: (with_closure inits @selfG @selfL body!) +(def (with_closure inits @selfG @selfL body!) (-> (List Expression) Global Var Statement [Statement Expression]) (case inits {.#End} @@ -67,7 +67,7 @@ (_.return @selfL)))) (_.apply inits @selfG)]))) -(def: .public (function statement expression archive [environment arity bodyS]) +(def .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Generator (Abstraction Synthesis))) (do [! ///////phase.monad] [[function_name body!] (/////generation.with_new_context archive diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux index f9798f4e6..c495d5a12 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/loop.lux @@ -33,11 +33,11 @@ [reference [variable (.only Register)]]]]]]]) -(def: @scope +(def @scope (-> Nat Label) (|>> %.nat (format "scope") _.label)) -(def: (setup offset bindings body) +(def (setup offset bindings body) (-> Register (List Expression) Statement Statement) ... TODO: There is a bug in the way the variables are updated. Do it like it's done in either JS or Lua. (|> bindings @@ -48,7 +48,7 @@ list.reversed (list#mix _.then body))) -(def: .public (scope! statement expression archive [start initsS+ bodyS]) +(def .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -67,7 +67,7 @@ (_.set_label @scope) body!)))))) -(def: .public (scope statement expression archive [start initsS+ bodyS]) +(def .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop @@ -106,10 +106,10 @@ (in (_.apply (list) instantiation))))) ... TODO: Stop using a constant hard-coded variable. Generate a new one each time. -(def: @temp +(def @temp (_.var "lux_again_values")) -(def: .public (again! statement expression archive argsS+) +(def .public (again! statement expression archive argsS+) (Generator! (List Synthesis)) (do [! ///////phase.monad] [[offset @scope] /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/primitive.lux index df2ae080f..b88e520c8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/primitive.lux @@ -9,11 +9,11 @@ ["[0]" // ["[1][0]" runtime]]) -(def: .public bit +(def .public bit (-> Bit Literal) _.bool) -(def: .public (i64 value) +(def .public (i64 value) (-> (I64 Any) Expression) (let [h32 (|> value //runtime.high .int _.int) l32 (|> value //runtime.low .int _.int)] @@ -21,10 +21,10 @@ (_.bit_shl (_.int +32)) (_.bit_or l32)))) -(def: .public f64 +(def .public f64 (-> Frac Literal) _.float) -(def: .public text +(def .public text (-> Text Literal) _.string) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/reference.lux index 1fb4ce3e2..8d723c451 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System Expression) (implementation - (def: constant _.global) - (def: variable _.var))) + (def constant _.global) + (def variable _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux index a8a1229dd..425dee836 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/runtime.lux @@ -57,20 +57,20 @@ (type: .public (Generator! i) (-> Phase! Phase Archive i (Operation Statement))) -(def: .public unit +(def .public unit (_.string /////synthesis.unit)) -(def: (flag value) +(def (flag value) (-> Bit Literal) (if value ..unit _.null)) -(def: (feature name definition) +(def (feature name definition) (-> Constant (-> Constant Statement) Statement) (definition name)) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -83,10 +83,10 @@ list.together))] (~ body)))))))) -(def: module_id +(def module_id 0) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -100,11 +100,11 @@ {.#Left name} (macro.with_symbols [g!_] (let [g!name (code.local name)] - (in (list (` (def: .public (~ g!name) + (in (list (` (def .public (~ g!name) Var (~ runtime_name))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..feature (~ runtime_name) (function ((~ g!_) (~ g!name)) @@ -116,11 +116,11 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` _.Expression)) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply (list (~+ inputsC)) (~ runtime_name)))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..feature (~ runtime_name) (function ((~ g!_) (~ g!_)) @@ -140,20 +140,20 @@ (_.throw (_.new (_.constant "Exception") (list message))) (_.return ..unit))) -(def: runtime//io +(def runtime//io Statement (all _.then @io//log! @io//throw! )) -(def: .public tuple_size_field +(def .public tuple_size_field "_lux_size") -(def: tuple_size +(def tuple_size (_.item (_.string ..tuple_size_field))) -(def: jphp? +(def jphp? (_.=== (_.string "5.6.99") (_.phpversion/0 []))) (runtime: (array//length array) @@ -167,17 +167,17 @@ (_.set! (_.item idx array) value) (_.return array))) -(def: runtime//array +(def runtime//array Statement (all _.then @array//length @array//write )) -(def: jphp_last_index +(def jphp_last_index (|>> ..tuple_size (_.- (_.int +1)))) -(def: normal_last_index +(def normal_last_index (|>> _.count/1 (_.- (_.int +1)))) (with_expansions [<recur> (these (all _.then @@ -243,34 +243,34 @@ (_.array_slice/2 [(_.do "getArrayCopy" (list) tuple) right_index]))))) ))))) -(def: .public variant_tag_field "_lux_tag") -(def: .public variant_flag_field "_lux_flag") -(def: .public variant_value_field "_lux_value") +(def .public variant_tag_field "_lux_tag") +(def .public variant_flag_field "_lux_flag") +(def .public variant_value_field "_lux_value") (runtime: (sum//make tag last? value) (_.return (_.array/** (list [(_.string ..variant_tag_field) tag] [(_.string ..variant_flag_field) last?] [(_.string ..variant_value_field) value])))) -(def: .public (variant tag last? value) +(def .public (variant tag last? value) (-> Nat Bit Expression Computation) (sum//make (_.int (.int tag)) (..flag last?) value)) -(def: .public none +(def .public none Computation (..variant 0 #0 ..unit)) -(def: .public some +(def .public some (-> Expression Computation) (..variant 1 #1)) -(def: .public left +(def .public left (-> Expression Computation) (..variant 0 #0)) -(def: .public right +(def .public right (-> Expression Computation) (..variant 1 #1)) @@ -302,7 +302,7 @@ (_.return (sum//make (_.- wantedTag sum_tag) sum_flag sum_value))]) no_match!)))) -(def: runtime//adt +(def runtime//adt Statement (all _.then @tuple//make @@ -331,18 +331,18 @@ (_.set! tail (..some (_.array/* (list head tail))))) (_.return tail)))) -(def: runtime//lux +(def runtime//lux Statement (all _.then @lux//try @lux//program_args )) -(def: .public high +(def .public high (-> (I64 Any) (I64 Any)) (i64.right_shifted 32)) -(def: .public low +(def .public low (-> (I64 Any) (I64 Any)) (let [mask (-- (i64.left_shifted 32 1))] (|>> (i64.and mask)))) @@ -491,7 +491,7 @@ (_.bit_or low32)))) )))) -(def: runtime//i64 +(def runtime//i64 Statement (all _.then @i64//right_shifted @@ -523,7 +523,7 @@ (_.return ..none) (_.return (..some idx)))))))) -(def: (within? top value) +(def (within? top value) (-> Expression Expression Computation) (_.and (|> value (_.>= (_.int +0))) (|> value (_.< top)))) @@ -545,7 +545,7 @@ (_.item (_.int +1))))) (_.throw (_.new (_.constant "Exception") (list (_.string "[Lux Error] Cannot get char from text.")))))) -(def: runtime//text +(def runtime//text Statement (all _.then @text//size @@ -571,13 +571,13 @@ (_.return (..some output))) ))) -(def: runtime//f64 +(def runtime//f64 Statement (all _.then @f64//decode )) -(def: check_necessary_conditions! +(def check_necessary_conditions! Statement (let [i64_support? (_.=== (_.int +8) (_.constant "PHP_INT_SIZE")) i64_error (_.string (format "Cannot run program!" text.new_line @@ -585,7 +585,7 @@ (_.when (_.not i64_support?) (_.throw (_.new (_.constant "Exception") (list i64_error)))))) -(def: runtime +(def runtime Statement (all _.then check_necessary_conditions! @@ -598,7 +598,7 @@ runtime//io )) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux index d7a945e58..2cc580fe5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/php/structure.lux @@ -17,7 +17,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple expression archive elemsS+) +(def .public (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -33,7 +33,7 @@ (///////phase#each (|>> _.array/* (//runtime.tuple//make size))))))) -(def: .public (variant expression archive [lefts right? valueS]) +(def .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux index a0c15f71e..f51b79f96 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python.lux @@ -34,7 +34,7 @@ (exception: .public cannot_recur_as_an_expression) -(def: .public (expression archive synthesis) +(def .public (expression archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] @@ -74,6 +74,6 @@ {////synthesis.#Extension extension} (///extension.apply archive expression extension))) -(def: .public generate +(def .public generate Phase ..expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux index 6b7d425f9..48ab895d4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux @@ -41,20 +41,20 @@ [dependency ["[1]" artifact]]]]]]]]]) -(def: .public (symbol prefix) +(def .public (symbol prefix) (-> Text (Operation SVar)) (///////phase#each (|>> %.nat (format prefix) _.var) /////generation.next)) -(def: .public register +(def .public register (-> Register SVar) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register SVar) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -64,7 +64,7 @@ (_.lambda (list (..register register)) bodyO))))) -(def: .public (let! statement expression archive [valueS register bodyS]) +(def .public (let! statement expression archive [valueS register bodyS]) (Generator! [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -73,14 +73,14 @@ (_.set (list (..register register)) valueO) bodyO)))) -(def: .public (exec expression archive [pre post]) +(def .public (exec expression archive [pre post]) (Generator [Synthesis Synthesis]) (do ///////phase.monad [pre (expression archive pre) post (expression archive post)] (in (_.item (_.int +1) (_.tuple (list pre post)))))) -(def: .public (exec! statement expression archive [pre post]) +(def .public (exec! statement expression archive [pre post]) (Generator! [Synthesis Synthesis]) (do ///////phase.monad [pre (expression archive pre) @@ -89,7 +89,7 @@ (_.statement pre) post)))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -97,7 +97,7 @@ elseO (expression archive elseS)] (in (_.? testO thenO elseO)))) -(def: .public (if! statement expression archive [testS thenS elseS]) +(def .public (if! statement expression archive [testS thenS elseS]) (Generator! [Synthesis Synthesis Synthesis]) (do ///////phase.monad [test! (expression archive testS) @@ -107,7 +107,7 @@ then! else!)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] @@ -120,43 +120,43 @@ valueO (list.reversed pathP))))) -(def: @savepoint (_.var "lux_pm_savepoint")) -(def: @cursor (_.var "lux_pm_cursor")) -(def: @temp (_.var "lux_pm_temp")) +(def @savepoint (_.var "lux_pm_savepoint")) +(def @cursor (_.var "lux_pm_cursor")) +(def @temp (_.var "lux_pm_temp")) -(def: (push! value) +(def (push! value) (-> (Expression Any) (Statement Any)) (_.statement (|> @cursor (_.do "append" (list value))))) -(def: peek_and_pop +(def peek_and_pop (Expression Any) (|> @cursor (_.do "pop" (list)))) -(def: pop! +(def pop! (Statement Any) (_.statement ..peek_and_pop)) -(def: peek +(def peek (Expression Any) (_.item (_.int -1) @cursor)) -(def: save! +(def save! (Statement Any) (.let [cursor (_.slice_from (_.int +0) @cursor)] (_.statement (|> @savepoint (_.do "append" (list cursor)))))) -(def: restore! +(def restore! (Statement Any) (_.set (list @cursor) (|> @savepoint (_.do "pop" (list))))) -(def: fail_pm! _.break) +(def fail_pm! _.break) -(def: (multi_pop! pops) +(def (multi_pop! pops) (-> Nat (Statement Any)) (_.delete (_.slice_from (_.int (i.* -1 (.int pops))) @cursor))) (with_template [<name> <flag>] - [(def: (<name> simple? idx) + [(def (<name> simple? idx) (-> Bit Nat (Statement Any)) (all _.then (_.set (list @temp) (//runtime.sum::get ..peek <flag> @@ -173,7 +173,7 @@ [right_choice //runtime.unit] ) -(def: (with_looping in_closure? g!once body!) +(def (with_looping in_closure? g!once body!) (-> Bit SVar (Statement Any) (Statement Any)) (.if in_closure? (_.while (_.bool true) @@ -187,7 +187,7 @@ body!) {.#Some _.continue})))) -(def: (alternation in_closure? g!once pre! post!) +(def (alternation in_closure? g!once pre! post!) (-> Bit SVar (Statement Any) (Statement Any) (Statement Any)) (all _.then (..with_looping in_closure? g!once @@ -197,7 +197,7 @@ ..restore! post!)) -(def: (primitive_pattern_matching again pathP) +(def (primitive_pattern_matching again pathP) (-> (-> Path (Operation (Statement Any))) (-> Path (Operation (Maybe (Statement Any))))) (.case pathP @@ -238,7 +238,7 @@ _ (at ///////phase.monad in {.#None}))) -(def: (pattern_matching' in_closure? statement expression archive) +(def (pattern_matching' in_closure? statement expression archive) (-> Bit Phase! Phase Archive Path (Operation (Statement Any))) (function (again pathP) (do [! ///////phase.monad] @@ -309,7 +309,7 @@ _ (undefined)))))) -(def: (pattern_matching in_closure? statement expression archive pathP) +(def (pattern_matching in_closure? statement expression archive pathP) (-> Bit Phase! Phase Archive Path (Operation (Statement Any))) (do ///////phase.monad [pattern_matching! (pattern_matching' in_closure? statement expression archive pathP) @@ -319,7 +319,7 @@ pattern_matching!) (_.raise (_.Exception/1 (_.string case.pattern_matching_error))))))) -(def: .public dependencies +(def .public dependencies (-> Path (List SVar)) (|>> case.storage (the case.#dependencies) @@ -332,7 +332,7 @@ {///////variable.#Foreign register} (..capture register)))))) -(def: .public (case! in_closure? statement expression archive [valueS pathP]) +(def .public (case! in_closure? statement expression archive [valueS pathP]) (-> Bit (Generator! [Synthesis Path])) (do ///////phase.monad [stack_init (expression archive valueS) @@ -343,7 +343,7 @@ pattern_matching! )))) -(def: .public (case statement expression archive [valueS pathP]) +(def .public (case statement expression archive [valueS pathP]) (-> Phase! (Generator [Synthesis Path])) (do ///////phase.monad [dependencies (cache.path_dependencies archive pathP) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux index abcc258a4..ca93b78d7 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/function.lux @@ -34,18 +34,18 @@ [dependency ["[1]" artifact]]]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Reification Synthesis)) (do [! ///////phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply argsO+ functionO)))) -(def: .public capture +(def .public capture (-> Register SVar) (|>> (///reference.foreign //reference.system) as_expected)) -(def: (with_closure function_id @function inits function_definition) +(def (with_closure function_id @function inits function_definition) (-> artifact.ID SVar (List (Expression Any)) (Statement Any) (Operation (Expression Any))) (case inits {.#End} @@ -66,10 +66,10 @@ _ (/////generation.save! function_id {.#None} directive)] (in (_.apply inits @function))))) -(def: input +(def input (|>> ++ //case.register)) -(def: .public (function statement expression archive [environment arity bodyS]) +(def .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Generator (Abstraction Synthesis))) (do [! ///////phase.monad] [dependencies (cache.dependencies archive bodyS) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux index 9dc509654..def965231 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/loop.lux @@ -35,7 +35,7 @@ [reference ["[1][0]" variable (.only Register)]]]]]]]) -(def: (setup offset bindings body) +(def (setup offset bindings body) (-> Register (List (Expression Any)) (Statement Any) (Statement Any)) (let [variables (|> bindings list.enumeration @@ -44,13 +44,13 @@ (_.set variables (_.multi bindings)) body))) -(def: .public (set_scope body!) +(def .public (set_scope body!) (-> (Statement Any) (Statement Any)) (_.while (_.bool true) body! {.#None})) -(def: .public (scope! statement expression archive [start initsS+ bodyS]) +(def .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -67,7 +67,7 @@ ..set_scope body!))))) -(def: .public (scope statement expression archive [start initsS+ bodyS]) +(def .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop @@ -110,7 +110,7 @@ _ (/////generation.save! loop_artifact {.#None} directive)] (in (_.apply initsO+ instantiation))))) -(def: .public (again! statement expression archive argsS+) +(def .public (again! statement expression archive argsS+) (Generator! (List Synthesis)) (do [! ///////phase.monad] [offset /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/primitive.lux index 7afebeba8..7e565f3fe 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/primitive.lux @@ -7,7 +7,7 @@ ["[1][0]" runtime]]) (with_template [<type> <name> <implementation>] - [(def: .public <name> + [(def .public <name> (-> <type> (Expression Any)) <implementation>)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux index 47b64cd94..8786e5309 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System (Expression Any)) (implementation - (def: constant' _.var) - (def: variable' _.var))) + (def constant' _.var) + (def variable' _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux index 194f641ee..5c984981b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux @@ -60,56 +60,56 @@ (type: .public (Generator i) (-> Phase Archive i (Operation (Expression Any)))) -(def: prefix +(def prefix "LuxRuntime") -(def: .public unit +(def .public unit (_.unicode /////synthesis.unit)) -(def: (flag value) +(def (flag value) (-> Bit Literal) (if value ..unit _.none)) -(def: (variant' tag last? value) +(def (variant' tag last? value) (-> (Expression Any) (Expression Any) (Expression Any) Literal) (_.tuple (list tag last? value))) -(def: .public (variant tag last? value) +(def .public (variant tag last? value) (-> Nat Bit (Expression Any) Literal) (variant' (_.int (.int tag)) (flag last?) value)) -(def: .public left +(def .public left (-> (Expression Any) Literal) (..variant 0 #0)) -(def: .public right +(def .public right (-> (Expression Any) Literal) (..variant 0 #1)) -(def: .public none +(def .public none Literal (..left ..unit)) -(def: .public some +(def .public some (-> (Expression Any) Literal) ..right) -(def: (runtime_name name) +(def (runtime_name name) (-> Text SVar) (let [symbol (format ..prefix "_" (%.nat version.latest) "_" (%.nat (text#hash name)))] (_.var symbol))) -(def: (feature name definition) +(def (feature name definition) (-> SVar (-> SVar (Statement Any)) (Statement Any)) (definition name)) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -122,7 +122,7 @@ list.together))] (~ body)))))))) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -133,8 +133,8 @@ (let [nameC (code.local name) code_nameC (code.local (format "@" name)) runtime_nameC (` (runtime_name (~ (code.text name))))] - (in (list (` (def: .public (~ nameC) SVar (~ runtime_nameC))) - (` (def: (~ code_nameC) + (in (list (` (def .public (~ nameC) SVar (~ runtime_nameC))) + (` (def (~ code_nameC) (Statement Any) (..feature (~ runtime_nameC) (function ((~ g!_) (~ g!_)) @@ -148,10 +148,10 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` (_.Expression Any))) inputs)] - (in (list (` (def: .public ((~ nameC) (~+ inputsC)) + (in (list (` (def .public ((~ nameC) (~+ inputsC)) (-> (~+ inputs_typesC) (Computation Any)) (_.apply (list (~+ inputsC)) (~ runtime_nameC)))) - (` (def: (~ code_nameC) + (` (def (~ code_nameC) (Statement Any) (..feature (~ runtime_nameC) (function ((~ g!_) (~ g!_)) @@ -179,7 +179,7 @@ (_.exec {.#Some globals} code) (_.return ..unit))) -(def: runtime::lux +(def runtime::lux (Statement Any) (all _.then @lux::try @@ -199,14 +199,14 @@ (runtime: (io::throw! message) (_.raise (_.Exception/1 message))) -(def: runtime::io +(def runtime::io (Statement Any) (all _.then @io::log! @io::throw! )) -(def: last_index +(def last_index (|>> _.len/1 (_.- (_.int +1)))) (with_expansions [<recur> (these (all _.then @@ -266,7 +266,7 @@ mismatch!) {.#None}))) -(def: runtime::adt +(def runtime::adt (Statement Any) (all _.then @tuple::left @@ -274,12 +274,12 @@ @sum::get )) -(def: i64::+limit (_.manual "+0x7FFFFFFFFFFFFFFF")) -(def: i64::-limit (_.manual "-0x8000000000000000")) -(def: i64::+iteration (_.manual "+0x10000000000000000")) -(def: i64::-iteration (_.manual "-0x10000000000000000")) -(def: i64::+cap (_.manual "+0x8000000000000000")) -(def: i64::-cap (_.manual "-0x8000000000000001")) +(def i64::+limit (_.manual "+0x7FFFFFFFFFFFFFFF")) +(def i64::-limit (_.manual "-0x8000000000000000")) +(def i64::+iteration (_.manual "+0x10000000000000000")) +(def i64::-iteration (_.manual "-0x10000000000000000")) +(def i64::+cap (_.manual "+0x8000000000000000")) +(def i64::-cap (_.manual "-0x8000000000000001")) (runtime: (i64::64 input) (with_vars [temp] @@ -298,7 +298,7 @@ ... This +- is only necessary to guarantee that values within the limits are always longs in Python 2 (|> input (_.+ ..i64::+limit) (_.- ..i64::+limit)))))))) -(def: as_nat +(def as_nat (_.% ..i64::+iteration)) (runtime: (i64::left_shifted param subject) @@ -345,7 +345,7 @@ [i64::xor _.bit_xor] ) -(def: python_version +(def python_version (Expression Any) (|> (_.__import__/1 (_.unicode "sys")) (_.the "version_info") @@ -356,7 +356,7 @@ (_.chr/1 value) (_.unichr/1 value)))) -(def: runtime::i64 +(def runtime::i64 (Statement Any) (all _.then @i64::64 @@ -385,7 +385,7 @@ (list [(list "Exception") ex (_.return ..none)])))) -(def: runtime::f64 +(def runtime::f64 (Statement Any) (all _.then @f64::/ @@ -400,10 +400,10 @@ ..none (..some (..i64::64 idx))))))) -(def: ++ +(def ++ (|>> (_.+ (_.int +1)))) -(def: (within? top value) +(def (within? top value) (-> (Expression Any) (Expression Any) (Computation Any)) (_.and (|> value (_.>= (_.int +0))) (|> value (_.< top)))) @@ -416,7 +416,7 @@ (_.return (|> text (_.slice idx (..++ idx)) _.ord/1 ..i64::64)) (_.raise (_.Exception/1 (_.unicode "[Lux Error] Cannot get char from text."))))) -(def: runtime::text +(def runtime::text (Statement Any) (all _.then @text::index @@ -429,13 +429,13 @@ (_.set (list (_.item idx array)) value) (_.return array))) -(def: runtime::array +(def runtime::array (Statement Any) (all _.then @array::write )) -(def: runtime +(def runtime (Statement Any) (all _.then runtime::lux @@ -447,10 +447,10 @@ runtime::array )) -(def: module_id +(def module_id 0) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux index 560fb1c49..cd9fe5bee 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux @@ -15,7 +15,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple generate archive elemsS+) +(def .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -29,7 +29,7 @@ (monad.each ///////phase.monad (generate archive)) (///////phase#each _.list)))) -(def: .public (variant generate archive [lefts right? valueS]) +(def .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (///////phase#each (//runtime.variant lefts right?) (generate archive valueS))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux index 582d8dd42..b73d54264 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r.lux @@ -27,7 +27,7 @@ [reference (.only) [variable (.only)]]]]]]]) -(def: .public (generate archive synthesis) +(def .public (generate archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux index 6f41454c2..ff52e460e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/case.lux @@ -37,15 +37,15 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public register +(def .public register (-> Register SVar) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register SVar) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -55,7 +55,7 @@ (_.set! (..register register) valueO) bodyO))))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -63,7 +63,7 @@ elseO (expression archive elseS)] (in (_.if testO thenO elseO)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] @@ -78,61 +78,61 @@ valueO (list.reversed pathP))))) -(def: $savepoint (_.var "lux_pm_cursor_savepoint")) -(def: $cursor (_.var "lux_pm_cursor")) -(def: $temp (_.var "lux_pm_temp")) -(def: $alt_error (_.var "alt_error")) +(def $savepoint (_.var "lux_pm_cursor_savepoint")) +(def $cursor (_.var "lux_pm_cursor")) +(def $temp (_.var "lux_pm_temp")) +(def $alt_error (_.var "alt_error")) -(def: top +(def top _.length) -(def: next +(def next (|>> _.length (_.+ (_.int +1)))) -(def: (push! value var) +(def (push! value var) (-> Expression SVar Expression) (_.set_item! (next var) value var)) -(def: (pop! var) +(def (pop! var) (-> SVar Expression) (_.set_item! (top var) _.null var)) -(def: (push_cursor! value) +(def (push_cursor! value) (-> Expression Expression) (push! value $cursor)) -(def: save_cursor! +(def save_cursor! Expression (push! (_.slice (_.float +1.0) (_.length $cursor) $cursor) $savepoint)) -(def: restore_cursor! +(def restore_cursor! Expression (_.set! $cursor (_.item (top $savepoint) $savepoint))) -(def: peek +(def peek Expression (|> $cursor (_.item (top $cursor)))) -(def: pop_cursor! +(def pop_cursor! Expression (pop! $cursor)) -(def: error +(def error (_.string (template.with_locals [error] (template.text [error])))) -(def: fail! +(def fail! (_.stop ..error)) -(def: (catch handler) +(def (catch handler) (-> Expression Expression) (_.function (list $alt_error) (_.if (|> $alt_error (_.= ..error)) handler (_.stop $alt_error)))) -(def: (pattern_matching' expression archive) +(def (pattern_matching' expression archive) (Generator Path) (function (again pathP) (.case pathP @@ -221,7 +221,7 @@ {.#None}))) ))) -(def: (pattern_matching expression archive pathP) +(def (pattern_matching expression archive pathP) (Generator Path) (do ///////phase.monad [pattern_matching! (pattern_matching' expression archive pathP)] @@ -230,7 +230,7 @@ {.#Some (..catch (_.stop (_.string "Invalid expression for pattern-matching.")))} {.#None})))) -(def: .public (case expression archive [valueS pathP]) +(def .public (case expression archive [valueS pathP]) (Generator [Synthesis Path]) (do [! ///////phase.monad] [valueO (expression archive valueS)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux index af38457a9..d0933505c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/function.lux @@ -32,14 +32,14 @@ [archive ["[0]" artifact]]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Application Synthesis)) (do [! ///////phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply argsO+ functionO)))) -(def: (with_closure function_id $function inits function_definition) +(def (with_closure function_id $function inits function_definition) (-> artifact.ID SVar (List Expression) Expression (Operation Expression)) (case inits {.#End} @@ -63,15 +63,15 @@ _ (/////generation.save! (%.nat function_id) closure_definition)] (in (_.apply inits $function))))) -(def: $curried (_.var "curried")) -(def: $missing (_.var "missing")) +(def $curried (_.var "curried")) +(def $missing (_.var "missing")) -(def: (input_declaration register) +(def (input_declaration register) (-> Register Expression) (_.set! (|> register ++ //case.register) (|> $curried (_.item (|> register ++ .int _.int))))) -(def: .public (function expression archive [environment arity bodyS]) +(def .public (function expression archive [environment arity bodyS]) (Generator (Abstraction Synthesis)) (do [! ///////phase.monad] [[[function_module function_artifact] bodyO] (/////generation.with_new_context archive diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux index 9c0a9cfa1..a3b660bd8 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/loop.lux @@ -33,7 +33,7 @@ [reference [variable (.only Register)]]]]]]]) -(def: .public (scope expression archive [offset initsS+ bodyS]) +(def .public (scope expression archive [offset initsS+ bodyS]) (Generator (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -57,7 +57,7 @@ bodyO)) (_.apply initsO+ $scope))))))) -(def: .public (again expression archive argsS+) +(def .public (again expression archive argsS+) (Generator (List Synthesis)) (do [! ///////phase.monad] [$scope /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/primitive.lux index ca30d7b84..1bbd9332c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/primitive.lux @@ -7,7 +7,7 @@ ["[1][0]" runtime]]) (with_template [<name> <type> <code>] - [(def: .public <name> + [(def .public <name> (-> <type> Expression) <code>)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux index 23f19d400..62d2f235b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux @@ -35,12 +35,12 @@ (Dict Text Proc)) ... [Utils] -(def: .public (install name unnamed) +(def .public (install name unnamed) (-> Text (-> Text Proc) (-> Bundle Bundle)) (dict.has name (unnamed name))) -(def: .public (prefix prefix bundle) +(def .public (prefix prefix bundle) (-> Text Bundle Bundle) (|> bundle dict.entries @@ -49,28 +49,28 @@ ... [Procedures] ... [[Lux]] -(def: (lux//is [leftO rightO]) +(def (lux//is [leftO rightO]) Binary (r.apply (list leftO rightO) (r.global "identical"))) -(def: (lux//if [testO thenO elseO]) +(def (lux//if [testO thenO elseO]) Trinary (caseT.translate_if testO thenO elseO)) -(def: (lux//try riskyO) +(def (lux//try riskyO) Unary (runtimeT.lux//try riskyO)) (exception: .public (Wrong_Syntax [message Text]) message) -(def: .public (wrong_syntax procedure args) +(def .public (wrong_syntax procedure args) (-> Text (List ls.Synthesis) Text) (format "Procedure: " procedure "\n" "Arguments: " (%code (code.tuple args)))) -(def: lux//loop +(def lux//loop (-> Text Proc) (function (_ proc_name) (function (_ translate inputsS) @@ -82,13 +82,13 @@ (&.throw Wrong_Syntax (wrong_syntax proc_name inputsS))) ))) -(def: lux//again +(def lux//again (-> Text Proc) (function (_ proc_name) (function (_ translate inputsS) (loopT.translate_again translate inputsS)))) -(def: lux_procs +(def lux_procs Bundle (|> (dict.empty text.Hash<Text>) (install "is" (binary lux//is)) @@ -100,7 +100,7 @@ ... [[Bits]] (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<op> paramO subjectO))] @@ -110,7 +110,7 @@ ) (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<op> (runtimeT.int64_low paramO) subjectO))] @@ -119,7 +119,7 @@ [bit//logical_right_shifted runtimeT.bit//logical_right_shifted] ) -(def: bit_procs +(def bit_procs Bundle (<| (prefix "bit") (|> (dict.empty text.Hash<Text>) @@ -137,7 +137,7 @@ ("static" MAX_VALUE Double)) (with_template [<name> <const> <encode>] - [(def: (<name> _) + [(def (<name> _) Nullary (<encode> <const>))] @@ -147,7 +147,7 @@ ) (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (|> subjectO (<op> paramO)))] @@ -159,7 +159,7 @@ ) (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<op> paramO subjectO))] @@ -176,7 +176,7 @@ ) (with_template [<name> <cmp>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<cmp> paramO subjectO))] @@ -184,14 +184,14 @@ [int//< runtimeT.int//<] ) -(def: (apply1 func) +(def (apply1 func) (-> Expression (-> Expression Expression)) (function (_ value) (r.apply (list value) func))) -(def: int//char (|>> runtimeT.int64_low (apply1 (r.global "intToUtf8")))) +(def int//char (|>> runtimeT.int64_low (apply1 (r.global "intToUtf8")))) -(def: int_procs +(def int_procs Bundle (<| (prefix "int") (|> (dict.empty text.Hash<Text>) @@ -205,11 +205,11 @@ (install "to-frac" (unary runtimeT.int//float)) (install "char" (unary int//char))))) -(def: (frac//encode value) +(def (frac//encode value) (-> Expression Expression) (r.apply (list (r.string "%f") value) (r.global "sprintf"))) -(def: frac_procs +(def frac_procs Bundle (<| (prefix "frac") (|> (dict.empty text.Hash<Text>) @@ -228,23 +228,23 @@ (install "decode" (unary runtimeT.frac//decode))))) ... [[Text]] -(def: (text//concat [subjectO paramO]) +(def (text//concat [subjectO paramO]) Binary (r.apply (list subjectO paramO) (r.global "paste0"))) -(def: (text//char [subjectO paramO]) +(def (text//char [subjectO paramO]) Binary (runtimeT.text//char subjectO paramO)) -(def: (text//clip [subjectO paramO extraO]) +(def (text//clip [subjectO paramO extraO]) Trinary (runtimeT.text//clip subjectO paramO extraO)) -(def: (text//index [textO partO startO]) +(def (text//index [textO partO startO]) Trinary (runtimeT.text//index textO partO startO)) -(def: text_procs +(def text_procs Bundle (<| (prefix "text") (|> (dict.empty text.Hash<Text>) @@ -258,17 +258,17 @@ ))) ... [[IO]] -(def: (io//exit input) +(def (io//exit input) Unary (r.apply_kw (list) (list ["status" (runtimeT.int//float input)]) (r.global "quit"))) -(def: (void code) +(def (void code) (-> Expression Expression) (r.block (r.then code runtimeT.unit))) -(def: io_procs +(def io_procs Bundle (<| (prefix "io") (|> (dict.empty text.Hash<Text>) @@ -279,7 +279,7 @@ (runtimeT.io//current_time! runtimeT.unit))))))) ... [Bundles] -(def: .public procedures +(def .public procedures Bundle (<| (prefix "lux") (|> lux_procs diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux index d8f9eae7c..fcc48447c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/host.lux @@ -16,13 +16,13 @@ (// ["@" common])) ... (with_template [<name> <lua>] -... [(def: (<name> _) @.Nullary <lua>)] +... [(def (<name> _) @.Nullary <lua>)] ... [lua//nil "nil"] ... [lua//table "{}"] ... ) -... (def: (lua//global proc translate inputs) +... (def (lua//global proc translate inputs) ... (-> Text @.Proc) ... (case inputs ... (pattern (list [_ {.#Text name}])) @@ -33,7 +33,7 @@ ... _ ... (&.throw @.Wrong_Syntax (@.wrong_syntax proc inputs)))) -... (def: (lua//call proc translate inputs) +... (def (lua//call proc translate inputs) ... (-> Text @.Proc) ... (case inputs ... (pattern (list.partial functionS argsS+)) @@ -45,7 +45,7 @@ ... _ ... (&.throw @.Wrong_Syntax (@.wrong_syntax proc inputs)))) -... (def: lua_procs +... (def lua_procs ... @.Bundle ... (|> (dict.empty text.Hash<Text>) ... (@.install "nil" (@.nullary lua//nil)) @@ -53,7 +53,7 @@ ... (@.install "global" lua//global) ... (@.install "call" lua//call))) -... (def: (table//call proc translate inputs) +... (def (table//call proc translate inputs) ... (-> Text @.Proc) ... (case inputs ... (pattern (list.partial tableS [_ {.#Text field}] argsS+)) @@ -65,15 +65,15 @@ ... _ ... (&.throw @.Wrong_Syntax (@.wrong_syntax proc inputs)))) -... (def: (table//get [fieldO tableO]) +... (def (table//get [fieldO tableO]) ... @.Binary ... (runtimeT.lua//get tableO fieldO)) -... (def: (table//set [fieldO valueO tableO]) +... (def (table//set [fieldO valueO tableO]) ... @.Trinary ... (runtimeT.lua//set tableO fieldO valueO)) -... (def: table_procs +... (def table_procs ... @.Bundle ... (<| (@.prefix "table") ... (|> (dict.empty text.Hash<Text>) @@ -81,7 +81,7 @@ ... (@.install "get" (@.binary table//get)) ... (@.install "set" (@.trinary table//set))))) -(def: .public procedures +(def .public procedures @.Bundle (<| (@.prefix "lua") (dict.empty text.Hash<Text>) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/reference.lux index 5a37d97b7..4cc1f49ba 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System Expression) (implementation - (def: constant _.var) - (def: variable _.var))) + (def constant _.var) + (def variable _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux index 20d9475a1..ff87c9113 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/runtime.lux @@ -41,7 +41,7 @@ [archive (.only Output Archive) ["[0]" artifact (.only Registry)]]]]]]) -(def: module_id +(def module_id 0) (with_template [<name> <base>] @@ -57,15 +57,15 @@ (type: .public (Generator i) (-> Phase Archive i (Operation Expression))) -(def: .public unit +(def .public unit Expression (_.string /////synthesis.unit)) -(def: full_32 (hex "FFFFFFFF")) -(def: half_32 (hex "7FFFFFFF")) -(def: post_32 (hex "100000000")) +(def full_32 (hex "FFFFFFFF")) +(def half_32 (hex "7FFFFFFF")) +(def post_32 (hex "100000000")) -(def: (cap_32 input) +(def (cap_32 input) (-> Nat Int) (cond (n.> full_32 input) (|> input (i64.and full_32) cap_32) @@ -76,7 +76,7 @@ ... else (.int input))) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -89,7 +89,7 @@ list.together))] (~ body)))))))) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -102,11 +102,11 @@ (case declaration {.#Left name} (let [g!name (code.local name)] - (in (list (` (def: .public (~ g!name) + (in (list (` (def .public (~ g!name) _.SVar (~ runtime_name))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) _.Expression (_.set! (~ runtime_name) (~ code))))))) @@ -115,22 +115,22 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` _.Expression)) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) _.Expression) (_.apply (list (~+ inputsC)) (~ runtime_name)))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) _.Expression (..with_vars [(~+ inputsC)] (_.set! (~ runtime_name) (_.function (list (~+ inputsC)) (~ code))))))))))))))) -(def: .public variant_tag_field "luxVT") -(def: .public variant_flag_field "luxVF") -(def: .public variant_value_field "luxVV") +(def .public variant_tag_field "luxVT") +(def .public variant_flag_field "luxVF") +(def .public variant_value_field "luxVV") -(def: .public (flag value) +(def .public (flag value) (-> Bit Expression) (if value (_.string "") @@ -141,29 +141,29 @@ [..variant_flag_field last?] [..variant_value_field value]))) -(def: .public (variant tag last? value) +(def .public (variant tag last? value) (-> Nat Bit Expression Expression) (adt::variant (_.int (.int tag)) (flag last?) value)) -(def: .public none +(def .public none Expression (variant 0 #0 ..unit)) -(def: .public some +(def .public some (-> Expression Expression) (variant 1 #1)) -(def: .public left +(def .public left (-> Expression Expression) (variant 0 #0)) -(def: .public right +(def .public right (-> Expression Expression) (variant 1 #1)) -(def: high_shift (_.bit_shl (_.int +32))) +(def high_shift (_.bit_shl (_.int +32))) (with_template [<name> <power>] [(runtime: <name> (|> (_.as::integer (_.int +2)) (_.** (_.as::integer (_.int <power>)))))] @@ -172,12 +172,12 @@ [f2^63 +63] ) -(def: (as_double value) +(def (as_double value) (-> Expression Expression) (_.apply (list value) (_.var "as.double"))) -(def: .public i64_high_field "luxIH") -(def: .public i64_low_field "luxIL") +(def .public i64_high_field "luxIH") +(def .public i64_low_field "luxIL") (runtime: (i64::unsigned_low input) (with_vars [low] @@ -199,21 +199,21 @@ (_.named_list (list [..i64_high_field (_.as::integer high)] [..i64_low_field (_.as::integer low)]))) -(def: high_32 +(def high_32 (-> Nat Nat) (i64.right_shifted 32)) -(def: low_32 +(def low_32 (-> Nat Nat) (|>> (i64.and (hex "FFFFFFFF")))) -(def: .public (i64 value) +(def .public (i64 value) (-> Int Expression) (let [value (.nat value)] (i64::new (|> value ..high_32 ..cap_32 _.int) (|> value ..low_32 ..cap_32 _.int)))) -(def: .public (lux_i64 high low) +(def .public (lux_i64 high low) (-> Int Int Int) (|> high (i64.left_shifted 32) @@ -229,8 +229,8 @@ [i64::max i#top] ) -(def: .public i64_high (_.item (_.string ..i64_high_field))) -(def: .public i64_low (_.item (_.string ..i64_low_field))) +(def .public i64_high (_.item (_.string ..i64_high_field))) +(def .public i64_low (_.item (_.string ..i64_low_field))) (runtime: (i64::not input) (i64::new (|> input i64_high _.bit_not) @@ -380,11 +380,11 @@ (new_half x16 x00))))) ))))))) -(def: (limit_shift! shift) +(def (limit_shift! shift) (-> SVar Expression) (_.set! shift (|> shift (_.bit_and (_.as::integer (_.int +63)))))) -(def: (no_shift_clause shift input) +(def (no_shift_clause shift input) (-> SVar SVar [Expression Expression]) [(|> shift (_.= (_.int +0))) input]) @@ -539,14 +539,14 @@ (_.set! inputs (..some (_.list (list value inputs))))) inputs))) -(def: runtime::lux +(def runtime::lux Expression (all _.then @lux::try @lux::program_args )) -(def: current_time_float +(def current_time_float Expression (let [raw_time (_.apply (list) (_.var "Sys.time"))] (_.apply (list raw_time) (_.var "as.numeric")))) @@ -556,25 +556,25 @@ (_.* (_.float +1,000.0)) i64::of_float)) -(def: runtime::io +(def runtime::io Expression (all _.then @io::current_time! )) -(def: minimum_index_length +(def minimum_index_length (-> SVar Expression) (|>> (_.+ (_.int +1)))) -(def: (product_element product index) +(def (product_element product index) (-> Expression Expression Expression) (|> product (_.item (|> index (_.+ (_.int +1)))))) -(def: (product_tail product) +(def (product_tail product) (-> SVar Expression) (|> product (_.item (_.length product)))) -(def: (updated_index min_length product) +(def (updated_index min_length product) (-> Expression Expression Expression) (|> min_length (_.- (_.length product)))) @@ -629,7 +629,7 @@ no_match))) -(def: runtime::adt +(def runtime::adt Expression (all _.then @tuple::left @@ -672,7 +672,7 @@ (let [low (|> (i64_high input) (_.bit_ushr (|> shift (_.- (_.int +32)))))] (i64::new (_.int +0) low))))) -(def: runtime::i64 +(def runtime::i64 Expression (all _.then @f2^32 @@ -715,22 +715,22 @@ ..none (..some output))))) -(def: runtime::frac +(def runtime::frac Expression (all _.then @frac::decode )) -(def: ++ +(def ++ (-> Expression Expression) (|>> (_.+ (_.int +1)))) -(def: (text_clip start end text) +(def (text_clip start end text) (-> Expression Expression Expression Expression) (_.apply (list text start end) (_.var "substr"))) -(def: (text_length text) +(def (text_length text) (-> Expression Expression) (_.apply (list text) (_.var "nchar"))) @@ -763,7 +763,7 @@ (..some (text_clip (++ minimum) (++ to) text)) ..none)))) -(def: (char_at idx text) +(def (char_at idx text) (-> Expression Expression Expression) (_.apply (list (text_clip idx idx text)) (_.var "utf8ToInt"))) @@ -775,7 +775,7 @@ (..some (i64::of_float (char_at idx text)))) ..none)) -(def: runtime::text +(def runtime::text Expression (all _.then @text::index @@ -783,7 +783,7 @@ @text::char )) -(def: (check_index_out_of_bounds array idx body) +(def (check_index_out_of_bounds array idx body) (-> Expression Expression Expression Expression) (_.if (_.> (_.length array) idx) (_.stop (_.string "Array index out of bounds!")) @@ -813,7 +813,7 @@ (_.set_item! (_.+ (_.int +1) idx) value array) array))) -(def: runtime::array +(def runtime::array Expression (all _.then @array::new @@ -821,7 +821,7 @@ @array::put )) -(def: runtime +(def runtime Expression (all _.then runtime::lux @@ -833,7 +833,7 @@ runtime::io )) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux index f41b3268d..5e376dd1f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/structure.lux @@ -17,7 +17,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple expression archive elemsS+) +(def .public (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -31,7 +31,7 @@ (monad.each ///////phase.monad (expression archive)) (///////phase#each _.list)))) -(def: .public (variant expression archive [lefts right? valueS]) +(def .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux index 93183d209..5ee5957eb 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux @@ -19,7 +19,7 @@ ... This universe constant is for languages where one can't just turn all compiled definitions ... into the local variables of some scoping function. -(def: .public universe +(def .public universe (for @.lua ... In the case of Lua, there is a limit of 200 locals in a function's scope. (not ("lua script universe")) @@ -37,7 +37,7 @@ (not ("scheme script universe")) #0)) -(def: universe_label +(def universe_label Text (with_expansions [<label> (format "u" (%.nat (if ..universe 1 0)))] (for @.lua <label> @@ -46,7 +46,7 @@ @.scheme <label> ""))) -(def: .public (artifact [module artifact]) +(def .public (artifact [module artifact]) (-> unit.ID Text) (format "l" (%.nat version.latest) ..universe_label @@ -60,7 +60,7 @@ (is (-> Text expression) variable'))) -(def: .public (constant system archive name) +(def .public (constant system archive name) (All (_ anchor expression directive) (-> (System expression) Archive Symbol (////generation.Operation anchor expression directive expression))) @@ -68,7 +68,7 @@ (////generation.remember archive name))) (with_template [<sigil> <name>] - [(def: .public (<name> system) + [(def .public (<name> system) (All (_ expression) (-> (System expression) (-> Register expression))) @@ -78,7 +78,7 @@ ["l" local] ) -(def: .public (variable system variable) +(def .public (variable system variable) (All (_ expression) (-> (System expression) Variable expression)) (case variable @@ -88,7 +88,7 @@ {variable.#Foreign register} (..foreign system register))) -(def: .public (reference system archive reference) +(def .public (reference system archive reference) (All (_ anchor expression directive) (-> (System expression) Archive Reference (////generation.Operation anchor expression directive expression))) (case reference diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux index 6a11d8996..8cc7466cc 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby.lux @@ -34,7 +34,7 @@ (exception: .public cannot_recur_as_an_expression) -(def: (expression archive synthesis) +(def (expression archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] @@ -74,6 +74,6 @@ {////synthesis.#Extension extension} (///extension.apply archive expression extension))) -(def: .public generate +(def .public generate Phase ..expression) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux index 3ddd687e1..bd9e27049 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux @@ -40,19 +40,19 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public (symbol prefix) +(def .public (symbol prefix) (-> Text (Operation LVar)) (///////phase#each (|>> %.nat (format prefix) _.local) /////generation.next)) -(def: .public register +(def .public register (-> Register LVar) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register LVar) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (exec expression archive [this that]) +(def .public (exec expression archive [this that]) (Generator [Synthesis Synthesis]) (do ///////phase.monad [this (expression archive this) @@ -60,7 +60,7 @@ (in (|> (_.array (list this that)) (_.item (_.int +1)))))) -(def: .public (exec! statement expression archive [this that]) +(def .public (exec! statement expression archive [this that]) (Generator! [Synthesis Synthesis]) (do ///////phase.monad [this (expression archive this) @@ -70,7 +70,7 @@ that )))) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -81,7 +81,7 @@ [(list (..register register))] (_.lambda {.#None}) (_.apply_lambda (list valueO)))))) -(def: .public (let! statement expression archive [valueS register bodyS]) +(def .public (let! statement expression archive [valueS register bodyS]) (Generator! [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -90,7 +90,7 @@ (_.set (list (..register register)) valueO) bodyO)))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -98,7 +98,7 @@ elseO (expression archive elseS)] (in (_.? testO thenO elseO)))) -(def: .public (if! statement expression archive [testS thenS elseS]) +(def .public (if! statement expression archive [testS thenS elseS]) (Generator! [Synthesis Synthesis Synthesis]) (do ///////phase.monad [test! (expression archive testS) @@ -108,7 +108,7 @@ then! else!)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] @@ -120,38 +120,38 @@ valueO (list.reversed pathP))))) -(def: @savepoint (_.local "lux_pm_savepoint")) -(def: @cursor (_.local "lux_pm_cursor")) -(def: @temp (_.local "lux_pm_temp")) +(def @savepoint (_.local "lux_pm_savepoint")) +(def @cursor (_.local "lux_pm_cursor")) +(def @temp (_.local "lux_pm_temp")) -(def: (push! value) +(def (push! value) (-> Expression Statement) (_.statement (|> @cursor (_.do "push" (list value) {.#None})))) -(def: peek_and_pop +(def peek_and_pop Expression (|> @cursor (_.do "pop" (list) {.#None}))) -(def: pop! +(def pop! Statement (_.statement ..peek_and_pop)) -(def: peek +(def peek Expression (_.item (_.int -1) @cursor)) -(def: save! +(def save! Statement (.let [cursor (_.array_range (_.int +0) (_.int -1) @cursor)] (_.statement (|> @savepoint (_.do "push" (list cursor) {.#None}))))) -(def: restore! +(def restore! Statement (_.set (list @cursor) (|> @savepoint (_.do "pop" (list) {.#None})))) -(def: fail! _.break) +(def fail! _.break) -(def: (multi_pop! pops) +(def (multi_pop! pops) (-> Nat Statement) (_.statement (_.do "slice!" (list (_.int (i.* -1 (.int pops))) @@ -160,7 +160,7 @@ @cursor))) (with_template [<name> <flag>] - [(def: (<name> simple? idx) + [(def (<name> simple? idx) (-> Bit Nat Statement) (all _.then (_.set (list @temp) (//runtime.sum//get ..peek <flag> @@ -176,7 +176,7 @@ [right_choice //runtime.unit] ) -(def: (with_looping in_closure? g!once g!continue? body!) +(def (with_looping in_closure? g!once g!continue? body!) (-> Bit LVar LVar Statement Statement) (.if in_closure? (all _.then @@ -196,7 +196,7 @@ (_.when g!continue? _.next)))) -(def: (alternation in_closure? g!once g!continue? pre! post!) +(def (alternation in_closure? g!once g!continue? pre! post!) (-> Bit LVar LVar Statement Statement Statement) (all _.then (with_looping in_closure? g!once g!continue? @@ -206,7 +206,7 @@ ..restore! post!)) -(def: (primitive_pattern_matching again pathP) +(def (primitive_pattern_matching again pathP) (-> (-> Path (Operation Statement)) (-> Path (Operation (Maybe Statement)))) (.case pathP @@ -247,7 +247,7 @@ _ (at ///////phase.monad in {.#None}))) -(def: (pattern_matching' in_closure? statement expression archive) +(def (pattern_matching' in_closure? statement expression archive) (-> Bit (Generator! Path)) (function (again pathP) (do ///////phase.monad @@ -352,7 +352,7 @@ g!continue? (..symbol "continue")] (in (..alternation in_closure? g!once g!continue? pre! post!)))))))) -(def: (pattern_matching in_closure? statement expression archive pathP) +(def (pattern_matching in_closure? statement expression archive pathP) (-> Bit (Generator! Path)) (do ///////phase.monad [pattern_matching! (pattern_matching' in_closure? statement expression archive pathP) @@ -363,7 +363,7 @@ pattern_matching!) (_.statement (_.raise (_.string case.pattern_matching_error))))))) -(def: .public (case! in_closure? statement expression archive [valueS pathP]) +(def .public (case! in_closure? statement expression archive [valueS pathP]) (-> Bit (Generator! [Synthesis Path])) (do ///////phase.monad [stack_init (expression archive valueS) @@ -374,7 +374,7 @@ pattern_matching! )))) -(def: .public (case statement expression archive case) +(def .public (case statement expression archive case) (-> Phase! (Generator [Synthesis Path])) (|> case (case! true statement expression archive) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux index 2ebe8edbb..67fd28d7b 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/function.lux @@ -32,18 +32,18 @@ [dependency ["[1]/[0]" artifact]]]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Reification Synthesis)) (do [! ///////phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply_lambda argsO+ functionO)))) -(def: .public capture +(def .public capture (-> Register LVar) (|>> (///reference.foreign //reference.system) as_expected)) -(def: (with_closure inits self function_definition) +(def (with_closure inits self function_definition) (-> (List Expression) Text Expression [Statement Expression]) (let [@self (_.global self)] (case inits @@ -61,10 +61,10 @@ (_.return @self)))])) (_.apply_lambda inits @self)]))) -(def: input +(def input (|>> ++ //case.register)) -(def: .public (function statement expression archive [environment arity bodyS]) +(def .public (function statement expression archive [environment arity bodyS]) (-> Phase! (Generator (Abstraction Synthesis))) (do [! ///////phase.monad] [dependencies (cache/artifact.dependencies archive bodyS) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux index 930206963..693f5a46d 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/loop.lux @@ -31,7 +31,7 @@ [reference ["[1][0]" variable (.only Register)]]]]]]]) -(def: (setup offset bindings body) +(def (setup offset bindings body) (-> Register (List Expression) Statement Statement) (let [variables (|> bindings list.enumeration @@ -40,14 +40,14 @@ (_.set variables (_.multi bindings)) body))) -(def: symbol +(def symbol (_.symbol "lux_continue")) -(def: .public with_scope +(def .public with_scope (-> Statement Statement) (_.while (_.bool true))) -(def: .public (scope! statement expression archive [start initsS+ bodyS]) +(def .public (scope! statement expression archive [start initsS+ bodyS]) (Generator! (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -64,7 +64,7 @@ ..with_scope body!))))) -(def: .public (scope statement expression archive [start initsS+ bodyS]) +(def .public (scope statement expression archive [start initsS+ bodyS]) (-> Phase! (Generator (Scope Synthesis))) (case initsS+ ... function/false/non-independent loop @@ -79,7 +79,7 @@ [(list)] (_.lambda {.#None}) (_.apply_lambda (list))))))) -(def: .public (again! statement expression archive argsS+) +(def .public (again! statement expression archive argsS+) (Generator! (List Synthesis)) (do [! ///////phase.monad] [offset /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/primitive.lux index 162936972..eebaa01d5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/primitive.lux @@ -5,7 +5,7 @@ ["_" ruby (.only Literal)]]]]) (with_template [<type> <name> <implementation>] - [(def: .public <name> + [(def .public <name> (-> <type> Literal) <implementation>)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux index b464719fc..b29560a21 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System Expression) (implementation - (def: constant' _.global) - (def: variable' _.local))) + (def constant' _.global) + (def variable' _.local))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux index 9552d15ac..7d5b9d6b4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux @@ -59,16 +59,16 @@ (type: .public (Generator! i) (-> Phase! Phase Archive i (Operation Statement))) -(def: .public unit +(def .public unit (_.string /////synthesis.unit)) -(def: (flag value) +(def (flag value) (-> Bit Literal) (if value ..unit _.nil)) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -81,14 +81,14 @@ list.together))] (~ body)))))))) -(def: module_id +(def module_id 0) -(def: $Numeric +(def $Numeric _.CVar (_.manual "Numeric")) -(def: mruby? +(def mruby? _.Expression (_.and (|> $Numeric (_.do "method_defined?" (list (_.string "remainder")) {.#None}) @@ -96,14 +96,14 @@ (|> $Numeric (_.do "method_defined?" (list (_.string "remainder_of_divide")) {.#None})))) -(def: normal_ruby? +(def normal_ruby? _.Expression (_.not ..mruby?) ... (|> (_.local "Object") ... (_.do "const_defined?" (list (_.string "Encoding")) {.#None})) ) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -118,8 +118,8 @@ (let [runtime (code.local (///reference.artifact [..module_id runtime_id])) runtime_name (` (_.constant (~ (code.text (%.code runtime))))) g!name (code.local name)] - (in (list (` (def: .public (~ g!name) _.CVar (~ runtime_name))) - (` (def: (~ (code.local (format "@" name))) + (in (list (` (def .public (~ g!name) _.CVar (~ runtime_name))) + (` (def (~ (code.local (format "@" name))) Statement (~ (list#mix (function (_ [when then] else) (` (_.if (~ when) @@ -136,12 +136,12 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` _.Expression)) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) Computation) (_.apply (list (~+ inputsC)) {.#None} (~ runtime_name)))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) Statement (..with_vars [(~+ inputsC)] (~ (list#mix (function (_ [when then] else) @@ -153,10 +153,10 @@ (~ default_implementation))) conditional_implementations)))))))))))))) -(def: tuple_size +(def tuple_size (_.the "length")) -(def: last_index +(def last_index (|>> ..tuple_size (_.- (_.int +1)))) (with_expansions [<recur> (these (all _.then @@ -187,32 +187,32 @@ (_.return (_.array_range right_index (..tuple_size tuple) tuple))) ))))) -(def: .public variant_tag_field "_lux_tag") -(def: .public variant_flag_field "_lux_flag") -(def: .public variant_value_field "_lux_value") +(def .public variant_tag_field "_lux_tag") +(def .public variant_flag_field "_lux_flag") +(def .public variant_value_field "_lux_value") (runtime: (sum//make tag last? value) (_.return (_.hash (list [(_.string ..variant_tag_field) tag] [(_.string ..variant_flag_field) last?] [(_.string ..variant_value_field) value])))) -(def: .public (variant tag last? value) +(def .public (variant tag last? value) (-> Nat Bit Expression Computation) (sum//make (_.int (.int tag)) (..flag last?) value)) -(def: .public left +(def .public left (-> Expression Computation) (..variant 0 #0)) -(def: .public right +(def .public right (-> Expression Computation) (..variant 0 #1)) -(def: .public none +(def .public none Computation (..left ..unit)) -(def: .public some +(def .public some (-> Expression Computation) ..right) @@ -243,7 +243,7 @@ actual::value))) mismatch!))) -(def: runtime//adt +(def runtime//adt Statement (all _.then @tuple//left @@ -268,17 +268,17 @@ (_.set (list tail) (..some (_.array (list head tail))))) (_.return tail)))) -(def: runtime//lux +(def runtime//lux Statement (all _.then @lux//try @lux//program_args )) -(def: i64::+limit (_.manual "+0x7FFFFFFFFFFFFFFF")) -(def: i64::-limit (_.manual "-0x8000000000000000")) -(def: i64::+cap (_.manual "+0x8000000000000000")) -(def: i64::-cap (_.manual "-0x8000000000000001")) +(def i64::+limit (_.manual "+0x7FFFFFFFFFFFFFFF")) +(def i64::-limit (_.manual "-0x8000000000000000")) +(def i64::+cap (_.manual "+0x8000000000000000")) +(def i64::-cap (_.manual "-0x8000000000000001")) (runtime: i64::+iteration (_.manual "(+1<<64)")) (runtime: i64::-iteration (_.manual "(-1<<64)")) @@ -299,21 +299,21 @@ )) (_.return input))))) -(def: i32::low +(def i32::low (|>> (_.bit_and (_.manual "+0xFFFFFFFF")))) -(def: i32::high +(def i32::high (|>> (_.bit_shr (_.int +32)) ..i32::low)) -(def: i32::positive? +(def i32::positive? (|>> (_.bit_and (_.manual "+0x80000000")) (_.= (_.int +0)))) -(def: i32::up +(def i32::up (_.bit_shl (_.int +32))) -(def: i64 +(def i64 (template (_ @high @low) [(|> (_.? (i32::positive? @high) @high @@ -323,7 +323,7 @@ i32::up (_.bit_or @low))])) -(def: as_nat +(def as_nat (_.% ..i64::+iteration)) (with_template [<runtime> <host>] @@ -340,16 +340,16 @@ [i64::xor _.bit_xor] ) -(def: (cap_shift! shift) +(def (cap_shift! shift) (-> LVar Statement) (_.set (list shift) (|> shift (_.bit_and (_.int +63))))) -(def: (handle_no_shift! shift input) +(def (handle_no_shift! shift input) (-> LVar LVar (-> Statement Statement)) (_.if (|> shift (_.= (_.int +0))) (_.return input))) -(def: small_shift? +(def small_shift? (-> LVar Expression) (|>> (_.< (_.int +32)))) @@ -419,10 +419,10 @@ (_.return (..i64 high (i32::low low))) ))) -(def: i64::min +(def i64::min (_.manual "-0x8000000000000000")) -(def: (i64::opposite value) +(def (i64::opposite value) (_.? (_.= i64::min value) i64::min (i64::+ (_.int +1) (_.bit_not value)))) @@ -431,13 +431,13 @@ [..normal_ruby? (_.return (i64::i64 (_.- parameter subject)))] (_.return (i64::+ (i64::opposite parameter) subject))) -(def: i16::high +(def i16::high (_.bit_shr (_.int +16))) -(def: i16::low +(def i16::low (_.bit_and (_.manual "+0xFFFF"))) -(def: i16::up +(def i16::up (_.bit_shl (_.int +16))) (runtime: (i64::* parameter subject) @@ -494,7 +494,7 @@ [..mruby? (_.return (_.do "chr" (list) {.#None} subject))] (_.return (_.do "chr" (list (_.string "UTF-8")) {.#None} subject))) -(def: runtime//i64 +(def runtime//i64 Statement (all _.then @i64::+iteration @@ -525,7 +525,7 @@ (_.return (..some @temp)) (_.return ..none))))) -(def: runtime//f64 +(def runtime//f64 Statement (all _.then @f64//decode @@ -539,7 +539,7 @@ (_.return ..none) (_.return (..some idx)))))) -(def: (within? top value) +(def (within? top value) (-> Expression Expression Computation) (_.and (|> value (_.>= (_.int +0))) (|> value (_.< top)))) @@ -554,7 +554,7 @@ (_.return (|> text (_.array_range idx idx) (_.do "ord" (list) {.#None}))) (_.statement (_.raise (_.string "[Lux Error] Cannot get char from text."))))) -(def: runtime//text +(def runtime//text Statement (all _.then @text//index @@ -567,13 +567,13 @@ (_.set (list (_.item idx array)) value) (_.return array))) -(def: runtime//array +(def runtime//array Statement (all _.then @array//write )) -(def: runtime +(def runtime Statement (all _.then (_.when ..mruby? @@ -592,7 +592,7 @@ runtime//array )) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux index 791f06d76..3cdbd9591 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux @@ -15,7 +15,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple generate archive elemsS+) +(def .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -29,7 +29,7 @@ (monad.each ///////phase.monad (generate archive)) (///////phase#each _.array)))) -(def: .public (variant generate archive [lefts right? valueS]) +(def .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) (///////phase#each (//runtime.variant lefts right?) (generate archive valueS))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux index 2702efa5e..b6a3a5842 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme.lux @@ -27,7 +27,7 @@ [reference (.only) [variable (.only)]]]]]]]) -(def: .public (generate archive synthesis) +(def .public (generate archive synthesis) Phase (case synthesis (^.with_template [<tag> <generator>] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux index 7cbfc7bfe..f492d94df 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/case.lux @@ -37,15 +37,15 @@ [meta [archive (.only Archive)]]]]]]]) -(def: .public register +(def .public register (-> Register Var) (|>> (///reference.local //reference.system) as_expected)) -(def: .public capture +(def .public capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: .public (let expression archive [valueS register bodyS]) +(def .public (let expression archive [valueS register bodyS]) (Generator [Synthesis Register Synthesis]) (do ///////phase.monad [valueO (expression archive valueS) @@ -53,7 +53,7 @@ (in (_.let (list [(..register register) valueO]) bodyO)))) -(def: .public (if expression archive [testS thenS elseS]) +(def .public (if expression archive [testS thenS elseS]) (Generator [Synthesis Synthesis Synthesis]) (do ///////phase.monad [testO (expression archive testS) @@ -61,7 +61,7 @@ elseO (expression archive elseS)] (in (_.if testO thenO elseO)))) -(def: .public (get expression archive [pathP valueS]) +(def .public (get expression archive [pathP valueS]) (Generator [(List Member) Synthesis]) (do ///////phase.monad [valueO (expression archive valueS)] @@ -76,48 +76,48 @@ valueO (list.reversed pathP))))) -(def: @savepoint (_.var "lux_pm_cursor_savepoint")) -(def: @cursor (_.var "lux_pm_cursor")) -(def: @temp (_.var "lux_pm_temp")) -(def: @alt_error (_.var "alt_error")) +(def @savepoint (_.var "lux_pm_cursor_savepoint")) +(def @cursor (_.var "lux_pm_cursor")) +(def @temp (_.var "lux_pm_temp")) +(def @alt_error (_.var "alt_error")) -(def: (push! value var) +(def (push! value var) (-> Expression Var Computation) (_.set! var (_.cons/2 value var))) -(def: (push_cursor! value) +(def (push_cursor! value) (-> Expression Computation) (push! value @cursor)) -(def: (pop! var) +(def (pop! var) (-> Var Computation) (_.set! var (_.cdr/1 var))) -(def: save_cursor! +(def save_cursor! Computation (push! @cursor @savepoint)) -(def: restore_cursor! +(def restore_cursor! Computation (_.begin (list (_.set! @cursor (_.car/1 @savepoint)) (_.set! @savepoint (_.cdr/1 @savepoint))))) -(def: peek +(def peek Computation (_.car/1 @cursor)) -(def: pop_cursor! +(def pop_cursor! Computation (pop! @cursor)) -(def: pm_error +(def pm_error (_.string (template.with_locals [pm_error] (template.text [pm_error])))) -(def: fail! +(def fail! (_.raise/1 pm_error)) -(def: (try_pm on_failure happy_path) +(def (try_pm on_failure happy_path) (-> Expression Expression Computation) (_.guard @alt_error (list [(_.and (list (_.string?/1 @alt_error) @@ -126,7 +126,7 @@ {.#None} happy_path)) -(def: (pattern_matching' expression archive) +(def (pattern_matching' expression archive) (Generator Path) (function (again pathP) (.case pathP @@ -209,13 +209,13 @@ leftO))))) ))) -(def: (pattern_matching expression archive pathP) +(def (pattern_matching expression archive pathP) (Generator Path) (at ///////phase.monad each (try_pm (_.raise/1 (_.string "Invalid expression for pattern-matching."))) (pattern_matching' expression archive pathP))) -(def: .public (case expression archive [valueS pathP]) +(def .public (case expression archive [valueS pathP]) (Generator [Synthesis Path]) (do [! ///////phase.monad] [valueO (expression archive valueS)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension.lux index 90acc3cef..eac649c9c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension.lux @@ -9,6 +9,6 @@ [/ ["[0]" common]]) -(def: .public bundle +(def .public bundle Bundle common.bundle) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux index 2ed9653b5..815a712b3 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux @@ -28,14 +28,14 @@ ["[1]/" // ["[1][0]" synthesis (.only Synthesis)]]]]) -(def: bundle::lux +(def bundle::lux Bundle (|> bundle.empty (bundle.install "is?" (binary (product.uncurried _.eq?/2))) (bundle.install "try" (unary ///runtime.lux//try)))) (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<op> paramO subjectO))] @@ -44,22 +44,22 @@ [i64::xor _.bit_xor/2] ) -(def: (i64::left_shifted [subjectO paramO]) +(def (i64::left_shifted [subjectO paramO]) Binary (_.arithmetic_shift/2 (_.remainder/2 (_.int +64) paramO) subjectO)) -(def: (i64::arithmetic_right_shifted [subjectO paramO]) +(def (i64::arithmetic_right_shifted [subjectO paramO]) Binary (_.arithmetic_shift/2 (|> paramO (_.remainder/2 (_.int +64)) (_.*/2 (_.int -1))) subjectO)) -(def: (i64::logical_right_shifted [subjectO paramO]) +(def (i64::logical_right_shifted [subjectO paramO]) Binary (///runtime.i64//logical_right_shifted (_.remainder/2 (_.int +64) paramO) subjectO)) (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (|> subjectO (<op> paramO)))] @@ -71,7 +71,7 @@ ) (with_template [<name> <op>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<op> paramO subjectO))] @@ -88,7 +88,7 @@ ) (with_template [<name> <cmp>] - [(def: (<name> [subjectO paramO]) + [(def (<name> [subjectO paramO]) Binary (<cmp> paramO subjectO))] @@ -96,9 +96,9 @@ [i64::< _.</2] ) -(def: i64::char (|>> _.integer->char/1 _.string/1)) +(def i64::char (|>> _.integer->char/1 _.string/1)) -(def: bundle::i64 +(def bundle::i64 Bundle (<| (bundle.prefix "i64") (|> bundle.empty @@ -118,7 +118,7 @@ (bundle.install "f64" (unary (|>> (_.//2 (_.float +1.0))))) (bundle.install "char" (unary i64::char))))) -(def: bundle::f64 +(def bundle::f64 Bundle (<| (bundle.prefix "f64") (|> bundle.empty @@ -133,15 +133,15 @@ (bundle.install "encode" (unary _.number->string/1)) (bundle.install "decode" (unary ///runtime.frac//decode))))) -(def: (text::char [subjectO paramO]) +(def (text::char [subjectO paramO]) Binary (_.string/1 (_.string_ref/2 subjectO paramO))) -(def: (text::clip [subjectO startO endO]) +(def (text::clip [subjectO startO endO]) Trinary (_.substring/3 subjectO startO endO)) -(def: bundle::text +(def bundle::text Bundle (<| (bundle.prefix "text") (|> bundle.empty @@ -152,16 +152,16 @@ (bundle.install "char" (binary text::char)) (bundle.install "clip" (trinary text::clip))))) -(def: (io::log input) +(def (io::log input) Unary (_.begin (list (_.display/1 input) _.newline/0))) -(def: (void code) +(def (void code) (-> Expression Computation) (_.begin (list code (_.string //////synthesis.unit)))) -(def: bundle::io +(def bundle::io Bundle (<| (bundle.prefix "io") (|> bundle.empty @@ -170,7 +170,7 @@ (bundle.install "exit" (unary _.exit/1)) (bundle.install "current-time" (nullary (function (_ _) (///runtime.io//current_time (_.string //////synthesis.unit)))))))) -(def: .public bundle +(def .public bundle Bundle (<| (bundle.prefix "lux") (|> bundle::lux diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux index 47297cb47..8f07bec50 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/function.lux @@ -29,18 +29,18 @@ [reference [variable (.only Register Variable)]]]]]]) -(def: .public (apply expression archive [functionS argsS+]) +(def .public (apply expression archive [functionS argsS+]) (Generator (Application Synthesis)) (do [! ///////phase.monad] [functionO (expression archive functionS) argsO+ (monad.each ! (expression archive) argsS+)] (in (_.apply argsO+ functionO)))) -(def: capture +(def capture (-> Register Var) (|>> (///reference.foreign //reference.system) as_expected)) -(def: (with_closure inits function_definition) +(def (with_closure inits function_definition) (-> (List Expression) Computation (Operation Computation)) (///////phase#in (case inits @@ -54,13 +54,13 @@ {.#None}]) (_.apply inits))))) -(def: @curried (_.var "curried")) -(def: @missing (_.var "missing")) +(def @curried (_.var "curried")) +(def @missing (_.var "missing")) -(def: input +(def input (|>> ++ //case.register)) -(def: .public (function expression archive [environment arity bodyS]) +(def .public (function expression archive [environment arity bodyS]) (Generator (Abstraction Synthesis)) (do [! ///////phase.monad] [[function_name bodyO] (/////generation.with_new_context archive diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux index 8ca9af784..cd2ebc5af 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/loop.lux @@ -33,10 +33,10 @@ [reference [variable (.only Register)]]]]]]]) -(def: @scope +(def @scope (_.var "scope")) -(def: .public (scope expression archive [start initsS+ bodyS]) +(def .public (scope expression archive [start initsS+ bodyS]) (Generator (Scope Synthesis)) (case initsS+ ... function/false/non-independent loop @@ -56,7 +56,7 @@ bodyO)]) (_.apply initsO+ @scope)))))) -(def: .public (again expression archive argsS+) +(def .public (again expression archive argsS+) (Generator (List Synthesis)) (do [! ///////phase.monad] [@scope /////generation.anchor diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/primitive.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/primitive.lux index 0772c64bc..cba7e79d6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/primitive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/primitive.lux @@ -5,7 +5,7 @@ ["_" scheme (.only Expression)]]]]) (with_template [<name> <type> <code>] - [(def: .public <name> + [(def .public <name> (-> <type> Expression) <code>)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/reference.lux index 7e0b61970..cef4fe09f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/reference.lux @@ -6,8 +6,8 @@ [/// [reference (.only System)]]) -(def: .public system +(def .public system (System Expression) (implementation - (def: constant _.var) - (def: variable _.var))) + (def constant _.var) + (def variable _.var))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux index ecac319c2..8d145794e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/runtime.lux @@ -39,7 +39,7 @@ [archive (.only Output Archive) ["[0]" artifact (.only Registry)]]]]]]) -(def: module_id +(def module_id 0) (with_template [<name> <base>] @@ -55,10 +55,10 @@ (type: .public (Generator i) (-> Phase Archive i (Operation Expression))) -(def: .public unit +(def .public unit (_.string /////synthesis.unit)) -(def: .public with_vars +(def .public with_vars (syntax (_ [vars (<code>.tuple (<>.some <code>.local)) body <code>.any]) (do [! meta.monad] @@ -71,7 +71,7 @@ list.together))] (~ body)))))))) -(def: runtime: +(def runtime: (syntax (_ [declaration (<>.or <code>.local (<code>.form (<>.and <code>.local (<>.some <code>.local)))) @@ -84,11 +84,11 @@ (case declaration {.#Left name} (let [g!name (code.local name)] - (in (list (` (def: .public (~ g!name) + (in (list (` (def .public (~ g!name) Var (~ runtime_name))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) _.Computation (_.define_constant (~ runtime_name) (~ code))))))) @@ -97,17 +97,17 @@ inputsC (list#each code.local inputs) inputs_typesC (list#each (function.constant (` _.Expression)) inputs)] - (in (list (` (def: .public ((~ g!name) (~+ inputsC)) + (in (list (` (def .public ((~ g!name) (~+ inputsC)) (-> (~+ inputs_typesC) _.Computation) (_.apply (list (~+ inputsC)) (~ runtime_name)))) - (` (def: (~ (code.local (format "@" name))) + (` (def (~ (code.local (format "@" name))) _.Computation (..with_vars [(~+ inputsC)] (_.define_function (~ runtime_name) [(list (~+ inputsC)) {.#None}] (~ code)))))))))))))) -(def: last_index +(def last_index (-> Expression Computation) (|>> _.length/1 (_.-/2 (_.int +1)))) @@ -139,7 +139,7 @@ @slice)))) ))) -(def: (variant' tag last? value) +(def (variant' tag last? value) (-> Expression Expression Expression Computation) (all _.cons/2 tag @@ -149,7 +149,7 @@ (runtime: (sum//make tag last? value) (variant' tag last? value)) -(def: .public (variant [lefts right? value]) +(def .public (variant [lefts right? value]) (-> (Variant Expression) Computation) (..sum//make (_.int (.int lefts)) (_.bool right?) value)) @@ -176,26 +176,26 @@ (variant' (|> sum_tag (_.-/2 wanted_tag)) sum_flag sum_value)) no_match)))) -(def: runtime//adt +(def runtime//adt Computation (_.begin (list @tuple//left @tuple//right @sum//get @sum//make))) -(def: .public none +(def .public none Computation (|> ..unit [0 #0] variant)) -(def: .public some +(def .public some (-> Expression Computation) (|>> [1 #1] ..variant)) -(def: .public left +(def .public left (-> Expression Computation) (|>> [0 #0] ..variant)) -(def: .public right +(def .public right (-> Expression Computation) (|>> [1 #1] ..variant)) @@ -229,27 +229,27 @@ (_.apply/2 @loop (_.cdr/1 @input) (..some (_.vector/* (list (_.car/1 @input) @output))))))]) (_.apply/2 @loop (_.reverse/1 program_args) ..none)))) -(def: runtime//lux +(def runtime//lux Computation (_.begin (list @lux//try @lux//program_args))) -(def: i64//+limit (_.manual "+9223372036854775807" +(def i64//+limit (_.manual "+9223372036854775807" ... "+0x7FFFFFFFFFFFFFFF" )) -(def: i64//-limit (_.manual "-9223372036854775808" +(def i64//-limit (_.manual "-9223372036854775808" ... "-0x8000000000000000" )) -(def: i64//+iteration (_.manual "+18446744073709551616" +(def i64//+iteration (_.manual "+18446744073709551616" ... "+0x10000000000000000" )) -(def: i64//-iteration (_.manual "-18446744073709551616" +(def i64//-iteration (_.manual "-18446744073709551616" ... "-0x10000000000000000" )) -(def: i64//+cap (_.manual "+9223372036854775808" +(def i64//+cap (_.manual "+9223372036854775808" ... "+0x8000000000000000" )) -(def: i64//-cap (_.manual "-9223372036854775809" +(def i64//-cap (_.manual "-9223372036854775809" ... "-0x8000000000000001" )) @@ -272,7 +272,7 @@ (_.arithmetic_shift/2 (_.remainder/2 (_.int +64) param)) ..i64//64)) -(def: as_nat +(def as_nat (_.remainder/2 ..i64//+iteration)) (runtime: (i64//right_shifted shift subject) @@ -295,7 +295,7 @@ (runtime: (i64//division param subject) (|> subject (_.//2 param) _.truncate/1 ..i64//64)) -(def: runtime//i64 +(def runtime//i64 Computation (_.begin (list @i64//64 @i64//left_shifted @@ -315,7 +315,7 @@ ..none (..some @output)))))) -(def: runtime//f64 +(def runtime//f64 Computation (_.begin (list @f64//decode))) @@ -332,7 +332,7 @@ (runtime: (text//char index text) (_.char->integer/1 (_.string_ref/2 text index))) -(def: runtime//text +(def runtime//text (_.begin (list @text//index @text//clip @text//char))) @@ -341,13 +341,13 @@ (_.begin (list (_.vector_set!/3 array idx value) array))) -(def: runtime//array +(def runtime//array Computation (all _.then @array//write )) -(def: runtime +(def runtime Computation (_.begin (list @slice runtime//lux @@ -358,7 +358,7 @@ runtime//array ))) -(def: .public generate +(def .public generate (Operation [Registry Output]) (do ///////phase.monad [_ (/////generation.execute! ..runtime) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux index ec1611ddf..fec696893 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/structure.lux @@ -17,7 +17,7 @@ ["//[1]" /// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]) -(def: .public (tuple expression archive elemsS+) +(def .public (tuple expression archive elemsS+) (Generator (Tuple Synthesis)) (case elemsS+ {.#End} @@ -31,7 +31,7 @@ (monad.each ///////phase.monad (expression archive)) (///////phase#each _.vector/*)))) -(def: .public (variant expression archive [lefts right? valueS]) +(def .public (variant expression archive [lefts right? valueS]) (Generator (Variant Synthesis)) (let [tag (if right? (++ lefts) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux index de5d4c9e4..3e7102696 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis.lux @@ -29,7 +29,7 @@ [reference (.only) [variable (.only)]]]]]]) -(def: (simple analysis) +(def (simple analysis) (-> ///simple.Simple /simple.Simple) (case analysis {///simple.#Unit} @@ -49,7 +49,7 @@ [///simple.#Int /simple.#I64] [///simple.#Rev /simple.#I64]))) -(def: (optimization archive) +(def (optimization archive) Phase (function (optimization' analysis) (case analysis @@ -102,7 +102,7 @@ (phase.result' state)))))) ))) -(def: .public (phase archive analysis) +(def .public (phase archive analysis) Phase (do phase.monad [synthesis (..optimization archive analysis)] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux index 218ece022..4f772b16c 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/case.lux @@ -37,11 +37,11 @@ [meta [archive (.only Archive)]]]]]) -(def: clean_up +(def clean_up (-> Path Path) (|>> {/.#Seq {/.#Pop}})) -(def: (path' pattern end? thenC) +(def (path' pattern end? thenC) (-> Pattern Bit (Operation Path) (Operation Path)) (case pattern {///pattern.#Simple simple} @@ -98,11 +98,11 @@ (list.reversed (list.enumeration tuple)))) )) -(def: (path archive synthesize pattern bodyA) +(def (path archive synthesize pattern bodyA) (-> Archive Phase Pattern Analysis (Operation Path)) (path' pattern true (///#each (|>> {/.#Then}) (synthesize archive bodyA)))) -(def: (weave_branch weave equivalence [new_test new_then] [[old_test old_then] old_tail]) +(def (weave_branch weave equivalence [new_test new_then] [[old_test old_then] old_tail]) (All (_ a) (-> (-> Path Path Path) (Equivalence a) [a Path] (/.Fork a Path) (/.Fork a Path))) @@ -116,13 +116,13 @@ {.#Item old_item} {.#Item (weave_branch weave equivalence [new_test new_then] old_item)})])) -(def: (weave_fork weave equivalence new_fork old_fork) +(def (weave_fork weave equivalence new_fork old_fork) (All (_ a) (-> (-> Path Path Path) (Equivalence a) (/.Fork a Path) (/.Fork a Path) (/.Fork a Path))) (list#mix (..weave_branch weave equivalence) old_fork {.#Item new_fork})) -(def: (weave new old) +(def (weave new old) (-> Path Path Path) (with_expansions [<default> (these {/.#Alt old new})] (case [new old] @@ -199,7 +199,7 @@ _ <default>))) -(def: (get patterns @selection) +(def (get patterns @selection) (-> (///complex.Tuple Pattern) Register (List Member)) (loop (again [lefts 0 patterns patterns]) @@ -236,52 +236,52 @@ _ <failure>))))) -(def: .public (synthesize_case synthesize archive input [[headP headA] tailPA+]) +(def .public (synthesize_case synthesize archive input [[headP headA] tailPA+]) (-> Phase Archive Synthesis Match (Operation Synthesis)) (do [! ///.monad] [headSP (path archive synthesize headP headA) tailSP+ (monad.each ! (product.uncurried (path archive synthesize)) tailPA+)] (in (/.branch/case [input (list#mix weave headSP tailSP+)])))) -(def: !masking +(def !masking (template (_ <variable> <output>) [[[{///pattern.#Bind <variable>} {///analysis.#Reference (///reference.local <output>)}] (list)]])) -(def: .public (synthesize_exec synthesize archive before after) +(def .public (synthesize_exec synthesize archive before after) (-> Phase Archive Synthesis Analysis (Operation Synthesis)) (do ///.monad [after (synthesize archive after)] (in (/.branch/exec [before after])))) -(def: .public (synthesize_let synthesize archive input @variable body) +(def .public (synthesize_let synthesize archive input @variable body) (-> Phase Archive Synthesis Register Analysis (Operation Synthesis)) (do ///.monad [body (/.with_new_local (synthesize archive body))] (in (/.branch/let [input @variable body])))) -(def: .public (synthesize_masking synthesize archive input @variable @output) +(def .public (synthesize_masking synthesize archive input @variable @output) (-> Phase Archive Synthesis Register Register (Operation Synthesis)) (if (n.= @variable @output) (///#in input) (..synthesize_let synthesize archive input @variable {///analysis.#Reference (///reference.local @output)}))) -(def: .public (synthesize_if synthesize archive test then else) +(def .public (synthesize_if synthesize archive test then else) (-> Phase Archive Synthesis Analysis Analysis (Operation Synthesis)) (do ///.monad [then (synthesize archive then) else (synthesize archive else)] (in (/.branch/if [test then else])))) -(def: !get +(def !get (template (_ <patterns> <output>) [[[(///pattern.tuple <patterns>) {///analysis.#Reference (///reference.local <output>)}] (.list)]])) -(def: .public (synthesize_get synthesize archive input patterns @member) +(def .public (synthesize_get synthesize archive input patterns @member) (-> Phase Archive Synthesis (///complex.Tuple Pattern) Register (Operation Synthesis)) (case (..get patterns @member) {.#End} @@ -295,7 +295,7 @@ _ (///#in (/.branch/get [path input]))))) -(def: .public (synthesize synthesize^ [headB tailB+] archive inputA) +(def .public (synthesize synthesize^ [headB tailB+] archive inputA) (-> Phase Match Phase) (do [! ///.monad] [inputS (synthesize^ archive inputA)] @@ -335,7 +335,7 @@ match (..synthesize_case synthesize^ archive inputS match)))) -(def: .public (count_pops path) +(def .public (count_pops path) (-> Path [Nat Path]) (case path (pattern (/.path/seq {/.#Pop} path')) @@ -345,7 +345,7 @@ _ [0 path])) -(def: .public pattern_matching_error +(def .public pattern_matching_error "Invalid expression for pattern-matching.") (type: .public Storage @@ -353,7 +353,7 @@ [#bindings (Set Register) #dependencies (Set Variable)])) -(def: empty +(def empty Storage [#bindings (set.empty n.hash) #dependencies (set.empty ///reference/variable.hash)]) @@ -364,7 +364,7 @@ ... since the variable will exist beforehand, so no closure will need ... to be created for it. ... Apply this trick to JS, Python et al. -(def: .public (storage path) +(def .public (storage path) (-> Path Storage) (loop (for_path [path path path_storage ..empty]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 8f29f5d0b..89af418b6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -36,21 +36,21 @@ "Foreign" (%.nat foreign) "Environment" (exception.listing /.%synthesis environment))) -(def: arity_arguments +(def arity_arguments (-> Arity (List Synthesis)) (|>> -- (enum.range n.enum 1) (list#each (|>> /.variable/local)))) -(def: .public self_reference +(def .public self_reference (template (self_reference) [(/.variable/local 0)])) -(def: (expanded_nested_self_reference arity) +(def (expanded_nested_self_reference arity) (-> Arity Synthesis) (/.function/apply [(..self_reference) (arity_arguments arity)])) -(def: .public (apply phase) +(def .public (apply phase) (-> Phase Phase) (function (_ archive exprA) (let [[funcA argsA] (////analysis.reification exprA)] @@ -86,7 +86,7 @@ _ (in <apply>))))))) -(def: (find_foreign environment register) +(def (find_foreign environment register) (-> (Environment Synthesis) Register (Operation Synthesis)) (case (list.item register environment) {.#Some aliased} @@ -95,7 +95,7 @@ {.#None} (phase.except ..cannot_find_foreign_variable_in_environment [register environment]))) -(def: (grow_path grow path) +(def (grow_path grow path) (-> (-> Synthesis (Operation Synthesis)) Path (Operation Path)) (case path {/.#Bind register} @@ -142,7 +142,7 @@ _ (phase#in path))) -(def: (grow environment expression) +(def (grow environment expression) (-> (Environment Synthesis) Synthesis (Operation Synthesis)) (case expression {/.#Structure structure} @@ -255,7 +255,7 @@ {/.#Simple _} (phase#in expression))) -(def: .public (abstraction phase environment archive bodyA) +(def .public (abstraction phase environment archive bodyA) (-> Phase (Environment Analysis) Phase) (do [! phase.monad] [environment (monad.each ! (phase archive) environment) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux index 778ba2900..f3c5fb252 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/loop.lux @@ -25,11 +25,11 @@ (type: .public (Transform a) (-> a (Maybe a))) -(def: .public (register_optimization offset) +(def .public (register_optimization offset) (-> Register (-> Register Register)) (|>> -- (n.+ offset))) -(def: (path_optimization body_optimization offset) +(def (path_optimization body_optimization offset) (-> (Transform Synthesis) Register (Transform Path)) (function (again path) (case path @@ -77,7 +77,7 @@ _ {.#Some path}))) -(def: (body_optimization true_loop? offset scope_environment arity expr) +(def (body_optimization true_loop? offset scope_environment arity expr) (-> Bit Register (Environment Synthesis) Arity (Transform Synthesis)) (loop (again [return? true expr expr]) @@ -211,7 +211,7 @@ (monad.each maybe.monad (again false)) (maybe#each (|>> [name] {/.#Extension})))))) -(def: .public (optimization true_loop? offset inits functionS) +(def .public (optimization true_loop? offset inits functionS) (-> Bit Register (List Synthesis) Abstraction (Maybe [Register (List Synthesis) Synthesis])) (|> (the /.#body functionS) (body_optimization true_loop? offset (the /.#environment functionS) (the /.#arity functionS)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux index 51de85771..1ca58edd0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/synthesis/variable.lux @@ -30,7 +30,7 @@ ["[0]" reference (.only) ["[0]" variable (.only Register Variable)]]]]) -(def: (prune redundant register) +(def (prune redundant register) (-> Register Register Register) (if (n.> redundant register) (-- register) @@ -39,7 +39,7 @@ (type: (Remover a) (-> Register (-> a a))) -(def: (remove_local_from_path remove_local redundant) +(def (remove_local_from_path remove_local redundant) (-> (Remover Synthesis) (Remover Path)) (function (again path) (case path @@ -98,7 +98,7 @@ {/.#Then (remove_local redundant then)} ))) -(def: (remove_local_from_variable redundant variable) +(def (remove_local_from_variable redundant variable) (Remover Variable) (case variable {variable.#Local register} @@ -107,7 +107,7 @@ {variable.#Foreign register} variable)) -(def: (remove_local redundant) +(def (remove_local redundant) (Remover Synthesis) (function (again synthesis) (case synthesis @@ -178,14 +178,14 @@ (type: Redundancy (Dictionary Register Bit)) -(def: initial +(def initial Redundancy (dictionary.empty n.hash)) -(def: redundant! true) -(def: necessary! false) +(def redundant! true) +(def necessary! false) -(def: (extended offset amount redundancy) +(def (extended offset amount redundancy) (-> Register Nat Redundancy [(List Register) Redundancy]) (let [extension (|> amount list.indices (list#each (n.+ offset)))] [extension @@ -194,14 +194,14 @@ redundancy extension)])) -(def: (default arity) +(def (default arity) (-> Arity Redundancy) (product.right (..extended 0 (++ arity) ..initial))) (type: (Optimization a) (-> [Redundancy a] (Try [Redundancy a]))) -(def: (list_optimization optimization) +(def (list_optimization optimization) (All (_ a) (-> (Optimization a) (Optimization (List a)))) (function (again [redundancy values]) (case values @@ -225,7 +225,7 @@ [unknown_register] ) -(def: (declare register redundancy) +(def (declare register redundancy) (-> Register Redundancy (Try Redundancy)) (case (dictionary.value register redundancy) {.#None} @@ -234,7 +234,7 @@ {.#Some _} (exception.except ..redundant_declaration [register]))) -(def: (observe register redundancy) +(def (observe register redundancy) (-> Register Redundancy (Try Redundancy)) (case (dictionary.value register redundancy) {.#None} @@ -243,7 +243,7 @@ {.#Some _} {try.#Success (dictionary.has register ..necessary! redundancy)})) -(def: (format redundancy) +(def (format redundancy) (%.Format Redundancy) (|> redundancy dictionary.entries @@ -251,7 +251,7 @@ (%.format (%.nat register) ": " (%.bit redundant?)))) (text.interposed ", "))) -(def: (path_optimization optimization) +(def (path_optimization optimization) (-> (Optimization Synthesis) (Optimization Path)) (function (again [redundancy path]) (case path @@ -329,7 +329,7 @@ (in [redundancy {/.#Then then}])) ))) -(def: (optimization' [redundancy synthesis]) +(def (optimization' [redundancy synthesis]) (Optimization Synthesis) (with_expansions [<no_op> (these {try.#Success [redundancy synthesis]})] @@ -449,7 +449,7 @@ (in [redundancy {/.#Extension name inputs}]))))) -(def: .public optimization +(def .public optimization (-> Synthesis (Try Synthesis)) (|>> [..initial] optimization' diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux index fcf6e4cdc..625448c47 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/program.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/program.lux @@ -24,7 +24,7 @@ (type: .public (Program expression directive) (-> unit.ID expression directive)) -(def: .public name +(def .public name Text "") @@ -32,7 +32,7 @@ (exception.report "Modules" (exception.listing %.text modules))) -(def: .public (context archive) +(def .public (context archive) (-> Archive (Try unit.ID)) (do [! try.monad] [registries (|> archive diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux index 3dcd579c9..054c8eeb2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -54,16 +54,16 @@ ["[0]" rev] ["[0]" frac]]]]]) -(def: declaration_name +(def declaration_name (syntax (_ [[name parameters] (<code>.form (<>.and <code>.any (<>.some <code>.any)))]) (in (list name)))) -(def: inline: +(def inlined (template (_ <declaration> <type> <body>) - [(for @.python (def: <declaration> <type> <body>) + [(for @.python (def <declaration> <type> <body>) ... TODO: No longer skip inlining Lua after Rembulan isn't being used anymore. - @.lua (def: <declaration> <type> <body>) - (`` (def: (~~ (..declaration_name <declaration>)) + @.lua (def <declaration> <type> <body>) + (`` (def (~~ (..declaration_name <declaration>)) (template <declaration> [<body>]))))])) @@ -84,7 +84,7 @@ Nat) (with_template [<extension> <diff> <name>] - [(def: <name> + [(def <name> (template (_ value) [(<extension> <diff> value)]))] @@ -93,12 +93,12 @@ ["lux i64 -" 1 !--] ) -(def: !clip +(def !clip (template (_ from to text) [("lux text clip" from (n.- from to) text)])) (with_template [<name> <extension>] - [(def: <name> + [(def <name> (template (_ reference subject) [(<extension> reference subject)]))] @@ -107,7 +107,7 @@ ) (with_template [<name> <extension>] - [(def: <name> + [(def <name> (template (_ param subject) [(<extension> param subject)]))] @@ -118,17 +118,17 @@ (type: .public Aliases (Dictionary Text Text)) -(def: .public no_aliases +(def .public no_aliases Aliases (dictionary.empty text.hash)) -(def: .public prelude +(def .public prelude .prelude) -(def: .public text_delimiter text.double_quote) +(def .public text_delimiter text.double_quote) (with_template [<char> <definition>] - [(def: .public <definition> <char>)] + [(def .public <definition> <char>)] ... Form delimiters ["(" open_form] @@ -165,9 +165,9 @@ (exception.report "Module" (%.text module))) -(def: amount_of_input_shown 64) +(def amount_of_input_shown 64) -(inline: (input_at start input) +(inlined (input_at start input) (-> Offset Text Text) (let [end (|> start (!n/+ amount_of_input_shown) (n.min ("lux text size" input)))] (!clip start end input))) @@ -187,12 +187,12 @@ (exception.report "Text" (%.text text))) -(def: !failure +(def !failure (template (_ parser where offset source_code) [{.#Left [[where offset source_code] (exception.error ..unrecognized_input [where (%.symbol (symbol parser)) source_code offset])]}])) -(def: !end_of_file +(def !end_of_file (template (_ where offset source_code current_module) [{.#Left [[where offset source_code] (exception.error ..end_of_file current_module)]}])) @@ -200,7 +200,7 @@ (type: (Parser a) (-> Source (Either [Source Text] [Source a]))) -(def: !with_char+ +(def !with_char+ (template (_ @source_code_size @source_code @offset @char @else @body) [(if (!i/< (as Int @source_code_size) (as Int @offset)) @@ -208,11 +208,11 @@ @body) @else)])) -(def: !with_char +(def !with_char (template (_ @source_code @offset @char @else @body) [(!with_char+ ("lux text size" @source_code) @source_code @offset @char @else @body)])) -(def: !letE +(def !letE (template (_ <binding> <computation> <body>) [(case <computation> {.#Right <binding>} @@ -222,30 +222,30 @@ <<otherwise>> (as_expected <<otherwise>>))])) -(def: !horizontal +(def !horizontal (template (_ where offset source_code) [[(revised .#column ++ where) (!++ offset) source_code]])) -(inline: (!new_line where) +(inlined (!new_line where) (-> Location Location) (let [[where::file where::line where::column] where] [where::file (!++ where::line) 0])) -(inline: (!forward length where) +(inlined (!forward length where) (-> Nat Location Location) (let [[where::file where::line where::column] where] [where::file where::line (!n/+ length where::column)])) -(def: !vertical +(def !vertical (template (_ where offset source_code) [[(!new_line where) (!++ offset) source_code]])) (with_template [<name> <close> <tag>] - [(inline: (<name> parse where offset source_code) + [(inlined (<name> parse where offset source_code) (-> (Parser Code) Location Offset Text (Either [Source Text] [Source Code])) (loop (again [source (is Source [(!forward 1 where) offset source_code]) @@ -268,7 +268,7 @@ [tuple_parser ..close_tuple .#Tuple] ) -(def: !guarantee_no_new_lines +(def !guarantee_no_new_lines (template (_ where offset source_code content body) [(case ("lux text index" 0 (static text.new_line) content) {.#None} @@ -278,7 +278,7 @@ {.#Left [[where offset source_code] (exception.error ..text_cannot_contain_new_lines content)]})])) -(def: (text_parser where offset source_code) +(def (text_parser where offset source_code) (-> Location Offset Text (Either [Source Text] [Source Code])) (case ("lux text index" offset (static ..text_delimiter) source_code) {.#Some g!end} @@ -306,7 +306,7 @@ [..open_tuple] [..close_tuple] [..text_delimiter]) <digit_separator> (static ..digit_separator)] - (def: !if_digit? + (def !if_digit? (template (_ @char @then @else) [("lux syntax char case!" @char [[<digits>] @@ -315,7 +315,7 @@ ... else @else)])) - (def: !if_digit?+ + (def !if_digit?+ (template (_ @char @then @else_options @else) [(`` ("lux syntax char case!" @char [[<digits> <digit_separator>] @@ -326,7 +326,7 @@ ... else @else))])) - (`` (def: !if_symbol_char?|tail + (`` (def !if_symbol_char?|tail (template (_ @char @then @else) [("lux syntax char case!" @char [[<non_symbol_chars>] @@ -335,7 +335,7 @@ ... else @then)]))) - (`` (def: !if_symbol_char?|head + (`` (def !if_symbol_char?|head (template (_ @char @then @else) [("lux syntax char case!" @char [[<non_symbol_chars> <digits>] @@ -345,7 +345,7 @@ @then)]))) ) -(def: !number_output +(def !number_output (template (_ <source_code> <start> <end> <codec> <tag>) [(case (|> <source_code> (!clip <start> <end>) @@ -362,7 +362,7 @@ {.#Left [[where <start> <source_code>] error]})])) -(def: no_exponent +(def no_exponent Offset 0) @@ -375,7 +375,7 @@ [..positive_sign] [..negative_sign])] - (inline: (frac_parser source_code//size start where offset source_code) + (inlined (frac_parser source_code//size start where offset source_code) (-> Nat Nat Location Offset Text (Either [Source Text] [Source Code])) (loop (again [end offset @@ -400,7 +400,7 @@ <frac_output>)))) - (inline: (signed_parser source_code//size start where offset source_code) + (inlined (signed_parser source_code//size start where offset source_code) (-> Nat Nat Location Offset Text (Either [Source Text] [Source Code])) (loop (again [end offset]) @@ -415,7 +415,7 @@ ) (with_template [<parser> <codec> <tag>] - [(inline: (<parser> source_code//size start where offset source_code) + [(inlined (<parser> source_code//size start where offset source_code) (-> Nat Nat Location Offset Text (Either [Source Text] [Source Code])) (loop (again [g!end offset]) @@ -429,7 +429,7 @@ [rev_parser rev.decimal .#Rev] ) -(def: !signed_parser +(def !signed_parser (template (_ source_code//size offset where source_code @aliases @end) [(<| (let [g!offset/1 (!++ offset)]) (!with_char+ source_code//size source_code g!offset/1 g!char/1 @end) @@ -441,7 +441,7 @@ end source_code] (!clip start end source_code)]}] - (inline: (symbol_part_parser start where offset source_code) + (inlined (symbol_part_parser start where offset source_code) (-> Nat Location Offset Text (Either [Source Text] [Source Text])) (let [source_code//size ("lux text size" source_code)] @@ -451,14 +451,14 @@ (again (!++ end)) <output>)))))) -(def: !half_symbol_parser +(def !half_symbol_parser (template (_ @offset @char @module) [(!if_symbol_char?|head @char (!letE [source' symbol] (..symbol_part_parser @offset (!forward 1 where) (!++ @offset) source_code) {.#Right [source' [@module symbol]]}) (!failure ..!half_symbol_parser where @offset source_code))])) -(`` (def: (short_symbol_parser source_code//size current_module [where offset/0 source_code]) +(`` (def (short_symbol_parser source_code//size current_module [where offset/0 source_code]) (-> Nat Text (Parser Symbol)) (<| (!with_char+ source_code//size source_code offset/0 char/0 (!end_of_file where offset/0 source_code current_module)) @@ -469,13 +469,13 @@ (!half_symbol_parser offset/1 char/1 current_module)) (!half_symbol_parser offset/0 char/0 (static ..prelude)))))) -(def: !short_symbol_parser +(def !short_symbol_parser (template (_ source_code//size @current_module @source @where @tag) [(!letE [source' symbol] (..short_symbol_parser source_code//size @current_module @source) {.#Right [source' [@where {@tag symbol}]]})])) (with_expansions [<simple> (these {.#Right [source' ["" simple]]})] - (`` (def: (full_symbol_parser aliases start source) + (`` (def (full_symbol_parser aliases start source) (-> Aliases Offset (Parser Symbol)) (<| (!letE [source' simple] (let [[where offset source_code] source] (..symbol_part_parser start where offset source_code))) @@ -493,13 +493,13 @@ complex]]})) <simple>))))) -(def: !full_symbol_parser +(def !full_symbol_parser (template (_ @offset @source @where @aliases @tag) [(!letE [source' full_symbol] (..full_symbol_parser @aliases @offset @source) {.#Right [source' [@where {@tag full_symbol}]]})])) ... TODO: Grammar macro for specifying syntax. -... (def: lux_grammar +... (def lux_grammar ... (grammar [expression "..."] ... [form "(" [#* expression] ")"])) @@ -508,18 +508,18 @@ <move_2> (these [(!forward 1 where) (!++/2 offset/0) source_code]) <again> (these (parse current_module aliases source_code//size))] - (def: !close + (def !close (template (_ closer) [{.#Left [<move_1> closer]}])) - (def: (bit_syntax value [where offset/0 source_code]) + (def (bit_syntax value [where offset/0 source_code]) (-> Bit (Parser Code)) {.#Right [[(revised .#column (|>> !++/2) where) (!++/2 offset/0) source_code] [where {.#Bit value}]]}) - (def: .public (parse current_module aliases source_code//size) + (def .public (parse current_module aliases source_code//size) (-> Text Aliases Nat (Parser Code)) ... The "exec []" is only there to avoid function fusion. ... This is to preserve the loop as much as possible and keep it tight. diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux index c4a772695..722029eb2 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -50,11 +50,11 @@ ... https://en.wikipedia.org/wiki/Currying #currying? Bit])) -(def: .public fresh_resolver +(def .public fresh_resolver Resolver (dictionary.empty variable.hash)) -(def: .public init +(def .public init State [#locals 0 #currying? false]) @@ -145,12 +145,12 @@ (type: .public Path (Path' Synthesis)) -(def: .public path/pop +(def .public path/pop Path {#Pop}) (with_template [<name> <kind>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(.<| {..#Access} {<kind>} @@ -161,7 +161,7 @@ ) (with_template [<name> <access> <lefts> <right?>] - [(def: .public <name> + [(def .public <name> (template (<name> lefts right?) [(.<| {..#Access} {<access>} @@ -173,7 +173,7 @@ ) (with_template [<access> <side> <name>] - [(def: .public <name> + [(def .public <name> (template (<name> lefts) [(<access> lefts <side>)]))] @@ -185,7 +185,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [{<tag> content}]))] @@ -194,7 +194,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> left right) [{<tag> left right}]))] @@ -208,16 +208,16 @@ (type: .public Apply (Apply' Synthesis)) -(def: .public unit +(def .public unit Text "") (with_template [<with> <query> <tag> <type>] - [(def: .public (<with> value) + [(def .public (<with> value) (-> <type> (All (_ a) (-> (Operation a) (Operation a)))) (extension.temporary (has <tag> value))) - (def: .public <query> + (def .public <query> (Operation <type>) (extension.read (the <tag>)))] @@ -225,14 +225,14 @@ [with_currying? currying? #currying? Bit] ) -(def: .public with_new_local +(def .public with_new_local (All (_ a) (-> (Operation a) (Operation a))) (<<| (do phase.monad [locals ..locals]) (..with_locals (++ locals)))) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [{..#Simple {<tag> content}}]))] @@ -243,7 +243,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(.<| {..#Structure} {<tag>} @@ -254,7 +254,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(.<| {..#Reference} <tag> @@ -267,7 +267,7 @@ ) (with_template [<name> <family> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(.<| {..#Control} {<family>} @@ -287,7 +287,7 @@ [function/apply ..#Function ..#Apply] ) -(def: .public (%path' %then value) +(def .public (%path' %then value) (All (_ a) (-> (Format a) (Format (Path' a)))) (case value {#Pop} @@ -331,7 +331,7 @@ (|> (%then then) (text.enclosed ["(! " ")"])))) -(def: .public (%synthesis value) +(def .public (%synthesis value) (Format Synthesis) (case value {#Simple it} @@ -419,14 +419,14 @@ (format (%.text name) " ") (text.enclosed ["(" ")"])))) -(def: .public %path +(def .public %path (Format Path) (%path' %synthesis)) -(def: .public (path'_equivalence equivalence) +(def .public (path'_equivalence equivalence) (All (_ a) (-> (Equivalence a) (Equivalence (Path' a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Pop} {#Pop}] true @@ -466,13 +466,13 @@ _ false)))) -(def: (path'_hash super) +(def (path'_hash super) (All (_ a) (-> (Hash a) (Hash (Path' a)))) (implementation - (def: equivalence + (def equivalence (..path'_equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value {#Pop} 2 @@ -511,10 +511,10 @@ (n.* 29 (at super hash body)) )))) -(def: (branch_equivalence (open "#[0]")) +(def (branch_equivalence (open "#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Branch a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Let [reference_input reference_register reference_body]} {#Let [sample_input sample_register sample_body]}] @@ -541,13 +541,13 @@ _ false)))) -(def: (branch_hash super) +(def (branch_hash super) (All (_ a) (-> (Hash a) (Hash (Branch a)))) (implementation - (def: equivalence + (def equivalence (..branch_equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value {#Exec this that} (all n.* 2 @@ -577,10 +577,10 @@ (at (..path'_hash super) hash path)) )))) -(def: (loop_equivalence (open "/#[0]")) +(def (loop_equivalence (open "/#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Loop a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Scope [reference_start reference_inits reference_iteration]} {#Scope [sample_start sample_inits sample_iteration]}] @@ -594,13 +594,13 @@ _ false)))) -(def: (loop_hash super) +(def (loop_hash super) (All (_ a) (-> (Hash a) (Hash (Loop a)))) (implementation - (def: equivalence + (def equivalence (..loop_equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value {#Scope [start inits iteration]} (all n.* 2 @@ -613,10 +613,10 @@ (at (list.hash super) hash resets)) )))) -(def: (function_equivalence (open "#[0]")) +(def (function_equivalence (open "#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Function a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] [{#Abstraction [reference_environment reference_arity reference_body]} {#Abstraction [sample_environment sample_arity sample_body]}] @@ -632,13 +632,13 @@ _ false)))) -(def: (function_hash super) +(def (function_hash super) (All (_ a) (-> (Hash a) (Hash (Function a)))) (implementation - (def: equivalence + (def equivalence (..function_equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value {#Abstraction [environment arity body]} (all n.* 2 @@ -652,10 +652,10 @@ (at (list.hash super) hash arguments)) )))) -(def: (control_equivalence (open "#[0]")) +(def (control_equivalence (open "#[0]")) (All (_ a) (-> (Equivalence a) (Equivalence (Control a)))) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag> <equivalence>] [[{<tag> reference} {<tag> sample}] @@ -667,13 +667,13 @@ _ false)))) -(def: (control_hash super) +(def (control_hash super) (All (_ a) (-> (Hash a) (Hash (Control a)))) (implementation - (def: equivalence + (def equivalence (..control_equivalence (at super equivalence))) - (def: (hash value) + (def (hash value) (case value (^.with_template [<factor> <tag> <hash>] [{<tag> value} @@ -683,10 +683,10 @@ [5 #Function ..function_hash]) )))) -(def: .public equivalence +(def .public equivalence (Equivalence Synthesis) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag> <equivalence>] [[{<tag> reference'} {<tag> sample'}] @@ -700,16 +700,16 @@ _ false)))) -(def: .public path_equivalence +(def .public path_equivalence (Equivalence Path) (path'_equivalence equivalence)) -(def: .public hash +(def .public hash (Hash Synthesis) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (hash value) + (def (hash value) (let [again_hash [..equivalence hash]] (case value (^.with_template [<tag> <hash>] @@ -721,14 +721,14 @@ [#Control (..control_hash again_hash)] [#Extension (extension.hash again_hash)])))))) -(def: .public !bind_top +(def .public !bind_top (template (!bind_top register thenP) [(all ..path/seq {..#Bind register} {..#Pop} thenP)])) -(def: .public !multi_pop +(def .public !multi_pop (template (!multi_pop nextP) [(all ..path/seq {..#Pop} @@ -743,7 +743,7 @@ ... pattern-optimizations again, since a lot of BINDs will become POPs ... and thus will result in useless code being generated. (with_template [<name> <side>] - [(def: .public <name> + [(def .public <name> (template (<name> idx nextP) [(all ..path/seq (<side> idx) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access.lux index dba26b8af..76c9a0400 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access.lux @@ -17,7 +17,7 @@ {#Side Side} {#Member Member})) -(def: .public (format it) +(def .public (format it) (Format Access) (case it {#Side it} @@ -26,13 +26,13 @@ {#Member it} (/member.format it))) -(def: .public hash +(def .public hash (Hash Access) (all sum.hash /side.hash /member.hash )) -(def: .public equivalence +(def .public equivalence (Equivalence Access) (at ..hash equivalence)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/member.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/member.lux index 24482862a..ec159b99a 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/member.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/member.lux @@ -18,17 +18,17 @@ [#lefts Nat #right? Bit])) -(def: .public (format it) +(def .public (format it) (%.Format Member) (%.format "[" (%.nat (the #lefts it)) " " (%.bit (the #right? it)) "]")) -(def: .public hash +(def .public hash (Hash Member) (all product.hash nat.hash bit.hash )) -(def: .public equivalence +(def .public equivalence (Equivalence Member) (at ..hash equivalence)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/side.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/side.lux index 89dd5e86a..df1bda351 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/side.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/access/side.lux @@ -18,17 +18,17 @@ [#lefts Nat #right? Bit])) -(def: .public (format it) +(def .public (format it) (%.Format Side) (%.format "{" (%.nat (the #lefts it)) " " (%.bit (the #right? it)) "}")) -(def: .public hash +(def .public hash (Hash Side) (all product.hash nat.hash bit.hash )) -(def: .public equivalence +(def .public equivalence (Equivalence Side) (at ..hash equivalence)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux index 343619a25..3774c0319 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis/simple.lux @@ -26,7 +26,7 @@ {#F64 Frac} {#Text Text})) -(def: .public (format it) +(def .public (format it) (%.Format Simple) (case it (^.with_template [<pattern> <format>] @@ -39,10 +39,10 @@ {#I64 value} (%.int (.int value)))) -(def: .public equivalence +(def .public equivalence (Equivalence Simple) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag> <eq> <format>] [[{<tag> reference'} {<tag> sample'}] @@ -57,12 +57,12 @@ _ false)))) -(def: .public hash +(def .public hash (Hash Simple) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: hash + (def hash (|>> (pipe.case (^.with_template [<factor> <tag> <hash>] [{<tag> value'} diff --git a/stdlib/source/library/lux/tool/compiler/meta.lux b/stdlib/source/library/lux/tool/compiler/meta.lux index 4034a23c8..ef6e71986 100644 --- a/stdlib/source/library/lux/tool/compiler/meta.lux +++ b/stdlib/source/library/lux/tool/compiler/meta.lux @@ -4,6 +4,6 @@ [// [version (.only Version)]]) -(def: .public version +(def .public version Version 00,02,00) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/archive.lux index bdb87cb95..b3b213099 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive.lux @@ -76,16 +76,16 @@ [#next module.ID #resolver (Dictionary descriptor.Module [module.ID (Maybe (Entry Any))])]) - (def: next + (def next (-> Archive module.ID) (|>> representation (the #next))) - (def: .public empty + (def .public empty Archive (abstraction [#next 0 #resolver (dictionary.empty text.hash)])) - (def: .public (id module archive) + (def .public (id module archive) (-> descriptor.Module Archive (Try module.ID)) (let [(open "/[0]") (representation archive)] (case (dictionary.value module /#resolver) @@ -96,7 +96,7 @@ (exception.except ..unknown_document [module (dictionary.keys /#resolver)])))) - (def: .public (reserve module archive) + (def .public (reserve module archive) (-> descriptor.Module Archive (Try [module.ID Archive])) (let [(open "/[0]") (representation archive)] (case (dictionary.value module /#resolver) @@ -111,7 +111,7 @@ (revised #next ++) abstraction)]}))) - (def: .public (has module entry archive) + (def .public (has module entry archive) (-> descriptor.Module (Entry Any) Archive (Try Archive)) (let [(open "/[0]") (representation archive)] (case (dictionary.value module /#resolver) @@ -131,7 +131,7 @@ {.#None} (exception.except ..module_must_be_reserved_before_it_can_be_added [module])))) - (def: .public entries + (def .public entries (-> Archive (List [descriptor.Module [module.ID (Entry Any)]])) (|>> representation (the #resolver) @@ -139,7 +139,7 @@ (list.all (function (_ [module [module_id entry]]) (at maybe.monad each (|>> [module_id] [module]) entry))))) - (def: .public (find module archive) + (def .public (find module archive) (-> descriptor.Module Archive (Try (Entry Any))) (let [(open "/[0]") (representation archive)] (case (dictionary.value module /#resolver) @@ -152,7 +152,7 @@ {.#None} (exception.except ..unknown_document [module (dictionary.keys /#resolver)])))) - (def: .public (archived? archive module) + (def .public (archived? archive module) (-> Archive descriptor.Module Bit) (case (..find module archive) {try.#Success _} @@ -161,7 +161,7 @@ {try.#Failure _} false)) - (def: .public archived + (def .public archived (-> Archive (List descriptor.Module)) (|>> representation (the #resolver) @@ -171,7 +171,7 @@ {.#Some _} {.#Some module} {.#None} {.#None}))))) - (def: .public (reserved? archive module) + (def .public (reserved? archive module) (-> Archive descriptor.Module Bit) (let [(open "/[0]") (representation archive)] (case (dictionary.value module /#resolver) @@ -181,13 +181,13 @@ {.#None} false))) - (def: .public reserved + (def .public reserved (-> Archive (List descriptor.Module)) (|>> representation (the #resolver) dictionary.keys)) - (def: .public reservations + (def .public reservations (-> Archive (List [descriptor.Module module.ID])) (|>> representation (the #resolver) @@ -195,7 +195,7 @@ (list#each (function (_ [module [id _]]) [module id])))) - (def: .public (composite additions archive) + (def .public (composite additions archive) (-> Archive Archive Archive) (let [[+next +resolver] (representation additions)] (|> archive @@ -219,21 +219,21 @@ (type: Frozen [Version module.ID (List Reservation)]) - (def: reader + (def reader (Parser ..Frozen) (all <>.and <binary>.nat <binary>.nat (<binary>.list (<>.and <binary>.text <binary>.nat)))) - (def: writer + (def writer (Writer ..Frozen) (all \\format.and \\format.nat \\format.nat (\\format.list (\\format.and \\format.text \\format.nat)))) - (def: .public (export version archive) + (def .public (export version archive) (-> Version Archive Binary) (let [(open "/[0]") (representation archive)] (|> /#resolver @@ -251,7 +251,7 @@ "Expected" (%.nat expected) "Actual" (%.nat actual))) - (def: .public (import expected binary) + (def .public (import expected binary) (-> Version Binary (Try Archive)) (do try.monad [[actual next reservations] (<binary>.result ..reader binary) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux index f66a0a42f..252776c37 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux @@ -23,7 +23,7 @@ #category Category #mandatory? Bit])) -(def: .public equivalence +(def .public equivalence (Equivalence Artifact) (all product.equivalence nat.equivalence diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux index 9e00a5b51..d9801694c 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact/category.lux @@ -19,7 +19,7 @@ (type: .public Definition [Text (Maybe [Arity [Nat Nat]])]) -(def: .public definition_equivalence +(def .public definition_equivalence (Equivalence Definition) (all product.equivalence text.equivalence @@ -40,10 +40,10 @@ {#Directive Text} {#Custom Text})) -(def: .public equivalence +(def .public equivalence (Equivalence Category) (implementation - (def: (= left right) + (def (= left right) (case [left right] [{#Anonymous} {#Anonymous}] true diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/key.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/key.lux index 445e44c72..0e35d6528 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/key.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/key.lux @@ -9,11 +9,11 @@ (primitive .public (Key k) Signature - (def: .public signature + (def .public signature (All (_ ?) (-> (Key ?) Signature)) (|>> representation)) - (def: .public (key signature sample) + (def .public (key signature sample) (All (_ d) (-> Signature d (Key d))) (abstraction signature)) ) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/module.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/module.lux index 868009871..4e2757bb8 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/module.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/module.lux @@ -8,7 +8,7 @@ (type: .public ID Nat) -(def: .public runtime +(def .public runtime ID 0) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux index b661a1587..92e8dcc60 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/module/descriptor.lux @@ -24,7 +24,7 @@ (type: .public Module Text) -(def: .public runtime +(def .public runtime Module "") @@ -36,10 +36,10 @@ #state Module_State #references (Set Module)])) -(def: module_state_equivalence +(def module_state_equivalence (Equivalence Module_State) (implementation - (def: (= left right) + (def (= left right) (case [left right] (^.with_template [<tag>] [[{<tag>} {<tag>}] @@ -51,7 +51,7 @@ _ false)))) -(def: .public equivalence +(def .public equivalence (Equivalence Descriptor) (all product.equivalence text.equivalence @@ -61,7 +61,7 @@ set.equivalence )) -(def: .public writer +(def .public writer (Writer Descriptor) (all \\format.and \\format.text @@ -71,7 +71,7 @@ (\\format.set \\format.text) )) -(def: .public parser +(def .public parser (Parser Descriptor) (all <>.and <binary>.text diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux index 56dd787be..fe4977e8d 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux @@ -30,7 +30,7 @@ [#signature Signature #content d]) - (def: .public (content key document) + (def .public (content key document) (All (_ d) (-> (Key d) (Document Any) (Try d))) (let [[document//signature document//content] (representation document)] (if (at signature.equivalence = @@ -44,29 +44,29 @@ (exception.except ..invalid_signature [(key.signature key) document//signature])))) - (def: .public (document key content) + (def .public (document key content) (All (_ d) (-> (Key d) d (Document d))) (abstraction [#signature (key.signature key) #content content])) - (def: .public (marked? key document) + (def .public (marked? key document) (All (_ d) (-> (Key d) (Document Any) (Try (Document d)))) (do try.monad [_ (..content key document)] (in (as_expected document)))) - (def: .public signature + (def .public signature (-> (Document Any) Signature) (|>> representation (the #signature))) - (def: .public (writer content) + (def .public (writer content) (All (_ d) (-> (Writer d) (Writer (Document d)))) (let [writer (all binary.and signature.writer content)] (|>> representation writer))) - (def: .public (parser key it) + (def .public (parser key it) (All (_ d) (-> (Key d) (Parser d) (Parser (Document d)))) (do <>.monad [actual signature.parser diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux index 09cfc1190..9f23cad2e 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/registry.lux @@ -34,20 +34,20 @@ [#artifacts (Sequence [Artifact (Set unit.ID)]) #resolver (Dictionary Text [ID (Maybe //category.Definition)])]) - (def: .public empty + (def .public empty Registry (abstraction [#artifacts sequence.empty #resolver (dictionary.empty text.hash)])) - (def: .public artifacts + (def .public artifacts (-> Registry (Sequence [Artifact (Set unit.ID)])) (|>> representation (the #artifacts))) - (def: next + (def next (-> Registry ID) (|>> ..artifacts sequence.size)) - (def: .public (resource mandatory? dependencies registry) + (def .public (resource mandatory? dependencies registry) (-> Bit (Set unit.ID) Registry [ID Registry]) (let [id (..next registry)] [id @@ -60,7 +60,7 @@ abstraction)])) (with_template [<tag> <create> <fetch> <type> <name> <+resolver>] - [(def: .public (<create> it mandatory? dependencies registry) + [(def .public (<create> it mandatory? dependencies registry) (-> <type> Bit (Set unit.ID) Registry [ID Registry]) (let [id (..next registry)] [id @@ -73,7 +73,7 @@ (revised #resolver (dictionary.has (<name> it) [id (is (Maybe //category.Definition) <+resolver>)])) abstraction)])) - (def: .public (<fetch> registry) + (def .public (<fetch> registry) (-> Registry (List <type>)) (|> registry representation @@ -94,17 +94,17 @@ [//category.#Custom custom customs Text |> {.#None}] ) - (def: .public (find_definition name registry) + (def .public (find_definition name registry) (-> Text Registry (Maybe [ID (Maybe //category.Definition)])) (|> (representation registry) (the #resolver) (dictionary.value name))) - (def: .public (id name registry) + (def .public (id name registry) (-> Text Registry (Maybe ID)) (maybe#each product.left (find_definition name registry))) - (def: .public writer + (def .public writer (Writer Registry) (let [definition (is (Writer //category.Definition) (all binary.and @@ -148,7 +148,7 @@ (exception.report "Tag" (%.nat tag))) - (def: .public parser + (def .public parser (Parser Registry) (let [definition (is (Parser //category.Definition) (all <>.and diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux index ac6a22c49..075e12c77 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux @@ -25,23 +25,23 @@ [#name Symbol #version Version])) -(def: .public equivalence +(def .public equivalence (Equivalence Signature) (all product.equivalence symbol.equivalence nat.equivalence)) -(def: .public (description signature) +(def .public (description signature) (-> Signature Text) (format (%.symbol (the #name signature)) " " (version.format (the #version signature)))) -(def: .public writer +(def .public writer (Writer Signature) (all binary.and (binary.and binary.text binary.text) binary.nat)) -(def: .public parser +(def .public parser (Parser Signature) (all <>.and (<>.and <binary>.text <binary>.text) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/unit.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/unit.lux index 9ce35e1b5..937f87043 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/unit.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/unit.lux @@ -22,21 +22,21 @@ [#module module.ID #artifact artifact.ID])) -(def: .public hash +(def .public hash (Hash ID) (all product.hash nat.hash nat.hash)) -(def: .public equivalence +(def .public equivalence (Equivalence ID) (at ..hash equivalence)) -(def: .public none +(def .public none (Set ID) (set.empty ..hash)) -(def: .public (format it) +(def .public (format it) (%.Format ID) (%.format (%.nat (the #module it)) "." diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache.lux b/stdlib/source/library/lux/tool/compiler/meta/cache.lux index 15cdef528..0ebd1e7d5 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache.lux @@ -15,18 +15,18 @@ [// ["[0]" version]]]) -(def: .public (path fs context) +(def .public (path fs context) (All (_ !) (-> (file.System !) Context file.Path)) (let [/ (at fs separator)] (format (the context.#target context) / (the context.#host context) / (version.format //.version)))) -(def: .public (enabled? fs context) +(def .public (enabled? fs context) (All (_ !) (-> (file.System !) Context (! Bit))) (at fs directory? (..path fs context))) -(def: .public (enable! ! fs context) +(def .public (enable! ! fs context) (All (_ !) (-> (Monad !) (file.System !) Context (! (Try Any)))) (do ! [? (..enabled? fs context)] diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/archive.lux index 4710ce851..8876e3e77 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/archive.lux @@ -13,12 +13,12 @@ [context (.only Context)] ["[0]" archive (.only Archive)]]]) -(def: .public (descriptor fs context) +(def .public (descriptor fs context) (All (_ !) (-> (file.System !) Context file.Path)) (%.format (//.path fs context) (at fs separator) "descriptor")) -(def: .public (cache! fs context it) +(def .public (cache! fs context it) (All (_ !) (-> (file.System !) Context Archive (! (Try Any)))) (at fs write (..descriptor fs context) (archive.export ///.version it))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux index 8494dba2c..69c131082 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/artifact.lux @@ -20,7 +20,7 @@ ["[0]" module] ["[0]" artifact]]]]) -(def: .public (path fs context @module @artifact) +(def .public (path fs context @module @artifact) (All (_ !) (-> (file.System !) Context module.ID artifact.ID file.Path)) (format (//module.path fs context @module) @@ -28,12 +28,12 @@ (%.nat @artifact) (the context.#artifact_extension context))) -(def: .public (cache fs context @module @artifact) +(def .public (cache fs context @module @artifact) (All (_ !) (-> (file.System !) Context module.ID artifact.ID (! (Try Binary)))) (at fs read (..path fs context @module @artifact))) -(def: .public (cache! fs context @module @artifact content) +(def .public (cache! fs context @module @artifact content) (All (_ !) (-> (file.System !) Context module.ID artifact.ID Binary (! (Try Any)))) (at fs write (..path fs context @module @artifact) content)) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux index 373696de2..5640bdd7e 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/artifact.lux @@ -35,7 +35,7 @@ ["[0]" registry (.only Registry)] ["[0]" unit]]]]]]]) -(def: (path_references references) +(def (path_references references) (-> (-> Synthesis (List Constant)) (-> Path (List Constant))) (function (again path) @@ -75,7 +75,7 @@ {synthesis.#Then then} (references then)))) -(def: (references value) +(def (references value) (-> Synthesis (List Constant)) (case value {synthesis.#Simple value} @@ -162,7 +162,7 @@ (list#each references) list#conjoint))) -(def: .public (dependencies archive value) +(def .public (dependencies archive value) (All (_ anchor expression directive) (-> Archive Synthesis (Operation anchor expression directive (Set unit.ID)))) (let [! phase.monad] @@ -173,7 +173,7 @@ (monad.each ! (generation.remember archive)) (at ! each (set.of_list unit.hash))))) -(def: .public (path_dependencies archive value) +(def .public (path_dependencies archive value) (All (_ anchor expression directive) (-> Archive Path (Operation anchor expression directive (Set unit.ID)))) (let [! phase.monad] @@ -184,12 +184,12 @@ (monad.each ! (generation.remember archive)) (at ! each (set.of_list unit.hash))))) -(def: .public all +(def .public all (-> (List (Set unit.ID)) (Set unit.ID)) (list#mix set.union unit.none)) -(def: (immediate_dependencies archive) +(def (immediate_dependencies archive) (-> Archive [(List unit.ID) (Dictionary unit.ID (Set unit.ID))]) (|> archive @@ -213,7 +213,7 @@ [(list) (dictionary.empty unit.hash)]))) -(def: .public (necessary_dependencies archive) +(def .public (necessary_dependencies archive) (-> Archive (Set unit.ID)) (let [[mandatory immediate] (immediate_dependencies archive)] (loop (again [pending mandatory diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/module.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/module.lux index 5cad8e963..bdb09274d 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/module.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency/module.lux @@ -26,18 +26,18 @@ (type: .public Ancestry (Set descriptor.Module)) -(def: fresh +(def fresh Ancestry (set.empty text.hash)) (type: .public Graph (Dictionary descriptor.Module Ancestry)) -(def: empty +(def empty Graph (dictionary.empty text.hash)) -(def: .public modules +(def .public modules (-> Graph (List descriptor.Module)) dictionary.keys) @@ -46,13 +46,13 @@ [#module descriptor.Module #imports Ancestry])) -(def: .public graph +(def .public graph (-> (List Dependency) Graph) (list#mix (function (_ [module imports] graph) (dictionary.has module imports graph)) ..empty)) -(def: (ancestry archive) +(def (ancestry archive) (-> Archive Graph) (let [memo (is (Memo descriptor.Module Ancestry) (function (_ again module) @@ -74,7 +74,7 @@ ..empty (archive.archived archive)))) -(def: (dependency? ancestry target source) +(def (dependency? ancestry target source) (-> Graph descriptor.Module descriptor.Module Bit) (let [target_ancestry (|> ancestry (dictionary.value target) @@ -84,7 +84,7 @@ (type: .public (Order a) (List [descriptor.Module [module.ID (archive.Entry a)]])) -(def: .public (load_order key archive) +(def .public (load_order key archive) (All (_ a) (-> (Key a) Archive (Try (Order a)))) (let [ancestry (..ancestry archive)] (|> ancestry diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux index 59c7f5b50..ea6c1a660 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux @@ -32,17 +32,17 @@ "Module ID" (%.nat @module) "Error" error)) -(def: .public (path fs context @module) +(def .public (path fs context @module) (All (_ !) (-> (file.System !) Context module.ID file.Path)) (format (//.path fs context) (at fs separator) (%.nat @module))) -(def: .public (enabled? fs context @module) +(def .public (enabled? fs context @module) (All (_ !) (-> (file.System !) Context module.ID (! Bit))) (at fs directory? (..path fs context @module))) -(def: .public (enable! ! fs context @module) +(def .public (enable! ! fs context @module) (All (_ !) (-> (Monad !) (file.System !) Context module.ID (! (Try Any)))) (do ! [.let [path (..path fs context @module)] @@ -68,25 +68,25 @@ success success)))))))))) -(def: file +(def file file.Path "descriptor") -(def: .public (descriptor fs context @module) +(def .public (descriptor fs context @module) (All (_ !) (-> (file.System !) Context module.ID file.Path)) (format (..path fs context @module) (at fs separator) ..file)) -(def: .public (cache! fs context @module content) +(def .public (cache! fs context @module content) (All (_ !) (-> (file.System !) Context module.ID Binary (! (Try Any)))) (at fs write (..descriptor fs context @module) content)) -(def: .public (cache fs context @module) +(def .public (cache fs context @module) (All (_ !) (-> (file.System !) Context module.ID (! (Try Binary)))) (at fs read (..descriptor fs context @module))) -(def: .public (artifacts ! fs context @module) +(def .public (artifacts ! fs context @module) (All (_ !) (-> (Monad !) (file.System !) Context module.ID (! (Try (Dictionary Text Binary))))) (do [! (try.with !)] [files (at fs directory_files (..path fs context @module)) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/purge.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/purge.lux index addb97821..d538861e6 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/purge.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/purge.lux @@ -38,7 +38,7 @@ (Dictionary descriptor.Module module.ID)) ... TODO: Make the monad parameterizable. -(def: .public (purge! fs context @module) +(def .public (purge! fs context @module) (-> (file.System Async) Context module.ID (Async (Try Any))) (do [! (try.with async.monad)] [.let [cache (//module.path fs context @module)] @@ -48,7 +48,7 @@ (at ! conjoint))] (at fs delete cache))) -(def: .public (valid? expected actual) +(def .public (valid? expected actual) (-> Descriptor Input Bit) (and (text#= (the descriptor.#name expected) (the ////.#module actual)) @@ -57,7 +57,7 @@ (n.= (the descriptor.#hash expected) (the ////.#hash actual)))) -(def: initial +(def initial (-> (List Cache) Purge) (|>> (list.all (function (_ [valid? module_name @module _]) (if valid? @@ -65,7 +65,7 @@ {.#Some [module_name @module]}))) (dictionary.of_list text.hash))) -(def: .public (purge caches load_order) +(def .public (purge caches load_order) (-> (List Cache) (dependency.Order Any) Purge) (list#mix (function (_ [module_name [@module entry]] purge) (let [purged? (is (Predicate descriptor.Module) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cli.lux b/stdlib/source/library/lux/tool/compiler/meta/cli.lux index ea10958bd..76c30f475 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cli.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cli.lux @@ -71,7 +71,7 @@ {#Export Export})) (with_template [<name> <long> <type> <parser>] - [(def: <name> + [(def <name> (Parser <type>) (<cli>.named <long> <parser>))] @@ -84,7 +84,7 @@ [configuration_parser "--configuration" Configuration (<text>.then configuration.parser <cli>.any)] ) -(def: .public service +(def .public service (Parser Service) (let [compilation (is (Parser Compilation) (all <>.and @@ -106,7 +106,7 @@ ..target_parser)) ))) -(def: .public target +(def .public target (-> Service Target) (|>> (pipe.case (^.or {#Compilation [host_dependencies libraries compilers sources target module]} diff --git a/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux b/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux index 40ee7afe4..e8c4196dd 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cli/compiler.lux @@ -23,7 +23,7 @@ [#definition Symbol #parameters (List Text)])) -(def: .public equivalence +(def .public equivalence (Equivalence Compiler) (all product.equivalence symbol.equivalence @@ -31,7 +31,7 @@ )) (with_template [<ascii> <name>] - [(def: <name> + [(def <name> Text (text.of_char (hex <ascii>)))] @@ -39,16 +39,16 @@ ["03" end] ) -(def: parameter +(def parameter (-> Text Text) (text.enclosed [..start ..end])) -(def: .public (format [[module short] parameters]) +(def .public (format [[module short] parameters]) (%.Format Compiler) (%.format (..parameter module) (..parameter short) (text.together (list#each ..parameter parameters)))) -(def: .public parser +(def .public parser (Parser Compiler) (let [parameter (is (Parser Text) (<| (<>.after (<text>.this ..start)) diff --git a/stdlib/source/library/lux/tool/compiler/meta/context.lux b/stdlib/source/library/lux/tool/compiler/meta/context.lux index cfacb3fe9..a2126c773 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/context.lux @@ -16,7 +16,7 @@ #artifact_extension Extension])) (with_template [<name> <host> <host_module_extension> <artifact_extension>] - [(def: .public (<name> target) + [(def .public (<name> target) (-> Path Context) [#host <host> #host_module_extension <host_module_extension> diff --git a/stdlib/source/library/lux/tool/compiler/meta/export.lux b/stdlib/source/library/lux/tool/compiler/meta/export.lux index 2871ecf8e..aab3dae55 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/export.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/export.lux @@ -28,16 +28,16 @@ [world ["[0]" file]]]]) -(def: .public file +(def .public file "library.tar") -(def: .public mode +(def .public mode (all tar.and tar.read_by_owner tar.write_by_owner tar.read_by_group tar.write_by_group tar.read_by_other)) -(def: .public ownership +(def .public ownership tar.Ownership (let [commons (is tar.Owner [tar.#name tar.anonymous @@ -45,7 +45,7 @@ [tar.#user commons tar.#group commons])) -(def: .public (library fs sources) +(def .public (library fs sources) (-> (file.System Async) (List Source) (Async (Try tar.Tar))) (|> sources (io.listing fs) @@ -65,7 +65,7 @@ (try#each sequence.of_list))) try#conjoint)))) -(def: .public (export fs [sources target]) +(def .public (export fs [sources target]) (-> (file.System Async) Export (Async (Try Any))) (do [! (try.with async.monad)] [tar (|> sources diff --git a/stdlib/source/library/lux/tool/compiler/meta/import.lux b/stdlib/source/library/lux/tool/compiler/meta/import.lux index dec6dde3b..d653afbac 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/import.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/import.lux @@ -26,7 +26,7 @@ [world ["[0]" file]]]]) -(def: Action +(def Action (type (All (_ a) (Async (Try a))))) (exception: .public useless_tar_entry) @@ -40,7 +40,7 @@ (type: .public Import (Dictionary file.Path Binary)) -(def: (import_library system library import) +(def (import_library system library import) (-> (file.System Async) Library Import (Action Import)) (let [! async.monad] (|> library @@ -65,7 +65,7 @@ import))) (at ! conjoint))))))) -(def: .public (import system libraries) +(def .public (import system libraries) (-> (file.System Async) (List Library) (Action Import)) (monad.mix (is (Monad Action) (try.with async.monad)) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io.lux b/stdlib/source/library/lux/tool/compiler/meta/io.lux index efbdb599d..374e71ef3 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io.lux @@ -12,10 +12,10 @@ (type: .public Code Text) -(def: .public (safe system) +(def .public (safe system) (All (_ m) (-> (System m) Text Text)) (text.replaced "/" (at system separator))) -(def: .public lux_context +(def .public lux_context Context "lux") diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux index a192cf58a..2cef8ada4 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux @@ -56,7 +56,7 @@ ["[0]" directive] ["[1]/[0]" program]]]]]]) -(def: (module_parser key parser) +(def (module_parser key parser) (All (_ document) (-> (Key document) (Parser document) (Parser (module.Module document)))) (all <>.and @@ -64,18 +64,18 @@ descriptor.parser (document.parser key parser))) -(def: (parser key parser) +(def (parser key parser) (All (_ document) (-> (Key document) (Parser document) (Parser [(module.Module document) Registry]))) (all <>.and (..module_parser key parser) registry.parser)) -(def: (fresh_analysis_state host configuration) +(def (fresh_analysis_state host configuration) (-> Target Configuration .Lux) (analysis.state (analysis.info version.latest host configuration))) -(def: (analysis_state host configuration archive) +(def (analysis_state host configuration archive) (-> Target Configuration Archive (Try .Lux)) (do [! try.monad] [modules (is (Try (List [descriptor.Module .Module])) @@ -101,14 +101,14 @@ Generators Directives]) -(def: empty_bundles +(def empty_bundles Bundles [(dictionary.empty text.hash) (dictionary.empty text.hash) (dictionary.empty text.hash) (dictionary.empty text.hash)]) -(def: (loaded_document extension host @module expected actual document) +(def (loaded_document extension host @module expected actual document) (All (_ expression directive) (-> Text (generation.Host expression directive) module.ID (Sequence [Artifact (Set unit.ID)]) (Dictionary Text Binary) (Document .Module) (Try [(Document .Module) Bundles Output]))) @@ -246,7 +246,7 @@ (in [(document.document $.key (has .#definitions definitions content)) bundles]))) -(def: (load_definitions fs context @module host_environment entry) +(def (load_definitions fs context @module host_environment entry) (All (_ expression directive) (-> (file.System Async) Context module.ID (generation.Host expression directive) (archive.Entry .Module) @@ -263,11 +263,11 @@ (has archive.#output output)) bundles]))) -(def: pseudo_module +(def pseudo_module Text "(Lux Caching System)") -(def: (cache_parser customs) +(def (cache_parser customs) (-> (List Custom) (Parser [(module.Module Any) Registry])) (case (for @.old (as (List (Custom Any Any Any)) customs) @@ -281,7 +281,7 @@ (cache_parser tail) ))) -(def: (valid_cache customs fs context import contexts [module_name @module]) +(def (valid_cache customs fs context import contexts [module_name @module]) (-> (List Custom) (file.System Async) Context Import (List //.Context) [descriptor.Module module.ID] (Async (Try Cache))) @@ -296,7 +296,7 @@ [input (//context.read fs ..pseudo_module import contexts (the context.#host_module_extension context) module_name)] (in [(cache/purge.valid? (the module.#descriptor module) input) <cache>])))))) -(def: (pre_loaded_caches customs fs context import contexts archive) +(def (pre_loaded_caches customs fs context import contexts archive) (-> (List Custom) (file.System Async) Context Import (List //.Context) Archive (Async (Try (List Cache)))) (do [! (try.with async.monad)] @@ -306,7 +306,7 @@ (monad.each ! (..valid_cache customs fs context import contexts)))] (in it))) -(def: (load_order archive pre_loaded_caches) +(def (load_order archive pre_loaded_caches) (-> Archive (List Cache) (Try (dependency.Order .Module))) (|> pre_loaded_caches @@ -321,7 +321,7 @@ (at try.monad each (dependency.load_order $.key)) (at try.monad conjoint))) -(def: (loaded_caches host_environment fs context purge load_order) +(def (loaded_caches host_environment fs context purge load_order) (All (_ expression directive) (-> (generation.Host expression directive) (file.System Async) Context Purge (dependency.Order .Module) @@ -343,7 +343,7 @@ <it>)))))))] (in it))) -(def: (load_every_reserved_module customs configuration host_environment fs context import contexts archive) +(def (load_every_reserved_module customs configuration host_environment fs context import contexts archive) (All (_ expression directive) (-> (List Custom) Configuration (generation.Host expression directive) (file.System Async) Context Import (List //.Context) Archive (Async (Try [Archive .Lux Bundles])))) @@ -374,7 +374,7 @@ ..empty_bundles loaded_caches)]))))) -(def: .public (thaw customs configuration host_environment fs context import contexts) +(def .public (thaw customs configuration host_environment fs context import contexts) (All (_ expression directive) (-> (List Custom) Configuration (generation.Host expression directive) (file.System Async) Context Import (List //.Context) (Async (Try [Archive .Lux Bundles])))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux index 6845f5cce..e79b60e7b 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux @@ -43,17 +43,17 @@ (type: .public Extension Text) -(def: .public lux_extension +(def .public lux_extension Extension ".lux") -(def: .public (path fs context module) +(def .public (path fs context module) (All (_ m) (-> (file.System m) Context Module file.Path)) (|> module (//.safe fs) (format context (at fs separator)))) -(def: (find_source_file fs importer contexts module extension) +(def (find_source_file fs importer contexts module extension) (-> (file.System Async) Module (List Context) Module Extension (Async (Try file.Path))) (case contexts @@ -68,11 +68,11 @@ (in {try.#Success path}) (find_source_file fs importer contexts' module extension)))))) -(def: (full_host_extension partial_host_extension) +(def (full_host_extension partial_host_extension) (-> Extension Extension) (format partial_host_extension ..lux_extension)) -(def: (find_local_source_file fs importer import contexts partial_host_extension module) +(def (find_local_source_file fs importer import contexts partial_host_extension module) (-> (file.System Async) Module Import (List Context) Extension Module (Async (Try [file.Path Binary]))) ... Preference is explicitly being given to Lux files that have a host extension. @@ -92,7 +92,7 @@ (at fs read) (at ! each (|>> [path]))))))) -(def: (find_library_source_file importer import partial_host_extension module) +(def (find_library_source_file importer import partial_host_extension module) (-> Module Import Extension Module (Try [file.Path Binary])) (let [path (format module (..full_host_extension partial_host_extension))] (case (dictionary.value path import) @@ -108,7 +108,7 @@ {.#None} (exception.except ..cannot_find_module [importer module])))))) -(def: (find_any_source_file fs importer import contexts partial_host_extension module) +(def (find_any_source_file fs importer import contexts partial_host_extension module) (-> (file.System Async) Module Import (List Context) Extension Module (Async (Try [file.Path Binary]))) ... Preference is explicitly being given to Lux files that have a host extension. @@ -122,7 +122,7 @@ {try.#Failure _} (in (..find_library_source_file importer import partial_host_extension module))))) -(def: .public (read fs importer import contexts partial_host_extension module) +(def .public (read fs importer import contexts partial_host_extension module) (-> (file.System Async) Module Import (List Context) Extension Module (Async (Try Input))) (do (try.with async.monad) @@ -140,7 +140,7 @@ (type: .public Enumeration (Dictionary file.Path Binary)) -(def: (context_listing fs context directory enumeration) +(def (context_listing fs context directory enumeration) (-> (file.System Async) Context file.Path Enumeration (Async (Try Enumeration))) (do [! (try.with async.monad)] [enumeration (|> directory @@ -158,10 +158,10 @@ (at ! each (monad.mix ! (context_listing fs context) enumeration)) (at ! conjoint)))) -(def: Action +(def Action (type (All (_ a) (Async (Try a))))) -(def: (canonical fs context) +(def (canonical fs context) (-> (file.System Async) Context (Action Context)) (do (try.with async.monad) [subs (at fs sub_directories context)] @@ -171,7 +171,7 @@ (file.parent fs) (maybe.else context))))) -(def: .public (listing fs contexts) +(def .public (listing fs contexts) (-> (file.System Async) (List Context) (Action Enumeration)) (let [! (is (Monad Action) (try.with async.monad))] diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager.lux b/stdlib/source/library/lux/tool/compiler/meta/packager.lux index 1543e082f..759cb26a5 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager.lux @@ -33,7 +33,7 @@ (type: .public Order (List [module.ID (List artifact.ID)])) -(def: .public order +(def .public order (-> (cache/module.Order Any) Order) (list#each (function (_ [module [module_id entry]]) (|> entry diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux index 47fb81088..ddc522426 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -118,21 +118,21 @@ (new [java/io/InputStream]) (getNextJarEntry [] "try" "?" java/util/jar/JarEntry)) -(def: byte +(def byte 1) ... https://en.wikipedia.org/wiki/Kibibyte -(def: kibi_byte +(def kibi_byte (n.* 1,024 byte)) ... https://en.wikipedia.org/wiki/Mebibyte -(def: mebi_byte +(def mebi_byte (n.* 1,024 kibi_byte)) -(def: manifest_version +(def manifest_version "1.0") -(def: (manifest program) +(def (manifest program) (-> (Maybe unit.ID) java/util/jar/Manifest) (let [manifest (java/util/jar/Manifest::new) attrs (do_to (java/util/jar/Manifest::getMainAttributes manifest) @@ -153,7 +153,7 @@ attrs) manifest))) -(def: (write_class static module artifact custom content sink) +(def (write_class static module artifact custom content sink) (-> Context module.ID artifact.ID (Maybe Text) Binary java/util/jar/JarOutputStream (Try java/util/jar/JarOutputStream)) (let [class_path (|> custom @@ -169,7 +169,7 @@ (java/io/Flushable::flush) (java/util/zip/ZipOutputStream::closeEntry)))))) -(def: (write_module static necessary_dependencies [module output] sink) +(def (write_module static necessary_dependencies [module output] sink) (-> Context (Set unit.ID) [module.ID Output] java/util/jar/JarOutputStream (Try java/util/jar/JarOutputStream)) (let [! try.monad] @@ -181,7 +181,7 @@ sink (sequence.list output)))) -(def: (read_jar_entry_with_unknown_size input) +(def (read_jar_entry_with_unknown_size input) (-> java/util/jar/JarInputStream [Nat Binary]) (let [chunk (binary.empty ..mebi_byte) chunk_size (.int ..mebi_byte) @@ -197,7 +197,7 @@ (java/io/OutputStream::write chunk (ffi.as_int +0) (ffi.as_int bytes_read) buffer) (again (|> bytes_read .nat (n.+ so_far)))))))) -(def: (read_jar_entry_with_known_size expected_size input) +(def (read_jar_entry_with_known_size expected_size input) (-> Nat java/util/jar/JarInputStream [Nat Binary]) (let [buffer (binary.empty expected_size)] (loop (again [so_far 0]) @@ -210,7 +210,7 @@ [expected_size buffer] (again so_far')))))) -(def: (read_jar_entry entry input) +(def (read_jar_entry entry input) (-> java/util/jar/JarEntry java/util/jar/JarInputStream [Nat Binary]) (case (ffi.of_long (java/util/zip/ZipEntry::getSize entry)) -1 @@ -219,7 +219,7 @@ entry_size (..read_jar_entry_with_known_size (.nat entry_size) input))) -(def: (write_host_dependency jar [entries duplicates sink]) +(def (write_host_dependency jar [entries duplicates sink]) (-> Binary [(Set file.Path) (Set file.Path) java/util/jar/JarOutputStream] (Try [(Set file.Path) (Set file.Path) java/util/jar/JarOutputStream])) @@ -267,7 +267,7 @@ duplicates sink)))))))) -(def: .public (package static) +(def .public (package static) (-> Context Packager) (function (_ host_dependencies archive program) (do [! try.monad] diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux index 0937615cc..cc5938094 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux @@ -44,7 +44,7 @@ [language ["$" lux]]]]]) -(def: (bundle_module module module_id necessary_dependencies output) +(def (bundle_module module module_id necessary_dependencies output) (-> descriptor.Module module.ID (Set unit.ID) Output (Try (Maybe _.Statement))) (do [! try.monad] [] @@ -73,11 +73,11 @@ artifacts)] (in {.#Some bundle}))))) -(def: module_file +(def module_file (-> module.ID file.Path) (|>> %.nat (text.suffix ".rb"))) -(def: (write_module mapping necessary_dependencies [module [module_id entry]] sink) +(def (write_module mapping necessary_dependencies [module [module_id entry]] sink) (-> (Dictionary descriptor.Module module.ID) (Set unit.ID) [descriptor.Module [module.ID (archive.Entry .Module)]] (List [module.ID [Text Binary]]) @@ -98,21 +98,21 @@ (in (list.partial [module_id [(..module_file module_id) entry_content]] sink)))))) -(def: .public main_file +(def .public main_file "main.rb") -(def: module_id_mapping +(def module_id_mapping (-> (Order .Module) (Dictionary descriptor.Module module.ID)) (|>> (list#each (function (_ [module [module_id entry]]) [module module_id])) (dictionary.of_list text.hash))) -(def: included_modules +(def included_modules (All (_ a) (-> (List [module.ID a]) (Set module.ID))) (|>> (list#each product.left) (list#mix set.has (set.empty nat.hash)))) -(def: .public (package host_dependencies archive program) +(def .public (package host_dependencies archive program) Packager (do [! try.monad] [.let [necessary_dependencies (cache/artifact.necessary_dependencies archive)] diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux index 1fed07990..70f595ff4 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux @@ -48,13 +48,13 @@ (type: (Action ! a) (! (Try a))) -(def: (then pre post) +(def (then pre post) (-> _.Expression _.Expression _.Expression) (_.manual (format (_.code pre) text.new_line (_.code post)))) -(def: bundle_module +(def bundle_module (-> Output (Try _.Expression)) (|>> sequence.list (list#each product.right) @@ -71,11 +71,11 @@ (..then so_far))))) (is _.Expression (_.manual ""))))) -(def: module_file +(def module_file (-> archive.ID file.Path) (|>> %.nat (text.suffix ".scm"))) -(def: mode +(def mode tar.Mode (all tar.and tar.read_by_group @@ -85,16 +85,16 @@ tar.write_by_group tar.write_by_owner)) -(def: owner +(def owner tar.Owner [tar.#name tar.anonymous tar.#id tar.no_id]) -(def: ownership +(def ownership [tar.#user ..owner tar.#group ..owner]) -(def: (write_module now mapping [module [module_id [descriptor document output]]]) +(def (write_module now mapping [module [module_id [descriptor document output]]]) (-> Instant (Dictionary Module archive.ID) [Module [archive.ID [Descriptor (Document .Module) Output]]] (Try tar.Entry)) @@ -115,7 +115,7 @@ module_file (tar.path (..module_file module_id))] (in {tar.#Normal [module_file now ..mode ..ownership entry_content]}))) -(def: .public (package now) +(def .public (package now) (-> Instant Packager) (function (package host_dependencies archive program) (do [! try.monad] diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux index 382536417..d68c344e5 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux @@ -34,7 +34,7 @@ [language ["$" lux]]]]]) -(def: (write_module necessary_dependencies sequence [module_id output] so_far) +(def (write_module necessary_dependencies sequence [module_id output] so_far) (All (_ directive) (-> (Set unit.ID) (-> directive directive directive) [module.ID Output] directive (Try directive))) @@ -57,7 +57,7 @@ (sequence so_far))))) so_far))) -(def: .public (package header code sequence scope) +(def .public (package header code sequence scope) (All (_ directive) (-> directive (-> directive Text) diff --git a/stdlib/source/library/lux/tool/compiler/phase.lux b/stdlib/source/library/lux/tool/compiler/phase.lux index 97eb3944c..c2aa03feb 100644 --- a/stdlib/source/library/lux/tool/compiler/phase.lux +++ b/stdlib/source/library/lux/tool/compiler/phase.lux @@ -23,10 +23,10 @@ (type: .public (Operation s o) (state.+State Try s o)) -(def: .public functor +(def .public functor (All (_ s) (Functor (Operation s))) (implementation - (def: (each f it) + (def (each f it) (function (_ state) (case (it state) {try.#Success [state' output]} @@ -35,16 +35,16 @@ {try.#Failure error} {try.#Failure error}))))) -(def: .public monad +(def .public monad (All (_ s) (Monad (Operation s))) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in it) + (def (in it) (function (_ state) {try.#Success [state it]})) - (def: (conjoint it) + (def (conjoint it) (function (_ state) (case (it state) {try.#Success [state' it']} @@ -59,31 +59,31 @@ (type: .public Wrapper (All (_ s i o) (-> (Phase s i o) Any))) -(def: .public (result' state operation) +(def .public (result' state operation) (All (_ s o) (-> s (Operation s o) (Try [s o]))) (operation state)) -(def: .public (result state operation) +(def .public (result state operation) (All (_ s o) (-> s (Operation s o) (Try o))) (|> state operation (at try.monad each product.right))) -(def: .public state +(def .public state (All (_ s o) (Operation s s)) (function (_ state) {try.#Success [state state]})) -(def: .public (with state) +(def .public (with state) (All (_ s o) (-> s (Operation s Any))) (function (_ _) {try.#Success [state []]})) -(def: .public (sub [get set] operation) +(def .public (sub [get set] operation) (All (_ s s' o) (-> [(-> s s') (-> s' s s)] (Operation s' o) @@ -93,31 +93,31 @@ [[state' output] (operation (get state))] (in [(set state' state) output])))) -(def: .public failure +(def .public failure (-> Text Operation) (|>> {try.#Failure} (state.lifted try.monad))) -(def: .public (except exception parameters) +(def .public (except exception parameters) (All (_ e) (-> (Exception e) e Operation)) (..failure (exception.error exception parameters))) -(def: .public (lifted error) +(def .public (lifted error) (All (_ s a) (-> (Try a) (Operation s a))) (function (_ state) (try#each (|>> [state]) error))) -(def: .public assertion +(def .public assertion (template (assertion exception message test) [(if test (at ..monad in []) (..except exception message))])) -(def: .public identity +(def .public identity (All (_ s a) (Phase s a a)) (function (_ archive input state) {try.#Success [state input]})) -(def: .public (composite pre post) +(def .public (composite pre post) (All (_ s0 s1 i t o) (-> (Phase s0 i t) (Phase s1 t o) diff --git a/stdlib/source/library/lux/tool/compiler/reference.lux b/stdlib/source/library/lux/tool/compiler/reference.lux index 78539332c..9701fbf11 100644 --- a/stdlib/source/library/lux/tool/compiler/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/reference.lux @@ -27,10 +27,10 @@ {#Variable Variable} {#Constant Constant})) -(def: .public equivalence +(def .public equivalence (Equivalence Reference) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag> <equivalence>] [[{<tag> reference} {<tag> sample}] @@ -41,13 +41,13 @@ _ false)))) -(def: .public hash +(def .public hash (Hash Reference) (implementation - (def: equivalence + (def equivalence ..equivalence) - (def: (hash value) + (def (hash value) (case value (^.with_template [<factor> <tag> <hash>] [{<tag> value} @@ -59,7 +59,7 @@ )))) (with_template [<name> <family> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(<| {<family>} {<tag>} @@ -70,7 +70,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> (template (<name> content) [(<| {<tag>} content)]))] @@ -79,11 +79,11 @@ [constant ..#Constant] ) -(`` (def: .public self +(`` (def .public self (template (self) [(..variable (~~ (/variable.self)))]))) -(def: .public format +(def .public format (Format Reference) (|>> (pipe.case {#Variable variable} diff --git a/stdlib/source/library/lux/tool/compiler/reference/variable.lux b/stdlib/source/library/lux/tool/compiler/reference/variable.lux index 8dea1368a..7dd3cdc4c 100644 --- a/stdlib/source/library/lux/tool/compiler/reference/variable.lux +++ b/stdlib/source/library/lux/tool/compiler/reference/variable.lux @@ -24,10 +24,10 @@ {#Local Register} {#Foreign Register})) -(def: .public equivalence +(def .public equivalence (Equivalence Variable) (implementation - (def: (= reference sample) + (def (= reference sample) (case [reference sample] (^.with_template [<tag>] [[{<tag> reference'} {<tag> sample'}] @@ -37,13 +37,13 @@ _ #0)))) -(def: .public hash +(def .public hash (Hash Variable) (implementation - (def: equivalence + (def equivalence ..equivalence) - (def: hash + (def hash (|>> (pipe.case (^.with_template [<factor> <tag>] [{<tag> register} @@ -53,11 +53,11 @@ ([2 #Local] [3 #Foreign])))))) -(def: .public self +(def .public self (template (self) [{..#Local 0}])) -(def: .public self? +(def .public self? (-> Variable Bit) (|>> (pipe.case (pattern (..self)) @@ -66,7 +66,7 @@ _ false))) -(def: .public format +(def .public format (Format Variable) (|>> (pipe.case {#Local local} diff --git a/stdlib/source/library/lux/tool/compiler/version.lux b/stdlib/source/library/lux/tool/compiler/version.lux index 67fe69189..1c8b12785 100644 --- a/stdlib/source/library/lux/tool/compiler/version.lux +++ b/stdlib/source/library/lux/tool/compiler/version.lux @@ -11,36 +11,36 @@ (type: .public Version Nat) -(def: range +(def range 100) -(def: level +(def level (n.% ..range)) -(def: next +(def next (n./ ..range)) -(def: .public patch +(def .public patch (-> Version Nat) (|>> ..level)) -(def: .public minor +(def .public minor (-> Version Nat) (|>> ..next ..level)) -(def: .public major +(def .public major (-> Version Nat) (|>> ..next ..next ..level)) -(def: separator ".") +(def separator ".") -(def: (padded value) +(def (padded value) (-> Nat Text) (if (n.< 10 value) (%.format "0" (%.nat value)) (%.nat value))) -(def: .public (format version) +(def .public (format version) (%.Format Version) (%.format (%.nat (..major version)) ..separator diff --git a/stdlib/source/library/lux/tool/interpreter.lux b/stdlib/source/library/lux/tool/interpreter.lux index f54f0ae59..da8c16991 100644 --- a/stdlib/source/library/lux/tool/interpreter.lux +++ b/stdlib/source/library/lux/tool/interpreter.lux @@ -32,32 +32,32 @@ (exception: .public (error [message Text]) message) -(def: .public module "<INTERPRETER>") +(def .public module "<INTERPRETER>") -(def: fresh_source +(def fresh_source Source [[..module 1 0] 0 ""]) -(def: (add_line line [where offset input]) +(def (add_line line [where offset input]) (-> Text Source Source) [where offset (format input text.new_line line)]) -(def: exit_command +(def exit_command Text "exit") -(def: welcome_message +(def welcome_message Text (format text.new_line "Welcome to the interpreter!" text.new_line "Type '" ..exit_command "' to leave." text.new_line text.new_line)) -(def: farewell_message +(def farewell_message Text "Till next time...") -(def: enter_module +(def enter_module (All (_ anchor expression directive) (Operation anchor expression directive Any)) (directive.lifted_analysis @@ -65,7 +65,7 @@ [_ (module.create 0 ..module)] (analysis.set_current_module ..module)))) -(def: (initialize Monad<!> Console<!> platform configuration generation_bundle) +(def (initialize Monad<!> Console<!> platform configuration generation_bundle) (All (_ ! anchor expression directive) (-> (Monad !) (Console !) (Platform ! anchor expression directive) @@ -89,7 +89,7 @@ (with_expansions [<Interpretation> (these (Operation anchor expression directive [Type Any]))] - (def: (interpret_directive code) + (def (interpret_directive code) (All (_ anchor expression directive) (-> Code <Interpretation>)) (do phase.monad @@ -97,7 +97,7 @@ _ init.refresh] (in [Any []]))) - (def: (interpret_expression code) + (def (interpret_expression code) (All (_ anchor expression directive) (-> Code <Interpretation>)) (do [! phase.monad] @@ -124,7 +124,7 @@ codeV (generation.evaluate! (format "interpretation_" (%.nat count)) codeH)] (in [codeT codeV])))))) - (def: (interpret configuration code) + (def (interpret configuration code) (All (_ anchor expression directive) (-> Configuration Code <Interpretation>)) (function (_ state) @@ -148,7 +148,7 @@ {try.#Failure error})))) ) -(def: (execute configuration code) +(def (execute configuration code) (All (_ anchor expression directive) (-> Configuration Code (Operation anchor expression directive Text))) (do phase.monad @@ -168,7 +168,7 @@ #source Source])) (with_expansions [<Context> (these (Context anchor expression directive))] - (def: (read_eval_print context) + (def (read_eval_print context) (All (_ anchor expression directive) (-> <Context> (Try [<Context> Text]))) (do try.monad @@ -192,7 +192,7 @@ (has #source source')) representation])))) -(def: .public (run! Monad<!> Console<!> platform configuration generation_bundle) +(def .public (run! Monad<!> Console<!> platform configuration generation_bundle) (All (_ ! anchor expression directive) (-> (Monad !) (Console !) (Platform ! anchor expression directive) diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index 52c70ada9..933d0e03c 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -29,7 +29,7 @@ ["[0]" symbol (.open: "[1]#[0]" equivalence codec)]]]]) (with_template [<name> <tag>] - [(def: .public (<name> type) + [(def .public (<name> type) (-> Type [Nat Type]) (loop (again [num_args 0 type type]) @@ -44,7 +44,7 @@ [flat_ex_q .#ExQ] ) -(def: .public (flat_function type) +(def .public (flat_function type) (-> Type [(List Type) Type]) (case type {.#Function in out'} @@ -54,7 +54,7 @@ _ [(list) type])) -(def: .public (flat_application type) +(def .public (flat_application type) (-> Type [Type (List Type)]) (case type {.#Apply arg func'} @@ -65,7 +65,7 @@ [type (list)])) (with_template [<name> <tag>] - [(def: .public (<name> type) + [(def .public (<name> type) (-> Type (List Type)) (case type {<tag> left right} @@ -78,7 +78,7 @@ [flat_tuple .#Product] ) -(def: .public (format type) +(def .public (format type) (-> Type Text) (case type {.#Primitive name params} @@ -136,7 +136,7 @@ )) ... https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B2-reduction -(def: (reduced env type) +(def (reduced env type) (-> (List Type) Type Type) (case type {.#Primitive name params} @@ -176,10 +176,10 @@ type )) -(def: .public equivalence +(def .public equivalence (Equivalence Type) (implementation - (def: (= x y) + (def (= x y) (or (for @.php ... TODO: Remove this once JPHP is gone. false @@ -223,7 +223,7 @@ #0 ))))) -(def: .public (applied params func) +(def .public (applied params func) (-> (List Type) Type (Maybe Type)) (case params {.#End} @@ -247,7 +247,7 @@ _ {.#None}))) -(def: .public (code type) +(def .public (code type) (-> Type Code) (case type {.#Primitive name params} @@ -275,7 +275,7 @@ ([.#UnivQ] [.#ExQ]) )) -(def: .public (de_aliased type) +(def .public (de_aliased type) (-> Type Type) (case type {.#Named _ {.#Named name type'}} @@ -284,7 +284,7 @@ _ type)) -(def: .public (anonymous type) +(def .public (anonymous type) (-> Type Type) (case type {.#Named name type'} @@ -294,7 +294,7 @@ type)) (with_template [<name> <base> <ctor>] - [(def: .public (<name> types) + [(def .public (<name> types) (-> (List Type) Type) (case types {.#End} @@ -310,7 +310,7 @@ [tuple Any .#Product] ) -(def: .public (function inputs output) +(def .public (function inputs output) (-> (List Type) Type Type) (case inputs {.#End} @@ -319,7 +319,7 @@ {.#Item input inputs'} {.#Function input (function inputs' output)})) -(def: .public (application params quant) +(def .public (application params quant) (-> (List Type) Type Type) (case params {.#End} @@ -329,7 +329,7 @@ (application params' {.#Apply param quant}))) (with_template [<name> <tag>] - [(def: .public (<name> size body) + [(def .public (<name> size body) (-> Nat Type Type) (case size 0 body @@ -339,7 +339,7 @@ [ex_q .#ExQ] ) -(def: .public (quantified? type) +(def .public (quantified? type) (-> Type Bit) (case type {.#Named [module name] _type} @@ -356,7 +356,7 @@ _ #0)) -(def: .public (array depth element_type) +(def .public (array depth element_type) (-> Nat Type Type) (case depth 0 element_type @@ -365,7 +365,7 @@ (list) {.#Primitive array.type_name}))) -(def: .public (flat_array type) +(def .public (flat_array type) (-> Type [Nat Type]) (case type (^.multi (pattern {.#Primitive name (list element_type)}) @@ -376,21 +376,21 @@ _ [0 type])) -(def: .public array? +(def .public array? (-> Type Bit) (|>> ..flat_array product.left (n.> 0))) -(def: new_secret_marker +(def new_secret_marker (syntax (_ []) (macro.with_symbols [g!_secret_marker_] (in (list g!_secret_marker_))))) -(def: secret_marker +(def secret_marker (`` (symbol (~~ (new_secret_marker))))) -(def: .public log! +(def .public log! (syntax (_ [input (<>.or (<>.and <code>.symbol (<>.maybe (<>.after (<code>.this_symbol ..secret_marker) <code>.any))) <code>.any)]) @@ -417,11 +417,11 @@ (in (list (` (.let [(~ g!value) (~ valueC)] (..log! (~ valueC) (~ (code.symbol ..secret_marker)) (~ g!value)))))))))) -(def: type_parameters +(def type_parameters (Parser (List Text)) (<code>.tuple (<>.some <code>.local))) -(def: .public as +(def .public as (syntax (_ [type_vars type_parameters input <code>.any output <code>.any @@ -442,7 +442,7 @@ [#type Code #expression Code])) -(def: (typed lux) +(def (typed lux) (-> Lux (Parser Typed)) (do <>.monad [it <code>.any @@ -453,7 +453,7 @@ (<>.and <code>.any <code>.any)))) ... TODO: Make sure the generated code always gets optimized away. -(def: .public sharing +(def .public sharing (syntax (_ lux [type_vars ..type_parameters exemplar (..typed lux) computation (..typed lux)]) @@ -466,7 +466,7 @@ (~ (the #expression computation)))))] (in (list (` ((~ shareC) (~ (the #expression exemplar)))))))))) -(def: .public by_example +(def .public by_example (syntax (_ lux [type_vars ..type_parameters exemplar (..typed lux) extraction <code>.any]) @@ -477,7 +477,7 @@ ... The value of this expression will never be relevant, so it doesn't matter what it is. (.as .Nothing []))))))))) -(def: .public (replaced before after) +(def .public (replaced before after) (-> Type Type Type Type) (.function (again it) (if (at ..equivalence = before it) @@ -506,7 +506,7 @@ {.#Named _}) it)))) -(def: .public let +(def .public let (syntax (_ [bindings (<code>.tuple (<>.some (<>.and <code>.any <code>.any))) bodyT <code>.any]) (in (list (` (..with_expansions [(~+ (|> bindings diff --git a/stdlib/source/library/lux/type/check.lux b/stdlib/source/library/lux/type/check.lux index 6b42b2d03..7241146ec 100644 --- a/stdlib/source/library/lux/type/check.lux +++ b/stdlib/source/library/lux/type/check.lux @@ -23,11 +23,11 @@ ["n" nat (.open: "[1]#[0]" decimal)]]]]] ["[0]" // (.open: "[1]#[0]" equivalence)]) -(def: !n#= +(def !n#= (template (_ reference subject) [("lux i64 =" reference subject)])) -(def: !text#= +(def !text#= (template (_ reference subject) [("lux text =" reference subject)])) @@ -74,10 +74,10 @@ (type: Type_Vars (List [Var (Maybe Type)])) -(def: .public functor +(def .public functor (Functor Check) (implementation - (def: (each f fa) + (def (each f fa) (function (_ context) (case (fa context) {try.#Success [context' output]} @@ -86,12 +86,12 @@ {try.#Failure error} {try.#Failure error}))))) -(def: .public apply +(def .public apply (Apply Check) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (on fa ff) + (def (on fa ff) (function (_ context) (case (ff context) {try.#Success [context' f]} @@ -107,16 +107,16 @@ ))) )) -(def: .public monad +(def .public monad (Monad Check) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in x) + (def (in x) (function (_ context) {try.#Success [context x]})) - (def: (conjoint ffa) + (def (conjoint ffa) (function (_ context) (case (ffa context) {try.#Success [context' fa]} @@ -134,11 +134,11 @@ (open: "check#[0]" ..monad) -(def: (var::new id plist) +(def (var::new id plist) (-> Var Type_Vars Type_Vars) {.#Item [id {.#None}] plist}) -(def: (var::get id plist) +(def (var::get id plist) (-> Var Type_Vars (Maybe (Maybe Type))) (case plist {.#Item [var_id var_type] @@ -150,7 +150,7 @@ {.#End} {.#None})) -(def: (var::put id value plist) +(def (var::put id value plist) (-> Var (Maybe Type) Type_Vars Type_Vars) (case plist {.#End} @@ -164,7 +164,7 @@ {.#Item [var_id var_type] (var::put id value plist')}))) -(def: .public (result context proc) +(def .public (result context proc) (All (_ a) (-> Type_Context (Check a) (Try a))) (case (proc context) {try.#Success [context' output]} @@ -173,23 +173,23 @@ {try.#Failure error} {try.#Failure error})) -(def: .public (failure message) +(def .public (failure message) (All (_ a) (-> Text (Check a))) (function (_ context) {try.#Failure message})) -(def: .public (assertion message test) +(def .public (assertion message test) (-> Text Bit (Check Any)) (function (_ context) (if test {try.#Success [context []]} {try.#Failure message}))) -(def: .public (except exception message) +(def .public (except exception message) (All (_ e a) (-> (Exception e) e (Check a))) (..failure (exception.error exception message))) -(def: .public existential +(def .public existential (Check [Nat Type]) (function (_ context) (let [id (the .#ex_counter context)] @@ -197,7 +197,7 @@ [id {.#Ex id}]]}))) (with_template [<name> <outputT> <fail> <succeed>] - [(def: .public (<name> id) + [(def .public (<name> id) (-> Var (Check <outputT>)) (function (_ context) (case (|> context (the .#var_bindings) (var::get id)) @@ -215,7 +215,7 @@ [peek (Maybe Type) {.#None} {.#Some bound}] ) -(def: .public (read id) +(def .public (read id) (-> Var (Check Type)) (do ..monad [?type (peek id)] @@ -226,7 +226,7 @@ {.#None} (..except ..unbound_type_var id)))) -(def: (bound id) +(def (bound id) (-> Var (Check Type)) (function (_ context) (case (|> context (the .#var_bindings) (var::get id)) @@ -239,7 +239,7 @@ _ (exception.except ..unknown_type_var id)))) -(def: .public (bind type id) +(def .public (bind type id) (-> Type Var (Check Any)) (function (_ context) (case (|> context (the .#var_bindings) (var::get id)) @@ -253,7 +253,7 @@ _ (exception.except ..unknown_type_var id)))) -(def: (re_bind' ?type id) +(def (re_bind' ?type id) (-> (Maybe Type) Var (Check Any)) (function (_ context) (case (|> context (the .#var_bindings) (var::get id)) @@ -264,11 +264,11 @@ _ (exception.except ..unknown_type_var id)))) -(def: (re_bind type id) +(def (re_bind type id) (-> Type Var (Check Any)) (re_bind' {.#Some type} id)) -(def: .public var +(def .public var (Check [Var Type]) (function (_ context) (let [id (the .#var_counter context)] @@ -277,7 +277,7 @@ (revised .#var_bindings (var::new id))) [id {.#Var id}]]}))) -(def: (on argT funcT) +(def (on argT funcT) (-> Type Type (Check Type)) (case funcT {.#Var func_id} @@ -303,7 +303,7 @@ _ (except ..invalid_type_application [funcT argT])))) -(def: .public (ring' start) +(def .public (ring' start) (-> Var (Check (List Var))) (function (_ context) (loop (again [current start @@ -326,12 +326,12 @@ (exception.except ..unknown_type_var current))))) ... TODO: Optimize this by not using sets anymore. -(def: ring +(def ring (-> Var (Check (Set Var))) (|>> ..ring' (check#each (set.of_list n.hash)))) -(def: .public (linked? @0 @1) +(def .public (linked? @0 @1) (-> Var Var (Check Bit)) (check#each (function (_ it) (set.member? it @1)) @@ -341,7 +341,7 @@ (exception.report "Var" (n#encoded var))) -(def: .public (identity aliases @) +(def .public (identity aliases @) (-> (List Var) Var (Check Type)) (do [! ..monad] [:bound: (..peek @)] @@ -364,7 +364,7 @@ {.#None} (..except ..cannot_identify [@])))))))) -(def: (erase! @) +(def (erase! @) (-> Var (Check Any)) (function (_ context) {try.#Success [(revised .#var_bindings @@ -382,7 +382,7 @@ context) []]})) -(def: .public (forget! @) +(def .public (forget! @) (-> Var (Check Any)) (do [! ..monad] [ring (..ring' @)] @@ -409,7 +409,7 @@ _ (undefined))))) -(def: .public (try it) +(def .public (try it) (All (_ a) (-> (Check a) (Check (Try a)))) (function (_ context) (case (it context) @@ -419,13 +419,13 @@ {try.#Failure error} {try.#Success [context {try.#Failure error}]}))) -(def: .public fresh_context +(def .public fresh_context Type_Context [.#var_counter 0 .#ex_counter 0 .#var_bindings (list)]) -(def: (either left right) +(def (either left right) (All (_ a) (-> (Check a) (Check a) (Check a))) (function (_ context) (case (left context) @@ -435,7 +435,7 @@ output output))) -(def: (assumed? [e a] assumptions) +(def (assumed? [e a] assumptions) (-> Assumption (List Assumption) Bit) (list.any? (function (_ [e' a']) (and (//#= e e') @@ -443,7 +443,7 @@ assumptions)) ... TODO: "if_can_bind" can be optimized... -(def: (if_can_bind id type then else) +(def (if_can_bind id type then else) (All (_ a) (-> Var Type (Check a) (-> Type (Check a)) (Check a))) @@ -461,21 +461,21 @@ (else (maybe.else {.#Var id} ?bound))))) ... TODO: "link/2" can be optimized... -(def: (link/2 left right) +(def (link/2 left right) (-> Var Var (Check Any)) (do ..monad [_ (..bind {.#Var right} left)] (..bind {.#Var left} right))) ... TODO: "link/3" can be optimized... -(def: (link/3 interpose to from) +(def (link/3 interpose to from) (-> Var Var Var (Check Any)) (do ..monad [_ (re_bind {.#Var interpose} from)] (re_bind {.#Var to} interpose))) ... TODO: "check_vars" can be optimized... -(def: (check_vars check' assumptions idE idA) +(def (check_vars check' assumptions idE idA) (-> (Checker Type) (Checker Var)) (if (!n#= idE idA) (check#in assumptions) @@ -541,12 +541,12 @@ _ (check' assumptions etype atype)))))) -(def: silent_failure! +(def silent_failure! (All (_ a) (Check a)) (..failure "")) ... TODO: "check_apply" can be optimized... -(def: (check_apply check' assumptions expected actual) +(def (check_apply check' assumptions expected actual) (-> (Checker Type) (Checker [Type Type])) (let [[expected_input expected_function] expected [actual_input actual_function] actual] @@ -632,14 +632,14 @@ _ ..silent_failure!))) -(def: (with_exception exception parameter check) +(def (with_exception exception parameter check) (All (_ e a) (-> (Exception e) e (Check a) (Check a))) (|>> check (exception.with exception parameter))) ... TODO: "check'" can be optimized... ... Type-check to ensure that the 'expected' type subsumes the 'actual' type. -(def: (check' assumptions expected actual) +(def (check' assumptions expected actual) (Checker Type) (if (for @.php ... TODO: Remove this once JPHP is gone. @@ -749,11 +749,11 @@ _ ..silent_failure!)))) -(def: .public (check expected actual) +(def .public (check expected actual) (-> Type Type (Check Any)) (check' (list) expected actual)) -(def: .public (subsumes? expected actual) +(def .public (subsumes? expected actual) (-> Type Type Bit) (case (..result ..fresh_context (..check expected actual)) @@ -763,17 +763,17 @@ {try.#Success _} true)) -(def: .public context +(def .public context (Check Type_Context) (function (_ context) {try.#Success [context context]})) -(def: .public (with context) +(def .public (with context) (-> Type_Context (Check Any)) (function (_ _) {try.#Success [context []]})) -(def: .public (clean aliases inputT) +(def .public (clean aliases inputT) (-> (List Var) Type (Check Type)) (case inputT {.#Primitive name paramsT+} diff --git a/stdlib/source/library/lux/type/dynamic.lux b/stdlib/source/library/lux/type/dynamic.lux index 3797e528c..169e16464 100644 --- a/stdlib/source/library/lux/type/dynamic.lux +++ b/stdlib/source/library/lux/type/dynamic.lux @@ -24,21 +24,21 @@ (primitive .public Dynamic [Type Any] - (def: abstraction + (def abstraction (-> [Type Any] Dynamic) (|>> primitive.abstraction)) - (def: representation + (def representation (-> Dynamic [Type Any]) (|>> primitive.representation)) - (def: .public dynamic + (def .public dynamic (syntax (_ [value <code>.any]) (with_symbols [g!value] (in (list (` (.let [(~ g!value) (~ value)] ((~! ..abstraction) [(.type_of (~ g!value)) (~ g!value)])))))))) - (def: .public static + (def .public static (syntax (_ [type <code>.any value <code>.any]) (with_symbols [g!type g!value] @@ -49,7 +49,7 @@ {try.#Success (.as (~ type) (~ g!value))} ((~! exception.except) ..wrong_type [(.type (~ type)) (~ g!type)])))))))))) - (def: .public (format value) + (def .public (format value) (-> Dynamic (Try Text)) (let [[type value] (primitive.representation value)] (debug.representation type value))) diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index 13b1d4c90..fb06527c8 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -26,7 +26,7 @@ ["[0]" type (.open: "[1]#[0]" equivalence) ["[0]" check (.only Check)]]]]) -(def: (type_var id env) +(def (type_var id env) (-> Nat Type_Context (Meta Type)) (case (list.example (|>> product.left (n.= id)) (the .#var_bindings env)) @@ -45,7 +45,7 @@ (meta.failure (format "Unknown type-var " (%.nat id))) )) -(def: (implicit_type var_name) +(def (implicit_type var_name) (-> Symbol (Meta Type)) (do meta.monad [raw_type (meta.type var_name) @@ -57,7 +57,7 @@ _ (in raw_type)))) -(def: (member_type idx sig_type) +(def (member_type idx sig_type) (-> Nat Type (Check Type)) (case sig_type {.#Named _ sig_type'} @@ -81,7 +81,7 @@ (at check.monad in sig_type) (check.failure (format "Cannot find member type " (%.nat idx) " for " (%.type sig_type)))))) -(def: (member_name member) +(def (member_name member) (-> Symbol (Meta Symbol)) (case member ["" simple_name] @@ -109,14 +109,14 @@ _ (at meta.monad in member))) -(def: (implicit_member member) +(def (implicit_member member) (-> Symbol (Meta [Nat Type])) (do meta.monad [member (member_name member) [idx tag_list sig_type] (meta.slot member)] (in [idx sig_type]))) -(def: (compatible_type? interface candidate) +(def (compatible_type? interface candidate) (-> Type Type Bit) (with_expansions [<found?> (type#= interface candidate)] (<| (or <found?>) @@ -133,7 +133,7 @@ (let [candidate (type.de_aliased candidate)]) <found?>))) -(def: (available_definitions sig_type source_module target_module constants aggregate) +(def (available_definitions sig_type source_module target_module constants aggregate) (-> Type Text Text (List [Text Definition]) (-> (List [Symbol Type]) (List [Symbol Type]))) (list#mix (function (_ [name [exported? def_type def_value]] aggregate) (if (and (or (text#= target_module source_module) @@ -144,7 +144,7 @@ aggregate constants)) -(def: (local_env sig_type) +(def (local_env sig_type) (-> Type (Meta (List [Symbol Type]))) (do meta.monad [local_batches meta.locals @@ -160,14 +160,14 @@ {.#Some [["" name] type]} {.#None}))))))) -(def: (local_structs sig_type) +(def (local_structs sig_type) (-> Type (Meta (List [Symbol Type]))) (do [! meta.monad] [this_module_name meta.current_module_name definitions (meta.definitions this_module_name)] (in (available_definitions sig_type this_module_name this_module_name definitions {.#End})))) -(def: (imported_structs sig_type) +(def (imported_structs sig_type) (-> Type (Meta (List [Symbol Type]))) (do [! meta.monad] [this_module_name meta.current_module_name @@ -178,7 +178,7 @@ {.#End} (list.zipped_2 imported_modules accessible_definitions))))) -(def: (on_argument arg func) +(def (on_argument arg func) (-> Type Type (Check Type)) (case func {.#Named _ func'} @@ -200,7 +200,7 @@ _ (check.failure (format "Invalid function type: " (%.type func))))) -(def: (concrete_type type) +(def (concrete_type type) (-> Type (Check [(List Nat) Type])) (case type {.#UnivQ _} @@ -213,7 +213,7 @@ _ (at check.monad in [(list) type]))) -(def: (ensure_function_application! member_type input_types expected_output) +(def (ensure_function_application! member_type input_types expected_output) (-> Type (List Type) Type (Check [])) (do check.monad [actual_output (monad.mix check.monad ..on_argument member_type input_types)] @@ -225,7 +225,7 @@ [#constructor Symbol #dependencies (List Instance)]))) -(def: (candidate_provision provision context dep alts) +(def (candidate_provision provision context dep alts) (-> (-> Lux Type_Context Type (Check Instance)) Type_Context Type (List [Symbol Type]) (Meta (List Instance))) @@ -253,7 +253,7 @@ found (in found)))) -(def: (provision sig_type compiler context dep) +(def (provision sig_type compiler context dep) (-> Type Lux Type_Context Type (Check Instance)) (case (meta.result compiler (all meta.either @@ -275,7 +275,7 @@ (check.failure (format "Too many candidates for provisioning: " (%.type dep) " --- " (%.list (|>> product.left %.symbol) candidates)))) )) -(def: (candidate_alternatives sig_type member_idx input_types output_type alts) +(def (candidate_alternatives sig_type member_idx input_types output_type alts) (-> Type Nat (List Type) Type (List [Symbol Type]) (Meta (List Instance))) (do meta.monad [compiler meta.compiler_state @@ -304,7 +304,7 @@ found (in found)))) -(def: (alternatives sig_type member_idx input_types output_type) +(def (alternatives sig_type member_idx input_types output_type) (-> Type Nat (List Type) Type (Meta (List Instance))) (let [test (candidate_alternatives sig_type member_idx input_types output_type)] (all meta.either @@ -312,7 +312,7 @@ (do meta.monad [alts (..local_structs sig_type)] (test alts)) (do meta.monad [alts (..imported_structs sig_type)] (test alts))))) -(def: (var? input) +(def (var? input) (-> Code Bit) (case input [_ {.#Symbol _}] @@ -321,11 +321,11 @@ _ #0)) -(def: (pair_list [l r]) +(def (pair_list [l r]) (All (_ a) (-> [a a] (List a))) (list l r)) -(def: (instance$ [constructor dependencies]) +(def (instance$ [constructor dependencies]) (-> Instance Code) (case dependencies {.#End} @@ -334,7 +334,7 @@ _ (` ((~ (code.symbol constructor)) (~+ (list#each instance$ dependencies)))))) -(def: .public a/an +(def .public a/an (syntax (_ [member <code>.symbol args (<>.or (<>.and (<>.some <code>.symbol) <code>.end) (<>.and (<>.some <code>.any) <code>.end))]) @@ -370,16 +370,16 @@ (..a/an (~ (code.symbol member)) (~+ labels))))))) ))) -(def: .public a ..a/an) -(def: .public an ..a/an) +(def .public a ..a/an) +(def .public an ..a/an) -(def: (implicit_bindings amount) +(def (implicit_bindings amount) (-> Nat (Meta (List Code))) (|> (macro.symbol "g!implicit") (list.repeated amount) (monad.all meta.monad))) -(def: .public with +(def .public with (syntax (_ [implementations (<code>.tuple (<>.many <code>.any)) body <code>.any]) (do meta.monad @@ -390,11 +390,11 @@ list#conjoint))] (~ body)))))))) -(def: .public implicitly +(def .public implicitly (syntax (_ [implementations (<>.many <code>.any)]) (do meta.monad [g!implicit+ (implicit_bindings (list.size implementations))] (in (|> (list.zipped_2 g!implicit+ implementations) (list#each (function (_ [g!implicit implementation]) - (` (def: .private (~ g!implicit) + (` (def .private (~ g!implicit) (~ implementation)))))))))) diff --git a/stdlib/source/library/lux/type/poly.lux b/stdlib/source/library/lux/type/poly.lux index aeb27188b..997c7b65f 100644 --- a/stdlib/source/library/lux/type/poly.lux +++ b/stdlib/source/library/lux/type/poly.lux @@ -24,7 +24,7 @@ [number ["n" nat]]]]]) -(def: .public polytypic +(def .public polytypic (syntax (_ [name <code>.local body <code>.any]) (with_symbols [g!_ g!type g!output] @@ -43,7 +43,7 @@ {.#Left (~ g!output)} ((~! meta.failure) (~ g!output)))))))))))) -(def: .public (code env type) +(def .public (code env type) (-> Env Type Code) (case type {.#Primitive name params} diff --git a/stdlib/source/library/lux/type/primitive.lux b/stdlib/source/library/lux/type/primitive.lux index 53202405e..274e07b32 100644 --- a/stdlib/source/library/lux/type/primitive.lux +++ b/stdlib/source/library/lux/type/primitive.lux @@ -24,15 +24,15 @@ (type: Stack List) -(def: peek +(def peek (All (_ a) (-> (Stack a) (Maybe a))) list.head) -(def: (push value stack) +(def (push value stack) (All (_ a) (-> a (Stack a) (Stack a))) {.#Item value stack}) -(def: pop +(def pop (All (_ a) (-> (Stack a) (Maybe (Stack a)))) list.tail) @@ -43,11 +43,11 @@ #abstraction Code #representation Code])) -(def: frames +(def frames (Stack Frame) {.#End}) -(def: !peek +(def !peek (template (_ <source> <reference> <then>) [(loop (again [entries <source>]) (case entries @@ -59,7 +59,7 @@ {.#End} (undefined)))])) -(def: (peek_frames_definition reference source) +(def (peek_frames_definition reference source) (-> Text (List [Text Global]) (Stack Frame)) (!peek source reference (case head @@ -72,14 +72,14 @@ {.#Slot _}) (undefined)))) -(def: (peek_frames reference definition_reference source) +(def (peek_frames reference definition_reference source) (-> Text Text (List [Text Module]) (Stack Frame)) (!peek source reference (peek_frames_definition definition_reference (the .#definitions head)))) (exception: .public no_active_frames) -(def: (peek! frame) +(def (peek! frame) (-> (Maybe Text) (Meta Frame)) (function (_ compiler) (let [[reference definition_reference] (symbol ..frames) @@ -98,15 +98,15 @@ {.#None} (exception.except ..no_active_frames []))))) -(def: .public current +(def .public current (Meta Frame) (..peek! {.#None})) -(def: .public (specific name) +(def .public (specific name) (-> Text (Meta Frame)) (..peek! {.#Some name})) -(def: !push +(def !push (template (_ <source> <reference> <then>) [(loop (again [entries <source>]) (case entries @@ -120,7 +120,7 @@ {.#End} (undefined)))])) -(def: (push_frame_definition reference frame source) +(def (push_frame_definition reference frame source) (-> Text Frame (List [Text Global]) (List [Text Global])) (!push source reference (case head @@ -135,12 +135,12 @@ {.#Slot _}) (undefined)))) -(def: (push_frame [module_reference definition_reference] frame source) +(def (push_frame [module_reference definition_reference] frame source) (-> Symbol Frame (List [Text Module]) (List [Text Module])) (!push source module_reference (revised .#definitions (push_frame_definition definition_reference frame) head))) -(def: (push! frame) +(def (push! frame) (-> Frame (Meta Any)) (function (_ compiler) {.#Right [(revised .#modules @@ -148,7 +148,7 @@ compiler) []]})) -(def: (pop_frame_definition reference source) +(def (pop_frame_definition reference source) (-> Text (List [Text Global]) (List [Text Global])) (!push source reference (case head @@ -169,12 +169,12 @@ {.#Slot _}) (undefined)))) -(def: (pop_frame [module_reference definition_reference] source) +(def (pop_frame [module_reference definition_reference] source) (-> Symbol (List [Text Module]) (List [Text Module])) (!push source module_reference (|> head (revised .#definitions (pop_frame_definition definition_reference))))) -(def: pop! +(def pop! (syntax (_ []) (function (_ compiler) {.#Right [(revised .#modules @@ -182,13 +182,13 @@ compiler) (list)]}))) -(def: cast +(def cast (Parser [(Maybe Text) Code]) (<>.either (<>.and (<>.maybe <code>.local) <code>.any) (<>.and (<>#in {.#None}) <code>.any))) (with_template [<name> <from> <to>] - [(def: .public <name> + [(def .public <name> (syntax (_ [[frame value] ..cast]) (do meta.monad [[name type_vars abstraction representation] (peek! frame)] @@ -199,22 +199,22 @@ [representation abstraction representation] ) -(def: abstraction_type_name +(def abstraction_type_name (-> Symbol Text) symbol#encoded) -(def: representation_definition_name +(def representation_definition_name (-> Text Text) (|>> (all text#composite (symbol#encoded (symbol ..#Representation)) " "))) -(def: declaration +(def declaration (Parser [Text (List Text)]) (<>.either (<code>.form (<>.and <code>.local (<>.some <code>.local))) (<>.and <code>.local (at <>.monad in (list))))) -(def: abstract +(def abstract (Parser [Code [Text (List Text)] Code (List Code)]) (|export|.parser (all <>.and @@ -225,7 +225,7 @@ ... TODO: Make sure the generated code always gets optimized away. ... (This applies to uses of "abstraction" and "representation") -(def: .public primitive +(def .public primitive (syntax (_ [[export_policy [name type_vars] representation_type primitives] ..abstract]) (do meta.monad @@ -252,12 +252,12 @@ {#Specific Code a} {#Current a})) -(def: (selection parser) +(def (selection parser) (All (_ a) (-> (Parser a) (Parser (Selection a)))) (<>.or (<>.and <code>.any parser) parser)) -(def: .public transmutation +(def .public transmutation (syntax (_ [selection (..selection <code>.any)]) (case selection {#Specific specific value} diff --git a/stdlib/source/library/lux/type/quotient.lux b/stdlib/source/library/lux/type/quotient.lux index da7c38025..355e14d0e 100644 --- a/stdlib/source/library/lux/type/quotient.lux +++ b/stdlib/source/library/lux/type/quotient.lux @@ -14,7 +14,7 @@ (primitive .public (Class t c %) (-> t c) - (def: .public class + (def .public class (All (_ t c) (Ex (_ %) (-> (-> t c) (Class t c %)))) @@ -25,7 +25,7 @@ [#value t #label c]) - (def: .public (quotient class value) + (def .public (quotient class value) (All (_ t c %) (-> (Class t c %) t (Quotient t c %))) @@ -33,7 +33,7 @@ #label ((representation Class class) value)])) (with_template [<name> <output> <slot>] - [(def: .public <name> + [(def .public <name> (All (_ t c %) (-> (Quotient t c %) <output>)) (|>> representation (the <slot>)))] @@ -43,7 +43,7 @@ ) ) -(def: .public type +(def .public type (syntax (_ [class <code>.any]) ... TODO: Switch to the cleaner approach ASAP. (with_symbols [g!t g!c g!% g!_ g!:quotient:] @@ -63,8 +63,8 @@ ... (..Quotient (~ g!t) (~ g!c) (~ g!%)))) ))))) -(def: .public (equivalence super) +(def .public (equivalence super) (All (_ t c %) (-> (Equivalence c) (Equivalence (..Quotient t c %)))) (implementation - (def: (= reference sample) + (def (= reference sample) (at super = (..label reference) (..label sample))))) diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux index 0fb387039..5b1cec8db 100644 --- a/stdlib/source/library/lux/type/refinement.lux +++ b/stdlib/source/library/lux/type/refinement.lux @@ -19,7 +19,7 @@ (type: .public (Refiner t %) (-> t (Maybe (Refined t %)))) - (def: .public (refiner predicate) + (def .public (refiner predicate) (All (_ t) (Ex (_ %) (-> (Predicate t) (Refiner t %)))) @@ -30,7 +30,7 @@ {.#None}))) (with_template [<name> <output> <slot>] - [(def: .public <name> + [(def .public <name> (All (_ t %) (-> (Refined t %) <output>)) (|>> representation (the <slot>)))] @@ -38,7 +38,7 @@ [predicate (Predicate t) #predicate] ) - (def: .public (lifted transform) + (def .public (lifted transform) (All (_ t %) (-> (-> t t) (-> (Refined t %) (Maybe (Refined t %))))) @@ -51,7 +51,7 @@ {.#None})))) ) -(def: .public (only refiner values) +(def .public (only refiner values) (All (_ t %) (-> (Refiner t %) (List t) (List (Refined t %)))) (case values @@ -66,7 +66,7 @@ {.#None} (only refiner tail)))) -(def: .public (partition refiner values) +(def .public (partition refiner values) (All (_ t %) (-> (Refiner t %) (List t) [(List (Refined t %)) (List t)])) (case values @@ -84,7 +84,7 @@ [yes {.#Item head no}])))) -(def: .public type +(def .public type (syntax (_ [refiner <code>.any]) ... TODO: Switch to the cleaner approach ASAP. (macro.with_symbols [g!t g!% g!_ g!:refiner:] diff --git a/stdlib/source/library/lux/type/resource.lux b/stdlib/source/library/lux/type/resource.lux index 0827dde1e..c906fc13e 100644 --- a/stdlib/source/library/lux/type/resource.lux +++ b/stdlib/source/library/lux/type/resource.lux @@ -40,26 +40,26 @@ (All (_ keys) (Procedure monad [permissions keys] keys value))) -(def: .public (monad monad) +(def .public (monad monad) (All (_ !) (-> (Monad !) (IxMonad (Procedure !)))) (implementation - (def: (in value) + (def (in value) (function (_ keys) (at monad in [keys value]))) - (def: (then f input) + (def (then f input) (function (_ keysI) (do monad [[keysT value] (input keysI)] ((f value) keysT)))))) -(def: .public (run! monad procedure) +(def .public (run! monad procedure) (All (_ ! v) (-> (Monad !) (Linear ! v) (! v))) (do monad [[_ output] (procedure [])] (in output))) -(def: .public (lifted monad procedure) +(def .public (lifted monad procedure) (All (_ ! v) (-> (Monad !) (! v) (Linear ! v))) (function (_ keys) (do monad @@ -73,7 +73,7 @@ Any (with_template [<name> <mode>] - [(def: <name> + [(def <name> (Ex (_ k) (-> Any (Key <mode> k))) (|>> abstraction))] @@ -85,7 +85,7 @@ value (with_template [<name> <mode> <key>] - [(def: .public (<name> monad value) + [(def .public (<name> monad value) (All (_ ! v) (Ex (_ k) (-> (Monad !) v (Affine ! (Key <mode> k) (Res k v))))) (function (_ keys) (at monad in [[(<key> []) keys] (abstraction value)])))] @@ -94,7 +94,7 @@ [commutative Commutative ..commutative_key] ) - (def: .public (read monad resource) + (def .public (read monad resource) (All (_ ! v k m) (-> (Monad !) (Res k v) (Relevant ! (Key m k) v))) (function (_ [key keys]) @@ -107,7 +107,7 @@ (exception: .public amount_cannot_be_zero) -(def: indices +(def indices (Parser (List Nat)) (<code>.tuple (loop (again [seen (set.empty n.hash)]) (do [! <>.monad] @@ -121,12 +121,12 @@ tail (again (set.has head seen))] (in (list.partial head tail)))))))) -(def: (no_op monad) +(def (no_op monad) (All (_ m) (-> (Monad m) (Linear m Any))) (function (_ context) (at monad in [context []]))) -(def: .public exchange +(def .public exchange (syntax (_ [swaps ..indices]) (macro.with_symbols [g!_ g!context g!!] (case swaps @@ -157,7 +157,7 @@ (function ((~ g!_) (~ g!!) [(~+ g!inputs) (~ g!context)]) (at (~ g!!) (~' in) [[(~+ g!outputs) (~ g!context)] []]))))))))))) -(def: amount +(def amount (Parser Nat) (do <>.monad [raw <code>.nat @@ -166,7 +166,7 @@ (in raw))) (with_template [<name> <from> <to>] - [(def: .public <name> + [(def .public <name> (syntax (_ [amount ..amount]) (macro.with_symbols [g!_ g!context g!!] (do [! meta.monad] diff --git a/stdlib/source/library/lux/type/unit.lux b/stdlib/source/library/lux/type/unit.lux index 9a84487e4..ba76121f0 100644 --- a/stdlib/source/library/lux/type/unit.lux +++ b/stdlib/source/library/lux/type/unit.lux @@ -19,37 +19,37 @@ (primitive .public (Qty scale unit) Int - (def: .public quantity + (def .public quantity (All (_ scale unit) (-> Int (Qty scale unit))) (|>> abstraction)) - (def: .public number + (def .public number (All (_ scale unit) (-> (Qty scale unit) Int)) (|>> representation)) - (def: .public equivalence + (def .public equivalence (All (_ scale unit) (Equivalence (Qty scale unit))) (implementation - (def: (= reference sample) + (def (= reference sample) (i.= (representation reference) (representation sample))))) - (def: .public order + (def .public order (All (_ scale unit) (Order (Qty scale unit))) (implementation - (def: equivalence ..equivalence) + (def equivalence ..equivalence) - (def: (< reference sample) + (def (< reference sample) (i.< (representation reference) (representation sample))))) - (def: .public enum + (def .public enum (All (_ scale unit) (Enum (Qty scale unit))) (implementation - (def: order ..order) - (def: succ (|>> representation ++ abstraction)) - (def: pred (|>> representation -- abstraction)))) + (def order ..order) + (def succ (|>> representation ++ abstraction)) + (def pred (|>> representation -- abstraction)))) (with_template [<name> <op>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (All (_ scale unit) (-> (Qty scale unit) (Qty scale unit) (Qty scale unit))) (abstraction (<op> (representation param) (representation subject))))] @@ -59,7 +59,7 @@ ) (with_template [<name> <op> <p> <s> <p*s>] - [(def: .public (<name> param subject) + [(def .public (<name> param subject) (All (_ scale p s) (-> (Qty scale <p>) (Qty scale <s>) (Qty scale <p*s>))) (abstraction (<op> (representation param) (representation subject))))] @@ -75,14 +75,14 @@ (is (-> (Qty Any a) Int) out))) - (def: .public (unit _) + (def .public (unit _) (Ex (_ a) (-> Any (Unit a))) (implementation - (def: in ..quantity) - (def: out ..number))) + (def in ..quantity) + (def out ..number))) ) -(def: .public type +(def .public type (syntax (_ [it <code>.any]) (macro.with_symbols [g!a] (in (list (` ((~! //.by_example) [(~ g!a)] @@ -91,7 +91,7 @@ (~ g!a)))))))) (with_template [<unit> <type>] - [(def: .public <unit> + [(def .public <unit> (..unit [])) (type: .public <type> diff --git a/stdlib/source/library/lux/type/unit/scale.lux b/stdlib/source/library/lux/type/unit/scale.lux index fe2d020bf..efca489a0 100644 --- a/stdlib/source/library/lux/type/unit/scale.lux +++ b/stdlib/source/library/lux/type/unit/scale.lux @@ -22,24 +22,24 @@ (is Ratio ratio))) -(def: .public (scale ratio) +(def .public (scale ratio) (Ex (_ s) (-> Ratio (Scale s))) (let [(open "/[0]") ratio] (implementation - (def: up + (def up (|>> //.number (i.* (.int /#numerator)) (i./ (.int /#denominator)) //.quantity)) - (def: down + (def down (|>> //.number (i.* (.int /#denominator)) (i./ (.int /#numerator)) //.quantity)) - (def: ratio + (def ratio ratio)))) -(def: .public (re_scaled from to quantity) +(def .public (re_scaled from to quantity) (All (_ si so u) (-> (Scale si) (Scale so) (//.Qty si u) (//.Qty so u))) (let [(open "/[0]") (ratio./ (at from ratio) (at to ratio))] @@ -49,7 +49,7 @@ (i./ (.int /#denominator)) //.quantity))) -(def: .public type +(def .public type (syntax (_ [it <code>.any]) (macro.with_symbols [g!a] (in (list (` ((~! ///.by_example) [(~ g!a)] @@ -58,14 +58,14 @@ (~ g!a)))))))) (with_template [<order_of_magnitude> <up> <up_type> <down> <down_type>] - [(def: .public <up> + [(def .public <up> (scale [ratio.#numerator <order_of_magnitude> ratio.#denominator 1])) (type: .public <up_type> (~ (..type <up>))) - (def: .public <down> + (def .public <down> (scale [ratio.#numerator 1 ratio.#denominator <order_of_magnitude>])) diff --git a/stdlib/source/library/lux/type/variance.lux b/stdlib/source/library/lux/type/variance.lux index 49563c465..53797fc61 100644 --- a/stdlib/source/library/lux/type/variance.lux +++ b/stdlib/source/library/lux/type/variance.lux @@ -17,7 +17,7 @@ (Primitive "#Mutable" [(-> w r)])) (with_template [<name> <type>] - [(def: .public <name> + [(def .public <name> (template (<name> it) [((.is (.All (_ r w) <type>) (.|>> .as_expected)) @@ -34,7 +34,7 @@ (Mutable Any a)) (with_template [<name> <type>] - [(def: .public <name> + [(def .public <name> (template (<name> it) [((.is (.All (_ r w) <type>) (.|>>)) diff --git a/stdlib/source/library/lux/world/console.lux b/stdlib/source/library/lux/world/console.lux index 4112af8f4..b5cc2db91 100644 --- a/stdlib/source/library/lux/world/console.lux +++ b/stdlib/source/library/lux/world/console.lux @@ -28,11 +28,11 @@ (is (-> [] (! (Try Any))) close))) -(def: .public (async console) +(def .public (async console) (-> (Console IO) (Console Async)) (`` (implementation (~~ (with_template [<capability>] - [(def: <capability> + [(def <capability> (|>> (at console <capability>) async.future))] [read] @@ -65,7 +65,7 @@ (exception: .public cannot_open) - (def: .public default + (def .public default (IO (Try (Console IO))) (do io.monad [?jvm_console (java/lang/System::console)] @@ -80,19 +80,19 @@ {try.#Success} (is (Console IO)) ... TODO: Remove ASAP (implementation - (def: (read _) + (def (read _) (|> jvm_input java/io/InputStream::read (at (try.with io.monad) each (|>> ffi.of_int .nat)))) - (def: (read_line _) + (def (read_line _) (io#each (try#each (|>> ffi.of_string)) (java/io/Console::readLine jvm_console))) - (def: (write message) + (def (write message) (java/io/PrintStream::print (ffi.as_string message) jvm_output)) - (def: close + (def close (|>> (exception.except ..cannot_close) in)))))))))] (for @.old (these <jvm>) @.jvm (these <jvm>) @@ -118,7 +118,7 @@ (exception: .public cannot_read) - (def: !read + (def !read (template (_ <type> <query>) [(let [it (process::stdin)] (case (Readable_Stream::read it) @@ -139,20 +139,20 @@ {.#None} (async#in (exception.except ..cannot_read []))))])) - (def: .public default + (def .public default (Maybe (Console Async)) (if ffi.on_node_js? {.#Some (implementation - (def: (read _) + (def (read _) (!read Char (do maybe.monad [head (text.char 0 input) [_ tail] (text.split_at 1 input)] (in [head tail])))) - (def: (read_line _) + (def (read_line _) (!read Text (text.split_by text.\n input))) - (def: (write it) + (def (write it) (let [[read! write!] (is [(async.Async (Try [])) (async.Resolver (Try []))] (async.async []))] (exec @@ -160,12 +160,12 @@ (process::stdout)) read!))) - (def: close + (def close (|>> (exception.except ..cannot_close) async#in)))} {.#None}))) (these))) -(def: .public (write_line message console) +(def .public (write_line message console) (All (_ !) (-> Text (Console !) (! (Try Any)))) (at console write (format message text.new_line))) @@ -180,12 +180,12 @@ (is (-> s (Try s)) on_close))) -(def: .public (mock mock init) +(def .public (mock mock init) (All (_ s) (-> (Mock s) s (Console IO))) (let [state (atom.atom init)] (`` (implementation (~~ (with_template [<method> <mock>] - [(def: (<method> _) + [(def (<method> _) (do [! io.monad] [|state| (atom.read! state)] (case (at mock <mock> |state|) @@ -201,7 +201,7 @@ [read_line on_read_line] )) - (def: (write input) + (def (write input) (do [! io.monad] [|state| (atom.read! state)] (case (at mock on_write input |state|) @@ -213,7 +213,7 @@ {try.#Failure error} (in {try.#Failure error})))) - (def: (close _) + (def (close _) (do [! io.monad] [|state| (atom.read! state)] (case (at mock on_close |state|) diff --git a/stdlib/source/library/lux/world/db/jdbc.lux b/stdlib/source/library/lux/world/db/jdbc.lux index d19e53c47..243ced2bf 100644 --- a/stdlib/source/library/lux/world/db/jdbc.lux +++ b/stdlib/source/library/lux/world/db/jdbc.lux @@ -90,7 +90,7 @@ (is (Can_Close !) close))) -(def: (with_statement statement conn action) +(def (with_statement statement conn action) (All (_ i a) (-> (Statement i) java/sql/Connection (-> java/sql/PreparedStatement (IO (Try a))) @@ -104,18 +104,18 @@ _ (java/sql/Statement::close prepared)] (in result))) -(def: .public (async db) +(def .public (async db) (-> (DB IO) (DB Async)) (`` (implementation (~~ (with_template [<name> <forge>] - [(def: <name> (<forge> (|>> (!.use (at db <name>)) async.future)))] + [(def <name> (<forge> (|>> (!.use (at db <name>)) async.future)))] [execute can_execute] [insert can_insert] [close can_close] [query can_query]))))) -(def: .public (connect creds) +(def .public (connect creds) (-> Credentials (IO (Try (DB IO)))) (do (try.with io.monad) [connection (java/sql/DriverManager::getConnection (the #url creds) @@ -123,7 +123,7 @@ (the #password creds))] (in (is (DB IO) (implementation - (def: execute + (def execute (..can_execute (function (execute statement) (with_statement statement connection @@ -132,7 +132,7 @@ [row_count (java/sql/PreparedStatement::executeUpdate prepared)] (in (.nat row_count)))))))) - (def: insert + (def insert (..can_insert (function (insert statement) (with_statement statement connection @@ -142,12 +142,12 @@ result_set (io.io (java/sql/Statement::getGeneratedKeys prepared))] (/output.rows /output.long result_set))))))) - (def: close + (def close (..can_close (function (close _) (java/sql/Connection::close connection)))) - (def: query + (def query (..can_query (function (query [statement output]) (with_statement statement connection @@ -157,7 +157,7 @@ (/output.rows output result_set))))))) ))))) -(def: .public (with_db creds action) +(def .public (with_db creds action) (All (_ a) (-> Credentials (-> (DB IO) (IO (Try a))) @@ -168,7 +168,7 @@ _ (!.use (at db close) [])] (in result))) -(def: .public (with_async_db creds action) +(def .public (with_async_db creds action) (All (_ a) (-> Credentials (-> (DB Async) (Async (Try a))) diff --git a/stdlib/source/library/lux/world/db/jdbc/input.lux b/stdlib/source/library/lux/world/db/jdbc/input.lux index 7a8c47899..c0e48dec4 100644 --- a/stdlib/source/library/lux/world/db/jdbc/input.lux +++ b/stdlib/source/library/lux/world/db/jdbc/input.lux @@ -47,32 +47,32 @@ (-> a [Nat java/sql/PreparedStatement] (Try [Nat java/sql/PreparedStatement]))) -(def: .public contravariant +(def .public contravariant (Contravariant Input) (implementation - (def: (each f fb) + (def (each f fb) (function (fa value circumstance) (fb (f value) circumstance))))) -(def: .public (and pre post) +(def .public (and pre post) (All (_ l r) (-> (Input l) (Input r) (Input [l r]))) (function (_ [left right] context) (do try.monad [context (pre left context)] (post right context)))) -(def: .public (fail error) +(def .public (fail error) (All (_ a) (-> Text (Input a))) (function (_ value [idx context]) {try.#Failure error})) -(def: .public empty +(def .public empty (Input Any) (function (_ value context) {try.#Success context})) (with_template [<function> <type> <setter>] - [(def: .public <function> + [(def .public <function> (Input <type>) (function (_ value [idx statement]) (do try.monad @@ -94,7 +94,7 @@ ) (with_template [<function> <setter> <constructor>] - [(def: .public <function> + [(def .public <function> (Input Instant) (function (_ value [idx statement]) (do try.monad diff --git a/stdlib/source/library/lux/world/db/jdbc/output.lux b/stdlib/source/library/lux/world/db/jdbc/output.lux index 3035cff80..a844ac78a 100644 --- a/stdlib/source/library/lux/world/db/jdbc/output.lux +++ b/stdlib/source/library/lux/world/db/jdbc/output.lux @@ -50,10 +50,10 @@ (type: .public (Output a) (-> [Nat java/sql/ResultSet] (Try [Nat a]))) -(def: .public functor +(def .public functor (Functor Output) (implementation - (def: (each f fa) + (def (each f fa) (function (_ idx+rs) (case (fa idx+rs) {try.#Failure error} @@ -62,12 +62,12 @@ {try.#Success [idx' value]} {try.#Success [idx' (f value)]}))))) -(def: .public apply +(def .public apply (Apply Output) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (apply ff fa) + (def (apply ff fa) (function (_ [idx rs]) (case (ff [idx rs]) {try.#Success [idx' f]} @@ -81,16 +81,16 @@ {try.#Failure msg} {try.#Failure msg}))))) -(def: .public monad +(def .public monad (Monad Output) (implementation - (def: functor ..functor) + (def functor ..functor) - (def: (in a) + (def (in a) (function (_ [idx rs]) {.#Some [idx a]})) - (def: (conjoint mma) + (def (conjoint mma) (function (_ [idx rs]) (case (mma [idx rs]) {try.#Failure error} @@ -99,12 +99,12 @@ {try.#Success [idx' ma]} (ma [idx' rs])))))) -(def: .public (fail error) +(def .public (fail error) (All (_ a) (-> Text (Output a))) (function (_ [idx result_set]) {try.#Failure error})) -(def: .public (and left right) +(def .public (and left right) (All (_ a b) (-> (Output a) (Output b) (Output [a b]))) (do ..monad @@ -113,7 +113,7 @@ (in [=left =right]))) (with_template [<func_name> <method_name> <type>] - [(def: .public <func_name> + [(def .public <func_name> (Output <type>) (function (_ [idx result_set]) (case (<method_name> [(.int idx)] result_set) @@ -138,7 +138,7 @@ ) (with_template [<func_name> <method_name>] - [(def: .public <func_name> + [(def .public <func_name> (Output Instant) (function (_ [idx result_set]) (case (<method_name> [(.int idx)] result_set) @@ -154,7 +154,7 @@ [time_stamp java/sql/ResultSet::getTimestamp] ) -(def: .public (rows output results) +(def .public (rows output results) (All (_ a) (-> (Output a) java/sql/ResultSet (IO (Try (List a))))) (case (java/sql/ResultSet::next results) {try.#Success has_next?} diff --git a/stdlib/source/library/lux/world/db/sql.lux b/stdlib/source/library/lux/world/db/sql.lux index 5c9fedc94..5dd75c61e 100644 --- a/stdlib/source/library/lux/world/db/sql.lux +++ b/stdlib/source/library/lux/world/db/sql.lux @@ -15,7 +15,7 @@ [type [primitive (.except)]]]]) -(def: parenthesize +(def parenthesize (-> Text Text) (text.enclosed ["(" ")"])) @@ -60,7 +60,7 @@ (type: .public Alias Text) -(def: .public no_alias Alias "") +(def .public no_alias Alias "") (primitive .public (SQL kind) Text @@ -97,51 +97,51 @@ [Statement (Statement' Any)] ) - (def: Base_Query (.type (Query No_Where No_Having No_Order No_Group No_Limit No_Offset))) - (def: Any_Query (.type (Query Any Any Any Any Any Any))) + (def Base_Query (.type (Query No_Where No_Having No_Order No_Group No_Limit No_Offset))) + (def Any_Query (.type (Query Any Any Any Any Any Any))) ... Only use this function for debugging purposes. ... Do not use this function to actually execute SQL code. - (def: .public read + (def .public read (-> (SQL Any) Text) (|>> representation)) - (def: .public (sql action) + (def .public (sql action) (-> Statement Text) (format (representation action) ";")) - (def: listing + (def listing (-> (List (SQL Any)) Text) (|>> (list#each (|>> representation)) (text.interposed ", "))) ... Value - (def: .public ? Placeholder (abstraction "?")) + (def .public ? Placeholder (abstraction "?")) - (def: literal + (def literal (-> Text Literal) (|>> abstraction)) - (def: .public null Literal (..literal "NULL")) + (def .public null Literal (..literal "NULL")) - (def: .public (int value) + (def .public (int value) (-> Int Literal) (..literal (if (i.< +0 value) (%.int value) (%.nat (.nat value))))) - (def: .public function + (def .public function (-> Text Function) (|>> abstraction)) - (def: .public (call function parameters) + (def .public (call function parameters) (-> Function (List Value) Value) (abstraction (format (representation function) (..parenthesize (..listing parameters))))) ... Condition (with_template [<name> <sql_op>] - [(def: .public (<name> reference sample) + [(def .public (<name> reference sample) (-> Value Value Condition) (abstraction (..parenthesize @@ -160,7 +160,7 @@ [ilike? "ILIKE"] ) - (def: .public (between from to sample) + (def .public (between from to sample) (-> Value Value Value Condition) (abstraction (..parenthesize @@ -168,7 +168,7 @@ " BETWEEN " (representation from) " AND " (representation to))))) - (def: .public (in options value) + (def .public (in options value) (-> (List Value) Value Condition) (abstraction (format (representation value) @@ -176,7 +176,7 @@ (..parenthesize (listing options))))) (with_template [<func_name> <sql_op>] - [(def: .public (<func_name> left right) + [(def .public (<func_name> left right) (-> Condition Condition Condition) (abstraction (format (..parenthesize (representation left)) @@ -188,7 +188,7 @@ ) (with_template [<name> <type> <sql>] - [(def: .public <name> + [(def .public <name> (-> <type> Condition) (|>> representation ..parenthesize (format <sql> " ") abstraction))] @@ -198,7 +198,7 @@ ... Query (with_template [<name> <type> <decoration>] - [(def: .public <name> + [(def .public <name> (-> <type> Source) (|>> representation <decoration> abstraction))] @@ -208,7 +208,7 @@ ) (with_template [<func_name> <op>] - [(def: .public (<func_name> columns source) + [(def .public (<func_name> columns source) (-> (List [Column Alias]) Source Base_Query) (abstraction (format <op> @@ -232,7 +232,7 @@ ) (with_template [<name> <join_text>] - [(def: .public (<name> table condition prev) + [(def .public (<name> table condition prev) (-> Table Condition Base_Query Base_Query) (abstraction (format (representation prev) @@ -247,7 +247,7 @@ ) (with_template [<function> <sql_op>] - [(def: .public (<function> left right) + [(def .public (<function> left right) (-> Any_Query Any_Query (Query Without_Where Without_Having No_Order No_Group No_Limit No_Offset)) (abstraction (format (representation left) @@ -260,7 +260,7 @@ ) (with_template [<name> <sql> <variables> <input> <output>] - [(`` (def: .public (<name> value query) + [(`` (def .public (<name> value query) (All (_ (~~ (template.spliced <variables>))) (-> Nat <input> <output>)) (abstraction @@ -278,7 +278,7 @@ ) (with_template [<name> <sql>] - [(def: .public <name> + [(def .public <name> Order (abstraction <sql>))] @@ -286,7 +286,7 @@ [descending "DESC"] ) - (def: .public (order_by pairs query) + (def .public (order_by pairs query) (All (_ where having group limit offset) (-> (List [Value Order]) (Query where having No_Order group limit offset) @@ -304,7 +304,7 @@ (format (representation value) " " (representation order)))) (text.interposed ", ")))))) - (def: .public (group_by pairs query) + (def .public (group_by pairs query) (All (_ where having order limit offset) (-> (List Value) (Query where having order No_Group limit offset) @@ -320,7 +320,7 @@ (..listing pairs))))) ... Command - (def: .public (insert table columns rows) + (def .public (insert table columns rows) (-> Table (List Column) (List (List Value)) (Command Without_Where Without_Having)) (abstraction (format "INSERT INTO " (representation table) " " @@ -331,7 +331,7 @@ (text.interposed ", ")) ))) - (def: .public (update table pairs) + (def .public (update table pairs) (-> Table (List [Column Value]) (Command No_Where No_Having)) (abstraction (format "UPDATE " (representation table) (case pairs @@ -344,12 +344,12 @@ (format (representation column) "=" (representation value)))) (text.interposed ", "))))))) - (def: .public delete + (def .public delete (-> Table (Command No_Where No_Having)) (|>> representation (format "DELETE FROM ") abstraction)) ... Action - (def: .public (where condition prev) + (def .public (where condition prev) (All (_ kind having) (-> Condition (Action No_Where having kind) (Action With_Where having kind))) (abstraction @@ -357,7 +357,7 @@ " WHERE " (representation condition)))) - (def: .public (having condition prev) + (def .public (having condition prev) (All (_ where kind) (-> Condition (Action where No_Having kind) (Action where With_Having kind))) (abstraction @@ -366,12 +366,12 @@ (representation condition)))) ... Schema - (def: .public type + (def .public type (-> Text (Schema Value)) (|>> abstraction)) (with_template [<name> <attr>] - [(def: .public (<name> attr) + [(def .public (<name> attr) (-> (Schema Value) (Schema Value)) (abstraction (format (representation attr) " " <attr>)))] @@ -381,22 +381,22 @@ [stored "STORED"] ) - (def: .public (default value attr) + (def .public (default value attr) (-> Value (Schema Value) (Schema Value)) (abstraction (format (representation attr) " DEFAULT " (representation value)))) - (def: .public (define_column name type) + (def .public (define_column name type) (-> Column (Schema Value) (Schema Column)) (abstraction (format (representation name) " " (representation type)))) - (def: .public (auto_increment offset column) + (def .public (auto_increment offset column) (-> Int (Schema Column) (Schema Column)) (abstraction (format (representation column) " AUTO_INCREMENT=" (representation (..int offset))))) - (def: .public (create_table or_replace? table columns) + (def .public (create_table or_replace? table columns) (-> Bit Table (List (Schema Column)) Definition) (let [command (if or_replace? "CREATE OR REPLACE TABLE" @@ -405,13 +405,13 @@ (format command " " (representation table) (..parenthesize (..listing columns)))))) - (def: .public (create_table_as table query) + (def .public (create_table_as table query) (-> Table Any_Query Definition) (abstraction (format "CREATE TABLE " (representation table) " AS " (representation query)))) (with_template [<name> <sql>] - [(def: .public (<name> table) + [(def .public (<name> table) (-> Table Definition) (abstraction (format <sql> " TABLE " (representation table))))] @@ -420,18 +420,18 @@ [truncate "TRUNCATE"] ) - (def: .public (add_column table column) + (def .public (add_column table column) (-> Table (Schema Column) Definition) (abstraction (format "ALTER TABLE " (representation table) " ADD " (representation column)))) - (def: .public (drop_column table column) + (def .public (drop_column table column) (-> Table Column Definition) (abstraction (format "ALTER TABLE " (representation table) " DROP COLUMN " (representation column)))) (with_template [<name> <type>] - [(def: .public (<name> name) + [(def .public (<name> name) (-> Text <type>) (abstraction name))] @@ -443,7 +443,7 @@ ) (with_template [<name> <type> <sql>] - [(def: .public <name> + [(def .public <name> (-> <type> Definition) (|>> representation (format <sql> " ") abstraction))] @@ -453,7 +453,7 @@ ) (with_template [<name> <sql>] - [(def: .public (<name> view query) + [(def .public (<name> view query) (-> View Any_Query Definition) (abstraction (format <sql> " " (representation view) " AS " (representation query))))] @@ -462,13 +462,13 @@ [create_or_replace_view "CREATE OR REPLACE VIEW"] ) - (def: .public (create_index index table unique? columns) + (def .public (create_index index table unique? columns) (-> Index Table Bit (List Column) Definition) (abstraction (format "CREATE " (if unique? "UNIQUE" "") " INDEX " (representation index) " ON " (representation table) " " (..parenthesize (..listing columns))))) - (def: .public (with alias query body) + (def .public (with alias query body) (All (_ where having order group limit offset) (-> Table Any_Query (Query where having order group limit offset) diff --git a/stdlib/source/library/lux/world/file.lux b/stdlib/source/library/lux/world/file.lux index 0e5dc9440..17bc128e1 100644 --- a/stdlib/source/library/lux/world/file.lux +++ b/stdlib/source/library/lux/world/file.lux @@ -80,7 +80,7 @@ ))) )) -(def: (un_rooted fs path) +(def (un_rooted fs path) (All (_ !) (-> (System !) Path (Maybe [Path Text]))) (let [/ (at fs separator)] (case (text.last_index / path) @@ -93,27 +93,27 @@ [_ child] (text.split_at (text.size /) temp)] (in [parent child]))))) -(def: .public (parent fs path) +(def .public (parent fs path) (All (_ !) (-> (System !) Path (Maybe Path))) (|> path (..un_rooted fs) (maybe#each product.left))) -(def: .public (name fs path) +(def .public (name fs path) (All (_ !) (-> (System !) Path Text)) (|> path (..un_rooted fs) (maybe#each product.right) (maybe.else path))) -(def: .public (async fs) +(def .public (async fs) (-> (System IO) (System Async)) (`` (implementation - (def: separator + (def separator (at fs separator)) (~~ (with_template [<name>] - [(def: <name> + [(def <name> (|>> (at fs <name>) async.future))] @@ -131,7 +131,7 @@ [delete])) (~~ (with_template [<name>] - [(def: (<name> path input) + [(def (<name> path input) (async.future (at fs <name> path input)))] [modify] @@ -140,7 +140,7 @@ [move])) ))) -(def: .public (rooted fs parent child) +(def .public (rooted fs parent child) (All (_ !) (-> (System !) Path Text Path)) (format parent (at fs separator) child)) @@ -200,14 +200,14 @@ "[1]::[0]" (new [java/io/File] "io" "try")) - (`` (def: .public default + (`` (def .public default (System IO) (implementation - (def: separator + (def separator (ffi.of_string (java/io/File::separator))) (~~ (with_template [<name> <method>] - [(def: <name> + [(def <name> (|>> ffi.as_string java/io/File::new <method> @@ -217,13 +217,13 @@ [directory? java/io/File::isDirectory] )) - (def: make_directory + (def make_directory (|>> ffi.as_string java/io/File::new java/io/File::mkdir)) (~~ (with_template [<name> <method>] - [(def: (<name> path) + [(def (<name> path) (do [! (try.with io.monad)] [?children (java/io/File::listFiles (java/io/File::new (ffi.as_string path)))] (case ?children @@ -241,25 +241,25 @@ [sub_directories java/io/File::isDirectory] )) - (def: file_size + (def file_size (|>> ffi.as_string java/io/File::new java/io/File::length (at (try.with io.monad) each (|>> ffi.of_long .nat)))) - (def: last_modified + (def last_modified (|>> ffi.as_string java/io/File::new (java/io/File::lastModified) (at (try.with io.monad) each (|>> ffi.of_long duration.of_millis instant.absolute)))) - (def: can_execute? + (def can_execute? (|>> ffi.as_string java/io/File::new java/io/File::canExecute (io#each (try#each (|>> ffi.of_boolean))))) - (def: (read path) + (def (read path) (do (try.with io.monad) [.let [file (java/io/File::new (ffi.as_string path))] size (java/io/File::length file) @@ -269,20 +269,20 @@ _ (java/lang/AutoCloseable::close stream)] (in data))) - (def: (delete path) + (def (delete path) (|> path ffi.as_string java/io/File::new java/io/File::delete)) - (def: (modify path time_stamp) + (def (modify path time_stamp) (|> path ffi.as_string java/io/File::new (java/io/File::setLastModified (|> time_stamp instant.relative duration.millis ffi.as_long)))) (~~ (with_template [<flag> <name>] - [(def: (<name> path data) + [(def (<name> path data) (do (try.with io.monad) [stream (java/io/FileOutputStream::new (java/io/File::new (ffi.as_string path)) (ffi.as_boolean <flag>)) _ (java/io/OutputStream::write data stream) @@ -293,7 +293,7 @@ [#1 append] )) - (def: (move origin destination) + (def (move origin destination) (|> origin ffi.as_string java/io/File::new @@ -328,7 +328,7 @@ "[1]::[0]" (toString [] ffi.String)) - (def: with_async + (def with_async (template (_ <write> <type> <body>) [(template.with_locals [<read>] (let [[<read> <write>] (is [(Async <type>) (async.Resolver <type>)] @@ -352,7 +352,7 @@ (unlink [ffi.String ffi.Function] Any) (rmdir [ffi.String ffi.Function] Any)) - (def: (any_callback write!) + (def (any_callback write!) (-> (async.Resolver (Try Any)) ffi.Function) (<| (ffi.function (_ [error Error]) Any) io.run! @@ -361,7 +361,7 @@ {try.#Success []} {try.#Failure (Error::toString error)}))) - (def: (value_callback write!) + (def (value_callback write!) (All (_ a) (-> (async.Resolver (Try a)) ffi.Function)) (<| (ffi.function (_ [error Error datum Any]) Any) io.run! @@ -374,7 +374,7 @@ "[1]::[0]" (sep ffi.String)) - (def: .public default + (def .public default (Maybe (System Async)) (do maybe.monad [node_fs (node_js.require "fs") @@ -385,11 +385,11 @@ "/")]] (in (is (System Async) (`` (implementation - (def: separator + (def separator js_separator) (~~ (with_template [<name> <method>] - [(def: (<name> path) + [(def (<name> path) (do async.monad [?stats (with_async write! (Try Stats) (Fs::stat path (..value_callback write!) @@ -405,7 +405,7 @@ [directory? Stats::isDirectory] )) - (def: (make_directory path) + (def (make_directory path) (do async.monad [outcome (with_async write! (Try Any) (Fs::access path @@ -421,7 +421,7 @@ (Fs::mkdir path (..any_callback write!) node_fs))))) (~~ (with_template [<name> <method>] - [(def: (<name> path) + [(def (<name> path) (do [! (try.with async.monad)] [subs (with_async write! (Try (Array ffi.String)) (Fs::readdir path (..value_callback write!) node_fs))] @@ -439,7 +439,7 @@ [sub_directories Stats::isDirectory] )) - (def: (file_size path) + (def (file_size path) (do (try.with async.monad) [stats (with_async write! (Try Stats) (Fs::stat path (..value_callback write!) @@ -448,7 +448,7 @@ Stats::size f.nat)))) - (def: (last_modified path) + (def (last_modified path) (do (try.with async.monad) [stats (with_async write! (Try Stats) (Fs::stat path (..value_callback write!) @@ -459,7 +459,7 @@ duration.of_millis instant.absolute)))) - (def: (can_execute? path) + (def (can_execute? path) (at async.monad each (|>> (pipe.case {try.#Success _} @@ -474,12 +474,12 @@ (..any_callback write!) node_fs)))) - (def: (read path) + (def (read path) (with_async write! (Try Binary) (Fs::readFile path (..value_callback write!) node_fs))) - (def: (delete path) + (def (delete path) (do (try.with async.monad) [stats (with_async write! (Try Stats) (Fs::stat path (..value_callback write!) node_fs))] @@ -488,14 +488,14 @@ (Fs::unlink path (..any_callback write!) node_fs) (Fs::rmdir path (..any_callback write!) node_fs))))) - (def: (modify path time_stamp) + (def (modify path time_stamp) (with_async write! (Try Any) (let [when (|> time_stamp instant.relative duration.millis i.frac)] (Fs::utimes path when when (..any_callback write!) node_fs)))) (~~ (with_template [<name> <method>] - [(def: (<name> path data) + [(def (<name> path data) (with_async write! (Try Any) (<method> path (Buffer::from data) (..any_callback write!) node_fs)))] @@ -504,7 +504,7 @@ [append Fs::appendFile] )) - (def: (move origin destination) + (def (move origin destination) (with_async write! (Try Any) (Fs::rename origin destination (..any_callback write!) node_fs)))))))))) @@ -545,17 +545,17 @@ ("static" getsize [ffi.String] "io" "try" ffi.Integer) ("static" getmtime [ffi.String] "io" "try" ffi.Float)) - (def: python_separator + (def python_separator (os/path::sep)) - (`` (def: .public default + (`` (def .public default (System IO) (implementation - (def: separator + (def separator ..python_separator) (~~ (with_template [<name> <method>] - [(def: <name> + [(def <name> (|>> <method> (io#each (|>> (try.else false)))))] @@ -563,11 +563,11 @@ [directory? os/path::isdir] )) - (def: make_directory + (def make_directory os::mkdir) (~~ (with_template [<name> <method>] - [(def: (<name> path) + [(def (<name> path) (let [! (try.with io.monad)] (|> path os::listdir @@ -583,40 +583,40 @@ [sub_directories os/path::isdir] )) - (def: file_size + (def file_size (|>> os/path::getsize (at (try.with io.monad) each (|>> .nat)))) - (def: last_modified + (def last_modified (|>> os/path::getmtime (at (try.with io.monad) each (|>> f.int (i.* +1,000) duration.of_millis instant.absolute)))) - (def: (can_execute? path) + (def (can_execute? path) (os::access path (os::X_OK))) - (def: (read path) + (def (read path) (do (try.with io.monad) [file (..open path "rb") data (PyFile::read file) _ (PyFile::close file)] (in data))) - (def: (delete path) + (def (delete path) (do (try.with io.monad) [? (os/path::isfile path)] (if ? (os::remove path) (os::rmdir path)))) - (def: (modify path time_stamp) + (def (modify path time_stamp) (let [when (|> time_stamp instant.relative duration.millis (i./ +1,000))] (os::utime path (..tuple [when when])))) (~~ (with_template [<name> <mode>] - [(def: (<name> path data) + [(def (<name> path data) (do (try.with io.monad) [file (..open path <mode>) _ (PyFile::write data file)] @@ -626,7 +626,7 @@ [append "ab"] )) - (def: (move origin destination) + (def (move origin destination) (os::rename origin destination)) )))) @@ -670,18 +670,18 @@ ("static" rmdir [Path] "io" "try" "?" Any) ("static" mkdir [Path] "io" "try" "?" Any)) - (def: ruby_separator + (def ruby_separator Text (..RubyFile::SEPARATOR)) - (`` (def: .public default + (`` (def .public default (System IO) (implementation - (def: separator + (def separator ..ruby_separator) (~~ (with_template [<name> <test>] - [(def: <name> + [(def <name> (|>> <test> (io#each (|>> (try.else false)))))] @@ -689,11 +689,11 @@ [directory? RubyFile::directory?] )) - (def: make_directory + (def make_directory FileUtils::mkdir) (~~ (with_template [<name> <test>] - [(def: (<name> path) + [(def (<name> path) (do [! (try.with io.monad)] [self (Dir::open path) children (Dir::children self) @@ -720,7 +720,7 @@ )) (~~ (with_template [<name> <pipeline>] - [(def: <name> + [(def <name> (let [! (try.with io.monad)] (|>> RubyFile::stat (at ! each (`` (|>> (~~ (template.spliced <pipeline>))))))))] @@ -735,21 +735,21 @@ [can_execute? [Stat::executable?]] )) - (def: (read path) + (def (read path) (do (try.with io.monad) [file (RubyFile::open path "rb") data (RubyFile::read file) _ (RubyFile::close file)] (in data))) - (def: (delete path) + (def (delete path) (do (try.with io.monad) [? (RubyFile::file? path)] (if ? (RubyFile::delete path) (FileUtils::rmdir path)))) - (def: (modify path moment) + (def (modify path moment) (let [moment (|> moment instant.relative duration.millis @@ -759,7 +759,7 @@ (RubyFile::utime moment moment path))) (~~ (with_template [<mode> <name>] - [(def: (<name> path data) + [(def (<name> path data) (do [! (try.with io.monad)] [file (RubyFile::open path <mode>) data (RubyFile::write data file) @@ -771,7 +771,7 @@ ["ab" append] )) - (def: (move origin destination) + (def (move origin destination) (do (try.with io.monad) [_ (FileUtils::move origin destination)] (in []))) @@ -807,8 +807,8 @@ ... ... https://www.php.net/manual/en/function.mkdir.php ... (ffi.import (mkdir [Path] "io" "try" ffi.Boolean)) - ... (def: byte_array_format "C*") - ... (def: default_separator (..DIRECTORY_SEPARATOR)) + ... (def byte_array_format "C*") + ... (def default_separator (..DIRECTORY_SEPARATOR)) ... (with_template [<name>] ... [(exception: .public (<name> [file Path]) @@ -818,11 +818,11 @@ ... [cannot_write_to_file] ... ) - ... (`` (def: (file path) + ... (`` (def (file path) ... (-> Path (File IO)) ... (implementation ... (~~ (with_template [<name> <mode>] - ... [(def: (<name> data) + ... [(def (<name> data) ... (do [! (try.with io.monad)] ... [outcome (..file_put_contents [path ("php pack" ..byte_array_format data) <mode>])] ... (if (bit#= false (as Bit outcome)) @@ -833,18 +833,18 @@ ... [append (..FILE_APPEND)] ... )) - ... (def: (content _) + ... (def (content _) ... (do [! (try.with io.monad)] ... [data (..file_get_contents [path])] ... (if (bit#= false (as Bit data)) ... (at io.monad in (exception.except ..cannot_find_file [path])) ... (in (..unpack [..byte_array_format data]))))) - ... (def: path + ... (def path ... path) ... (~~ (with_template [<name> <ffi> <pipeline>] - ... [(def: (<name> _) + ... [(def (<name> _) ... (do [! (try.with io.monad)] ... [value (<ffi> [path])] ... (if (bit#= false (as Bit value)) @@ -855,24 +855,24 @@ ... [last_modified ..filemtime [(i.* +1,000) duration.of_millis instant.absolute]] ... )) - ... (def: (can_execute? _) + ... (def (can_execute? _) ... (..is_executable [path])) - ... (def: (modify moment) + ... (def (modify moment) ... (do [! (try.with io.monad)] ... [verdict (..touch [path (|> moment instant.relative duration.millis (i./ +1,000))])] ... (if (bit#= false (as Bit verdict)) ... (at io.monad in (exception.except ..cannot_find_file [path])) ... (in [])))) - ... (def: (move destination) + ... (def (move destination) ... (do [! (try.with io.monad)] ... [verdict (..rename [path destination])] ... (if (bit#= false (as Bit verdict)) ... (at io.monad in (exception.except ..cannot_find_file [path])) ... (in (file destination))))) - ... (def: (delete _) + ... (def (delete _) ... (do (try.with io.monad) ... [verdict (..unlink [path])] ... (if (bit#= false (as Bit verdict)) @@ -880,14 +880,14 @@ ... (in [])))) ... ))) - ... (`` (def: (directory path) + ... (`` (def (directory path) ... (-> Path (Directory IO)) ... (implementation - ... (def: scope + ... (def scope ... path) ... (~~ (with_template [<name> <test> <constructor> <capability>] - ... [(def: (<name> _) + ... [(def (<name> _) ... (do [! (try.with io.monad)] ... [children (..scandir [path])] ... (loop (again [input (|> children @@ -912,7 +912,7 @@ ... [directories ..is_dir directory Directory] ... )) - ... (def: (discard _) + ... (def (discard _) ... (do (try.with io.monad) ... [verdict (..rmdir [path])] ... (if (bit#= false (as Bit verdict)) @@ -920,11 +920,11 @@ ... (in [])))) ... ))) - ... (`` (def: .public default + ... (`` (def .public default ... (System IO) ... (implementation ... (~~ (with_template [<name> <test> <constructor> <exception>] - ... [(def: (<name> path) + ... [(def (<name> path) ... (do [! (try.with io.monad)] ... [verdict (<test> path)] ... (at io.monad in @@ -936,7 +936,7 @@ ... [directory ..is_dir ..directory ..cannot_find_directory] ... )) - ... (def: (make_file path) + ... (def (make_file path) ... (do [! (try.with io.monad)] ... [verdict (..touch [path (|> instant.now io.run! instant.relative duration.millis (i./ +1,000))])] ... (at io.monad in @@ -944,7 +944,7 @@ ... {try.#Success (..file path)} ... (exception.except ..cannot_make_file [path]))))) - ... (def: (make_directory path) + ... (def (make_directory path) ... (do [! (try.with io.monad)] ... [verdict (..mkdir path)] ... (at io.monad in @@ -952,14 +952,14 @@ ... {try.#Success (..directory path)} ... (exception.except ..cannot_make_directory [path]))))) - ... (def: separator + ... (def separator ... ..default_separator) ... ))) ... ) (these))) -(def: .public (exists? monad fs path) +(def .public (exists? monad fs path) (All (_ !) (-> (Monad !) (System !) Path (! Bit))) (do monad [verdict (at fs file? path)] @@ -977,11 +977,11 @@ (Rec Mock (Dictionary Text (Either Mock_File Mock)))) -(def: empty_mock +(def empty_mock Mock (dictionary.empty text.hash)) -(def: (retrieve_mock_file! separator path mock) +(def (retrieve_mock_file! separator path mock) (-> Text Path Mock (Try [Text Mock_File])) (loop (again [directory mock trail (text.all_split_by separator path)]) @@ -1005,7 +1005,7 @@ {.#End} (exception.except ..cannot_find_file [path])))) -(def: (update_mock_file! / path now content mock) +(def (update_mock_file! / path now content mock) (-> Text Path Instant Binary Mock (Try Mock)) (loop (again [directory mock trail (text.all_split_by / path)]) @@ -1044,7 +1044,7 @@ {.#End} (exception.except ..cannot_find_file [path])))) -(def: (delete_mock_node! / path mock) +(def (delete_mock_node! / path mock) (-> Text Path Mock (Try Mock)) (loop (again [directory mock trail (text.all_split_by / path)]) @@ -1079,7 +1079,7 @@ {.#End} (exception.except ..cannot_delete [path])))) -(def: (attempt! transform var) +(def (attempt! transform var) (All (_ a) (-> (-> a (Try a)) (Var a) (STM (Try Any)))) (do [! stm.monad] [|var| (stm.read var)] @@ -1092,7 +1092,7 @@ {try.#Failure error} (in {try.#Failure error})))) -(def: (make_mock_directory! / path mock) +(def (make_mock_directory! / path mock) (-> Text Path Mock (Try Mock)) (loop (again [directory mock trail (text.all_split_by / path)]) @@ -1120,7 +1120,7 @@ {.#End} (exception.except ..cannot_make_directory [path])))) -(def: (retrieve_mock_directory! / path mock) +(def (retrieve_mock_directory! / path mock) (-> Text Path Mock (Try Mock)) (loop (again [directory mock trail (text.all_split_by / path)]) @@ -1146,15 +1146,15 @@ {.#Item _} (again sub_directory tail))))))) -(def: .public (mock separator) +(def .public (mock separator) (-> Text (System Async)) (let [store (stm.var ..empty_mock)] (`` (implementation - (def: separator + (def separator separator) (~~ (with_template [<method> <retrieve>] - [(def: (<method> path) + [(def (<method> path) (|> store stm.read (at stm.monad each @@ -1166,7 +1166,7 @@ [file? ..retrieve_mock_file!] [directory? ..retrieve_mock_directory!])) - (def: (make_directory path) + (def (make_directory path) (stm.commit! (do [! stm.monad] [|store| (stm.read store)] @@ -1180,7 +1180,7 @@ (in {try.#Failure error}))))) (~~ (with_template [<method> <tag>] - [(def: (<method> path) + [(def (<method> path) (stm.commit! (do stm.monad [|store| (stm.read store)] @@ -1200,7 +1200,7 @@ [sub_directories .#Right] )) - (def: (file_size path) + (def (file_size path) (stm.commit! (do stm.monad [|store| (stm.read store)] @@ -1210,7 +1210,7 @@ (the #mock_content) binary.size))))))) - (def: (last_modified path) + (def (last_modified path) (stm.commit! (do stm.monad [|store| (stm.read store)] @@ -1219,7 +1219,7 @@ (try#each (|>> product.right (the #mock_last_modified)))))))) - (def: (can_execute? path) + (def (can_execute? path) (stm.commit! (do stm.monad [|store| (stm.read store)] @@ -1228,7 +1228,7 @@ (try#each (|>> product.right (the #mock_can_execute)))))))) - (def: (read path) + (def (read path) (stm.commit! (do stm.monad [|store| (stm.read store)] @@ -1237,11 +1237,11 @@ (try#each (|>> product.right (the #mock_content)))))))) - (def: (delete path) + (def (delete path) (stm.commit! (..attempt! (..delete_mock_node! separator path) store))) - (def: (modify path now) + (def (modify path now) (stm.commit! (..attempt! (function (_ |store|) (do try.monad @@ -1249,13 +1249,13 @@ (..update_mock_file! separator path now (the #mock_content file) |store|))) store))) - (def: (write path content) + (def (write path content) (do async.monad [now (async.future instant.now)] (stm.commit! (..attempt! (..update_mock_file! separator path now content) store)))) - (def: (append path content) + (def (append path content) (do async.monad [now (async.future instant.now)] (stm.commit! @@ -1269,7 +1269,7 @@ |store|))) store)))) - (def: (move origin destination) + (def (move origin destination) (stm.commit! (do [! stm.monad] [|store| (stm.read store)] @@ -1286,7 +1286,7 @@ (in {try.#Failure error}))))) )))) -(def: (check_or_make_directory monad fs path) +(def (check_or_make_directory monad fs path) (All (_ !) (-> (Monad !) (System !) Path (! (Try Any)))) (do monad [? (at fs directory? path)] @@ -1294,7 +1294,7 @@ (in {try.#Success []}) (at fs make_directory path)))) -(def: .public (make_directories monad fs path) +(def .public (make_directories monad fs path) (All (_ !) (-> (Monad !) (System !) Path (! (Try Any)))) (let [rooted? (text.starts_with? (at fs separator) path) segments (text.all_split_by (at fs separator) path)] @@ -1326,7 +1326,7 @@ {try.#Failure error} (in {try.#Failure error})))))))) -(def: .public (make_file monad fs content path) +(def .public (make_file monad fs content path) (All (_ !) (-> (Monad !) (System !) Binary Path (! (Try Any)))) (do monad [? (at fs file? path)] diff --git a/stdlib/source/library/lux/world/file/watch.lux b/stdlib/source/library/lux/world/file/watch.lux index dc890fa54..d756ed11c 100644 --- a/stdlib/source/library/lux/world/file/watch.lux +++ b/stdlib/source/library/lux/world/file/watch.lux @@ -38,7 +38,7 @@ #modification Bit #deletion Bit]) - (def: none + (def none Concern (abstraction [#creation false @@ -46,14 +46,14 @@ #deletion false])) (with_template [<concern> <predicate> <event> <create> <modify> <delete>] - [(def: .public <concern> + [(def .public <concern> Concern (abstraction [#creation <create> #modification <modify> #deletion <delete>])) - (def: .public <predicate> + (def .public <predicate> (Predicate Concern) (|>> representation (the <event>)))] @@ -65,14 +65,14 @@ false false true] ) - (def: .public (also left right) + (def .public (also left right) (-> Concern Concern Concern) (abstraction [#creation (or (..creation? left) (..creation? right)) #modification (or (..modification? left) (..modification? right)) #deletion (or (..deletion? left) (..deletion? right))])) - (def: .public all + (def .public all Concern (.all ..also ..creation @@ -107,7 +107,7 @@ (type: Directory_Tracker (Dictionary //.Path [Concern File_Tracker])) -(def: (update_watch! new_concern path tracker) +(def (update_watch! new_concern path tracker) (-> Concern //.Path (Var Directory_Tracker) (STM Bit)) (do [! stm.monad] [@tracker (stm.read tracker)] @@ -120,7 +120,7 @@ {.#None} (in false)))) -(def: (file_tracker fs directory) +(def (file_tracker fs directory) (-> (//.System Async) //.Path (Async (Try File_Tracker))) (do [! (try.with async.monad)] [files (at fs directory_files directory)] @@ -133,7 +133,7 @@ (dictionary.empty text.hash)) files))) -(def: (available_files fs directory) +(def (available_files fs directory) (-> (//.System Async) //.Path (Async (Try (List [//.Path Instant])))) (do [! (try.with async.monad)] [files (at fs directory_files directory)] @@ -143,7 +143,7 @@ (at ! each (|>> [file])))) files))) -(def: (available_directory_changes fs [directory [the_concern file_tracker]]) +(def (available_directory_changes fs [directory [the_concern file_tracker]]) (-> (//.System Async) [//.Path [Concern File_Tracker]] (Async (Try [[//.Path [Concern File_Tracker]] [(List [//.Path Instant]) @@ -184,12 +184,12 @@ modifications deletions]]))) -(def: .public (polling fs) +(def .public (polling fs) (-> (//.System Async) (Watcher Async)) (let [tracker (is (Var Directory_Tracker) (stm.var (dictionary.empty text.hash)))] (implementation - (def: (start new_concern path) + (def (start new_concern path) (do [! async.monad] [exists? (at fs directory? path)] (if exists? @@ -203,7 +203,7 @@ [_ (stm.commit! (stm.update (dictionary.has path [new_concern file_tracker]) tracker))] (in {try.#Success []}))))) (in (exception.except ..cannot_poll_a_non_existent_directory [path]))))) - (def: (concern path) + (def (concern path) (stm.commit! (do stm.monad [@tracker (stm.read tracker)] @@ -213,7 +213,7 @@ {.#None} (exception.except ..not_being_watched [path])))))) - (def: (stop path) + (def (stop path) (stm.commit! (do [! stm.monad] [@tracker (stm.read tracker)] @@ -225,7 +225,7 @@ {.#None} (in (exception.except ..not_being_watched [path])))))) - (def: (poll _) + (def (poll _) (do async.monad [@tracker (stm.commit! (stm.read tracker))] (do [! (try.with async.monad)] @@ -256,7 +256,7 @@ ))))) ))) -(def: .public (mock separator) +(def .public (mock separator) (-> Text [(//.System Async) (Watcher Async)]) (let [fs (//.mock separator)] [fs @@ -273,7 +273,7 @@ (size [] int) (get [int] a)) - (def: (default_list list) + (def (default_list list) (All (_ a) (-> (java/util/List a) (List a))) (let [size (.nat (ffi.of_int (java/util/List::size list)))] (loop (again [idx 0 @@ -305,7 +305,7 @@ ("read_only" "static" ENTRY_MODIFY (java/nio/file/WatchEvent$Kind java/nio/file/Path)) ("read_only" "static" ENTRY_DELETE (java/nio/file/WatchEvent$Kind java/nio/file/Path))) - (def: (default_event_concern event) + (def (default_event_concern event) (All (_ a) (-> (java/nio/file/WatchEvent a) Concern)) (let [kind (as (java/nio/file/WatchEvent$Kind java/nio/file/Path) @@ -333,7 +333,7 @@ (watchable [] java/nio/file/Watchable) (pollEvents [] "io" (java/util/List (java/nio/file/WatchEvent ?)))) - (def: default_key_concern + (def default_key_concern (-> java/nio/file/WatchKey (IO Concern)) (|>> java/nio/file/WatchKey::pollEvents (at io.monad each (|>> ..default_list @@ -360,7 +360,7 @@ (type: Watch_Event (java/nio/file/WatchEvent$Kind java/lang/Object)) - (def: (default_start watch_events watcher path) + (def (default_start watch_events watcher path) (-> (List Watch_Event) java/nio/file/WatchService //.Path (Async (Try java/nio/file/WatchKey))) (let [watch_events' (list#mix (function (_ [index watch_event] watch_events') (ffi.write! index watch_event watch_events')) @@ -372,7 +372,7 @@ watch_events' (|> path ffi.as_string java/io/File::new java/io/File::toPath))))) - (def: (default_poll watcher) + (def (default_poll watcher) (-> java/nio/file/WatchService (IO (Try (List [Concern //.Path])))) (loop (again [output (is (List [Concern //.Path]) (list))]) @@ -398,7 +398,7 @@ {.#None} (in output))))) - (def: (watch_events concern) + (def (watch_events concern) (-> Concern (List Watch_Event)) (.all list#composite (if (..creation? concern) @@ -412,7 +412,7 @@ (list)) )) - (def: .public default + (def .public default (IO (Try (Watcher Async))) (do (try.with io.monad) [watcher (java/nio/file/FileSystem::newWatchService @@ -436,7 +436,7 @@ (in (exception.except ..not_being_watched [path]))))))]] (in (is (Watcher Async) (implementation - (def: (start the_concern path) + (def (start the_concern path) (do async.monad [?concern (stop path)] (do (try.with async.monad) @@ -447,7 +447,7 @@ (do async.monad [_ (stm.commit! (stm.update (dictionary.has path [the_concern key]) tracker))] (in {try.#Success []}))))) - (def: (concern path) + (def (concern path) (do async.monad [@tracker (stm.commit! (stm.read tracker))] (case (dictionary.value path @tracker) @@ -456,8 +456,8 @@ {.#None} (in (exception.except ..not_being_watched [path]))))) - (def: stop stop) - (def: (poll _) + (def stop stop) + (def (poll _) (async.future (..default_poll watcher))) ))))) )] diff --git a/stdlib/source/library/lux/world/input/keyboard.lux b/stdlib/source/library/lux/world/input/keyboard.lux index 79685c797..baaac2289 100644 --- a/stdlib/source/library/lux/world/input/keyboard.lux +++ b/stdlib/source/library/lux/world/input/keyboard.lux @@ -6,7 +6,7 @@ Nat) (with_template [<code> <name>] - [(def: .public <name> Key <code>)] + [(def .public <name> Key <code>)] [00008 back_space] [00010 enter] @@ -103,7 +103,7 @@ #input Key])) (with_template [<bit> <name>] - [(def: .public (<name> key) + [(def .public (<name> key) (-> Key Press) [#pressed? <bit> #input key])] diff --git a/stdlib/source/library/lux/world/net/http.lux b/stdlib/source/library/lux/world/net/http.lux index bfbcf4926..a39c3d371 100644 --- a/stdlib/source/library/lux/world/net/http.lux +++ b/stdlib/source/library/lux/world/net/http.lux @@ -36,7 +36,7 @@ (type: .public Headers Environment) -(def: .public empty +(def .public empty Headers environment.empty) diff --git a/stdlib/source/library/lux/world/net/http/client.lux b/stdlib/source/library/lux/world/net/http/client.lux index 2decbe412..c23b58b95 100644 --- a/stdlib/source/library/lux/world/net/http/client.lux +++ b/stdlib/source/library/lux/world/net/http/client.lux @@ -36,13 +36,13 @@ (! (Try (//.Response !)))) request))) -(def: method_function +(def method_function (syntax (_ [[_ name] <code>.symbol]) (in (list (code.local (text.replaced "#" "" (text.lower_cased name))))))) (with_template [<method>] [(with_expansions [<name> (method_function <method>)] - (def: .public (<name> url headers data client) + (def .public (<name> url headers data client) (All (_ !) (-> URL //.Headers (Maybe Binary) (Client !) (! (Try (//.Response !))))) @@ -59,14 +59,14 @@ [//.#Trace] ) -(def: default_buffer_size +(def default_buffer_size (n.* 1,024 1,024)) -(def: empty_body +(def empty_body [Nat Binary] [0 (binary.empty 0)]) -(def: (body_of data) +(def (body_of data) (-> Binary [Nat Binary]) [(binary.size data) data]) @@ -109,7 +109,7 @@ (new [java/io/InputStream]) (read [[byte] int int] "io" "try" int)) - (def: jvm_method + (def jvm_method (-> //.Method Text) (|>> (pipe.case {//.#Post} "POST" @@ -122,7 +122,7 @@ {//.#Options} "OPTIONS" {//.#Trace} "TRACE"))) - (def: (default_body input) + (def (default_body input) (-> java/io/BufferedInputStream (//.Body IO)) (|>> (maybe#each (|>> [true])) (maybe.else [false ..default_buffer_size]) @@ -172,7 +172,7 @@ (again (i.+ bytes_read so_far) output)))))))))) - (def: (default_headers connection) + (def (default_headers connection) (-> java/net/HttpURLConnection (IO (Try //.Headers))) (loop (again [index +0 headers //.empty]) @@ -188,10 +188,10 @@ {.#None} (in headers))))) - (def: .public default + (def .public default (Client IO) (implementation - (def: (request method url headers data) + (def (request method url headers data) (is (IO (Try (//.Response IO))) (do [! (try.with io.monad)] [connection (|> url ffi.as_string java/net/URL::new java/net/URL::openConnection) @@ -224,10 +224,10 @@ @.jvm (these <jvm>) (these))) -(def: .public (async client) +(def .public (async client) (-> (Client IO) (Client Async)) (implementation - (def: (request method url headers data) + (def (request method url headers data) (|> (at client request method url headers data) async.future (at async.monad each @@ -241,6 +241,6 @@ {try.#Failure error} {try.#Failure error}))))))) -(def: .public headers +(def .public headers (-> (List [Text Text]) //.Headers) (dictionary.of_list text.hash)) diff --git a/stdlib/source/library/lux/world/net/http/cookie.lux b/stdlib/source/library/lux/world/net/http/cookie.lux index dd17d428e..26ef5688a 100644 --- a/stdlib/source/library/lux/world/net/http/cookie.lux +++ b/stdlib/source/library/lux/world/net/http/cookie.lux @@ -23,16 +23,16 @@ (type: .public Directive (-> Text Text)) -(def: (directive extension) +(def (directive extension) (-> Text Directive) (function (_ so_far) (format so_far "; " extension))) -(def: .public (set name value) +(def .public (set name value) (-> Text Text Header) (header.has "Set-Cookie" (format name "=" value))) -(def: .public (max_age duration) +(def .public (max_age duration) (-> Duration Directive) (let [seconds (duration.ticks duration.second duration)] (..directive (format "Max-Age=" (if (i.< +0 seconds) @@ -40,7 +40,7 @@ (%.nat (.nat seconds))))))) (with_template [<name> <prefix>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> Text Directive) (..directive (format <prefix> "=" value)))] @@ -49,7 +49,7 @@ ) (with_template [<name> <tag>] - [(def: .public <name> + [(def .public <name> Directive (..directive <tag>))] @@ -62,13 +62,13 @@ {#Strict} {#Lax})) -(def: .public (same_site policy) +(def .public (same_site policy) (-> CSRF_Policy Directive) (..directive (format "SameSite=" (case policy {#Strict} "Strict" {#Lax} "Lax")))) -(def: (cookie context) +(def (cookie context) (-> Context (Parser Context)) (do p.monad [key (l.slice (l.many! (l.none_of! "="))) @@ -76,7 +76,7 @@ value (l.slice (l.many! (l.none_of! ";")))] (in (dictionary.has key value context)))) -(def: (cookies context) +(def (cookies context) (-> Context (Parser Context)) (all p.either (do p.monad @@ -85,6 +85,6 @@ (cookies context')) (p#in context))) -(def: .public (get header) +(def .public (get header) (-> Text (Try Context)) (l.result header (..cookies context.empty))) diff --git a/stdlib/source/library/lux/world/net/http/header.lux b/stdlib/source/library/lux/world/net/http/header.lux index 95fd9713c..a8bc408a0 100644 --- a/stdlib/source/library/lux/world/net/http/header.lux +++ b/stdlib/source/library/lux/world/net/http/header.lux @@ -12,7 +12,7 @@ ["[0]" mime (.only MIME)] [// (.only URL)]]) -(def: .public (has name value) +(def .public (has name value) (-> Text Text Header) (dictionary.revised' name "" (|>> (pipe.case @@ -22,14 +22,14 @@ previous (format previous "," value))))) -(def: .public content_length +(def .public content_length (-> Nat Header) (|>> %.nat (..has "Content-Length"))) -(def: .public content_type +(def .public content_type (-> MIME Header) (|>> mime.name (..has "Content-Type"))) -(def: .public location +(def .public location (-> URL Header) (..has "Location")) diff --git a/stdlib/source/library/lux/world/net/http/mime.lux b/stdlib/source/library/lux/world/net/http/mime.lux index 36a5bae3d..ff449a568 100644 --- a/stdlib/source/library/lux/world/net/http/mime.lux +++ b/stdlib/source/library/lux/world/net/http/mime.lux @@ -11,18 +11,18 @@ (primitive .public MIME Text - (def: .public mime + (def .public mime (-> Text MIME) (|>> abstraction)) - (def: .public name + (def .public name (-> MIME Text) (|>> representation)) ) ... https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types (with_template [<name> <type>] - [(def: .public <name> MIME (..mime <type>))] + [(def .public <name> MIME (..mime <type>))] [aac_audio "audio/aac"] [abiword "application/x-abiword"] @@ -91,10 +91,10 @@ [!7z "application/x-7z-compressed"] ) -(def: .public (text encoding) +(def .public (text encoding) (-> Encoding MIME) (..mime (format "text/plain; charset=" text.double_quote (encoding.name encoding) text.double_quote))) -(def: .public utf_8 +(def .public utf_8 MIME (..text encoding.utf_8)) diff --git a/stdlib/source/library/lux/world/net/http/query.lux b/stdlib/source/library/lux/world/net/http/query.lux index 3409734a7..72f5c345d 100644 --- a/stdlib/source/library/lux/world/net/http/query.lux +++ b/stdlib/source/library/lux/world/net/http/query.lux @@ -17,7 +17,7 @@ [collection ["[0]" dictionary]]]]]) -(def: component +(def component (Parser Text) (p.rec (function (_ component) @@ -39,7 +39,7 @@ tail component] (in (format head code tail)))))))) -(def: (form context) +(def (form context) (-> Context (Parser Context)) (all p.either (do p.monad @@ -60,6 +60,6 @@ ... if invalid form data, just stop parsing... (at p.monad in context))) -(def: .public (parameters raw) +(def .public (parameters raw) (-> Text (Try Context)) (l.result raw (..form context.empty))) diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux index 36f0498ea..d3a970d14 100644 --- a/stdlib/source/library/lux/world/net/http/request.lux +++ b/stdlib/source/library/lux/world/net/http/request.lux @@ -31,7 +31,7 @@ ["[1][0]" query] ["[1][0]" cookie]]) -(def: (merge inputs) +(def (merge inputs) (-> (List Binary) Binary) (let [[_ output] (try.trusted (monad.mix try.monad @@ -46,15 +46,15 @@ inputs))] output)) -(def: (read_text_body body) +(def (read_text_body body) (-> Body (Async (Try Text))) (do async.monad [blobs (frp.list body)] (in (at encoding.utf8 decoded (merge blobs))))) -(def: failure (//response.bad_request "")) +(def failure (//response.bad_request "")) -(def: .public (json reader server) +(def .public (json reader server) (All (_ a) (-> (<json>.Reader a) (-> a Server) Server)) (function (_ (^.let request [identification protocol resource message])) (do async.monad @@ -69,7 +69,7 @@ {try.#Failure error} (async.resolved ..failure))))) -(def: .public (text server) +(def .public (text server) (-> (-> Text Server) Server) (function (_ (^.let request [identification protocol resource message])) (do async.monad @@ -81,7 +81,7 @@ {try.#Failure error} (async.resolved ..failure))))) -(def: .public (query property server) +(def .public (query property server) (All (_ a) (-> (Property a) (-> a Server) Server)) (function (_ [identification protocol resource message]) (let [full (the //.#uri resource) @@ -99,7 +99,7 @@ {try.#Failure error} (async.resolved ..failure))))) -(def: .public (form property server) +(def .public (form property server) (All (_ a) (-> (Property a) (-> a Server) Server)) (function (_ (^.let request [identification protocol resource message])) (do async.monad @@ -114,7 +114,7 @@ {try.#Failure error} (async.resolved ..failure))))) -(def: .public (cookies property server) +(def .public (cookies property server) (All (_ a) (-> (Property a) (-> a Server) Server)) (function (_ (^.let request [identification protocol resource message])) (case (do try.monad diff --git a/stdlib/source/library/lux/world/net/http/response.lux b/stdlib/source/library/lux/world/net/http/response.lux index db54411cc..277f21202 100644 --- a/stdlib/source/library/lux/world/net/http/response.lux +++ b/stdlib/source/library/lux/world/net/http/response.lux @@ -22,12 +22,12 @@ ["[0]" header] [// (.only URL)]]) -(def: .public (static response) +(def .public (static response) (-> Response Server) (function (_ request) (async.resolved response))) -(def: .public empty +(def .public empty (-> Status Response) (let [body (frp#in (at encoding.utf8 encoded ""))] (function (_ status) @@ -37,16 +37,16 @@ (header.content_type mime.utf_8)) //.#body body]]))) -(def: .public (temporary_redirect to) +(def .public (temporary_redirect to) (-> URL Response) (let [[status message] (..empty status.temporary_redirect)] [status (revised //.#headers (header.location to) message)])) -(def: .public not_found +(def .public not_found Response (..empty status.not_found)) -(def: .public (content status type data) +(def .public (content status type data) (-> Status MIME Binary Response) [status [//.#headers (|> context.empty @@ -54,16 +54,16 @@ (header.content_type type)) //.#body (frp#in data)]]) -(def: .public bad_request +(def .public bad_request (-> Text Response) (|>> (at encoding.utf8 encoded) (content status.bad_request mime.utf_8))) -(def: .public ok +(def .public ok (-> MIME Binary Response) (content status.ok)) (with_template [<name> <type> <mime> <pre>] - [(def: .public <name> + [(def .public <name> (-> <type> Response) (|>> <pre> (at encoding.utf8 encoded) (..ok <mime>)))] diff --git a/stdlib/source/library/lux/world/net/http/route.lux b/stdlib/source/library/lux/world/net/http/route.lux index b4f31b525..d9f63d9ad 100644 --- a/stdlib/source/library/lux/world/net/http/route.lux +++ b/stdlib/source/library/lux/world/net/http/route.lux @@ -17,7 +17,7 @@ ["[1][0]" response]]) (with_template [<scheme> <name>] - [(def: .public (<name> server) + [(def .public (<name> server) (-> Server Server) (function (_ (^.let request [identification protocol resource message])) (case (the //.#scheme protocol) @@ -32,7 +32,7 @@ ) (with_template [<method> <name>] - [(def: .public (<name> server) + [(def .public (<name> server) (-> Server Server) (function (_ (^.let request [identification protocol resource message])) (case (the //.#method resource) @@ -53,7 +53,7 @@ [//.#Trace trace] ) -(def: .public (uri path server) +(def .public (uri path server) (-> URI Server Server) (function (_ [identification protocol resource message]) (if (text.starts_with? path (the //.#uri resource)) @@ -65,7 +65,7 @@ message]) (async.resolved //response.not_found)))) -(def: .public (or primary alternative) +(def .public (or primary alternative) (-> Server Server Server) (function (_ request) (do async.monad diff --git a/stdlib/source/library/lux/world/net/http/status.lux b/stdlib/source/library/lux/world/net/http/status.lux index 2752b8651..dc2ff105f 100644 --- a/stdlib/source/library/lux/world/net/http/status.lux +++ b/stdlib/source/library/lux/world/net/http/status.lux @@ -5,7 +5,7 @@ ... https://en.wikipedia.org/wiki/List_of_HTTP_status_codes (with_template [<status> <name>] - [(def: .public <name> + [(def .public <name> Status <status>)] diff --git a/stdlib/source/library/lux/world/net/http/version.lux b/stdlib/source/library/lux/world/net/http/version.lux index b56ddf052..0cb62b627 100644 --- a/stdlib/source/library/lux/world/net/http/version.lux +++ b/stdlib/source/library/lux/world/net/http/version.lux @@ -4,7 +4,7 @@ [// (.only Version)]) (with_template [<name> <version>] - [(def: .public <name> Version <version>)] + [(def .public <name> Version <version>)] [v0_9 "0.9"] [v1_0 "1.0"] diff --git a/stdlib/source/library/lux/world/net/uri.lux b/stdlib/source/library/lux/world/net/uri.lux index 253550d6e..ec7c8b984 100644 --- a/stdlib/source/library/lux/world/net/uri.lux +++ b/stdlib/source/library/lux/world/net/uri.lux @@ -6,5 +6,5 @@ (type: .public URI Text) -(def: .public separator +(def .public separator "/") diff --git a/stdlib/source/library/lux/world/output/video/resolution.lux b/stdlib/source/library/lux/world/output/video/resolution.lux index fd6a1a9de..ebe60cf6d 100644 --- a/stdlib/source/library/lux/world/output/video/resolution.lux +++ b/stdlib/source/library/lux/world/output/video/resolution.lux @@ -15,17 +15,17 @@ [#width Nat #height Nat])) -(def: .public hash +(def .public hash (Hash Resolution) (product.hash nat.hash nat.hash)) -(def: .public equivalence +(def .public equivalence (Equivalence Resolution) (at ..hash equivalence)) ... https://en.wikipedia.org/wiki/Display_resolution#Common_display_resolutions (with_template [<name> <width> <height>] - [(def: .public <name> + [(def .public <name> Resolution [#width <width> #height <height>])] diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux index b0df93d8b..f45930389 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/program.lux @@ -53,7 +53,7 @@ (is (-> Exit (! Nothing)) exit))) -(def: .public (environment monad program) +(def .public (environment monad program) (All (_ !) (-> (Monad !) (Program !) (! Environment))) (do [! monad] [variables (at program available_variables []) @@ -70,11 +70,11 @@ {.#None}))) (dictionary.of_list text.hash))))) -(`` (def: .public (async program) +(`` (def .public (async program) (-> (Program IO) (Program Async)) (implementation (~~ (with_template [<method>] - [(def: <method> + [(def <method> (at program <method>))] [home] @@ -82,7 +82,7 @@ )) (~~ (with_template [<method>] - [(def: <method> + [(def <method> (|>> (at program <method>) async.future))] [available_variables] @@ -90,24 +90,24 @@ [exit] ))))) -(def: .public (mock environment home directory) +(def .public (mock environment home directory) (-> Environment Path Path (Program IO)) (let [@dead? (atom.atom false)] (implementation - (def: available_variables + (def available_variables (function.constant (io.io (dictionary.keys environment)))) - (def: (variable name) + (def (variable name) (io.io (case (dictionary.value name environment) {.#Some value} {try.#Success value} {.#None} (exception.except ..unknown_environment_variable [name])))) - (def: home + (def home home) - (def: directory + (def directory directory) - (def: exit + (def exit (|>> %.int panic! io.io))))) ... Do not trust the values of environment variables @@ -136,7 +136,7 @@ ("static" getProperty [java/lang/String] "?" java/lang/String) ("static" exit [int] "io" void)) - (def: (jvm::consume iterator) + (def (jvm::consume iterator) (All (_ a) (-> (java/util/Iterator a) (List a))) (if (ffi.of_boolean (java/util/Iterator::hasNext iterator)) {.#Item (java/util/Iterator::next iterator) @@ -145,7 +145,7 @@ )] (for @.old (these <jvm>) @.jvm (these <jvm>) - @.js (these (def: default_exit! + @.js (these (def default_exit! (-> Exit (IO Nothing)) (|>> %.int panic! io.io)) @@ -154,7 +154,7 @@ (exit [ffi.Number] "io" Nothing) (cwd [] "io" Path)) - (def: (exit_node_js! code) + (def (exit_node_js! code) (-> Exit (IO Nothing)) (case (ffi.global ..NodeJs_Process [process]) {.#Some process} @@ -171,7 +171,7 @@ "[1]::[0]" (reload [] Nothing)) - (def: (exit_browser! code) + (def (exit_browser! code) (-> Exit (IO Nothing)) (case [(ffi.global ..Browser_Window [window]) (ffi.global ..Browser_Location [location])] @@ -223,7 +223,7 @@ (ffi.import (os/getenv [ffi.String] "io" "?" ffi.String)) (ffi.import (os/exit [ffi.Integer] "io" Nothing)) - (def: (run_command default command) + (def (run_command default command) (-> Text Text (IO Text)) (do [! io.monad] [outcome (io/popen [command])] @@ -283,10 +283,10 @@ (these))) -(def: .public default +(def .public default (Program IO) (implementation - (def: (available_variables _) + (def (available_variables _) (with_expansions [<jvm> (|> (java/lang/System::getenv) java/util/Map::keySet java/util/Set::iterator @@ -328,7 +328,7 @@ ... (dictionary.has (..car entry) (..cdr entry) output)))))) ))) - (def: (variable name) + (def (variable name) (template.let [(!fetch <method> <post>) [(do io.monad [value (|> name <method>)] @@ -357,7 +357,7 @@ @.ruby (!fetch Env::fetch |>) )))) - (def: home + (def home (io.run! (with_expansions [<default> (io.io "~") <jvm> (|> (java/lang/System::getProperty (ffi.as_string "user.home")) @@ -384,7 +384,7 @@ ... TODO: Replace dummy implementation. <default>)))) - (def: directory + (def directory (io.run! (with_expansions [<default> "." <jvm> (|> (java/lang/System::getProperty (ffi.as_string "user.dir")) @@ -418,7 +418,7 @@ ... TODO: Replace dummy implementation. (io.io <default>))))) - (def: (exit code) + (def (exit code) (with_expansions [<jvm> (do io.monad [_ (java/lang/System::exit (ffi.as_int code))] (in (undefined)))] diff --git a/stdlib/source/library/lux/world/shell.lux b/stdlib/source/library/lux/world/shell.lux index 79fc635a9..22ef8464b 100644 --- a/stdlib/source/library/lux/world/shell.lux +++ b/stdlib/source/library/lux/world/shell.lux @@ -37,7 +37,7 @@ Int) (with_template [<code> <name>] - [(def: .public <name> + [(def .public <name> Exit <code>)] @@ -58,11 +58,11 @@ (is (-> [] (! (Try Exit))) await))) -(def: (async_process process) +(def (async_process process) (-> (Process IO) (Process Async)) (`` (implementation (~~ (with_template [<method>] - [(def: <method> + [(def <method> (|>> (at process <method>) async.future))] @@ -84,10 +84,10 @@ (is (-> [Environment Path Command (List Argument)] (! (Try (Process !)))) execute))) -(def: .public (async shell) +(def .public (async shell) (-> (Shell IO) (Shell Async)) (implementation - (def: (execute input) + (def (execute input) (async.future (do (try.with io.monad) [process (at shell execute input)] @@ -109,11 +109,11 @@ (type: Replacer (-> Text Text)) -(def: (replaced bad replacer) +(def (replaced bad replacer) (-> Text Replacer (-> Text Text)) (text.replaced bad (replacer bad))) -(def: safe_common_command +(def safe_common_command (-> Replacer (Sanitizer Command)) (let [x0A (text.of_char (hex "0A")) xFF (text.of_char (hex "FF"))] @@ -136,17 +136,17 @@ (..replaced "[" replacer) (..replaced "]" replacer) (..replaced "{" replacer) (..replaced "}" replacer))))) -(def: (policy safe_command safe_argument) +(def (policy safe_command safe_argument) (Ex (_ ?) (-> (Sanitizer Command) (Sanitizer Argument) (Policy ?))) (?.with_policy (is (Context Safety Policy) (function (_ (open "?[0]")) (implementation - (def: command (|>> safe_command ?#can_upgrade)) - (def: argument (|>> safe_argument ?#can_upgrade)) - (def: value ?#can_downgrade)))))) + (def command (|>> safe_command ?#can_upgrade)) + (def argument (|>> safe_argument ?#can_upgrade)) + (def value ?#can_downgrade)))))) -(def: unix_policy +(def unix_policy (let [replacer (is Replacer (|>> (format "\"))) safe_command (is (Sanitizer Command) @@ -156,7 +156,7 @@ (text.enclosed' "'")))] (..policy safe_command safe_argument))) -(def: windows_policy +(def windows_policy (let [replacer (is Replacer (function.constant " ")) safe_command (is (Sanitizer Command) @@ -174,7 +174,7 @@ "[1]::[0]" (toLowerCase [] java/lang/String)) - (def: (jvm::arguments_array arguments) + (def (jvm::arguments_array arguments) (-> (List Argument) (Array java/lang/String)) (product.right (list#mix (function (_ argument [idx output]) @@ -188,7 +188,7 @@ "[1]::[0]" (put [k v] v)) - (def: (jvm::load_environment input target) + (def (jvm::load_environment input target) (-> Environment (java/util/Map java/lang/String java/lang/String) (java/util/Map java/lang/String java/lang/String)) @@ -231,7 +231,7 @@ (exception: .public no_more_output) - (def: (default_process process) + (def (default_process process) (-> java/lang/Process (IO (Try (Process IO)))) (do [! (try.with io.monad)] [jvm_input (java/lang/Process::getInputStream process) @@ -246,7 +246,7 @@ (in (is (Process IO) (`` (implementation (~~ (with_template [<name> <stream>] - [(def: (<name> _) + [(def (<name> _) (do ! [output (java/io/BufferedReader::readLine <stream>)] (case output @@ -259,10 +259,10 @@ [read jvm_input] [fail jvm_error] )) - (def: (write message) + (def (write message) (java/io/OutputStream::write (at utf8.codec encoded message) jvm_output)) (~~ (with_template [<name> <method>] - [(def: (<name> _) + [(def (<name> _) (|> process <method>))] [destroy java/lang/Process::destroy] @@ -285,16 +285,16 @@ ("static" getProperty [java/lang/String] "io" "try" java/lang/String)) ... https://en.wikipedia.org/wiki/Code_injection#Shell_injection - (def: windows? + (def windows? (IO (Try Bit)) (at (try.with io.monad) each (|>> java/lang/String::toLowerCase ffi.of_string (text.starts_with? "windows")) (java/lang/System::getProperty (ffi.as_string "os.name")))) - (def: .public default + (def .public default (Shell IO) (implementation - (def: (execute [environment working_directory the_command arguments]) + (def (execute [environment working_directory the_command arguments]) (do [! (try.with io.monad)] [.let [builder (|> (list.partial the_command arguments) ..jvm::arguments_array @@ -324,11 +324,11 @@ (is (-> s (Try [s Exit])) on_await))) -(`` (def: (mock_process state mock) +(`` (def (mock_process state mock) (All (_ s) (-> (Atom s) (Mock s) (Process IO))) (implementation (~~ (with_template [<name> <mock>] - [(def: (<name> _) + [(def (<name> _) (do [! io.monad] [|state| (atom.read! state)] (case (at mock <mock> |state|) @@ -344,7 +344,7 @@ [fail on_fail] [await on_await] )) - (def: (write message) + (def (write message) (do [! io.monad] [|state| (atom.read! state)] (case (at mock on_write message |state|) @@ -355,7 +355,7 @@ {try.#Failure error} (in {try.#Failure error})))) - (def: (destroy _) + (def (destroy _) (do [! io.monad] [|state| (atom.read! state)] (case (at mock on_destroy |state|) @@ -367,14 +367,14 @@ {try.#Failure error} (in {try.#Failure error}))))))) -(def: .public (mock mock init) +(def .public (mock mock init) (All (_ s) (-> (-> [Environment Path Command (List Argument)] (Try (Mock s))) s (Shell IO))) (implementation - (def: execute + (def execute (|>> mock (at try.monad each (..mock_process (atom.atom init))) io.io)))) diff --git a/stdlib/source/parser/lux/data/binary.lux b/stdlib/source/parser/lux/data/binary.lux index d09eeba86..117f07a34 100644 --- a/stdlib/source/parser/lux/data/binary.lux +++ b/stdlib/source/parser/lux/data/binary.lux @@ -44,7 +44,7 @@ "Bytes read" (%.nat bytes_read))) (with_template [<name> <extension>] - [(def: <name> + [(def <name> (template (<name> <parameter> <subject>) [(<extension> <parameter> <subject>)]))] @@ -53,7 +53,7 @@ [n#- "lux i64 -"] ) -(def: .public (result parser input) +(def .public (result parser input) (All (_ a) (-> (Parser a) Binary (Try a))) (case (parser [0 input]) {try.#Success [[end _] output]} @@ -65,17 +65,17 @@ failure (as_expected failure))) -(def: .public end? +(def .public end? (Parser Bit) (function (_ (^.let input [offset data])) {try.#Success [input (n#= offset (/.size data))]})) -(def: .public offset +(def .public offset (Parser Offset) (function (_ (^.let input [offset data])) {try.#Success [input offset]})) -(def: .public remaining +(def .public remaining (Parser Nat) (function (_ (^.let input [offset data])) {try.#Success [input (n#- offset (/.size data))]})) @@ -83,10 +83,10 @@ (type: .public Size Nat) -(def: .public size_8 Size 1) -(def: .public size_16 Size (n.* 2 size_8)) -(def: .public size_32 Size (n.* 2 size_16)) -(def: .public size_64 Size (n.* 2 size_32)) +(def .public size_8 Size 1) +(def .public size_16 Size (n.* 2 size_8)) +(def .public size_32 Size (n.* 2 size_16)) +(def .public size_64 Size (n.* 2 size_32)) (exception: .public (range_out_of_bounds [length Nat start Nat @@ -97,7 +97,7 @@ "Range end" (%.nat end))) (with_template [<name> <size> <read>] - [(def: .public <name> + [(def .public <name> (Parser I64) (function (_ [start binary]) (let [end (n#+ <size> start)] @@ -114,14 +114,14 @@ ) (with_template [<name> <type>] - [(def: .public <name> (Parser <type>) ..bits_64)] + [(def .public <name> (Parser <type>) ..bits_64)] [nat Nat] [int Int] [rev Rev] ) -(def: .public frac +(def .public frac (Parser Frac) (//#each frac.of_bits ..bits_64)) @@ -131,7 +131,7 @@ "Tag range" (%.nat range) "Tag value" (%.nat byte))) -(def: !variant +(def !variant (template (!variant <case>+) [(do [! //.monad] [flag (is (Parser Nat) @@ -144,18 +144,18 @@ _ (//.lifted (exception.except ..invalid_tag [(template.amount [<case>+]) flag])))))])) -(def: .public (or left right) +(def .public (or left right) (All (_ l r) (-> (Parser l) (Parser r) (Parser (Or l r)))) (!variant [[0 [.#Left] left] [1 [.#Right] right]])) -(def: .public (rec body) +(def .public (rec body) (All (_ a) (-> (-> (Parser a) (Parser a)) (Parser a))) (function (_ input) (let [parser (body (rec body))] (parser input)))) -(def: .public any +(def .public any (Parser Any) (//#in [])) @@ -164,7 +164,7 @@ "Expected values" "either 0 or 1" "Actual value" (%.nat value))) -(def: .public bit +(def .public bit (Parser Bit) (do //.monad [value (is (Parser Nat) @@ -174,7 +174,7 @@ 1 (in #1) _ (//.lifted (exception.except ..not_a_bit [value]))))) -(def: .public (segment size) +(def .public (segment size) (-> Nat (Parser Binary)) (case size 0 (//#in (/.empty 0)) @@ -188,7 +188,7 @@ {try.#Success})))))) (with_template [<size> <name> <bits>] - [(`` (def: .public <name> + [(`` (def .public <name> (Parser Binary) (do //.monad [size (//#each (|>> .nat) <bits>)] @@ -201,7 +201,7 @@ ) (with_template [<size> <name> <binary>] - [(`` (def: .public <name> + [(`` (def .public <name> (Parser Text) (do //.monad [utf8 <binary>] @@ -213,10 +213,10 @@ [64 utf8_64 ..binary_64] ) -(def: .public text ..utf8_64) +(def .public text ..utf8_64) (with_template [<size> <name> <bits>] - [(def: .public (<name> valueP) + [(def .public (<name> valueP) (All (_ v) (-> (Parser v) (Parser (Sequence v)))) (do //.monad [amount (is (Parser Nat) @@ -240,11 +240,11 @@ [64 sequence_64 ..bits_64] ) -(def: .public maybe +(def .public maybe (All (_ a) (-> (Parser a) (Parser (Maybe a)))) (..or ..any)) -(def: .public (list value) +(def .public (list value) (All (_ a) (-> (Parser a) (Parser (List a)))) (..rec (|>> (//.and value) @@ -252,7 +252,7 @@ (exception: .public set_elements_are_not_unique) -(def: .public (set hash value) +(def .public (set hash value) (All (_ a) (-> (Hash a) (Parser a) (Parser (Set a)))) (do //.monad [raw (..list value) @@ -262,11 +262,11 @@ (set.size output)))] (in output))) -(def: .public symbol +(def .public symbol (Parser Symbol) (//.and ..text ..text)) -(def: .public type +(def .public type (Parser Type) (..rec (function (_ type) @@ -285,11 +285,11 @@ [9 [.#Apply] pair] [10 [.#Named] (//.and ..symbol type)]]))))) -(def: .public location +(def .public location (Parser Location) (all //.and ..text ..nat ..nat)) -(def: .public code +(def .public code (Parser Code) (..rec (function (_ again) diff --git a/stdlib/source/parser/lux/data/text.lux b/stdlib/source/parser/lux/data/text.lux index e02733f77..b6d86b35a 100644 --- a/stdlib/source/parser/lux/data/text.lux +++ b/stdlib/source/parser/lux/data/text.lux @@ -24,7 +24,7 @@ (type: .public Offset Nat) -(def: beginning +(def beginning Offset 0) @@ -39,7 +39,7 @@ [#basis Offset #distance Offset])) -(def: .public (slice parser) +(def .public (slice parser) (-> (Parser Slice) (Parser Text)) (do //.monad [[basis distance] parser] @@ -51,7 +51,7 @@ {.#None} (exception.except ..cannot_slice []))))) -(def: (left_over offset tape) +(def (left_over offset tape) (-> Offset Text Text) (|> tape (/.clip_since offset) maybe.trusted)) @@ -68,7 +68,7 @@ "Offset" (n#encoded offset) "Input" (..left_over offset tape))) -(def: .public (result parser input) +(def .public (result parser input) (All (_ a) (-> (Parser a) Text (Try a))) (case (parser [..beginning input]) {try.#Failure msg} @@ -79,12 +79,12 @@ {try.#Success output} (exception.except ..unconsumed_input [end_offset input])))) -(def: .public offset +(def .public offset (Parser Offset) (function (_ (^.let input [offset tape])) {try.#Success [input offset]})) -(def: (with_slices parser) +(def (with_slices parser) (-> (Parser (List Slice)) (Parser Slice)) (do //.monad [offset ..offset @@ -96,7 +96,7 @@ #distance 0] slices)))) -(def: .public any +(def .public any (Parser Text) (function (_ [offset tape]) (case (/.char offset tape) @@ -106,7 +106,7 @@ _ (exception.except ..cannot_parse [])))) -(def: .public any! +(def .public any! (Parser Slice) (function (_ [offset tape]) (case (/.char offset tape) @@ -119,7 +119,7 @@ (exception.except ..cannot_slice [])))) (with_template [<name> <type> <any>] - [(`` (def: .public (<name> parser) + [(`` (def .public (<name> parser) (All (_ a) (-> (Parser a) (Parser <type>))) (function (_ input) (case (parser input) @@ -137,7 +137,7 @@ (exception.report "Reference" (/.format reference))) -(def: .public (this reference) +(def .public (this reference) (-> Text (Parser Any)) (function (_ [offset tape]) (case (/.index_since offset reference tape) @@ -150,14 +150,14 @@ _ (exception.except ..cannot_match [reference])))) -(def: .public end +(def .public end (Parser Any) (function (_ (^.let input [offset tape])) (if (n.= offset (/.size tape)) {try.#Success [input []]} (exception.except ..unconsumed_input input)))) -(def: .public next +(def .public next (Parser Text) (function (_ (^.let input [offset tape])) (case (/.char offset tape) @@ -167,12 +167,12 @@ _ (exception.except ..cannot_parse [])))) -(def: .public remaining +(def .public remaining (Parser Text) (function (_ (^.let input [offset tape])) {try.#Success [input (..left_over offset tape)]})) -(def: .public (range bottom top) +(def .public (range bottom top) (-> Nat Nat (Parser Text)) (do //.monad [char any @@ -182,7 +182,7 @@ (n.<= top char')))] (in char))) -(def: .public (range! bottom top) +(def .public (range! bottom top) (-> Nat Nat (Parser Slice)) (do //.monad [it ..any! @@ -194,11 +194,11 @@ (in it))) (with_template [<bottom> <top> <text> <slice>] - [(def: .public <text> + [(def .public <text> (Parser Text) (..range (char <bottom>) (char <top>))) - (def: .public <slice> + (def .public <slice> (Parser Slice) (..range! (char <bottom>) (char <top>)))] @@ -208,20 +208,20 @@ ["0" "7" octal octal!] ) -(def: .public alpha (Parser Text) (//.either ..lower ..upper)) -(def: .public alpha! (Parser Slice) (//.either ..lower! ..upper!)) +(def .public alpha (Parser Text) (//.either ..lower ..upper)) +(def .public alpha! (Parser Slice) (//.either ..lower! ..upper!)) -(def: .public alpha_num (Parser Text) (//.either ..alpha ..decimal)) -(def: .public alpha_num! (Parser Slice) (//.either ..alpha! ..decimal!)) +(def .public alpha_num (Parser Text) (//.either ..alpha ..decimal)) +(def .public alpha_num! (Parser Slice) (//.either ..alpha! ..decimal!)) -(def: .public hexadecimal +(def .public hexadecimal (Parser Text) (all //.either ..decimal (..range (char "a") (char "f")) (..range (char "A") (char "F")))) -(def: .public hexadecimal! +(def .public hexadecimal! (Parser Slice) (all //.either ..decimal! @@ -240,7 +240,7 @@ ) (with_template [<name> <modifier> <exception>] - [(def: .public (<name> options) + [(def .public (<name> options) (-> Text (Parser Text)) (function (_ [offset tape]) (case (/.char offset tape) @@ -258,7 +258,7 @@ ) (with_template [<name> <modifier> <exception>] - [(def: .public (<name> options) + [(def .public (<name> options) (-> Text (Parser Slice)) (function (_ [offset tape]) (case (/.char offset tape) @@ -281,7 +281,7 @@ (exception.report "Character" (/.format (/.of_char character)))) -(def: .public (satisfies parser) +(def .public (satisfies parser) (-> (-> Char Bit) (Parser Text)) (function (_ [offset tape]) (case (/.char offset tape) @@ -293,7 +293,7 @@ _ (exception.except ..cannot_parse [])))) -(def: .public (satisfies! parser) +(def .public (satisfies! parser) (-> (-> Char Bit) (Parser Slice)) (function (_ [offset tape]) (case (/.char offset tape) @@ -306,22 +306,22 @@ _ (exception.except ..cannot_parse [])))) -(def: .public space +(def .public space (Parser Text) (..satisfies /.space?)) -(def: .public space! +(def .public space! (Parser Slice) (..satisfies! /.space?)) -(def: .public (and left right) +(def .public (and left right) (-> (Parser Text) (Parser Text) (Parser Text)) (do //.monad [=left left =right right] (in (all /#composite =left =right)))) -(def: .public (and! left right) +(def .public (and! left right) (-> (Parser Slice) (Parser Slice) (Parser Slice)) (do //.monad [(open "left[0]") left @@ -329,7 +329,7 @@ (in [left#basis ("lux i64 +" left#distance right#distance)]))) (with_template [<name> <base> <doc_modifier>] - [(def: .public (<name> parser) + [(def .public (<name> parser) (-> (Parser Text) (Parser Text)) (|> parser <base> (at //.monad each /.together)))] @@ -338,7 +338,7 @@ ) (with_template [<name> <base> <doc_modifier>] - [(def: .public (<name> parser) + [(def .public (<name> parser) (-> (Parser Slice) (Parser Slice)) (with_slices (<base> parser)))] @@ -347,7 +347,7 @@ ) (with_template [<name> <base> <doc_modifier>] - [(def: .public (<name> amount parser) + [(def .public (<name> amount parser) (-> Nat (Parser Text) (Parser Text)) (|> parser (<base> amount) @@ -359,7 +359,7 @@ ) (with_template [<name> <base> <doc_modifier>] - [(def: .public (<name> amount parser) + [(def .public (<name> amount parser) (-> Nat (Parser Slice) (Parser Slice)) (with_slices (<base> amount parser)))] @@ -369,24 +369,24 @@ [at_least! //.at_least "at least"] ) -(def: .public (between minimum additional parser) +(def .public (between minimum additional parser) (-> Nat Nat (Parser Text) (Parser Text)) (|> parser (//.between minimum additional) (at //.monad each /.together))) -(def: .public (between! minimum additional parser) +(def .public (between! minimum additional parser) (-> Nat Nat (Parser Slice) (Parser Slice)) (with_slices (//.between minimum additional parser))) -(def: .public (enclosed [start end] parser) +(def .public (enclosed [start end] parser) (All (_ a) (-> [Text Text] (Parser a) (Parser a))) (|> parser (//.before (this end)) (//.after (this start)))) -(def: .public (local local_input parser) +(def .public (local local_input parser) (All (_ a) (-> Text (Parser a) (Parser a))) (function (_ real_input) (case (..result parser local_input) @@ -396,7 +396,7 @@ {try.#Success value} {try.#Success [real_input value]}))) -(def: .public (then structured text) +(def .public (then structured text) (All (_ s a) (-> (Parser a) (//.Parser s Text) diff --git a/stdlib/source/parser/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/parser/lux/tool/compiler/language/lux/analysis.lux index 3a298ba27..eb2695e96 100644 --- a/stdlib/source/parser/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/parser/lux/tool/compiler/language/lux/analysis.lux @@ -31,7 +31,7 @@ [variable (.only)]]]]]] ["/" \\library (.only Environment Analysis)]) -(def: (remaining_inputs asts) +(def (remaining_inputs asts) (-> (List Analysis) Text) (format text.new_line "Remaining input: " (|> asts @@ -49,7 +49,7 @@ (type: .public Parser (//.Parser (List Analysis))) -(def: .public (result parser input) +(def .public (result parser input) (All (_ a) (-> (Parser a) (List Analysis) (Try a))) (case (parser input) {try.#Failure error} @@ -61,7 +61,7 @@ {try.#Success [unconsumed _]} (exception.except ..unconsumed_input unconsumed))) -(def: .public any +(def .public any (Parser Analysis) (function (_ input) (case input @@ -71,7 +71,7 @@ {.#Item [head tail]} {try.#Success [tail head]}))) -(def: .public end +(def .public end (Parser Any) (function (_ tokens) (case tokens @@ -79,7 +79,7 @@ _ {try.#Failure (format "Expected list of tokens to be empty!" (remaining_inputs tokens))}))) -(def: .public end? +(def .public end? (Parser Bit) (function (_ tokens) {try.#Success [tokens (case tokens @@ -87,7 +87,7 @@ _ false)]})) (with_template [<query> <assertion> <tag> <type> <eq>] - [(`` (these (def: .public <query> + [(`` (these (def .public <query> (Parser <type>) (function (_ input) (case input @@ -97,7 +97,7 @@ _ (exception.except ..cannot_parse input)))) - (def: .public (<assertion> expected) + (def .public (<assertion> expected) (-> <type> (Parser Any)) (function (_ input) (case input @@ -120,7 +120,7 @@ [constant this_constant /.constant Symbol symbol.equivalence] ) -(def: .public (tuple parser) +(def .public (tuple parser) (All (_ a) (-> (Parser a) (Parser a))) (function (_ input) (case input diff --git a/stdlib/source/parser/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/parser/lux/tool/compiler/language/lux/synthesis.lux index c6537531f..535e03cc0 100644 --- a/stdlib/source/parser/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/parser/lux/tool/compiler/language/lux/synthesis.lux @@ -54,7 +54,7 @@ (type: .public Parser (//.Parser (List Synthesis))) -(def: .public (result parser input) +(def .public (result parser input) (All (_ a) (-> (Parser a) (List Synthesis) (Try a))) (case (parser input) {try.#Failure error} @@ -66,7 +66,7 @@ {try.#Success [unconsumed _]} (exception.except ..unconsumed_input unconsumed))) -(def: .public any +(def .public any (Parser Synthesis) (.function (_ input) (case input @@ -76,14 +76,14 @@ {.#Item [head tail]} {try.#Success [tail head]}))) -(def: .public end +(def .public end (Parser Any) (.function (_ tokens) (case tokens {.#End} {try.#Success [tokens []]} _ (exception.except ..expected_empty_input [tokens])))) -(def: .public end? +(def .public end? (Parser Bit) (.function (_ tokens) {try.#Success [tokens (case tokens @@ -91,7 +91,7 @@ _ false)]})) (with_template [<query> <assertion> <tag> <type> <eq>] - [(`` (def: .public <query> + [(`` (def .public <query> (Parser <type>) (.function (_ input) (case input @@ -101,7 +101,7 @@ _ (exception.except ..cannot_parse input))))) - (`` (def: .public (<assertion> expected) + (`` (def .public (<assertion> expected) (-> <type> (Parser Any)) (.function (_ input) (case input @@ -122,7 +122,7 @@ [constant this_constant /.constant Symbol symbol.equivalence] ) -(def: .public (tuple parser) +(def .public (tuple parser) (All (_ a) (-> (Parser a) (Parser a))) (.function (_ input) (case input @@ -134,7 +134,7 @@ _ (exception.except ..cannot_parse input)))) -(def: .public (function expected parser) +(def .public (function expected parser) (All (_ a) (-> Arity (Parser a) (Parser [(Environment Synthesis) a]))) (.function (_ input) (case input @@ -148,7 +148,7 @@ _ (exception.except ..cannot_parse input)))) -(def: .public (loop init_parsers iteration_parser) +(def .public (loop init_parsers iteration_parser) (All (_ a b) (-> (Parser a) (Parser b) (Parser [Register a b]))) (.function (_ input) (case input diff --git a/stdlib/source/polytypic/lux/abstract/equivalence.lux b/stdlib/source/polytypic/lux/abstract/equivalence.lux index 03d3dd3de..48accfa31 100644 --- a/stdlib/source/polytypic/lux/abstract/equivalence.lux +++ b/stdlib/source/polytypic/lux/abstract/equivalence.lux @@ -40,7 +40,7 @@ [\\library ["[0]" /]]) -(def: .public equivalence +(def .public equivalence (polytypic equivalence (`` (do [! <>.monad] [.let [g!_ (code.local "_____________")] diff --git a/stdlib/source/polytypic/lux/abstract/functor.lux b/stdlib/source/polytypic/lux/abstract/functor.lux index fc7cae722..07f2492cf 100644 --- a/stdlib/source/polytypic/lux/abstract/functor.lux +++ b/stdlib/source/polytypic/lux/abstract/functor.lux @@ -23,7 +23,7 @@ [\\library ["[0]" /]]) -(def: .public functor +(def .public functor (polytypic functor (do [! p.monad] [.let [g!_ (code.local "____________") @@ -107,5 +107,5 @@ (p.failure (format "Cannot create Functor for: " (%.type inputT)))))] (in (` (is (~ (@Functor inputT)) (implementation - (def: ((~' each) (~ funcC) (~ inputC)) + (def ((~' each) (~ funcC) (~ inputC)) (~ outputC))))))))) diff --git a/stdlib/source/polytypic/lux/data/format/json.lux b/stdlib/source/polytypic/lux/data/format/json.lux index 63017d5ba..972e074a5 100644 --- a/stdlib/source/polytypic/lux/data/format/json.lux +++ b/stdlib/source/polytypic/lux/data/format/json.lux @@ -38,29 +38,29 @@ [\\library ["[0]" / (.only JSON)]]) -(def: tag +(def tag (-> Nat Frac) (|>> .int int.frac)) -(def: (rec_encoded non_rec) +(def (rec_encoded non_rec) (All (_ a) (-> (-> (-> a JSON) (-> a JSON)) (-> a JSON))) (function (_ input) (non_rec (rec_encoded non_rec) input))) -(def: low_mask Nat (|> 1 (i64.left_shifted 32) --)) -(def: high_mask Nat (|> low_mask (i64.left_shifted 32))) +(def low_mask Nat (|> 1 (i64.left_shifted 32) --)) +(def high_mask Nat (|> low_mask (i64.left_shifted 32))) -(def: nat_codec +(def nat_codec (codec.Codec JSON Nat) (implementation - (def: (encoded input) + (def (encoded input) (let [high (|> input (i64.and high_mask) (i64.right_shifted 32)) low (i64.and low_mask input)] {/.#Array (sequence (|> high .int int.frac {/.#Number}) (|> low .int int.frac {/.#Number}))})) - (def: decoded + (def decoded (</>.result (</>.array (do <>.monad [high </>.number @@ -68,34 +68,34 @@ (in (n.+ (|> high frac.int .nat (i64.left_shifted 32)) (|> low frac.int .nat))))))))) -(def: int_codec +(def int_codec (codec.Codec JSON Int) (implementation - (def: encoded + (def encoded (|>> .nat (at nat_codec encoded))) - (def: decoded + (def decoded (|>> (at nat_codec decoded) (at try.functor each (|>> .int)))))) ... Builds a JSON generator for potentially inexistent values. -(def: (nullable writer) +(def (nullable writer) (All (_ a) (-> (-> a JSON) (-> (Maybe a) JSON))) (function (_ elem) (case elem {.#None} {/.#Null} {.#Some value} (writer value)))) -(def: qty_codec +(def qty_codec (All (_ unit) (codec.Codec JSON (unit.Qty unit))) (implementation - (def: encoded + (def encoded (|>> unit.number (at ..int_codec encoded))) - (def: decoded + (def decoded (|>> (at ..int_codec decoded) (at try.functor each unit.quantity))))) -(def: encoded +(def encoded (polytypic encoded (with_expansions [<basic> (with_template [<matcher> <encoder>] @@ -221,7 +221,7 @@ (<>.failure (format "Cannot create JSON encoder for: " (type.format inputT))) ))))) -(def: decoded +(def decoded (polytypic decoded (with_expansions [<basic> (with_template [<matcher> <decoder>] @@ -325,12 +325,12 @@ (<>.failure (format "Cannot create JSON decoder for: " (type.format inputT))) ))))) -(def: .public codec +(def .public codec (syntax (_ [inputT <code>.any]) (in (.list (` (is (codec.Codec /.JSON (~ inputT)) (implementation - (def: (~' encoded) + (def (~' encoded) ((~! ..encoded) (~ inputT))) - (def: (~' decoded) + (def (~' decoded) ((~! </>.result) ((~! ..decoded) (~ inputT)))) ))))))) diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux index 636487ee8..c763171c7 100644 --- a/stdlib/source/program/aedifex.lux +++ b/stdlib/source/program/aedifex.lux @@ -63,17 +63,17 @@ ["[1]/[0]" auto] ["[1]/[0]" deploy]]]) -(def: repositories +(def repositories (-> /.Profile (List (Repository Async))) (|>> (the /.#repositories) set.list (list#each (|>> (/repository/remote.repository http.default {.#None}) /repository.async)))) -(def: program (program.async program.default)) -(def: fs (file.async file.default)) -(def: local (/repository/local.repository ..program ..fs)) +(def program (program.async program.default)) +(def fs (file.async file.default)) +(def local (/repository/local.repository ..program ..fs)) -(def: (with_dependencies program console command profile) +(def (with_dependencies program console command profile) (All (_ a) (-> (Program Async) (Console Async) (-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit a])) @@ -104,17 +104,17 @@ (format (%.text name) " := " (%.text repo))) (dictionary.entries options)))) -(def: succeed! +(def succeed! (IO Any) (at program.default exit shell.normal)) -(def: (fail! error) +(def (fail! error) (-> Text (IO Any)) (exec (debug.log! error) (at program.default exit shell.error))) -(def: (command action) +(def (command action) (All (_ a) (-> (Async (Try a)) (IO Any))) (exec (do async.monad @@ -130,11 +130,11 @@ (exception: .public invalid_operation) -(`` (def: write_only +(`` (def write_only (Console IO) (implementation (~~ (with_template [<name>] - [(def: (<name> _) + [(def (<name> _) (io.io (exception.except ..invalid_operation [])))] [read] @@ -142,7 +142,7 @@ [close] )) - (def: (write it) + (def (write it) (<| io.io {try.#Success} debug.log! diff --git a/stdlib/source/program/aedifex/action.lux b/stdlib/source/program/aedifex/action.lux index fac52a5e7..1e2e25921 100644 --- a/stdlib/source/program/aedifex/action.lux +++ b/stdlib/source/program/aedifex/action.lux @@ -11,6 +11,6 @@ (type: .public (Action a) (Async (Try a))) -(def: .public monad +(def .public monad (Monad Action) (as_expected (try.with async.monad))) diff --git a/stdlib/source/program/aedifex/artifact.lux b/stdlib/source/program/aedifex/artifact.lux index 278b79ea4..3799bfb74 100644 --- a/stdlib/source/program/aedifex/artifact.lux +++ b/stdlib/source/program/aedifex/artifact.lux @@ -31,7 +31,7 @@ #name Name #version Version])) -(def: .public hash +(def .public hash (Hash Artifact) (all product.hash text.hash @@ -39,17 +39,17 @@ text.hash )) -(def: .public equivalence +(def .public equivalence (Equivalence Artifact) (at ..hash equivalence)) -(def: .public order +(def .public order (Order Artifact) (implementation - (def: equivalence + (def equivalence ..equivalence) - (def: (< reference subject) + (def (< reference subject) (<| (or (text#< (the #group reference) (the #group subject))) @@ -64,7 +64,7 @@ (the #version subject)))))) (with_template [<separator> <definition>] - [(def: <definition> + [(def <definition> Text <separator>)] @@ -73,37 +73,37 @@ [":" identity_separator] ) -(def: .public (identity artifact) +(def .public (identity artifact) (-> Artifact Text) (%.format (the #name artifact) ..version_separator (the #version artifact))) -(def: .public (format value) +(def .public (format value) (Format Artifact) (%.format (the #group value) ..identity_separator (..identity value))) -(def: .public (directory separator group) +(def .public (directory separator group) (-> Text Group Text) (|> group (text.all_split_by ..group_separator) (text.interposed separator))) -(def: .public (bundle version artifact) +(def .public (bundle version artifact) (-> Version Artifact URI) (let [/ uri.separator group (..directory / (the #group artifact)) name (the #name artifact)] (%.format group / name / version))) -(def: .public (uri version artifact) +(def .public (uri version artifact) (-> Version Artifact URI) (let [/ uri.separator] (%.format (..bundle version artifact) / (..identity artifact)))) -(def: .public (local artifact) +(def .public (local artifact) (-> Artifact (List Text)) (list#composite (|> artifact (the #group) diff --git a/stdlib/source/program/aedifex/artifact/extension.lux b/stdlib/source/program/aedifex/artifact/extension.lux index c89fd2a35..f78a4b963 100644 --- a/stdlib/source/program/aedifex/artifact/extension.lux +++ b/stdlib/source/program/aedifex/artifact/extension.lux @@ -12,19 +12,19 @@ (type: .public Extension Text) -(def: separator +(def separator ".") -(def: .public extension +(def .public extension (-> //.Type Extension) (|>> (format ..separator))) -(def: .public type +(def .public type (-> Extension //.Type) (text.replaced ..separator "")) (with_template [<name>] - [(def: .public <name> + [(def .public <name> Extension (..extension (template.symbol [//._] [<name>])))] diff --git a/stdlib/source/program/aedifex/artifact/snapshot.lux b/stdlib/source/program/aedifex/artifact/snapshot.lux index b9fde212c..4966eb80f 100644 --- a/stdlib/source/program/aedifex/artifact/snapshot.lux +++ b/stdlib/source/program/aedifex/artifact/snapshot.lux @@ -21,13 +21,13 @@ {#Local} {#Remote Stamp})) -(def: any_equivalence +(def any_equivalence (Equivalence Any) (implementation - (def: (= _ _) + (def (= _ _) true))) -(def: .public equivalence +(def .public equivalence (Equivalence Snapshot) (all sum.equivalence ..any_equivalence @@ -35,28 +35,28 @@ )) (with_template [<definition> <tag>] - [(def: <definition> xml.Tag ["" <tag>])] + [(def <definition> xml.Tag ["" <tag>])] [<local_copy> "localCopy"] [<snapshot> "snapshot"] ) -(def: local_copy_value +(def local_copy_value "true") -(def: local_copy_format +(def local_copy_format XML {xml.#Node <local_copy> xml.attributes (list {xml.#Text ..local_copy_value})}) -(def: local_copy_parser +(def local_copy_parser (Parser Any) (<| (<xml>.node ..<local_copy>) (<text>.then (<text>.this ..local_copy_value)) <xml>.text)) -(def: .public (format snapshot) +(def .public (format snapshot) (-> Snapshot XML) (<| {xml.#Node ..<snapshot> xml.attributes} (case snapshot @@ -66,7 +66,7 @@ {#Remote stamp} (/stamp.format stamp)))) -(def: .public parser +(def .public parser (Parser Snapshot) (<| (<xml>.node <snapshot>) (<>.or ..local_copy_parser diff --git a/stdlib/source/program/aedifex/artifact/snapshot/build.lux b/stdlib/source/program/aedifex/artifact/snapshot/build.lux index 483da5e39..f0a0c7d18 100644 --- a/stdlib/source/program/aedifex/artifact/snapshot/build.lux +++ b/stdlib/source/program/aedifex/artifact/snapshot/build.lux @@ -20,22 +20,22 @@ (type: .public Build Nat) -(def: .public equivalence +(def .public equivalence (Equivalence Build) nat.equivalence) -(def: tag +(def tag xml.Tag ["" "buildNumber"]) -(def: .public format +(def .public format (-> Build XML) (|>> %.nat {xml.#Text} list {xml.#Node ..tag xml.attributes})) -(def: .public parser +(def .public parser (Parser Build) (<| (<xml>.node ..tag) (<text>.then (<>.codec nat.decimal (<text>.many <text>.decimal))) diff --git a/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux b/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux index 3365d685c..2f82cf020 100644 --- a/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux +++ b/stdlib/source/program/aedifex/artifact/snapshot/stamp.lux @@ -22,36 +22,36 @@ [#time Time #build Build])) -(def: .public equivalence +(def .public equivalence (Equivalence Stamp) (all product.equivalence //time.equivalence //build.equivalence )) -(def: <timestamp> +(def <timestamp> xml.Tag ["" "timestamp"]) -(def: time_format +(def time_format (-> Time XML) (|>> //time.format {xml.#Text} list {xml.#Node ..<timestamp> xml.attributes})) -(def: .public (format (open "_[0]")) +(def .public (format (open "_[0]")) (-> Stamp (List XML)) (list (..time_format _#time) (//build.format _#build))) -(def: time_parser +(def time_parser (Parser Time) (<| (<xml>.node <timestamp>) (<text>.then //time.parser) <xml>.text)) -(def: .public parser +(def .public parser (Parser Stamp) (<>.and (<xml>.somewhere ..time_parser) (<xml>.somewhere //build.parser))) diff --git a/stdlib/source/program/aedifex/artifact/snapshot/time.lux b/stdlib/source/program/aedifex/artifact/snapshot/time.lux index 3b6fbe0ee..38a60ede0 100644 --- a/stdlib/source/program/aedifex/artifact/snapshot/time.lux +++ b/stdlib/source/program/aedifex/artifact/snapshot/time.lux @@ -24,20 +24,20 @@ (type: .public Time ///time.Time) -(def: .public equivalence +(def .public equivalence (Equivalence Time) ///time.equivalence) -(def: separator +(def separator ".") -(def: .public (format [date time]) +(def .public (format [date time]) (%.Format Time) (%.format (///time/date.format date) ..separator (///time/time.format time))) -(def: .public parser +(def .public parser (<text>.Parser Time) (do <>.monad [date ///time/date.parser diff --git a/stdlib/source/program/aedifex/artifact/snapshot/version.lux b/stdlib/source/program/aedifex/artifact/snapshot/version.lux index bf26ae259..e38534c8f 100644 --- a/stdlib/source/program/aedifex/artifact/snapshot/version.lux +++ b/stdlib/source/program/aedifex/artifact/snapshot/version.lux @@ -23,7 +23,7 @@ #value Text #updated Time])) -(def: .public equivalence +(def .public equivalence (Equivalence Version) (all product.equivalence text.equivalence @@ -32,7 +32,7 @@ )) (with_template [<definition> <tag>] - [(def: <definition> xml.Tag ["" <tag>])] + [(def <definition> xml.Tag ["" <tag>])] [<extension> "extension"] [<value> "value"] @@ -41,23 +41,23 @@ [<snapshot_version> "snapshotVersion"] ) -(def: (text_format tag value) +(def (text_format tag value) (-> xml.Tag Text XML) (|> value {xml.#Text} list {xml.#Node tag xml.attributes})) -(def: .public (format (open "_[0]")) +(def .public (format (open "_[0]")) (-> Version XML) (<| {xml.#Node ..<snapshot_version> xml.attributes} (list (..text_format ..<extension> _#extension) (..text_format ..<value> _#value) (..text_format ..<updated> (///time.format _#updated))))) -(def: (text tag) +(def (text tag) (-> xml.Tag (Parser Text)) (<| (<xml>.node tag) <xml>.text)) -(def: .public parser +(def .public parser (Parser Version) (<| (<xml>.node ..<snapshot_version>) (all <>.and diff --git a/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux b/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux index 875326058..c0b528186 100644 --- a/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux +++ b/stdlib/source/program/aedifex/artifact/snapshot/version/value.lux @@ -16,20 +16,20 @@ [#version Text #snapshot Snapshot])) -(def: .public equivalence +(def .public equivalence (Equivalence Value) (all product.equivalence text.equivalence ///.equivalence )) -(def: separator +(def separator "-") -(def: .public snapshot +(def .public snapshot "SNAPSHOT") -(def: .public (format (open "/[0]")) +(def .public (format (open "/[0]")) (%.Format Value) (case /#snapshot {///.#Local} diff --git a/stdlib/source/program/aedifex/artifact/time.lux b/stdlib/source/program/aedifex/artifact/time.lux index d7be974fd..9e52e52ca 100644 --- a/stdlib/source/program/aedifex/artifact/time.lux +++ b/stdlib/source/program/aedifex/artifact/time.lux @@ -22,34 +22,34 @@ (type: .public Time [/date.Date /time.Time]) -(def: .public epoch +(def .public epoch Time [/date.epoch time.midnight]) -(def: .public (instant time) +(def .public (instant time) (-> Time Instant) (let [[date time] time] (instant.of_date_time (/date.value date) time))) -(def: .public (of_instant instant) +(def .public (of_instant instant) (-> Instant (Try Time)) (do try.monad [date (/date.date (instant.date instant))] (in [date (instant.time instant)]))) -(def: .public equivalence +(def .public equivalence (Equivalence Time) (product.equivalence /date.equivalence time.equivalence)) -(def: .public (format [date time]) +(def .public (format [date time]) (Format Time) (%.format (/date.format date) (/time.format time))) -(def: .public parser +(def .public parser (Parser Time) (do <>.monad [date /date.parser diff --git a/stdlib/source/program/aedifex/artifact/time/date.lux b/stdlib/source/program/aedifex/artifact/time/date.lux index 027ec6004..ba908f0af 100644 --- a/stdlib/source/program/aedifex/artifact/time/date.lux +++ b/stdlib/source/program/aedifex/artifact/time/date.lux @@ -23,14 +23,14 @@ [type [primitive (.except)]]]]) -(def: .public (pad value) +(def .public (pad value) (-> Nat Text) (if (n.< 10 value) (%.format "0" (%.nat value)) (%.nat value))) -(def: min_year +1,000) -(def: max_year +9,999) +(def min_year +1,000) +(def max_year +9,999) (exception: .public (year_is_out_of_range [year year.Year]) (exception.report @@ -41,11 +41,11 @@ (primitive .public Date date.Date - (def: .public epoch + (def .public epoch Date (abstraction date.epoch)) - (def: .public (date raw) + (def .public (date raw) (-> date.Date (Try Date)) (let [year (|> raw date.year year.value)] (if (or (i.< ..min_year year) @@ -53,24 +53,24 @@ (exception.except ..year_is_out_of_range [(date.year raw)]) {try.#Success (abstraction raw)}))) - (def: .public value + (def .public value (-> Date date.Date) (|>> representation)) - (def: .public equivalence + (def .public equivalence (Equivalence Date) (implementation - (def: (= reference subject) + (def (= reference subject) (date#= (representation reference) (representation subject))))) - (def: .public (format value) + (def .public (format value) (%.Format Date) (%.format (|> value representation date.year year.value .nat %.nat) (|> value representation date.month month.number ..pad) (|> value representation date.day_of_month ..pad))) - (def: .public parser + (def .public parser (Parser Date) (do <>.monad [year (<>.codec n.decimal (<text>.exactly 4 <text>.decimal)) diff --git a/stdlib/source/program/aedifex/artifact/time/time.lux b/stdlib/source/program/aedifex/artifact/time/time.lux index 01d2169d5..d02667bbc 100644 --- a/stdlib/source/program/aedifex/artifact/time/time.lux +++ b/stdlib/source/program/aedifex/artifact/time/time.lux @@ -19,14 +19,14 @@ (type: .public Time time.Time) -(def: .public (format value) +(def .public (format value) (%.Format Time) (let [(open "_[0]") (time.clock value)] (%.format (//.pad _#hour) (//.pad _#minute) (//.pad _#second)))) -(def: .public parser +(def .public parser (<text>.Parser Time) (do <>.monad [hour (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) diff --git a/stdlib/source/program/aedifex/artifact/type.lux b/stdlib/source/program/aedifex/artifact/type.lux index 53242c437..971b8757a 100644 --- a/stdlib/source/program/aedifex/artifact/type.lux +++ b/stdlib/source/program/aedifex/artifact/type.lux @@ -7,7 +7,7 @@ Text) (with_template [<type> <name>] - [(def: .public <name> + [(def .public <name> Type <type>)] diff --git a/stdlib/source/program/aedifex/artifact/versioning.lux b/stdlib/source/program/aedifex/artifact/versioning.lux index 5812e4368..811db7ab9 100644 --- a/stdlib/source/program/aedifex/artifact/versioning.lux +++ b/stdlib/source/program/aedifex/artifact/versioning.lux @@ -35,12 +35,12 @@ #last_updated //time.Time #versions (List Version)])) -(def: .public init +(def .public init [#snapshot {//snapshot.#Local} #last_updated //time.epoch #versions (list)]) -(def: .public equivalence +(def .public equivalence (Equivalence Versioning) (all product.equivalence //snapshot.equivalence @@ -49,7 +49,7 @@ )) (with_template [<definition> <tag>] - [(def: <definition> xml.Tag ["" <tag>])] + [(def <definition> xml.Tag ["" <tag>])] [<last_updated> "lastUpdated"] [<snapshot_versions> "snapshotVersions"] @@ -57,11 +57,11 @@ [<versioning> "versioning"] ) -(def: last_updated_format +(def last_updated_format (-> //time.Time XML) (|>> //time.format {xml.#Text} list {xml.#Node ..<last_updated> xml.attributes})) -(def: .public (format (open "_[0]")) +(def .public (format (open "_[0]")) (-> Versioning XML) (<| {xml.#Node ..<versioning> xml.attributes} (list (//snapshot.format _#snapshot) @@ -70,17 +70,17 @@ (list#each //snapshot/version.format) {xml.#Node ..<snapshot_versions> xml.attributes})))) -(def: (text tag) +(def (text tag) (-> xml.Tag (Parser Text)) (<| (<xml>.node tag) <xml>.text)) -(def: last_updated_parser +(def last_updated_parser (Parser //time.Time) (<| (<text>.then //time.parser) (..text ..<last_updated>))) -(def: .public parser +(def .public parser (Parser Versioning) (<| (<xml>.node ..<versioning>) (all <>.and diff --git a/stdlib/source/program/aedifex/cli.lux b/stdlib/source/program/aedifex/cli.lux index 25ab8be02..c717313cd 100644 --- a/stdlib/source/program/aedifex/cli.lux +++ b/stdlib/source/program/aedifex/cli.lux @@ -21,18 +21,18 @@ {#Build} {#Test})) -(def: any_equivalence +(def any_equivalence (Equivalence Any) (implementation - (def: (= reference subject) + (def (= reference subject) true))) -(def: compilation_equivalence +(def compilation_equivalence (Equivalence Compilation) (sum.equivalence ..any_equivalence ..any_equivalence)) -(def: compilation +(def compilation (Parser Compilation) (<>.or (cli.this "build") (cli.this "test"))) @@ -48,7 +48,7 @@ {#Compilation Compilation} {#Auto Compilation})) -(def: .public equivalence +(def .public equivalence (Equivalence Command) (all sum.equivalence ... #Version @@ -71,7 +71,7 @@ ... #Auto ..compilation_equivalence)) -(def: command' +(def command' (Parser Command) (all <>.or (cli.this "version") @@ -88,7 +88,7 @@ ..compilation) )) -(def: .public command +(def .public command (Parser [(List Name) Command]) (<>.rec (function (_ command) diff --git a/stdlib/source/program/aedifex/command/auto.lux b/stdlib/source/program/aedifex/command/auto.lux index 2e07625cb..81a1a855a 100644 --- a/stdlib/source/program/aedifex/command/auto.lux +++ b/stdlib/source/program/aedifex/command/auto.lux @@ -25,7 +25,7 @@ [dependency [resolution (.only Resolution)]]]]) -(def: (targets fs path) +(def (targets fs path) (-> (file.System Async) file.Path (Async (List file.Path))) (let [! async.monad] (|> path @@ -35,15 +35,15 @@ (at ! conjoint) (at ! each (|>> list.together (list.partial path)))))) -(def: .public delay +(def .public delay Nat 1,000) -(def: (pause delay) +(def (pause delay) (-> Nat (Async (Try Any))) (async.after delay {try.#Success []})) -(def: .public (do! delay watcher command) +(def .public (do! delay watcher command) (All (_ a) (-> Nat (Watcher Async) (-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit a])) diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index 168aa1971..d183b975b 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -56,7 +56,7 @@ (type: Finder (-> Resolution (Maybe Dependency))) -(def: (dependency_finder group name) +(def (dependency_finder group name) (-> Group Name Finder) (|>> dictionary.entries (list.one (function (_ [dependency package]) @@ -65,12 +65,12 @@ {.#Some dependency} {.#None}))))) -(def: .public lux_group +(def .public lux_group Group "com.github.luxlang") (with_template [<dependency> <definition>] - [(def: .public <definition> + [(def .public <definition> Name <dependency>)] @@ -92,13 +92,13 @@ {#Lua Dependency} {#Ruby Dependency})) -(def: (remove_dependency dependency) +(def (remove_dependency dependency) (-> Dependency (-> Resolution Resolution)) (|>> dictionary.entries (list.only (|>> product.left (same? dependency) not)) (dictionary.of_list ///dependency.hash))) -(def: (lux resolution lux_dependency) +(def (lux resolution lux_dependency) (-> Resolution Dependency (Try [Resolution Lux])) (let [[[lux_group lux_name lux_version] lux_type] lux_dependency] (case (..dependency_finder lux_group lux_name resolution) @@ -120,7 +120,7 @@ _ (exception.except ..no_available_lux [])))) -(def: (path fs home dependency) +(def (path fs home dependency) (All (_ !) (-> (file.System !) Path Dependency Path)) (let [/ (at fs separator) artifact (the ///dependency.#artifact dependency)] @@ -130,23 +130,23 @@ (format home /) (text.suffix (format "." (the ///dependency.#type dependency)))))) -(def: (libraries fs home) +(def (libraries fs home) (All (_ !) (-> (file.System !) Path Resolution (List Path))) (|>> dictionary.keys (list.only (|>> (the ///dependency.#type) (text#= ///artifact/type.lux_library))) (list#each (..path fs home)))) -(def: version_separator +(def version_separator ".") -(def: version_order +(def version_order (Order Version) (implementation - (def: equivalence + (def equivalence text.equivalence) - (def: (< left right) + (def (< left right) (loop (again [left (text.all_split_by ..version_separator left) right (text.all_split_by ..version_separator right)]) (case [left right] @@ -165,7 +165,7 @@ [{.#End} {.#End}] false))))) -(def: .public (host_dependencies fs home) +(def .public (host_dependencies fs home) (All (_ !) (-> (file.System !) Path Resolution (List Path))) (|>> dictionary.keys (list.only (|>> (the ///dependency.#type) @@ -189,20 +189,20 @@ dictionary.values (list#each (|>> product.right (..path fs home))))) -(def: (singular name) +(def (singular name) (-> Text Text (List Text)) (|>> (list name))) -(def: (plural name) +(def (plural name) (-> Text (List Text) (List Text)) (|>> (list#each (|>> (list name))) list.together)) -(def: .public start "[BUILD STARTED]") -(def: .public success "[BUILD ENDED]") -(def: .public failure "[BUILD FAILED]") +(def .public start "[BUILD STARTED]") +(def .public success "[BUILD ENDED]") +(def .public failure "[BUILD FAILED]") (with_template [<name> <capability>] - [(def: .public (<name> console process) + [(def .public (<name> console process) (-> (Console Async) (Process Async) (Async (Try Any))) ... This is a very odd way of implementing this function. ... But it's written this way because the more straightforward way (i.e. by using (try.with async.monad)) @@ -243,7 +243,7 @@ "[1]::[0]" ("static" getProperty [java/lang/String] "io" "try" java/lang/String)) -(def: windows? +(def windows? Bit (|> (java/lang/System::getProperty (ffi.as_string "os.name")) io.run! @@ -252,18 +252,18 @@ text.lower_cased (text.starts_with? "windows"))) -(def: jvm_class_path_separator +(def jvm_class_path_separator (if windows? ";" ":")) -(def: (jvm_class_path host_dependencies) +(def (jvm_class_path host_dependencies) (-> (List Path) Text) (|> host_dependencies {.#Item "."} (text.interposed ..jvm_class_path_separator))) -(def: .public (with_jvm_class_path host_dependencies runtime) +(def .public (with_jvm_class_path host_dependencies runtime) (-> (List Path) ///runtime.Runtime ///runtime.Runtime) (case host_dependencies {.#End} @@ -276,7 +276,7 @@ "--add-opens" "java.base/java.lang=ALL-UNNAMED")) runtime))) -(def: .public (do! console program fs shell resolution) +(def .public (do! console program fs shell resolution) (-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit Lux Path])) (function (_ profile) (let [target (the ///.#target profile)] diff --git a/stdlib/source/program/aedifex/command/clean.lux b/stdlib/source/program/aedifex/command/clean.lux index c16c517d6..de683bce1 100644 --- a/stdlib/source/program/aedifex/command/clean.lux +++ b/stdlib/source/program/aedifex/command/clean.lux @@ -18,7 +18,7 @@ ["[1]" profile] ["[1][0]" action (.only Action)]]) -(def: (clean_files! fs root) +(def (clean_files! fs root) (-> (file.System Async) Path (Async (Try Any))) (do [! ///action.monad] [_ (|> root @@ -27,11 +27,11 @@ (at ! conjoint))] (in []))) -(def: .public success +(def .public success (-> ///.Target Text) (|>> (format "Successfully cleaned target directory: "))) -(def: .public (do! console fs profile) +(def .public (do! console fs profile) (-> (Console Async) (file.System Async) (Command Any)) (do [! async.monad] [.let [target (the ///.#target profile)] diff --git a/stdlib/source/program/aedifex/command/deploy.lux b/stdlib/source/program/aedifex/command/deploy.lux index 0f34ba9a3..e432f5dac 100644 --- a/stdlib/source/program/aedifex/command/deploy.lux +++ b/stdlib/source/program/aedifex/command/deploy.lux @@ -23,10 +23,10 @@ ["/" profile] ["[1][0]" action]]]]) -(def: .public success +(def .public success "Successfully deployed the project.") -(def: .public (do! program shell console local remote fs artifact profile) +(def .public (do! program shell console local remote fs artifact profile) (-> (Program Async) (Shell Async) (Console Async) (Repository Async) (Repository Async) (file.System Async) Artifact (Command Any)) (do [! ///action.monad] [_ (if (/snapshot.snapshot? artifact) diff --git a/stdlib/source/program/aedifex/command/deploy/release.lux b/stdlib/source/program/aedifex/command/deploy/release.lux index 667bbf1ee..b709680ad 100644 --- a/stdlib/source/program/aedifex/command/deploy/release.lux +++ b/stdlib/source/program/aedifex/command/deploy/release.lux @@ -67,13 +67,13 @@ "[1]::[0]" ("static" getProperty [java/lang/String] "io" "try" java/lang/String)) -(def: windows? +(def windows? (IO (Try Bit)) (at (try.with io.monad) each (|>> java/lang/String::toLowerCase ffi.of_string (text.starts_with? "windows")) (java/lang/System::getProperty (ffi.as_string "os.name")))) -(def: dummy_jar +(def dummy_jar Binary (|> (packager.package (context.jvm "") (dictionary.empty text.hash) @@ -88,7 +88,7 @@ (undefined)))) (with_template [<name> <extension>] - [(def: <name> + [(def <name> (-> Text Text) (text.suffix <extension>))] @@ -100,7 +100,7 @@ ) (with_template [<name> <suffix>] - [(def: <name> + [(def <name> (-> Text Text) (|>> (text.suffix <suffix>) ..jar))] @@ -108,11 +108,11 @@ [sources "-sources"] ) -(def: .public release? +(def .public release? (Predicate Artifact) (|>> //snapshot.snapshot? not)) -(def: (install_dummies! program local fs artifact) +(def (install_dummies! program local fs artifact) (-> (Program Async) (Repository Async) (file.System Async) Artifact (Async (Try Any))) (do (try.with async.monad) [.let [$artifact (////artifact.uri (the ////artifact.#version artifact) artifact)] @@ -121,18 +121,18 @@ _ (at local upload (..sources $artifact) ..dummy_jar)] (in []))) -(def: (signed it) +(def (signed it) (-> Text [Text Text]) [it (..asc it)]) -(def: (release_unsigned_artifact! local remote uri) +(def (release_unsigned_artifact! local remote uri) (-> (Repository Async) (Repository Async) Text (Async (Try Binary))) (do [! ////action.monad] [it (at local download uri) _ (at remote upload uri it)] (in it))) -(def: (release_signed_artifact! local remote [artifact signature]) +(def (release_signed_artifact! local remote [artifact signature]) (-> (Repository Async) (Repository Async) [Text Text] (Async (Try Any))) (do [! ////action.monad] [it (..release_unsigned_artifact! local remote artifact) @@ -144,7 +144,7 @@ _ (..release_unsigned_artifact! local remote signature)] (in []))) -(def: .public (do! program shell console local remote fs artifact profile) +(def .public (do! program shell console local remote fs artifact profile) (-> (Program Async) (Shell Async) (Console Async) (Repository Async) (Repository Async) (file.System Async) Artifact (Command Any)) (do [! ////action.monad] [_ (///install.do! console fs local profile) diff --git a/stdlib/source/program/aedifex/command/deploy/snapshot.lux b/stdlib/source/program/aedifex/command/deploy/snapshot.lux index 37fc9a19b..dcfdc3ba4 100644 --- a/stdlib/source/program/aedifex/command/deploy/snapshot.lux +++ b/stdlib/source/program/aedifex/command/deploy/snapshot.lux @@ -39,12 +39,12 @@ ["[1][0]" artifact (.only Artifact) ["[1]/[0]" type]]]) -(def: .public snapshot? +(def .public snapshot? (Predicate Artifact) (|>> (the ////artifact.#version) (text.contains? "-SNAPSHOT"))) -(def: .public (do! console remote fs artifact profile) +(def .public (do! console remote fs artifact profile) (-> (Console Async) (Repository Async) (file.System Async) Artifact (Command Any)) (do [! ////action.monad] [library (|> profile diff --git a/stdlib/source/program/aedifex/command/deps.lux b/stdlib/source/program/aedifex/command/deps.lux index f2bc10fb1..682bec78c 100644 --- a/stdlib/source/program/aedifex/command/deps.lux +++ b/stdlib/source/program/aedifex/command/deps.lux @@ -31,13 +31,13 @@ ["[1]/[0]" resolution (.only Resolution)] ["[1]/[0]" deployment]]]]) -(def: format +(def format (%.Format Dependency) (|>> (the ///dependency.#artifact) ///artifact.format %.text)) -(def: .public (do! console local remotes new_repository profile) +(def .public (do! console local remotes new_repository profile) (-> (Console Async) (Repository Async) (List (Repository Async)) (-> URL (Repository Async)) (Command Resolution)) (do async.monad [.let [dependencies (|> (the ///.#dependencies profile) diff --git a/stdlib/source/program/aedifex/command/install.lux b/stdlib/source/program/aedifex/command/install.lux index 9e624a11c..f42a8fd65 100644 --- a/stdlib/source/program/aedifex/command/install.lux +++ b/stdlib/source/program/aedifex/command/install.lux @@ -45,13 +45,13 @@ ["[1][0]" artifact (.only Artifact) ["[1]/[0]" type]]]]) -(def: .public success +(def .public success "Successfully installed the project locally.") -(def: .public failure +(def .public failure "Failure: No 'identity' defined for the project.") -(def: .public (do! console fs local profile) +(def .public (do! console fs local profile) (-> (Console Async) (file.System Async) (Repository Async) (Command Any)) (case (the /.#identity profile) {.#Some identity} diff --git a/stdlib/source/program/aedifex/command/pom.lux b/stdlib/source/program/aedifex/command/pom.lux index 7b12a095b..f156e6f6b 100644 --- a/stdlib/source/program/aedifex/command/pom.lux +++ b/stdlib/source/program/aedifex/command/pom.lux @@ -22,10 +22,10 @@ ["[1][0]" action] ["[1][0]" pom]]) -(def: .public success +(def .public success (format "Successfully created POM file: " ///pom.file)) -(def: .public (do! console fs profile) +(def .public (do! console fs profile) (-> (Console Async) (file.System Async) (Command Any)) (do ///action.monad [content (|> (///pom.write profile) diff --git a/stdlib/source/program/aedifex/command/test.lux b/stdlib/source/program/aedifex/command/test.lux index 2e9e69ef8..c4eb94274 100644 --- a/stdlib/source/program/aedifex/command/test.lux +++ b/stdlib/source/program/aedifex/command/test.lux @@ -30,11 +30,11 @@ [dependency [resolution (.only Resolution)]]]]) -(def: .public start "[TEST STARTED]") -(def: .public success "[TEST ENDED]") -(def: .public failure "[TEST FAILED]") +(def .public start "[TEST STARTED]") +(def .public success "[TEST ENDED]") +(def .public failure "[TEST FAILED]") -(def: .public (do! console program fs shell resolution profile) +(def .public (do! console program fs shell resolution profile) (-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit Any])) (do async.monad [environment (program.environment async.monad program) diff --git a/stdlib/source/program/aedifex/command/version.lux b/stdlib/source/program/aedifex/command/version.lux index 506c1d93f..68293c94c 100644 --- a/stdlib/source/program/aedifex/command/version.lux +++ b/stdlib/source/program/aedifex/command/version.lux @@ -15,7 +15,7 @@ [/// [command (.only Command)]]) -(def: .public (do! console profile) +(def .public (do! console profile) (-> (Console Async) (Command Any)) (is (Async (Try Any)) (console.write_line (version.format meta/version.latest) diff --git a/stdlib/source/program/aedifex/dependency.lux b/stdlib/source/program/aedifex/dependency.lux index 11c66941f..92fe6b7ce 100644 --- a/stdlib/source/program/aedifex/dependency.lux +++ b/stdlib/source/program/aedifex/dependency.lux @@ -18,24 +18,24 @@ [#artifact Artifact #type Type])) -(def: .public hash +(def .public hash (Hash Dependency) (all product.hash //.hash text.hash )) -(def: .public equivalence +(def .public equivalence (Equivalence Dependency) (at hash equivalence)) -(def: .public order +(def .public order (Order Dependency) (implementation - (def: equivalence + (def equivalence ..equivalence) - (def: (< reference subject) + (def (< reference subject) (<| (or (//#< (the #artifact reference) (the #artifact subject))) diff --git a/stdlib/source/program/aedifex/dependency/deployment.lux b/stdlib/source/program/aedifex/dependency/deployment.lux index 7e4a427e3..85dd6fa2d 100644 --- a/stdlib/source/program/aedifex/dependency/deployment.lux +++ b/stdlib/source/program/aedifex/dependency/deployment.lux @@ -40,7 +40,7 @@ [resolution (.only Resolution)] ["[1]/[0]" status (.only Status)]]]) -(def: (with_status repository version_template [artifact type] [data status]) +(def (with_status repository version_template [artifact type] [data status]) (-> (Repository Async) ///artifact.Version Dependency [Binary Status] (Async (Try Any))) (let [artifact (format (///artifact.uri version_template artifact) (///artifact/extension.extension type)) @@ -69,7 +69,7 @@ [_ (deploy_hash ///hash.sha-1_codec ///artifact/extension.sha-1 sha-1)] (deploy_hash ///hash.md5_codec ///artifact/extension.md5 md5)))))) -(def: (artifacts type status) +(def (artifacts type status) (-> ///artifact/type.Type Status (List ///artifact/type.Type)) (with_expansions [<sha-1> (format type ///artifact/extension.sha-1) <md5> (format type ///artifact/extension.md5)] @@ -86,7 +86,7 @@ {///dependency/status.#Verified _} (list <sha-1> <md5>))))) -(def: (update_snapshot [artifact type] now snapshot) +(def (update_snapshot [artifact type] now snapshot) (-> Dependency Instant Metadata (Try Metadata)) (do try.monad [now (is (Try ///artifact/time.Time) @@ -115,7 +115,7 @@ ... (..artifacts ///artifact/type.pom (product.right (the ///package.#pom package))))) )))) -(def: .public (one repository [artifact type] package) +(def .public (one repository [artifact type] package) (-> (Repository Async) Dependency Package (Async (Try Artifact))) (do [! async.monad] [now (async.future instant.now) @@ -140,7 +140,7 @@ (///metadata/artifact.write repository artifact))] (in artifact)))) -(def: .public (all repository resolution) +(def .public (all repository resolution) (-> (Repository Async) Resolution (Async (Try (Set Artifact)))) (let [! (try.with async.monad)] (|> (dictionary.entries resolution) diff --git a/stdlib/source/program/aedifex/dependency/resolution.lux b/stdlib/source/program/aedifex/dependency/resolution.lux index 6a15823c8..08ca4d1a8 100644 --- a/stdlib/source/program/aedifex/dependency/resolution.lux +++ b/stdlib/source/program/aedifex/dependency/resolution.lux @@ -75,7 +75,7 @@ "[1]::[0]" (trim [] java/lang/String)) -(def: (verified_hash library repository version_template artifact extension hash codec exception) +(def (verified_hash library repository version_template artifact extension hash codec exception) (All (_ h) (-> Binary (Repository Async) Version Artifact Extension (-> Binary (Hash h)) (Codec Text (Hash h)) @@ -100,7 +100,7 @@ {try.#Failure error} (in {try.#Success {.#None}})))) -(def: (hashed repository version_template artifact extension) +(def (hashed repository version_template artifact extension) (-> (Repository Async) Version Artifact Extension (Async (Try [Binary Status]))) (do (try.with async.monad) [data (at repository download (///repository/remote.uri version_template artifact extension)) @@ -123,7 +123,7 @@ [{.#None} {.#None}] {//status.#Unverified})]))) -(def: .public (one repository dependency) +(def .public (one repository dependency) (-> (Repository Async) Dependency (Async (Try Package))) (let [[artifact type] dependency extension (///artifact/extension.extension type)] @@ -147,11 +147,11 @@ (type: .public Resolution (Dictionary Dependency Package)) -(def: .public empty +(def .public empty Resolution (dictionary.empty //.hash)) -(def: .public equivalence +(def .public equivalence (Equivalence Resolution) (dictionary.equivalence ///package.equivalence)) @@ -161,7 +161,7 @@ "Type" (%.text (the //.#type dependency)))) (with_template [<sigil> <name> <doing> <at>] - [(def: (<name> console repository artifact) + [(def (<name> console repository artifact) (-> (Console Async) (Repository Async) Artifact (Async (Try Any))) (at console write (format "[" <sigil> "]" " " <doing> @@ -175,7 +175,7 @@ ["X" announce_failure "Missed" "from"] ) -(def: .public (any console repositories dependency) +(def .public (any console repositories dependency) (-> (Console Async) (List (Repository Async)) Dependency (Async (Try Package))) (case repositories {.#End} @@ -198,7 +198,7 @@ [_ (..announce_failure console repository (the //.#artifact dependency))] (any console alternatives dependency)))))) -(def: .public (all console repositories new_repository dependencies resolution) +(def .public (all console repositories new_repository dependencies resolution) (-> (Console Async) (List (Repository Async)) (-> URL (Repository Async)) (List Dependency) Resolution (Async [(List Dependency) (List Dependency) diff --git a/stdlib/source/program/aedifex/dependency/status.lux b/stdlib/source/program/aedifex/dependency/status.lux index f36f85fe2..b8a962142 100644 --- a/stdlib/source/program/aedifex/dependency/status.lux +++ b/stdlib/source/program/aedifex/dependency/status.lux @@ -17,13 +17,13 @@ (Hash MD5))} {#Verified (Hash SHA-1) (Hash MD5)})) -(def: any_equivalence +(def any_equivalence (Equivalence Any) (implementation - (def: (= _ _) + (def (= _ _) true))) -(def: .public equivalence +(def .public equivalence (Equivalence Status) (all sum.equivalence ..any_equivalence @@ -35,7 +35,7 @@ ///hash.equivalence) )) -(def: .public (verified payload) +(def .public (verified payload) (-> Binary Status) {#Verified (///hash.sha-1 payload) diff --git a/stdlib/source/program/aedifex/format.lux b/stdlib/source/program/aedifex/format.lux index 6316e6287..cd10c675f 100644 --- a/stdlib/source/program/aedifex/format.lux +++ b/stdlib/source/program/aedifex/format.lux @@ -26,7 +26,7 @@ (type: .public (Format a) (-> a Code)) -(def: (license [name url type]) +(def (license [name url type]) (Format /.License) (`' [#name (~ (code.text name)) #url (~ (code.text url)) @@ -37,12 +37,12 @@ {/.#Manual} (' "manual")))])) -(def: (organization [name url]) +(def (organization [name url]) (Format /.Organization) (`' [#name (~ (code.text name)) #url (~ (code.text url))])) -(def: (developer [name url organization]) +(def (developer [name url organization]) (Format /.Developer) (case organization {.#None} @@ -54,14 +54,14 @@ #url (~ (code.text url)) #organization (~ (..organization value))]))) -(def: contributor +(def contributor (Format /.Contributor) ..developer) (type: Aggregate (Dictionary Text Code)) -(def: aggregate +(def aggregate (Format Aggregate) (|>> dictionary.entries (list#each (function (_ [key value]) @@ -69,11 +69,11 @@ list#conjoint code.tuple)) -(def: empty +(def empty Aggregate (dictionary.empty text.hash)) -(def: (on_maybe field value format aggregate) +(def (on_maybe field value format aggregate) (All (_ a) (-> Text (Maybe a) (Format a) Aggregate Aggregate)) (case value @@ -83,7 +83,7 @@ {.#Some value} (dictionary.has field (format value) aggregate))) -(def: (on_list field value format aggregate) +(def (on_list field value format aggregate) (All (_ a) (-> Text (List a) (Format a) Aggregate Aggregate)) (case value @@ -93,12 +93,12 @@ value (dictionary.has field (` [(~+ (list#each format value))]) aggregate))) -(def: (on_set field value format aggregate) +(def (on_set field value format aggregate) (All (_ a) (-> Text (Set a) (Format a) Aggregate Aggregate)) (..on_list field (set.list value) format aggregate)) -(def: (on_dictionary field value key_format value_format aggregate) +(def (on_dictionary field value key_format value_format aggregate) (All (_ k v) (-> Text (Dictionary k v) (Format k) (Format v) Aggregate Aggregate)) (if (dictionary.empty? value) @@ -112,7 +112,7 @@ code.tuple) aggregate))) -(def: (info value) +(def (info value) (Format /.Info) (|> ..empty (..on_maybe "name" (the /.#name value) code.text) @@ -125,24 +125,24 @@ (..on_list "contributors" (the /.#contributors value) ..contributor) ..aggregate)) -(def: (artifact' [group name version]) +(def (artifact' [group name version]) (-> Artifact (List Code)) (list (code.text group) (code.text name) (code.text version))) -(def: (artifact value) +(def (artifact value) (Format Artifact) (` [(~+ (..artifact' value))])) -(def: (dependency [artifact type]) +(def (dependency [artifact type]) (Format Dependency) (if (text#= //artifact/type.lux_library type) (` [(~+ (..artifact' artifact))]) (` [(~+ (..artifact' artifact)) (~ (code.text type))]))) -(def: (runtime [environment program parameters]) +(def (runtime [environment program parameters]) (Format Runtime) (` [(~+ (list#each (function (_ [var value]) (` [(~ (code.text var)) @@ -151,15 +151,15 @@ (~ (code.text program)) (~+ (list#each code.text parameters))])) -(def: (compiler [definition parameters]) +(def (compiler [definition parameters]) (Format Compiler) (` [(~ (code.symbol definition)) (~+ (list#each code.text parameters))])) -(def: .public lux_compiler_label +(def .public lux_compiler_label "lux") -(def: (profile value) +(def (profile value) (Format /.Profile) (`` (|> ..empty (..on_list "parents" (the /.#parents value) code.text) @@ -184,7 +184,7 @@ [/.#ruby])) ..aggregate))) -(def: .public project +(def .public project (Format Project) (|>> dictionary.entries (list#each (function (_ [key value]) diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux index 7a2668bc7..5d5890c3a 100644 --- a/stdlib/source/program/aedifex/hash.lux +++ b/stdlib/source/program/aedifex/hash.lux @@ -40,12 +40,12 @@ (primitive .public (Hash h) Binary - (def: .public data + (def .public data (All (_ h) (-> (Hash h) Binary)) (|>> representation)) (with_template [<name> <kind> <algorithm>] - [(def: .public (<name> value) + [(def .public (<name> value) (-> Binary (Hash <kind>)) (|> (java/security/MessageDigest::getInstance [(ffi.as_string <algorithm>)]) (java/security/MessageDigest::digest [value]) @@ -55,7 +55,7 @@ [md5 ..MD5 "MD5"] ) - (def: encoded + (def encoded (Format Binary) (binary.mix (function (_ byte representation) (let [hex (at n.hex encoded byte) @@ -66,7 +66,7 @@ "")) (with_template [<factor> <name>] - [(def: <name> + [(def <name> Nat <factor>)] @@ -74,10 +74,10 @@ [16 md5::size] ) - (def: hex_per_byte + (def hex_per_byte 2) - (def: hex_per_chunk + (def hex_per_chunk (n.* hex_per_byte i64.bytes_per_i64)) (exception: .public (not_a_hash [size Nat @@ -99,7 +99,7 @@ ) (with_template [<name> <kind> <size> <exception>] - [(def: .public (<name> data) + [(def .public (<name> data) (-> Binary (Try (Hash <kind>))) (if (n.= <size> (binary.size data)) {try.#Success (abstraction data)} @@ -109,15 +109,15 @@ [as_md5 MD5 ..md5::size ..not_a_md5] ) - (def: hash_size + (def hash_size (-> Text Nat) (|>> text.size (n./ ..hex_per_byte))) - (def: encoding_size + (def encoding_size (-> Nat Nat) (n.* ..hex_per_byte)) - (def: (decoded size constructor encoded) + (def (decoded size constructor encoded) (All (_ h) (-> Nat (-> Binary (Try (Hash h))) (-> Text (Try (Hash h))))) @@ -150,20 +150,20 @@ (exception.except ..not_a_hash [(..encoding_size size) encoded])))) (with_template [<codec> <hash> <nat> <constructor>] - [(def: .public <codec> + [(def .public <codec> (Codec Text (Hash <hash>)) (implementation - (def: encoded (|>> representation ..encoded)) - (def: decoded (..decoded <nat> <constructor>))))] + (def encoded (|>> representation ..encoded)) + (def decoded (..decoded <nat> <constructor>))))] [sha-1_codec SHA-1 ..sha-1::size ..as_sha-1] [md5_codec MD5 ..md5::size ..as_md5] ) - (def: .public equivalence + (def .public equivalence (All (_ h) (Equivalence (Hash h))) (implementation - (def: (= reference subject) + (def (= reference subject) (at binary.equivalence = (representation reference) (representation subject))))) diff --git a/stdlib/source/program/aedifex/input.lux b/stdlib/source/program/aedifex/input.lux index 13d7159ba..99dc93542 100644 --- a/stdlib/source/program/aedifex/input.lux +++ b/stdlib/source/program/aedifex/input.lux @@ -30,7 +30,7 @@ ["[1][0]" project (.only Project)] ["[1][0]" parser]]) -(def: (lux_parser source_code) +(def (lux_parser source_code) (-> Text (Try Code)) (let [parse (syntax.parse "" syntax.no_aliases @@ -42,14 +42,14 @@ {.#Right [_ lux_code]} {try.#Success lux_code}))) -(def: project_parser +(def project_parser (-> Binary (Try Project)) (|>> (pipe.do try.monad [(at utf8.codec decoded)] [..lux_parser] [(list) (<code>.result //parser.project)]))) -(def: .public (read monad fs profiles) +(def .public (read monad fs profiles) (All (_ !) (-> (Monad !) (file.System !) (List Name) (! (Try Profile)))) (|> //project.file (at fs read) diff --git a/stdlib/source/program/aedifex/local.lux b/stdlib/source/program/aedifex/local.lux index 8a4aa3b1e..a6236a469 100644 --- a/stdlib/source/program/aedifex/local.lux +++ b/stdlib/source/program/aedifex/local.lux @@ -10,12 +10,12 @@ ["[0]" // ["[1][0]" artifact (.only Version Artifact)]]) -(def: / uri.separator) +(def / uri.separator) -(def: .public repository +(def .public repository URI (format ".m2" / "repository")) -(def: .public (uri version artifact) +(def .public (uri version artifact) (-> Version Artifact URI) (format ..repository / (//artifact.uri version artifact))) diff --git a/stdlib/source/program/aedifex/metadata.lux b/stdlib/source/program/aedifex/metadata.lux index 36e287325..3ba470501 100644 --- a/stdlib/source/program/aedifex/metadata.lux +++ b/stdlib/source/program/aedifex/metadata.lux @@ -11,11 +11,11 @@ ["[0]" // ["[1][0]" artifact (.only Artifact)]]) -(def: remote_file +(def remote_file Path "maven-metadata.xml") -(def: .public (remote_artifact_uri artifact) +(def .public (remote_artifact_uri artifact) (-> Artifact URI) (let [/ uri.separator] (format (//artifact.directory / (the //artifact.#group artifact)) @@ -23,21 +23,21 @@ / (the //artifact.#version artifact) / ..remote_file))) -(def: .public (remote_project_uri artifact) +(def .public (remote_project_uri artifact) (-> Artifact URI) (let [/ uri.separator] (format (//artifact.directory / (the //artifact.#group artifact)) / (the //artifact.#name artifact) / ..remote_file))) -(def: local_file +(def local_file Path "maven-metadata-local.xml") -(def: .public (local_uri remote_uri) +(def .public (local_uri remote_uri) (-> URI URI) (text.replaced_once ..remote_file ..local_file remote_uri)) -(def: .public (remote_uri local_uri) +(def .public (remote_uri local_uri) (-> URI URI) (text.replaced_once ..local_file ..remote_file local_uri)) diff --git a/stdlib/source/program/aedifex/metadata/artifact.lux b/stdlib/source/program/aedifex/metadata/artifact.lux index 0057ce119..01271437e 100644 --- a/stdlib/source/program/aedifex/metadata/artifact.lux +++ b/stdlib/source/program/aedifex/metadata/artifact.lux @@ -45,32 +45,32 @@ #versions (List Version) #last_updated Instant])) -(def: (pad value) +(def (pad value) (-> Nat Text) (if (n.< 10 value) (%.format "0" (%.nat value)) (%.nat value))) -(def: (date_format value) +(def (date_format value) (%.Format Date) (%.format (|> value date.year year.value .nat %.nat) (|> value date.month month.number ..pad) (|> value date.day_of_month ..pad))) -(def: (time_format value) +(def (time_format value) (%.Format Time) (let [(open "[0]") (time.clock value)] (%.format (..pad #hour) (..pad #minute) (..pad #second)))) -(def: (instant_format value) +(def (instant_format value) (%.Format Instant) (%.format (..date_format (instant.date value)) (..time_format (instant.time value)))) (with_template [<definition> <tag>] - [(def: <definition> xml.Tag ["" <tag>])] + [(def <definition> xml.Tag ["" <tag>])] [<group> "groupId"] [<name> "artifactId"] @@ -82,7 +82,7 @@ ) (with_template [<name> <type> <tag> <pre>] - [(def: <name> + [(def <name> (-> <type> XML) (|>> <pre> {xml.#Text} list {xml.#Node <tag> xml.attributes}))] @@ -92,11 +92,11 @@ [last_updated_format Instant ..<last_updated> ..instant_format] ) -(def: versions_format +(def versions_format (-> (List Version) XML) (|>> (list#each ..version_format) {xml.#Node ..<versions> xml.attributes})) -(def: .public (format value) +(def .public (format value) (-> Metadata XML) {xml.#Node ..<metadata> xml.attributes @@ -107,12 +107,12 @@ (list (..versions_format (the #versions value)) (..last_updated_format (the #last_updated value)))})}) -(def: (text tag) +(def (text tag) (-> xml.Tag (Parser Text)) (<| (<xml>.node tag) <xml>.text)) -(def: date_parser +(def date_parser (<text>.Parser Date) (do <>.monad [year (<>.codec n.decimal (<text>.exactly 4 <text>.decimal)) @@ -122,7 +122,7 @@ day_of_month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))] (<>.lifted (date.date year month day_of_month)))) -(def: time_parser +(def time_parser (<text>.Parser Time) (do <>.monad [hour (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) @@ -134,7 +134,7 @@ time.#second second time.#milli_second 0])))) -(def: last_updated_parser +(def last_updated_parser (Parser Instant) (<text>.then (do <>.monad [date ..date_parser @@ -142,7 +142,7 @@ (in (instant.of_date_time date time))) (..text ..<last_updated>))) -(def: .public parser +(def .public parser (Parser Metadata) (<| (<xml>.node ..<metadata>) (all <>.and @@ -158,7 +158,7 @@ (<xml>.somewhere ..last_updated_parser) ))))) -(def: .public equivalence +(def .public equivalence (Equivalence Metadata) (all product.equivalence text.equivalence @@ -167,15 +167,15 @@ instant.equivalence )) -(def: .public uri +(def .public uri (-> Artifact URI) //.remote_project_uri) -(def: epoch +(def epoch Instant (instant.of_millis +0)) -(def: .public (read repository artifact) +(def .public (read repository artifact) (-> (Repository Async) Artifact (Async (Try Metadata))) (do async.monad [project (at repository download (..uri artifact))] @@ -195,7 +195,7 @@ ..#versions (list) ..#last_updated ..epoch])})))) -(def: .public (write repository artifact metadata) +(def .public (write repository artifact metadata) (-> (Repository Async) Artifact Metadata (Async (Try Any))) (|> metadata ..format diff --git a/stdlib/source/program/aedifex/metadata/snapshot.lux b/stdlib/source/program/aedifex/metadata/snapshot.lux index 7645b556b..4479fe244 100644 --- a/stdlib/source/program/aedifex/metadata/snapshot.lux +++ b/stdlib/source/program/aedifex/metadata/snapshot.lux @@ -51,7 +51,7 @@ #versioning Versioning])) (with_template [<definition> <tag>] - [(def: <definition> xml.Tag ["" <tag>])] + [(def <definition> xml.Tag ["" <tag>])] [<group> "groupId"] [<name> "artifactId"] @@ -60,7 +60,7 @@ ) (with_template [<name> <type> <tag> <pre>] - [(def: <name> + [(def <name> (-> <type> XML) (|>> <pre> {xml.#Text} list {xml.#Node <tag> xml.attributes}))] @@ -69,7 +69,7 @@ [version_format Version ..<version> (|>)] ) -(def: .public (format (open "/[0]")) +(def .public (format (open "/[0]")) (-> Metadata XML) (let [(open "//[0]") /#artifact] {xml.#Node ..<metadata> @@ -79,12 +79,12 @@ (..version_format //#version) (///artifact/versioning.format /#versioning))})) -(def: (text tag) +(def (text tag) (-> xml.Tag (Parser Text)) (<| (<xml>.node tag) <xml>.text)) -(def: .public parser +(def .public parser (Parser Metadata) (<| (<xml>.node ..<metadata>) (do [! <>.monad] @@ -113,18 +113,18 @@ ///artifact.#version version] #versioning versioning])))) -(def: .public equivalence +(def .public equivalence (Equivalence Metadata) (all product.equivalence ///artifact.equivalence ///artifact/versioning.equivalence )) -(def: .public uri +(def .public uri (-> Artifact URI) //.remote_artifact_uri) -(def: .public (read repository artifact) +(def .public (read repository artifact) (-> (Repository Async) Artifact (Async (Try Metadata))) (do async.monad [project (at repository download (..uri artifact))] @@ -141,7 +141,7 @@ [#artifact artifact #versioning ///artifact/versioning.init]})))) -(def: .public (write repository artifact metadata) +(def .public (write repository artifact metadata) (-> (Repository Async) Artifact Metadata (Async (Try Any))) (|> metadata ..format diff --git a/stdlib/source/program/aedifex/package.lux b/stdlib/source/program/aedifex/package.lux index 3dc430c9c..258a80c2f 100644 --- a/stdlib/source/program/aedifex/package.lux +++ b/stdlib/source/program/aedifex/package.lux @@ -35,7 +35,7 @@ #pom [XML Binary Status]])) (with_template [<name> <tag>] - [(def: .public (<name> package) + [(def .public (<name> package) (-> Package Bit) (case (the #origin package) {<tag> _} @@ -48,7 +48,7 @@ [remote? //origin.#Remote] ) -(def: .public (local pom library) +(def .public (local pom library) (-> XML Binary Package) [#origin {//origin.#Local ""} #library [library @@ -60,7 +60,7 @@ {//status.#Verified (//hash.sha-1 binary_pom) (//hash.md5 binary_pom)}])]) -(def: .public dependencies +(def .public dependencies (-> Package (Try (Set Dependency))) (|>> (the #pom) product.left @@ -68,7 +68,7 @@ (<xml>.result //pom.parser) (try#each (the /.#dependencies)))) -(def: .public repositories +(def .public repositories (-> Package (Try (Set Address))) (|>> (the #pom) product.left @@ -76,7 +76,7 @@ (<xml>.result //pom.parser) (try#each (the /.#repositories)))) -(def: .public equivalence +(def .public equivalence (Equivalence Package) (all product.equivalence //origin.equivalence diff --git a/stdlib/source/program/aedifex/parser.lux b/stdlib/source/program/aedifex/parser.lux index 7fa14fb60..435e0fb79 100644 --- a/stdlib/source/program/aedifex/parser.lux +++ b/stdlib/source/program/aedifex/parser.lux @@ -34,49 +34,49 @@ ["[1][0]" artifact (.only Artifact) ["[1]/[0]" type]]]) -(def: (singular input tag parser) +(def (singular input tag parser) (All (_ a) (-> (Dictionary Text Code) Text (Parser a) (Parser a))) (<code>.locally (maybe.list (dictionary.value tag input)) parser)) -(def: (plural input tag parser) +(def (plural input tag parser) (All (_ a) (-> (Dictionary Text Code) Text (Parser a) (Parser (List a)))) (<code>.locally (maybe.list (dictionary.value tag input)) (<code>.tuple (<>.some parser)))) -(def: group +(def group (Parser //artifact.Group) <code>.text) -(def: name +(def name (Parser //artifact.Name) <code>.text) -(def: version +(def version (Parser //artifact.Version) <code>.text) -(def: artifact' +(def artifact' (Parser //artifact.Artifact) (all <>.and ..group ..name ..version)) -(def: artifact +(def artifact (Parser //artifact.Artifact) (<code>.tuple ..artifact')) -(def: url +(def url (Parser URL) <code>.text) -(def: scm +(def scm (Parser /.SCM) ..url) -(def: description +(def description (Parser Text) <code>.text) -(def: license +(def license (Parser /.License) (do [! <>.monad] [input (at ! each @@ -91,7 +91,7 @@ (<>.or (<code>.this (' "repo")) (<code>.this (' "manual")))))))) -(def: organization +(def organization (Parser /.Organization) (do [! <>.monad] [input (at ! each @@ -102,7 +102,7 @@ (..singular input "name" ..name) (..singular input "url" ..url)))) -(def: developer +(def developer (Parser /.Developer) (do [! <>.monad] [input (at ! each @@ -115,11 +115,11 @@ (<>.maybe (..singular input "organization" ..organization)) ))) -(def: contributor +(def contributor (Parser /.Contributor) ..developer) -(def: info +(def info (Parser /.Info) (do [! <>.monad] [input (at ! each @@ -137,15 +137,15 @@ (<>.else (list) (..plural input "contributors" ..contributor)) ))) -(def: repository +(def repository (Parser //repository.Address) ..url) -(def: type +(def type (Parser //artifact/type.Type) <code>.text) -(def: dependency +(def dependency (Parser //dependency.Dependency) (<code>.tuple (all <>.and @@ -153,7 +153,7 @@ (<>.else //artifact/type.lux_library ..type) ))) -(def: compiler +(def compiler (Parser Compiler) (<code>.tuple (all <>.and @@ -161,29 +161,29 @@ (<>.some <code>.text) ))) -(def: source +(def source (Parser /.Source) <code>.text) -(def: target +(def target (Parser /.Target) <code>.text) -(def: module +(def module (Parser Module) <code>.text) -(def: deploy_repository +(def deploy_repository (Parser [Text //repository.Address]) (<>.and <code>.text ..repository)) -(def: configuration/1 +(def configuration/1 (Parser [Text Text]) (<>.and <code>.text <code>.text)) -(def: runtime +(def runtime (Parser Runtime) (let [environment (<>#each (dictionary.of_list text.hash) (<>.some (<code>.tuple (<>.and <code>.text <code>.text))))] @@ -193,7 +193,7 @@ <code>.text (<>.some <code>.text))))) -(def: profile +(def profile (Parser /.Profile) (do [! <>.monad] [input (at ! each @@ -281,7 +281,7 @@ ^ruby ))) -(def: .public project +(def .public project (Parser Project) (at <>.monad each (dictionary.of_list text.hash) diff --git a/stdlib/source/program/aedifex/pom.lux b/stdlib/source/program/aedifex/pom.lux index 3c966930a..0f5d3b50e 100644 --- a/stdlib/source/program/aedifex/pom.lux +++ b/stdlib/source/program/aedifex/pom.lux @@ -32,93 +32,93 @@ ... https://maven.apache.org/pom.html -(def: project_tag "project") -(def: dependency_tag "dependency") -(def: dependencies_tag "dependencies") -(def: repositories_tag "repositories") -(def: repository_tag "repository") -(def: url_tag "url") -(def: group_tag "groupId") -(def: artifact_tag "artifactId") -(def: version_tag "version") - -(def: .public file +(def project_tag "project") +(def dependency_tag "dependency") +(def dependencies_tag "dependencies") +(def repositories_tag "repositories") +(def repository_tag "repository") +(def url_tag "url") +(def group_tag "groupId") +(def artifact_tag "artifactId") +(def version_tag "version") + +(def .public file file.Path "pom.xml") -(def: version +(def version XML {_.#Node ["" "modelVersion"] _.attributes (list {_.#Text "4.0.0"})}) -(def: (property tag value) +(def (property tag value) (-> Text Text XML) {_.#Node ["" tag] _.attributes (list {_.#Text value})}) -(def: (artifact value) +(def (artifact value) (-> Artifact (List XML)) (list (..property ..group_tag (the //artifact.#group value)) (..property ..artifact_tag (the //artifact.#name value)) (..property ..version_tag (the //artifact.#version value)))) -(def: distribution +(def distribution (-> /.Distribution XML) (|>> (pipe.case {/.#Repo} "repo" {/.#Manual} "manual") (..property "distribution"))) -(def: (license [name url distribution]) +(def (license [name url distribution]) (-> /.License XML) (|> (list (..property "name" name) (..property ..url_tag url) (..distribution distribution)) {_.#Node ["" "license"] _.attributes})) -(def: repository +(def repository (-> Address XML) (|>> (..property ..url_tag) list {_.#Node ["" ..repository_tag] _.attributes})) -(def: (dependency value) +(def (dependency value) (-> Dependency XML) {_.#Node ["" ..dependency_tag] _.attributes (list#composite (..artifact (the //dependency.#artifact value)) (list (..property "type" (the //dependency.#type value))))}) -(def: (group tag) +(def (group tag) (-> Text (-> (List XML) XML)) (|>> {_.#Node ["" tag] _.attributes})) -(def: scm +(def scm (-> /.SCM XML) (|>> (..property ..url_tag) list {_.#Node ["" "scm"] _.attributes})) -(def: (organization [name url]) +(def (organization [name url]) (-> /.Organization XML) (|> (list (..property "name" name) (..property ..url_tag url)) {_.#Node ["" "organization"] _.attributes})) -(def: (developer_organization [name url]) +(def (developer_organization [name url]) (-> /.Organization (List XML)) (list (..property "organization" name) (..property "organizationUrl" url))) -(def: (developer' [name email organization]) +(def (developer' [name email organization]) (-> /.Developer (List XML)) (list.partial (..property "name" name) (..property "email" email) (|> organization (maybe#each ..developer_organization) (maybe.else (list))))) (with_template [<name> <type> <tag>] - [(def: <name> + [(def <name> (-> <type> XML) (|>> ..developer' {_.#Node ["" <tag>] _.attributes}))] @@ -126,7 +126,7 @@ [contributor /.Contributor "contributor"] ) -(def: (info value) +(def (info value) (-> /.Info (List XML)) (all list#composite (|> value (the /.#name) (maybe#each (..property "name")) maybe.list) @@ -139,7 +139,7 @@ (|> value (the /.#contributors) (list#each ..contributor) (..group "contributors") list) )) -(def: .public (write value) +(def .public (write value) (-> /.Profile (Try XML)) (case (the /.#identity value) {.#Some identity} @@ -159,7 +159,7 @@ _ (exception.except /.no_identity []))) -(def: property_parser +(def property_parser (Parser [Tag Text]) (do [! <>.monad] [tag <xml>.tag] @@ -167,7 +167,7 @@ (at ! each (|>> [tag])) <xml>.text))) -(def: (dependency_parser own_version parent_version) +(def (dependency_parser own_version parent_version) (-> Text Text (Parser Dependency)) (do [! <>.monad] [properties (at ! each (dictionary.of_list symbol.hash) @@ -189,33 +189,33 @@ (dictionary.value ["" "type"]) (maybe.else //artifact/type.jvm_library))]))))) -(def: (dependencies_parser own_version parent_version) +(def (dependencies_parser own_version parent_version) (-> Text Text (Parser (List Dependency))) (<| (<xml>.node ["" ..dependencies_tag]) (<>.some (..dependency_parser own_version parent_version)))) -(def: repository_parser +(def repository_parser (Parser Address) (<| (<xml>.node ["" ..repository_tag]) (<xml>.node ["" ..url_tag]) <xml>.text)) -(def: repositories_parser +(def repositories_parser (Parser (List Address)) (<| (<xml>.node ["" ..repositories_tag]) (<>.some ..repository_parser))) -(def: own_version +(def own_version (Parser Text) (<| (<xml>.node ["" ..version_tag]) <xml>.text)) -(def: parent_version +(def parent_version (Parser Text) (<| (<xml>.node ["" "parent"]) ..own_version)) -(def: .public parser +(def .public parser (Parser /.Profile) (do [! <>.monad] [own_version (<>.else "" (<xml>.somewhere ..own_version)) diff --git a/stdlib/source/program/aedifex/profile.lux b/stdlib/source/program/aedifex/profile.lux index 90e5f3d8d..5758a3795 100644 --- a/stdlib/source/program/aedifex/profile.lux +++ b/stdlib/source/program/aedifex/profile.lux @@ -39,7 +39,7 @@ [repository [remote (.only Address)]]]) -(def: .public default_lux +(def .public default_lux Dependency [dependency.#artifact ["com.github.luxlang" "lux-jvm" "0.6.5"] dependency.#type type.jvm_library]) @@ -49,10 +49,10 @@ {#Repo} {#Manual})) -(def: distribution_equivalence +(def distribution_equivalence (Equivalence Distribution) (implementation - (def: (= reference subject) + (def (= reference subject) (case [reference subject] (^.with_template [<tag>] [[{<tag>} {<tag>}] @@ -68,7 +68,7 @@ URL Distribution]) -(def: license_equivalence +(def license_equivalence (Equivalence License) (all product.equivalence text.equivalence @@ -82,7 +82,7 @@ [Text URL]) -(def: organization_equivalence +(def organization_equivalence (Equivalence Organization) (all product.equivalence text.equivalence @@ -96,7 +96,7 @@ Email (Maybe Organization)]) -(def: developer_equivalence +(def developer_equivalence (Equivalence Developer) (all product.equivalence text.equivalence @@ -117,7 +117,7 @@ #developers (List Developer) #contributors (List Contributor)])) -(def: info_equivalence +(def info_equivalence (Equivalence Info) (all product.equivalence (maybe.equivalence text.equivalence) @@ -129,7 +129,7 @@ (list.equivalence ..developer_equivalence) (list.equivalence ..developer_equivalence))) -(def: .public default_info +(def .public default_info Info [#name {.#None} #url {.#None} @@ -143,25 +143,25 @@ (type: .public Source Path) -(def: .public default_source +(def .public default_source Source "source") (type: .public Target Path) -(def: .public default_target +(def .public default_target Target "target") -(def: .public default_repository +(def .public default_repository Address "https://repo1.maven.org/maven2/") (type: .public Name Text) -(def: .public default +(def .public default Name "") @@ -186,7 +186,7 @@ #lua Runtime #ruby Runtime])) -(def: .public equivalence +(def .public equivalence (Equivalence Profile) (all product.equivalence ... #parents @@ -226,10 +226,10 @@ ... #ruby runtime.equivalence)) -(def: .public monoid +(def .public monoid (Monoid Profile) (implementation - (def: identity + (def identity [#parents (list) #identity {.#None} #info {.#None} @@ -249,7 +249,7 @@ #lua runtime.default_lua #ruby runtime.default_ruby]) - (def: (composite override baseline) + (def (composite override baseline) (template.let [(!runtime <tag> <runtime>) [(if (runtime#= <runtime> (the <tag> override)) (the <tag> baseline) diff --git a/stdlib/source/program/aedifex/project.lux b/stdlib/source/program/aedifex/project.lux index 868fb7691..0d1fb6559 100644 --- a/stdlib/source/program/aedifex/project.lux +++ b/stdlib/source/program/aedifex/project.lux @@ -18,27 +18,27 @@ ["[0]" // ["[1]" profile (.only Name Profile)]]) -(def: .public file +(def .public file "project.lux") (type: .public Project (Dictionary Name Profile)) -(def: .public (project name profile) +(def .public (project name profile) (-> Name Profile Project) (dictionary.of_list text.hash (list [name profile]))) -(def: .public equivalence +(def .public equivalence (Equivalence Project) (dictionary.equivalence //.equivalence)) -(def: .public monoid +(def .public monoid (Monoid Project) (implementation - (def: identity + (def identity (dictionary.empty text.hash)) - (def: composite + (def composite (dictionary.composite_with (at //.monoid composite))))) (exception: .public (unknown_profile [name Name]) @@ -51,7 +51,7 @@ "Dependent" (%.text dependent) "Dependee" (%.text dependee))) -(def: (profile' lineage project name) +(def (profile' lineage project name) (-> (Set Name) Project Name (Try Profile)) (case (dictionary.value name project) {.#Some profile} @@ -72,6 +72,6 @@ {.#None} (exception.except ..unknown_profile [name]))) -(def: .public profile +(def .public profile (-> Project Name (Try Profile)) (..profile' (set.empty text.hash))) diff --git a/stdlib/source/program/aedifex/repository.lux b/stdlib/source/program/aedifex/repository.lux index 395eefc20..2b092ad41 100644 --- a/stdlib/source/program/aedifex/repository.lux +++ b/stdlib/source/program/aedifex/repository.lux @@ -24,15 +24,15 @@ (is (-> URI Binary (! (Try Any))) upload))) -(def: .public (async repository) +(def .public (async repository) (-> (Repository IO) (Repository Async)) (implementation - (def: description + (def description (at repository description)) - (def: (download uri) + (def (download uri) (async.future (at repository download uri))) - (def: (upload uri content) + (def (upload uri content) (async.future (at repository upload uri content))) )) @@ -45,14 +45,14 @@ (is (-> URI Binary s (Try s)) on_upload))) -(def: .public (mock mock init) +(def .public (mock mock init) (All (_ s) (-> (Mock s) s (Repository Async))) (let [state (stm.var init)] (implementation - (def: description + (def description (at mock the_description)) - (def: (download uri) + (def (download uri) (stm.commit! (do [! stm.monad] [|state| (stm.read state)] @@ -65,7 +65,7 @@ {try.#Failure error} (in {try.#Failure error}))))) - (def: (upload uri content) + (def (upload uri content) (stm.commit! (do [! stm.monad] [|state| (stm.read state)] diff --git a/stdlib/source/program/aedifex/repository/identity.lux b/stdlib/source/program/aedifex/repository/identity.lux index d6b14b12b..634423e7c 100644 --- a/stdlib/source/program/aedifex/repository/identity.lux +++ b/stdlib/source/program/aedifex/repository/identity.lux @@ -22,7 +22,7 @@ [#user User #password Password])) -(def: .public equivalence +(def .public equivalence (Equivalence Identity) (all product.equivalence text.equivalence @@ -37,7 +37,7 @@ "[1]::[0]" ("static" getEncoder [] java/util/Base64$Encoder)) -(def: .public (basic_auth user password) +(def .public (basic_auth user password) (-> User Password Text) (let [credentials (at utf8.codec encoded (format user ":" password))] (|> (java/util/Base64::getEncoder) diff --git a/stdlib/source/program/aedifex/repository/local.lux b/stdlib/source/program/aedifex/repository/local.lux index 1a7fb0ffd..b491e6d12 100644 --- a/stdlib/source/program/aedifex/repository/local.lux +++ b/stdlib/source/program/aedifex/repository/local.lux @@ -20,35 +20,35 @@ ["[1][0]" local] ["[1][0]" metadata]]]) -(def: .public (root program fs) +(def .public (root program fs) (-> (Program Async) (file.System Async) file.Path) (let [/ (at fs separator)] (|> ///local.repository (text.replaced uri.separator /) (format (at program home) /)))) -(def: (path /) +(def (path /) (-> Text (-> URI file.Path)) (text.replaced uri.separator /)) -(def: (absolute_path program fs) +(def (absolute_path program fs) (-> (Program Async) (file.System Async) (-> URI file.Path)) (let [/ (at fs separator)] (|>> ///metadata.local_uri (..path /) (format (..root program fs) /)))) -(def: .public (repository program fs) +(def .public (repository program fs) (-> (Program Async) (file.System Async) (//.Repository Async)) (implementation - (def: description + (def description (..root program fs)) - (def: download + (def download (|>> (..absolute_path program fs) (at fs read))) - (def: (upload uri content) + (def (upload uri content) (do [! async.monad] [.let [absolute_path (..absolute_path program fs uri)] ? (at fs file? absolute_path) diff --git a/stdlib/source/program/aedifex/repository/origin.lux b/stdlib/source/program/aedifex/repository/origin.lux index c69337877..b8556c4c4 100644 --- a/stdlib/source/program/aedifex/repository/origin.lux +++ b/stdlib/source/program/aedifex/repository/origin.lux @@ -15,7 +15,7 @@ {#Local Path} {#Remote URL})) -(def: .public equivalence +(def .public equivalence (Equivalence Origin) (all sum.equivalence text.equivalence diff --git a/stdlib/source/program/aedifex/repository/remote.lux b/stdlib/source/program/aedifex/repository/remote.lux index cbe1ffd8e..d91047f7c 100644 --- a/stdlib/source/program/aedifex/repository/remote.lux +++ b/stdlib/source/program/aedifex/repository/remote.lux @@ -45,23 +45,23 @@ [upload_failure] ) -(def: .public (uri version_template artifact extension) +(def .public (uri version_template artifact extension) (-> Version Artifact Extension URI) (format (///artifact.uri version_template artifact) extension)) -(def: .public user_agent +(def .public user_agent (format "LuxAedifex/" (version.format meta/version.latest))) -(def: base_headers +(def base_headers (List [Text Text]) (list ["User-Agent" ..user_agent])) -(def: .public (repository http identity address) +(def .public (repository http identity address) (All (_ s) (-> (http.Client IO) (Maybe Identity) Address (//.Repository IO))) (implementation - (def: description + (def description address) - (def: (download uri) + (def (download uri) (do [! (try.with io.monad)] [[status message] (is (IO (Try (@http.Response IO))) (http.get (format address uri) @@ -77,7 +77,7 @@ [_ ((the @http.#body message) {.#Some 0})] (at io.monad in (exception.except ..download_failure [(format address uri) status])))))) - (def: (upload uri content) + (def (upload uri content) (do (try.with io.monad) [[status message] (is (IO (Try (@http.Response IO))) (http.put (format address uri) diff --git a/stdlib/source/program/aedifex/runtime.lux b/stdlib/source/program/aedifex/runtime.lux index 47bcfbb43..401a9fa7c 100644 --- a/stdlib/source/program/aedifex/runtime.lux +++ b/stdlib/source/program/aedifex/runtime.lux @@ -21,7 +21,7 @@ #program Text #parameters (List Text)])) -(def: .public equivalence +(def .public equivalence (Equivalence Runtime) (all product.equivalence (dictionary.equivalence text.equivalence) @@ -30,7 +30,7 @@ )) (with_template [<name> <command> <environment> <parameters>] - [(def: .public <name> + [(def .public <name> Runtime [#environment (dictionary.of_list text.hash (`` (list (~~ (template.spliced <environment>))))) #program <command> @@ -44,7 +44,7 @@ [default_ruby "ruby" [["RUBY_THREAD_VM_STACK_SIZE" "8388608"]] []] ) -(def: .public (for runtime path) +(def .public (for runtime path) (-> Runtime file.Path Runtime) (revised #parameters (function (_ parameters) diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index 5e71b0741..c29ef5160 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -57,7 +57,7 @@ ... ["[0]" interpreter] ]]]) -(def: (or_crash! failure_description action) +(def (or_crash! failure_description action) (All (_ a) (-> Text (Async (Try a)) (Async a))) (do [! async.monad] @@ -83,7 +83,7 @@ {try.#Success output} (in output)))) -(def: (timed process) +(def (timed process) (All (_ a) (-> (Async (Try a)) (Async (Try a)))) (do async.monad @@ -95,7 +95,7 @@ (format "Duration: ")))]] (in output))) -(def: (package! fs host_dependencies [packager package] archive context) +(def (package! fs host_dependencies [packager package] archive context) (-> (file.System Async) (Dictionary file.Path Binary) [Packager file.Path] Archive (Maybe unit.ID) (Async (Try Any))) (case (packager host_dependencies archive context) {try.#Success content} @@ -114,7 +114,7 @@ {try.#Failure error} (at async.monad in {try.#Failure error}))) -(def: (load_host_dependencies fs host_dependencies) +(def (load_host_dependencies fs host_dependencies) (-> (file.System Async) (List file.Path) (Async (Try (Dictionary file.Path Binary)))) (do [! (try.with async.monad)] [] @@ -132,7 +132,7 @@ (dictionary.has head content output))))))) (with_expansions [<parameters> (these anchor expression artifact)] - (def: .public (compiler lux_compiler file_context + (def .public (compiler lux_compiler file_context expander host_analysis platform generation_bundle host_directive_bundle program anchorT,expressionT,directiveT extender service packager,package) diff --git a/stdlib/source/specification/aedifex/repository.lux b/stdlib/source/specification/aedifex/repository.lux index d71b95e75..777040e35 100644 --- a/stdlib/source/specification/aedifex/repository.lux +++ b/stdlib/source/specification/aedifex/repository.lux @@ -23,7 +23,7 @@ ["_[0]" // ["[1][0]" artifact]]]) -(def: .public (spec valid_artifact invalid_artifact subject) +(def .public (spec valid_artifact invalid_artifact subject) (-> Artifact Artifact (/.Repository Async) Test) (do random.monad [expected (_binary.random 100)] diff --git a/stdlib/source/specification/compositor.lux b/stdlib/source/specification/compositor.lux index 99d991c0f..ad95c3c6f 100644 --- a/stdlib/source/specification/compositor.lux +++ b/stdlib/source/specification/compositor.lux @@ -29,7 +29,7 @@ ["[1][0]" function] ["[1][0]" common]]]) -(def: (test runner definer state expander) +(def (test runner definer state expander) (-> Runner Definer analysis.State+ Expander Test) (all _.and (/analysis/type.spec expander state) @@ -41,7 +41,7 @@ (/generation/common.spec runner) )) -(def: .public (spec platform bundle expander program) +(def .public (spec platform bundle expander program) (All (_ anchor expression directive) (-> (IO (Platform IO anchor expression directive)) (Bundle anchor expression directive) diff --git a/stdlib/source/specification/compositor/analysis/type.lux b/stdlib/source/specification/compositor/analysis/type.lux index d1115fbfa..8aae58f13 100644 --- a/stdlib/source/specification/compositor/analysis/type.lux +++ b/stdlib/source/specification/compositor/analysis/type.lux @@ -20,7 +20,7 @@ ["[1]/[0]" scope] ["[1]/[0]" type]]]]]]) -(def: (check_success+ expander state extension params output_type) +(def (check_success+ expander state extension params output_type) (-> Expander State+ Text (List Code) Type Bit) (|> (analysis/scope.with_scope "" (analysis/type.with_type output_type @@ -33,7 +33,7 @@ {try.#Failure _} false))) -(def: check +(def check (Random [Code Type Code]) (`` (all r.either (~~ (with_template [<random> <type> <code>] @@ -51,7 +51,7 @@ [(r.upper_case_alpha 5) {0 #0 "#Text" {0 #0}} code.text] ))))) -(def: .public (spec expander state) +(def .public (spec expander state) (-> Expander State+ Test) (do r.monad [[typeC exprT exprC] ..check diff --git a/stdlib/source/specification/compositor/common.lux b/stdlib/source/specification/compositor/common.lux index 947131032..50383371b 100644 --- a/stdlib/source/specification/compositor/common.lux +++ b/stdlib/source/specification/compositor/common.lux @@ -31,7 +31,7 @@ (generation.State+ anchor expression directive) what))) -(def: (runner (open "[0]") state) +(def (runner (open "[0]") state) (Instancer Runner) (function (_ evaluation_name expressionS) (do try.monad @@ -42,7 +42,7 @@ (phase expressionS)))] (at host evaluate! evaluation_name expressionG)))) -(def: (definer (open "[0]") state) +(def (definer (open "[0]") state) (Instancer Definer) (function (_ lux_name expressionS) (do try.monad @@ -56,7 +56,7 @@ (phase (synthesis.constant lux_name))))] (at host evaluate! "definer" definitionG)))) -(def: .public (executors target expander platform +(def .public (executors target expander platform analysis_bundle generation_bundle directive_bundle program extender) (All (_ anchor expression directive) diff --git a/stdlib/source/specification/compositor/generation/case.lux b/stdlib/source/specification/compositor/generation/case.lux index c76cd5037..e1603a517 100644 --- a/stdlib/source/specification/compositor/generation/case.lux +++ b/stdlib/source/specification/compositor/generation/case.lux @@ -28,17 +28,17 @@ [/// [common (.only Runner)]]) -(def: limit Nat 10) +(def limit Nat 10) -(def: size +(def size (Random Nat) (|> r.nat (at r.monad each (|>> (n.% ..limit) (n.max 2))))) -(def: (tail? size idx) +(def (tail? size idx) (-> Nat Nat Bit) (n.= (-- size) idx)) -(def: .public (verify expected) +(def .public (verify expected) (-> Frac (Try Any) Bit) (|>> (pipe.case {try.#Success actual} @@ -47,7 +47,7 @@ {try.#Failure _} false))) -(def: case +(def case (Random [Synthesis Path]) (<| r.rec (function (_ case)) (`` (all r.either @@ -97,7 +97,7 @@ (in [caseS caseP])) )))) -(def: (let_spec run) +(def (let_spec run) (-> Runner Test) (do r.monad [value r.safe_frac] @@ -108,7 +108,7 @@ (run "let_spec") (verify value))))) -(def: (if_spec run) +(def (if_spec run) (-> Runner Test) (do r.monad [on_true r.safe_frac @@ -121,7 +121,7 @@ (run "if_spec") (verify (if verdict on_true on_false)))))) -(def: (case_spec run) +(def (case_spec run) (-> Runner Test) (do r.monad [[inputS pathS] ..case @@ -138,7 +138,7 @@ (run "case_spec") (verify on_success))))) -(def: special_input +(def special_input Synthesis (let [_cursor_ (is Synthesis (synthesis.tuple (list (synthesis.text .prelude) @@ -182,7 +182,7 @@ (_item_ (__tuple__ (list (__symbol__ ["" "tail"])))) )))) -(def: special_path +(def special_path Path (let [_end_ (synthesis.path/side {.#Left 0}) _item_ (synthesis.path/side {.#Right 0}) @@ -208,7 +208,7 @@ ... THEN (synthesis.path/then (synthesis.bit #0)))))) -(def: special_pattern +(def special_pattern analysis.Pattern (let [... [_ {#Tuple {#Item arg args'}}] head (<| analysis.pattern/tuple (list (analysis.pattern/bind 2)) @@ -225,7 +225,7 @@ (<| analysis.pattern/variant [0 #1] (analysis.pattern/tuple (list head tail))))) -(def: special_pattern_path +(def special_pattern_path Path (all synthesis.path/alt (<| try.trusted @@ -240,7 +240,7 @@ (synthesis.path/then (synthesis.bit #0))))) ... TODO: Get rid of this ASAP -(def: (special_spec run) +(def (special_spec run) (-> Runner Test) (all _.and (_.property "===" @@ -278,7 +278,7 @@ false))) )) -(def: .public (spec run) +(def .public (spec run) (-> Runner Test) (all _.and (..special_spec run) diff --git a/stdlib/source/specification/compositor/generation/common.lux b/stdlib/source/specification/compositor/generation/common.lux index 85ea2a496..fabd44907 100644 --- a/stdlib/source/specification/compositor/generation/common.lux +++ b/stdlib/source/specification/compositor/generation/common.lux @@ -30,11 +30,11 @@ [// [common (.only Runner)]]]) -(def: safe +(def safe (-> Text Text) (text.replaced " " "_")) -(def: (bit run) +(def (bit run) (-> Runner Test) (do r.monad [param r.i64 @@ -76,7 +76,7 @@ (let [param (n.% 64 param)]))) )))) -(def: (i64 run) +(def (i64 run) (-> Runner Test) (do r.monad [param (|> r.i64 (r.only (|>> ("lux i64 =" 0) not))) @@ -122,11 +122,11 @@ )) )))) -(def: simple_frac +(def simple_frac (Random Frac) (|> r.nat (at r.monad each (|>> (n.% 1000) .int i.frac)))) -(def: (f64 run) +(def (f64 run) (-> Runner Test) (do r.monad [param (|> ..simple_frac (r.only (|>> (f.= +0.0) not))) @@ -179,7 +179,7 @@ (//case.verify subject))) )))) -(def: (text run) +(def (text run) (-> Runner Test) (do [! r.monad] [sample_size (|> r.nat (at ! each (|>> (n.% 10) (n.max 1)))) @@ -300,7 +300,7 @@ false))) ))) -(def: (io run) +(def (io run) (-> Runner Test) (do r.monad [message (r.alphabetic 5)] @@ -358,7 +358,7 @@ false))) ))) -(def: .public (spec runner) +(def .public (spec runner) (-> Runner Test) (all _.and (..bit runner) diff --git a/stdlib/source/specification/compositor/generation/function.lux b/stdlib/source/specification/compositor/generation/function.lux index 86c495c3b..a7cb2de43 100644 --- a/stdlib/source/specification/compositor/generation/function.lux +++ b/stdlib/source/specification/compositor/generation/function.lux @@ -23,19 +23,19 @@ [// [common (.only Runner)]]]) -(def: max_arity +(def max_arity Arity 10) -(def: arity +(def arity (Random Arity) (|> r.nat (r#each (|>> (n.% max_arity) (n.max 1))))) -(def: (local arity) +(def (local arity) (-> Arity (Random Register)) (|> r.nat (r#each (|>> (n.% arity) ++)))) -(def: function +(def function (Random [Arity Register Synthesis]) (do r.monad [arity ..arity @@ -46,7 +46,7 @@ synthesis.#arity arity synthesis.#body (synthesis.variable/local local)])]))) -(def: .public (spec run) +(def .public (spec run) (-> Runner Test) (do [! r.monad] [[arity local functionS] ..function diff --git a/stdlib/source/specification/compositor/generation/primitive.lux b/stdlib/source/specification/compositor/generation/primitive.lux index 540fc289b..f927d5dd2 100644 --- a/stdlib/source/specification/compositor/generation/primitive.lux +++ b/stdlib/source/specification/compositor/generation/primitive.lux @@ -20,13 +20,13 @@ [/// [common (.only Runner)]]) -(def: (f/=' reference subject) +(def (f/=' reference subject) (-> Frac Frac Bit) (or (f.= reference subject) (and (f.not_a_number? reference) (f.not_a_number? subject)))) -(def: .public (spec run) +(def .public (spec run) (-> Runner Test) (`` (all _.and (~~ (with_template [<evaluation_name> <synthesis> <gen> <test>] diff --git a/stdlib/source/specification/compositor/generation/reference.lux b/stdlib/source/specification/compositor/generation/reference.lux index f8f68c51e..c7ba5c2bf 100644 --- a/stdlib/source/specification/compositor/generation/reference.lux +++ b/stdlib/source/specification/compositor/generation/reference.lux @@ -19,12 +19,12 @@ [/// [common (.only Runner Definer)]]) -(def: symbol +(def symbol (Random Symbol) (let [symbol_part (r.upper_case_alpha 5)] [(r.and symbol_part symbol_part)])) -(def: (definition define) +(def (definition define) (-> Definer Test) (do r.monad [name ..symbol @@ -38,7 +38,7 @@ {try.#Failure _} false))))) -(def: (variable run) +(def (variable run) (-> Runner Test) (do [! r.monad] [register (|> r.nat (at ! each (n.% 100))) @@ -55,7 +55,7 @@ {try.#Failure _} false))))) -(def: .public (spec runner definer) +(def .public (spec runner definer) (-> Runner Definer Test) (all _.and (..definition definer) diff --git a/stdlib/source/specification/compositor/generation/structure.lux b/stdlib/source/specification/compositor/generation/structure.lux index 3d6b482ad..bfc6621b9 100644 --- a/stdlib/source/specification/compositor/generation/structure.lux +++ b/stdlib/source/specification/compositor/generation/structure.lux @@ -28,7 +28,7 @@ (import java/lang/Integer) -(def: (variant run) +(def (variant run) (-> Runner Test) (do [! r.monad] [num_tags (|> r.nat (at ! each (|>> (n.% 10) (n.max 2)))) @@ -64,7 +64,7 @@ {try.#Failure _} false))))) -(def: (tuple run) +(def (tuple run) (-> Runner Test) (do [! r.monad] [size (|> r.nat (at ! each (|>> (n.% 10) (n.max 2)))) @@ -83,7 +83,7 @@ {try.#Failure _} false))))) -(def: .public (spec runner) +(def .public (spec runner) (-> Runner Test) (all _.and (..variant runner) diff --git a/stdlib/source/specification/lux/abstract/apply.lux b/stdlib/source/specification/lux/abstract/apply.lux index 8d0fe390e..385cbfb2d 100644 --- a/stdlib/source/specification/lux/abstract/apply.lux +++ b/stdlib/source/specification/lux/abstract/apply.lux @@ -16,7 +16,7 @@ [// [functor (.only Injection Comparison)]]) -(def: (identity injection comparison (open "/#[0]")) +(def (identity injection comparison (open "/#[0]")) (All (_ f) (-> (Injection f) (Comparison f) (Apply f) Test)) (do [! random.monad] [sample (at ! each injection random.nat)] @@ -25,7 +25,7 @@ (/#on sample (injection function.identity)) sample)))) -(def: (homomorphism injection comparison (open "/#[0]")) +(def (homomorphism injection comparison (open "/#[0]")) (All (_ f) (-> (Injection f) (Comparison f) (Apply f) Test)) (do [! random.monad] [sample random.nat @@ -35,7 +35,7 @@ (/#on (injection sample) (injection increase)) (injection (increase sample)))))) -(def: (interchange injection comparison (open "/#[0]")) +(def (interchange injection comparison (open "/#[0]")) (All (_ f) (-> (Injection f) (Comparison f) (Apply f) Test)) (do [! random.monad] [sample random.nat @@ -46,7 +46,7 @@ (/#on (injection increase) (injection (is (-> (-> Nat Nat) Nat) (function (_ f) (f sample))))))))) -(def: (composition injection comparison (open "/#[0]")) +(def (composition injection comparison (open "/#[0]")) (All (_ f) (-> (Injection f) (Comparison f) (Apply f) Test)) (type.let [:$/1: (-> Nat Nat)] (do [! random.monad] @@ -66,7 +66,7 @@ (injection increase)) (injection decrease))))))) -(def: .public (spec injection comparison apply) +(def .public (spec injection comparison apply) (All (_ f) (-> (Injection f) (Comparison f) (Apply f) Test)) (_.for [/.Apply] (all _.and diff --git a/stdlib/source/specification/lux/abstract/codec.lux b/stdlib/source/specification/lux/abstract/codec.lux index 59d8b5104..9c91c18e9 100644 --- a/stdlib/source/specification/lux/abstract/codec.lux +++ b/stdlib/source/specification/lux/abstract/codec.lux @@ -13,7 +13,7 @@ [// [equivalence (.only Equivalence)]]]]) -(def: .public (spec (open "@//[0]") (open "@//[0]") generator) +(def .public (spec (open "@//[0]") (open "@//[0]") generator) (All (_ m a) (-> (Equivalence a) (/.Codec m a) (Random a) Test)) (do random.monad [expected generator] diff --git a/stdlib/source/specification/lux/abstract/comonad.lux b/stdlib/source/specification/lux/abstract/comonad.lux index c9a03c6d3..4050d2660 100644 --- a/stdlib/source/specification/lux/abstract/comonad.lux +++ b/stdlib/source/specification/lux/abstract/comonad.lux @@ -13,7 +13,7 @@ [// [functor (.only Injection Comparison)]]) -(def: (left_identity injection (open "_//[0]")) +(def (left_identity injection (open "_//[0]")) (All (_ f) (-> (Injection f) (CoMonad f) Test)) (do [! random.monad] [sample random.nat @@ -25,7 +25,7 @@ (n.= (morphism start) (|> start _//disjoint (_//each morphism) _//out))))) -(def: (right_identity injection comparison (open "_//[0]")) +(def (right_identity injection comparison (open "_//[0]")) (All (_ f) (-> (Injection f) (Comparison f) (CoMonad f) Test)) (do random.monad [sample random.nat @@ -35,7 +35,7 @@ (== start (|> start _//disjoint (_//each _//out)))))) -(def: (associativity injection comparison (open "_//[0]")) +(def (associativity injection comparison (open "_//[0]")) (All (_ f) (-> (Injection f) (Comparison f) (CoMonad f) Test)) (do [! random.monad] [sample random.nat @@ -51,7 +51,7 @@ (== (|> start _//disjoint (_//each (|>> _//disjoint (_//each increase) decrease))) (|> start _//disjoint (_//each increase) _//disjoint (_//each decrease)))))) -(def: .public (spec injection comparison subject) +(def .public (spec injection comparison subject) (All (_ f) (-> (Injection f) (Comparison f) (CoMonad f) Test)) (<| (_.for [/.CoMonad]) (all _.and diff --git a/stdlib/source/specification/lux/abstract/enum.lux b/stdlib/source/specification/lux/abstract/enum.lux index 6e48b6521..021d6ba96 100644 --- a/stdlib/source/specification/lux/abstract/enum.lux +++ b/stdlib/source/specification/lux/abstract/enum.lux @@ -9,7 +9,7 @@ [\\library ["[0]" /]]) -(def: .public (spec (open "_#[0]") gen_sample) +(def .public (spec (open "_#[0]") gen_sample) (All (_ a) (-> (/.Enum a) (Random a) Test)) (do random.monad [sample gen_sample] diff --git a/stdlib/source/specification/lux/abstract/equivalence.lux b/stdlib/source/specification/lux/abstract/equivalence.lux index eaa2a9b5b..d7ebc8895 100644 --- a/stdlib/source/specification/lux/abstract/equivalence.lux +++ b/stdlib/source/specification/lux/abstract/equivalence.lux @@ -11,7 +11,7 @@ [\\library ["[0]" / (.only Equivalence)]]) -(def: .public (spec (open "/#[0]") random) +(def .public (spec (open "/#[0]") random) (All (_ a) (-> (Equivalence a) (Random a) Test)) (do random.monad [left random diff --git a/stdlib/source/specification/lux/abstract/functor.lux b/stdlib/source/specification/lux/abstract/functor.lux index 8ac207e97..5551e5a6f 100644 --- a/stdlib/source/specification/lux/abstract/functor.lux +++ b/stdlib/source/specification/lux/abstract/functor.lux @@ -22,7 +22,7 @@ (-> (Equivalence a) (Equivalence (f a))))) -(def: (identity injection comparison (open "@//[0]")) +(def (identity injection comparison (open "@//[0]")) (All (_ f) (-> (Injection f) (Comparison f) (Functor f) Test)) (do [! random.monad] [sample (at ! each injection random.nat)] @@ -31,7 +31,7 @@ (@//each function.identity sample) sample)))) -(def: (homomorphism injection comparison (open "@//[0]")) +(def (homomorphism injection comparison (open "@//[0]")) (All (_ f) (-> (Injection f) (Comparison f) (Functor f) Test)) (do [! random.monad] [sample random.nat @@ -41,7 +41,7 @@ (@//each increase (injection sample)) (injection (increase sample)))))) -(def: (composition injection comparison (open "@//[0]")) +(def (composition injection comparison (open "@//[0]")) (All (_ f) (-> (Injection f) (Comparison f) (Functor f) Test)) (do [! random.monad] [sample (at ! each injection random.nat) @@ -52,7 +52,7 @@ (|> sample (@//each increase) (@//each decrease)) (|> sample (@//each (|>> increase decrease))))))) -(def: .public (spec injection comparison functor) +(def .public (spec injection comparison functor) (All (_ f) (-> (Injection f) (Comparison f) (Functor f) Test)) (<| (_.for [/.Functor]) (all _.and diff --git a/stdlib/source/specification/lux/abstract/functor/contravariant.lux b/stdlib/source/specification/lux/abstract/functor/contravariant.lux index b89e6cd6a..5cb3b75ee 100644 --- a/stdlib/source/specification/lux/abstract/functor/contravariant.lux +++ b/stdlib/source/specification/lux/abstract/functor/contravariant.lux @@ -14,14 +14,14 @@ [\\library ["[0]" / (.only Functor)]]) -(def: (identity equivalence value (open "@//[0]")) +(def (identity equivalence value (open "@//[0]")) (All (_ f a) (-> (Equivalence (f a)) (f a) (Functor f) Test)) (_.property "Law of identity." (equivalence (@//each function.identity value) value))) -(def: .public (spec equivalence value functor) +(def .public (spec equivalence value functor) (All (_ f a) (-> (Equivalence (f a)) (f a) (Functor f) Test)) (do random.monad [sample random.nat] diff --git a/stdlib/source/specification/lux/abstract/hash.lux b/stdlib/source/specification/lux/abstract/hash.lux index a1c4d4880..d8294015c 100644 --- a/stdlib/source/specification/lux/abstract/hash.lux +++ b/stdlib/source/specification/lux/abstract/hash.lux @@ -11,7 +11,7 @@ [\\library ["[0]" /]]) -(def: .public (spec (open "_#[0]") random) +(def .public (spec (open "_#[0]") random) (All (_ a) (-> (/.Hash a) (Random a) Test)) (do random.monad [parameter random diff --git a/stdlib/source/specification/lux/abstract/interval.lux b/stdlib/source/specification/lux/abstract/interval.lux index 567ac7cbb..2ccb4da32 100644 --- a/stdlib/source/specification/lux/abstract/interval.lux +++ b/stdlib/source/specification/lux/abstract/interval.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(def: .public (spec (open "@//[0]") gen_sample) +(def .public (spec (open "@//[0]") gen_sample) (All (_ a) (-> (/.Interval a) (Random a) Test)) (<| (_.for [/.Interval]) (do random.monad diff --git a/stdlib/source/specification/lux/abstract/mix.lux b/stdlib/source/specification/lux/abstract/mix.lux index 519f1249e..5d3ed3994 100644 --- a/stdlib/source/specification/lux/abstract/mix.lux +++ b/stdlib/source/specification/lux/abstract/mix.lux @@ -13,7 +13,7 @@ [\\library ["[0]" /]]) -(def: .public (spec injection comparison (open "@//[0]")) +(def .public (spec injection comparison (open "@//[0]")) (All (_ f) (-> (Injection f) (Comparison f) (/.Mix f) Test)) (do random.monad [subject random.nat diff --git a/stdlib/source/specification/lux/abstract/monad.lux b/stdlib/source/specification/lux/abstract/monad.lux index 25a2f3e4f..b4b3f7029 100644 --- a/stdlib/source/specification/lux/abstract/monad.lux +++ b/stdlib/source/specification/lux/abstract/monad.lux @@ -11,7 +11,7 @@ [// [functor (.only Injection Comparison)]]) -(def: (left_identity injection comparison (open "_//[0]")) +(def (left_identity injection comparison (open "_//[0]")) (All (_ f) (-> (Injection f) (Comparison f) (/.Monad f) Test)) (do [! random.monad] [sample random.nat @@ -23,7 +23,7 @@ (|> (injection sample) (_//each morphism) _//conjoint) (morphism sample))))) -(def: (right_identity injection comparison (open "_//[0]")) +(def (right_identity injection comparison (open "_//[0]")) (All (_ f) (-> (Injection f) (Comparison f) (/.Monad f) Test)) (do random.monad [sample random.nat] @@ -32,7 +32,7 @@ (|> (injection sample) (_//each _//in) _//conjoint) (injection sample))))) -(def: (associativity injection comparison (open "_//[0]")) +(def (associativity injection comparison (open "_//[0]")) (All (_ f) (-> (Injection f) (Comparison f) (/.Monad f) Test)) (do [! random.monad] [sample random.nat @@ -47,7 +47,7 @@ (|> (injection sample) (_//each increase) _//conjoint (_//each decrease) _//conjoint) (|> (injection sample) (_//each (|>> increase (_//each decrease) _//conjoint)) _//conjoint))))) -(def: .public (spec injection comparison monad) +(def .public (spec injection comparison monad) (All (_ f) (-> (Injection f) (Comparison f) (/.Monad f) Test)) (<| (_.for [/.Monad]) (all _.and diff --git a/stdlib/source/specification/lux/abstract/monoid.lux b/stdlib/source/specification/lux/abstract/monoid.lux index 1786919f4..8cc42c232 100644 --- a/stdlib/source/specification/lux/abstract/monoid.lux +++ b/stdlib/source/specification/lux/abstract/monoid.lux @@ -11,7 +11,7 @@ [// [equivalence (.only Equivalence)]]]]) -(def: .public (spec (open "_#[0]") (open "_#[0]") gen_sample) +(def .public (spec (open "_#[0]") (open "_#[0]") gen_sample) (All (_ a) (-> (Equivalence a) (/.Monoid a) (Random a) Test)) (do random.monad [sample gen_sample diff --git a/stdlib/source/specification/lux/abstract/order.lux b/stdlib/source/specification/lux/abstract/order.lux index 365164c19..7e6c7a0d2 100644 --- a/stdlib/source/specification/lux/abstract/order.lux +++ b/stdlib/source/specification/lux/abstract/order.lux @@ -9,7 +9,7 @@ [\\library ["[0]" /]]) -(def: .public (spec (open "@//[0]") generator) +(def .public (spec (open "@//[0]") generator) (All (_ a) (-> (/.Order a) (Random a) Test)) (<| (_.for [/.Order]) (all _.and diff --git a/stdlib/source/specification/lux/world/console.lux b/stdlib/source/specification/lux/world/console.lux index 1aa2f06bb..e3ab5391e 100644 --- a/stdlib/source/specification/lux/world/console.lux +++ b/stdlib/source/specification/lux/world/console.lux @@ -17,7 +17,7 @@ [\\library ["[0]" /]]) -(def: .public (spec console) +(def .public (spec console) (-> (IO (/.Console Async)) Test) (do random.monad [message (random.alphabetic 10)] diff --git a/stdlib/source/specification/lux/world/file.lux b/stdlib/source/specification/lux/world/file.lux index 7b4512970..1b31a1e4c 100644 --- a/stdlib/source/specification/lux/world/file.lux +++ b/stdlib/source/specification/lux/world/file.lux @@ -30,7 +30,7 @@ [\\library ["[0]" /]]) -(def: (for_path fs) +(def (for_path fs) (-> (IO (/.System Async)) Test) (<| (_.for [/.Path]) (do [! random.monad] @@ -55,7 +55,7 @@ (text#= child))) )))) -(def: (directory?&make_directory fs parent) +(def (directory?&make_directory fs parent) (-> (/.System Async) /.Path (Async Bit)) (do async.monad [directory_pre! (at fs directory? parent) @@ -67,7 +67,7 @@ {try.#Failure _} false) directory_post!)))) -(def: (file?&write fs content path) +(def (file?&write fs content path) (-> (/.System Async) Binary /.Path (Async Bit)) (do async.monad [file_pre! (at fs file? path) @@ -79,7 +79,7 @@ {try.#Failure _} false) file_post!)))) -(def: (file_size&read&append fs expected_file_size content appendix path) +(def (file_size&read&append fs expected_file_size content appendix path) (-> (/.System Async) Nat Binary Binary /.Path (Async Bit)) (do async.monad [pre_file_size (at fs file_size path) @@ -107,7 +107,7 @@ post_file_size! post_content!))))))) -(def: (modified?&last_modified fs expected_time path) +(def (modified?&last_modified fs expected_time path) (-> (/.System Async) Instant /.Path (Async Bit)) (do async.monad [modified? (at fs modify path expected_time) @@ -117,7 +117,7 @@ [_ modified?] (at ! each (instant#= expected_time) last_modified)))))) -(def: (directory_files&sub_directories fs parent sub_dir child) +(def (directory_files&sub_directories fs parent sub_dir child) (-> (/.System Async) /.Path /.Path /.Path (Async Bit)) (let [sub_dir (/.rooted fs parent sub_dir) child (/.rooted fs parent child)] @@ -136,7 +136,7 @@ (try#each (list#= (list sub_dir))) (try.else false)))))))))) -(def: (move&delete fs parent child alternate_child) +(def (move&delete fs parent child alternate_child) (-> (/.System Async) /.Path Text Text (Async Bit)) (let [origin (/.rooted fs parent child) destination (/.rooted fs parent alternate_child)] @@ -154,7 +154,7 @@ (in (and lost? found?)))))))) -(def: (for_system fs) +(def (for_system fs) (-> (IO (/.System Async)) Test) (<| (do [! random.monad] [parent (random.numeric 2) @@ -205,7 +205,7 @@ directory_files&sub_directories move&delete)))) -(def: (make_directories&cannot_make_directory fs) +(def (make_directories&cannot_make_directory fs) (-> (IO (/.System Async)) Test) (<| (do [! random.monad] [dir/0 (random.numeric 2) @@ -252,7 +252,7 @@ (exception.match? /.cannot_make_directory error)))) ))) -(def: (make_file&cannot_make_file fs) +(def (make_file&cannot_make_file fs) (-> (IO (/.System Async)) Test) (<| (do [! random.monad] [file/0 (random.numeric 3)]) @@ -275,14 +275,14 @@ (exception.match? /.cannot_make_file error))) ))) -(def: (for_utilities fs) +(def (for_utilities fs) (-> (IO (/.System Async)) Test) (all _.and (..make_directories&cannot_make_directory fs) (..make_file&cannot_make_file fs) )) -(def: (exists? fs) +(def (exists? fs) (-> (IO (/.System Async)) Test) (<| (do [! random.monad] [file (random.numeric 2) @@ -322,7 +322,7 @@ post_dir/0 post_dir/1)))) -(def: .public (spec fs) +(def .public (spec fs) (-> (IO (/.System Async)) Test) (all _.and (..for_path fs) diff --git a/stdlib/source/specification/lux/world/program.lux b/stdlib/source/specification/lux/world/program.lux index 3830dfb2a..8bfacf0c8 100644 --- a/stdlib/source/specification/lux/world/program.lux +++ b/stdlib/source/specification/lux/world/program.lux @@ -18,7 +18,7 @@ [\\library ["[0]" /]]) -(def: .public (spec subject) +(def .public (spec subject) (-> (/.Program Async) Test) (do random.monad [exit random.int] diff --git a/stdlib/source/specification/lux/world/shell.lux b/stdlib/source/specification/lux/world/shell.lux index 9ff673a05..fbd952add 100644 --- a/stdlib/source/specification/lux/world/shell.lux +++ b/stdlib/source/specification/lux/world/shell.lux @@ -25,7 +25,7 @@ [file (.only Path)]]]]) (with_template [<name> <command> <type> <prep>] - [(def: <name> + [(def <name> (-> <type> [Environment Path /.Command (List /.Argument)]) (|>> <prep> list [environment.empty "~" <command>]))] @@ -33,7 +33,7 @@ [sleep! "sleep" Nat %.nat] ) -(def: (can_wait! process) +(def (can_wait! process) (-> (/.Process Async) _.Assertion) (|> (at process await []) (async#each (|>> (try#each (i.= /.normal)) @@ -41,13 +41,13 @@ (_.coverage' [/.Exit /.normal]))) async#conjoint)) -(def: (can_read! expected process) +(def (can_read! expected process) (-> Text (/.Process Async) (Async Bit)) (|> (at process read []) (async#each (|>> (try#each (text#= expected)) (try.else false))))) -(def: (can_destroy! process) +(def (can_destroy! process) (-> (/.Process Async) (Async Bit)) (do async.monad [?destroy (at process destroy []) @@ -66,7 +66,7 @@ true))))) (with_expansions [<shell_coverage> (these [/.Command /.Argument])] - (def: .public (spec shell) + (def .public (spec shell) (-> (/.Shell Async) Test) (<| (_.for [/.Shell /.Process]) (do [! random.monad] diff --git a/stdlib/source/test/aedifex.lux b/stdlib/source/test/aedifex.lux index 929d5de80..ccdc14e05 100644 --- a/stdlib/source/test/aedifex.lux +++ b/stdlib/source/test/aedifex.lux @@ -25,7 +25,7 @@ ["[1][0]" repository] ["[1][0]" runtime]]) -(def: dependency +(def dependency Test (all _.and /dependency.test @@ -34,7 +34,7 @@ /dependency/status.test )) -(def: test +(def test Test (all _.and /artifact.test diff --git a/stdlib/source/test/aedifex/artifact.lux b/stdlib/source/test/aedifex/artifact.lux index aefe175f4..1b9bad2f0 100644 --- a/stdlib/source/test/aedifex/artifact.lux +++ b/stdlib/source/test/aedifex/artifact.lux @@ -26,7 +26,7 @@ [\\program ["[0]" /]]) -(def: .public random +(def .public random (Random /.Artifact) (let [size 4] (all random.and @@ -34,7 +34,7 @@ (random.lower_case size) (random.lower_case size)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/aedifex/artifact/extension.lux b/stdlib/source/test/aedifex/artifact/extension.lux index 7ca90b6a6..80b49fdfb 100644 --- a/stdlib/source/test/aedifex/artifact/extension.lux +++ b/stdlib/source/test/aedifex/artifact/extension.lux @@ -18,7 +18,7 @@ ["/[1]" // ["[1]" type]]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Extension] diff --git a/stdlib/source/test/aedifex/artifact/snapshot.lux b/stdlib/source/test/aedifex/artifact/snapshot.lux index 628412bee..8888dc848 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot.lux @@ -20,12 +20,12 @@ [\\program ["[0]" /]]) -(def: .public random +(def .public random (Random /.Snapshot) (random.or (random#in []) $/stamp.random)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Snapshot] diff --git a/stdlib/source/test/aedifex/artifact/snapshot/build.lux b/stdlib/source/test/aedifex/artifact/snapshot/build.lux index 71024f4d0..f6224dd0b 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/build.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/build.lux @@ -15,11 +15,11 @@ [\\program ["[0]" /]]) -(def: .public random +(def .public random (Random /.Build) random.nat) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Build] diff --git a/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux b/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux index ae1ffb7a5..c24a06f5a 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/stamp.lux @@ -20,14 +20,14 @@ ["[1][0]" time] ["[1][0]" build]]) -(def: .public random +(def .public random (Random /.Stamp) (all random.and $//time.random $//build.random )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Stamp]) diff --git a/stdlib/source/test/aedifex/artifact/snapshot/time.lux b/stdlib/source/test/aedifex/artifact/snapshot/time.lux index a26532ce1..3b6136ce9 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/time.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/time.lux @@ -18,11 +18,11 @@ ["$[0]" /// ["[1][0]" time]]) -(def: .public random +(def .public random (Random /.Time) $///time.random) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Time]) diff --git a/stdlib/source/test/aedifex/artifact/snapshot/version.lux b/stdlib/source/test/aedifex/artifact/snapshot/version.lux index c5c8f0e71..d2a3e01e4 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/version.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/version.lux @@ -20,7 +20,7 @@ ["[1][0]" type] ["[1][0]" time]]) -(def: .public random +(def .public random (Random /.Version) (all random.and $///type.random @@ -28,7 +28,7 @@ $///time.random )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Version]) diff --git a/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux b/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux index 5fcef9a0c..0c63a2215 100644 --- a/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux +++ b/stdlib/source/test/aedifex/artifact/snapshot/version/value.lux @@ -27,7 +27,7 @@ ["[1][0]" stamp] ["[1][0]" time]]]]) -(def: .public random +(def .public random (Random /.Value) (all random.and (random.alphabetic 5) @@ -35,7 +35,7 @@ $///stamp.random) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Value]) diff --git a/stdlib/source/test/aedifex/artifact/time.lux b/stdlib/source/test/aedifex/artifact/time.lux index 8ee637360..c6ba0f2c0 100644 --- a/stdlib/source/test/aedifex/artifact/time.lux +++ b/stdlib/source/test/aedifex/artifact/time.lux @@ -23,14 +23,14 @@ ["[1][0]" date] ["[1][0]" time]]) -(def: .public random +(def .public random (Random /.Time) (do random.monad [date /date.random time /time.random] (in [date time]))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Time]) diff --git a/stdlib/source/test/aedifex/artifact/time/date.lux b/stdlib/source/test/aedifex/artifact/time/date.lux index b53420e0a..6d2e4296a 100644 --- a/stdlib/source/test/aedifex/artifact/time/date.lux +++ b/stdlib/source/test/aedifex/artifact/time/date.lux @@ -23,7 +23,7 @@ [\\program ["[0]" /]]) -(def: .public random +(def .public random (Random /.Date) (random.one (function (_ raw) (try.maybe @@ -35,7 +35,7 @@ (/.date raw)))) random.date)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Date]) diff --git a/stdlib/source/test/aedifex/artifact/time/time.lux b/stdlib/source/test/aedifex/artifact/time/time.lux index 9a7189e33..33bc56c87 100644 --- a/stdlib/source/test/aedifex/artifact/time/time.lux +++ b/stdlib/source/test/aedifex/artifact/time/time.lux @@ -18,14 +18,14 @@ [\\program ["[0]" /]]) -(def: .public random +(def .public random (Random /.Time) (random.one (|>> time.clock (has time.#milli_second 0) time.time) random.time)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Time]) diff --git a/stdlib/source/test/aedifex/artifact/type.lux b/stdlib/source/test/aedifex/artifact/type.lux index a2b5926e5..003123f40 100644 --- a/stdlib/source/test/aedifex/artifact/type.lux +++ b/stdlib/source/test/aedifex/artifact/type.lux @@ -16,7 +16,7 @@ [\\program ["[0]" /]]) -(def: .public random +(def .public random (Random /.Type) (all random.either (all random.either @@ -28,7 +28,7 @@ (random#in /.sha-1)) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Type] diff --git a/stdlib/source/test/aedifex/artifact/versioning.lux b/stdlib/source/test/aedifex/artifact/versioning.lux index d1efdb17f..451d0b824 100644 --- a/stdlib/source/test/aedifex/artifact/versioning.lux +++ b/stdlib/source/test/aedifex/artifact/versioning.lux @@ -19,7 +19,7 @@ ["[1][0]" snapshot (.only) ["[1]/[0]" version]]]) -(def: .public random +(def .public random (Random /.Versioning) (all random.and $//snapshot.random @@ -27,7 +27,7 @@ (random.list 5 $//snapshot/version.random) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Versioning]) diff --git a/stdlib/source/test/aedifex/cache.lux b/stdlib/source/test/aedifex/cache.lux index 34173ce62..6456cc824 100644 --- a/stdlib/source/test/aedifex/cache.lux +++ b/stdlib/source/test/aedifex/cache.lux @@ -46,13 +46,13 @@ ["[1][0]" repository ["[1]/[0]" origin]]]]]) -(def: type +(def type (Random Type) (all random.either (random#in //artifact/type.lux_library) (random#in //artifact/type.jvm_library))) -(def: profile +(def profile (Random [Artifact Profile XML]) (random.one (function (_ profile) (try.maybe @@ -62,13 +62,13 @@ (in [identity profile pom])))) @profile.random)) -(def: content +(def content (Random Binary) (do [! random.monad] [content_size (at ! each (n.% 100) random.nat)] (_binary.random content_size))) -(def: package +(def package (Random [Dependency Package]) (do [! random.monad] [[identity profile pom] ..profile @@ -78,7 +78,7 @@ //dependency.#type type] (has //package.#origin {//repository/origin.#Remote ""} (//package.local pom content))]))) -(def: resolution +(def resolution (Random Resolution) (do [! random.monad] [[main_dependency main_package] ..package @@ -99,7 +99,7 @@ (has //package.#origin {//repository/origin.#Remote ""} (//package.local pom content))])))))] (in (dictionary.of_list //dependency.hash (list.partial [main_dependency main_package] dependencies))))) -(def: singular +(def singular Test (do [! random.monad] [[dependency expected_package] ..package @@ -120,7 +120,7 @@ (has //package.#origin {//repository/origin.#Local ""} expected_package) actual_package))))))))) -(def: plural +(def plural Test (do [! random.monad] [expected ..resolution @@ -143,7 +143,7 @@ expected) actual))))))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/aedifex/cli.lux b/stdlib/source/test/aedifex/cli.lux index f0b011180..a4af47e46 100644 --- a/stdlib/source/test/aedifex/cli.lux +++ b/stdlib/source/test/aedifex/cli.lux @@ -22,12 +22,12 @@ ["/[1]" // ["[1]" profile]]]]) -(def: compilation +(def compilation (Random /.Compilation) (random.or (random#in []) (random#in []))) -(def: command +(def command (Random /.Command) (all random.or ... #Version @@ -50,13 +50,13 @@ ... #Auto ..compilation)) -(def: (compilation_format value) +(def (compilation_format value) (-> /.Compilation (List Text)) (case value {/.#Build} (list "build") {/.#Test} (list "test"))) -(def: (format value) +(def (format value) (-> /.Command (List Text)) (case value {/.#Version} (list "version") @@ -68,7 +68,7 @@ {/.#Compilation compilation} (..compilation_format compilation) {/.#Auto compilation} (list.partial "auto" (..compilation_format compilation)))) -(def: without_profile +(def without_profile Test (do random.monad [expected ..command] @@ -84,7 +84,7 @@ {try.#Failure error} false))))) -(def: with_profile +(def with_profile Test (do random.monad [expected_profile (random.alphabetic 1) @@ -102,7 +102,7 @@ {try.#Failure error} false))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Compilation /.Command] diff --git a/stdlib/source/test/aedifex/command.lux b/stdlib/source/test/aedifex/command.lux index 537f93562..cf3068d3c 100644 --- a/stdlib/source/test/aedifex/command.lux +++ b/stdlib/source/test/aedifex/command.lux @@ -18,7 +18,7 @@ [\\program ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Command]) diff --git a/stdlib/source/test/aedifex/command/auto.lux b/stdlib/source/test/aedifex/command/auto.lux index 6834fe8eb..2d6ed1354 100644 --- a/stdlib/source/test/aedifex/command/auto.lux +++ b/stdlib/source/test/aedifex/command/auto.lux @@ -44,7 +44,7 @@ [dependency [resolution (.only Resolution)]]]]]) -(def: (command expected_runs end_signal fs dummy_file) +(def (command expected_runs end_signal fs dummy_file) (-> Nat Text (file.System Async) file.Path [(Atom Nat) (-> (Console Async) (Program Async) (file.System Async) (Shell Async) Resolution (Command [Exit Any]))]) @@ -61,7 +61,7 @@ _ (at fs modify dummy_file (|> actual_runs .int instant.of_millis))] (in [shell.normal []])))))])) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/aedifex/command/build.lux b/stdlib/source/test/aedifex/command/build.lux index c740ad48f..47c3ac71a 100644 --- a/stdlib/source/test/aedifex/command/build.lux +++ b/stdlib/source/test/aedifex/command/build.lux @@ -37,50 +37,50 @@ ["[1][0]" dependency (.only Dependency) ["[1]/[0]" resolution (.only Resolution)]]]]]) -(def: .public good_shell +(def .public good_shell (-> Any (Shell IO)) (shell.mock (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) {try.#Success (is (shell.Mock []) (implementation - (def: (on_read state) + (def (on_read state) (exception.except shell.no_more_output [])) - (def: (on_fail state) + (def (on_fail state) (exception.except shell.no_more_output [])) - (def: (on_write input state) + (def (on_write input state) {try.#Failure "on_write"}) - (def: (on_destroy state) + (def (on_destroy state) {try.#Failure "on_destroy"}) - (def: (on_await state) + (def (on_await state) {try.#Success [state shell.normal]})))}))) -(def: .public bad_shell +(def .public bad_shell (-> Any (Shell IO)) (shell.mock (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) {try.#Success (is (shell.Mock []) (implementation - (def: (on_read state) + (def (on_read state) (exception.except shell.no_more_output [])) - (def: (on_fail state) + (def (on_fail state) (exception.except shell.no_more_output [])) - (def: (on_write input state) + (def (on_write input state) {try.#Failure "on_write"}) - (def: (on_destroy state) + (def (on_destroy state) {try.#Failure "on_destroy"}) - (def: (on_await state) + (def (on_await state) {try.#Success [state shell.error]})))}))) -(def: .public (reader_shell error?) +(def .public (reader_shell error?) (-> Bit (-> (List Text) (Shell IO))) (shell.mock (function (_ [actual_environment actual_working_directory actual_command actual_arguments]) {try.#Success (is (shell.Mock (List Text)) (implementation - (def: (on_read state) + (def (on_read state) (if error? (exception.except shell.no_more_output []) (case state @@ -89,7 +89,7 @@ {.#End} (exception.except shell.no_more_output [])))) - (def: (on_fail state) + (def (on_fail state) (if error? (case state {.#Item head tail} @@ -98,14 +98,14 @@ {.#End} (exception.except shell.no_more_output [])) (exception.except shell.no_more_output []))) - (def: (on_write input state) + (def (on_write input state) {try.#Failure "on_write"}) - (def: (on_destroy state) + (def (on_destroy state) {try.#Failure "on_destroy"}) - (def: (on_await state) + (def (on_await state) {try.#Success [state shell.error]})))}))) -(def: compiler +(def compiler (Random Dependency) (do random.monad [lux_version (random.alphabetic 5) @@ -127,7 +127,7 @@ [/.ruby_lux_name] )))))) -(def: .public resolution +(def .public resolution (Random [Dependency Resolution]) (do random.monad [dependency ..compiler @@ -136,7 +136,7 @@ (|> ///dependency/resolution.empty (dictionary.has dependency package))]))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/aedifex/command/clean.lux b/stdlib/source/test/aedifex/command/clean.lux index 4f37c7bc3..7edf91440 100644 --- a/stdlib/source/test/aedifex/command/clean.lux +++ b/stdlib/source/test/aedifex/command/clean.lux @@ -36,11 +36,11 @@ ["[1]" profile] ["[1][0]" action (.only Action)]]]]) -(def: node_name +(def node_name (Random Text) (random.alphabetic 10)) -(def: (files prefix) +(def (files prefix) (-> Path (Random (List [Path Binary]))) (do [! random.monad] [count (at ! each (n.% 10) random.nat) @@ -49,11 +49,11 @@ (in (list.zipped_2 (list#each (|>> (format prefix)) (set.list names)) contents)))) -(def: (create_file! fs [path content]) +(def (create_file! fs [path content]) (-> (file.System Async) [Path Binary] (Async (Try Any))) (at fs write path content)) -(def: (create_directory! fs path files) +(def (create_directory! fs path files) (-> (file.System Async) Path (List [Path Binary]) (Async (Try Any))) (do [! (try.with async.monad)] [_ (is (Async (Try Any)) @@ -61,15 +61,15 @@ _ (monad.each ! (..create_file! fs) files)] (in []))) -(def: (directory_exists? fs) +(def (directory_exists? fs) (-> (file.System Async) Path (Async (Try Bit))) (|>> (at fs directory?) (try.lifted async.monad))) -(def: (file_exists? fs) +(def (file_exists? fs) (-> (file.System Async) Path (Async (Try Bit))) (|>> (at fs file?) (try.lifted async.monad))) -(def: (assets_exist? fs directory_path files) +(def (assets_exist? fs directory_path files) (-> (file.System Async) Path (List [Path Binary]) (Async (Try Bit))) (do [! (try.with async.monad)] [directory_exists? (..directory_exists? fs directory_path) @@ -80,7 +80,7 @@ (in (and directory_exists? (list.every? (|>>) files_exist?))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/aedifex/command/deploy.lux b/stdlib/source/test/aedifex/command/deploy.lux index 871083df6..7b709c82d 100644 --- a/stdlib/source/test/aedifex/command/deploy.lux +++ b/stdlib/source/test/aedifex/command/deploy.lux @@ -53,7 +53,7 @@ ["[1][0]" artifact (.only Artifact) ["[1]/[0]" extension]]]]]) -(def: (execute! program local remote fs artifact profile) +(def (execute! program local remote fs artifact profile) (-> (Program Async) (Repository Async) (Repository Async) (file.System Async) Artifact ///.Profile (Async (Try Text))) @@ -64,7 +64,7 @@ _ (/.do! program shell console local remote fs artifact profile)] (at console read_line []))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/aedifex/command/deps.lux b/stdlib/source/test/aedifex/command/deps.lux index 450152fe2..14d0f040b 100644 --- a/stdlib/source/test/aedifex/command/deps.lux +++ b/stdlib/source/test/aedifex/command/deps.lux @@ -52,7 +52,7 @@ ["[1]/[0]" origin] ["[1]/[0]" local]]]]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/aedifex/command/install.lux b/stdlib/source/test/aedifex/command/install.lux index de26f5ecb..a55e96d95 100644 --- a/stdlib/source/test/aedifex/command/install.lux +++ b/stdlib/source/test/aedifex/command/install.lux @@ -38,7 +38,7 @@ ["[1][0]" repository ["[1]/[0]" local]]]]]) -(def: .public (make_sources! fs sources) +(def .public (make_sources! fs sources) (-> (file.System Async) (Set file.Path) (Action (List Any))) (let [/ (at fs separator) ! ///action.monad] @@ -51,7 +51,7 @@ (is (Async (Try Any)) (file.make_file async.monad fs (binary.empty 0) (format head / head ".lux"))))))))) -(def: (execute! program fs sample) +(def (execute! program fs sample) (-> (Program Async) (file.System Async) ///.Profile (Async (Try Text))) (do ///action.monad [.let [console ($version.echo "")] @@ -59,7 +59,7 @@ _ (/.do! console fs (///repository/local.repository program fs) sample)] (at console read_line []))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/aedifex/command/pom.lux b/stdlib/source/test/aedifex/command/pom.lux index 278d91209..f6ba0e28e 100644 --- a/stdlib/source/test/aedifex/command/pom.lux +++ b/stdlib/source/test/aedifex/command/pom.lux @@ -30,7 +30,7 @@ ["[1][0]" action] ["[1][0]" pom]]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/aedifex/command/test.lux b/stdlib/source/test/aedifex/command/test.lux index 9b01c2feb..7ab540925 100644 --- a/stdlib/source/test/aedifex/command/test.lux +++ b/stdlib/source/test/aedifex/command/test.lux @@ -39,7 +39,7 @@ ["[1][0]" dependency (.only) ["[1]/[0]" resolution]]]]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] @@ -86,15 +86,15 @@ {try.#Success (is (shell.Mock []) (implementation - (def: (on_read state) + (def (on_read state) (exception.except shell.no_more_output [])) - (def: (on_fail state) + (def (on_fail state) (exception.except shell.no_more_output [])) - (def: (on_write input state) + (def (on_write input state) {try.#Failure "on_write"}) - (def: (on_destroy state) + (def (on_destroy state) {try.#Failure "on_destroy"}) - (def: (on_await state) + (def (on_await state) {try.#Success [state (if (list.any? (text#= "build") actual_arguments) shell.normal shell.error)]})))}) diff --git a/stdlib/source/test/aedifex/command/version.lux b/stdlib/source/test/aedifex/command/version.lux index 740065820..c8f427a71 100644 --- a/stdlib/source/test/aedifex/command/version.lux +++ b/stdlib/source/test/aedifex/command/version.lux @@ -29,10 +29,10 @@ (exception: .public console_is_closed!) -(def: mock +(def mock (Mock [Bit Text]) (implementation - (def: (on_read [open? state]) + (def (on_read [open? state]) (if open? (try.of_maybe (do maybe.monad @@ -40,29 +40,29 @@ [_ tail] (text.split_at 1 state)] (in [[open? tail] head]))) (exception.except ..console_is_closed! []))) - (def: (on_read_line [open? state]) + (def (on_read_line [open? state]) (if open? (try.of_maybe (do maybe.monad [[output state] (text.split_by text.new_line state)] (in [[open? state] output]))) (exception.except ..console_is_closed! []))) - (def: (on_write input [open? state]) + (def (on_write input [open? state]) (if open? {try.#Success [open? (format state input)]} (exception.except ..console_is_closed! []))) - (def: (on_close [open? buffer]) + (def (on_close [open? buffer]) (if open? {try.#Success [false buffer]} (exception.except ..console_is_closed! []))))) -(def: .public echo +(def .public echo (-> Text (Console Async)) (|>> [true] (console.mock ..mock) console.async)) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/aedifex/dependency.lux b/stdlib/source/test/aedifex/dependency.lux index 2d4e6b981..93acdb4c6 100644 --- a/stdlib/source/test/aedifex/dependency.lux +++ b/stdlib/source/test/aedifex/dependency.lux @@ -15,13 +15,13 @@ [\\program ["[0]" /]]) -(def: .public random +(def .public random (Random /.Dependency) (all random.and @artifact.random (random.alphabetic 1))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Dependency] diff --git a/stdlib/source/test/aedifex/dependency/deployment.lux b/stdlib/source/test/aedifex/dependency/deployment.lux index 0c605141a..456897460 100644 --- a/stdlib/source/test/aedifex/dependency/deployment.lux +++ b/stdlib/source/test/aedifex/dependency/deployment.lux @@ -49,7 +49,7 @@ ["[0]" repository (.only) ["[0]" remote]]]]]]) -(def: good_upload +(def good_upload (@http.Response IO) [http/status.created [@http.#headers (http.headers (list)) @@ -61,10 +61,10 @@ (type: Cache (Atom (Dictionary URL Binary))) -(def: (http cache) +(def (http cache) (-> Cache (http.Client IO)) (implementation - (def: (request method url headers input) + (def (request method url headers input) (do io.monad [_ (is (IO Any) (case [method input] @@ -75,7 +75,7 @@ (in [])))] (in {try.#Success ..good_upload}))))) -(def: (verify_one expected_deployments address package cache expected_artifact actual_artifact) +(def (verify_one expected_deployments address package cache expected_artifact actual_artifact) (-> Nat URL Package (Dictionary URL Binary) Artifact Artifact Bit) (let [url (is (-> URI URL) (|>> (format address))) @@ -131,7 +131,7 @@ artifact_metadata_upload! project_metadata_upload!))) -(def: bundle +(def bundle (Random [Dependency Artifact Package]) (do random.monad [[profile package] $///package.random @@ -143,7 +143,7 @@ artifact/type.lux_library])]] (in [dependency artifact package]))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index 598b7fa24..ae4366042 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -48,7 +48,7 @@ ["[1][0]" repository (.only Mock) ["[1]/[0]" origin]]]]]) -(def: random +(def random (Random /.Resolution) (do [! random.monad] [artifact $///artifact.random @@ -58,51 +58,51 @@ package /.empty)))) -(def: lux_sha-1 +(def lux_sha-1 Text (format ///artifact/extension.lux_library ///artifact/extension.sha-1)) -(def: lux_md5 +(def lux_md5 Text (format ///artifact/extension.lux_library ///artifact/extension.md5)) -(def: pom_sha-1 +(def pom_sha-1 Text (format ///artifact/extension.pom ///artifact/extension.sha-1)) -(def: pom_md5 +(def pom_md5 Text (format ///artifact/extension.pom ///artifact/extension.md5)) -(def: sha-1 +(def sha-1 (-> Binary Binary) (|>> ///hash.sha-1 (at ///hash.sha-1_codec encoded) (at utf8.codec encoded))) -(def: md5 +(def md5 (-> Binary Binary) (|>> ///hash.md5 (at ///hash.md5_codec encoded) (at utf8.codec encoded))) -(def: .public nope +(def .public nope (Mock Any) (implementation - (def: the_description + (def the_description "[0]") - (def: (on_download uri state) + (def (on_download uri state) {try.#Failure "NOPE"}) - (def: (on_upload uri binary state) + (def (on_upload uri binary state) {try.#Failure "NOPE"}))) -(def: .public (single artifact package) +(def .public (single artifact package) (-> Artifact Package (Mock Any)) (let [expected (///artifact.uri (the ///artifact.#version artifact) artifact)] (implementation - (def: the_description + (def the_description "[1]") - (def: (on_download uri state) + (def (on_download uri state) (if (text.contains? expected uri) (let [library (is Binary (|> package @@ -135,15 +135,15 @@ ... else {try.#Failure "NOPE"})) {try.#Failure "NOPE"})) - (def: (on_upload uri binary state) + (def (on_upload uri binary state) {try.#Failure "NOPE"})))) -(def: (bad_sha-1 expected_artifact expected_package dummy_package) +(def (bad_sha-1 expected_artifact expected_package dummy_package) (-> Artifact Package Package (Mock Any)) (implementation - (def: the_description + (def the_description "[~SHA-1]") - (def: (on_download uri state) + (def (on_download uri state) (if (text.contains? (///artifact.uri (the ///artifact.#version expected_artifact) expected_artifact) uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) {try.#Success [state (|> expected_package @@ -188,15 +188,15 @@ ... else {try.#Failure "NOPE"}) {try.#Failure "NOPE"})) - (def: (on_upload uri binary state) + (def (on_upload uri binary state) {try.#Failure "NOPE"}))) -(def: (bad_md5 expected_artifact expected_package dummy_package) +(def (bad_md5 expected_artifact expected_package dummy_package) (-> Artifact Package Package (Mock Any)) (implementation - (def: the_description + (def the_description "[~MD5]") - (def: (on_download uri state) + (def (on_download uri state) (if (text.contains? (///artifact.uri (the ///artifact.#version expected_artifact) expected_artifact) uri) (cond (text.ends_with? ///artifact/extension.lux_library uri) {try.#Success [state (|> expected_package @@ -241,10 +241,10 @@ ... else {try.#Failure "NOPE"}) {try.#Failure "NOPE"})) - (def: (on_upload uri binary state) + (def (on_upload uri binary state) {try.#Failure "NOPE"}))) -(def: one +(def one Test (do [! random.monad] [expected_artifact $///artifact.random @@ -289,7 +289,7 @@ )) )))) -(def: any +(def any Test (do [! random.monad] [expected_artifact $///artifact.random @@ -336,7 +336,7 @@ false)))) ))) -(def: artifacts +(def artifacts (Random [Artifact Artifact Artifact]) (do random.monad [dependee_artifact $///artifact.random @@ -349,7 +349,7 @@ $///artifact.random)] (in [dependee_artifact depender_artifact ignored_artifact]))) -(def: (packages [dependee_artifact depender_artifact ignored_artifact]) +(def (packages [dependee_artifact depender_artifact ignored_artifact]) (-> [Artifact Artifact Artifact] (Random [[Dependency Dependency Dependency] [Package Package Package]])) @@ -397,7 +397,7 @@ (in [[dependee depender ignored] [dependee_package depender_package ignored_package]]))) -(def: all +(def all Test (do [! random.monad] [[dependee_artifact depender_artifact ignored_artifact] ..artifacts @@ -427,7 +427,7 @@ (not (dictionary.key? resolution ignored)))))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Resolution]) diff --git a/stdlib/source/test/aedifex/dependency/status.lux b/stdlib/source/test/aedifex/dependency/status.lux index 6b59fa394..ef3d704f6 100644 --- a/stdlib/source/test/aedifex/dependency/status.lux +++ b/stdlib/source/test/aedifex/dependency/status.lux @@ -18,7 +18,7 @@ ["//[1]" /// ["[1][0]" hash]]]]) -(def: .public random +(def .public random (Random /.Status) (all random.or (random#in []) @@ -28,7 +28,7 @@ ($///hash.random ///hash.md5)) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Status] diff --git a/stdlib/source/test/aedifex/hash.lux b/stdlib/source/test/aedifex/hash.lux index b4ef53c73..28d912a48 100644 --- a/stdlib/source/test/aedifex/hash.lux +++ b/stdlib/source/test/aedifex/hash.lux @@ -25,7 +25,7 @@ [data ["_[0]" binary]]]]) -(def: .public (random hash) +(def .public (random hash) (All (_ h) (-> (-> Binary (/.Hash h)) (Random (/.Hash h)))) @@ -33,7 +33,7 @@ [size (at ! each (n.% 100) random.nat)] (at ! each hash (_binary.random size)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Hash /.SHA-1 /.MD5]) diff --git a/stdlib/source/test/aedifex/input.lux b/stdlib/source/test/aedifex/input.lux index 6932ccf56..47d8bf0c9 100644 --- a/stdlib/source/test/aedifex/input.lux +++ b/stdlib/source/test/aedifex/input.lux @@ -31,17 +31,17 @@ [repository [remote (.only Address)]]]]]) -(def: (with_default_source sources) +(def (with_default_source sources) (-> (Set //.Source) (Set //.Source)) (if (set.empty? sources) (set.has //.default_source sources) sources)) -(def: with_default_repository +(def with_default_repository (-> (Set Address) (Set Address)) (set.has //.default_repository)) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/aedifex/local.lux b/stdlib/source/test/aedifex/local.lux index d5f058050..9adef30d6 100644 --- a/stdlib/source/test/aedifex/local.lux +++ b/stdlib/source/test/aedifex/local.lux @@ -15,7 +15,7 @@ ["/[1]" // ["[1][0]" artifact]]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/aedifex/metadata.lux b/stdlib/source/test/aedifex/metadata.lux index bdac5dfac..f5179d2a9 100644 --- a/stdlib/source/test/aedifex/metadata.lux +++ b/stdlib/source/test/aedifex/metadata.lux @@ -16,7 +16,7 @@ [\\program ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/aedifex/metadata/artifact.lux b/stdlib/source/test/aedifex/metadata/artifact.lux index 041bad539..a43777707 100644 --- a/stdlib/source/test/aedifex/metadata/artifact.lux +++ b/stdlib/source/test/aedifex/metadata/artifact.lux @@ -41,7 +41,7 @@ ["[1][0]" repository ["[1]/[0]" local]]]]]]) -(def: .public random +(def .public random (Random /.Metadata) (all random.and (random.alphabetic 5) @@ -66,7 +66,7 @@ time.#milli_second 0])] (in (instant.of_date_time date time)))))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Metadata]) diff --git a/stdlib/source/test/aedifex/metadata/snapshot.lux b/stdlib/source/test/aedifex/metadata/snapshot.lux index 7cff9954a..a40ed0553 100644 --- a/stdlib/source/test/aedifex/metadata/snapshot.lux +++ b/stdlib/source/test/aedifex/metadata/snapshot.lux @@ -49,7 +49,7 @@ ["[1][0]" repository ["[1]/[0]" local]]]]]]) -(def: random_instant +(def random_instant (Random Instant) (do [! random.monad] [year (at ! each (|>> (n.% 9,000) (n.+ 1,000) .int) random.nat) @@ -70,7 +70,7 @@ time.#milli_second 0])] (in (instant.of_date_time date time))))))) -(def: random_versioning +(def random_versioning (Random Versioning) (all random.and (random#in {///snapshot.#Local}) @@ -78,14 +78,14 @@ (random.list 5 $///artifact/snapshot/version.random) )) -(def: .public random +(def .public random (Random /.Metadata) (all random.and $///artifact.random ..random_versioning )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Metadata]) diff --git a/stdlib/source/test/aedifex/package.lux b/stdlib/source/test/aedifex/package.lux index 2e669228a..42eded5a5 100644 --- a/stdlib/source/test/aedifex/package.lux +++ b/stdlib/source/test/aedifex/package.lux @@ -40,7 +40,7 @@ [repository ["[1][0]" origin]]]]]) -(def: .public random +(def .public random (Random [//.Profile /.Package]) (do [! random.monad] [content_size (at ! each (n.% 100) random.nat) @@ -53,7 +53,7 @@ $profile.random)] (in [profile (/.local pom content)]))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Package]) diff --git a/stdlib/source/test/aedifex/parser.lux b/stdlib/source/test/aedifex/parser.lux index 945576470..f887958b2 100644 --- a/stdlib/source/test/aedifex/parser.lux +++ b/stdlib/source/test/aedifex/parser.lux @@ -33,27 +33,27 @@ ["[1][0]" dependency (.only Dependency)] ["[1][0]" format]]]]) -(def: name +(def name (Random //.Name) (random.alphabetic 1)) -(def: (list_of random) +(def (list_of random) (All (_ a) (-> (Random a) (Random (List a)))) (do [! random.monad] [size (at ! each (n.% 5) random.nat)] (random.list size random))) -(def: (dictionary_of key_hash key_random value_random) +(def (dictionary_of key_hash key_random value_random) (All (_ k v) (-> (Hash k) (Random k) (Random v) (Random (Dictionary k v)))) (at random.functor each (dictionary.of_list key_hash) (..list_of (random.and key_random value_random)))) -(def: random +(def random (Random Project) (..dictionary_of text.hash ..name @profile.random)) -(def: with_default_sources +(def with_default_sources (-> //.Profile //.Profile) (revised //.#sources (is (-> (Set //.Source) (Set //.Source)) @@ -62,17 +62,17 @@ (set.of_list text.hash (list //.default_source)) sources))))) -(def: with_default_repository +(def with_default_repository (-> //.Profile //.Profile) (revised //.#repositories (set.has //.default_repository))) -(def: (with_empty_profile project) +(def (with_empty_profile project) (-> Project Project) (if (dictionary.empty? project) (//project.project //.default (at //.monoid identity)) project)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.covering //format._) diff --git a/stdlib/source/test/aedifex/pom.lux b/stdlib/source/test/aedifex/pom.lux index ab19c1c7f..e72eef0ef 100644 --- a/stdlib/source/test/aedifex/pom.lux +++ b/stdlib/source/test/aedifex/pom.lux @@ -22,7 +22,7 @@ ["/[1]" // ["[1]" profile]]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/aedifex/profile.lux b/stdlib/source/test/aedifex/profile.lux index 5a040973e..a71284333 100644 --- a/stdlib/source/test/aedifex/profile.lux +++ b/stdlib/source/test/aedifex/profile.lux @@ -39,62 +39,62 @@ [repository [remote (.only Address)]]]]]) -(def: distribution +(def distribution (Random /.Distribution) (random.or (random#in []) (random#in []))) -(def: license +(def license (Random /.License) (all random.and (random.alphabetic 1) (random.alphabetic 1) ..distribution)) -(def: scm +(def scm (Random /.SCM) (random.alphabetic 1)) -(def: organization +(def organization (Random /.Organization) (all random.and (random.alphabetic 1) (random.alphabetic 1))) -(def: email +(def email (Random /.Email) (random.alphabetic 1)) -(def: developer +(def developer (Random /.Developer) (all random.and (random.alphabetic 1) (random.alphabetic 1) (random.maybe organization))) -(def: contributor +(def contributor (Random /.Contributor) ..developer) -(def: (list_of random) +(def (list_of random) (All (_ a) (-> (Random a) (Random (List a)))) (do [! random.monad] [size (at ! each (n.% 5) random.nat)] (random.list size random))) -(def: (set_of hash random) +(def (set_of hash random) (All (_ a) (-> (Hash a) (Random a) (Random (Set a)))) (at random.functor each (set.of_list hash) (..list_of random))) -(def: (dictionary_of key_hash key_random value_random) +(def (dictionary_of key_hash key_random value_random) (All (_ k v) (-> (Hash k) (Random k) (Random v) (Random (Dictionary k v)))) (at random.functor each (dictionary.of_list key_hash) (..list_of (random.and key_random value_random)))) -(def: info +(def info (Random /.Info) (all random.and (random.maybe (random.alphabetic 1)) @@ -107,23 +107,23 @@ (..list_of ..contributor) )) -(def: name +(def name (Random /.Name) (random.alphabetic 1)) -(def: repository +(def repository (Random Address) (random.alphabetic 1)) -(def: source +(def source (Random /.Source) (random.alphabetic 1)) -(def: target +(def target (Random /.Target) (random.alphabetic 1)) -(def: .public random +(def .public random (Random /.Profile) (all random.and (..list_of ..name) @@ -147,7 +147,7 @@ (random#in //runtime.default_ruby) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Distribution /.License /.SCM /.Organization diff --git a/stdlib/source/test/aedifex/project.lux b/stdlib/source/test/aedifex/project.lux index d0f658040..e66284a31 100644 --- a/stdlib/source/test/aedifex/project.lux +++ b/stdlib/source/test/aedifex/project.lux @@ -24,19 +24,19 @@ ["/[1]" // ["[1]" profile]]]]) -(def: profile +(def profile (Random [//.Name //.Profile]) (|> @profile.random (random#each (has //.#parents (list))) (random.and (random.alphabetic 1)))) -(def: .public random +(def .public random (Random /.Project) (do random.monad [[name profile] ..profile] (in (/.project name profile)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Project /.project] diff --git a/stdlib/source/test/aedifex/repository.lux b/stdlib/source/test/aedifex/repository.lux index 6b4feec76..5ef8a77c8 100644 --- a/stdlib/source/test/aedifex/repository.lux +++ b/stdlib/source/test/aedifex/repository.lux @@ -38,7 +38,7 @@ ["[1][0]" artifact (.only Version Artifact) ["[1]/[0]" extension (.only Extension)]]]]]) -(def: artifact +(def artifact (-> Version Artifact) (|>> ["com.github.luxlang" "test-artifact"])) @@ -53,24 +53,24 @@ (type: Store (Dictionary URI Binary)) -(def: .public empty +(def .public empty Store (dictionary.empty text.hash)) -(def: valid_version +(def valid_version Version "1.2.3-YES") -(def: invalid_version +(def invalid_version Version "4.5.6-NO") -(def: .public mock +(def .public mock (/.Mock Store) (implementation - (def: the_description + (def the_description "@") - (def: (on_download uri state) + (def (on_download uri state) (case (dictionary.value uri state) {.#Some content} (case (binary.size content) @@ -79,12 +79,12 @@ {.#None} (exception.except ..not_found [uri]))) - (def: (on_upload uri content state) + (def (on_upload uri content state) (if (dictionary.key? state uri) (exception.except ..cannot_upload [uri]) {try.#Success (dictionary.has uri content state)})))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/aedifex/repository/identity.lux b/stdlib/source/test/aedifex/repository/identity.lux index b7ab8e23d..5b556db20 100644 --- a/stdlib/source/test/aedifex/repository/identity.lux +++ b/stdlib/source/test/aedifex/repository/identity.lux @@ -10,14 +10,14 @@ [\\program ["[0]" /]]) -(def: .public random +(def .public random (Random /.Identity) (all random.and (random.alphabetic 10) (random.alphabetic 10) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.User /.Password /.Identity] diff --git a/stdlib/source/test/aedifex/repository/local.lux b/stdlib/source/test/aedifex/repository/local.lux index 93bb28f1d..5a6be7777 100644 --- a/stdlib/source/test/aedifex/repository/local.lux +++ b/stdlib/source/test/aedifex/repository/local.lux @@ -23,7 +23,7 @@ [\\program ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/aedifex/repository/origin.lux b/stdlib/source/test/aedifex/repository/origin.lux index 0f0fe6191..a414c8371 100644 --- a/stdlib/source/test/aedifex/repository/origin.lux +++ b/stdlib/source/test/aedifex/repository/origin.lux @@ -10,14 +10,14 @@ [\\program ["[0]" /]]) -(def: .public random +(def .public random (Random /.Origin) (all random.or (random.alphabetic 10) (random.alphabetic 10) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Origin] diff --git a/stdlib/source/test/aedifex/repository/remote.lux b/stdlib/source/test/aedifex/repository/remote.lux index 75e9ff35e..1c16ddf09 100644 --- a/stdlib/source/test/aedifex/repository/remote.lux +++ b/stdlib/source/test/aedifex/repository/remote.lux @@ -31,16 +31,16 @@ ["/[1]" // ["[1][0]" identity]]]]) -(def: (url_body url) +(def (url_body url) (-> URL (@http.Body IO)) (let [url (at utf8.codec encoded url)] (function (_ _) (io.io {try.#Success [(binary.size url) url]})))) -(def: (good_http user password) +(def (good_http user password) (-> //identity.User //identity.Password (http.Client IO)) (implementation - (def: (request method url headers input) + (def (request method url headers input) (with_expansions [<failure> [http/status.bad_request [@http.#headers (http.headers (list)) @http.#body (..url_body "")]]] @@ -70,17 +70,17 @@ <failure>) <failure>)))))) -(def: bad_http +(def bad_http (http.Client IO) (implementation - (def: (request method url headers input) + (def (request method url headers input) (<| io.io {try.#Success} [http/status.bad_request [@http.#headers (http.headers (list)) @http.#body (..url_body "")]])))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/aedifex/runtime.lux b/stdlib/source/test/aedifex/runtime.lux index 58d539584..dfe5abfac 100644 --- a/stdlib/source/test/aedifex/runtime.lux +++ b/stdlib/source/test/aedifex/runtime.lux @@ -20,7 +20,7 @@ [\\program ["[0]" /]]) -(def: .public random +(def .public random (Random /.Runtime) (all random.either (random#in /.default_java) @@ -30,7 +30,7 @@ (random#in /.default_ruby) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Runtime]) diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index aa18015e5..71f03201e 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -75,7 +75,7 @@ (.~~ (.these))))] ]))) -(def: for_bit +(def for_bit Test (do random.monad [expected random.nat @@ -138,7 +138,7 @@ dummy)))) )))) -(def: for_try +(def for_try Test (do random.monad [expected_error (random.lower_case 5) @@ -167,7 +167,7 @@ false)) ))) -(def: for_list +(def for_list Test (do random.monad [e/0 random.nat @@ -190,23 +190,23 @@ (is (-> Any a) return))) -(def: (global_returner value) +(def (global_returner value) (All (_ a) (-> a (Returner a))) (/.implementation - (def: (return _) + (def (return _) value))) -(def: static_return 123) +(def static_return 123) (/.open: "global#[0]" (..global_returner ..static_return)) -(def: for_interface +(def for_interface Test (do random.monad [expected random.nat .let [local_returner (is (Returner Nat) (/.implementation - (def: (return _) + (def (return _) expected)))]] (_.for [/.Interface] (all _.and @@ -221,7 +221,7 @@ (n.= expected (/.at local_returner return []))) )))) -(def: for_module +(def for_module Test (all _.and (let [[module short] (/.symbol .example)] @@ -234,7 +234,7 @@ (not (text.contains? /.module_separator short))))) )) -(def: for_pipe +(def for_pipe Test (do random.monad [start random.nat @@ -255,15 +255,15 @@ ((/.<<| (n.* factor) ++) start))) ))) -(def: example_symbol "YOLO") -(def: i8 8) +(def example_symbol "YOLO") +(def i8 8) -(def: current_module +(def current_module Text (let [[module _] (symbol .._)] module)) -(def: for_code/' +(def for_code/' Test (do random.monad [example_nat random.nat] @@ -293,7 +293,7 @@ (/.' (~ (code.nat example_nat))))) )))) -(def: for_code/` +(def for_code/` Test (do random.monad [example_nat random.nat] @@ -322,7 +322,7 @@ (code#= (code.nat example_nat) (/.` (~ (code.nat example_nat)))))))) -(def: for_code/`' +(def for_code/`' Test (do random.monad [example_nat random.nat] @@ -351,7 +351,7 @@ (code#= (code.nat example_nat) (/.`' (~ (code.nat example_nat)))))))) -(def: for_code +(def for_code Test (do [! random.monad] [example (at ! each code.nat random.nat)] @@ -368,19 +368,19 @@ (location#= location.dummy))) ))) -(def: identity_macro +(def identity_macro (/.macro (_ tokens) (at meta.monad in tokens))) -(def: crosshair +(def crosshair "This is an arbitrary text whose only purpose is to be found, somewhere, in the source-code.") -(def: found_crosshair? +(def found_crosshair? (macro (_ tokens lux) (let [[_ _ source_code] (the .#source lux)] {.#Right [lux (list (code.bit (text.contains? ..crosshair source_code)))]}))) -(def: for_macro +(def for_macro Test (let [macro (is /.Macro' (function (_ tokens lux) @@ -522,7 +522,7 @@ (/.type: (for_type/all parameter) [parameter parameter]) -(def: for_type +(def for_type Test (do [! random.monad] [expected random.nat @@ -608,7 +608,7 @@ true)) )))) -(def: for_i64 +(def for_i64 Test (do random.monad [expected random.i64] @@ -633,7 +633,7 @@ expected))) ))) -(def: for_function +(def for_function Test (do random.monad [expected_left random.nat @@ -650,11 +650,11 @@ (n.= (n.* (++ expected_left) (-- expected_right)) (actual [expected_left expected_right]))))))) -(def: !n/+ +(def !n/+ (/.template (_ <left> <right>) [(n.+ <left> <right>)])) -(def: for_template +(def for_template Test (`` (all _.and (_.coverage [/.with_template] @@ -673,11 +673,11 @@ (!n/+ left right)))) ))) -(def: option/0 "0") -(def: option/1 "1") -(def: static_char "@") +(def option/0 "0") +(def option/1 "1") +(def static_char "@") -(def: for_static +(def for_static Test (do random.monad [sample (random.either (in option/0) @@ -704,7 +704,7 @@ [#big_left Nat #big_right Small])) -(def: for_slot +(def for_slot Test (do random.monad [start/s random.nat @@ -788,7 +788,7 @@ (n.= expected/s))))) ))) -(def: for_associative +(def for_associative Test (do random.monad [left (random.lower_case 1) @@ -809,7 +809,7 @@ (not (code#= (' <left_association>) (' <right_association>)))))))) -(def: for_expansion +(def for_expansion Test (do random.monad [left random.nat @@ -850,7 +850,7 @@ dummy)))) ))) -(def: for_value +(def for_value Test (do random.monad [left random.nat @@ -937,12 +937,12 @@ [#left l #right r])) -(def: !pair +(def !pair (template (_ <left> <right>) [[..#left <left> ..#right <right>]])) -(def: for_case +(def for_case Test (do [! random.monad] [expected_nat (at ! each (n.% 1) random.nat) @@ -998,7 +998,7 @@ (/.same? expected_int actual_right))))) ))) -(def: for_control_flow +(def for_control_flow Test (all _.and (do random.monad @@ -1023,24 +1023,24 @@ (same? post (io.run! (atom.read! box))))))) )) -(def: identity/constant +(def identity/constant (All (_ a) (-> a a)) (function (_ value) value)) -(def: (identity/function value) +(def (identity/function value) (All (_ a) (-> a a)) value) -(def: for_def: +(def for_def Test (do random.monad [expected random.nat] - (_.coverage [/.def:] + (_.coverage [/.def] (and (same? expected (identity/constant expected)) (same? expected (identity/function expected)))))) -(def: possible_targets +(def possible_targets (Set @.Target) (<| (set.of_list text.hash) (list @.old @@ -1050,7 +1050,7 @@ @.python @.ruby))) -(def: for_meta|Info +(def for_meta|Info (syntax (_ []) (function (_ lux) (let [info (the .#info lux) @@ -1065,7 +1065,7 @@ {.#Right [lux (list (code.bit (and conforming_target! compiling!)))]})))) -(def: for_meta|Module_State +(def for_meta|Module_State (syntax (_ []) (do meta.monad [prelude (meta.module .prelude)] @@ -1073,7 +1073,7 @@ {.#Active} false _ true))))))) -(def: for_meta +(def for_meta Test (all _.and (_.coverage [/.Mode /.Info] @@ -1082,7 +1082,7 @@ (for_meta|Module_State)) )) -(def: for_export +(def for_export Test (all _.and (_.coverage [/.public /.private] @@ -1093,7 +1093,7 @@ )) (for @.old (these) - (these (def: for_bindings|test + (these (def for_bindings|test (syntax (_ lux_state [fn/0 <code>.local var/0 <code>.local @@ -1154,7 +1154,7 @@ _ false)))))) - (def: for_bindings + (def for_bindings Test ((<| (template.with_locals [fn/0 var/0 let/0 fn/1 var/1 let/1 @@ -1174,7 +1174,7 @@ verdict))) 0 1 2)))) -(def: test|lux +(def test|lux Test (`` (`` (all _.and ..for_bit @@ -1196,14 +1196,14 @@ ..for_value ..for_case ..for_control_flow - ..for_def: + ..for_def ..for_meta ..for_export (~~ (for @.old (~~ (these)) (~~ (these ..for_bindings)))) )))) -(def: test +(def test Test (<| (_.covering /._) (`` (`` (_.in_parallel diff --git a/stdlib/source/test/lux/abstract.lux b/stdlib/source/test/lux/abstract.lux index b044876aa..a20f2f871 100644 --- a/stdlib/source/test/lux/abstract.lux +++ b/stdlib/source/test/lux/abstract.lux @@ -20,28 +20,28 @@ ["[1][0]" order] ["[1][0]" predicate]]) -(def: functor +(def functor Test (all _.and /functor.test /functor/contravariant.test )) -(def: monad +(def monad Test (all _.and /monad.test /monad/free.test )) -(def: comonad +(def comonad Test (all _.and /comonad.test /comonad/free.test )) -(def: .public test +(def .public test Test (all _.and /apply.test diff --git a/stdlib/source/test/lux/abstract/apply.lux b/stdlib/source/test/lux/abstract/apply.lux index d7845ae47..7eed1d6bc 100644 --- a/stdlib/source/test/lux/abstract/apply.lux +++ b/stdlib/source/test/lux/abstract/apply.lux @@ -16,7 +16,7 @@ [\\library ["[0]" / (.only Apply)]]) -(def: .public test +(def .public test Test (do random.monad [left random.nat diff --git a/stdlib/source/test/lux/abstract/codec.lux b/stdlib/source/test/lux/abstract/codec.lux index 6169669c5..8d70588c8 100644 --- a/stdlib/source/test/lux/abstract/codec.lux +++ b/stdlib/source/test/lux/abstract/codec.lux @@ -17,23 +17,23 @@ [// [equivalence (.only Equivalence)]]]]) -(def: json +(def json (Codec JSON Bit) (let [field "value"] (implementation - (def: encoded + (def encoded (|>> {json.#Boolean} [field] list json.object)) - (def: decoded + (def decoded (json.boolean_field field))))) -(def: codec +(def codec (Codec Text Bit) (/.composite json.codec ..json)) -(def: .public test +(def .public test Test (do random.monad [expected random.bit] diff --git a/stdlib/source/test/lux/abstract/comonad.lux b/stdlib/source/test/lux/abstract/comonad.lux index 450a1e1ae..9c752b46d 100644 --- a/stdlib/source/test/lux/abstract/comonad.lux +++ b/stdlib/source/test/lux/abstract/comonad.lux @@ -13,7 +13,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (do random.monad [sample random.nat] diff --git a/stdlib/source/test/lux/abstract/comonad/free.lux b/stdlib/source/test/lux/abstract/comonad/free.lux index 9c84654c2..093f5eda1 100644 --- a/stdlib/source/test/lux/abstract/comonad/free.lux +++ b/stdlib/source/test/lux/abstract/comonad/free.lux @@ -19,25 +19,25 @@ [\\library ["[0]" /]]) -(def: (injection value) +(def (injection value) (Injection (/.Free Stream)) [value (stream#each injection (stream.repeated value))]) -(def: (interpret [head tail]) +(def (interpret [head tail]) (All (_ a) (-> (/.Free Stream a) (Stream a))) (|> tail (stream#each (at (/.comonad stream.functor) out)) [head] //.pending)) -(def: comparison +(def comparison (Comparison (/.Free Stream)) (function (_ == left right) (at (list.equivalence ==) = (stream.first 100 (..interpret left)) (stream.first 100 (..interpret right))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Free]) diff --git a/stdlib/source/test/lux/abstract/enum.lux b/stdlib/source/test/lux/abstract/enum.lux index 9848653ba..98a139603 100644 --- a/stdlib/source/test/lux/abstract/enum.lux +++ b/stdlib/source/test/lux/abstract/enum.lux @@ -17,7 +17,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (let [limit (is (Random Nat) (at random.monad each (n.% 20) random.nat))] diff --git a/stdlib/source/test/lux/abstract/equivalence.lux b/stdlib/source/test/lux/abstract/equivalence.lux index 7740565ed..339279e00 100644 --- a/stdlib/source/test/lux/abstract/equivalence.lux +++ b/stdlib/source/test/lux/abstract/equivalence.lux @@ -49,14 +49,14 @@ #tuple [Int Frac Text] #recursive Recursive])) -(def: gen_recursive +(def gen_recursive (Random Recursive) (random.rec (function (_ gen_recursive) (random.or random.safe_frac (random.and random.safe_frac gen_recursive))))) -(def: random +(def random (Random Record) (do [! random.monad] [size (at ! each (n.% 2) random.nat) @@ -79,18 +79,18 @@ gen_recursive))) (for @.old (these) - (these (def: equivalence + (these (def equivalence (Equivalence ..Record) (\\polytypic.equivalence ..Record)))) -(def: \\polytypic +(def \\polytypic Test (<| (_.covering \\polytypic._) (_.for [\\polytypic.equivalence] (for @.old (_.property "PLACEHOLDER" true) (\\specification.spec ..equivalence ..random))))) -(def: .public test +(def .public test Test (do random.monad [leftN random.nat @@ -101,7 +101,7 @@ different (|> random.nat (random.only (|>> (n.= sample) not))) .let [equivalence (is (Equivalence (Equivalence Nat)) (implementation - (def: (= left right) + (def (= left right) (and (bit#= (at left = leftN leftN) (at right = leftN leftN)) (bit#= (at left = rightN rightN) @@ -116,7 +116,7 @@ (let [equivalence (is (Equivalence (List Nat)) (/.rec (function (_ equivalence) (implementation - (def: (= left right) + (def (= left right) (case [left right] [{.#End} {.#End}] true diff --git a/stdlib/source/test/lux/abstract/functor.lux b/stdlib/source/test/lux/abstract/functor.lux index 5bef11061..33a1df347 100644 --- a/stdlib/source/test/lux/abstract/functor.lux +++ b/stdlib/source/test/lux/abstract/functor.lux @@ -21,29 +21,29 @@ ["[0]" / (.only Functor)]]) (for @.old (these) - (these (def: maybe_functor + (these (def maybe_functor (Functor .Maybe) (\\polytypic.functor .Maybe)) - (def: list_functor + (def list_functor (Functor .List) (\\polytypic.functor .List)) - (def: state_functor + (def state_functor (All (_ s) (Functor (state.State s))) (\\polytypic.functor state.State)) - (def: identity_functor + (def identity_functor (Functor identity.Identity) (\\polytypic.functor identity.Identity)))) -(def: \\polytypic +(def \\polytypic Test (<| (_.covering \\polytypic._) (_.coverage [\\polytypic.functor] true))) -(def: .public test +(def .public test Test (do random.monad [left random.nat diff --git a/stdlib/source/test/lux/abstract/functor/contravariant.lux b/stdlib/source/test/lux/abstract/functor/contravariant.lux index a23aee828..12b95bf9d 100644 --- a/stdlib/source/test/lux/abstract/functor/contravariant.lux +++ b/stdlib/source/test/lux/abstract/functor/contravariant.lux @@ -5,7 +5,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.in_parallel (list)))) diff --git a/stdlib/source/test/lux/abstract/hash.lux b/stdlib/source/test/lux/abstract/hash.lux index cd9a966da..153cd1ec2 100644 --- a/stdlib/source/test/lux/abstract/hash.lux +++ b/stdlib/source/test/lux/abstract/hash.lux @@ -18,14 +18,14 @@ [// [equivalence (.only Equivalence)]]]]) -(def: .public test +(def .public test Test (do random.monad [leftN random.nat rightN random.nat .let [hash (is (Equivalence (/.Hash Nat)) (implementation - (def: (= (open "left#[0]") (open "right#[0]")) + (def (= (open "left#[0]") (open "right#[0]")) (and (bit#= (left#= (left#hash leftN) (left#hash leftN)) (right#= (right#hash leftN) (right#hash leftN))) (bit#= (left#= (left#hash rightN) (left#hash rightN)) diff --git a/stdlib/source/test/lux/abstract/interval.lux b/stdlib/source/test/lux/abstract/interval.lux index 9917756e8..30ac69ccc 100644 --- a/stdlib/source/test/lux/abstract/interval.lux +++ b/stdlib/source/test/lux/abstract/interval.lux @@ -21,7 +21,7 @@ ["[0]" / (.only Interval) (.open: "[1]#[0]" equivalence)]]) (with_template [<name> <cmp>] - [(def: .public <name> + [(def .public <name> (Random (Interval Nat)) (do random.monad [bottom random.nat @@ -35,20 +35,20 @@ [outer n.>] ) -(def: .public singleton +(def .public singleton (Random (Interval Nat)) (do random.monad [point random.nat] (in (/.singleton n.enum point)))) -(def: .public interval +(def .public interval (Random (Interval Nat)) (all random.either ..inner ..outer ..singleton)) -(def: types +(def types Test (do random.monad [inner ..inner @@ -63,7 +63,7 @@ (/.singleton? singleton)) ))) -(def: boundaries +(def boundaries Test (do random.monad [bottom random.nat @@ -82,7 +82,7 @@ (/.borders? interval top))) ))) -(def: union +(def union Test (do random.monad [some_interval ..interval @@ -103,7 +103,7 @@ (/.inner? (/.union left_outer right_outer)))) ))) -(def: intersection +(def intersection Test (do random.monad [some_interval ..interval @@ -124,7 +124,7 @@ (/.outer? (/.intersection left_outer right_outer))) ))) -(def: complement +(def complement Test (do random.monad [some_interval ..interval] @@ -135,7 +135,7 @@ (not (/.overlaps? some_interval (/.complement some_interval)))) ))) -(def: location +(def location Test (do [! random.monad] [[l m r] (|> (random.set n.hash 3 random.nat) @@ -158,7 +158,7 @@ (/.after? m right))) ))) -(def: touch +(def touch Test (do [! random.monad] [[b t1 t2] (|> (random.set n.hash 3 random.nat) @@ -185,7 +185,7 @@ (/.between n.enum t1 t2))) ))) -(def: nested +(def nested Test (do [! random.monad] [some_interval ..interval @@ -219,7 +219,7 @@ (/.nested? outer right_inner)))) ))) -(def: overlap +(def overlap Test (do [! random.monad] [some_interval ..interval @@ -248,7 +248,7 @@ (/.overlaps? outer right_inner)))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/abstract/mix.lux b/stdlib/source/test/lux/abstract/mix.lux index 42fba9a6c..8754df110 100644 --- a/stdlib/source/test/lux/abstract/mix.lux +++ b/stdlib/source/test/lux/abstract/mix.lux @@ -14,7 +14,7 @@ [\\library ["[0]" / (.only Mix)]]) -(def: .public test +(def .public test Test (do random.monad [samples (random.list 10 random.nat)] diff --git a/stdlib/source/test/lux/abstract/monad.lux b/stdlib/source/test/lux/abstract/monad.lux index 7ea1093aa..7cfe4f080 100644 --- a/stdlib/source/test/lux/abstract/monad.lux +++ b/stdlib/source/test/lux/abstract/monad.lux @@ -13,7 +13,7 @@ [\\library ["[0]" / (.only Monad do)]]) -(def: .public test +(def .public test Test (do random.monad [mono random.nat diff --git a/stdlib/source/test/lux/abstract/monad/free.lux b/stdlib/source/test/lux/abstract/monad/free.lux index d98fb1cbd..8031bf189 100644 --- a/stdlib/source/test/lux/abstract/monad/free.lux +++ b/stdlib/source/test/lux/abstract/monad/free.lux @@ -18,11 +18,11 @@ [\\library ["[0]" /]]) -(def: injection +(def injection (Injection (/.Free List)) (|>> {/.#Pure})) -(def: (interpret free) +(def (interpret free) (All (_ a) (-> (/.Free List a) (List a))) (case free {/.#Pure value} @@ -33,14 +33,14 @@ (list#each interpret) list.together))) -(def: comparison +(def comparison (Comparison (/.Free List)) (function (_ == left right) (at (list.equivalence ==) = (..interpret left) (..interpret right)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Free]) diff --git a/stdlib/source/test/lux/abstract/monoid.lux b/stdlib/source/test/lux/abstract/monoid.lux index 0b30b882c..75a5f6863 100644 --- a/stdlib/source/test/lux/abstract/monoid.lux +++ b/stdlib/source/test/lux/abstract/monoid.lux @@ -14,7 +14,7 @@ [// [equivalence (.only Equivalence)]]]]) -(def: .public test +(def .public test Test (do random.monad [natL random.nat diff --git a/stdlib/source/test/lux/abstract/order.lux b/stdlib/source/test/lux/abstract/order.lux index d8792eafa..941c9cccb 100644 --- a/stdlib/source/test/lux/abstract/order.lux +++ b/stdlib/source/test/lux/abstract/order.lux @@ -18,7 +18,7 @@ [// [equivalence (.only Equivalence)]]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad @@ -26,7 +26,7 @@ right (|> random.nat (random.only (|>> (n.= left) not))) .let [equivalence (is (Equivalence (/.Order Nat)) (implementation - (def: (= leftO rightO) + (def (= leftO rightO) (and (bit#= (at leftO < left left) (at rightO < left left)) (bit#= (at leftO < right right) diff --git a/stdlib/source/test/lux/abstract/predicate.lux b/stdlib/source/test/lux/abstract/predicate.lux index 9fb8bd1a5..1d1839804 100644 --- a/stdlib/source/test/lux/abstract/predicate.lux +++ b/stdlib/source/test/lux/abstract/predicate.lux @@ -22,13 +22,13 @@ [\\library ["[0]" /]]) -(def: (multiple? factor) +(def (multiple? factor) (-> Nat (/.Predicate Nat)) (case factor 0 (function.constant false) _ (|>> (n.% factor) (n.= 0)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] @@ -36,7 +36,7 @@ samples (random.list 10 random.nat) .let [equivalence (is (Equivalence (/.Predicate Nat)) (implementation - (def: (= left right) + (def (= left right) (bit#= (left sample) (right sample)))))]]) (_.for [/.Predicate]) diff --git a/stdlib/source/test/lux/control.lux b/stdlib/source/test/lux/control.lux index 3fff75e05..0f99b21b2 100644 --- a/stdlib/source/test/lux/control.lux +++ b/stdlib/source/test/lux/control.lux @@ -31,7 +31,7 @@ ["[1][0]" try] ["[1][0]" writer]]) -(def: concurrency +(def concurrency Test (all _.and /concurrency/actor.test @@ -43,14 +43,14 @@ /concurrency/stm.test )) -(def: security +(def security Test (all _.and /policy.test /capability.test )) -(def: .public test +(def .public test Test (all _.and /concatenative.test diff --git a/stdlib/source/test/lux/control/concatenative.lux b/stdlib/source/test/lux/control/concatenative.lux index 4092dbd0d..26e98f649 100644 --- a/stdlib/source/test/lux/control/concatenative.lux +++ b/stdlib/source/test/lux/control/concatenative.lux @@ -19,7 +19,7 @@ [\\library ["[0]" / (.only =>)]]) -(def: stack_shuffling +(def stack_shuffling Test (do random.monad [sample random.nat @@ -91,7 +91,7 @@ /.drop /.drop)))) )))) -(def: !numerical +(def !numerical (template (_ <=> <generator> <only> <arithmetic> <order>) [(is Test (with_expansions [<arithmetic>' (template.spliced <arithmetic>) @@ -118,7 +118,7 @@ <order>')) )))))])) -(def: numerical +(def numerical Test (all _.and (!numerical n.= random.nat (|>> (n.= 0) not) @@ -135,7 +135,7 @@ [[/.f/= f.=] [/.f/< f.<] [/.f/<= f.<=] [/.f/> f.>] [/.f/>= f.>=]]) )) -(def: control_flow +(def control_flow Test (do random.monad [choice random.bit @@ -296,12 +296,12 @@ /.?)))) ))) -(def: square +(def square (=> [Nat] [Nat]) (|>> /.dup (/.apply_2 n.*))) -(def: definition +(def definition Test (do random.monad [sample random.nat] @@ -310,7 +310,7 @@ (/.value (|>> (/.push sample) ..square)))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/control/concurrency/actor.lux b/stdlib/source/test/lux/control/concurrency/actor.lux index 4570a3708..db84ea614 100644 --- a/stdlib/source/test/lux/control/concurrency/actor.lux +++ b/stdlib/source/test/lux/control/concurrency/actor.lux @@ -27,24 +27,24 @@ (exception: got_wrecked) -(def: counter +(def counter (/.Behavior Nat) (function (_ message state self) (message state self))) -(def: (count! increment) +(def (count! increment) (-> Nat (/.Message Nat Nat)) (function (_ state self) (let [state' (n.+ increment state)] (async#in {try.#Success [state' state']})))) -(def: (mailed? outcome) +(def (mailed? outcome) (-> (Try Any) Bit) (case outcome {try.#Success _} true {try.#Failure _} false)) -(def: .public test +(def .public test Test (do [! random.monad] [initial_state random.nat diff --git a/stdlib/source/test/lux/control/concurrency/async.lux b/stdlib/source/test/lux/control/concurrency/async.lux index 1e343c32d..2be98d4d2 100644 --- a/stdlib/source/test/lux/control/concurrency/async.lux +++ b/stdlib/source/test/lux/control/concurrency/async.lux @@ -25,11 +25,11 @@ [// ["[0]" atom (.only Atom)]]]]) -(def: injection +(def injection (Injection /.Async) /.resolved) -(def: comparison +(def comparison (Comparison /.Async) (function (_ == left right) (io.run! @@ -44,11 +44,11 @@ _ false)))))) -(def: delay +(def delay (for @.js (i64.left_shifted 4 1) (i64.left_shifted 3 1))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/control/concurrency/atom.lux b/stdlib/source/test/lux/control/concurrency/atom.lux index 2654e109a..21dbe86d5 100644 --- a/stdlib/source/test/lux/control/concurrency/atom.lux +++ b/stdlib/source/test/lux/control/concurrency/atom.lux @@ -13,7 +13,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/control/concurrency/frp.lux b/stdlib/source/test/lux/control/concurrency/frp.lux index 004659886..e2e8c286d 100644 --- a/stdlib/source/test/lux/control/concurrency/frp.lux +++ b/stdlib/source/test/lux/control/concurrency/frp.lux @@ -28,12 +28,12 @@ ["[0]" async (.only Async) (.open: "[1]#[0]" monad)] ["[0]" atom (.only Atom atom)]]]]) -(def: injection +(def injection (Injection /.Channel) (|>> async.resolved /.of_async)) -(def: comparison +(def comparison (Comparison /.Channel) (function (_ == left right) (io.run! @@ -48,7 +48,7 @@ _ false)))))) -(def: (take_amount amount_of_polls [channel sink]) +(def (take_amount amount_of_polls [channel sink]) (All (_ a) (-> Nat [(/.Channel a) (/.Sink a)] (Async (List a)))) (case amount_of_polls 0 (do async.monad @@ -64,7 +64,7 @@ (at ! each (|>> {.#Item (variance.read head)}) (take_amount (-- amount_of_polls) [channel sink])))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (let [(open "list#[0]") (list.equivalence n.equivalence)] diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux index e71f42484..65eef901f 100644 --- a/stdlib/source/test/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux @@ -29,11 +29,11 @@ [\\library ["[0]" /]]) -(def: delay +(def delay (for @.js (i64.left_shifted 4 1) (i64.left_shifted 3 1))) -(def: semaphore +(def semaphore Test (_.for [/.Semaphore] (all _.and @@ -92,7 +92,7 @@ false))))) ))) -(def: mutex +(def mutex Test (_.for [/.Mutex] (all _.and @@ -129,14 +129,14 @@ outcome)))))) ))) -(def: (waiter resource barrier id) +(def (waiter resource barrier id) (-> (Atom Text) /.Barrier Nat (Async Any)) (do async.monad [_ (/.block! barrier) _ (async.future (atom.update! (|>> (format (%.nat id))) resource))] (in []))) -(def: barrier +(def barrier Test (_.for [/.Barrier] (all _.and @@ -177,7 +177,7 @@ expected_ids)))))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/control/concurrency/stm.lux b/stdlib/source/test/lux/control/concurrency/stm.lux index a06248ba1..3400840ff 100644 --- a/stdlib/source/test/lux/control/concurrency/stm.lux +++ b/stdlib/source/test/lux/control/concurrency/stm.lux @@ -25,17 +25,17 @@ ["[0]" async] ["[0]" frp (.only Channel)]]]]) -(def: injection +(def injection (Injection /.STM) (at /.monad in)) -(def: comparison +(def comparison (Comparison /.STM) (function (_ == left right) (== (product.right (left (list))) (product.right (right (list)))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/control/concurrency/thread.lux b/stdlib/source/test/lux/control/concurrency/thread.lux index 7ed7aff8c..e9e9f0c03 100644 --- a/stdlib/source/test/lux/control/concurrency/thread.lux +++ b/stdlib/source/test/lux/control/concurrency/thread.lux @@ -20,7 +20,7 @@ ["[0]" atom (.only Atom)] ["[0]" async]]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/control/continuation.lux b/stdlib/source/test/lux/control/continuation.lux index 94b90e540..b0055b0b3 100644 --- a/stdlib/source/test/lux/control/continuation.lux +++ b/stdlib/source/test/lux/control/continuation.lux @@ -18,16 +18,16 @@ [\\library ["[0]" /]]) -(def: injection +(def injection (All (_ o) (Injection (All (_ i) (/.Cont i o)))) (|>> /.pending)) -(def: comparison +(def comparison (Comparison /.Cont) (function (_ == left right) (== (/.result left) (/.result right)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/lux/control/exception.lux b/stdlib/source/test/lux/control/exception.lux index 8dcdb7ec6..b755a370b 100644 --- a/stdlib/source/test/lux/control/exception.lux +++ b/stdlib/source/test/lux/control/exception.lux @@ -19,11 +19,11 @@ (exception: an_exception) (exception: another_exception) -(def: label "YOLO") +(def label "YOLO") (exception: (custom_exception [value Nat]) (/.report label (%.nat value))) -(def: .public test +(def .public test Test (do [! random.monad] [expected random.nat diff --git a/stdlib/source/test/lux/control/function.lux b/stdlib/source/test/lux/control/function.lux index 4a95a0065..e867ccdfd 100644 --- a/stdlib/source/test/lux/control/function.lux +++ b/stdlib/source/test/lux/control/function.lux @@ -20,7 +20,7 @@ ["[1][0]" mutual] ["[1][0]" inline]]) -(def: .public test +(def .public test Test (do [! random.monad] [expected random.nat @@ -32,7 +32,7 @@ (all _.and (let [equivalence (is (Equivalence (-> Nat Nat)) (implementation - (def: (= left right) + (def (= left right) (n.= (left extra) (right extra))))) generator (is (Random (-> Nat Nat)) diff --git a/stdlib/source/test/lux/control/function/contract.lux b/stdlib/source/test/lux/control/function/contract.lux index 84b1f52d9..ea99016d5 100644 --- a/stdlib/source/test/lux/control/function/contract.lux +++ b/stdlib/source/test/lux/control/function/contract.lux @@ -16,7 +16,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/control/function/inline.lux b/stdlib/source/test/lux/control/function/inline.lux index 6bd4eee3e..ed01e9b0c 100644 --- a/stdlib/source/test/lux/control/function/inline.lux +++ b/stdlib/source/test/lux/control/function/inline.lux @@ -11,15 +11,15 @@ [\\library ["[0]" /]]) -(def: !quadrance/2 +(def !quadrance/2 (template (_ m0 m1) [(i.+ (i.* m0 m0) (i.* m1 m1))])) -(/.inline: .public (quadrance/2 m0 m1) +(/.inlined .public (quadrance/2 m0 m1) (-> Int Int Int) (!quadrance/2 m0 m1)) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] @@ -27,7 +27,7 @@ m0 measurement m1 measurement]) (all _.and - (_.coverage [/.inline:] + (_.coverage [/.inlined] (i.= (..!quadrance/2 m0 m1) (..quadrance/2 m0 m1))) ))) diff --git a/stdlib/source/test/lux/control/function/memo.lux b/stdlib/source/test/lux/control/function/memo.lux index 3a74921cf..093f32626 100644 --- a/stdlib/source/test/lux/control/function/memo.lux +++ b/stdlib/source/test/lux/control/function/memo.lux @@ -27,7 +27,7 @@ ["/[1]" // ["[1]" mixin]]]]) -(def: (fibonacci again input) +(def (fibonacci again input) (/.Memo Nat Nat) (case input 0 (state#in 0) @@ -37,7 +37,7 @@ output_2 (again (n.- 2 input))] (in (n.+ output_1 output_2))))) -(def: (time function input) +(def (time function input) (All (_ i o) (-> (-> i o) i (IO [Duration o]))) (do io.monad [before instant.now @@ -46,17 +46,17 @@ (in [(instant.span before after) output]))) -(def: milli_seconds +(def milli_seconds (-> Duration Nat) (|>> (duration.ticks duration.milli_second) .nat)) ... the wiggle room is there to account for GC pauses ... and other issues that might mess with duration -(def: wiggle_room +(def wiggle_room Nat (i64.left_shifted 4 1)) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/control/function/mixin.lux b/stdlib/source/test/lux/control/function/mixin.lux index 02ea34ad3..3e03102fd 100644 --- a/stdlib/source/test/lux/control/function/mixin.lux +++ b/stdlib/source/test/lux/control/function/mixin.lux @@ -23,7 +23,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] @@ -32,7 +32,7 @@ shift (|> random.nat (random.only (|>> (n.= dummy) not))) .let [equivalence (is (Equivalence (/.Mixin Nat Nat)) (implementation - (def: (= left right) + (def (= left right) (n.= ((/.fixed left) input) ((/.fixed right) input))))) generator (is (Random (/.Mixin Nat Nat)) diff --git a/stdlib/source/test/lux/control/function/mutual.lux b/stdlib/source/test/lux/control/function/mutual.lux index a263e5c96..433c51b7e 100644 --- a/stdlib/source/test/lux/control/function/mutual.lux +++ b/stdlib/source/test/lux/control/function/mutual.lux @@ -15,7 +15,7 @@ [\\library ["[0]" /]]) -(def: test_let +(def test_let Test (do [! random.monad] [sample (at ! each (n.% 10) random.nat) @@ -35,7 +35,7 @@ (and (bit#= expected (even? sample)) (bit#= (not expected) (odd? sample))))))) -(/.def: +(/.def [(even? number) (-> Nat Bit) (case number @@ -48,16 +48,16 @@ 0 false _ (even? (-- number)))]) -(def: test_def +(def test_def Test (do [! random.monad] [sample (at ! each (n.% 10) random.nat) .let [expected (n.even? sample)]] - (<| (_.coverage [/.def:]) + (<| (_.coverage [/.def]) (and (bit#= expected (..even? sample)) (bit#= (not expected) (..odd? sample)))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/control/io.lux b/stdlib/source/test/lux/control/io.lux index bee5da8db..6260f5a74 100644 --- a/stdlib/source/test/lux/control/io.lux +++ b/stdlib/source/test/lux/control/io.lux @@ -17,16 +17,16 @@ [// ["[0]" function]]]]) -(def: injection +(def injection (Injection IO) (|>> /.io)) -(def: comparison +(def comparison (Comparison IO) (function (_ == left right) (== (/.run! left) (/.run! right)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.IO]) diff --git a/stdlib/source/test/lux/control/lazy.lux b/stdlib/source/test/lux/control/lazy.lux index 26e1baba6..5c9551f71 100644 --- a/stdlib/source/test/lux/control/lazy.lux +++ b/stdlib/source/test/lux/control/lazy.lux @@ -18,20 +18,20 @@ [\\library ["[0]" / (.only Lazy)]]) -(def: injection +(def injection (Injection Lazy) (|>> /.lazy)) -(def: comparison +(def comparison (Comparison Lazy) (function (_ ==) (at (/.equivalence ==) =))) -(def: .public lazy +(def .public lazy (All (_ a) (-> (Random a) (Random (Lazy a)))) (at random.functor each (|>> /.lazy))) -(def: .public test +(def .public test Test (with_expansions [<eager> (is [Nat Nat] [(n.+ left right) diff --git a/stdlib/source/test/lux/control/maybe.lux b/stdlib/source/test/lux/control/maybe.lux index 7b5c61659..1ca6c8498 100644 --- a/stdlib/source/test/lux/control/maybe.lux +++ b/stdlib/source/test/lux/control/maybe.lux @@ -25,7 +25,7 @@ [\\library ["[0]" / (.open: "[1]#[0]" monoid monad)]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [.Maybe]) diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index cca247004..8bd0632d5 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -36,7 +36,7 @@ ["[1][0]" type] ["[1][0]" xml]]) -(def: (should_fail expected input) +(def (should_fail expected input) (All (_ a) (-> Text (Try a) Bit)) (case input {try.#Failure actual} @@ -45,7 +45,7 @@ _ #0)) -(def: (enforced? parser input) +(def (enforced? parser input) (All (_ s) (-> (Parser s Any) s Bit)) (case (/.result parser input) {try.#Success [_ []]} @@ -54,7 +54,7 @@ _ #0)) -(def: (found? parser input) +(def (found? parser input) (All (_ s) (-> (Parser s Bit) s Bit)) (case (/.result parser input) {try.#Success [_ #1]} @@ -63,7 +63,7 @@ _ #0)) -(def: (fails? input) +(def (fails? input) (All (_ a) (-> (Try a) Bit)) (case input {try.#Failure _} @@ -72,7 +72,7 @@ _ #0)) -(def: match +(def match (syntax (_ [pattern <code>.any then <code>.any input <code>.any]) @@ -83,7 +83,7 @@ (~' _) #0)))))) -(def: combinators_0 +(def combinators_0 Test (do [! random.monad] [expected0 random.nat @@ -174,7 +174,7 @@ (match [] #1)))) ))) -(def: combinators_1 +(def combinators_1 Test (do [! random.monad] [variadic (at ! each (|>> (n.max 1) (n.min 20)) random.nat) @@ -253,7 +253,7 @@ )) ))) -(def: combinators_2 +(def combinators_2 Test (do random.monad [expected random.nat @@ -327,11 +327,11 @@ (match actual (n.= expected actual)))) ))) -(def: injection +(def injection (Injection (All (_ a i) (Parser i a))) (at /.monad in)) -(def: comparison +(def comparison (Comparison (All (_ a i) (Parser i a))) (function (_ == left right) (case [(/.result left []) (/.result right [])] @@ -341,7 +341,7 @@ _ false))) -(def: .public test +(def .public test Test (do random.monad [expected random.nat diff --git a/stdlib/source/test/lux/control/parser/cli.lux b/stdlib/source/test/lux/control/parser/cli.lux index 686207191..c0d0ba4f6 100644 --- a/stdlib/source/test/lux/control/parser/cli.lux +++ b/stdlib/source/test/lux/control/parser/cli.lux @@ -20,7 +20,7 @@ [\\library ["[0]" /]]) -(def: !expect +(def !expect (template (_ <pattern> <value>) [(case <value> <pattern> @@ -29,7 +29,7 @@ _ false)])) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Parser]) diff --git a/stdlib/source/test/lux/control/parser/code.lux b/stdlib/source/test/lux/control/parser/code.lux index c0fecf490..959285faa 100644 --- a/stdlib/source/test/lux/control/parser/code.lux +++ b/stdlib/source/test/lux/control/parser/code.lux @@ -28,7 +28,7 @@ [\\library ["[0]" /]]) -(def: !expect +(def !expect (template (_ <pattern> <value>) [(case <value> <pattern> @@ -37,18 +37,18 @@ _ false)])) -(def: local +(def local (Random Text) (random.lower_case 1)) -(def: global +(def global (Random Symbol) (all random.and (random.lower_case 1) (random.lower_case 1) )) -(def: any_symbol +(def any_symbol (Random Symbol) (all random.either (random#each (|>> [""]) @@ -56,7 +56,7 @@ ..global )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Parser]) diff --git a/stdlib/source/test/lux/control/parser/environment.lux b/stdlib/source/test/lux/control/parser/environment.lux index d009918c4..ad4bb4711 100644 --- a/stdlib/source/test/lux/control/parser/environment.lux +++ b/stdlib/source/test/lux/control/parser/environment.lux @@ -19,7 +19,7 @@ ["[0]" / (.only) ["/[1]" // (.open: "[1]#[0]" monad)]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Environment /.Parser]) diff --git a/stdlib/source/test/lux/control/parser/json.lux b/stdlib/source/test/lux/control/parser/json.lux index 15b110eed..cf4faf7c4 100644 --- a/stdlib/source/test/lux/control/parser/json.lux +++ b/stdlib/source/test/lux/control/parser/json.lux @@ -30,7 +30,7 @@ [\\library ["[0]" /]]) -(def: !expect +(def !expect (template (_ <pattern> <value>) [(case <value> <pattern> @@ -39,11 +39,11 @@ _ false)])) -(def: safe_frac +(def safe_frac (Random Frac) (random.only (|>> frac.not_a_number? not) random.frac)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Parser]) diff --git a/stdlib/source/test/lux/control/parser/tree.lux b/stdlib/source/test/lux/control/parser/tree.lux index f10b11b26..9564e58e1 100644 --- a/stdlib/source/test/lux/control/parser/tree.lux +++ b/stdlib/source/test/lux/control/parser/tree.lux @@ -21,7 +21,7 @@ ["[0]" / (.only) ["/[1]" //]]]) -(def: !expect +(def !expect (template (_ <pattern> <value>) [(case <value> <pattern> @@ -30,7 +30,7 @@ _ false)])) -(def: !cover +(def !cover (template (_ <coverage> <parser> <sample>) [(do [! random.monad] [dummy random.nat @@ -41,7 +41,7 @@ (!expect (^.multi {try.#Success actual} (n.= expected actual))))))])) -(def: !cover/2 +(def !cover/2 (template (_ <coverage> <parser> <sample0> <sample1>) [(do [! random.monad] [dummy random.nat @@ -54,7 +54,7 @@ (!expect (^.multi {try.#Success actual} (n.= expected actual)))))))])) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Parser]) diff --git a/stdlib/source/test/lux/control/parser/type.lux b/stdlib/source/test/lux/control/parser/type.lux index 43935a76f..4764eb381 100644 --- a/stdlib/source/test/lux/control/parser/type.lux +++ b/stdlib/source/test/lux/control/parser/type.lux @@ -25,7 +25,7 @@ ["[0]" / (.only) ["/[1]" //]]]) -(def: !expect +(def !expect (template (_ <pattern> <value>) [(case <value> <pattern> @@ -34,13 +34,13 @@ _ false)])) -(def: primitive +(def primitive (Random Type) (|> (random.alpha_numeric 1) (at random.monad each (function (_ name) {.#Primitive name (list)})))) -(def: test|matches +(def test|matches Test (<| (_.for [/.types_do_not_match]) (do [! random.monad] @@ -76,7 +76,7 @@ (exception.match? /.types_do_not_match error)))))) ))) -(def: test|aggregate +(def test|aggregate Test (do [! random.monad] [expected_left ..primitive @@ -124,7 +124,7 @@ (exception.match? /.not_application error)))))) )))) -(def: test|parameter +(def test|parameter Test (do random.monad [quantification ..primitive @@ -185,7 +185,7 @@ (!expect {try.#Success [quantification::binding argument::binding _]}))) ))) -(def: test|polymorphic +(def test|polymorphic Test (do [! random.monad] [not_polymorphic ..primitive @@ -208,7 +208,7 @@ (same? not_polymorphic bodyT)))))) ))) -(def: test|recursive +(def test|recursive Test (do random.monad [expected ..primitive] @@ -238,7 +238,7 @@ (exception.match? /.not_recursive error)))))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Parser]) diff --git a/stdlib/source/test/lux/control/parser/xml.lux b/stdlib/source/test/lux/control/parser/xml.lux index 818f48a14..b671c071e 100644 --- a/stdlib/source/test/lux/control/parser/xml.lux +++ b/stdlib/source/test/lux/control/parser/xml.lux @@ -28,7 +28,7 @@ ["[0]" / (.only) ["/[1]" // (.open: "[1]#[0]" monad)]]]) -(def: !expect +(def !expect (template (_ <pattern> <value>) [(case <value> <pattern> @@ -37,7 +37,7 @@ _ false)])) -(def: !failure +(def !failure (template (_ <exception> <cases>) [(with_expansions [<<cases>> (template.spliced <cases>)] (do [! random.monad] @@ -50,15 +50,15 @@ <<cases>>)))))))])) -(def: random_label +(def random_label (Random Symbol) (random.and (random.alphabetic 1) (random.alphabetic 1))) -(def: random_tag ..random_label) -(def: random_attribute ..random_label) +(def random_tag ..random_label) +(def random_attribute ..random_label) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Parser]) diff --git a/stdlib/source/test/lux/control/pipe.lux b/stdlib/source/test/lux/control/pipe.lux index 3bee082a9..e818021a2 100644 --- a/stdlib/source/test/lux/control/pipe.lux +++ b/stdlib/source/test/lux/control/pipe.lux @@ -16,7 +16,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/control/reader.lux b/stdlib/source/test/lux/control/reader.lux index cfe5fe76b..57d862206 100644 --- a/stdlib/source/test/lux/control/reader.lux +++ b/stdlib/source/test/lux/control/reader.lux @@ -17,17 +17,17 @@ [// ["[0]" io (.only IO)]]]]) -(def: (injection value) +(def (injection value) (Injection (All (_ a r) (Reader r a))) (function (_ env) value)) -(def: comparison +(def comparison (Comparison (All (_ a r) (Reader r a))) (function (_ == left right) (== (/.result [] left) (/.result [] right)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Reader]) diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux index 999d1fa6b..31e6f2f8c 100644 --- a/stdlib/source/test/lux/control/region.lux +++ b/stdlib/source/test/lux/control/region.lux @@ -30,7 +30,7 @@ (exception: oops) -(def: (success? result) +(def (success? result) (All (_ a) (-> (Try a) Bit)) (case result {try.#Success _} @@ -39,7 +39,7 @@ {try.#Failure _} false)) -(def: (throws? exception result) +(def (throws? exception result) (All (_ e a) (-> (Exception e) (Try a) Bit)) (case result {try.#Success _} @@ -48,14 +48,14 @@ {try.#Failure error} (exception.match? exception error))) -(def: (injection value) +(def (injection value) (Injection (All (_ a) (All (_ ! r) (Region r (Thread !) a)))) (function (_ [region scope]) (function (_ !) [scope {try.#Success value}]))) -(def: comparison +(def comparison (Comparison (All (_ a) (All (_ ! r) (Region r (Thread !) a)))) (function (_ == left right) (case [(sharing [a] @@ -74,7 +74,7 @@ _ false))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Region]) diff --git a/stdlib/source/test/lux/control/remember.lux b/stdlib/source/test/lux/control/remember.lux index 263209c34..2e1a93f38 100644 --- a/stdlib/source/test/lux/control/remember.lux +++ b/stdlib/source/test/lux/control/remember.lux @@ -28,11 +28,11 @@ [\\library ["[0]" /]]) -(def: deadline (Random Date) random.date) -(def: message (Random Text) (random#each %.bit random.bit)) -(def: focus (Random Code) (random#each code.bit random.bit)) +(def deadline (Random Date) random.date) +(def message (Random Text) (random#each %.bit random.bit)) +(def focus (Random Code) (random#each code.bit random.bit)) -(def: (memory macro deadline message focus) +(def (memory macro deadline message focus) (-> Symbol Date Text (Maybe Code) Code) (` ((~ (code.symbol macro)) (~ (code.text (%.date deadline))) @@ -41,7 +41,7 @@ {.#None} (list) {.#Some focus} (list focus)))))) -(def: (attempt computation) +(def (attempt computation) (All (_ a) (-> (Meta a) (Meta (Try a)))) (function (_ compiler) (case (computation compiler) @@ -51,7 +51,7 @@ {try.#Failure error} {try.#Success [compiler {try.#Failure error}]}))) -(def: (test_failure deadline message focus failure) +(def (test_failure deadline message focus failure) (-> Date Text (Maybe Code) Text Bit) (and (text.contains? (%.date deadline) failure) (text.contains? message failure) @@ -62,7 +62,7 @@ {.#Some focus} (text.contains? (%.code focus) failure)))) -(def: test_macro +(def test_macro (syntax (_ [macro <code>.symbol extra <code>.text]) (let [now (io.run! instant.now) @@ -106,7 +106,7 @@ false) )))))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/lux/control/security/capability.lux b/stdlib/source/test/lux/control/security/capability.lux index e47e71509..efaae0687 100644 --- a/stdlib/source/test/lux/control/security/capability.lux +++ b/stdlib/source/test/lux/control/security/capability.lux @@ -21,7 +21,7 @@ (/.capability: Can_IO (can_io [] (IO Nat))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/lux/control/security/policy.lux b/stdlib/source/test/lux/control/security/policy.lux index 8e188702b..52e0f786f 100644 --- a/stdlib/source/test/lux/control/security/policy.lux +++ b/stdlib/source/test/lux/control/security/policy.lux @@ -20,12 +20,12 @@ [\\library ["[0]" / (.only Context Privacy Can_Conceal Can_Reveal Privilege Private)]]) -(def: (injection can_conceal) +(def (injection can_conceal) (All (_ label) (-> (Can_Conceal label) (Injection (All (_ value) (Private value label))))) can_conceal) -(def: (comparison can_reveal) +(def (comparison can_reveal) (All (_ label) (-> (Can_Reveal label) (Comparison (All (_ value) (Private value label))))) (function (_ == left right) @@ -46,30 +46,30 @@ (is (Privilege Privacy %) privilege))) -(def: (policy _) +(def (policy _) (Ex (_ %) (-> Any (Policy %))) (/.with_policy (is (Context Privacy Policy) (function (_ (^.let privilege (open "%[0]"))) (implementation - (def: &hash + (def &hash (implementation - (def: equivalence + (def equivalence (implementation - (def: (= reference sample) + (def (= reference sample) (text#= (%#can_downgrade reference) (%#can_downgrade sample))))) - (def: hash + (def hash (|>> %#can_downgrade (at text.hash hash))))) - (def: password + (def password %#can_upgrade) - (def: privilege + (def privilege privilege)))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Policy diff --git a/stdlib/source/test/lux/control/state.lux b/stdlib/source/test/lux/control/state.lux index 81c10a970..728304f50 100644 --- a/stdlib/source/test/lux/control/state.lux +++ b/stdlib/source/test/lux/control/state.lux @@ -20,14 +20,14 @@ [\\library ["[0]" / (.only State)]]) -(def: (with_conditions [state output] computation) +(def (with_conditions [state output] computation) (-> [Nat Nat] (State Nat Nat) Bit) (|> computation (/.result state) product.right (n.= output))) -(def: basics +(def basics (do random.monad [state random.nat value random.nat] @@ -54,18 +54,18 @@ /.get))) ))) -(def: (injection value) +(def (injection value) (All (_ s) (Injection (State s))) (function (_ state) [state value])) -(def: (comparison init) +(def (comparison init) (All (_ s) (-> s (Comparison (State s)))) (function (_ == left right) (== (product.right (/.result init left)) (product.right (/.result init right))))) -(def: structures +(def structures Test (do random.monad [state random.nat] @@ -78,7 +78,7 @@ ($monad.spec ..injection (..comparison state) /.monad)) ))) -(def: loops +(def loops Test (do [! random.monad] [limit (|> random.nat (at ! each (n.% 10))) @@ -100,7 +100,7 @@ (n.= 1 state')))))) ))) -(def: monad_transformer +(def monad_transformer Test (do random.monad [state random.nat @@ -120,7 +120,7 @@ (n.= (n.+ left right) output'))))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/control/thread.lux b/stdlib/source/test/lux/control/thread.lux index 7d7e9ae43..e57457306 100644 --- a/stdlib/source/test/lux/control/thread.lux +++ b/stdlib/source/test/lux/control/thread.lux @@ -17,16 +17,16 @@ [// ["[0]" io]]]]) -(def: (injection value) +(def (injection value) (Injection (All (_ a !) (Thread ! a))) (at /.monad in value)) -(def: comparison +(def comparison (Comparison (All (_ a !) (Thread ! a))) (function (_ == left right) (== (/.result left) (/.result right)))) -(def: .public test +(def .public test Test (do random.monad [sample random.nat diff --git a/stdlib/source/test/lux/control/try.lux b/stdlib/source/test/lux/control/try.lux index d448bedc2..b039e6221 100644 --- a/stdlib/source/test/lux/control/try.lux +++ b/stdlib/source/test/lux/control/try.lux @@ -21,22 +21,22 @@ [\\library ["[0]" / (.only Try)]]) -(def: injection +(def injection (Injection Try) (|>> {/.#Success})) -(def: comparison +(def comparison (Comparison Try) (function (_ ==) (at (/.equivalence ==) =))) -(def: .public (attempt element) +(def .public (attempt element) (All (_ a) (-> (Random a) (Random (Try a)))) (all random.or (random.unicode 1) element)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Try]) diff --git a/stdlib/source/test/lux/control/writer.lux b/stdlib/source/test/lux/control/writer.lux index 986ffa366..2b873c6e7 100644 --- a/stdlib/source/test/lux/control/writer.lux +++ b/stdlib/source/test/lux/control/writer.lux @@ -22,16 +22,16 @@ [\\library ["[0]" / (.only Writer)]]) -(def: (injection monoid value) +(def (injection monoid value) (All (_ w) (-> (Monoid w) (Injection (Writer w)))) [(at monoid identity) value]) -(def: comparison +(def comparison (All (_ w) (Comparison (Writer w))) (function (_ == [_ left] [_ right]) (== left right))) -(def: .public test +(def .public test Test (do random.monad [log (random.ascii 1) diff --git a/stdlib/source/test/lux/data.lux b/stdlib/source/test/lux/data.lux index 68e1b03f8..e4668dfc4 100644 --- a/stdlib/source/test/lux/data.lux +++ b/stdlib/source/test/lux/data.lux @@ -22,14 +22,14 @@ ["[1][0]" collection]]) ... TODO: Get rid of this ASAP -(def: !bundle +(def !bundle (template (_ body) [(is Test (do random.monad [_ (in [])] body))])) -(def: format +(def format Test (all _.and /format/json.test @@ -37,7 +37,7 @@ /format/xml.test )) -(def: test/0 +(def test/0 Test (all _.and /binary.test @@ -45,19 +45,19 @@ /color.test /color/named.test)) -(def: test/1 +(def test/1 Test (all _.and /identity.test)) -(def: test/2 +(def test/2 Test (all _.and /product.test /sum.test /text.test)) -(def: .public test +(def .public test Test ... TODO: Inline ASAP (all _.and diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux index 691b6ff55..cdb0d9101 100644 --- a/stdlib/source/test/lux/data/binary.lux +++ b/stdlib/source/test/lux/data/binary.lux @@ -50,7 +50,7 @@ ["[0]" \\format] ["[0]" \\parser]]]) -(def: !expect +(def !expect (template (_ <expectation> <computation>) [(case <computation> <expectation> @@ -59,9 +59,9 @@ _ false)])) -(def: segment_size 10) +(def segment_size 10) -(def: (utf8_conversion_does_not_alter? value) +(def (utf8_conversion_does_not_alter? value) (Predicate Text) (|> value (at utf8.codec encoded) @@ -73,32 +73,32 @@ {try.#Failure error} false))) -(def: random_text +(def random_text (Random Text) (random.only ..utf8_conversion_does_not_alter? (random.unicode ..segment_size))) -(def: random_symbol +(def random_symbol (Random Symbol) (random.and ..random_text ..random_text)) -(def: location_equivalence +(def location_equivalence (Equivalence Location) (implementation - (def: (= [expected_module expected_line expected_column] + (def (= [expected_module expected_line expected_column] [sample_module sample_line sample_column]) (and (text#= expected_module sample_module) (n.= expected_line sample_line) (n.= expected_column sample_column))))) -(def: random_location +(def random_location (Random Location) (all random.and ..random_text random.nat random.nat)) -(def: random_code +(def random_code (Random Code) (random.rec (function (_ again) @@ -121,7 +121,7 @@ random_sequence ))))))) -(def: random_type +(def random_type (Random Type) (let [(open "[0]") random.monad] (all random.either @@ -130,7 +130,7 @@ (in .Code) (in .Type)))) -(def: size +(def size Test (<| (_.for [\\parser.Size]) (`` (all _.and @@ -151,7 +151,7 @@ [\\parser.size_64 \\parser.bits_64 \\format.bits_64] )))))) -(def: binary +(def binary Test (`` (all _.and (~~ (with_template [<parser> <format>] @@ -169,7 +169,7 @@ [\\parser.binary_64 \\format.binary_64] ))))) -(def: utf8 +(def utf8 Test (`` (all _.and (~~ (with_template [<parser> <format>] @@ -188,7 +188,7 @@ [\\parser.text \\format.text] ))))) -(def: sequence +(def sequence Test (`` (all _.and (~~ (with_template [<parser> <format>] @@ -207,7 +207,7 @@ [\\parser.sequence_64 \\format.sequence_64] ))))) -(def: simple +(def simple Test (`` (all _.and (~~ (with_template [<parser> <format> <random> <equivalence>] @@ -246,7 +246,7 @@ (exception.match? \\parser.not_a_bit error)))))) ))) -(def: complex +(def complex Test (`` (all _.and (~~ (with_template [<parser> <format> <random> <equivalence>] @@ -326,7 +326,7 @@ actual)))))) ))) -(def: \\parser +(def \\parser Test (<| (_.covering \\parser._) (_.for [\\parser.Parser]) @@ -399,18 +399,18 @@ ..complex )))) -(def: equivalence +(def equivalence (Equivalence \\format.Specification) (implementation - (def: (= reference subject) + (def (= reference subject) (/#= (\\format.instance reference) (\\format.instance subject))))) -(def: random_specification +(def random_specification (Random \\format.Specification) (at random.monad each \\format.nat random.nat)) -(def: \\format +(def \\format Test (<| (_.covering \\format._) (_.for [\\format.Mutation \\format.Specification \\format.Writer]) @@ -419,7 +419,7 @@ ($monoid.spec ..equivalence \\format.monoid ..random_specification)) ))) -(def: (succeed result) +(def (succeed result) (-> (Try Bit) Bit) (case result {try.#Failure _} @@ -428,7 +428,7 @@ {try.#Success output} output)) -(def: .public (random size) +(def .public (random size) (-> Nat (Random /.Binary)) (let [output (/.empty size)] (loop (again [idx 0]) @@ -439,7 +439,7 @@ (again (++ idx)))) (at random.monad in output))))) -(def: (throws? exception try) +(def (throws? exception try) (All (_ e a) (-> (Exception e) (Try a) Bit)) (case try {try.#Failure error} @@ -448,7 +448,7 @@ {try.#Success _} false)) -(def: (binary_io power read write value) +(def (binary_io power read write value) (-> Nat (-> Nat /.Binary (Try Nat)) (-> Nat Nat /.Binary (Try Any)) Nat Bit) (let [bytes (i64.left_shifted power 1) binary (/.empty bytes) @@ -466,13 +466,13 @@ (throws? /.index_out_of_bounds (read 1 binary)) (throws? /.index_out_of_bounds (write 1 value binary))))) -(def: as_list +(def as_list (-> /.Binary (List Nat)) (/.mix (function (_ head tail) {.#Item head tail}) (list))) -(def: test|unsafe +(def test|unsafe Test (<| (_.covering !._) (_.for [!.Binary]) @@ -536,7 +536,7 @@ (n.= 0 copy/1))))) ))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Binary]) diff --git a/stdlib/source/test/lux/data/bit.lux b/stdlib/source/test/lux/data/bit.lux index 868c673f6..7b6b72d08 100644 --- a/stdlib/source/test/lux/data/bit.lux +++ b/stdlib/source/test/lux/data/bit.lux @@ -16,7 +16,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/lux/data/collection.lux b/stdlib/source/test/lux/data/collection.lux index ffbe005bb..2f85ba057 100644 --- a/stdlib/source/test/lux/data/collection.lux +++ b/stdlib/source/test/lux/data/collection.lux @@ -21,7 +21,7 @@ ["[1]/[0]" finger] ["[1]/[0]" zipper]]]) -(def: dictionary +(def dictionary Test (all _.and /dictionary.test @@ -29,14 +29,14 @@ /dictionary/plist.test )) -(def: queue +(def queue Test (all _.and /queue.test /queue/priority.test )) -(def: set +(def set Test (all _.and /set.test @@ -44,7 +44,7 @@ /set/ordered.test )) -(def: tree +(def tree Test (all _.and /tree.test @@ -52,7 +52,7 @@ /tree/zipper.test )) -(def: .public test +(def .public test Test (all _.and /array.test diff --git a/stdlib/source/test/lux/data/collection/array.lux b/stdlib/source/test/lux/data/collection/array.lux index d62e20981..73d2b7b3a 100644 --- a/stdlib/source/test/lux/data/collection/array.lux +++ b/stdlib/source/test/lux/data/collection/array.lux @@ -28,16 +28,16 @@ ["[0]" / (.only Array) ["!" \\unsafe]]]) -(def: injection +(def injection (Injection Array) (|>> list /.of_list)) -(def: bounded_size +(def bounded_size (Random Nat) (at random.monad each (|>> (n.% 20) ++) random.nat)) -(def: structures +(def structures Test (do [! random.monad] [size ..bounded_size] @@ -52,7 +52,7 @@ ($mix.spec ..injection /.equivalence /.mix)) ))) -(def: search +(def search Test (do [! random.monad] [size ..bounded_size @@ -114,7 +114,7 @@ (/.any? n.even? the_array))) ))) -(def: test|unsafe +(def test|unsafe Test (<| (_.covering !._) (_.for [!.Array]) @@ -134,8 +134,8 @@ (_.for [!.composite] ($monoid.spec (/.equivalence n.equivalence) (implementation - (def: identity (!.empty 0)) - (def: (composite left right) + (def identity (!.empty 0)) + (def (composite left right) (!.composite left right))) (random.array size random.nat))) (_.for [!.each] @@ -304,7 +304,7 @@ (!.any? n.even? the_array))) ))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Array]) diff --git a/stdlib/source/test/lux/data/collection/bits.lux b/stdlib/source/test/lux/data/collection/bits.lux index 72bd8a31f..a53a0f042 100644 --- a/stdlib/source/test/lux/data/collection/bits.lux +++ b/stdlib/source/test/lux/data/collection/bits.lux @@ -14,12 +14,12 @@ [\\library ["[0]" / (.only Bits)]]) -(def: (size min max) +(def (size min max) (-> Nat Nat (Random Nat)) (|> random.nat (at random.monad each (|>> (n.% (++ max)) (n.max min))))) -(def: .public random +(def .public random (Random Bits) (do [! random.monad] [size (at ! each (n.% 1,000) random.nat)] @@ -29,7 +29,7 @@ [idx (|> random.nat (at ! each (n.% size)))] (in (/.one idx /.empty)))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Bits]) diff --git a/stdlib/source/test/lux/data/collection/dictionary.lux b/stdlib/source/test/lux/data/collection/dictionary.lux index f5c0b4c9d..e4207f540 100644 --- a/stdlib/source/test/lux/data/collection/dictionary.lux +++ b/stdlib/source/test/lux/data/collection/dictionary.lux @@ -24,11 +24,11 @@ [\\library ["[0]" /]]) -(def: injection +(def injection (Injection (/.Dictionary Nat)) (|>> [0] list (/.of_list n.hash))) -(def: for_dictionaries +(def for_dictionaries Test (do [! random.monad] [.let [capped_nat (at random.monad each (n.% 100) random.nat)] @@ -56,8 +56,8 @@ [constant random.nat .let [hash (is (Hash Nat) (implementation - (def: equivalence n.equivalence) - (def: (hash _) + (def equivalence n.equivalence) + (def (hash _) constant)))]] (_.coverage [/.key_hash] (same? hash (/.key_hash (/.empty hash))))) @@ -130,7 +130,7 @@ (|> dict /.entries (/.of_list n.hash) (= dict))))) ))) -(def: for_entries +(def for_entries Test (do random.monad [.let [capped_nat (at random.monad each (n.% 100) random.nat)] @@ -248,7 +248,7 @@ (maybe.trusted (/.value non_key rebound))))))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Dictionary]) diff --git a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux index 19454582a..c90d91cda 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/ordered.lux @@ -23,7 +23,7 @@ [\\library ["[0]" /]]) -(def: .public (dictionary order gen_key gen_value size) +(def .public (dictionary order gen_key gen_value size) (All (_ k v) (-> (Order k) (Random k) (Random v) Nat (Random (/.Dictionary k v)))) (case size @@ -38,7 +38,7 @@ value gen_value] (in (/.has key value partial))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Dictionary]) diff --git a/stdlib/source/test/lux/data/collection/dictionary/plist.lux b/stdlib/source/test/lux/data/collection/dictionary/plist.lux index 7cd9ad3aa..46874e2d1 100644 --- a/stdlib/source/test/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/test/lux/data/collection/dictionary/plist.lux @@ -22,7 +22,7 @@ [\\library ["[0]" /]]) -(def: .public (random size gen_key gen_value) +(def .public (random size gen_key gen_value) (All (_ v) (-> Nat (Random Text) (Random v) (Random (/.PList v)))) (do random.monad @@ -30,7 +30,7 @@ values (random.list size gen_value)] (in (list.zipped_2 (set.list keys) values)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.PList]) diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index f82ac2f35..61d1f7a0d 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -32,12 +32,12 @@ [\\library ["[0]" / (.open: "[1]#[0]" monad)]]) -(def: bounded_size +(def bounded_size (Random Nat) (at random.monad each (n.% 100) random.nat)) -(def: random +(def random (Random (List Nat)) (do [! random.monad] [size ..bounded_size] @@ -45,7 +45,7 @@ (random.set n.hash size) (at ! each set.list)))) -(def: signatures +(def signatures Test (all _.and (_.for [/.equivalence] @@ -84,7 +84,7 @@ false))))) )) -(def: whole +(def whole Test (do [! random.monad] [size ..bounded_size @@ -128,7 +128,7 @@ symmetry!))) ))) -(def: indices +(def indices Test (let [(open "/#[0]") (/.equivalence n.equivalence) (open "/#[0]") /.functor] @@ -188,7 +188,7 @@ _ (not changed?)))) )))) -(def: slice +(def slice Test (let [(open "/#[0]") (/.equivalence n.equivalence) (open "/#[0]") /.monoid] @@ -237,7 +237,7 @@ (/.together subs))))) )))) -(def: member +(def member Test (let [(open "/#[0]") (/.equivalence n.equivalence)] (do [! random.monad] @@ -275,7 +275,7 @@ )) ))))) -(def: grouping +(def grouping Test (let [(open "/#[0]") (/.equivalence n.equivalence) (open "/#[0]") /.functor @@ -370,7 +370,7 @@ (/.together (list sample/0 sample/1 sample/2))))) )))) -(def: search +(def search Test (let [(open "/#[0]") /.functor @@ -411,7 +411,7 @@ (not (/.any? n.even? sample)))) )))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [.List]) diff --git a/stdlib/source/test/lux/data/collection/queue.lux b/stdlib/source/test/lux/data/collection/queue.lux index 460c64618..c5fe69611 100644 --- a/stdlib/source/test/lux/data/collection/queue.lux +++ b/stdlib/source/test/lux/data/collection/queue.lux @@ -19,11 +19,11 @@ [\\library ["[0]" /]]) -(def: injection +(def injection (Injection /.Queue) (|>> list /.of_list)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Queue]) diff --git a/stdlib/source/test/lux/data/collection/queue/priority.lux b/stdlib/source/test/lux/data/collection/queue/priority.lux index 106884fa1..9013b4a44 100644 --- a/stdlib/source/test/lux/data/collection/queue/priority.lux +++ b/stdlib/source/test/lux/data/collection/queue/priority.lux @@ -15,7 +15,7 @@ [\\library ["[0]" / (.only Queue)]]) -(def: .public (random size) +(def .public (random size) (-> Nat (Random (Queue Nat))) (do [! random.monad] [inputs (random.list size random.nat)] @@ -26,7 +26,7 @@ /.empty inputs))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Queue]) diff --git a/stdlib/source/test/lux/data/collection/sequence.lux b/stdlib/source/test/lux/data/collection/sequence.lux index 445d6b033..c6d9f6d4d 100644 --- a/stdlib/source/test/lux/data/collection/sequence.lux +++ b/stdlib/source/test/lux/data/collection/sequence.lux @@ -27,7 +27,7 @@ [\\library ["[0]" / (.open: "[1]#[0]" monad)]]) -(def: signatures +(def signatures Test (do [! random.monad] [size (at ! each (n.% 100) random.nat)] @@ -46,7 +46,7 @@ ($monad.spec /#in /.equivalence /.monad)) ))) -(def: whole +(def whole Test (do [! random.monad] [size (at ! each (n.% 100) random.nat) @@ -79,7 +79,7 @@ (/.any? (bit.complement n.even?) sample))) ))) -(def: index_based +(def index_based Test (do [! random.monad] [size (at ! each (|>> (n.% 100) ++) random.nat)] @@ -130,7 +130,7 @@ )) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Sequence]) diff --git a/stdlib/source/test/lux/data/collection/set.lux b/stdlib/source/test/lux/data/collection/set.lux index be1168ad5..7dfd3b682 100644 --- a/stdlib/source/test/lux/data/collection/set.lux +++ b/stdlib/source/test/lux/data/collection/set.lux @@ -20,12 +20,12 @@ [\\library ["[0]" / (.open: "[1]#[0]" equivalence)]]) -(def: gen_nat +(def gen_nat (Random Nat) (at random.monad each (n.% 100) random.nat)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Set]) @@ -55,9 +55,9 @@ [hash (at ! each (function (_ constant) (is (Hash Nat) (implementation - (def: equivalence n.equivalence) + (def equivalence n.equivalence) - (def: (hash _) + (def (hash _) constant)))) random.nat)] (_.coverage [/.member_hash] diff --git a/stdlib/source/test/lux/data/collection/set/multi.lux b/stdlib/source/test/lux/data/collection/set/multi.lux index 0cabf93c6..6a05d80c9 100644 --- a/stdlib/source/test/lux/data/collection/set/multi.lux +++ b/stdlib/source/test/lux/data/collection/set/multi.lux @@ -21,11 +21,11 @@ [\\library ["[0]" /]]) -(def: count +(def count (Random Nat) (at random.monad each (|>> (n.% 10) ++) random.nat)) -(def: .public (random size hash count element) +(def .public (random size hash count element) (All (_ a) (-> Nat (Hash a) (Random Nat) (Random a) (Random (/.Set a)))) (do [! random.monad] [elements (random.set hash size element) @@ -36,7 +36,7 @@ (list.zipped_2 element_counts (set.list elements)))))) -(def: signature +(def signature Test (do [! random.monad] [diversity (at ! each (n.% 10) random.nat)] @@ -50,7 +50,7 @@ ($hash.spec /.hash))) ))) -(def: composition +(def composition Test (do [! random.monad] [diversity (at ! each (n.% 10) random.nat) @@ -108,7 +108,7 @@ common_changes!))) )))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Set]) diff --git a/stdlib/source/test/lux/data/collection/set/ordered.lux b/stdlib/source/test/lux/data/collection/set/ordered.lux index 95f1644a1..f95f2e481 100644 --- a/stdlib/source/test/lux/data/collection/set/ordered.lux +++ b/stdlib/source/test/lux/data/collection/set/ordered.lux @@ -19,11 +19,11 @@ ["[0]" / (.only Set) ["[0]" //]]]) -(def: size +(def size (random.Random Nat) (at random.monad each (n.% 100) random.nat)) -(def: .public (random size order gen_value) +(def .public (random size order gen_value) (All (_ a) (-> Nat (Order a) (Random a) (Random (Set a)))) (case size 0 @@ -36,7 +36,7 @@ gen_value)] (in (/.has value partial))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Set]) diff --git a/stdlib/source/test/lux/data/collection/stack.lux b/stdlib/source/test/lux/data/collection/stack.lux index 3f600a958..64339fccd 100644 --- a/stdlib/source/test/lux/data/collection/stack.lux +++ b/stdlib/source/test/lux/data/collection/stack.lux @@ -18,11 +18,11 @@ [\\library ["[0]" /]]) -(def: (injection value) +(def (injection value) (Injection /.Stack) (/.top value /.empty)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Stack]) diff --git a/stdlib/source/test/lux/data/collection/stream.lux b/stdlib/source/test/lux/data/collection/stream.lux index 17bb614ad..398873f2f 100644 --- a/stdlib/source/test/lux/data/collection/stream.lux +++ b/stdlib/source/test/lux/data/collection/stream.lux @@ -21,15 +21,15 @@ [\\library ["[0]" /]]) -(def: (equivalence super) +(def (equivalence super) (All (_ a) (-> (Equivalence a) (Equivalence (/.Stream a)))) (implementation - (def: (= reference subject) + (def (= reference subject) (at (list.equivalence super) = (/.first 100 reference) (/.first 100 subject))))) -(def: (iterations step) +(def (iterations step) (All (_ a) (-> (-> a a) (-> a (/.Stream a)))) @@ -38,7 +38,7 @@ (let [state' (step state)] [state' state])))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Stream]) diff --git a/stdlib/source/test/lux/data/collection/tree.lux b/stdlib/source/test/lux/data/collection/tree.lux index f1d964e2e..a302565f9 100644 --- a/stdlib/source/test/lux/data/collection/tree.lux +++ b/stdlib/source/test/lux/data/collection/tree.lux @@ -19,7 +19,7 @@ [\\library ["[0]" / (.only Tree)]]) -(def: .public (tree gen_value) +(def .public (tree gen_value) (All (_ a) (-> (Random a) (Random [Nat (Tree a)]))) (do [! random.monad] [value gen_value @@ -31,7 +31,7 @@ [/.#value value /.#children (list#each product.right children)]]))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Tree]) diff --git a/stdlib/source/test/lux/data/collection/tree/finger.lux b/stdlib/source/test/lux/data/collection/tree/finger.lux index bb6d9ac98..bad7dec35 100644 --- a/stdlib/source/test/lux/data/collection/tree/finger.lux +++ b/stdlib/source/test/lux/data/collection/tree/finger.lux @@ -18,16 +18,16 @@ [\\library ["[0]" /]]) -(def: builder +(def builder (/.builder text.monoid)) -(def: :@: +(def :@: (by_example [@] (is (/.Builder @ Text) ..builder) @)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Tree]) diff --git a/stdlib/source/test/lux/data/collection/tree/zipper.lux b/stdlib/source/test/lux/data/collection/tree/zipper.lux index eb4a1c553..c98560160 100644 --- a/stdlib/source/test/lux/data/collection/tree/zipper.lux +++ b/stdlib/source/test/lux/data/collection/tree/zipper.lux @@ -25,7 +25,7 @@ ["[0]" / (.only Zipper) ["tree" //]]]) -(def: move +(def move Test (do random.monad [expected random.nat @@ -151,7 +151,7 @@ (maybe.else false)))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Zipper]) diff --git a/stdlib/source/test/lux/data/color.lux b/stdlib/source/test/lux/data/color.lux index e1d06c542..a59494de6 100644 --- a/stdlib/source/test/lux/data/color.lux +++ b/stdlib/source/test/lux/data/color.lux @@ -21,30 +21,30 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Color) (|> (all random.and random.nat random.nat random.nat) (at random.monad each /.of_rgb))) -(def: scale +(def scale (-> Nat Frac) (|>> .int int.frac)) -(def: square +(def square (-> Frac Frac) (f.pow +2.0)) -(def: square_root +(def square_root (-> Frac Frac) (f.pow +0.5)) -(def: (distance/1 from to) +(def (distance/1 from to) (-> Frac Frac Frac) (square_root (square (f.- from to)))) -(def: (distance/3 from to) +(def (distance/3 from to) (-> /.Color /.Color Frac) (let [[fr fg fb] (/.rgb from) [tr tg tb] (/.rgb to)] @@ -54,10 +54,10 @@ (|> (scale tg) (f.- (scale fg)) square) (|> (scale tb) (f.- (scale fb)) square))))) -(def: rgb_error_margin +1.8) +(def rgb_error_margin +1.8) (with_template [<field>] - [(def: (<field> color) + [(def (<field> color) (-> /.Color Frac) (let [[hue saturation luminance] (/.hsl color)] <field>))] @@ -66,7 +66,7 @@ [luminance] ) -(def: (encoding expected) +(def (encoding expected) (-> /.Color Test) (all _.and (_.coverage [/.RGB /.rgb /.of_rgb] @@ -86,7 +86,7 @@ (f.<= ..rgb_error_margin))) )) -(def: transformation +(def transformation Test (do random.monad [colorful (|> ..random @@ -125,7 +125,7 @@ (f.<= ..rgb_error_margin))))) ))) -(def: palette +(def palette Test (_.for [/.Spread /.Palette] (do [! random.monad] @@ -174,7 +174,7 @@ [/.tetradic])) ))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Color]) diff --git a/stdlib/source/test/lux/data/color/named.lux b/stdlib/source/test/lux/data/color/named.lux index 7034f41d1..4365468df 100644 --- a/stdlib/source/test/lux/data/color/named.lux +++ b/stdlib/source/test/lux/data/color/named.lux @@ -200,7 +200,7 @@ [/.yellow /.yellow_green]] )] - (def: all_colors + (def all_colors (list.together (`` (list (~~ (with_template [<definition> <by_letter>] [((is (-> Any (List //.Color)) (function (_ _) @@ -209,22 +209,22 @@ <colors>)))))) - (def: unique_colors + (def unique_colors (set.of_list //.hash ..all_colors)) - (def: verdict + (def verdict (n.= (list.size ..all_colors) (set.size ..unique_colors))) (with_template [<definition> <by_letter>] - [(def: <definition> + [(def <definition> Test (_.coverage <by_letter> ..verdict))] <colors>) - (def: .public test + (def .public test Test (<| (_.covering /._) (`` (all _.and diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux index 613767144..13d7f11cc 100644 --- a/stdlib/source/test/lux/data/format/json.lux +++ b/stdlib/source/test/lux/data/format/json.lux @@ -76,7 +76,7 @@ #date date.Date #grams (unit.Qty unit.Gram)])) -(def: gen_recursive +(def gen_recursive (Random Recursive) (random.rec (function (_ gen_recursive) @@ -84,11 +84,11 @@ (random.and random.safe_frac gen_recursive))))) -(def: qty +(def qty (All (_ unit) (Random (unit.Qty unit))) (at random.monad each unit.quantity random.int)) -(def: gen_record +(def gen_record (Random Record) (do [! random.monad] [size (at ! each (n.% 2) random.nat)] @@ -109,22 +109,22 @@ ))) (for @.old (these) - (these (def: equivalence + (these (def equivalence (Equivalence Record) (\\polytypic/equivalence.equivalence Record)) - (def: codec + (def codec (Codec JSON Record) (\\polytypic.codec Record)))) -(def: \\polytypic +(def \\polytypic Test (<| (_.covering \\polytypic._) (_.for [\\polytypic.codec] (for @.old (_.property "PLACEHOLDER" true) ($codec.spec ..equivalence ..codec ..gen_record))))) -(def: .public random +(def .public random (Random /.JSON) (random.rec (function (_ again) @@ -139,25 +139,25 @@ (random.dictionary text.hash size (random.unicode size) again) ))))) -(def: boolean +(def boolean (syntax (_ []) (do meta.monad [value meta.seed] (in (list (code.bit (n.even? value))))))) -(def: number +(def number (syntax (_ []) (do meta.monad [value meta.seed] (in (list (code.frac (n.frac value))))))) -(def: string +(def string (syntax (_ []) (do meta.monad [value (macro.symbol "string")] (in (list (code.text (%.code value))))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.JSON]) diff --git a/stdlib/source/test/lux/data/format/tar.lux b/stdlib/source/test/lux/data/format/tar.lux index 16bf8fb62..dad5eea06 100644 --- a/stdlib/source/test/lux/data/format/tar.lux +++ b/stdlib/source/test/lux/data/format/tar.lux @@ -35,7 +35,7 @@ [\\library ["[0]" /]]) -(def: path +(def path Test (_.for [/.Path] (do [! random.monad] @@ -70,7 +70,7 @@ (exception.match? /.not_ascii error))) ))))) -(def: name +(def name Test (_.for [/.Name] (do [! random.monad] @@ -103,7 +103,7 @@ (exception.match? /.not_ascii error))) ))))) -(def: small +(def small Test (_.for [/.Small] (do [! random.monad] @@ -127,7 +127,7 @@ (exception.match? /.not_a_small_number error))) ))))) -(def: big +(def big Test (_.for [/.Big] (do [! random.monad] @@ -151,9 +151,9 @@ (exception.match? /.not_a_big_number error))) ))))) -(def: chunk_size 32) +(def chunk_size 32) -(def: entry +(def entry Test (do [! random.monad] [expected_path (random.lower_case (-- /.path_size)) @@ -221,7 +221,7 @@ [/.Contiguous /.#Contiguous] )))))))) -(def: random_mode +(def random_mode (Random /.Mode) (do [! random.monad] [] @@ -238,7 +238,7 @@ (random.either (in /.set_group_id_on_execution) (in /.set_user_id_on_execution))))))) -(def: mode +(def mode Test (_.for [/.Mode /.mode] (do [! random.monad] @@ -311,7 +311,7 @@ [/.set_user_id_on_execution] ))))))) -(def: ownership +(def ownership Test (do [! random.monad] [path (random.lower_case /.path_size) @@ -390,7 +390,7 @@ (try.else false))) )))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Tar]) diff --git a/stdlib/source/test/lux/data/format/xml.lux b/stdlib/source/test/lux/data/format/xml.lux index 72be44fa1..0798b1d83 100644 --- a/stdlib/source/test/lux/data/format/xml.lux +++ b/stdlib/source/test/lux/data/format/xml.lux @@ -29,35 +29,35 @@ [\\library ["[0]" / (.only XML)]]) -(def: char_range +(def char_range Text (format "_" "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ")) -(def: char +(def char (Random Nat) (do [! random.monad] [idx (|> random.nat (at ! each (n.% (text.size char_range))))] (in (maybe.trusted (text.char idx char_range))))) -(def: (size bottom top) +(def (size bottom top) (-> Nat Nat (Random Nat)) (let [constraint (|>> (n.% top) (n.max bottom))] (random#each constraint random.nat))) -(def: (text bottom top) +(def (text bottom top) (-> Nat Nat (Random Text)) (do random.monad [size (..size bottom top)] (random.text ..char size))) -(def: symbol +(def symbol (Random Symbol) (random.and (..text 0 10) (..text 1 10))) -(def: .public random +(def .public random (Random XML) (random.rec (function (_ random) (random.or (..text 1 10) @@ -68,7 +68,7 @@ (random.dictionary symbol.hash size ..symbol (..text 0 10)) (random.list size random))))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.XML]) diff --git a/stdlib/source/test/lux/data/identity.lux b/stdlib/source/test/lux/data/identity.lux index a6b0fb397..b7d1ff001 100644 --- a/stdlib/source/test/lux/data/identity.lux +++ b/stdlib/source/test/lux/data/identity.lux @@ -12,16 +12,16 @@ [\\library ["[0]" / (.only Identity)]]) -(def: injection +(def injection (Injection Identity) (|>>)) -(def: comparison +(def comparison (Comparison Identity) (function (_ ==) ==)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Identity]) diff --git a/stdlib/source/test/lux/data/product.lux b/stdlib/source/test/lux/data/product.lux index 1cde90959..df2d4dc93 100644 --- a/stdlib/source/test/lux/data/product.lux +++ b/stdlib/source/test/lux/data/product.lux @@ -14,7 +14,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [.Tuple .And]) diff --git a/stdlib/source/test/lux/data/sum.lux b/stdlib/source/test/lux/data/sum.lux index 8543ddba6..fd3f4fecc 100644 --- a/stdlib/source/test/lux/data/sum.lux +++ b/stdlib/source/test/lux/data/sum.lux @@ -21,7 +21,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [.Union .Or]) diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index 3c65ea9ff..15e456a9c 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -79,13 +79,13 @@ ["[0]" \\parser] ["[0]" \\format]) -(def: (equivalence example) +(def (equivalence example) (All (_ a) (-> a (Equivalence (\\format.Format a)))) (implementation - (def: (= reference subject) + (def (= reference subject) (/#= (reference example) (subject example))))) -(def: random_contravariant +(def random_contravariant (Random (Ex (_ a) [(\\format.Format a) (Random a)])) @@ -97,7 +97,7 @@ (random#in [\\format.frac random.frac]) )) -(def: codec +(def codec Test (`` (all _.and (~~ (with_template [<format> <codec> <random>] @@ -145,7 +145,7 @@ )) ))) -(def: \\format +(def \\format Test (<| (_.covering \\format._) (_.for [\\format.Format]) @@ -212,7 +212,7 @@ (\\format.mod sample)))) )))) -(def: !expect +(def !expect (template (_ <pattern> <value>) [(case <value> <pattern> @@ -221,7 +221,7 @@ _ false)])) -(def: (should_fail' sample parser exception) +(def (should_fail' sample parser exception) (All (_ a e) (-> Text (\\parser.Parser a) (Exception e) Bit)) (case (\\parser.result parser sample) {try.#Failure error} @@ -230,7 +230,7 @@ _ false)) -(def: (should_fail sample parser) +(def (should_fail sample parser) (All (_ a) (-> Text (\\parser.Parser a) Bit)) (case (\\parser.result parser sample) {try.#Failure _} @@ -239,18 +239,18 @@ _ false)) -(def: (should_pass expected parser) +(def (should_pass expected parser) (-> Text (\\parser.Parser Text) Bit) (|> expected (\\parser.result parser) (at try.functor each (/#= expected)) (try.else false))) -(def: (should_pass! expected parser) +(def (should_pass! expected parser) (-> Text (\\parser.Parser \\parser.Slice) Bit) (..should_pass expected (\\parser.slice parser))) -(def: \\parser#character_classes +(def \\parser#character_classes Test (all _.and (do [! random.monad] @@ -387,7 +387,7 @@ ))) )) -(def: \\parser#runs +(def \\parser#runs Test (let [octal! (\\parser.one_of! "01234567")] (all _.and @@ -473,7 +473,7 @@ (..should_fail (\\format.format first) (\\parser.between! 2 1 octal!))))) ))) -(def: \\parser +(def \\parser Test (<| (_.covering \\parser._) (_.for [\\parser.Parser]) @@ -624,12 +624,12 @@ \\parser#runs ))) -(def: bounded_size +(def bounded_size (random.Random Nat) (|> random.nat (at random.monad each (|>> (nat.% 20) (nat.+ 1))))) -(def: size +(def size Test (do [! random.monad] [size (at ! each (nat.% 10) random.nat) @@ -641,7 +641,7 @@ (or (/.empty? sample) (not (nat.= 0 size))))))) -(def: affix +(def affix Test (do [! random.monad] [inner (random.unicode 1) @@ -670,7 +670,7 @@ (/.contains? inner sample)))) )))) -(def: index +(def index Test (do [! random.monad] [inner (random.unicode 1) @@ -717,7 +717,7 @@ (nat.= 2))))) ))) -(def: char +(def char Test (all _.and (_.for [/.Char /.of_char] @@ -768,7 +768,7 @@ ))))) )) -(def: manipulation +(def manipulation Test (do [! random.monad] [size (at ! each (|>> (nat.% 10) (nat.+ 2)) random.nat) @@ -851,7 +851,7 @@ inverse!))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [.Text]) diff --git a/stdlib/source/test/lux/data/text/buffer.lux b/stdlib/source/test/lux/data/text/buffer.lux index 6c1531b66..f11248cd8 100644 --- a/stdlib/source/test/lux/data/text/buffer.lux +++ b/stdlib/source/test/lux/data/text/buffer.lux @@ -14,13 +14,13 @@ [\\library ["[0]" /]]) -(def: part +(def part (Random Text) (do [! random.monad] [size (at ! each (|>> (n.% 10) ++) random.nat)] (random.alphabetic size))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Buffer]) diff --git a/stdlib/source/test/lux/data/text/encoding.lux b/stdlib/source/test/lux/data/text/encoding.lux index 12be514b8..a3686fc6a 100644 --- a/stdlib/source/test/lux/data/text/encoding.lux +++ b/stdlib/source/test/lux/data/text/encoding.lux @@ -189,35 +189,35 @@ [])] <encodings>)] - (def: all_encodings + (def all_encodings (list.together (list <named>))) - (def: unique_encodings + (def unique_encodings (list#mix (function (_ encoding set) (set.has (/.name encoding) set)) (set.empty text.hash) ..all_encodings)) - (def: verdict + (def verdict (n.= (list.size ..all_encodings) (set.size ..unique_encodings))) (with_template [<definition> <by_letter>] - [(def: <definition> + [(def <definition> Test (`` (_.coverage [/.name (~~ (template.spliced <by_letter>))] ..verdict)))] <encodings>) - (def: .public random + (def .public random (Random /.Encoding) (let [options (list.size ..all_encodings)] (do [! random.monad] [choice (at ! each (n.% options) random.nat)] (in (maybe.trusted (list.item choice ..all_encodings)))))) - (def: .public test + (def .public test Test (<| (_.covering /._) (_.for [/.Encoding]) diff --git a/stdlib/source/test/lux/data/text/encoding/utf8.lux b/stdlib/source/test/lux/data/text/encoding/utf8.lux index 20f49c113..e7cdc660d 100644 --- a/stdlib/source/test/lux/data/text/encoding/utf8.lux +++ b/stdlib/source/test/lux/data/text/encoding/utf8.lux @@ -12,7 +12,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.codec] diff --git a/stdlib/source/test/lux/data/text/escape.lux b/stdlib/source/test/lux/data/text/escape.lux index a583c2b6e..082f638c2 100644 --- a/stdlib/source/test/lux/data/text/escape.lux +++ b/stdlib/source/test/lux/data/text/escape.lux @@ -31,30 +31,30 @@ ["[0]" unicode ["[1]" set]]]]]) -(def: (range max min) +(def (range max min) (-> Char Char (Random Char)) (let [range (n.- min max)] (at random.monad each (|>> (n.% range) (n.+ min)) random.nat))) -(def: under_range +(def under_range (Random Char) (..range (debug.private /.ascii_bottom) 0)) -(def: over_range +(def over_range (Random Char) (..range (hex "FFFF") (++ (debug.private /.ascii_top)))) -(def: in_range +(def in_range (Random Char) (..range (++ (debug.private /.ascii_top)) (debug.private /.ascii_bottom))) -(def: ascii_range +(def ascii_range (Random Char) (..range (++ (debug.private /.ascii_top)) 0)) -(def: valid_sigils +(def valid_sigils (Set Char) (set.of_list n.hash (list (debug.private /.\0_sigil) @@ -69,7 +69,7 @@ (debug.private /.\\_sigil) (debug.private /.\u_sigil)))) -(def: static_sample +(def static_sample (syntax (_ []) (do meta.monad [seed meta.seed @@ -78,11 +78,11 @@ (random.result (random.pcg_32 [seed seed])))]] (in (list (code.text expected)))))) -(def: static_escaped +(def static_escaped (syntax (_ [un_escaped <code>.text]) (in (list (code.text (/.escaped un_escaped)))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/data/text/regex.lux b/stdlib/source/test/lux/data/text/regex.lux index a31b6247b..787d432a6 100644 --- a/stdlib/source/test/lux/data/text/regex.lux +++ b/stdlib/source/test/lux/data/text/regex.lux @@ -22,7 +22,7 @@ [\\library ["[0]" /]]) -(def: (should_pass regex input) +(def (should_pass regex input) (-> (Parser Text) Text Bit) (|> input (<text>.result regex) @@ -33,7 +33,7 @@ _ #0))) -(def: (text_should_pass test regex input) +(def (text_should_pass test regex input) (-> Text (Parser Text) Text Bit) (|> input (<text>.result regex) @@ -44,7 +44,7 @@ _ false))) -(def: (should_fail regex input) +(def (should_fail regex input) (All (_ a) (-> (Parser a) Text Bit)) (|> input (<text>.result regex) @@ -55,7 +55,7 @@ _ false))) -(def: should_check +(def should_check (syntax (_ [pattern <code>.any regex <code>.any input <code>.any]) @@ -69,7 +69,7 @@ (~ g!_) false)))))))) -(def: basics +(def basics Test (_.property "Can parse character literals." (and (should_pass (/.regex "a") "a") @@ -77,7 +77,7 @@ (should_pass (/.regex "\.") ".") (should_fail (/.regex "\.") "a")))) -(def: system_character_classes +(def system_character_classes Test (all _.and (_.property "Can parse anything." @@ -108,7 +108,7 @@ (should_fail (/.regex "\W") "a"))) )) -(def: special_system_character_classes +(def special_system_character_classes Test (all _.and (_.property "Lower-case." @@ -155,7 +155,7 @@ (should_fail (/.regex "\p{Print}") (text.of_char (hex "1234"))))) )) -(def: custom_character_classes +(def custom_character_classes Test (all _.and (_.property "Can parse using custom character classes." @@ -194,7 +194,7 @@ (should_fail RE "p"))))) )) -(def: references +(def references Test (let [number (/.regex "\d+")] (_.property "Can build complex regexs by combining simpler ones." @@ -202,7 +202,7 @@ (/.regex "(\@<number>)-(\@<number>)-(\@<number>)") "809-345-6789")))) -(def: fuzzy_quantifiers +(def fuzzy_quantifiers Test (all _.and (_.property "Can sequentially combine patterns." @@ -222,7 +222,7 @@ (should_fail (/.regex "a+") ""))) )) -(def: crisp_quantifiers +(def crisp_quantifiers Test (all _.and (_.property "Can match a pattern N times." @@ -244,7 +244,7 @@ (text_should_pass "aa" (/.regex "a{1,2}") "aa"))) )) -(def: groups +(def groups Test (all _.and (_.property "Can extract groups of sub-matches specified in a pattern." @@ -260,7 +260,7 @@ (should_check ["809-345-6789" "809" ["345-6789" "345" "6789"]] (/.regex "(\d{3})-((\d{3})-(\d{4}))") "809-345-6789")) )) -(def: alternation +(def alternation Test (all _.and (_.property "Can specify alternative patterns." @@ -277,7 +277,7 @@ "123-456-7890"))) )) -(def: expands? +(def expands? (syntax (_ [form <code>.any]) (function (_ lux) {try.#Success [lux (list (code.bit (case (macro.single_expansion form lux) @@ -287,7 +287,7 @@ {try.#Failure error} false)))]}))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/data/text/unicode/block.lux b/stdlib/source/test/lux/data/text/unicode/block.lux index c07da3b71..4c07e1531 100644 --- a/stdlib/source/test/lux/data/text/unicode/block.lux +++ b/stdlib/source/test/lux/data/text/unicode/block.lux @@ -22,7 +22,7 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Block) (do [! random.monad] [start (at ! each (n.% 1,000,000) random.nat) @@ -154,7 +154,7 @@ <blocks>)] (with_template [<definition> <part>] - [(def: <definition> + [(def <definition> Test (`` (_.coverage [(~~ (template.spliced <part>))] (let [all (list.together (list <named>)) @@ -165,7 +165,7 @@ <blocks> ) - (def: .public test + (def .public test Test (<| (_.covering /._) (_.for [/.Block]) diff --git a/stdlib/source/test/lux/data/text/unicode/set.lux b/stdlib/source/test/lux/data/text/unicode/set.lux index e4eed7710..e2bbc663c 100644 --- a/stdlib/source/test/lux/data/text/unicode/set.lux +++ b/stdlib/source/test/lux/data/text/unicode/set.lux @@ -23,14 +23,14 @@ [// ["[0]" block]]]]) -(def: .public random +(def .public random (Random /.Set) (do [! random.monad] [left //block.random right //block.random] (in (/.set [left (list right)])))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Set]) diff --git a/stdlib/source/test/lux/debug.lux b/stdlib/source/test/lux/debug.lux index d0292ab1a..4888bc61b 100644 --- a/stdlib/source/test/lux/debug.lux +++ b/stdlib/source/test/lux/debug.lux @@ -48,7 +48,7 @@ ["[1][0]" location] ["[1][0]" symbol]]]) -(def: can_represent_simple_types +(def can_represent_simple_types (Random Bit) (do random.monad [sample_bit random.bit @@ -70,7 +70,7 @@ [Text %.text sample_text])) ))))) -(def: can_represent_structure_types +(def can_represent_structure_types (Random Bit) (do random.monad [sample_bit random.bit @@ -103,7 +103,7 @@ ... )) ))))) -(def: can_represent_complex_types +(def can_represent_complex_types (Random Bit) (do random.monad [sample_ratio $//ratio.random @@ -127,7 +127,7 @@ [JSON %.json sample_json])) ))))) -(def: can_represent_time_types +(def can_represent_time_types (Random Bit) (do random.monad [sample_instant random.instant @@ -149,7 +149,7 @@ [Day %.day sample_day])) ))))) -(def: representation +(def representation Test (do random.monad [sample_bit random.bit @@ -192,7 +192,7 @@ (exception.match? /.cannot_represent_value error))) ))) -(def: inspection +(def inspection Test (do random.monad [sample_bit random.bit @@ -216,7 +216,7 @@ (/.inspection [sample_bit sample_int sample_frac sample_text])) ))))) -(def: macro_error +(def macro_error (syntax (_ [macro <code>.any]) (function (_ compiler) (case ((macro.expansion macro) compiler) @@ -229,7 +229,7 @@ (type: My_Text Text) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/lux/documentation.lux b/stdlib/source/test/lux/documentation.lux index 600030da4..ddfc1c876 100644 --- a/stdlib/source/test/lux/documentation.lux +++ b/stdlib/source/test/lux/documentation.lux @@ -20,7 +20,7 @@ [\\library ["[0]" /]]) -(def: macro_error +(def macro_error (syntax (_ [macro <code>.any]) (function (_ compiler) {try.#Success [compiler (list (code.bit (case ((macro.expansion macro) compiler) @@ -30,7 +30,7 @@ {try.#Success _} false)))]}))) -(def: description +(def description (syntax (_ []) (at meta.monad each (|>> %.nat code.text list) @@ -40,15 +40,15 @@ (with_expansions ['definition_description' (..description) 'sub_description' (..description) 'super_description' (..description)] - (these (def: .public g!default + (these (def .public g!default Nat 123) - (def: documentation + (def documentation (/.documentation /.documentation 'definition_description')) - (def: .public test + (def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux index 22b8813e7..81fa7e1df 100644 --- a/stdlib/source/test/lux/extension.lux +++ b/stdlib/source/test/lux/extension.lux @@ -61,10 +61,10 @@ [\\library ["[0]" / (.only analysis synthesis generation directive)]]))) -(def: dummy_generation "dummy generation") +(def dummy_generation "dummy generation") (with_template [<name>] - [(def: <name> + [(def <name> Text (`` (%.symbol (symbol (~~ (template.symbol [.._ <name>]))))))] @@ -180,7 +180,7 @@ (`` ((~~ (static ..my_directive)) (n.* 2 3))) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/lux/ffi.js.lux b/stdlib/source/test/lux/ffi.js.lux index 6de496499..19d33cae6 100644 --- a/stdlib/source/test/lux/ffi.js.lux +++ b/stdlib/source/test/lux/ffi.js.lux @@ -45,7 +45,7 @@ (new [/.String]) (decode [Uint8Array] /.String)) -(def: .public test +(def .public test Test (do [! random.monad] [boolean random.bit diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux index 327c2c77f..fde11038a 100644 --- a/stdlib/source/test/lux/ffi.jvm.lux +++ b/stdlib/source/test/lux/ffi.jvm.lux @@ -57,7 +57,7 @@ (getName [] java/lang/String)) (with_template [<name> <type> <conversion> <lux> <=>] - [(def: (<name> left right) + [(def (<name> left right) (-> <type> <type> Bit) (<=> (as <lux> (<conversion> left)) (as <lux> (<conversion> right))))] @@ -72,7 +72,7 @@ [character#= /.Character /.char_to_long Int i#=] ) -(def: macro_error +(def macro_error (syntax (_ [expression <code>.any]) (function (_ lux) (|> (macro.single_expansion expression) @@ -84,7 +84,7 @@ {try.#Failure error} {try.#Success [lux (list (code.text error))]}))))) -(def: for_conversions +(def for_conversions Test (do [! random.monad] [long (at ! each (|>> /.as_long) random.int) @@ -119,7 +119,7 @@ [float float#= /.float_to_double /.double_to_float] )))))) -(def: for_arrays +(def for_arrays Test (do [! random.monad] [size (|> random.nat (at ! each (|>> (n.% 100) (n.max 1)))) @@ -145,7 +145,7 @@ ..macro_error (text.contains? (the exception.#label /.cannot_convert_to_jvm_type)))))))) -(def: for_miscellaneous +(def for_miscellaneous Test (`` (do [! random.monad] [sample (at ! each (|>> (as java/lang/Object)) @@ -298,7 +298,7 @@ "[1]::[0]" (actual4 [long long] long)) -(def: for_interface +(def for_interface Test (do random.monad [expected random.nat @@ -551,7 +551,7 @@ (new [a]) ("read_only" value11 a)) -(def: for_class +(def for_class Test (do [! random.monad] [expected random.nat @@ -668,7 +668,7 @@ example/9!) ))) -(def: expands? +(def expands? (syntax (_ [expression <code>.any]) (function (_ lux) (|> (macro.single_expansion expression) @@ -684,7 +684,7 @@ [lux] {try.#Success})))) -(def: for_exception +(def for_exception Test (do [! random.monad] [var/0 (random.lower_case 1) @@ -721,7 +721,7 @@ false))))) ))) -(def: .public test +(def .public test (<| (_.covering /._) (all _.and ..for_conversions diff --git a/stdlib/source/test/lux/ffi.lua.lux b/stdlib/source/test/lux/ffi.lua.lux index 4ca013d88..aac4a2091 100644 --- a/stdlib/source/test/lux/ffi.lua.lux +++ b/stdlib/source/test/lux/ffi.lua.lux @@ -15,7 +15,7 @@ (/.import (os/getenv [/.String] "io" "?" /.String)) -(def: .public test +(def .public test Test (do [! random.monad] [boolean random.bit diff --git a/stdlib/source/test/lux/ffi.old.lux b/stdlib/source/test/lux/ffi.old.lux index 917e18949..9fc124852 100644 --- a/stdlib/source/test/lux/ffi.old.lux +++ b/stdlib/source/test/lux/ffi.old.lux @@ -71,7 +71,7 @@ (up [] java/lang/Long) (down [] java/lang/Long)) -(def: (test_object increase counter) +(def (test_object increase counter) (-> Int Int test/lux/ffi/TestInterface) (/.object [] [test/lux/ffi/TestInterface] [] @@ -88,7 +88,7 @@ test/lux/ffi/TestInterface (test_object increase (i.- increase counter))))) -(def: conversions +(def conversions Test (do [! random.monad] [long random.int @@ -156,7 +156,7 @@ (|> capped <to> <from> /.int_to_long (i.= (/.int_to_long capped)))))))) )))) -(def: arrays +(def arrays Test (do [! random.monad] [size (|> random.nat (at ! each (|>> (n.% 100) (n.max 1)))) @@ -172,7 +172,7 @@ (i.= value))) ))) -(def: null +(def null Test (do random.monad [sample (random.ascii 1)] @@ -194,7 +194,7 @@ (not (/.null? (/.!!! (/.??? sample)))))) ))) -(def: miscellaneous +(def miscellaneous Test (do random.monad [sample (random.ascii 1) @@ -233,7 +233,7 @@ (/.type (java/util/List java/lang/Byte))))) ))) -(def: .public test +(def .public test (<| (_.covering /._) (all _.and ..conversions diff --git a/stdlib/source/test/lux/ffi.php.lux b/stdlib/source/test/lux/ffi.php.lux index 22532f1b1..4e4537188 100644 --- a/stdlib/source/test/lux/ffi.php.lux +++ b/stdlib/source/test/lux/ffi.php.lux @@ -16,7 +16,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (do [! random.monad] [] diff --git a/stdlib/source/test/lux/ffi.py.lux b/stdlib/source/test/lux/ffi.py.lux index bdaab94c5..b559ee5c3 100644 --- a/stdlib/source/test/lux/ffi.py.lux +++ b/stdlib/source/test/lux/ffi.py.lux @@ -18,7 +18,7 @@ ("static" R_OK /.Integer) ("static" W_OK /.Integer)) -(def: .public test +(def .public test Test (do [! random.monad] [boolean random.bit diff --git a/stdlib/source/test/lux/ffi.rb.lux b/stdlib/source/test/lux/ffi.rb.lux index f5185ea81..7f2c25334 100644 --- a/stdlib/source/test/lux/ffi.rb.lux +++ b/stdlib/source/test/lux/ffi.rb.lux @@ -15,7 +15,7 @@ "[1]::[0]" ("static" SEPARATOR /.String)) -(def: .public test +(def .public test Test (do [! random.monad] [boolean random.bit diff --git a/stdlib/source/test/lux/ffi.scm.lux b/stdlib/source/test/lux/ffi.scm.lux index 22532f1b1..4e4537188 100644 --- a/stdlib/source/test/lux/ffi.scm.lux +++ b/stdlib/source/test/lux/ffi.scm.lux @@ -16,7 +16,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (do [! random.monad] [] diff --git a/stdlib/source/test/lux/ffi/export.js.lux b/stdlib/source/test/lux/ffi/export.js.lux index 37402fc3b..a0d5dcf16 100644 --- a/stdlib/source/test/lux/ffi/export.js.lux +++ b/stdlib/source/test/lux/ffi/export.js.lux @@ -12,17 +12,17 @@ (with_expansions [<nat> (static.random_nat)] (/.export - (def: constant + (def constant Nat <nat>) - (def: shift + (def shift (-> Nat Nat) (|>> (n.+ <nat>)))) (//.import (constant Nat)) (//.import (shift (-> Nat Nat))) - (def: .public test + (def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/ffi/export.jvm.lux b/stdlib/source/test/lux/ffi/export.jvm.lux index e9468a8fe..efa8d80fb 100644 --- a/stdlib/source/test/lux/ffi/export.jvm.lux +++ b/stdlib/source/test/lux/ffi/export.jvm.lux @@ -24,15 +24,15 @@ ["[0]" / (.only) ["/[1]" //]]]) -(def: expected_boolean (//.as_boolean (static.random_bit))) -(def: expected_byte (//.as_byte (static.random_int))) -(def: expected_short (//.as_short (static.random_int))) -(def: expected_int (//.as_int (static.random_int))) -(def: expected_long (//.as_long (static.random_int))) -(def: expected_char (//.as_char (static.random_int))) -(def: expected_float (//.as_float (static.random_frac))) -(def: expected_double (//.as_double (static.random_frac))) -(def: expected_string (//.as_string (static.random code.text (random.lower_case 2)))) +(def expected_boolean (//.as_boolean (static.random_bit))) +(def expected_byte (//.as_byte (static.random_int))) +(def expected_short (//.as_short (static.random_int))) +(def expected_int (//.as_int (static.random_int))) +(def expected_long (//.as_long (static.random_int))) +(def expected_char (//.as_char (static.random_int))) +(def expected_float (//.as_float (static.random_frac))) +(def expected_double (//.as_double (static.random_frac))) +(def expected_string (//.as_string (static.random code.text (random.lower_case 2)))) (`` (`` (/.export Primitives ... Constants @@ -110,19 +110,19 @@ ("static" [a] left [a a] a) ("static" [a] right [a a] a)) -(def: tiny_int +(def tiny_int (Random Int) (random#each (|>> (i64.and (hex "F")) .int) random.nat)) -(def: tiny_frac +(def tiny_frac (Random Frac) (random#each (|>> (i64.and (hex "FFFF")) .int int.frac) random.nat)) -(`` (`` (def: .public test +(`` (`` (def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/ffi/export.lua.lux b/stdlib/source/test/lux/ffi/export.lua.lux index f3c9b90ea..8af9418af 100644 --- a/stdlib/source/test/lux/ffi/export.lua.lux +++ b/stdlib/source/test/lux/ffi/export.lua.lux @@ -12,17 +12,17 @@ (with_expansions [<nat> (static.random_nat)] (/.export - (def: constant + (def constant Nat <nat>) - (def: shift + (def shift (-> Nat Nat) (|>> (n.+ <nat>)))) (//.import (constant Nat)) (//.import (shift (-> Nat Nat))) - (def: .public test + (def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/ffi/export.py.lux b/stdlib/source/test/lux/ffi/export.py.lux index 37402fc3b..a0d5dcf16 100644 --- a/stdlib/source/test/lux/ffi/export.py.lux +++ b/stdlib/source/test/lux/ffi/export.py.lux @@ -12,17 +12,17 @@ (with_expansions [<nat> (static.random_nat)] (/.export - (def: constant + (def constant Nat <nat>) - (def: shift + (def shift (-> Nat Nat) (|>> (n.+ <nat>)))) (//.import (constant Nat)) (//.import (shift (-> Nat Nat))) - (def: .public test + (def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/ffi/export.rb.lux b/stdlib/source/test/lux/ffi/export.rb.lux index f107536f2..3b17b4c2c 100644 --- a/stdlib/source/test/lux/ffi/export.rb.lux +++ b/stdlib/source/test/lux/ffi/export.rb.lux @@ -12,16 +12,16 @@ (with_expansions [<nat> (static.random_nat)] (/.export - (def: nullary + (def nullary Nat <nat>) - (def: unary + (def unary (-> Nat Nat) (|>> (n.+ <nat>))) - (def: CONSTANT + (def CONSTANT Nat <nat>) - (def: $global + (def $global (-> Nat Nat) (|>> (n.+ <nat>)))) @@ -30,7 +30,7 @@ (//.import (CONSTANT Nat)) (//.import ($global (-> Nat Nat))) - (def: .public test + (def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/locale.lux b/stdlib/source/test/lux/locale.lux index 0a05619e8..8d114aacd 100644 --- a/stdlib/source/test/lux/locale.lux +++ b/stdlib/source/test/lux/locale.lux @@ -22,22 +22,22 @@ ["[0]" language (.only Language)] ["[0]" territory (.only Territory)]]]) -(def: random_language +(def random_language (Random Language) (random.either (random#in language.afar) (random#in language.zaza))) -(def: random_territory +(def random_territory (Random Territory) (random.either (random#in territory.afghanistan) (random#in territory.zimbabwe))) -(def: random_encoding +(def random_encoding (Random Encoding) (random.either (random#in encoding.ascii) (random#in encoding.koi8_u))) -(def: random_locale +(def random_locale (Random /.Locale) (do random.monad [language ..random_language @@ -45,7 +45,7 @@ encoding ..random_encoding] (in (/.locale language {.#Some territory} {.#Some encoding})))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Locale]) diff --git a/stdlib/source/test/lux/locale/language.lux b/stdlib/source/test/lux/locale/language.lux index 8691b1dc4..010328aeb 100644 --- a/stdlib/source/test/lux/locale/language.lux +++ b/stdlib/source/test/lux/locale/language.lux @@ -32,7 +32,7 @@ #test Test])) (with_template [<bundle> <languages>] - [(def: <bundle> + [(def <bundle> Bundle (let [amount (template.amount <languages>) languages (is (List /.Language) @@ -152,7 +152,7 @@ [languages/etc [/.uncoded /.multiple /.undetermined /.not_applicable]] ) -(def: languages +(def languages (List Bundle) (list ..languages/a ..languages/b @@ -184,7 +184,7 @@ ..languages/etc )) -(def: (aggregate lens hash territories) +(def (aggregate lens hash territories) (All (_ a) (-> (-> Bundle (Set a)) (Hash a) (List Bundle) @@ -195,7 +195,7 @@ [0 (set.empty hash)] territories)) -(def: languages_test +(def languages_test Test (|> ..languages list.reversed @@ -213,13 +213,13 @@ )) ))))) -(def: !aliases +(def !aliases (template (_ <reference> <aliases>) [(_.coverage <aliases> (list.every? (at /.equivalence = <reference>) (`` (list (~~ (template.spliced <aliases>))))))])) -(def: aliases_test/0 +(def aliases_test/0 Test (all _.and ... A @@ -243,7 +243,7 @@ (!aliases /.khotanese [/.sakan]) )) -(def: aliases_test/1 +(def aliases_test/1 Test (all _.and ... M @@ -270,14 +270,14 @@ (!aliases /.zaza [/.dimili /.dimli /.kirdki /.kirmanjki /.zazaki]) )) -(def: aliases_test +(def aliases_test Test (all _.and ..aliases_test/0 ..aliases_test/1 )) -(def: .public random +(def .public random (Random /.Language) (let [options (|> ..languages (list#each (|>> (the #languages) set.list)) @@ -287,7 +287,7 @@ random.nat)] (in (maybe.trusted (list.item choice options)))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Language]) diff --git a/stdlib/source/test/lux/locale/territory.lux b/stdlib/source/test/lux/locale/territory.lux index a68eaf8f3..8ad7741d7 100644 --- a/stdlib/source/test/lux/locale/territory.lux +++ b/stdlib/source/test/lux/locale/territory.lux @@ -34,7 +34,7 @@ #test Test])) (with_template [<bundle> <territories>] - [(def: <bundle> + [(def <bundle> Bundle (let [amount (template.amount <territories>) territories (`` (list (~~ (template.spliced <territories>))))] @@ -111,7 +111,7 @@ [territories/z [/.zambia /.zimbabwe]] ) -(def: territories +(def territories (List Bundle) (list ..territories/a ..territories/b @@ -139,7 +139,7 @@ ..territories/y ..territories/z)) -(def: (aggregate lens hash territories) +(def (aggregate lens hash territories) (All (_ a) (-> (-> Bundle (Set a)) (Hash a) (List Bundle) @@ -150,7 +150,7 @@ [0 (set.empty hash)] territories)) -(def: territories_test +(def territories_test Test (|> ..territories list.reversed @@ -170,13 +170,13 @@ )) ))))) -(def: !aliases +(def !aliases (template (_ <reference> <aliases>) [(_.coverage <aliases> (list.every? (at /.equivalence = <reference>) (`` (list (~~ (template.spliced <aliases>))))))])) -(def: aliases_test +(def aliases_test Test (all _.and ... A @@ -203,7 +203,7 @@ (!aliases /.wallis [/.futuna]) )) -(def: .public random +(def .public random (Random /.Territory) (let [options (|> ..territories (list#each (|>> (the #territories) set.list)) @@ -213,7 +213,7 @@ random.nat)] (in (maybe.trusted (list.item choice options)))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Territory]) diff --git a/stdlib/source/test/lux/macro.lux b/stdlib/source/test/lux/macro.lux index f43fb3d7d..bbedbc302 100644 --- a/stdlib/source/test/lux/macro.lux +++ b/stdlib/source/test/lux/macro.lux @@ -36,37 +36,37 @@ ["[1][0]" template] ["[1][0]" pattern]]) -(def: !expect +(def !expect (template (_ <pattern> <value>) [(case <value> <pattern> true _ false)])) -(def: !global +(def !global (template (_ <definition>) [(is [Text .Global] [(template.text [<definition>]) {.#Definition [true .Macro <definition>]}])])) -(def: pow/2 +(def pow/2 (syntax (_ [number <code>.any]) (in (list (` (n.* (~ number) (~ number))))))) -(def: pow/4 +(def pow/4 (syntax (_ [number <code>.any]) (in (list (` (..pow/2 (..pow/2 (~ number)))))))) -(def: repeated +(def repeated (syntax (_ [times <code>.nat token <code>.any]) (in (list.repeated times token)))) -(def: fresh_symbol +(def fresh_symbol (syntax (_ []) (do meta.monad [g!fresh (/.symbol "fresh")] (in (list g!fresh))))) -(def: random_lux +(def random_lux (Random [Nat Text .Lux]) (do [! random.monad] [seed random.nat @@ -111,14 +111,14 @@ .#eval (as (-> Type Code (Meta Any)) []) .#host []]]))) -(def: iterated +(def iterated (syntax (_ [cycle <code>.nat it <code>.any]) (in (list (case cycle 0 it _ (` (..iterated (~ (code.nat (-- cycle))) (~ it)))))))) -(def: test|expansion +(def test|expansion Test (do [! random.monad] [[seed symbol_prefix lux] ..random_lux @@ -187,7 +187,7 @@ false)))) )))) -(def: sum +(def sum (macro (_ tokens) (loop (again [tokens tokens output 0]) @@ -201,11 +201,11 @@ _ (meta.failure ""))))) -(def: sum' +(def sum' (macro (_ tokens lux) ((/.function ..sum) tokens lux))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/macro/code.lux b/stdlib/source/test/lux/macro/code.lux index b0479c538..ee22f74ce 100644 --- a/stdlib/source/test/lux/macro/code.lux +++ b/stdlib/source/test/lux/macro/code.lux @@ -27,21 +27,21 @@ [\\library ["[0]" /]]) -(def: random_text +(def random_text (Random Text) (random.alphabetic 10)) -(def: random_symbol +(def random_symbol (Random Symbol) (random.and ..random_text ..random_text)) -(def: (random_sequence random) +(def (random_sequence random) (All (_ a) (-> (Random a) (Random (List a)))) (do [! random.monad] [size (|> random.nat (at ! each (n.% 3)))] (random.list size random))) -(def: .public random +(def .public random (Random Code) (random.rec (function (_ random) @@ -58,7 +58,7 @@ (random#each /.tuple (..random_sequence random)) )))) -(def: (read source_code) +(def (read source_code) (-> Text (Try Code)) (let [parse (syntax.parse "" syntax.no_aliases @@ -72,7 +72,7 @@ {.#Right [end lux_code]} {try.#Success lux_code}))) -(def: (replacement_simulation [original substitute]) +(def (replacement_simulation [original substitute]) (-> [Code Code] (Random [Code Code])) (random.rec (function (_ replacement_simulation) @@ -101,7 +101,7 @@ (for_sequence /.tuple) ))))) -(def: for_format +(def for_format Test (`` (all _.and (~~ (with_template [<coverage> <random> <tag>] @@ -150,7 +150,7 @@ [/.local ..random_text .#Symbol] ))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/macro/local.lux b/stdlib/source/test/lux/macro/local.lux index 5c55670e7..96d883a6e 100644 --- a/stdlib/source/test/lux/macro/local.lux +++ b/stdlib/source/test/lux/macro/local.lux @@ -29,11 +29,11 @@ (/.let [!pow/2 (template (_ <scalar>) [(n.* <scalar> <scalar>)])] - (def: pow/2 + (def pow/2 (-> Nat Nat) (|>> !pow/2))) -(def: macro_error +(def macro_error (syntax (_ [macro <code>.any]) (function (_ compiler) (case ((macro.expansion macro) compiler) @@ -43,13 +43,13 @@ {try.#Success _} {try.#Failure "OOPS!"})))) -(def: (constant output) +(def (constant output) (-> Code Macro) ("lux macro" (function (_ inputs lux) {try.#Success [lux (list output)]}))) -(def: with +(def with (syntax (_ [name (<code>.tuple (<>.and <code>.text <code>.text)) constant <code>.any pre_remove <code>.bit @@ -72,7 +72,7 @@ (macro.full_expansion pre_expansion) (in (list pre_expansion)))))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/macro/pattern.lux b/stdlib/source/test/lux/macro/pattern.lux index 53d3435ce..b1047a7ea 100644 --- a/stdlib/source/test/lux/macro/pattern.lux +++ b/stdlib/source/test/lux/macro/pattern.lux @@ -22,12 +22,12 @@ [#left l #right r])) -(def: !pair +(def !pair (template (_ <left> <right>) [[..#left <left> ..#right <right>]])) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/macro/syntax.lux b/stdlib/source/test/lux/macro/syntax.lux index 8c851a778..8af853dbf 100644 --- a/stdlib/source/test/lux/macro/syntax.lux +++ b/stdlib/source/test/lux/macro/syntax.lux @@ -22,13 +22,13 @@ ["[1][0]" type ["[1]/[0]" variable]]]) -(def: +/3 +(def +/3 (/.syntax (_ [a <code>.any b <code>.any c <code>.any]) (in (list (` (all n.+ (~ a) (~ b) (~ c))))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/macro/syntax/check.lux b/stdlib/source/test/lux/macro/syntax/check.lux index cb43a209c..5177ef24b 100644 --- a/stdlib/source/test/lux/macro/syntax/check.lux +++ b/stdlib/source/test/lux/macro/syntax/check.lux @@ -19,14 +19,14 @@ ["$[0]" /// ["[1][0]" code]]) -(def: .public random +(def .public random (Random /.Check) (all random.and $///code.random $///code.random )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Check]) diff --git a/stdlib/source/test/lux/macro/syntax/declaration.lux b/stdlib/source/test/lux/macro/syntax/declaration.lux index f6a5a1973..87756b7e3 100644 --- a/stdlib/source/test/lux/macro/syntax/declaration.lux +++ b/stdlib/source/test/lux/macro/syntax/declaration.lux @@ -17,7 +17,7 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Declaration) (let [word (random.alphabetic 10)] (all random.and @@ -27,7 +27,7 @@ (random.list size word)) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Declaration]) diff --git a/stdlib/source/test/lux/macro/syntax/definition.lux b/stdlib/source/test/lux/macro/syntax/definition.lux index 504ff7e4b..b3fba4489 100644 --- a/stdlib/source/test/lux/macro/syntax/definition.lux +++ b/stdlib/source/test/lux/macro/syntax/definition.lux @@ -24,7 +24,7 @@ ["[1]/" // ["[1][0]" code]]]) -(def: .public random +(def .public random (Random /.Definition) (all random.and (random.alphabetic 5) @@ -33,7 +33,7 @@ random.bit )) -(def: compiler +(def compiler [.#info [.#target "FAKE" .#version "0.0.0" .#mode {.#Build} @@ -53,7 +53,7 @@ .#eval (as (-> Type Code (Meta Any)) []) .#host []]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Definition]) diff --git a/stdlib/source/test/lux/macro/syntax/export.lux b/stdlib/source/test/lux/macro/syntax/export.lux index 3b4e6adb1..f1a4c2ff0 100644 --- a/stdlib/source/test/lux/macro/syntax/export.lux +++ b/stdlib/source/test/lux/macro/syntax/export.lux @@ -18,7 +18,7 @@ [\\library ["[0]" /]]) -(def: export +(def export (Random [(Maybe Code) Nat]) (all random.and (|> random.bit @@ -26,7 +26,7 @@ random.maybe) random.nat)) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/lux/macro/syntax/input.lux b/stdlib/source/test/lux/macro/syntax/input.lux index 6de252987..19c15072d 100644 --- a/stdlib/source/test/lux/macro/syntax/input.lux +++ b/stdlib/source/test/lux/macro/syntax/input.lux @@ -22,14 +22,14 @@ ["$[0]" /// ["[1][0]" code]]) -(def: .public random +(def .public random (Random /.Input) (all random.and $///code.random $///code.random )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Input]) diff --git a/stdlib/source/test/lux/macro/syntax/type/variable.lux b/stdlib/source/test/lux/macro/syntax/type/variable.lux index 55ab5bcc1..e811c8a57 100644 --- a/stdlib/source/test/lux/macro/syntax/type/variable.lux +++ b/stdlib/source/test/lux/macro/syntax/type/variable.lux @@ -15,11 +15,11 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Variable) (random.alphabetic 10)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Variable]) diff --git a/stdlib/source/test/lux/macro/template.lux b/stdlib/source/test/lux/macro/template.lux index 715a0dbe2..ee2176248 100644 --- a/stdlib/source/test/lux/macro/template.lux +++ b/stdlib/source/test/lux/macro/template.lux @@ -24,11 +24,11 @@ (/.let [(!pow/2 <scalar>) [(nat.* <scalar> <scalar>)]] - (def: pow/2 + (def pow/2 (-> Nat Nat) (|>> !pow/2))) -(def: macro_error +(def macro_error (syntax (_ [macro <code>.any]) (function (_ compiler) (case ((macro.expansion macro) compiler) @@ -38,7 +38,7 @@ {try.#Success _} {try.#Failure "OOPS!"})))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/math.lux b/stdlib/source/test/lux/math.lux index 3695f4be8..4d3464ef6 100644 --- a/stdlib/source/test/lux/math.lux +++ b/stdlib/source/test/lux/math.lux @@ -28,15 +28,15 @@ ["[1]/[0]" continuous] ["[1]/[0]" fuzzy]]]) -(def: ratio/0 +(def ratio/0 Ratio [ratio.#numerator 0 ratio.#denominator 1]) -(def: complex/0 +(def complex/0 Complex [complex.#real +0.0 complex.#imaginary +0.0]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/lux/math/infix.lux b/stdlib/source/test/lux/math/infix.lux index 441df11b9..badd95dc1 100644 --- a/stdlib/source/test/lux/math/infix.lux +++ b/stdlib/source/test/lux/math/infix.lux @@ -14,7 +14,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/lux/math/logic/continuous.lux b/stdlib/source/test/lux/math/logic/continuous.lux index b4c4614e5..fd4c1d97f 100644 --- a/stdlib/source/test/lux/math/logic/continuous.lux +++ b/stdlib/source/test/lux/math/logic/continuous.lux @@ -13,7 +13,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/lux/math/logic/fuzzy.lux b/stdlib/source/test/lux/math/logic/fuzzy.lux index 9ea59ccd4..8aeab5de4 100644 --- a/stdlib/source/test/lux/math/logic/fuzzy.lux +++ b/stdlib/source/test/lux/math/logic/fuzzy.lux @@ -23,7 +23,7 @@ ["/[1]" // ["[1]" continuous]]]]) -(def: trivial +(def trivial Test (do random.monad [sample random.rev] @@ -34,7 +34,7 @@ (r.= //.true (/.full sample))) ))) -(def: simple +(def simple Test (do [! random.monad] [sample random.rev @@ -81,7 +81,7 @@ (/.membership set sample)))) ))) -(def: composition +(def composition Test (do [! random.monad] [sample random.rev @@ -163,7 +163,7 @@ (/.membership (/.difference bottom_set top_set) sample))))) ))) -(def: geometric +(def geometric Test (<| (_.covering /._) (_.for [/.Fuzzy]) @@ -287,7 +287,7 @@ inside_inner_range!))) )))) -(def: discrete +(def discrete Test (do random.monad [threshold random.nat @@ -304,7 +304,7 @@ (set.member? set sample)))) ))) -(def: gradient +(def gradient (Random [[Rev Rev] (Fuzzy Rev)]) (do random.monad [sample random.rev @@ -317,7 +317,7 @@ (in [[bottom top] (/.gradient bottom top)]))) -(def: threshold +(def threshold Test (do random.monad [[_ set] ..gradient @@ -332,7 +332,7 @@ (r.< threshold (/.membership set sample)))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Fuzzy]) @@ -341,7 +341,7 @@ [_ fuzzy] ..gradient .let [equivalence (is (Equivalence (/.Fuzzy Rev)) (implementation - (def: (= left right) + (def (= left right) (r.= (left sample) (right sample)))))]] (all _.and diff --git a/stdlib/source/test/lux/math/modular.lux b/stdlib/source/test/lux/math/modular.lux index 76098ff66..bccbdc3e0 100644 --- a/stdlib/source/test/lux/math/modular.lux +++ b/stdlib/source/test/lux/math/modular.lux @@ -28,13 +28,13 @@ ["/[1]" // ["[1]" modulus]]]]) -(def: .public (random modulus) +(def .public (random modulus) (All (_ %) (-> (//.Modulus %) (Random (/.Mod %)))) (at random.monad each (/.modular modulus) random.int)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Mod]) diff --git a/stdlib/source/test/lux/math/modulus.lux b/stdlib/source/test/lux/math/modulus.lux index a3f26cdf5..c360ffd2d 100644 --- a/stdlib/source/test/lux/math/modulus.lux +++ b/stdlib/source/test/lux/math/modulus.lux @@ -18,7 +18,7 @@ [\\library ["[0]" /]]) -(def: |divisor| +(def |divisor| (syntax (_ []) (do meta.monad [divisor meta.seed] @@ -26,13 +26,13 @@ 0 +1 _ (.int divisor)))))))) -(def: .public (random range) +(def .public (random range) (Ex (_ %) (-> Int (Random (/.Modulus %)))) (|> random.int (at random.monad each (i.% range)) (random.one (|>> /.modulus try.maybe)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Modulus]) diff --git a/stdlib/source/test/lux/math/number.lux b/stdlib/source/test/lux/math/number.lux index 9d8b8ce52..d5f49461e 100644 --- a/stdlib/source/test/lux/math/number.lux +++ b/stdlib/source/test/lux/math/number.lux @@ -24,11 +24,11 @@ ["[1][0]" ratio] ["[1][0]" complex]]) -(def: clean_commas +(def clean_commas (-> Text Text) (text.replaced "," "")) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/math/number/complex.lux b/stdlib/source/test/lux/math/number/complex.lux index ee1a6e210..2790964d4 100644 --- a/stdlib/source/test/lux/math/number/complex.lux +++ b/stdlib/source/test/lux/math/number/complex.lux @@ -19,10 +19,10 @@ ["[0]" int]]]]) ... This margin of error is necessary because floating-point arithmetic is not exact. -(def: margin_of_error +(def margin_of_error +0.000000001) -(def: dimension +(def dimension (Random Frac) (do [! random.monad] [factor (|> random.nat (at ! each (|>> (n.% 1000) (n.max 1)))) @@ -30,21 +30,21 @@ (in (f.* (|> factor .int int.frac) measure)))) -(def: .public random +(def .public random (Random /.Complex) (do random.monad [real ..dimension imaginary ..dimension] (in (/.complex real imaginary)))) -(def: angle +(def angle (Random /.Complex) (at random.monad each (|>> (revised /.#real (f.% +1.0)) (revised /.#imaginary (f.% +1.0))) ..random)) -(def: construction +(def construction Test (do random.monad [real ..dimension @@ -66,7 +66,7 @@ (/.not_a_number? (/.complex real f.not_a_number)))) ))) -(def: constant +(def constant Test (do random.monad [sample ..random @@ -88,7 +88,7 @@ (/.* /.i (/.* /.i sample))))) ))) -(def: absolute_value&argument +(def absolute_value&argument Test (do random.monad [real ..dimension @@ -122,7 +122,7 @@ (/.exp (/.* /.i (/.complex (/.argument sample))))))))) ))) -(def: number +(def number Test (do random.monad [x ..random @@ -165,7 +165,7 @@ (|> quotient (/.* y) (/.+ rem))))) ))) -(def: conjugate&reciprocal&signum&negation +(def conjugate&reciprocal&signum&negation Test (do random.monad [x ..random] @@ -204,12 +204,12 @@ absolute!))) ))) -(def: (trigonometric_symmetry forward backward angle) +(def (trigonometric_symmetry forward backward angle) (-> (-> /.Complex /.Complex) (-> /.Complex /.Complex) /.Complex Bit) (let [normal (|> angle forward backward)] (|> normal forward backward (/.approximately? ..margin_of_error normal)))) -(def: trigonometry +(def trigonometry Test (do [! random.monad] [angle ..angle] @@ -221,7 +221,7 @@ (_.coverage [/.tan /.atan] (trigonometric_symmetry /.tan /.atan angle))))) -(def: hyperbolic +(def hyperbolic Test (do [! random.monad] [angle ..angle] @@ -240,7 +240,7 @@ (/.tanh angle))) ))) -(def: exponentiation&logarithm +(def exponentiation&logarithm Test (do random.monad [x ..random] @@ -253,7 +253,7 @@ (|> x /.log /.exp (/.approximately? ..margin_of_error x))) ))) -(def: root +(def root Test (do [! random.monad] [sample ..random @@ -264,7 +264,7 @@ (list#each (/.pow' (|> degree .int int.frac))) (list.every? (/.approximately? ..margin_of_error sample)))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Complex]) diff --git a/stdlib/source/test/lux/math/number/frac.lux b/stdlib/source/test/lux/math/number/frac.lux index 88862c47f..9c97d2835 100644 --- a/stdlib/source/test/lux/math/number/frac.lux +++ b/stdlib/source/test/lux/math/number/frac.lux @@ -26,11 +26,11 @@ ["r" rev] ["[0]" i64]]]]) -(def: random +(def random (Random Frac) (at random.monad each (|>> (i.% +1,000,000) i.frac) random.int)) -(def: constant +(def constant Test (do random.monad [sample random.safe_frac] @@ -50,7 +50,7 @@ (/.not_a_number? sample))))) ))) -(def: predicate +(def predicate Test (do [! random.monad] [sample ..random @@ -75,7 +75,7 @@ (/.number? sample))) ))) -(def: conversion +(def conversion Test (all _.and (do [! random.monad] @@ -93,7 +93,7 @@ (|> expected r.frac /.rev (r.= expected)))) )) -(def: signature +(def signature Test (`` (all _.and (_.for [/.equivalence /.=] @@ -128,15 +128,15 @@ @.jvm (these <jvm>) (these))) -(def: margin_of_error +(def margin_of_error +0.0000001) -(def: (trigonometric_symmetry forward backward angle) +(def (trigonometric_symmetry forward backward angle) (-> (-> Frac Frac) (-> Frac Frac) Frac Bit) (let [normal (|> angle forward backward)] (|> normal forward backward (/.approximately? ..margin_of_error normal)))) -(def: test|math +(def test|math Test (all _.and (do [! random.monad] @@ -270,7 +270,7 @@ (|> (/.factorial of) (n.% of) (n.= 0))))) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [.Frac]) diff --git a/stdlib/source/test/lux/math/number/i16.lux b/stdlib/source/test/lux/math/number/i16.lux index d8ee85c4a..9fbc74498 100644 --- a/stdlib/source/test/lux/math/number/i16.lux +++ b/stdlib/source/test/lux/math/number/i16.lux @@ -14,11 +14,11 @@ ["i" int] ["[1][0]" i64]]]]) -(def: .public random +(def .public random (Random /.I16) (at random.functor each /.i16 random.i64)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.I16]) diff --git a/stdlib/source/test/lux/math/number/i32.lux b/stdlib/source/test/lux/math/number/i32.lux index 189e79b06..43b9d3547 100644 --- a/stdlib/source/test/lux/math/number/i32.lux +++ b/stdlib/source/test/lux/math/number/i32.lux @@ -14,11 +14,11 @@ ["i" int] ["[1][0]" i64]]]]) -(def: .public random +(def .public random (Random /.I32) (at random.functor each /.i32 random.i64)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.I32]) diff --git a/stdlib/source/test/lux/math/number/i64.lux b/stdlib/source/test/lux/math/number/i64.lux index 75324e869..c389f5119 100644 --- a/stdlib/source/test/lux/math/number/i64.lux +++ b/stdlib/source/test/lux/math/number/i64.lux @@ -18,7 +18,7 @@ ["n" nat] ["i" int]]]]) -(def: bit +(def bit Test (do [! random.monad] [pattern random.nat @@ -42,7 +42,7 @@ (/#= /.false (/.and (/.bit idx) pattern)))) ))) -(def: shift +(def shift Test (do [! random.monad] [pattern random.nat] @@ -69,7 +69,7 @@ movement!)))) ))) -(def: mask +(def mask Test (<| (_.for [/.Mask]) (do [! random.monad] @@ -118,7 +118,7 @@ (/.and (/.region offset size) pattern))))) )))) -(def: sub +(def sub Test (_.for [/.Sub] (do [! random.monad] @@ -146,7 +146,7 @@ (/#= expected actual))) )))))) -(def: signature +(def signature Test (all _.and (_.for [/.equivalence] @@ -159,7 +159,7 @@ ($monoid.spec n.equivalence /.conjunction random.nat)) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [.I64]) diff --git a/stdlib/source/test/lux/math/number/i8.lux b/stdlib/source/test/lux/math/number/i8.lux index edf503bf9..851d6aef7 100644 --- a/stdlib/source/test/lux/math/number/i8.lux +++ b/stdlib/source/test/lux/math/number/i8.lux @@ -14,11 +14,11 @@ ["i" int] ["[1][0]" i64]]]]) -(def: .public random +(def .public random (Random /.I8) (at random.functor each /.i8 random.i64)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.I8]) diff --git a/stdlib/source/test/lux/math/number/int.lux b/stdlib/source/test/lux/math/number/int.lux index 8f451d37e..9e343f98a 100644 --- a/stdlib/source/test/lux/math/number/int.lux +++ b/stdlib/source/test/lux/math/number/int.lux @@ -23,7 +23,7 @@ ["f" frac] ["[0]" i64]]]]) -(def: signature +(def signature Test (`` (all _.and (_.for [/.equivalence /.=] @@ -54,7 +54,7 @@ )) ))) -(def: predicate +(def predicate Test (do [! random.monad] [sample random.int] @@ -73,7 +73,7 @@ (not (/.odd? sample)))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [.Int]) diff --git a/stdlib/source/test/lux/math/number/nat.lux b/stdlib/source/test/lux/math/number/nat.lux index a29ce19a3..9d70c9702 100644 --- a/stdlib/source/test/lux/math/number/nat.lux +++ b/stdlib/source/test/lux/math/number/nat.lux @@ -21,7 +21,7 @@ [// ["f" frac]]]]) -(def: signature +(def signature Test (`` (all _.and (_.for [/.equivalence /.=] @@ -52,7 +52,7 @@ )) ))) -(def: predicate +(def predicate Test (do [! random.monad] [sample random.nat] @@ -62,7 +62,7 @@ (not (/.odd? sample)))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [.Nat]) diff --git a/stdlib/source/test/lux/math/number/ratio.lux b/stdlib/source/test/lux/math/number/ratio.lux index 536ce838c..147853cf7 100644 --- a/stdlib/source/test/lux/math/number/ratio.lux +++ b/stdlib/source/test/lux/math/number/ratio.lux @@ -20,13 +20,13 @@ [// ["n" nat (.open: "[1]#[0]" equivalence)]]]]) -(def: part +(def part (Random Nat) (at random.monad each (|>> (n.% 1,000,000) (n.max 1)) random.nat)) -(def: .public random +(def .public random (Random /.Ratio) (do random.monad [numerator ..part @@ -34,7 +34,7 @@ ..part)] (in (/.ratio numerator denominator)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Ratio]) diff --git a/stdlib/source/test/lux/math/number/rev.lux b/stdlib/source/test/lux/math/number/rev.lux index b7403a4f2..932ab3e25 100644 --- a/stdlib/source/test/lux/math/number/rev.lux +++ b/stdlib/source/test/lux/math/number/rev.lux @@ -23,7 +23,7 @@ ["f" frac] ["[0]" i64 (.open: "[1]#[0]" hash)]]]]) -(def: signature +(def signature Test (`` (all _.and (_.for [/.equivalence /.=] @@ -53,7 +53,7 @@ )) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [.Rev]) diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index bd253b16c..2b99ba948 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -38,13 +38,13 @@ ["[1][0]" configuration] ["[1][0]" version]]) -(def: !expect +(def !expect (template (_ <pattern> <value>) [(case <value> <pattern> true _ false)])) -(def: compiler_related +(def compiler_related Test (do random.monad [target (random.upper_case 1) @@ -105,7 +105,7 @@ (same? configuration it))))) ))) -(def: error_handling +(def error_handling Test (do random.monad [target (random.upper_case 1) @@ -191,7 +191,7 @@ (same? expected actual)))))) ))) -(def: module_related +(def module_related Test (do random.monad [target (random.upper_case 1) @@ -302,14 +302,14 @@ (same? expected_short actual_short))))))) )))) -(def: random_location +(def random_location (Random Location) (all random.and (random.upper_case 1) random.nat random.nat)) -(def: context_related +(def context_related (do [! random.monad] [target (random.upper_case 1) version (random.upper_case 1) @@ -373,7 +373,7 @@ (try.else false))) ))) -(def: definition_related +(def definition_related Test (do [! random.monad] [expected_current_module (random.upper_case 1) @@ -383,7 +383,7 @@ expected_type (at ! each (function (_ name) {.#Primitive name (list)}) (random.upper_case 1)) - expected_value (random.either (in .def:) + expected_value (random.either (in .def) (in .macro)) .let [expected_lux (is (-> Bit (Maybe Type) @@ -488,7 +488,7 @@ )))) ))) -(def: search_related +(def search_related Test (do [! random.monad] [expected_exported? random.bit @@ -499,7 +499,7 @@ expected_type (at ! each (function (_ name) {.#Primitive name (list)}) (random.upper_case 1)) - expected_value (random.either (in .def:) + expected_value (random.either (in .def) (in .macro)) .let [expected_lux (is (-> Bit (Maybe Type) @@ -662,7 +662,7 @@ alias!))) ))) -(def: label_related +(def label_related Test (do [! random.monad] [current_module (random.upper_case 1) @@ -801,7 +801,7 @@ ))))) ))) -(def: locals_related +(def locals_related Test (do [! random.monad] [current_module (random.upper_case 1) @@ -927,11 +927,11 @@ (try.else false)))) ))) -(def: injection +(def injection (Injection Meta) (at /.monad in)) -(def: (comparison init) +(def (comparison init) (-> Lux (Comparison Meta)) (function (_ == left right) (case [(/.result init left) @@ -942,7 +942,7 @@ _ false))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [.Meta .Lux]) diff --git a/stdlib/source/test/lux/meta/configuration.lux b/stdlib/source/test/lux/meta/configuration.lux index ce22166b8..ff85808b5 100644 --- a/stdlib/source/test/lux/meta/configuration.lux +++ b/stdlib/source/test/lux/meta/configuration.lux @@ -26,7 +26,7 @@ [\\library ["[0]" /]]) -(def: .public (random amount) +(def .public (random amount) (-> Nat (Random /.Configuration)) (case amount 0 (random#in /.empty) @@ -36,7 +36,7 @@ (at ! each (|>> (list.partial [feature value])) (random (-- amount)))))) -(def: failure +(def failure (syntax (_ [it <code>.any]) (function (_ lux) (case (macro.expansion it lux) @@ -46,7 +46,7 @@ {try.#Success _} {try.#Failure ""})))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Configuration]) diff --git a/stdlib/source/test/lux/meta/location.lux b/stdlib/source/test/lux/meta/location.lux index 36de9909c..5016b6aca 100644 --- a/stdlib/source/test/lux/meta/location.lux +++ b/stdlib/source/test/lux/meta/location.lux @@ -16,7 +16,7 @@ [macro ["[1][0]" code]]]) -(def: .public random +(def .public random (Random Location) (all random.and (random.alphabetic 10) @@ -24,7 +24,7 @@ random.nat )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [.Location]) diff --git a/stdlib/source/test/lux/meta/symbol.lux b/stdlib/source/test/lux/meta/symbol.lux index 76bbb76c6..3e279949b 100644 --- a/stdlib/source/test/lux/meta/symbol.lux +++ b/stdlib/source/test/lux/meta/symbol.lux @@ -20,12 +20,12 @@ [\\library ["[0]" /]]) -(def: .public (random module_size short_size) +(def .public (random module_size short_size) (-> Nat Nat (Random Symbol)) (random.and (random.alphabetic module_size) (random.alphabetic short_size))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/meta/version.lux b/stdlib/source/test/lux/meta/version.lux index 3a59251de..6767da8dd 100644 --- a/stdlib/source/test/lux/meta/version.lux +++ b/stdlib/source/test/lux/meta/version.lux @@ -23,7 +23,7 @@ [\\library ["[0]" /]]) -(def: failure +(def failure (syntax (_ [it <code>.any]) (function (_ lux) (case (macro.expansion it lux) @@ -33,7 +33,7 @@ {try.#Success _} {try.#Failure ""})))) -(def: .public test +(def .public test Test (<| (_.covering /._) (with_expansions [<current> (/.current) diff --git a/stdlib/source/test/lux/program.lux b/stdlib/source/test/lux/program.lux index 7e3430387..91078279e 100644 --- a/stdlib/source/test/lux/program.lux +++ b/stdlib/source/test/lux/program.lux @@ -21,13 +21,13 @@ [\\library ["[0]" /]]) -(def: actual_program +(def actual_program (syntax (_ [actual_program (<| <code>.form (<>.after (<code>.this_text "lux def program")) <code>.any)]) (in (list actual_program)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/lux/static.lux b/stdlib/source/test/lux/static.lux index acaac3bda..ebc642bb7 100644 --- a/stdlib/source/test/lux/static.lux +++ b/stdlib/source/test/lux/static.lux @@ -21,7 +21,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (for @.old (_.property "PLACEHOLDER" true)) diff --git a/stdlib/source/test/lux/target.lux b/stdlib/source/test/lux/target.lux index 538499f33..549a9059f 100644 --- a/stdlib/source/test/lux/target.lux +++ b/stdlib/source/test/lux/target.lux @@ -23,19 +23,19 @@ /.php /.r /.scheme)] - (def: all + (def all (List /.Target) (list <targets>)) - (def: unique + (def unique (Set /.Target) (set.of_list text.hash ..all)) - (def: verdict + (def verdict (n.= (list.size ..all) (set.size ..unique))) - (def: .public test + (def .public test Test (<| (_.covering /._) (_.for [/.Target]) diff --git a/stdlib/source/test/lux/target/js.lux b/stdlib/source/test/lux/target/js.lux index dfdc02ab0..82462679f 100644 --- a/stdlib/source/test/lux/target/js.lux +++ b/stdlib/source/test/lux/target/js.lux @@ -29,7 +29,7 @@ [\\library ["[0]" /]]) -(def: (eval code) +(def (eval code) (-> /.Expression (Try (Maybe Any))) ... Note: I have to call "eval" this way ... in order to avoid a quirk of calling eval in Node @@ -39,7 +39,7 @@ {.#None} {.#Some return})))) -(def: (expression ??? it) +(def (expression ??? it) (-> (-> Any Bit) /.Expression Bit) (|> it ..eval @@ -48,10 +48,10 @@ (try.else false))) (with_template [<range>] - [(`` (def: (~~ (template.symbol ["as_int_" <range>])) + [(`` (def (~~ (template.symbol ["as_int_" <range>])) (-> Int Int) (|>> (i64.and (static.nat (-- (i64.left_shifted <range> 1))))))) - (`` (def: (~~ (template.symbol ["int_" <range>])) + (`` (def (~~ (template.symbol ["int_" <range>])) (Random Int) (do [! random.monad] [negative? random.bit @@ -66,7 +66,7 @@ [32] ) -(def: test|literal +(def test|literal Test (do [! random.monad] [boolean random.bit @@ -96,7 +96,7 @@ (/.string string))) ))) -(def: test|boolean +(def test|boolean Test (do [! random.monad] [left random.bit @@ -116,7 +116,7 @@ (/.not (/.boolean left)))) )))) -(def: test|number +(def test|number Test (do [! random.monad] [parameter (random.only (|>> (f.= +0.0) not) @@ -149,7 +149,7 @@ )) )))) -(def: test|i32 +(def test|i32 Test (do [! random.monad] [left ..int_32 @@ -202,7 +202,7 @@ (/.bit_not (/.i32 i32))))) )))) -(def: test|array +(def test|array Test (do [! random.monad] [size (at ! each (|>> (n.% 10) ++) random.nat) @@ -222,7 +222,7 @@ (/.= /.undefined))))) ))) -(def: test|object +(def test|object Test (do [! random.monad] [expected random.safe_frac @@ -251,7 +251,7 @@ (/.= /.undefined)))) ))) -(def: test|computation +(def test|computation Test (do [! random.monad] [test random.bit @@ -303,7 +303,7 @@ (/.number then)))) ))) -(def: test|expression +(def test|expression Test (do [! random.monad] [dummy random.safe_frac @@ -318,7 +318,7 @@ (/., (/.number dummy) (/.number expected)))) )))) -(def: test/var +(def test/var Test (do [! random.monad] [number/0 random.safe_frac @@ -351,7 +351,7 @@ (list (/.number number/0))))) ))) -(def: test/location +(def test/location Test (do [! random.monad] [number/0 random.safe_frac @@ -442,7 +442,7 @@ ..test/var) ))) -(def: test|label +(def test|label Test (do [! random.monad] [input ..int_16 @@ -549,7 +549,7 @@ )) ))) -(def: test|loop +(def test|loop Test (do [! random.monad] [input ..int_16 @@ -601,7 +601,7 @@ ..test|label) ))) -(def: test|exception +(def test|exception Test (do [! random.monad] [expected random.safe_frac @@ -625,7 +625,7 @@ (list)))) ))) -(def: test|apply +(def test|apply Test (do [! random.monad] [number/0 random.safe_frac @@ -658,7 +658,7 @@ (/.number number/2))))) )))) -(def: test|function +(def test|function Test (do [! random.monad] [number/0 random.safe_frac @@ -701,7 +701,7 @@ ..test|apply ))) -(def: test|branching +(def test|branching Test (do [! random.monad] [number/0 random.safe_frac @@ -762,7 +762,7 @@ ))) ))) -(def: test|statement +(def test|statement Test (do [! random.monad] [number/0 random.safe_frac @@ -832,7 +832,7 @@ ..test|loop) )))) -(def: .public test +(def .public test Test (do [! random.monad] [] diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index 3b9ad317c..322631e71 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -54,7 +54,7 @@ ["[1][0]" type (.only Type) ["[0]" category (.only Value Object Class)]]]]) -(def: method_modifier +(def method_modifier (all /modifier#composite /method.public /method.static)) @@ -100,7 +100,7 @@ (getClass [] (java/lang/Class java/lang/Object)) (toString [] java/lang/String)) -(def: class_name +(def class_name (Random Text) (do random.monad [super_package (random.lower_case 10) @@ -110,15 +110,15 @@ /name.external_separator package /name.external_separator name)))) -(def: (get_method name class) +(def (get_method name class) (-> Text (java/lang/Class java/lang/Object) java/lang/reflect/Method) (java/lang/Class::getDeclaredMethod (ffi.as_string name) (ffi.array (java/lang/Class java/lang/Object) 0) class)) -(def: $Object (/type.class "java.lang.Object" (list))) +(def $Object (/type.class "java.lang.Object" (list))) -(def: (bytecode test bytecode) +(def (bytecode test bytecode) (-> (-> Any Bit) (Bytecode Any) (Random Bit)) (do random.monad [class_name ..class_name @@ -158,19 +158,19 @@ #random (Random a) #literal (-> a (Bytecode Any))])) -(def: $Boolean +(def $Boolean (/type.class "java.lang.Boolean" (list))) -(def: $Boolean::wrap +(def $Boolean::wrap (/.invokestatic ..$Boolean "valueOf" (/type.method [(list) (list /type.boolean) ..$Boolean (list)]))) -(def: $Boolean::random (as (Random java/lang/Boolean) random.bit)) -(def: !false (|> 0 .i64 i32.i32 /.int)) -(def: !true (|> 1 .i64 i32.i32 /.int)) -(def: ($Boolean::literal value) +(def $Boolean::random (as (Random java/lang/Boolean) random.bit)) +(def !false (|> 0 .i64 i32.i32 /.int)) +(def !true (|> 1 .i64 i32.i32 /.int)) +(def ($Boolean::literal value) (-> java/lang/Boolean (Bytecode Any)) (if (as Bit value) ..!true ..!false)) -(def: $Boolean::primitive +(def $Boolean::primitive (Primitive java/lang/Boolean) [#unboxed /type.boolean #boxed ..$Boolean @@ -178,17 +178,17 @@ #random ..$Boolean::random #literal ..$Boolean::literal]) -(def: $Byte +(def $Byte (/type.class "java.lang.Byte" (list))) -(def: $Byte::wrap +(def $Byte::wrap (/.invokestatic ..$Byte "valueOf" (/type.method [(list) (list /type.byte) ..$Byte (list)]))) -(def: $Byte::random +(def $Byte::random (Random java/lang/Byte) (at random.monad each (|>> (as java/lang/Long) ffi.long_to_byte) random.int)) -(def: $Byte::literal +(def $Byte::literal (-> java/lang/Byte (Bytecode Any)) (|>> ffi.byte_to_long (as I64) i32.i32 /.int)) -(def: $Byte::primitive +(def $Byte::primitive (Primitive java/lang/Byte) [#unboxed /type.byte #boxed ..$Byte @@ -196,17 +196,17 @@ #random ..$Byte::random #literal ..$Byte::literal]) -(def: $Short +(def $Short (/type.class "java.lang.Short" (list))) -(def: $Short::wrap +(def $Short::wrap (/.invokestatic ..$Short "valueOf" (/type.method [(list) (list /type.short) ..$Short (list)]))) -(def: $Short::random +(def $Short::random (Random java/lang/Short) (at random.monad each (|>> (as java/lang/Long) ffi.long_to_short) random.int)) -(def: $Short::literal +(def $Short::literal (-> java/lang/Short (Bytecode Any)) (|>> ffi.short_to_long (as I64) i32.i32 /.int)) -(def: $Short::primitive +(def $Short::primitive (Primitive java/lang/Short) [#unboxed /type.short #boxed ..$Short @@ -214,17 +214,17 @@ #random ..$Short::random #literal ..$Short::literal]) -(def: $Integer +(def $Integer (/type.class "java.lang.Integer" (list))) -(def: $Integer::wrap +(def $Integer::wrap (/.invokestatic ..$Integer "valueOf" (/type.method [(list) (list /type.int) ..$Integer (list)]))) -(def: $Integer::random +(def $Integer::random (Random java/lang/Integer) (at random.monad each (|>> (as java/lang/Long) ffi.long_to_int) random.int)) -(def: $Integer::literal +(def $Integer::literal (-> java/lang/Integer (Bytecode Any)) (|>> ffi.int_to_long (as I64) i32.i32 /.int)) -(def: $Integer::primitive +(def $Integer::primitive (Primitive java/lang/Integer) [#unboxed /type.int #boxed ..$Integer @@ -232,11 +232,11 @@ #random ..$Integer::random #literal ..$Integer::literal]) -(def: $Long (/type.class "java.lang.Long" (list))) -(def: $Long::wrap (/.invokestatic ..$Long "valueOf" (/type.method [(list) (list /type.long) ..$Long (list)]))) -(def: $Long::random (as (Random java/lang/Long) random.int)) -(def: $Long::literal (-> java/lang/Long (Bytecode Any)) (|>> (as Int) /.long)) -(def: $Long::primitive +(def $Long (/type.class "java.lang.Long" (list))) +(def $Long::wrap (/.invokestatic ..$Long "valueOf" (/type.method [(list) (list /type.long) ..$Long (list)]))) +(def $Long::random (as (Random java/lang/Long) random.int)) +(def $Long::literal (-> java/lang/Long (Bytecode Any)) (|>> (as Int) /.long)) +(def $Long::primitive (Primitive java/lang/Long) [#unboxed /type.long #boxed ..$Long @@ -244,19 +244,19 @@ #random ..$Long::random #literal ..$Long::literal]) -(def: $Float (/type.class "java.lang.Float" (list))) -(def: $Float::wrap (/.invokestatic ..$Float "valueOf" (/type.method [(list) (list /type.float) ..$Float (list)]))) -(def: $Float::random +(def $Float (/type.class "java.lang.Float" (list))) +(def $Float::wrap (/.invokestatic ..$Float "valueOf" (/type.method [(list) (list /type.float) ..$Float (list)]))) +(def $Float::random (Random java/lang/Float) (at random.monad each (|>> (as java/lang/Double) ffi.double_to_float) random.frac)) -(def: $Float::literal /.float) -(def: valid_float +(def $Float::literal /.float) +(def valid_float (Random java/lang/Float) (random.only (|>> ffi.float_to_double (as Frac) f.not_a_number? not) ..$Float::random)) -(def: $Float::primitive +(def $Float::primitive (Primitive java/lang/Float) [#unboxed /type.float #boxed ..$Float @@ -264,17 +264,17 @@ #random ..valid_float #literal ..$Float::literal]) -(def: $Double (/type.class "java.lang.Double" (list))) -(def: $Double::wrap (/.invokestatic ..$Double "valueOf" (/type.method [(list) (list /type.double) ..$Double (list)]))) -(def: $Double::random (as (Random java/lang/Double) random.frac)) -(def: $Double::literal +(def $Double (/type.class "java.lang.Double" (list))) +(def $Double::wrap (/.invokestatic ..$Double "valueOf" (/type.method [(list) (list /type.double) ..$Double (list)]))) +(def $Double::random (as (Random java/lang/Double) random.frac)) +(def $Double::literal (-> java/lang/Double (Bytecode Any)) /.double) -(def: valid_double +(def valid_double (Random java/lang/Double) (random.only (|>> (as Frac) f.not_a_number? not) ..$Double::random)) -(def: $Double::primitive +(def $Double::primitive (Primitive java/lang/Double) [#unboxed /type.double #boxed ..$Double @@ -282,17 +282,17 @@ #random ..valid_double #literal ..$Double::literal]) -(def: $Character +(def $Character (/type.class "java.lang.Character" (list))) -(def: $Character::wrap +(def $Character::wrap (/.invokestatic ..$Character "valueOf" (/type.method [(list) (list /type.char) ..$Character (list)]))) -(def: $Character::random +(def $Character::random (Random java/lang/Character) (at random.monad each (|>> (as java/lang/Long) ffi.long_to_int ffi.int_to_char) random.int)) -(def: $Character::literal +(def $Character::literal (-> java/lang/Character (Bytecode Any)) (|>> ffi.char_to_long (as I64) i32.i32 /.int)) -(def: $Character::primitive +(def $Character::primitive (Primitive java/lang/Character) [#unboxed /type.char #boxed ..$Character @@ -300,18 +300,18 @@ #random ..$Character::random #literal ..$Character::literal]) -(def: $String +(def $String (/type.class "java.lang.String" (list))) -(def: $String::random +(def $String::random (as (Random java/lang/String) (random.alphabetic 10))) -(def: $String::literal +(def $String::literal (-> java/lang/String (Bytecode Any)) (|>> (as Text) /.string)) -(def: $String::primitive +(def $String::primitive (Primitive java/lang/String) [#unboxed ..$String #boxed ..$String @@ -320,7 +320,7 @@ #literal ..$String::literal]) (with_template [<name> <bits> <type> <push> <wrap> <message> <to_long> <signed>] - [(def: <name> + [(def <name> Test (do [! random.monad] [expected (at ! each (i64.and (i64.mask <bits>)) random.nat)] @@ -339,7 +339,7 @@ ) (with_template [<name> <type>] - [(def: <name> + [(def <name> (template (_ <old_extension> <new_extension>) [(is (-> <type> <type> <type>) (function (_ parameter subject) @@ -357,7 +357,7 @@ [double/2 java/lang/Double] ) -(def: int+long/2 +(def int+long/2 (template (_ <old_extension> <new_extension>) [(is (-> java/lang/Integer java/lang/Long java/lang/Long) (function (_ parameter subject) @@ -369,7 +369,7 @@ (<new_extension> ("jvm object cast" parameter) ("jvm object cast" subject))))))])) -(def: int +(def int Test (let [int (is (-> java/lang/Integer (Bytecode Any) (Random Bit)) (function (_ expected bytecode) @@ -450,7 +450,7 @@ bitwise) ))) -(def: long +(def long Test (let [long (is (-> java/lang/Long (Bytecode Any) (Random Bit)) (function (_ expected bytecode) @@ -549,7 +549,7 @@ comparison) ))) -(def: float +(def float Test (let [float (is (-> java/lang/Float (Bytecode Any) (Random Bit)) (function (_ expected bytecode) @@ -650,7 +650,7 @@ comparison) ))) -(def: double +(def double Test (let [double (is (-> java/lang/Double (Bytecode Any) (Random Bit)) (function (_ expected bytecode) @@ -745,7 +745,7 @@ comparison) ))) -(def: primitive +(def primitive Test (all _.and (<| (_.context "byte") @@ -762,7 +762,7 @@ ..double) )) -(def: object +(def object Test (let [!object (is (Bytecode Any) (do /.monad @@ -803,7 +803,7 @@ ..$Boolean::wrap)) ))) -(def: method +(def method Test (all _.and (<| (_.lifted "INVOKESTATIC") @@ -852,7 +852,7 @@ ..$Long::wrap)) )) -(def: field +(def field Test (do random.monad [class_name ..class_name @@ -924,7 +924,7 @@ {try.#Failure error} false)))) -(def: array +(def array Test (let [!length (is (-> Nat (Bytecode Any)) (function (_ size) @@ -1058,7 +1058,7 @@ $Long::wrap)))) ))) -(def: !::= +(def !::= (template (_ <type> <old> <new>) [(is (-> <type> Any Bit) (function (_ expected) @@ -1068,7 +1068,7 @@ @.jvm (|>> (as <type>) "jvm object cast" (<new> ("jvm object cast" (as <type> expected)))))))])) -(def: conversion +(def conversion Test (let [conversion (is (All (_ a z) (-> (Primitive a) (Primitive z) (Bytecode Any) (-> a z) (-> z Any Bit) (Random Bit))) @@ -1124,7 +1124,7 @@ (_.lifted "D2F" (conversion ..$Double::primitive ..$Float::primitive /.d2f (|>> ffi.double_to_float) float::=)))) ))) -(def: value +(def value Test (all _.and (<| (_.context "primitive") @@ -1141,7 +1141,7 @@ ..conversion) )) -(def: registry +(def registry Test (let [store_and_load (is (All (_ a) (-> (Random a) (-> a (Bytecode Any)) (Bytecode Any) @@ -1252,7 +1252,7 @@ (store_and_load ..$String::random ..$String::literal /.nop [/.astore /.aload] test))))) ))) -(def: stack +(def stack Test (do random.monad [expected/1 $String::random @@ -1328,7 +1328,7 @@ double) ))) -(def: resource +(def resource Test (all _.and (<| (_.context "registry") @@ -1337,7 +1337,7 @@ ..stack) )) -(def: return +(def return Test (let [primitive_return (is (All (_ a) (-> (Primitive a) (Bytecode Any) (Maybe (-> a (Bytecode Any))) (-> a Any Bit) (Random Bit))) (function (_ primitive return substitute test) @@ -1407,7 +1407,7 @@ (function (_ expected actual) (text#= (as Text expected) (as Text actual))))) ))) -(def: branching +(def branching Test (do random.monad [expected ..$Long::random @@ -1469,7 +1469,7 @@ reference_comparison ))) -(def: jump +(def jump Test (do random.monad [expected ..$Long::random @@ -1493,7 +1493,7 @@ (_.lifted "GOTO" (jump /.goto)) (_.lifted "GOTO_W" (jump /.goto_w))))) -(def: switch +(def switch Test (all _.and (<| (_.lifted "TABLESWITCH") @@ -1548,7 +1548,7 @@ ..$Long::wrap)) )) -(def: exception +(def exception Test (do random.monad [expected ..$Long::random @@ -1578,7 +1578,7 @@ _ (/.set_label @return)] ..$Long::wrap)))) -(def: code +(def code Test (all _.and (<| (_.context "return") @@ -1593,7 +1593,7 @@ ..exception) )) -(def: instruction +(def instruction Test (all _.and (<| (_.context "value") @@ -1604,7 +1604,7 @@ ..code) )) -(def: inheritance +(def inheritance Test (do random.monad [abstract_class ..class_name @@ -1746,7 +1746,7 @@ {try.#Failure error} false)))) -(def: .public test +(def .public test Test (<| (_.context (%.symbol (symbol .._))) (all _.and diff --git a/stdlib/source/test/lux/target/lua.lux b/stdlib/source/test/lux/target/lua.lux index e8c1057c5..0ada22cf1 100644 --- a/stdlib/source/test/lux/target/lua.lux +++ b/stdlib/source/test/lux/target/lua.lux @@ -35,7 +35,7 @@ ... http://www.lua.org/manual/5.3/manual.html#pdf-load (ffi.import (load [Text] "?" (-> Any Any))) -(def: (expression ??? it) +(def (expression ??? it) (-> (-> Any Bit) /.Expression Bit) (|> it /.code @@ -44,7 +44,7 @@ (maybe#each (|>> (function.on []) ???)) (maybe.else false))) -(def: test|literal +(def test|literal Test (do [! random.monad] [boolean random.bit @@ -73,7 +73,7 @@ (/.string string))) ))) -(def: test|boolean +(def test|boolean Test (do [! random.monad] [left random.bit @@ -94,7 +94,7 @@ )))) (with_template [<bits>] - [(`` (def: (~~ (template.symbol [int_ <bits>])) + [(`` (def (~~ (template.symbol [int_ <bits>])) (Random Int) (let [mask (|> 1 (i64.left_shifted (-- <bits>)) --)] (random#each (|>> (i64.and mask) .int) random.nat))))] @@ -103,7 +103,7 @@ [32] ) -(def: test|int +(def test|int Test (do [! random.monad] [left random.int @@ -146,7 +146,7 @@ (/.// (/.int parameter) (/.int subject))))) )))) -(def: test|float +(def test|float Test (do [! random.monad] [parameter (random.only (|>> (f.= +0.0) not) @@ -180,7 +180,7 @@ )) )))) -(def: test|string +(def test|string Test (do random.monad [left (random.lower_case 8) @@ -193,7 +193,7 @@ (/.concat (/.string right))))) ))) -(def: test|array +(def test|array Test (do [! random.monad] [size (at ! each (|>> (n.% 10) ++) random.nat) @@ -216,7 +216,7 @@ (/.length (/.array (list#each /.float items))))) ))) -(def: test|table +(def test|table Test (do [! random.monad] [expected random.safe_frac @@ -255,7 +255,7 @@ (/.apply (list))))) ))) -(def: test|computation +(def test|computation Test (do [! random.monad] [test random.bit @@ -304,7 +304,7 @@ (/.float then)))) ))) -(def: test|expression +(def test|expression Test (`` (all _.and (_.for [/.Literal] @@ -313,7 +313,7 @@ ..test|computation) ))) -(def: test/var +(def test/var Test (do [! random.monad] [float/0 random.safe_frac @@ -354,7 +354,7 @@ (/.apply (list (/.float float/0)))))) ))) -(def: test/location +(def test/location Test (do [! random.monad] [float/0 random.safe_frac @@ -406,7 +406,7 @@ ..test/var) ))) -(def: test|label +(def test|label Test (do [! random.monad] [input ..int_16 @@ -496,7 +496,7 @@ (/.apply (list (/.int input)))))) ))) -(def: test|loop +(def test|loop Test (do [! random.monad] [input ..int_16 @@ -554,7 +554,7 @@ ..test|label) ))) -(def: test|exception +(def test|exception Test (do [! random.monad] [expected random.safe_frac @@ -599,7 +599,7 @@ (/.apply (list))))) ))) -(def: test|function +(def test|function Test (do [! random.monad] [float/0 random.safe_frac @@ -640,7 +640,7 @@ ))) ))) -(def: test|branching +(def test|branching Test (do [! random.monad] [float/0 random.safe_frac @@ -664,7 +664,7 @@ (/.apply (list))))) ))) -(def: test|binding +(def test|binding Test (all _.and ..test|function @@ -672,7 +672,7 @@ ..test/location) )) -(def: test|control +(def test|control Test (all _.and ..test|branching @@ -680,7 +680,7 @@ ..test|exception )) -(def: test|statement +(def test|statement Test (do [! random.monad] [float/0 random.safe_frac @@ -699,7 +699,7 @@ ..test|control )))) -(def: .public test +(def .public test Test (do [! random.monad] [.let [random (at ! each /.int random.int)] diff --git a/stdlib/source/test/lux/target/python.lux b/stdlib/source/test/lux/target/python.lux index b31a398fc..44c9e4dc9 100644 --- a/stdlib/source/test/lux/target/python.lux +++ b/stdlib/source/test/lux/target/python.lux @@ -34,7 +34,7 @@ (ffi.import (eval [Text] "try" "?" Any)) -(def: (expression ??? it) +(def (expression ??? it) (-> (-> Any Bit) (/.Expression Any) Bit) (|> it /.code @@ -43,7 +43,7 @@ (maybe.else false))) (try.else false))) -(def: test|literal +(def test|literal Test (do [! random.monad] [bool random.bit @@ -80,7 +80,7 @@ (/.unicode string))) ))) -(def: test|bool +(def test|bool Test (do [! random.monad] [left random.bit @@ -100,7 +100,7 @@ (/.not (/.bool left)))) )))) -(def: test|float +(def test|float Test (do [! random.monad] [parameter (random.only (|>> (f.= +0.0) not) @@ -140,18 +140,18 @@ (/.repr/1 (/.float subject)))) )))) -(def: python_3? +(def python_3? (/.Expression Any) (|> (/.__import__/1 (/.unicode "sys")) (/.the "version_info") (/.the "major") (/.= (/.int +3)))) -(def: int_16 +(def int_16 (-> Int Int) (i64.and (-- (i64.left_shifted 15 1)))) -(def: test|int +(def test|int Test (do [! random.monad] [left random.int @@ -206,7 +206,7 @@ (/.long left)))) )))) -(def: test|text +(def test|text Test (do [! random.monad] [expected_code (at ! each (n.% 128) random.nat) @@ -224,7 +224,7 @@ (/.unichr/1 (/.unicode/1 (/.string expected_char))))))) ))) -(def: test|array +(def test|array Test (do [! random.monad] [size (at ! each (|>> (n.% 10) ++) random.nat) @@ -261,7 +261,7 @@ /.len/1))) ))) -(def: test|dict +(def test|dict Test (do [! random.monad] [expected random.safe_frac @@ -281,7 +281,7 @@ (/.in? (/.dict (list [field (/.float expected)])) field)))) ))) -(def: test|computation +(def test|computation Test (do [! random.monad] [test random.bit @@ -331,7 +331,7 @@ (/.is $arg/0 (/.+ $arg/1 $arg/1))))))) ))) -(def: test|function +(def test|function Test (do [! random.monad] [float/0 random.safe_frac @@ -353,7 +353,7 @@ (all /.+ $arg/0 $arg/1 $arg/2))))) ))) -(def: test|var +(def test|var Test (do [! random.monad] [expected/0 random.safe_frac @@ -412,7 +412,7 @@ )) ))) -(def: test|expression +(def test|expression Test (do [! random.monad] [dummy random.safe_frac @@ -433,7 +433,7 @@ (ffi.import (dict [] ..Dict)) -(def: (statement it) +(def (statement it) (-> (-> /.SVar (/.Statement Any)) Any) (let [$output (static.random (|>> %.nat (format "output_") code.text) random.nat) @@ -442,7 +442,7 @@ ("python exec" (/.code (it (/.var $output))) (as_expected environment)) (Dict::get $output environment)))) -(def: test|access +(def test|access Test (do [! random.monad] [$var/0 (at ! each (|>> %.nat (format "v0_") /.var) random.nat) @@ -480,7 +480,7 @@ (f.= expected/0))))) ))) -(def: test|location +(def test|location Test (do [! random.monad] [$var/0 (at ! each (|>> %.nat (format "v0_") /.var) random.nat) @@ -591,7 +591,7 @@ ..test|access) ))) -(def: test|exception +(def test|exception Test (do [! random.monad] [expected_error (random.upper_case 10) @@ -637,7 +637,7 @@ false))) ))) -(def: test|loop +(def test|loop Test (do [! random.monad] [base (at ! each (n.% 100) random.nat) @@ -742,7 +742,7 @@ (n.= expected))) ))) -(def: test|statement +(def test|statement Test (do [! random.monad] [$def (at ! each (|>> %.nat (format "def_") /.var) random.nat) @@ -810,7 +810,7 @@ ..test|loop) ))) -(def: random_expression +(def random_expression (Random /.Literal) (all random.either (random#each /.bool random.bit) @@ -819,7 +819,7 @@ (random#each /.string (random.lower_case 1)) )) -(def: .public test +(def .public test Test (do [! random.monad] [expected ..random_expression] diff --git a/stdlib/source/test/lux/target/ruby.lux b/stdlib/source/test/lux/target/ruby.lux index 011720095..7c6b3fcf6 100644 --- a/stdlib/source/test/lux/target/ruby.lux +++ b/stdlib/source/test/lux/target/ruby.lux @@ -39,7 +39,7 @@ (ffi.import (eval [Text] "try" "?" Any)) -(def: (expression ??? it) +(def (expression ??? it) (-> (-> Any Bit) /.Expression Bit) (|> it /.code @@ -48,7 +48,7 @@ (maybe.else false))) (try.else false))) -(def: nil +(def nil (-> /.Expression Bit) (|>> /.code ..eval @@ -57,7 +57,7 @@ {.#Some _} false))) (try.else false))) -(def: test|literal +(def test|literal Test (do [! random.monad] [bool random.bit @@ -84,7 +84,7 @@ (/.do "id2name" (list) {.#None} (/.symbol string)))) ))) -(def: test|bool +(def test|bool Test (do [! random.monad] [left random.bit @@ -104,7 +104,7 @@ (/.not (/.bool left)))) )))) -(def: test|float +(def test|float Test (do [! random.monad] [parameter (random.only (|>> (f.= +0.0) not) @@ -138,11 +138,11 @@ )) )))) -(def: int_16 +(def int_16 (-> Int Int) (i64.and (-- (i64.left_shifted 15 1)))) -(def: test|int +(def test|int Test (do [! random.monad] [left random.int @@ -179,7 +179,7 @@ (/.int i16))))) )))) -(def: test|array +(def test|array Test (do [! random.monad] [size (at ! each (|>> (n.% 10) ++) random.nat) @@ -208,7 +208,7 @@ (/.the "length")))) ))) -(def: test|hash +(def test|hash Test (do [! random.monad] [expected random.safe_frac @@ -227,7 +227,7 @@ (/.= /.nil))))) ))) -(def: test|object +(def test|object Test (do [! random.monad] [size (at ! each (|>> (n.% 10) ++) random.nat) @@ -327,7 +327,7 @@ )) ))) -(def: test|io +(def test|io Test (<| (do [! random.monad] [left (random.upper_case 5) @@ -397,7 +397,7 @@ )) ))) -(def: test|computation +(def test|computation Test (do [! random.monad] [test random.bit @@ -429,7 +429,7 @@ (/.float then)))) ))) -(def: test|global +(def test|global Test (do [! random.monad] [float/0 random.safe_frac @@ -483,7 +483,7 @@ (/.apply_lambda (list))))) ))) -(def: test|local_var +(def test|local_var Test (do [! random.monad] [float/0 random.safe_frac @@ -503,7 +503,7 @@ (/.apply_lambda (list))))) ))) -(def: test|instance_var +(def test|instance_var Test (do [! random.monad] [float/0 random.safe_frac @@ -575,7 +575,7 @@ (/.apply_lambda (list))))) ))) -(def: test|static_var +(def test|static_var Test (do [! random.monad] [int/0 (at ! each (|>> (n.% 10) ++ .int) @@ -601,7 +601,7 @@ (/.apply_lambda (list))))) ))) -(def: test|variadic +(def test|variadic Test (do [! random.monad] [$inputs (at ! each /.local (random.lower_case 10)) @@ -633,7 +633,7 @@ (/.apply_lambda (list (/.double_splat (/.hash (list.zipped_2 keys vals))))))))) ))) -(def: test|var +(def test|var Test (do [! random.monad] [float/0 random.safe_frac @@ -670,7 +670,7 @@ ..test|variadic ))) -(def: test|location +(def test|location Test (do [! random.monad] [float/0 random.safe_frac @@ -699,7 +699,7 @@ )) ))) -(def: test|expression +(def test|expression Test (do [! random.monad] [dummy random.safe_frac @@ -713,7 +713,7 @@ ..test|location) )))) -(def: test|label +(def test|label Test (do [! random.monad] [input (at ! each ..int_16 random.int) @@ -779,7 +779,7 @@ (/.apply_lambda (list (/.int input))))))) ))) -(def: test|loop +(def test|loop Test (do [! random.monad] [input (at ! each (i.right_shifted 32) random.int) @@ -814,12 +814,12 @@ ..test|label ))) -(def: random_tag +(def random_tag (Random Int) (random#each (i64.and (hex "FF,FF,FF,FF")) random.int)) -(def: test|exception +(def test|exception Test (do [! random.monad] [expected random.safe_frac @@ -901,7 +901,7 @@ (/.apply_lambda (list)))))) ))) -(def: test|function +(def test|function Test (do [! random.monad] [iterations (at ! each (n.% 10) random.nat) @@ -952,7 +952,7 @@ (/.apply_lambda (list))))) ))) -(def: test|branching +(def test|branching Test (do [! random.monad] [float/0 random.safe_frac @@ -986,7 +986,7 @@ (/.apply_lambda (list))))) ))) -(def: test|statement +(def test|statement Test (do [! random.monad] [float/0 random.safe_frac @@ -1028,7 +1028,7 @@ ..test|function) ))) -(def: random_expression +(def random_expression (Random /.Expression) (let [literal (is (Random /.Literal) (all random.either @@ -1041,7 +1041,7 @@ literal ))) -(def: .public test +(def .public test Test (do [! random.monad] [expected ..random_expression] diff --git a/stdlib/source/test/lux/test.lux b/stdlib/source/test/lux/test.lux index b7d59da1e..3cf4b7f51 100644 --- a/stdlib/source/test/lux/test.lux +++ b/stdlib/source/test/lux/test.lux @@ -22,14 +22,14 @@ [\\library ["[0]" /]]) -(def: (verify expected_message/0 expected_message/1 successes failures [tally message]) +(def (verify expected_message/0 expected_message/1 successes failures [tally message]) (-> Text Text Nat Nat [/.Tally Text] Bit) (and (text.contains? expected_message/0 message) (text.contains? expected_message/1 message) (n.= successes (the /.#successes tally)) (n.= failures (the /.#failures tally)))) -(def: assertion +(def assertion /.Test (do [! random.monad] [expected_message/0 (random.lower_case 5) @@ -62,7 +62,7 @@ (..verify expected_message/0 expected_message/1 1 1 ft))))) ))) -(def: seed +(def seed /.Test (do [! random.monad] [seed random.nat @@ -88,7 +88,7 @@ (and (n.= 1 (the /.#successes post_tally)) (n.= 0 (the /.#failures post_tally))))))))) -(def: times +(def times /.Test (all /.and (do [! random.monad] @@ -117,7 +117,7 @@ (n.= 0 (the /.#failures tally))))))) )) -(def: in_parallel +(def in_parallel /.Test (all /.and (do [! random.monad] @@ -164,10 +164,10 @@ ran_all_tests!)))))) )) -(def: .public dummy_target +(def .public dummy_target "YOLO") -(def: coverage +(def coverage /.Test (all /.and (do random.monad @@ -216,7 +216,7 @@ (set.member? (the /.#actual_coverage covering) (symbol ..dummy_target)))))))) )) -(def: .public test +(def .public test /.Test (<| (/.covering /._) (/.for [/.Test]) diff --git a/stdlib/source/test/lux/time.lux b/stdlib/source/test/lux/time.lux index 8962c7adb..ccce44873 100644 --- a/stdlib/source/test/lux/time.lux +++ b/stdlib/source/test/lux/time.lux @@ -32,7 +32,7 @@ ["[0]" / (.only) ["[0]" duration]]]) -(def: for_implementation +(def for_implementation Test (all _.and (_.for [/.equivalence] @@ -44,7 +44,7 @@ (_.for [/.codec] ($codec.spec /.equivalence /.codec random.time)))) -(def: for_clock +(def for_clock Test (do [! random.monad] [expected random.time] @@ -55,7 +55,7 @@ (try#each (at /.equivalence = expected)) (try.else false))))) -(def: for_ranges +(def for_ranges Test (do [! random.monad] [valid_hour (at ! each (|>> (n.% /.hours) (n.max 10)) random.nat) @@ -108,7 +108,7 @@ {try.#Failure error} false))) )))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Time]) diff --git a/stdlib/source/test/lux/time/date.lux b/stdlib/source/test/lux/time/date.lux index 958438f13..7a805e4ec 100644 --- a/stdlib/source/test/lux/time/date.lux +++ b/stdlib/source/test/lux/time/date.lux @@ -24,7 +24,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Date]) diff --git a/stdlib/source/test/lux/time/day.lux b/stdlib/source/test/lux/time/day.lux index 0e7e958cc..3f820e733 100644 --- a/stdlib/source/test/lux/time/day.lux +++ b/stdlib/source/test/lux/time/day.lux @@ -25,7 +25,7 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Day) (random.either (random.either (random.either (random#in {/.#Sunday}) (random#in {/.#Monday})) @@ -35,7 +35,7 @@ (random#in {/.#Friday})) (random#in {/.#Saturday})))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Day]) diff --git a/stdlib/source/test/lux/time/duration.lux b/stdlib/source/test/lux/time/duration.lux index 2d4847d29..3778516a1 100644 --- a/stdlib/source/test/lux/time/duration.lux +++ b/stdlib/source/test/lux/time/duration.lux @@ -20,7 +20,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Duration]) diff --git a/stdlib/source/test/lux/time/instant.lux b/stdlib/source/test/lux/time/instant.lux index 0ae5bf04c..66ccccb65 100644 --- a/stdlib/source/test/lux/time/instant.lux +++ b/stdlib/source/test/lux/time/instant.lux @@ -24,7 +24,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Instant]) diff --git a/stdlib/source/test/lux/time/month.lux b/stdlib/source/test/lux/time/month.lux index a791e59a1..5399a9a87 100644 --- a/stdlib/source/test/lux/time/month.lux +++ b/stdlib/source/test/lux/time/month.lux @@ -27,14 +27,14 @@ [// ["[0]" duration]]]]) -(def: .public random +(def .public random (Random /.Month) (let [december (/.number {/.#December})] (|> random.nat (at random.monad each (|>> (n.% december) ++)) (random.one (|>> /.by_number try.maybe))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Month]) diff --git a/stdlib/source/test/lux/time/year.lux b/stdlib/source/test/lux/time/year.lux index cb2be3918..ed50e138b 100644 --- a/stdlib/source/test/lux/time/year.lux +++ b/stdlib/source/test/lux/time/year.lux @@ -27,11 +27,11 @@ ["[1][0]" instant] ["[1][0]" date]]]]) -(def: .public random +(def .public random (Random /.Year) (random.one (|>> /.year try.maybe) random.int)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Year]) diff --git a/stdlib/source/test/lux/tool.lux b/stdlib/source/test/lux/tool.lux index 217647f2e..25345fcae 100644 --- a/stdlib/source/test/lux/tool.lux +++ b/stdlib/source/test/lux/tool.lux @@ -27,7 +27,7 @@ ["[1]/[0]" cache]] ]]) -(def: .public test +(def .public test Test (all _.and /arity.test diff --git a/stdlib/source/test/lux/tool/compiler/arity.lux b/stdlib/source/test/lux/tool/compiler/arity.lux index a53ca8c6d..6dcbfcac9 100644 --- a/stdlib/source/test/lux/tool/compiler/arity.lux +++ b/stdlib/source/test/lux/tool/compiler/arity.lux @@ -13,7 +13,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Arity]) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux index 763b3ba9f..37b298b3c 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis.lux @@ -65,7 +65,7 @@ ["[2][1]" /] ["[1]" \\library (.open: "[1]#[0]" equivalence)]]]]]]) -(def: !expect +(def !expect (template (_ <expectation> <computation>) [(case <computation> <expectation> @@ -74,12 +74,12 @@ _ false)])) -(def: constant +(def constant (Random Constant) (random.and (random.unicode 10) (random.unicode 10))) -(def: \\parser +(def \\parser Test (<| (_.covering \\parser._) (_.for [\\parser.Parser]) @@ -187,21 +187,21 @@ (exception.match? \\parser.unconsumed_input error))))) ))))) -(def: (random_branch random) +(def (random_branch random) (All (_ a) (-> (Random a) (Random (/.Branch' a)))) (all random.and /pattern.random random )) -(def: (random_match multiplicity random) +(def (random_match multiplicity random) (All (_ a) (-> Nat (Random a) (Random (/.Match' a)))) (all random.and (..random_branch random) (random.list multiplicity (..random_branch random)) )) -(def: .public (random multiplicity) +(def .public (random multiplicity) (-> Nat (Random /.Analysis)) (<| random.rec (function (_ random)) @@ -231,7 +231,7 @@ random|extension ))) -(def: test|simple +(def test|simple Test (do random.monad [bit random.bit @@ -265,7 +265,7 @@ [/.text text])) )))) -(def: test|complex +(def test|complex Test (do random.monad [expected_left (..random 2) @@ -295,7 +295,7 @@ false)) ))) -(def: test|reference +(def test|reference Test (do random.monad [expected_register random.nat @@ -318,7 +318,7 @@ )) )))) -(def: tagged? +(def tagged? (template (_ <tag> <it>) [(case <it> {<tag> _} @@ -327,7 +327,7 @@ _ false)])) -(def: test|reification +(def test|reification Test (do random.monad [expected_abstraction (random.only (|>> (..tagged? /.#Apply) not) @@ -355,7 +355,7 @@ false)) ))) -(def: test|case +(def test|case Test (do random.monad [expected_input (..random 2) @@ -375,7 +375,7 @@ <exception> (template.symbol ["exception_" <id>])] (exception: <exception>) - (def: test|phase + (def test|phase Test (do random.monad [version/0 random.nat @@ -458,7 +458,7 @@ false)))) )))) -(def: test|state +(def test|state Test (do random.monad [version random.nat @@ -588,7 +588,7 @@ (try.else false)))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Analysis]) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/complex.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/complex.lux index 44e430c0e..b68171b90 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/complex.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/complex.lux @@ -18,7 +18,7 @@ [\\library ["[0]" /]]) -(def: test|tag +(def test|tag Test (do [! random.monad] [multiplicity (at ! each (n.max 2) random.nat) @@ -42,7 +42,7 @@ (n.= tag lefts)))) ))) -(def: .public (random multiplicity it) +(def .public (random multiplicity it) (All (_ a) (-> Nat (Random a) (Random (/.Complex a)))) (all random.or @@ -53,7 +53,7 @@ (random.list multiplicity it) )) -(def: .public test +(def .public test Test (let [random (..random 3 random.nat)] (<| (_.covering /._) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/coverage.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/coverage.lux index d308e446c..df0ff10b0 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/coverage.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/coverage.lux @@ -36,13 +36,13 @@ ["[1][0]" complex] ["[1][0]" pattern (.only Pattern)]]]]) -(def: spread 16) +(def spread 16) -(def: random_tag +(def random_tag (Random Nat) (random#each (n.% ..spread) random.nat)) -(def: .public random +(def .public random (Random /.Coverage) (<| random.rec (function (_ again)) @@ -68,12 +68,12 @@ (random.and again again) ))) -(def: (ranged min range) +(def (ranged min range) (-> Nat Nat (Random Nat)) (random#each (|>> (n.% (++ range)) (n.+ min)) random.nat)) -(def: random_pattern +(def random_pattern (Random [/.Coverage Pattern]) (<| random.rec (function (_ again)) @@ -135,7 +135,7 @@ {//pattern.#Bind register}])) )))) -(def: (failure? exception it) +(def (failure? exception it) (All (_ a) (-> (Exception a) (Try /.Coverage) Bit)) (case it {try.#Failure error} @@ -144,7 +144,7 @@ _ false)) -(def: test|value +(def test|value Test (<| (let [(open "/#[0]") /.equivalence]) (do [! random.monad] @@ -162,7 +162,7 @@ (text#= (/.format left) (/.format right)))) )))) -(def: test|coverage +(def test|coverage Test (<| (let [(open "/#[0]") /.equivalence]) (do [! random.monad] @@ -193,12 +193,12 @@ not)))) )))) -(def: random_partial_pattern +(def random_partial_pattern (Random [/.Coverage Pattern]) (random.only (|>> product.left /.exhaustive? not) ..random_pattern)) -(def: test|variant +(def test|variant Test (<| (let [(open "/#[0]") /.equivalence]) (do [! random.monad] @@ -221,7 +221,7 @@ (n.= expected_maximum (/.maximum [{.#Some expected_maximum} cases])))) )))) -(def: random_value_pattern +(def random_value_pattern (Random [/.Coverage Pattern]) (random.only (function (_ [coverage pattern]) (case coverage @@ -232,7 +232,7 @@ true)) ..random_partial_pattern)) -(def: test|composite +(def test|composite Test (<| (let [(open "/#[0]") /.equivalence]) (do [! random.monad] @@ -453,7 +453,7 @@ {/.#Variant {.#Some arity} (dictionary.of_list n.hash (list [tag/1 expected/1]))})))))) )))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Coverage]) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/inference.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/inference.lux index 6b7c63309..90d337051 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/inference.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/inference.lux @@ -46,15 +46,15 @@ [meta ["[0]" archive]]]]]]]) -(def: (eval archive type term) +(def (eval archive type term) Eval (/phase#in [])) -(def: (expander macro inputs state) +(def (expander macro inputs state) //macro.Expander {try.#Success ((macro.function macro) inputs state)}) -(def: random_state +(def random_state (Random Lux) (do random.monad [version random.nat @@ -62,17 +62,17 @@ configuration ($configuration.random 5)] (in (//.state (//.info version host configuration))))) -(def: primitive +(def primitive (Random Type) (do random.monad [name (random.lower_case 1)] (in {.#Primitive name (list)}))) -(def: analysis +(def analysis //.Phase (/analysis.phase ..expander)) -(def: (fails? exception try) +(def (fails? exception try) (All (_ e a) (-> (Exception e) (Try a) Bit)) (case try {try.#Success _} @@ -81,7 +81,7 @@ {try.#Failure error} (text.contains? (the exception.#label exception) error))) -(def: .public simple_parameter +(def .public simple_parameter (Random [Type Code]) (`` (all random.either (~~ (with_template [<type> <random> <code>] @@ -96,7 +96,7 @@ )) ))) -(def: test|general +(def test|general Test (do [! random.monad] [lux ..random_state @@ -211,7 +211,7 @@ (..fails? /.cannot_infer_argument))) ))) -(def: test|variant +(def test|variant Test (do [! random.monad] [lux ..random_state @@ -320,7 +320,7 @@ (..fails? /.not_a_variant)))) ))) -(def: test|record +(def test|record Test (do [! random.monad] [lux ..random_state @@ -394,7 +394,7 @@ (..fails? /.not_a_record))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/macro.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/macro.lux index 05c17f492..cf1ee869c 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/macro.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/macro.lux @@ -34,7 +34,7 @@ ["[0]" / (.only) ["/[1]" //]]]) -(def: random_state +(def random_state (Random Lux) (do random.monad [version random.nat @@ -42,11 +42,11 @@ configuration ($configuration.random 5)] (in (//.state (//.info version host configuration))))) -(def: (expander macro inputs state) +(def (expander macro inputs state) /.Expander {try.#Success ((macro.function macro) inputs state)}) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Expander]) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/module.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/module.lux index 0c0831530..fc075bd16 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/module.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/module.lux @@ -30,7 +30,7 @@ [/// ["[2][0]" phase]]]]]]) -(def: random_state +(def random_state (Random Lux) (do random.monad [version random.nat @@ -38,13 +38,13 @@ configuration ($configuration.random 5)] (in (//.state (//.info version host configuration))))) -(def: primitive +(def primitive (Random Type) (do random.monad [name (random.lower_case 1)] (in {.#Primitive name (list)}))) -(def: (new? hash it) +(def (new? hash it) (-> Nat .Module Bit) (and (same? hash (the .#module_hash it)) (list.empty? (the .#module_aliases it)) @@ -57,7 +57,7 @@ _ false))) -(def: test|module +(def test|module Test (do [! random.monad] [lux ..random_state @@ -131,7 +131,7 @@ (try.else false))) ))) -(def: test|state +(def test|state Test (do [! random.monad] [lux ..random_state @@ -196,7 +196,7 @@ )))) )))) -(def: test|definition +(def test|definition Test (do [! random.monad] [lux ..random_state @@ -268,7 +268,7 @@ {try.#Failure _} true))))) ))) -(def: test|label +(def test|label Test (do [! random.monad] [lux ..random_state @@ -342,7 +342,7 @@ [.#Right true]))))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux index 8c3636a55..e7739df16 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/pattern.lux @@ -19,7 +19,7 @@ ["[1][0]" simple] ["[1][0]" complex]]) -(def: .public random +(def .public random (Random /.Pattern) (random.rec (function (_ random) @@ -29,7 +29,7 @@ random.nat )))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Pattern]) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/scope.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/scope.lux index 584eb63b2..a0c29f7a0 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/scope.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/scope.lux @@ -33,7 +33,7 @@ ["[1][0]" type]]) (with_template [<name> <tag>] - [(def: (<name> expected_type expected_register [actual_type actual_var]) + [(def (<name> expected_type expected_register [actual_type actual_var]) (-> Type Register [Type Variable] Bit) (and (same? expected_type actual_type) (case actual_var @@ -47,7 +47,7 @@ [foreign? //variable.#Foreign] ) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/simple.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/simple.lux index 656722030..b292022ad 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/simple.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/simple.lux @@ -16,7 +16,7 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Simple) (all random.or (random#in []) @@ -28,7 +28,7 @@ (random.lower_case 5) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Simple]) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux index 5b2c340dc..4e02553e4 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/analysis/type.lux @@ -26,7 +26,7 @@ [/// ["[2][0]" phase (.open: "[1]#[0]" functor)]]]]]]) -(def: .public random_state +(def .public random_state (Random Lux) (do random.monad [version random.nat @@ -34,13 +34,13 @@ configuration ($configuration.random 5)] (in (//.state (//.info version host configuration))))) -(def: primitive +(def primitive (Random Type) (do random.monad [name (random.lower_case 1)] (in {.#Primitive name (list)}))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis.lux index 6cc3dd37a..3ac028ac3 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis.lux @@ -46,15 +46,15 @@ ["[1][0]" function] ["[1][0]" case]]) -(def: (eval archive type term) +(def (eval archive type term) Eval (phase#in [])) -(def: (expander macro inputs state) +(def (expander macro inputs state) //macro.Expander {try.#Success ((macro.function macro) inputs state)}) -(def: (can_analyse_unit! lux module/0) +(def (can_analyse_unit! lux module/0) (-> Lux Text Bit) (let [state [extension.#bundle (extension/analysis.bundle ..eval) extension.#state lux]] @@ -75,7 +75,7 @@ (phase.result state) (try.else false)))) -(def: (can_analyse_simple_literal_or_singleton_tuple! lux module/0 [bit/0 nat/0 int/0 rev/0 frac/0 text/0]) +(def (can_analyse_simple_literal_or_singleton_tuple! lux module/0 [bit/0 nat/0 int/0 rev/0 frac/0 text/0]) (-> Lux Text [.Bit .Nat .Int .Rev .Frac .Text] Bit) (let [state [extension.#bundle (extension/analysis.bundle ..eval) extension.#state lux]] @@ -115,7 +115,7 @@ )) )))) -(def: (can_analyse_sum! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] [@left @right]) +(def (can_analyse_sum! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] [@left @right]) (-> Lux Text [.Text .Text .Text .Text .Text .Text .Text] [.Bit .Nat .Int .Rev .Frac .Text] [.Text .Text] Bit) (let [state [extension.#bundle (extension/analysis.bundle ..eval) extension.#state lux] @@ -222,7 +222,7 @@ can_analyse_multiary! ))) -(def: (can_analyse_variant! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] [@left @right]) +(def (can_analyse_variant! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] [@left @right]) (-> Lux Text [.Text .Text .Text .Text .Text .Text .Text] [.Bit .Nat .Int .Rev .Frac .Text] [.Text .Text] Bit) (let [state [extension.#bundle (extension/analysis.bundle ..eval) extension.#state lux] @@ -347,7 +347,7 @@ can_analyse_nullary! can_analyse_multiary!))) -(def: (can_analyse_tuple! lux module/0 [bit/0 nat/0 int/0 rev/0 frac/0 text/0]) +(def (can_analyse_tuple! lux module/0 [bit/0 nat/0 int/0 rev/0 frac/0 text/0]) (-> Lux Text [.Bit .Nat .Int .Rev .Frac .Text] Bit) (let [state [extension.#bundle (extension/analysis.bundle ..eval) extension.#state lux]] @@ -386,7 +386,7 @@ (phase.result state) (try.else false)))) -(def: (can_analyse_record! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0]) +(def (can_analyse_record! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0]) (-> Lux Text [.Text .Text .Text .Text .Text .Text .Text] [.Bit .Nat .Int .Rev .Frac .Text] Bit) (let [state [extension.#bundle (extension/analysis.bundle ..eval) extension.#state lux] @@ -429,7 +429,7 @@ (phase.result state) (try.else false)))) -(def: (can_analyse_function! lux module/0 nat/0 [$abstraction/0 $parameter/0 $abstraction/1 $parameter/1]) +(def (can_analyse_function! lux module/0 nat/0 [$abstraction/0 $parameter/0 $abstraction/1 $parameter/1]) (-> Lux Text Nat [Code Code Code Code] Bit) (let [state [extension.#bundle (extension/analysis.bundle ..eval) extension.#state lux] @@ -559,7 +559,7 @@ ... (try.else false)) ))) -(def: (can_analyse_apply! lux module/0 bit/0 nat/0 [$abstraction/0 $parameter/0 $abstraction/1 $parameter/1]) +(def (can_analyse_apply! lux module/0 bit/0 nat/0 [$abstraction/0 $parameter/0 $abstraction/1 $parameter/1]) (-> Lux Text Bit Nat [Code Code Code Code] Bit) (let [state [extension.#bundle (extension/analysis.bundle ..eval) extension.#state lux] @@ -632,7 +632,7 @@ variable! partial!))) -(def: (can_analyse_extension! lux module/0 text/0) +(def (can_analyse_extension! lux module/0 text/0) (-> Lux Text Text Bit) (let [state [extension.#bundle (extension/analysis.bundle ..eval) extension.#state lux]] @@ -654,7 +654,7 @@ (phase.result state) (try.else false)))) -(def: (can_analyse_pattern_matching! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] $parameter/0) +(def (can_analyse_pattern_matching! lux module/0 [@any @bit @nat @int @rev @frac @text] [bit/0 nat/0 int/0 rev/0 frac/0 text/0] $parameter/0) (-> Lux Text [.Text .Text .Text .Text .Text .Text .Text] [.Bit .Nat .Int .Rev .Frac .Text] Code Bit) (let [state [extension.#bundle (extension/analysis.bundle ..eval) extension.#state lux] @@ -889,7 +889,7 @@ tuple! record!))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux index 33e7c009e..5891bb218 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/case.lux @@ -40,19 +40,19 @@ [meta ["[0]" archive]]]]]]]]) -(def: (eval archive type term) +(def (eval archive type term) Eval (//phase#in [])) -(def: (expander macro inputs state) +(def (expander macro inputs state) //macro.Expander {try.#Success ((macro.function macro) inputs state)}) -(def: analysis +(def analysis //analysis.Phase (//.phase ..expander)) -(def: test|tuple +(def test|tuple Test (do [! random.monad] [lux $//type.random_state @@ -140,7 +140,7 @@ (exception.otherwise (text.contains? (the exception.#label /.non_tuple)))))) ))) -(def: (test|case lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0]) +(def (test|case lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0]) (-> Lux Symbol [Type Code] [Type Code] [Type Code] [Code Code Code] [Type Code] [Type Code] [Bit Nat] Bit) (let [state [//extension.#bundle (//extension/analysis.bundle ..eval) //extension.#state lux] @@ -247,7 +247,7 @@ ... 111 ))))) -(def: (test|redundancy lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] bit/0) +(def (test|redundancy lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] bit/0) (-> Lux Symbol [Type Code] [Type Code] [Type Code] [Code Code Code] [Type Code] Bit Bit) (let [state [//extension.#bundle (//extension/analysis.bundle ..eval) //extension.#state lux] @@ -297,7 +297,7 @@ (list [$binding/0 body/0] [(` [(~ $binding/0) (~ $binding/1)]) body/0]))))) -(def: (test|variant lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0]) +(def (test|variant lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0]) (-> Lux Symbol [Type Code] [Type Code] [Type Code] [Code Code Code] [Type Code] [Type Code] [Bit Nat] Bit) (let [state [//extension.#bundle (//extension/analysis.bundle ..eval) //extension.#state lux] @@ -368,7 +368,7 @@ can_bind_partial_variant! ))) -(def: (test|record lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0]) +(def (test|record lux [module/0 name/0] [input/0 simple/0] [input/1 simple/1] [input/2 simple/2] [$binding/0 $binding/1 $binding/2] [output/0 body/0] [output/1 body/1] [bit/0 nat/0]) (-> Lux Symbol [Type Code] [Type Code] [Type Code] [Code Code Code] [Type Code] [Type Code] [Bit Nat] Bit) (let [state [//extension.#bundle (//extension/analysis.bundle ..eval) //extension.#state lux] @@ -493,7 +493,7 @@ cannot_omit_slot! can_bind_partial_tuple!))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/complex.lux index 61c790517..499b7a7ec 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/complex.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/complex.lux @@ -52,15 +52,15 @@ [meta ["[0]" archive]]]]]]]]) -(def: (eval archive type term) +(def (eval archive type term) Eval (//phase#in [])) -(def: (expander macro inputs state) +(def (expander macro inputs state) //macro.Expander {try.#Success ((macro.function macro) inputs state)}) -(def: random_state +(def random_state (Random Lux) (do random.monad [version random.nat @@ -68,17 +68,17 @@ configuration ($configuration.random 5)] (in (//analysis.state (//analysis.info version host configuration))))) -(def: primitive +(def primitive (Random Type) (do random.monad [name (random.lower_case 1)] (in {.#Primitive name (list)}))) -(def: analysis +(def analysis //analysis.Phase (//.phase ..expander)) -(def: (failure? exception try) +(def (failure? exception try) (All (_ e a) (-> (Exception e) (Try a) Bit)) (case try {try.#Success _} @@ -87,7 +87,7 @@ {try.#Failure error} (text.contains? (the exception.#label exception) error))) -(def: simple_parameter +(def simple_parameter (Random [Type Code]) (`` (all random.either (~~ (with_template [<type> <random> <code>] @@ -102,7 +102,7 @@ )) ))) -(def: (analysed? expected actual) +(def (analysed? expected actual) (-> Code Analysis Bit) (case [expected actual] (pattern [[_ {.#Tuple (list)}] (//analysis.unit)]) @@ -128,7 +128,7 @@ _ false)) -(def: test|sum +(def test|sum (do [! random.monad] [lux ..random_state .let [state [//extension.#bundle (//extension/analysis.bundle ..eval) @@ -211,7 +211,7 @@ ))) ))) -(def: test|variant +(def test|variant (do [! random.monad] [lux ..random_state .let [state [//extension.#bundle (//extension/analysis.bundle ..eval) @@ -284,7 +284,7 @@ (type: (Triple a) [a a a]) -(def: test|product +(def test|product (do [! random.monad] [lux ..random_state .let [state [//extension.#bundle (//extension/analysis.bundle ..eval) @@ -428,7 +428,7 @@ (failure? /.invalid_tuple_type)))))) ))) -(def: test|record +(def test|record (do [! random.monad] [lux ..random_state .let [state [//extension.#bundle (//extension/analysis.bundle ..eval) @@ -628,7 +628,7 @@ (inferred? global_record)))) ))) -(def: .public test +(def .public test (<| (_.covering /._) (do [! random.monad] [lux ..random_state diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux index 23d910b37..e5ed71930 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/function.lux @@ -47,19 +47,19 @@ [meta ["[0]" archive]]]]]]]]) -(def: (eval archive type term) +(def (eval archive type term) Eval (//phase#in [])) -(def: (expander macro inputs state) +(def (expander macro inputs state) //macro.Expander {try.#Success ((macro.function macro) inputs state)}) -(def: analysis +(def analysis //analysis.Phase (//.phase ..expander)) -(def: test|function +(def test|function Test (do [! random.monad] [lux $//type.random_state @@ -193,7 +193,7 @@ (exception.otherwise (text.contains? (the exception.#label /.cannot_analyse))))) ))) -(def: test|apply +(def test|apply Test (do [! random.monad] [lux $//type.random_state @@ -249,7 +249,7 @@ (exception.otherwise (text.contains? (the exception.#label /.cannot_apply))))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux index 9f09dba69..20f666efe 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/reference.lux @@ -29,7 +29,7 @@ [/// ["[1][0]" phase (.open: "[1]#[0]" monad)]]]]]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux index 03a9dc1e6..cfd9df933 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/simple.lux @@ -26,7 +26,7 @@ [/// ["[1][0]" phase (.open: "[1]#[0]" functor)]]]]]]) -(def: (analysis state module type it ?) +(def (analysis state module type it ?) (-> Lux Text Type (Operation Analysis) (-> Analysis Bit) Bit) (and (|> it (/type.expecting type) @@ -66,7 +66,7 @@ _ false)))) -(def: analysis? +(def analysis? (template (_ <type> <tag>) [(is (-> <type> Analysis Bit) (function (_ expected) @@ -77,7 +77,7 @@ _ false))))])) -(def: .public test +(def .public test (<| (_.covering /._) (do [! random.monad] [version random.nat diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension.lux index 745b50cf8..d081e2cbf 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension.lux @@ -30,14 +30,14 @@ [meta ["[0]" archive]]]]]) -(def: .public random +(def .public random (Random (/.Extension Nat)) (all random.and (random.lower_case 5) (random.list 2 random.nat) )) -(def: test|state +(def test|state Test (do [! random.monad] [state random.int @@ -94,21 +94,21 @@ (try.else false)))) )) -(def: extender +(def extender /.Extender (|>> as_expected)) -(def: handler/0 +(def handler/0 (/.Handler Int Nat Nat) (function (_ @self phase archive inputs) (at phase.monad in (list#mix n.+ 0 inputs)))) -(def: handler/1 +(def handler/1 (/.Handler Int Nat Nat) (function (_ @self phase archive inputs) (at phase.monad in (list#mix n.* 1 inputs)))) -(def: test|name +(def test|name Test (do [! random.monad] [state random.int @@ -142,7 +142,7 @@ false))) ))) -(def: test|bundle +(def test|bundle Test (let [phase (is (/.Phase Int Nat Nat) (function (_ archive input) @@ -225,7 +225,7 @@ )) )))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Extension]) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux index 0123bd0bc..72a38e623 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/extension/analysis/lux.lux @@ -34,7 +34,7 @@ ["[0]" archive]]]]]]) (with_template [<name> <success> <failure>] - [(def: (<name> procedure params output_type) + [(def (<name> procedure params output_type) (-> Text (List Code) Type Bit) (|> (////scope.with_scope "" (////type.with_type output_type @@ -51,11 +51,11 @@ [check_failure+ false true] ) -(def: primitive +(def primitive (Random [Type Code]) (r.only (|>> product.left (same? Any) not) _primitive.primitive)) -(def: lux +(def lux Test (do r.monad [[primT primC] ..primitive @@ -72,7 +72,7 @@ (type (Either Text primT)))) ))) -(def: i64 +(def i64 Test (do [! r.monad] [subjectC (|> r.nat (at ! each code.nat)) @@ -99,7 +99,7 @@ (check_success+ "lux i64 -" (list paramC subjectC) Int)) ))) -(def: int +(def int Test (do [! r.monad] [subjectC (|> r.int (at ! each code.int)) @@ -119,7 +119,7 @@ (check_success+ "lux i64 f64" (list subjectC) Frac)) ))) -(def: frac +(def frac Test (do [! r.monad] [subjectC (|> r.safe_frac (at ! each code.frac)) @@ -154,7 +154,7 @@ (check_success+ "lux f64 decode" (list encodedC) (type (Maybe Frac)))) ))) -(def: text +(def text Test (do [! r.monad] [subjectC (|> (r.unicode 5) (at ! each code.text)) @@ -179,7 +179,7 @@ (check_success+ "lux text clip" (list fromC toC subjectC) Text)) ))) -(def: io +(def io Test (do [! r.monad] [logC (|> (r.unicode 5) (at ! each code.text)) @@ -193,7 +193,7 @@ (check_success+ "lux io current-time" (list) Int)) ))) -(def: .public test +(def .public test Test (<| (_.context (symbol.module (symbol /._))) (all _.and diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis.lux index 2f382a752..9e37ebf65 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis.lux @@ -9,7 +9,7 @@ ["[1][0]" loop] ["[1][0]" variable]]) -(def: .public test +(def .public test Test (all _.and /primitive.test diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux index 804c115d4..bb45ee381 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/case.lux @@ -39,7 +39,7 @@ [meta ["[0]" archive]]]]]]]]) -(def: masking_test +(def masking_test Test (do [! random.monad] [maskedA //primitive.primitive @@ -56,7 +56,7 @@ (try#each (//primitive.corresponds? maskedA)) (try.default false))))) -(def: let_test +(def let_test Test (do random.monad [registerA random.nat @@ -80,7 +80,7 @@ _ false))))) -(def: if_test +(def if_test Test (do random.monad [then|else random.bit @@ -109,7 +109,7 @@ _ false))))) -(def: random_member +(def random_member (Random synthesis.Member) (do [! random.monad] [lefts (|> random.nat (at ! each (n.% 10))) @@ -118,13 +118,13 @@ {.#Right lefts} {.#Left lefts})))) -(def: random_path +(def random_path (Random (analysis.Tuple synthesis.Member)) (do [! random.monad] [size_1 (|> random.nat (at ! each (|>> (n.% 10) ++)))] (random.list size_1 ..random_member))) -(def: (get_pattern path) +(def (get_pattern path) (-> (analysis.Tuple synthesis.Member) (Random [analysis.Pattern Register])) (do random.monad @@ -144,7 +144,7 @@ (list.reversed path)) @member]))) -(def: get_test +(def get_test Test (do [! random.monad] [recordA (|> random.nat @@ -168,7 +168,7 @@ _ false))))) -(def: random_bit +(def random_bit (Random [Path Match]) (do [! random.monad] [test random.bit @@ -183,7 +183,7 @@ (list [analysis.#when (analysis.pattern/bit (not test)) analysis.#then (analysis.nat else)])]]))) -(def: (random_five hash random_element) +(def (random_five hash random_element) (All (_ a) (-> (Hash a) (Random a) (Random [a a a a a]))) (|> random_element (random.set hash 5) @@ -196,7 +196,7 @@ (undefined)))))) (with_template [<name> <hash> <random> <path> <synthesis> <pattern> <analysis>] - [(def: <name> + [(def <name> (Random [Path Match]) (do [! random.monad] [[test/0 test/1 test/2 test/3 test/4] (random_five <hash> <random>) @@ -220,7 +220,7 @@ [random_text text.hash (random.unicode 1) synthesis.path/text synthesis.text analysis.pattern/text analysis.text] ) -(def: random_simple +(def random_simple (all random.either ..random_bit ..random_nat @@ -230,7 +230,7 @@ ..random_text )) -(def: random_variant +(def random_variant (Random [Path Match]) (do [! random.monad] [[lefts/0 lefts/1 lefts/2 lefts/3 lefts/4] (random_five n.hash random.nat) @@ -263,7 +263,7 @@ (branch lefts/3 false value/3 body/3) (branch lefts/4 last_is_right? value/4 body/4))]]))) -(def: random_tuple +(def random_tuple (Random [Path Match]) (do [! random.monad] [mid_size (at ! each (n.% 4) random.nat) @@ -317,19 +317,19 @@ (branch (++ lefts') false value body)))) (list (branch (++ mid_size) true value/last body/last)))]]))) -(def: random_complex +(def random_complex (all random.either ..random_variant ..random_tuple )) -(def: random_case +(def random_case (all random.either ..random_simple ..random_complex )) -(def: case_test +(def case_test Test (do [! random.monad] [expected_input (at ! each (|>> .i64 synthesis.i64) random.nat) @@ -345,7 +345,7 @@ _ false))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.synthesize]) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux index 8f59b1714..b93fd3c22 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/function.lux @@ -38,7 +38,7 @@ [meta ["[0]" archive]]]]]]]]) -(def: (n_function loop? arity body) +(def (n_function loop? arity body) (-> Bit Arity Synthesis Synthesis) (synthesis.function/abstraction [synthesis.#environment (list) @@ -50,7 +50,7 @@ synthesis.#iteration body]) body)])) -(def: (n_abstraction arity body) +(def (n_abstraction arity body) (-> Arity Analysis Analysis) (list#mix (function (_ arity_1 body) (case arity_1 @@ -63,7 +63,7 @@ body (list.reversed (list.indices arity)))) -(def: !expect +(def !expect (template (_ <pattern> <value>) (case <value> <pattern> @@ -81,7 +81,7 @@ (type: Scenario (-> Bit (Random Circumstance))) -(def: (random_unit output?) +(def (random_unit output?) Scenario (at random.monad in [true @@ -89,7 +89,7 @@ (analysis.unit)])) (with_template [<name> <random> <synthesis> <analysis>] - [(def: (<name> output?) + [(def (<name> output?) Scenario (do [! random.monad] [value <random>] @@ -105,7 +105,7 @@ [random_text (random.unicode 1) synthesis.text analysis.text] ) -(def: (random_primitive output?) +(def (random_primitive output?) Scenario (random.either (random.either (..random_unit output?) (random.either (..random_bit output?) @@ -115,7 +115,7 @@ (random.either (..random_frac output?) (..random_text output?))))) -(def: (random_variant random_value output?) +(def (random_variant random_value output?) (-> Scenario Scenario) (do [! random.monad] [lefts random.nat @@ -131,7 +131,7 @@ analysis.#right? right? analysis.#value actual_value])]))) -(def: (random_tuple random_value output?) +(def (random_tuple random_value output?) (-> Scenario Scenario) (do [! random.monad] [[loop?_left expected_left actual_left] (random_value false) @@ -141,13 +141,13 @@ (synthesis.tuple (list expected_left expected_right)) (analysis.tuple (list actual_left actual_right))]))) -(def: (random_structure random_value output?) +(def (random_structure random_value output?) (-> Scenario Scenario) (all random.either (..random_variant random_value output?) (..random_tuple random_value output?))) -(def: (random_variable arity output?) +(def (random_variable arity output?) (-> Arity Scenario) (do [! random.monad] [register (at ! each (|>> (n.% arity) ++) random.nat)] @@ -157,7 +157,7 @@ {analysis.#Reference (reference.local 1)} {analysis.#Reference (reference.foreign register)})]))) -(def: (random_constant output?) +(def (random_constant output?) Scenario (do [! random.monad] [module (random.unicode 1) @@ -166,12 +166,12 @@ (synthesis.constant [module short]) {analysis.#Reference (reference.constant [module short])}]))) -(def: (random_reference arity output?) +(def (random_reference arity output?) (-> Arity Scenario) (random.either (..random_variable arity output?) (..random_constant output?))) -(def: (random_case arity random_value output?) +(def (random_case arity random_value output?) (-> Arity Scenario Scenario) (do [! random.monad] [bit_test random.bit @@ -239,7 +239,7 @@ (list {analysis.#Bind 2} (analysis.pattern/unit))))) analysis.#then actual_output])]}]))) -(def: (random_let arity random_value output?) +(def (random_let arity random_value output?) (-> Arity Scenario Scenario) (do [! random.monad] [[loop?_input expected_input actual_input] (random_value false) @@ -254,7 +254,7 @@ analysis.#then actual_output] (list)]}]))) -(def: (random_if random_value output?) +(def (random_if random_value output?) (-> Scenario Scenario) (do [! random.monad] [[loop?_test expected_test actual_test] (random_value false) @@ -279,7 +279,7 @@ (list [analysis.#when (analysis.pattern/bit false) analysis.#then actual_else])]})]))) -(def: (random_get random_value output?) +(def (random_get random_value output?) (-> Scenario Scenario) (do [! random.monad] [lefts (|> random.nat (at ! each (n.% 10))) @@ -299,14 +299,14 @@ analysis.#then {analysis.#Reference (reference.local 2)}] (list)]}]))) -(def: (random_branch arity random_value output?) +(def (random_branch arity random_value output?) (-> Arity Scenario Scenario) (random.either (random.either (..random_case arity random_value output?) (..random_let arity random_value output?)) (random.either (..random_if random_value output?) (..random_get random_value output?)))) -(def: (random_again arity random_value output?) +(def (random_again arity random_value output?) (-> Arity Scenario Scenario) (do [! random.monad] [resets (random.list arity (random_value false))] @@ -317,7 +317,7 @@ _ (reference.foreign 0))} (list#each (|>> product.right product.right) resets)])]))) -(def: (random_scope arity output?) +(def (random_scope arity output?) (-> Arity Scenario) (do [! random.monad] [resets (random.list arity (..random_variable arity output?)) @@ -333,7 +333,7 @@ (analysis.apply [(..n_abstraction arity actual_output) (list#each (|>> product.right product.right) resets)])]))) -(def: (random_loop arity random_value output?) +(def (random_loop arity random_value output?) (-> Arity Scenario Scenario) (if output? (all random.either @@ -342,7 +342,7 @@ ) (..random_scope arity output?))) -(def: (random_abstraction' output?) +(def (random_abstraction' output?) Scenario (do [! random.monad] [[loop?_output expected_output actual_output] (..random_nat output?) @@ -362,7 +362,7 @@ {analysis.#Function environment actual_output}]))) -(def: (random_apply random_value output?) +(def (random_apply random_value output?) (-> Scenario Scenario) (do [! random.monad] [[loop?_abstraction expected_abstraction actual_abstraction] (..random_nat output?) @@ -377,7 +377,7 @@ (analysis.apply [actual_abstraction (list#each (|>> product.right product.right) inputs)])]))) -(def: (random_function random_value output?) +(def (random_function random_value output?) (-> Scenario Scenario) (if output? (..random_apply random_value output?) @@ -386,7 +386,7 @@ (..random_apply random_value output?) ))) -(def: (random_control arity random_value output?) +(def (random_control arity random_value output?) (-> Arity Scenario Scenario) (all random.either (..random_branch arity random_value output?) @@ -394,7 +394,7 @@ (..random_function random_value output?) )) -(def: (random_extension random_value output?) +(def (random_extension random_value output?) (-> Scenario Scenario) (do [! random.monad] [name (random.unicode 1) @@ -407,7 +407,7 @@ {synthesis.#Extension name (list expected_first expected_second expected_third)} {analysis.#Extension name (list actual_first actual_second actual_third)}]))) -(def: (random_body arity) +(def (random_body arity) (-> Arity Scenario) (function (random_value output?) (random.rec @@ -419,7 +419,7 @@ (..random_control arity random_value output?) (..random_extension random_value output?)))))) -(def: random_abstraction +(def random_abstraction (Random [Synthesis Analysis]) (do [! random.monad] [arity (|> random.nat (at ! each (|>> (n.% 5) ++))) @@ -427,7 +427,7 @@ (in [(..n_function loop? arity expected_body) (..n_abstraction arity actual_body)]))) -(def: abstraction +(def abstraction Test (do random.monad [[expected input] ..random_abstraction] @@ -438,7 +438,7 @@ (!expect (^.multi {try.#Success actual} (at synthesis.equivalence = expected actual))))))) -(def: application +(def application Test (do [! random.monad] [arity (|> random.nat (at ! each (|>> (n.% 10) (n.max 1)))) @@ -458,7 +458,7 @@ (!expect (^.multi {try.#Success funcS} (//primitive.corresponds? funcA funcS)))))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux index c123d5ef7..38058930e 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/loop.lux @@ -26,7 +26,7 @@ (type: (Scenario a) (-> Register Arity Register (Random [Register [a a]]))) -(def: (primitive offset arity next) +(def (primitive offset arity next) (Scenario Synthesis) (`` (all random.either (~~ (with_template [<synthesis> <random>] @@ -43,7 +43,7 @@ )) ))) -(def: (constant offset arity next) +(def (constant offset arity next) (Scenario Constant) (do random.monad [name (random.and (random.unicode 1) @@ -52,7 +52,7 @@ [name name]]))) -(def: (variable offset arity next) +(def (variable offset arity next) (Scenario Variable) (let [local (do [! random.monad] [register (at ! each (|>> (n.% arity) ++) random.nat)] @@ -69,7 +69,7 @@ [{variable.#Local foreign} {variable.#Foreign foreign}]])))))) -(def: (reference offset arity next) +(def (reference offset arity next) (Scenario Synthesis) (`` (all random.either (~~ (with_template [<tag> <random>] @@ -83,7 +83,7 @@ [//.variable ..variable] ))))) -(def: (structure offset arity next) +(def (structure offset arity next) (Scenario Synthesis) (all random.either (do [! random.monad] @@ -107,7 +107,7 @@ (//.tuple (list leftA rightA))]])) )) -(def: path +(def path (Scenario Path) (let [pattern (is (Scenario Path) (.function (again offset arity next) @@ -159,7 +159,7 @@ [(//.path/alt leftE rightE) (//.path/alt leftA rightA)]]))))) -(def: (branch offset arity next) +(def (branch offset arity next) (Scenario Synthesis) (let [random_member (is (Random Member) (random.or random.nat @@ -195,7 +195,7 @@ (//.branch/case [inputA pathA])]]))) ))) -(def: (loop offset arity next) +(def (loop offset arity next) (Scenario Synthesis) (all random.either (do random.monad @@ -213,7 +213,7 @@ //.#iteration iterationA])]])) )) -(def: (function offset arity next) +(def (function offset arity next) (Scenario Synthesis) (all random.either (do [! random.monad] @@ -232,7 +232,7 @@ //.#body bodyA])]])) )) -(def: (control offset arity next) +(def (control offset arity next) (Scenario Synthesis) (all random.either (..branch offset arity next) @@ -240,7 +240,7 @@ (..function offset arity next) )) -(def: (extension offset arity next) +(def (extension offset arity next) (Scenario Synthesis) (do random.monad [name (random.unicode 10) @@ -251,7 +251,7 @@ [{//.#Extension name (list firstE secondE thirdE)} {//.#Extension name (list firstA secondA thirdA)}]]))) -(def: (scenario offset arity next) +(def (scenario offset arity next) (Scenario Synthesis) (all random.either (..primitive offset arity next) @@ -261,7 +261,7 @@ (..extension offset arity next) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux index fc6758d5a..b0fd4e5e2 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/primitive.lux @@ -28,7 +28,7 @@ [meta ["[0]" archive]]]]]]]]) -(def: .public primitive +(def .public primitive (Random Analysis) (do r.monad [primitive (is (Random ////analysis.Primitive) @@ -42,7 +42,7 @@ (r.unicode 5)))] (in {////analysis.#Primitive primitive}))) -(def: .public (corresponds? analysis synthesis) +(def .public (corresponds? analysis synthesis) (-> Analysis Synthesis Bit) (`` (case [analysis synthesis] (~~ (with_template [<analysis> <post_analysis> <synthesis> <post_synthesis>] @@ -71,7 +71,7 @@ _ false))) -(def: .public test +(def .public test Test (<| (_.context (%.symbol (symbol ////synthesis.#Primitive))) (`` (all _.and diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux index 237a877a4..500a45325 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/structure.lux @@ -34,7 +34,7 @@ [meta ["[0]" archive]]]]]]]]) -(def: variant +(def variant Test (do [! r.monad] [size (|> r.nat (at ! each (|>> (n.% 10) (n.+ 2)))) @@ -58,7 +58,7 @@ _ false))))) -(def: tuple +(def tuple Test (do [! r.monad] [size (|> r.nat (at ! each (|>> (n.% 10) (n.max 2)))) @@ -76,7 +76,7 @@ _ false))))) -(def: .public test +(def .public test Test (<| (_.context (%.symbol (symbol ////synthesis.#Structure))) (all _.and diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux index 2d794cf3f..6cdbb6ba4 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/synthesis/variable.lux @@ -27,7 +27,7 @@ [reference ["[0]" variable]]]]]]) -(def: !expect +(def !expect (template (_ <pattern> <value>) (case <value> <pattern> @@ -44,7 +44,7 @@ (-> Context (Random [a a]))) (with_template [<name> <synthesis> <random>] - [(def: (<name> context) + [(def (<name> context) (Scenario Synthesis) (do [! random.monad] [value <random>] @@ -57,14 +57,14 @@ [text_scenario synthesis.text (random.unicode 1)] ) -(def: (primitive_scenario context) +(def (primitive_scenario context) (Scenario Synthesis) (random.either (random.either (..bit_scenario context) (..i64_scenario context)) (random.either (..f64_scenario context) (..text_scenario context)))) -(def: (with_redundancy scenario context) +(def (with_redundancy scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do [! random.monad] [redundant? random.bit] @@ -86,7 +86,7 @@ {synthesis.#Then actual_output}}}]))])) (scenario context)))) -(def: (variant_scenario scenario context) +(def (variant_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do [! random.monad] [lefts random.nat @@ -95,19 +95,19 @@ (in [(synthesis.variant [lefts right? expected]) (synthesis.variant [lefts right? input])]))) -(def: (tuple_scenario context) +(def (tuple_scenario context) (Scenario Synthesis) (let [registers (dictionary.entries (the #necessary context))] (at random.monad in [(synthesis.tuple (list#each (|>> product.left synthesis.variable/local) registers)) (synthesis.tuple (list#each (|>> product.right synthesis.variable/local) registers))]))) -(def: (structure_scenario context) +(def (structure_scenario context) (Scenario Synthesis) (random.either (..variant_scenario (..with_redundancy ..tuple_scenario) context) (..tuple_scenario context))) -(def: (let_scenario scenario context) +(def (let_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do random.monad [_ (in []) @@ -119,7 +119,7 @@ (in [(synthesis.branch/let [expected_input real_register expected_output]) (synthesis.branch/let [actual_input fake_register actual_output])]))) -(def: (if_scenario scenario context) +(def (if_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do random.monad [_ (in []) @@ -133,7 +133,7 @@ actual_then actual_else])]))) -(def: random_member +(def random_member (Random Member) (do random.monad [lefts random.nat @@ -142,7 +142,7 @@ {.#Right lefts} {.#Left lefts})))) -(def: (get_scenario scenario context) +(def (get_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do [! random.monad] [length (at ! each (|>> (n.% 5) ++) random.nat) @@ -151,11 +151,11 @@ (in [(synthesis.branch/get [path expected_record]) (synthesis.branch/get [path actual_record])]))) -(def: random_side +(def random_side (Random Side) ..random_member) -(def: (path_scenario scenario context) +(def (path_scenario scenario context) (-> (Scenario Synthesis) (Scenario Path)) (`` (all random.either (all random.either @@ -216,7 +216,7 @@ {synthesis.#Alt actual_left actual_right}])) ))) -(def: (case_scenario scenario context) +(def (case_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do [! random.monad] [_ (in []) @@ -225,7 +225,7 @@ (in [(synthesis.branch/case [expected_input expected_path]) (synthesis.branch/case [actual_input actual_path])]))) -(def: (branch_scenario scenario context) +(def (branch_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (all random.either (..let_scenario scenario context) @@ -234,9 +234,9 @@ (..case_scenario scenario context) )) -(def: scope_arity 5) +(def scope_arity 5) -(def: (scope_scenario scenario context) +(def (scope_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do [! random.monad] [_ (in []) @@ -256,7 +256,7 @@ (in [(synthesis.loop/scope [real_start (list#each product.left inits) expected_iteration]) (synthesis.loop/scope [fake_start (list#each product.right inits) actual_iteration])]))) -(def: (again_scenario scenario context) +(def (again_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do [! random.monad] [_ (in []) @@ -264,14 +264,14 @@ (in [(synthesis.loop/again (list#each product.left resets)) (synthesis.loop/again (list#each product.right resets))]))) -(def: (loop_scenario scenario context) +(def (loop_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (all random.either (..scope_scenario scenario context) (..again_scenario scenario context) )) -(def: (abstraction_scenario scenario context) +(def (abstraction_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do [! random.monad] [_ (in []) @@ -282,7 +282,7 @@ (in [(synthesis.function/abstraction [expected_environment 1 expected_body]) (synthesis.function/abstraction [actual_environment 1 actual_body])]))) -(def: (apply_scenario scenario context) +(def (apply_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (do [! random.monad] [abstraction (at ! each (|>> synthesis.constant) @@ -292,14 +292,14 @@ (in [(synthesis.function/apply [abstraction (list#each product.left inputs)]) (synthesis.function/apply [abstraction (list#each product.right inputs)])]))) -(def: (function_scenario scenario context) +(def (function_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (all random.either (..abstraction_scenario scenario context) (..apply_scenario scenario context) )) -(def: (control_scenario scenario context) +(def (control_scenario scenario context) (-> (Scenario Synthesis) (Scenario Synthesis)) (all random.either (..branch_scenario scenario context) @@ -307,7 +307,7 @@ (..function_scenario scenario context) )) -(def: (scenario context) +(def (scenario context) (Scenario Synthesis) (all random.either (..primitive_scenario context) @@ -319,12 +319,12 @@ context) )) -(def: default +(def default Context [#redundants 0 #necessary (dictionary.empty n.hash)]) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux index 19ae703cb..08a7dd4b4 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/syntax.lux @@ -24,17 +24,17 @@ [\\ ["[0]" /]]) -(def: symbol_part^ +(def symbol_part^ (Random Text) (do [! r.monad] [size (|> r.nat (at ! each (|>> (n.% 20) (n.max 1))))] (r.lower_case_alpha size))) -(def: symbol^ +(def symbol^ (Random Symbol) (r.and symbol_part^ symbol_part^)) -(def: code^ +(def code^ (Random Code) (let [numeric^ (is (Random Code) (all r.either @@ -71,7 +71,7 @@ simple^ composite^)))))) -(def: code +(def code Test (do [! r.monad] [sample code^] @@ -106,20 +106,20 @@ (at code.equivalence = other =other))))))) ))) -(def: comment_text^ +(def comment_text^ (Random Text) (let [char_gen (|> r.nat (r.only (|>> (n.= (`` (char (~~ (static text.new_line))))) not)))] (do r.monad [size (|> r.nat (r#each (n.% 20)))] (r.text char_gen size)))) -(def: comment^ +(def comment^ (Random Text) (do r.monad [comment comment_text^] (in (format "... " comment text.new_line)))) -(def: comments +(def comments Test (do r.monad [sample code^ @@ -137,7 +137,7 @@ (at code.equivalence = parsed sample))) ))) -(def: .public test +(def .public test Test (<| (_.context (symbol.module (symbol /._))) (all _.and diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis.lux index 38d846740..8b5620394 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis.lux @@ -36,7 +36,7 @@ ["[1][0]" simple] ["[1][0]" access]]) -(def: !expect +(def !expect (template (_ <pattern> <value>) [(case <value> <pattern> @@ -45,17 +45,17 @@ _ false)])) -(def: random_constant +(def random_constant (Random Symbol) (random.and (random.unicode 1) (random.unicode 1))) -(def: random_variable +(def random_variable (Random Variable) (random.or random.nat random.nat)) -(def: random_environment +(def random_environment (Random (Environment Synthesis)) (do [! random.monad] [size (at ! each (n.% 5) random.nat)] @@ -63,7 +63,7 @@ (at ! each (|>> synthesis.variable)) (random.list size)))) -(def: simple +(def simple Test (`` (all _.and (~~ (with_template [<query> <check> <random> <synthesis> <equivalence>] @@ -93,7 +93,7 @@ )) ))) -(def: complex +(def complex Test (all _.and (do [! random.monad] @@ -163,7 +163,7 @@ (exception.match? \\parser.cannot_parse error))))))) )) -(def: \\parser +(def \\parser Test (<| (_.covering \\parser._) (_.for [\\parser.Parser]) @@ -206,7 +206,7 @@ )) ))) -(def: .public test +(def .public test Test (all _.and ..\\parser diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access.lux index 5b1a4de66..6b4e22b3a 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access.lux @@ -6,7 +6,7 @@ ["[1][0]" side] ["[1][0]" member]]) -(def: .public test +(def .public test Test (all _.and /side.test diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/member.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/member.lux index 5ff10e052..cb6eecc2b 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/member.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/member.lux @@ -15,14 +15,14 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Member) (all random.and random.nat random.bit )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Member]) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/side.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/side.lux index 4d3d12bad..1fb2caec2 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/side.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/access/side.lux @@ -15,14 +15,14 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Side) (all random.and random.nat random.bit )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Side]) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/simple.lux b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/simple.lux index 3fc98a592..6c6260ba4 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/simple.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/synthesis/simple.lux @@ -17,7 +17,7 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Simple) (all random.or random.bit @@ -26,7 +26,7 @@ (random.lower_case 1) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Simple]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive.lux b/stdlib/source/test/lux/tool/compiler/meta/archive.lux index 9153a8f3c..2fe7ddc98 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/archive.lux @@ -35,7 +35,7 @@ ["[1][0]" module] ["[1][0]" unit]]) -(def: .public (descriptor module hash) +(def .public (descriptor module hash) (-> /descriptor.Module Nat /descriptor.Descriptor) [/descriptor.#name module /descriptor.#file (format module ".lux") @@ -43,7 +43,7 @@ /descriptor.#state {.#Active} /descriptor.#references (set.empty text.hash)]) -(def: test|entry +(def test|entry Test (do random.monad [module/0 (random.lower_case 1) @@ -191,7 +191,7 @@ (exception.otherwise (exception.match? /.version_mismatch)))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Archive]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux index 3610d0116..5bb35f439 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/archive/artifact.lux @@ -12,7 +12,7 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Artifact) (all random.and random.nat @@ -20,7 +20,7 @@ random.bit )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Artifact /.ID]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/artifact/category.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/artifact/category.lux index 2f8086595..af39aec3d 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/archive/artifact/category.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/archive/artifact/category.lux @@ -10,7 +10,7 @@ [\\library ["[0]" /]]) -(def: random_definition +(def random_definition (Random /.Definition) (all random.and (random.lower_case 1) @@ -22,7 +22,7 @@ )) )) -(def: .public random +(def .public random (Random /.Category) (all random.or (random#in []) @@ -34,7 +34,7 @@ (random.lower_case 6) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Category]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/key.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/key.lux index b5c67b383..221380e77 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/archive/key.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/archive/key.lux @@ -11,7 +11,7 @@ ["[0]" // ["[1][0]" signature]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Key]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/module.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/module.lux index 343aeb8f7..0924b7d6e 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/archive/module.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/archive/module.lux @@ -19,7 +19,7 @@ ["[1][0]" document] ["[1][0]" descriptor]]) -(def: .public (random it) +(def .public (random it) (All (_ a) (-> (Random a) (Random (/.Module a)))) (all random.and random.nat @@ -30,7 +30,7 @@ (in (document.document (key.key signature example) example))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Module]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/module/descriptor.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/module/descriptor.lux index 6d2acbc82..379fb92de 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/archive/module/descriptor.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/archive/module/descriptor.lux @@ -18,7 +18,7 @@ [\\library ["[0]" /]]) -(def: random_module_state +(def random_module_state (Random Module_State) (all random.or (random#in []) @@ -26,7 +26,7 @@ (random#in []) )) -(def: .public (random imports) +(def .public (random imports) (-> Nat (Random /.Descriptor)) (all random.and (random.lower_case 1) @@ -36,7 +36,7 @@ (random.set text.hash imports (random.lower_case 2)) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Descriptor]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/module/document.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/module/document.lux index 4f25ec351..0647858d3 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/archive/module/document.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/archive/module/document.lux @@ -24,7 +24,7 @@ ["[0]" /// ["[1][0]" signature]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Document]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/registry.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/registry.lux index 3cd46c9c8..2c6a5c206 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/archive/registry.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/archive/registry.lux @@ -28,7 +28,7 @@ ["[0]" artifact (.only) ["[0]" category]]]]]) -(def: tagged? +(def tagged? (template (_ <tag> <it>) [(case <it> {<tag> _} @@ -37,18 +37,18 @@ _ false)])) -(def: random_dependency +(def random_dependency (Random unit.ID) (all random.and random.nat random.nat )) -(def: (random_dependencies amount) +(def (random_dependencies amount) (-> Nat (Random (Set unit.ID))) (random.set unit.hash amount ..random_dependency)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Registry]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/signature.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/signature.lux index 2586666ee..4f21b086b 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/archive/signature.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/archive/signature.lux @@ -21,7 +21,7 @@ ["[0]" //// ["[1][0]" version]]) -(def: .public random +(def .public random (Random /.Signature) (all random.and (all random.and @@ -30,7 +30,7 @@ ////version.random )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Signature]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/archive/unit.lux b/stdlib/source/test/lux/tool/compiler/meta/archive/unit.lux index 222ad9ec9..2dc7e3477 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/archive/unit.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/archive/unit.lux @@ -14,14 +14,14 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.ID) (all random.and random.nat random.nat )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.ID]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/cache.lux b/stdlib/source/test/lux/tool/compiler/meta/cache.lux index c2ba9e659..ae8df8e37 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/cache.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/cache.lux @@ -22,7 +22,7 @@ ["$/[1]" // ["[1][0]" context]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/tool/compiler/meta/cache/archive.lux b/stdlib/source/test/lux/tool/compiler/meta/cache/archive.lux index b93c34577..a05484a04 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/cache/archive.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/cache/archive.lux @@ -34,7 +34,7 @@ ["[1][0]" archive (.only) ["[2][0]" signature]]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/tool/compiler/meta/cache/artifact.lux b/stdlib/source/test/lux/tool/compiler/meta/cache/artifact.lux index 2fcbf2246..679bdfc47 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/cache/artifact.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/cache/artifact.lux @@ -24,7 +24,7 @@ ["$[0]" /// ["[1][0]" context]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/tool/compiler/meta/cache/module.lux b/stdlib/source/test/lux/tool/compiler/meta/cache/module.lux index 9508037ea..69993bdf6 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/cache/module.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/cache/module.lux @@ -18,11 +18,11 @@ ["$[0]" /// ["[1][0]" context]]) -(`` (def: (bad it) +(`` (def (bad it) (-> (file.System Async) (file.System Async)) (implementation (~~ (with_template [<name>] - [(def: <name> + [(def <name> (at it <name>))] [separator] @@ -41,11 +41,11 @@ [delete] )) - (def: (make_directory path) + (def (make_directory path) (async#in {try.#Failure ""})) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/tool/compiler/meta/cache/purge.lux b/stdlib/source/test/lux/tool/compiler/meta/cache/purge.lux index 47582d841..db1ab573d 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/cache/purge.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/cache/purge.lux @@ -41,7 +41,7 @@ ["$[1]" \\test]]]] ["/[1]" //]]]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/tool/compiler/meta/cli.lux b/stdlib/source/test/lux/tool/compiler/meta/cli.lux index d93193c54..f4230a2f8 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/cli.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/cli.lux @@ -27,7 +27,7 @@ ["$[0]" / ["[1][0]" compiler]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Service /.service]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux b/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux index b66061811..988f032f8 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/cli/compiler.lux @@ -21,7 +21,7 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Compiler) (do [! random.monad] [definition ($symbol.random 1 1) @@ -30,7 +30,7 @@ (in [/.#definition definition /.#parameters parameters]))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Compiler]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/context.lux b/stdlib/source/test/lux/tool/compiler/meta/context.lux index 41c2adf26..8137243dc 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/context.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/context.lux @@ -16,7 +16,7 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Context) (do [! random.monad] [context (all random.either @@ -27,7 +27,7 @@ (in /.ruby))] (at ! each context (random.lower_case 1)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Context /.Extension]) diff --git a/stdlib/source/test/lux/tool/compiler/meta/export.lux b/stdlib/source/test/lux/tool/compiler/meta/export.lux index 134f62058..1058fb18c 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/export.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/export.lux @@ -34,7 +34,7 @@ ["[0]" io ["[1]" context]]]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/tool/compiler/meta/import.lux b/stdlib/source/test/lux/tool/compiler/meta/import.lux index c5d2ce2b1..363fef1e5 100644 --- a/stdlib/source/test/lux/tool/compiler/meta/import.lux +++ b/stdlib/source/test/lux/tool/compiler/meta/import.lux @@ -38,7 +38,7 @@ ["[0]" io ["[1]" context]]]]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Import]) diff --git a/stdlib/source/test/lux/tool/compiler/phase.lux b/stdlib/source/test/lux/tool/compiler/phase.lux index 1692ffc4d..7a1d960cc 100644 --- a/stdlib/source/test/lux/tool/compiler/phase.lux +++ b/stdlib/source/test/lux/tool/compiler/phase.lux @@ -25,12 +25,12 @@ [meta ["[0]" archive]]]]]) -(def: (injection value) +(def (injection value) (All (_ s) (Injection (/.Operation s))) (function (_ state) {try.#Success [state value]})) -(def: (comparison init) +(def (comparison init) (All (_ s) (-> s (Comparison (/.Operation s)))) (function (_ == left right) (case [(/.result init left) @@ -44,7 +44,7 @@ (exception: oops) -(def: test|error +(def test|error Test (do [! random.monad] [state random.nat @@ -96,7 +96,7 @@ false)))) ))) -(def: test|state +(def test|state Test (do [! random.monad] [state random.nat @@ -133,7 +133,7 @@ false))) ))) -(def: test|operation +(def test|operation Test (do [! random.monad] [state random.nat @@ -165,7 +165,7 @@ ..test|error ))) -(def: test|phase +(def test|phase Test (do [! random.monad] [state/0 random.nat @@ -195,7 +195,7 @@ false)))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/tool/compiler/reference.lux b/stdlib/source/test/lux/tool/compiler/reference.lux index 3fcd3800d..eda2f8381 100644 --- a/stdlib/source/test/lux/tool/compiler/reference.lux +++ b/stdlib/source/test/lux/tool/compiler/reference.lux @@ -22,21 +22,21 @@ ["[0]" / ["[1][0]" variable]]) -(def: constant +(def constant (Random /.Constant) (all random.and (random.upper_case 5) (random.lower_case 5) )) -(def: .public random +(def .public random (Random /.Reference) (all random.or /variable.random ..constant )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Reference /.Constant]) diff --git a/stdlib/source/test/lux/tool/compiler/reference/variable.lux b/stdlib/source/test/lux/tool/compiler/reference/variable.lux index cfbd5eeaa..977fdbaf3 100644 --- a/stdlib/source/test/lux/tool/compiler/reference/variable.lux +++ b/stdlib/source/test/lux/tool/compiler/reference/variable.lux @@ -14,14 +14,14 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Variable) (all random.or random.nat random.nat )) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Variable]) diff --git a/stdlib/source/test/lux/tool/compiler/version.lux b/stdlib/source/test/lux/tool/compiler/version.lux index d441ef9d1..695c36644 100644 --- a/stdlib/source/test/lux/tool/compiler/version.lux +++ b/stdlib/source/test/lux/tool/compiler/version.lux @@ -15,11 +15,11 @@ [\\library ["[0]" /]]) -(def: .public random +(def .public random (Random /.Version) random.nat) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Version]) diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux index e365ab360..7972ba4e8 100644 --- a/stdlib/source/test/lux/type.lux +++ b/stdlib/source/test/lux/type.lux @@ -35,17 +35,17 @@ ["[1][0]" unit] ["[1][0]" variance]]) -(def: short +(def short (Random Text) (do [! random.monad] [size (|> random.nat (at ! each (n.% 10)))] (random.unicode size))) -(def: symbol +(def symbol (Random Symbol) (random.and ..short ..short)) -(def: (random' parameters) +(def (random' parameters) (-> Nat (Random Type)) (random.rec (function (_ again) @@ -65,14 +65,14 @@ (random#each (|>> (n.% parameters) {.#Parameter})) (random.either un_parameterized))))))) -(def: .public (random parameters) +(def .public (random parameters) (-> Nat (Random Type)) (all random.either (random#each (/.univ_q parameters) (random' parameters)) (random#each (/.ex_q parameters) (random' parameters)) )) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/type/check.lux b/stdlib/source/test/lux/type/check.lux index 9f3c993dc..ebc227760 100644 --- a/stdlib/source/test/lux/type/check.lux +++ b/stdlib/source/test/lux/type/check.lux @@ -32,15 +32,15 @@ ["[0]" /]]) ... TODO: Remove the following 3 definitions ASAP. //.type already exists... -(def: short +(def short (Random Text) (random.unicode 10)) -(def: symbol +(def symbol (Random Symbol) (random.and ..short ..short)) -(def: (type' num_vars) +(def (type' num_vars) (-> Nat (Random Type)) (random.rec (function (_ again) @@ -66,11 +66,11 @@ (random#each (|>> {.#Named}) (random.and ..symbol (type' 0))) ))))) -(def: type +(def type (Random Type) (..type' 0)) -(def: (valid_type? type) +(def (valid_type? type) (-> Type Bit) (case type {.#Primitive name params} @@ -91,11 +91,11 @@ _ #0)) -(def: injection +(def injection (Injection (All (_ a) (/.Check a))) (at /.monad in)) -(def: comparison +(def comparison (Comparison (All (_ a) (/.Check a))) (function (_ == left right) (case [(/.result /.fresh_context left) (/.result /.fresh_context right)] @@ -105,7 +105,7 @@ _ false))) -(def: polymorphism +(def polymorphism Test (all _.and (_.for [/.functor] @@ -116,20 +116,20 @@ ($monad.spec ..injection ..comparison /.monad)) )) -(def: (primitive_type parameters) +(def (primitive_type parameters) (-> Nat (Random Type)) (do random.monad [primitive (random.upper_case 3) parameters (random.list parameters (primitive_type (-- parameters)))] (in {.#Primitive primitive parameters}))) -(def: clean_type +(def clean_type (Random Type) (primitive_type 2)) (exception: yolo) -(def: error_handling +(def error_handling Test (do random.monad [left ..clean_type @@ -195,7 +195,7 @@ (scenario {.#Apply left right} left))))) ))) -(def: var +(def var Test (<| (_.for [/.Var]) (all _.and @@ -324,7 +324,7 @@ false))) ))) -(def: context +(def context Test (all _.and (_.coverage [/.fresh_context] @@ -363,7 +363,7 @@ false)) )) -(def: succeeds? +(def succeeds? (All (_ a) (-> (/.Check a) Bit)) (|>> (/.result /.fresh_context) (pipe.case {try.#Success _} @@ -372,18 +372,18 @@ {try.#Failure error} false))) -(def: fails? +(def fails? (All (_ a) (-> (/.Check a) Bit)) (|>> ..succeeds? not)) -(def: nominal +(def nominal (Random Type) (do random.monad [name (random.upper_case 10)] (in {.#Primitive name (list)}))) -(def: (non_twins = random) +(def (non_twins = random) (All (_ a) (-> (-> a a Bit) (Random a) (Random [a a]))) (do random.monad [left random @@ -396,7 +396,7 @@ (type: Sub (Super Bit)) -(def: (handles_nominal_types! name/0 name/1 parameter/0 parameter/1) +(def (handles_nominal_types! name/0 name/1 parameter/0 parameter/1) (-> Text Text Type Type Bit) (let [names_matter! (and (..succeeds? (/.check {.#Primitive name/0 (list)} @@ -420,7 +420,7 @@ covariant_parameters!))) (with_template [<assertion> <combinator>] - [(def: (<assertion> name/0 name/1) + [(def (<assertion> name/0 name/1) (-> Text Text Bit) (let [pair/0 {<combinator> {.#Primitive name/0 (list)} {.#Primitive name/0 (list)}} pair/1 {<combinator> {.#Primitive name/1 (list)} {.#Primitive name/1 (list)}} @@ -442,7 +442,7 @@ [handles_sums! .#Sum] ) -(def: (handles_function_variance! nominal) +(def (handles_function_variance! nominal) (-> Type Bit) (let [functions_have_contravariant_inputs! (..succeeds? (/.check {.#Function Sub nominal} {.#Function Super nominal})) @@ -452,7 +452,7 @@ (and functions_have_contravariant_inputs! functions_have_covariant_outputs!))) -(def: (verdict check) +(def (verdict check) (All (_ _) (-> (/.Check _) (/.Check Bit))) (function (_ context) {try.#Success [context (case (check context) @@ -462,7 +462,7 @@ {try.#Failure _} false)]})) -(def: (build_ring tail_size) +(def (build_ring tail_size) (-> Nat (/.Check [Type (List Type) Type])) (do [! /.monad] [[id/head var/head] /.var @@ -480,7 +480,7 @@ _ (/.check var/last var/head)] (in [var/head var/tail+ var/last]))) -(def: (handles_var_rings! tail_size nominal/0 nominal/1) +(def (handles_var_rings! tail_size nominal/0 nominal/1) (-> Nat Type Type Bit) (let [can_create_rings_of_variables! (succeeds? (..build_ring tail_size)) @@ -510,7 +510,7 @@ can_bind_rings_of_variables! can_merge_multiple_rings_of_variables!))) -(def: (handles_vars! nominal) +(def (handles_vars! nominal) (-> Type Bit) (let [vars_check_against_themselves! (succeeds? (do /.monad @@ -558,7 +558,7 @@ cannot_rebind! bound_vars_check_against_their_bound_types!))) -(def: handles_existentials! +(def handles_existentials! Bit (let [existentials_always_match_themselves! (..succeeds? (do /.monad @@ -573,7 +573,7 @@ (and existentials_always_match_themselves! existentials_never_match_each_other!))) -(def: (handles_quantification! nominal) +(def (handles_quantification! nominal) (-> Type Bit) (let [universals_satisfy_themselves! (..succeeds? (/.check (.type (All (_ a) (Maybe a))) @@ -608,7 +608,7 @@ existentials_do_not_satisfy_particulars! ))) -(def: (handles_ultimates! nominal) +(def (handles_ultimates! nominal) (-> Type Bit) (let [any_is_the_ultimate_super_type! (and (..succeeds? (/.check Any nominal)) @@ -625,14 +625,14 @@ nothing_is_the_ultimate_sub_type! ultimates_check_themselves!))) -(def: (names_do_not_affect_types! left_name right_name nominal) +(def (names_do_not_affect_types! left_name right_name nominal) (-> Symbol Symbol Type Bit) (and (..succeeds? (/.check {.#Named left_name Any} nominal)) (..succeeds? (/.check Any {.#Named right_name nominal})) (..succeeds? (/.check {.#Named left_name Any} {.#Named right_name nominal})))) ... TODO: Test all the crazy corner cases from /.check_apply -(def: (handles_application! nominal/0 nominal/1) +(def (handles_application! nominal/0 nominal/1) (-> Type Type Bit) (let [types_flow_through! (and (..succeeds? (/.check (.type ((All (_ a) a) nominal/0)) @@ -658,7 +658,7 @@ (and types_flow_through! multiple_parameters!))) -(def: check +(def check Test (do [! random.monad] [nominal ..nominal @@ -681,7 +681,7 @@ (..names_do_not_affect_types! left_name right_name nominal) )))) -(def: dirty_type +(def dirty_type (Random (-> Type Type)) (random.rec (function (_ dirty_type) @@ -726,7 +726,7 @@ )) ))))) -(def: clean +(def clean Test (do random.monad [type_shape ..dirty_type] @@ -749,7 +749,7 @@ (try.else false)) )))) -(def: for_subsumption|ultimate +(def for_subsumption|ultimate (Random Bit) (do random.monad [example ..clean_type] @@ -760,7 +760,7 @@ (not (/.subsumes? .Nothing example)) )))) -(def: for_subsumption|nominal +(def for_subsumption|nominal (Random Bit) (do random.monad [primitive (random.upper_case 10) @@ -777,7 +777,7 @@ {.#Primitive primitive (list example)})) )))) -(def: for_subsumption|sum +(def for_subsumption|sum (Random Bit) (do random.monad [left ..clean_type @@ -792,7 +792,7 @@ {.#Sum left right})) )))) -(def: for_subsumption|product +(def for_subsumption|product (Random Bit) (do random.monad [left ..clean_type @@ -807,7 +807,7 @@ {.#Product left right})) )))) -(def: for_subsumption|function +(def for_subsumption|function (Random Bit) (do random.monad [left ..clean_type @@ -821,7 +821,7 @@ )))) (with_template [<tag> <name>] - [(def: <name> + [(def <name> (Random Bit) (do random.monad [id random.nat @@ -833,7 +833,7 @@ [.#Ex for_subsumption|existential] ) -(def: for_subsumption|quantification+application +(def for_subsumption|quantification+application (Random Bit) (do random.monad [example ..clean_type] @@ -842,7 +842,7 @@ (and (/.subsumes? (.type (Ex (_ a) (List a))) (.type (List example))) (not (/.subsumes? (.type (List example)) (.type (Ex (_ a) (List a)))))))))) -(def: for_subsumption|named +(def for_subsumption|named (Random Bit) (do random.monad [module (random.upper_case 10) @@ -854,7 +854,7 @@ {.#Named [module short] example}) )))) -(def: for_subsumption +(def for_subsumption Test (do random.monad [for_subsumption|ultimate ..for_subsumption|ultimate @@ -878,7 +878,7 @@ for_subsumption|named )))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Check]) diff --git a/stdlib/source/test/lux/type/dynamic.lux b/stdlib/source/test/lux/type/dynamic.lux index 756545b61..326c92375 100644 --- a/stdlib/source/test/lux/type/dynamic.lux +++ b/stdlib/source/test/lux/type/dynamic.lux @@ -17,7 +17,7 @@ [\\library ["[0]" /]]) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Dynamic]) diff --git a/stdlib/source/test/lux/type/implicit.lux b/stdlib/source/test/lux/type/implicit.lux index 4e69f9f10..276a9c051 100644 --- a/stdlib/source/test/lux/type/implicit.lux +++ b/stdlib/source/test/lux/type/implicit.lux @@ -21,7 +21,7 @@ (/.implicitly n.multiplication) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/type/primitive.lux b/stdlib/source/test/lux/type/primitive.lux index c2be544ed..6b6f56535 100644 --- a/stdlib/source/test/lux/type/primitive.lux +++ b/stdlib/source/test/lux/type/primitive.lux @@ -25,7 +25,7 @@ (template.with_locals [g!Foo g!Bar] (these (with_template [<syntax> <meta>] - [(def: <syntax> + [(def <syntax> (syntax (_ []) (do meta.monad [frame <meta>] @@ -35,7 +35,7 @@ [specific (/.specific (template.text [g!Foo]))] ) - (def: with_no_active_frames + (def with_no_active_frames (syntax (_ [macro <code>.any]) (function (_ compiler) (let [verdict (case ((macro.expansion macro) compiler) @@ -54,7 +54,7 @@ (/.primitive (g!Bar a) Nat - (def: .public test + (def .public test Test (<| (_.covering /._) (_.for [/.primitive]) diff --git a/stdlib/source/test/lux/type/quotient.lux b/stdlib/source/test/lux/type/quotient.lux index 1653fcb36..6d1d85f6f 100644 --- a/stdlib/source/test/lux/type/quotient.lux +++ b/stdlib/source/test/lux/type/quotient.lux @@ -16,17 +16,17 @@ [\\library ["[0]" /]]) -(def: .public (random class super) +(def .public (random class super) (All (_ t c %) (-> (/.Class t c %) (Random t) (Random (/.Quotient t c %)))) (at random.monad each (/.quotient class) super)) -(def: mod_10_class +(def mod_10_class (/.class (|>> (n.% 10) %.nat))) -(def: Mod_10 +(def Mod_10 (/.type ..mod_10_class)) -(def: .public test +(def .public test Test (<| (_.covering /._) (do random.monad diff --git a/stdlib/source/test/lux/type/refinement.lux b/stdlib/source/test/lux/type/refinement.lux index 29856f4f5..b30e4a19d 100644 --- a/stdlib/source/test/lux/type/refinement.lux +++ b/stdlib/source/test/lux/type/refinement.lux @@ -17,13 +17,13 @@ [\\library ["[0]" /]]) -(def: _refiner +(def _refiner (/.refiner (n.> 123))) -(def: _type +(def _type (/.type _refiner)) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Refined]) diff --git a/stdlib/source/test/lux/type/resource.lux b/stdlib/source/test/lux/type/resource.lux index 1c2547ad9..8bd0f85d4 100644 --- a/stdlib/source/test/lux/type/resource.lux +++ b/stdlib/source/test/lux/type/resource.lux @@ -26,7 +26,7 @@ [\\library ["[0]" / (.only Res)]]) -(def: pure +(def pure Test (monad.do [! random.monad] [pre (at ! each %.nat random.nat) @@ -68,7 +68,7 @@ )) ))))) -(def: sync +(def sync Test (monad.do [! random.monad] [pre (at ! each %.nat random.nat) @@ -111,7 +111,7 @@ )) ))))) -(def: async +(def async Test (monad.do [! random.monad] [pre (at ! each %.nat random.nat) @@ -155,7 +155,7 @@ )) ))))) -(def: with_error +(def with_error (syntax (_ [exception <code>.symbol to_expand <code>.any]) (monad.do meta.monad @@ -169,7 +169,7 @@ {try.#Failure error} true)))]})))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Procedure]) diff --git a/stdlib/source/test/lux/type/unit.lux b/stdlib/source/test/lux/type/unit.lux index a4198429c..048be4d5b 100644 --- a/stdlib/source/test/lux/type/unit.lux +++ b/stdlib/source/test/lux/type/unit.lux @@ -19,7 +19,7 @@ ["[1][0]" scale]]) (with_template [<name> <type> <unit>] - [(def: (<name> range) + [(def (<name> range) (-> Nat (Random (/.Qty Any <type>))) (|> random.int (at random.monad each (i.% (.int range))) @@ -30,7 +30,7 @@ [second /.Second /.second] ) -(def: polymorphism +(def polymorphism Test (all _.and (_.for [/.equivalence] @@ -41,10 +41,10 @@ ($enum.spec /.enum (..meter 1,000))) )) -(def: what (/.unit [])) -(def: What (/.type what)) +(def what (/.unit [])) +(def What (/.type what)) -(def: unit +(def unit Test (do random.monad [expected random.int] @@ -75,7 +75,7 @@ (i.= expected))) ))))) -(def: arithmetic +(def arithmetic Test (do random.monad [.let [zero (at /.meter in +0) @@ -105,7 +105,7 @@ (meter#= right))) )))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Qty]) diff --git a/stdlib/source/test/lux/type/unit/scale.lux b/stdlib/source/test/lux/type/unit/scale.lux index 569cdc0ba..589e553ab 100644 --- a/stdlib/source/test/lux/type/unit/scale.lux +++ b/stdlib/source/test/lux/type/unit/scale.lux @@ -18,7 +18,7 @@ ["[0]" / (.only) ["/[1]" //]]]) -(def: natural +(def natural (syntax (_ []) (at meta.monad each (|>> code.nat list) @@ -26,14 +26,14 @@ (with_expansions [<from> (..natural) <to> (..natural)] - (def: how (/.scale [ratio.#denominator <from> ratio.#numerator <to>])) - (def: How (/.type how)) + (def how (/.scale [ratio.#denominator <from> ratio.#numerator <to>])) + (def How (/.type how)) - (def: how::from <from>) - (def: how::to <to>) + (def how::from <from>) + (def how::to <to>) ) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Scale]) diff --git a/stdlib/source/test/lux/type/variance.lux b/stdlib/source/test/lux/type/variance.lux index c9e65123e..1914fe807 100644 --- a/stdlib/source/test/lux/type/variance.lux +++ b/stdlib/source/test/lux/type/variance.lux @@ -17,7 +17,7 @@ (type: Sub (Super Bit)) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/world.lux b/stdlib/source/test/lux/world.lux index bebd06ea8..51002f660 100644 --- a/stdlib/source/test/lux/world.lux +++ b/stdlib/source/test/lux/world.lux @@ -17,7 +17,7 @@ ["[1]/[0]" client] ["[1]/[0]" status]]]]) -(def: .public test +(def .public test Test (all _.and /file.test diff --git a/stdlib/source/test/lux/world/console.lux b/stdlib/source/test/lux/world/console.lux index cd3ac7f1d..cc43e3860 100644 --- a/stdlib/source/test/lux/world/console.lux +++ b/stdlib/source/test/lux/world/console.lux @@ -20,10 +20,10 @@ (exception: dead) -(def: mock +(def mock (/.Mock [Bit Text]) (implementation - (def: (on_read [dead? content]) + (def (on_read [dead? content]) (do try.monad [char (try.of_maybe (text.char 0 content)) [_ content] (try.of_maybe (text.split_at 1 content))] @@ -31,24 +31,24 @@ (exception.except ..dead []) (in [[dead? content] char])))) - (def: (on_read_line [dead? content]) + (def (on_read_line [dead? content]) (do try.monad [[line content] (try.of_maybe (text.split_by text.new_line content))] (if dead? (exception.except ..dead []) (in [[dead? content] line])))) - (def: (on_write message [dead? content]) + (def (on_write message [dead? content]) (if dead? (exception.except ..dead []) {try.#Success [dead? (format content message)]})) - (def: (on_close [dead? content]) + (def (on_close [dead? content]) (if dead? (exception.except ..dead []) {try.#Success [true content]})))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux index 872436a4f..3f8cb84f4 100644 --- a/stdlib/source/test/lux/world/file.lux +++ b/stdlib/source/test/lux/world/file.lux @@ -33,7 +33,7 @@ (type: Disk (Dictionary /.Path (Either [Instant Binary] (List Text)))) -(def: (file? disk @) +(def (file? disk @) (-> (Atom Disk) (-> /.Path (IO Bit))) (do io.monad [disk (atom.read! disk)] @@ -42,7 +42,7 @@ {.#Some {.#Left _}} true {.#Some {.#Right _}} false)))) -(def: (directory? disk @) +(def (directory? disk @) (-> (Atom Disk) (-> /.Path (IO Bit))) (do io.monad [disk (atom.read! disk)] @@ -51,7 +51,7 @@ {.#Some {.#Left _}} false {.#Some {.#Right _}} true)))) -(def: (alert_parent! disk alert @) +(def (alert_parent! disk alert @) (-> (Atom Disk) (-> (List /.Path) (List /.Path)) (-> /.Path (IO (Try Any)))) @@ -66,7 +66,7 @@ _ (in {try.#Failure ""})))) -(def: (write fs disk @ it) +(def (write fs disk @ it) (-> (/.System Async) (Atom Disk) (-> /.Path Binary (IO (Try Any)))) (do [! io.monad] [now instant.now @@ -86,7 +86,7 @@ _ (in {try.#Failure ""})))) -(def: (read disk @) +(def (read disk @) (-> (Atom Disk) (-> /.Path (IO (Try Binary)))) (do io.monad [disk (atom.read! disk)] @@ -97,7 +97,7 @@ _ {try.#Failure ""})))) -(def: (delete fs disk @) +(def (delete fs disk @) (-> (/.System Async) (Atom Disk) (-> /.Path (IO (Try Any)))) (do [! io.monad] @@ -123,21 +123,21 @@ _ (in {try.#Failure ""})))) -(def: (fs /) +(def (fs /) (-> Text (/.System IO)) (let [disk (is (Atom Disk) (atom.atom (dictionary.empty text.hash))) mock (/.mock /)] (implementation - (def: separator /) + (def separator /) - (def: file? (..file? disk)) - (def: directory? (..directory? disk)) - (def: write (..write mock disk)) - (def: read (..read disk)) - (def: delete (..delete mock disk)) + (def file? (..file? disk)) + (def directory? (..directory? disk)) + (def write (..write mock disk)) + (def read (..read disk)) + (def delete (..delete mock disk)) - (def: (file_size @) + (def (file_size @) (do [! io.monad] [disk (atom.read! disk)] (in (case (dictionary.value @ disk) @@ -146,7 +146,7 @@ _ {try.#Failure ""})))) - (def: (last_modified @) + (def (last_modified @) (do [! io.monad] [disk (atom.read! disk)] (in (case (dictionary.value @ disk) @@ -155,7 +155,7 @@ _ {try.#Failure ""})))) - (def: (can_execute? @) + (def (can_execute? @) (do [! io.monad] [disk (atom.read! disk)] (in (case (dictionary.value @ disk) @@ -165,7 +165,7 @@ _ {try.#Failure ""})))) - (def: (make_directory @) + (def (make_directory @) (do [! io.monad] [disk' (atom.read! disk)] (case (dictionary.value @ disk') @@ -181,7 +181,7 @@ _ (in {try.#Failure ""})))) - (def: (directory_files @) + (def (directory_files @) (do [! io.monad] [disk' (atom.read! disk)] (case (dictionary.value @ disk') @@ -192,7 +192,7 @@ _ (in {try.#Failure ""})))) - (def: (sub_directories @) + (def (sub_directories @) (do [! io.monad] [disk' (atom.read! disk)] (case (dictionary.value @ disk') @@ -203,7 +203,7 @@ _ (in {try.#Failure ""})))) - (def: (append @ it) + (def (append @ it) (do [! io.monad] [now instant.now disk' (atom.read! disk)] @@ -220,7 +220,7 @@ _ (in {try.#Failure ""})))) - (def: (modify @ it) + (def (modify @ it) (do [! io.monad] [disk' (atom.read! disk)] (case (dictionary.value @ disk') @@ -231,14 +231,14 @@ _ (in {try.#Failure ""})))) - (def: (move @ it) + (def (move @ it) (do [! (try.with io.monad)] [data (..read disk @) write (..write mock disk it data)] (..delete mock disk @))) ))) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/world/file/watch.lux b/stdlib/source/test/lux/world/file/watch.lux index 2a2053e77..78e239524 100644 --- a/stdlib/source/test/lux/world/file/watch.lux +++ b/stdlib/source/test/lux/world/file/watch.lux @@ -25,7 +25,7 @@ [data ["$[0]" binary]]]) -(def: concern +(def concern (Random [/.Concern (Predicate /.Concern)]) (all random.either (random#in [/.creation /.creation?]) @@ -33,7 +33,7 @@ (random#in [/.deletion /.deletion?]) )) -(def: concern::test +(def concern::test Test (all _.and (_.coverage [/.creation /.creation?] @@ -64,7 +64,7 @@ (/.deletion? /.all))) )) -(def: exception +(def exception Test (do [! random.monad] [directory (random.alphabetic 5) @@ -88,7 +88,7 @@ false))))) ))) -(def: (no_events_prior_to_creation! fs watcher directory) +(def (no_events_prior_to_creation! fs watcher directory) (-> (//.System Async) (/.Watcher Async) //.Path (Async (Try Bit))) (do [! (try.with async.monad)] [_ (at fs make_directory directory) @@ -96,7 +96,7 @@ (|> (at watcher poll []) (at ! each list.empty?)))) -(def: (after_creation! fs watcher expected_path) +(def (after_creation! fs watcher expected_path) (-> (//.System Async) (/.Watcher Async) //.Path (Async (Try Bit))) (do (try.with async.monad) [_ (is (Async (Try Any)) @@ -114,7 +114,7 @@ false) (list.empty? poll/post))))) -(def: (after_modification! fs watcher data expected_path) +(def (after_modification! fs watcher data expected_path) (-> (//.System Async) (/.Watcher Async) Binary //.Path (Async (Try Bit))) (do (try.with async.monad) [_ (async.after 1 {try.#Success "Delay to make sure the over_write time-stamp always changes."}) @@ -132,7 +132,7 @@ false) (list.empty? poll/2'))))) -(def: (after_deletion! fs watcher expected_path) +(def (after_deletion! fs watcher expected_path) (-> (//.System Async) (/.Watcher Async) //.Path (Async (Try Bit))) (do (try.with async.monad) [_ (at fs delete expected_path) @@ -148,7 +148,7 @@ false) (list.empty? poll/3'))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Watcher]) diff --git a/stdlib/source/test/lux/world/input/keyboard.lux b/stdlib/source/test/lux/world/input/keyboard.lux index 6d3daa301..a2db959e7 100644 --- a/stdlib/source/test/lux/world/input/keyboard.lux +++ b/stdlib/source/test/lux/world/input/keyboard.lux @@ -110,7 +110,7 @@ /.f22 /.f23 /.f24]])] - (def: listing + (def listing (List /.Key) (list.together (`` (list (~~ (with_template [<definition> <keys>] [((is (-> Any (List /.Key)) @@ -120,30 +120,30 @@ <groups>)))))) - (def: catalogue + (def catalogue (Set /.Key) (set.of_list n.hash ..listing)) - (def: verdict + (def verdict (n.= (list.size ..listing) (set.size ..catalogue))) (with_template [<definition> <keys>] - [(def: <definition> + [(def <definition> Test (_.coverage <keys> ..verdict))] <groups>) - (def: .public random + (def .public random (Random /.Key) (let [count (list.size ..listing)] (do [! random.monad] [choice (at ! each (n.% count) random.nat)] (in (maybe.trusted (list.item choice ..listing)))))) - (def: .public test + (def .public test Test (<| (_.covering /._) (_.for [/.Key]) diff --git a/stdlib/source/test/lux/world/net/http/client.lux b/stdlib/source/test/lux/world/net/http/client.lux index 1ccf30196..1572f30d3 100644 --- a/stdlib/source/test/lux/world/net/http/client.lux +++ b/stdlib/source/test/lux/world/net/http/client.lux @@ -29,7 +29,7 @@ ["/[1]" // (.only) ["[1][0]" status]]]]) -(def: (verification ! expected response) +(def (verification ! expected response) (All (_ !) (-> (Monad !) Nat (! (Try (//.Response !))) (! Bit))) @@ -51,7 +51,7 @@ {try.#Failure error} (in false)))) -(def: .public test +(def .public test Test (<| (_.covering /._) (_.for [/.Client]) @@ -69,7 +69,7 @@ headers (random.dictionary text.hash num_headers (random.lower_case 3) (random.lower_case 3)) .let [mock (is (/.Client IO) (implementation - (def: (request method url headers data) + (def (request method url headers data) (io.io (let [value (case method {//.#Post} on_post {//.#Get} on_get diff --git a/stdlib/source/test/lux/world/net/http/status.lux b/stdlib/source/test/lux/world/net/http/status.lux index 28789a09a..4ba760537 100644 --- a/stdlib/source/test/lux/world/net/http/status.lux +++ b/stdlib/source/test/lux/world/net/http/status.lux @@ -82,7 +82,7 @@ /.loop_detected /.not_extended /.network_authentication_required]])] - (def: all + (def all (List //.Status) (list.together (`` (list (~~ (with_template [<category> <status+>] [((is (-> Any (List //.Status)) @@ -92,23 +92,23 @@ <categories>)))))) - (def: unique + (def unique (Set //.Status) (set.of_list n.hash ..all)) - (def: verdict + (def verdict (n.= (list.size ..all) (set.size ..unique))) (with_template [<category> <status+>] - [(def: <category> + [(def <category> Test (_.coverage <status+> ..verdict))] <categories>) - (def: .public test + (def .public test Test (<| (_.covering /._) (`` (.all _.and diff --git a/stdlib/source/test/lux/world/output/video/resolution.lux b/stdlib/source/test/lux/world/output/video/resolution.lux index f9e679733..d7fa6e20b 100644 --- a/stdlib/source/test/lux/world/output/video/resolution.lux +++ b/stdlib/source/test/lux/world/output/video/resolution.lux @@ -35,22 +35,22 @@ /.wuxga /.wqhd /.uhd_4k)] - (def: listing + (def listing (List /.Resolution) (list <resolutions>)) - (def: catalogue + (def catalogue (Set /.Resolution) (set.of_list /.hash ..listing)) - (def: .public random + (def .public random (Random /.Resolution) (let [count (list.size ..listing)] (do [! random.monad] [choice (at ! each (n.% count) random.nat)] (in (maybe.trusted (list.item choice ..listing)))))) - (def: .public test + (def .public test Test (<| (_.covering /._) (_.for [/.Resolution]) diff --git a/stdlib/source/test/lux/world/program.lux b/stdlib/source/test/lux/world/program.lux index 3067422e0..dac2768c9 100644 --- a/stdlib/source/test/lux/world/program.lux +++ b/stdlib/source/test/lux/world/program.lux @@ -28,17 +28,17 @@ [\\specification ["$[0]" /]]) -(def: (environment env_size) +(def (environment env_size) (-> Nat (Random Environment)) (random.dictionary text.hash env_size (random.alphabetic 5) (random.alphabetic 5))) -(def: path +(def path (Random Path) (random.alphabetic 5)) -(def: .public test +(def .public test Test (<| (_.covering /._) (do [! random.monad] diff --git a/stdlib/source/test/lux/world/shell.lux b/stdlib/source/test/lux/world/shell.lux index 3ad40e908..dd83fd31b 100644 --- a/stdlib/source/test/lux/world/shell.lux +++ b/stdlib/source/test/lux/world/shell.lux @@ -30,57 +30,57 @@ (exception: dead) -(def: (mock [environment working_directory command arguments]) +(def (mock [environment working_directory command arguments]) (-> [Environment Path /.Command (List /.Argument)] (/.Mock Bit)) (implementation - (def: (on_read dead?) + (def (on_read dead?) (if dead? (exception.except ..dead []) (do try.monad [echo (try.of_maybe (list.head arguments))] (in [dead? echo])))) - (def: (on_fail dead?) + (def (on_fail dead?) (if dead? (exception.except ..dead []) {try.#Success [dead? ""]})) - (def: (on_write message dead?) + (def (on_write message dead?) (if dead? (exception.except ..dead []) {try.#Success dead?})) - (def: (on_destroy dead?) + (def (on_destroy dead?) (if dead? (exception.except ..dead []) {try.#Success true})) - (def: (on_await dead?) + (def (on_await dead?) (if dead? (exception.except ..dead []) {try.#Success [true /.normal]})))) -(def: (io_shell command oops input destruction exit) +(def (io_shell command oops input destruction exit) (-> /.Command Text Text Text /.Exit (/.Shell IO)) (implementation - (def: (execute [environment working_directory command arguments]) + (def (execute [environment working_directory command arguments]) (<| io.io {try.#Success} (is (/.Process IO)) (implementation - (def: (read _) + (def (read _) (io.io {try.#Success command})) - (def: (fail _) + (def (fail _) (io.io {try.#Success oops})) - (def: (write message) + (def (write message) (io.io {try.#Failure message})) - (def: (destroy _) + (def (destroy _) (io.io {try.#Failure destruction})) - (def: (await _) + (def (await _) (io.io {try.#Success exit}))))))) -(def: .public test +(def .public test Test (<| (_.covering /._) (all _.and diff --git a/stdlib/source/unsafe/lux/data/binary.lux b/stdlib/source/unsafe/lux/data/binary.lux index 1dc9fc96c..a59239afb 100644 --- a/stdlib/source/unsafe/lux/data/binary.lux +++ b/stdlib/source/unsafe/lux/data/binary.lux @@ -5,7 +5,7 @@ ["[0]" ffi] [control [function - [inline (.only inline:)]]] + [inline (.only inlined)]]] [data [collection ["[0]" array @@ -60,7 +60,7 @@ (`` (with_expansions [<size> (.is .Nat size) <jvm> (ffi.array byte <size>) <jvm> (.is ..Binary <jvm>)] - (def: .public empty + (def .public empty (template (empty size) [(is ..Binary (for (~~ (.static @.old)) <jvm> @@ -90,7 +90,7 @@ (`` (with_expansions [<it> (.is ..Binary it) <jvm> (ffi.length <it>)] - (def: .public size + (def .public size (template (size it) [(.is .Nat (.for (~~ (.static @.old)) <jvm> @@ -114,7 +114,7 @@ ... Default (array.size <it>)))])))) -(def: byte_mask +(def byte_mask Nat (i64.mask i64.bits_per_byte)) @@ -126,7 +126,7 @@ <jvm> (.|> <jvm> (.as .I64) ("lux i64 and" <byte_mask>))] - (def: .public bits_8 + (def .public bits_8 (template (bits_8 index it) [(.<| (.as .I64) (.is (.I64 .Any)) @@ -154,7 +154,7 @@ (.i64 0) (array.item <index> <it>)))))]))) -(def: .public bits_16 +(def .public bits_16 (template (bits_16 index' it') [(.<| (.let [index (.is Nat index') it (.is ..Binary it')]) @@ -164,7 +164,7 @@ ("lux i64 left-shift" 8 (..bits_8 index it)) (..bits_8 ("lux i64 +" 1 index) it)))])) -(def: .public bits_32 +(def .public bits_32 (template (bits_32 index' it') [(.<| (.let [index (.is Nat index') it (.is ..Binary it')]) @@ -176,7 +176,7 @@ ("lux i64 left-shift" 8 (..bits_8 ("lux i64 +" 2 index) it)) (..bits_8 ("lux i64 +" 3 index) it)))])) -(def: .public bits_64 +(def .public bits_64 (template (bits_64 index' it') [(.<| (.let [index (.is Nat index') it (.is ..Binary it')]) @@ -205,7 +205,7 @@ <jvm_value> <jvm_value> <jvm_value> (ffi.long_to_byte <jvm_value>) <jvm> (ffi.write! <index> <jvm_value> <it>)] - (`` (def: .public has_8! + (`` (def .public has_8! (template (has_8! index value it) [(.is ..Binary (.for (~~ (.static @.old)) <jvm> @@ -239,7 +239,7 @@ ... Default (array.has! <index> (.|> <value> .int ("lux i64 and" (.int <byte>))) <it>)))])))) -(def: .public has_16! +(def .public has_16! (template (has_16! index' value' it) [(.let [index (.is .Nat index') value (.is (.I64 .Any) value')] @@ -247,7 +247,7 @@ (..has_8! index ("lux i64 right-shift" 8 value)) (..has_8! ("lux i64 +" 1 index) value)))])) -(def: .public has_32! +(def .public has_32! (template (has_32! index' value' it) [(.let [index (.is .Nat index') value (.is (.I64 .Any) value')] @@ -257,7 +257,7 @@ (..has_8! ("lux i64 +" 2 index) ("lux i64 right-shift" 8 value)) (..has_8! ("lux i64 +" 3 index) value)))])) -(`` (def: .public has_64! +(`` (def .public has_64! (template (has_64! index' value' it) [(.let [index (.is .Nat index') value (.is (.I64 .Any) value')] @@ -288,7 +288,7 @@ <sample> (.is ..Binary sample') <jvm> (java/util/Arrays::equals <reference> <sample>) <jvm> (ffi.of_boolean <jvm>)] - (`` (def: .public = + (`` (def .public = (template (= reference' sample') [(.for (~~ (.static @.old)) <jvm> (~~ (.static @.jvm)) <jvm> @@ -305,7 +305,7 @@ (again ("lux i64 +" 1 index))))))))])))) ... TODO: Turn into a template ASAP. -(`` (inline: .public (copy! bytes source_offset source target_offset target) +(`` (inlined .public (copy! bytes source_offset source target_offset target) (-> .Nat .Nat ..Binary Nat ..Binary ..Binary) (with_expansions [<jvm> (java/lang/System::arraycopy source (ffi.as_int (.int source_offset)) target (ffi.as_int (.int target_offset)) @@ -332,7 +332,7 @@ (ffi.as_int (.int limit))) <jvm> (.let [limit ("lux i64 +" size offset)] <jvm>)] - (inline: .public (slice offset size binary) + (inlined .public (slice offset size binary) (-> .Nat .Nat ..Binary ..Binary) (.for (~~ (.static @.old)) <jvm> (~~ (.static @.jvm)) <jvm> diff --git a/stdlib/source/unsafe/lux/data/collection/array.lux b/stdlib/source/unsafe/lux/data/collection/array.lux index d3116b89b..ef81167d2 100644 --- a/stdlib/source/unsafe/lux/data/collection/array.lux +++ b/stdlib/source/unsafe/lux/data/collection/array.lux @@ -10,7 +10,7 @@ [type ["[0]" variance]]]]) -(def: .public type +(def .public type "#Array") (with_template [<item> <array>] @@ -23,7 +23,7 @@ (with_expansions [<index_type> (.Primitive "java.lang.Long") <item_type> (.Primitive "java.lang.Object")] - (for @.jvm (def: jvm_int + (for @.jvm (def jvm_int (template (jvm_int value) [(.|> value (.as <index_type>) @@ -31,7 +31,7 @@ "jvm conversion long-to-int")])) (these)) - (`` (def: .public empty + (`` (def .public empty (template (empty <size>) [((.is (.All (_ a) (.-> .Nat (..Array a))) (.function (empty size) @@ -52,7 +52,7 @@ (~~ (.static @.scheme)) ("scheme array new" size))))) <size>)]))) - (`` (def: .public size + (`` (def .public size (template (size <array>) [((.is (.All (_ r w) (.-> (..Array' r w) .Nat)) (.function (size array) @@ -75,11 +75,11 @@ (~~ (.static @.scheme)) ("scheme array length" array)))) <array>)]))) - (def: lacks?' + (def lacks?' (template (lacks?' <read!> <null?> index array) [(<null?> (<read!> index array))])) - (`` (def: .public lacks? + (`` (def .public lacks? (template (lacks? <index> <array>) [((.is (.All (_ r w) (.-> .Nat (..Array' r w) .Bit)) @@ -103,11 +103,11 @@ .true)))) <index> <array>)]))) - (def: .public has? + (def .public has? (template (has? index array) [(.not (..lacks? index array))])) - (`` (def: .public item + (`` (def .public item (template (item <index> <array>) [((.is (.All (_ r w) (.-> .Nat (..Array' r w) r)) @@ -127,7 +127,7 @@ (~~ (.static @.scheme)) ("scheme array read" index array))))) <index> <array>)]))) - (`` (def: .public has! + (`` (def .public has! (template (has! <index> <value> <array>) [((.is (.All (_ r w) (.-> .Nat w (..Array' r w) (..Array' r w))) @@ -148,7 +148,7 @@ (~~ (.static @.scheme)) ("scheme array write" index (.as_expected value) array)))) <index> <value> <array>)]))) - (`` (def: .public lacks! + (`` (def .public lacks! (template (lacks! <index> <array>) [((.is (.All (_ r w) (.-> .Nat (..Array' r w) (..Array' r w))) @@ -171,7 +171,7 @@ <index> <array>)]))) ) -(def: .public revised! +(def .public revised! (template (revised! <index> <$> <array>) [((.is (.All (_ r w) (.-> .Nat (.-> r w) (..Array' r w) (..Array' r w))) @@ -181,7 +181,7 @@ (..has! index ($ (..item index array)) array)))) <index> <$> <array>)])) -(def: .public upsert! +(def .public upsert! (template (upsert! <index> <default> <$> <array>) [((.is (.All (_ r w) (.-> .Nat r (.-> r w) (..Array' r w) (..Array' r w))) @@ -193,7 +193,7 @@ array))) <index> <default> <$> <array>)])) -(def: .public copy! +(def .public copy! (template (copy! <length> <src_start> <src_array> <dest_start> <dest_array>) [((.is (.All (_ r w) (.-> .Nat .Nat (..Array' w .Nothing) .Nat (..Array' r w) @@ -212,7 +212,7 @@ <length> <src_start> <src_array> <dest_start> <dest_array>)])) (with_template [<name> <when_lacks> <when_has>] - [(def: .public <name> + [(def .public <name> (template (<name> <array>) [((.is (.All (_ r w) (.-> (..Array' r w) .Nat)) (.function (occupancy array) @@ -230,7 +230,7 @@ [vacancy ("lux i64 +" 1 it) it] ) -(def: .public only! +(def .public only! (template (only! <?> <it>) [((.is (.All (_ r w) (.-> (.-> r .Bit) (..Array' r w) (..Array' r w))) @@ -249,7 +249,7 @@ <?> <it>)])) (with_template [<name> <predicate> <test> <type> <term>] - [(def: .public <name> + [(def .public <name> (template (<name> <?> <it>) [((.is (.All (_ r w) (.-> <predicate> (..Array' r w) (.Maybe <type>))) @@ -270,7 +270,7 @@ [example' (.-> Nat r .Bit) (? index it) [Nat r] [index it]] ) -(def: .public clone +(def .public clone (template (clone <it>) [((.is (.All (_ a) (.-> (..Array a) (..Array a))) (.function (clone it) @@ -278,7 +278,7 @@ (..copy! size 0 it 0 (..empty size))))) <it>)])) -(def: .public of_list +(def .public of_list (template (of_list <input>) [((.is (.All (_ a) (.-> (.List a) (..Array a))) (.function (of_list input) @@ -296,11 +296,11 @@ (again ("lux i64 +" 1 index) tail))))))) <input>)])) -(def: underflow +(def underflow Nat (-- 0)) -(`` (def: list|-default +(`` (def list|-default (template (list|-default <empty> <array>) [((.is (.All (_ r w) (.-> (.List r) (..Array' r w) (.List r))) (.function (list|-default empty array) @@ -314,7 +314,7 @@ {.#Item (..item index array) output})))))) <empty> <array>)]))) -(`` (def: list|+default +(`` (def list|+default (template (list|+default <default> <array>) [((.is (.All (_ r w) (.-> r (..Array' r w) (.List r))) (.function (list|+default default array) @@ -330,7 +330,7 @@ output}))))) <default> <array>)]))) -(`` (def: .public list +(`` (def .public list (template (list <default> <array>) [((.is (.All (_ r w) (.-> (.Maybe r) (..Array' r w) (.List r))) (.function (list default array) @@ -342,7 +342,7 @@ (~~ (..list|-default {.#End} array))))) <default> <array>)]))) -(def: .public = +(def .public = (template (= <//#=> <left/*> <right/*>) [((.is (.All (_ r w0 w1) (.-> (.-> r r .Bit) (..Array' r w0) (..Array' r w1) .Bit)) (.function (= //#= left/* right/*) @@ -360,7 +360,7 @@ true)))))) <//#=> <left/*> <right/*>)])) -(def: .public composite +(def .public composite (template (composite <left/*> <right/*>) [((.is (.All (_ a) (.-> (..Array' a .Nothing) (..Array' a .Nothing) (..Array a))) (.function (composite left/* right/*) @@ -371,7 +371,7 @@ (..copy! |right| 0 right/* |left|))))) <left/*> <right/*>)])) -(def: .public mix +(def .public mix (template (mix <$> <init> <it>) [((.is (.All (_ r w s) (.-> (.-> Nat r s s) s (..Array' r w) s)) @@ -386,7 +386,7 @@ so_far))))) <$> <init> <it>)])) -(def: .public each +(def .public each (template (each <$> <input>) [((.is (functor.Functor ..Array) (.function (each $ input) @@ -397,7 +397,7 @@ <$> <input>)])) (with_template [<name> <init> <op>] - [(def: .public <name> + [(def .public <name> (template (<name> <?> <it>) [((.is (.All (_ r w) (.-> (.-> r .Bit) @@ -417,7 +417,7 @@ [any? .false or] ) -(def: .public one +(def .public one (template (one <?> <it>) [((.is (.All (_ r r' w) (.-> (.-> r (.Maybe r')) (..Array' r w) (.Maybe r'))) |