diff options
Diffstat (limited to 'stdlib')
259 files changed, 2930 insertions, 1815 deletions
diff --git a/stdlib/source/documentation/lux.lux b/stdlib/source/documentation/lux.lux index 5131a9607..1f30de85c 100644 --- a/stdlib/source/documentation/lux.lux +++ b/stdlib/source/documentation/lux.lux @@ -9,7 +9,8 @@ [\\library ["." /]] ["." / #_ - ["#." abstract]]) + ["#." abstract] + ["#." control]]) (documentation: /.:of "Generates the type corresponding to a given expression." @@ -24,8 +25,10 @@ (.def: .public documentation (.List $.Module) ($.module /._ + "" [..:of] - [/abstract.documentation])) + [/abstract.documentation + /control.documentation])) (program: inputs (io.io (debug.log! ($.documentation ..documentation)))) diff --git a/stdlib/source/documentation/lux/abstract.lux b/stdlib/source/documentation/lux/abstract.lux index a4e7ec807..9cc80dcac 100644 --- a/stdlib/source/documentation/lux/abstract.lux +++ b/stdlib/source/documentation/lux/abstract.lux @@ -13,30 +13,29 @@ ["#." comonad] ["#." enum] ["#." equivalence] - ... ["#." hash] - ... ["#." fold] + ["#." fold] ["#." functor] - ... ["#." interval] + ["#." hash] + ["#." interval] ["#." monad] - ... ["#." monoid] - ... ["#." order] - ... ["#." predicate] - ]) + ["#." monoid] + ["#." order] + ["#." predicate]]) (.def: .public documentation (.List $.Module) - (list.joined (list - /apply.documentation - /codec.documentation - /comonad.documentation - /enum.documentation - /equivalence.documentation - ... /hash.documentation - ... /fold.documentation - ... /interval.documentation - ... /monoid.documentation - ... /order.documentation - ... /predicate.documentation - /functor.documentation - /monad.documentation - ))) + (list.joined + (list /apply.documentation + /codec.documentation + /comonad.documentation + /enum.documentation + /equivalence.documentation + /fold.documentation + /functor.documentation + /hash.documentation + /interval.documentation + /monad.documentation + /monoid.documentation + /order.documentation + /predicate.documentation + ))) diff --git a/stdlib/source/documentation/lux/abstract/apply.lux b/stdlib/source/documentation/lux/abstract/apply.lux index ba611918d..0ba31d5a4 100644 --- a/stdlib/source/documentation/lux/abstract/apply.lux +++ b/stdlib/source/documentation/lux/abstract/apply.lux @@ -8,12 +8,13 @@ (documentation: /.Apply "Applicative functors.") -(documentation: /.compose +(documentation: /.composite "Applicative functor composition.") (.def: .public documentation (.List $.Module) ($.module /._ + "" [..Apply - ..compose] + ..composite] [])) diff --git a/stdlib/source/documentation/lux/abstract/codec.lux b/stdlib/source/documentation/lux/abstract/codec.lux index dc83d6fce..d4f3dbeb0 100644 --- a/stdlib/source/documentation/lux/abstract/codec.lux +++ b/stdlib/source/documentation/lux/abstract/codec.lux @@ -8,17 +8,18 @@ (documentation: /.Codec "A way to move back-and-forth between a type and an alternative representation for it.") -(documentation: /.compose +(documentation: /.composite "Codec composition." [(: (Codec c a) - (compose (: (Codec c b) - cb_codec) - (: (Codec b a) - ba_codec)))]) + (composite (: (Codec c b) + cb_codec) + (: (Codec b a) + ba_codec)))]) (.def: .public documentation (.List $.Module) ($.module /._ + "" [..Codec - ..compose] + ..composite] [])) diff --git a/stdlib/source/documentation/lux/abstract/comonad.lux b/stdlib/source/documentation/lux/abstract/comonad.lux index 10f39e86d..f1e220593 100644 --- a/stdlib/source/documentation/lux/abstract/comonad.lux +++ b/stdlib/source/documentation/lux/abstract/comonad.lux @@ -24,6 +24,7 @@ (.def: .public documentation (.List $.Module) ($.module /._ + "" [..CoMonad ..be] [/cofree.documentation])) diff --git a/stdlib/source/documentation/lux/abstract/comonad/cofree.lux b/stdlib/source/documentation/lux/abstract/comonad/cofree.lux index 332cae864..2330b5c78 100644 --- a/stdlib/source/documentation/lux/abstract/comonad/cofree.lux +++ b/stdlib/source/documentation/lux/abstract/comonad/cofree.lux @@ -11,6 +11,7 @@ (.def: .public documentation (.List $.Module) ($.module /._ + "" [..CoFree ($.default /.functor) ($.default /.comonad)] diff --git a/stdlib/source/documentation/lux/abstract/enum.lux b/stdlib/source/documentation/lux/abstract/enum.lux index 2853ba8ca..779b97a77 100644 --- a/stdlib/source/documentation/lux/abstract/enum.lux +++ b/stdlib/source/documentation/lux/abstract/enum.lux @@ -15,6 +15,7 @@ (.def: .public documentation (.List $.Module) ($.module /._ + "" [..Enum ..range] [])) diff --git a/stdlib/source/documentation/lux/abstract/equivalence.lux b/stdlib/source/documentation/lux/abstract/equivalence.lux index 0be66e537..fb393d7c9 100644 --- a/stdlib/source/documentation/lux/abstract/equivalence.lux +++ b/stdlib/source/documentation/lux/abstract/equivalence.lux @@ -18,6 +18,7 @@ (.def: .public documentation (.List $.Module) ($.module /._ + "" [..Equivalence ..rec ($.default /.functor)] diff --git a/stdlib/source/documentation/lux/abstract/fold.lux b/stdlib/source/documentation/lux/abstract/fold.lux new file mode 100644 index 000000000..33a12a91c --- /dev/null +++ b/stdlib/source/documentation/lux/abstract/fold.lux @@ -0,0 +1,24 @@ +(.module: + [library + [lux + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]]]] + [\\library + ["." /]]) + +(documentation: /.Fold + "Iterate over a structure's values to build a summary value.") + +(documentation: /.with_monoid + "Fold over a foldable structure using the monoid's identity as the initial value." + [(with_monoid monoid fold value)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Fold + ..with_monoid] + [])) diff --git a/stdlib/source/documentation/lux/abstract/functor.lux b/stdlib/source/documentation/lux/abstract/functor.lux index 1ca3b082a..3de919eb5 100644 --- a/stdlib/source/documentation/lux/abstract/functor.lux +++ b/stdlib/source/documentation/lux/abstract/functor.lux @@ -16,12 +16,13 @@ (documentation: /.product "Product composition for functors.") -(documentation: /.compose +(documentation: /.composite "Functor composition.") (.def: .public documentation (.List $.Module) ($.module /._ + "" [($.default /.Functor) ($.default /.Fix) ($.default /.Or) @@ -29,5 +30,5 @@ ($.default /.Then) ..sum ..product - ..compose] + ..composite] [/contravariant.documentation])) diff --git a/stdlib/source/documentation/lux/abstract/functor/contravariant.lux b/stdlib/source/documentation/lux/abstract/functor/contravariant.lux index 15f2332ed..7720babde 100644 --- a/stdlib/source/documentation/lux/abstract/functor/contravariant.lux +++ b/stdlib/source/documentation/lux/abstract/functor/contravariant.lux @@ -11,5 +11,6 @@ (.def: .public documentation (.List $.Module) ($.module /._ + "" [..Functor] [])) diff --git a/stdlib/source/documentation/lux/abstract/hash.lux b/stdlib/source/documentation/lux/abstract/hash.lux new file mode 100644 index 000000000..88fdd0a6e --- /dev/null +++ b/stdlib/source/documentation/lux/abstract/hash.lux @@ -0,0 +1,20 @@ +(.module: + [library + [lux + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]]]] + [\\library + ["." /]]) + +(documentation: /.Hash + "A way to produce hash-codes for a type's instances.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Hash + ($.default /.functor)] + [])) diff --git a/stdlib/source/documentation/lux/abstract/interval.lux b/stdlib/source/documentation/lux/abstract/interval.lux new file mode 100644 index 000000000..f4c57de2a --- /dev/null +++ b/stdlib/source/documentation/lux/abstract/interval.lux @@ -0,0 +1,57 @@ +(.module: + [library + [lux + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]]]] + [\\library + ["." /]]) + +(documentation: /.Interval + "A representation of top and bottom boundaries for an ordered type.") + +(documentation: /.borders? + "Where a value is at the border of an interval.") + +(documentation: /.union + "An interval that spans both predecessors.") + +(documentation: /.intersection + "An interval spanned by both predecessors.") + +(documentation: /.complement + "The inverse of an interval.") + +(documentation: /.meets? + "Whether an interval meets another one on its bottom/lower side.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Interval + ..borders? + ..union + ..intersection + ..complement + ..meets? + ($.default /.between) + ($.default /.singleton) + ($.default /.inner?) + ($.default /.outer?) + ($.default /.singleton?) + ($.default /.within?) + ($.default /.starts_with?) + ($.default /.ends_with?) + ($.default /.precedes?) + ($.default /.succeeds?) + ($.default /.before?) + ($.default /.after?) + ($.default /.touches?) + ($.default /.starts?) + ($.default /.finishes?) + ($.default /.equivalence) + ($.default /.nested?) + ($.default /.overlaps?)] + [])) diff --git a/stdlib/source/documentation/lux/abstract/monad.lux b/stdlib/source/documentation/lux/abstract/monad.lux index 7293f9a1d..dd472057d 100644 --- a/stdlib/source/documentation/lux/abstract/monad.lux +++ b/stdlib/source/documentation/lux/abstract/monad.lux @@ -44,6 +44,7 @@ (.def: .public documentation (.List $.Module) ($.module /._ + "" [..Monad ..do ..bind diff --git a/stdlib/source/documentation/lux/abstract/monad/free.lux b/stdlib/source/documentation/lux/abstract/monad/free.lux index c29516a1c..24f9ac79f 100644 --- a/stdlib/source/documentation/lux/abstract/monad/free.lux +++ b/stdlib/source/documentation/lux/abstract/monad/free.lux @@ -11,6 +11,7 @@ (.def: .public documentation (.List $.Module) ($.module /._ + "" [..Free ($.default /.functor) ($.default /.apply) diff --git a/stdlib/source/documentation/lux/abstract/monoid.lux b/stdlib/source/documentation/lux/abstract/monoid.lux new file mode 100644 index 000000000..e9c7a590e --- /dev/null +++ b/stdlib/source/documentation/lux/abstract/monoid.lux @@ -0,0 +1,21 @@ +(.module: + [library + [lux + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]]]] + [\\library + ["." /]]) + +(documentation: /.Monoid + (format "A way to compose values." + \n "Includes an identity value which does not alter any other value when combined with.")) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Monoid + ($.default /.composite)] + [])) diff --git a/stdlib/source/documentation/lux/abstract/order.lux b/stdlib/source/documentation/lux/abstract/order.lux new file mode 100644 index 000000000..ef7826d0f --- /dev/null +++ b/stdlib/source/documentation/lux/abstract/order.lux @@ -0,0 +1,48 @@ +(.module: + [library + [lux + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]]]] + [\\library + ["." /]]) + +(documentation: /.Order + "A signature for types that possess some sense of ordering among their elements.") + +(documentation: /.Comparison + "An arbitrary comparison between two values, with the knowledge of how to order them.") + +(documentation: /.<= + "Less than or equal.") + +(documentation: /.> + "Greater than.") + +(documentation: /.>= + "Greater than or equal.") + +(documentation: /.Choice + "A choice comparison between two values, with the knowledge of how to order them.") + +(documentation: /.min + "Minimum.") + +(documentation: /.max + "Maximum.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Order + ..Comparison + ..<= + ..> + ..>= + ..Choice + ..min + ..max + ($.default /.functor)] + [])) diff --git a/stdlib/source/documentation/lux/abstract/predicate.lux b/stdlib/source/documentation/lux/abstract/predicate.lux new file mode 100644 index 000000000..a71326b98 --- /dev/null +++ b/stdlib/source/documentation/lux/abstract/predicate.lux @@ -0,0 +1,50 @@ +(.module: + [library + [lux + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]]]] + [\\library + ["." /]]) + +(documentation: /.Predicate + "A question that can be asked of a value, yield either false (#0) or true (#1).") + +(documentation: /.none + "A predicate that always fails.") + +(documentation: /.or + "A predicate that meets either predecessor.") + +(documentation: /.all + "A predicate that always succeeds.") + +(documentation: /.and + "A predicate that meets both predecessors.") + +(documentation: /.complement + "The opposite of a predicate.") + +(documentation: /.difference + "A predicate that meeds 'base', but not 'sub'.") + +(documentation: /.rec + "Ties the knot for a recursive predicate.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Predicate + ..none + ..or + ..all + ..and + ..complement + ..difference + ..rec + ($.default /.union) + ($.default /.intersection) + ($.default /.functor)] + [])) diff --git a/stdlib/source/documentation/lux/control.lux b/stdlib/source/documentation/lux/control.lux new file mode 100644 index 000000000..4fcbe7a98 --- /dev/null +++ b/stdlib/source/documentation/lux/control.lux @@ -0,0 +1,61 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]] + [collection + ["." list]]]]] + ["." / #_ + ["#." concatenative] + ["#." concurrency] + ["#." continuation] + ["#." exception] + ["#." function] + ["#." io] + ["#." lazy] + ["#." maybe] + ... ["#." parser] + ... ["#." pipe] + ... ["#." reader] + ... ["#." region] + ... ["#." remember] + ... [security + ... ["#." policy] + ... ["#." capability]] + ... ["#." state] + ... ["#." thread] + ... ["#." try] + ... ["#." writer] + ]) + +... (def: security +... Test +... ($_ _.and +... /policy.documentation +... /capability.documentation +... )) + +(.def: .public documentation + (.List $.Module) + (list.joined + (list /concatenative.documentation + /concurrency.documentation + /continuation.documentation + /exception.documentation + /function.documentation + /io.documentation + /lazy.documentation + /maybe.documentation + ... /parser.documentation + ... /pipe.documentation + ... /reader.documentation + ... /region.documentation + ... /remember.documentation + ... ..security + ... /state.documentation + ... /thread.documentation + ... /try.documentation + ... /writer.documentation + ))) diff --git a/stdlib/source/documentation/lux/control/concatenative.lux b/stdlib/source/documentation/lux/control/concatenative.lux new file mode 100644 index 000000000..495bc5512 --- /dev/null +++ b/stdlib/source/documentation/lux/control/concatenative.lux @@ -0,0 +1,288 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]] + [collection + ["." list ("#\." monad)]]] + [macro + ["." template]] + [math + [number + ["n" nat] + ["i" int] + ["r" rev] + ["f" frac]]]]] + [\\library + ["." /]]) + +(documentation: /.=> + "Concatenative function types." + [(=> [Nat] [Nat])] + [(All [a] + (-> a (=> [] [a])))] + [(All [t] + (=> [t] []))] + [(All [a b c] + (=> [a b c] [b c a]))] + [(All [___a ___z] + (=> {then (=> ___a ___z) + else (=> ___a ___z)} + ___a [Bit then else] ___z))]) + +(documentation: /.||> + "A self-contained sequence of concatenative instructions." + [(same? value + (||> (push sample)))] + [(||> (push 123) + dup + n/=)]) + +(documentation: /.word: + "A named concatenative function." + [(word: square + (=> [Nat] [Nat]) + + dup + (apply/2 n.*))]) + +(documentation: /.apply + "A generator for functions that turn arity N functions into arity N concatenative functions." + [(: (=> [Nat] [Nat]) + ((apply 1) inc))]) + +(template [<arity>] + [(with_expansions [<name> (template.identifier [/._] ["apply/" <arity>]) + <doc> (template.text ["Lift a function of arity " <arity> + " into a concatenative function of arity " <arity> "."]) + <function_of_arity> (template.identifier ["function_of_arity_" <arity>])] + (documentation: <name> + <doc> + [(<arity> <function_of_arity>)]))] + + [1] [2] [3] [4] + [5] [6] [7] [8] + ) + +(documentation: /.push + "Push a value onto the stack.") + +(documentation: /.drop + "Drop/pop a value from the top of the stack.") + +(documentation: /.nip + "Drop the second-to-last value from the top of the stack.") + +(documentation: /.dup + "Duplicate the top of the stack.") + +(documentation: /.swap + "Swaps the 2 topmost stack values.") + +(documentation: /.rotL + "Rotes the 3 topmost stack values to the left.") + +(documentation: /.rotR + "Rotes the 3 topmost stack values to the right.") + +(documentation: /.&& + "Groups the 2 topmost stack values as a 2-tuple.") + +(documentation: /.||L + "Left-injects the top into sum.") + +(documentation: /.||R + "Right-injects the top into sum.") + +(template [<input> <word> <func>] + [(`` (documentation: (~~ (template.identifier [/._] [<word>])) + (~~ (template.text [<func> " for " <input> " arithmetic."]))))] + + [Nat n/+ n.+] + [Nat n/- n.-] + [Nat n/* n.*] + [Nat n// n./] + [Nat n/% n.%] + [Nat n/= n.=] + [Nat n/< n.<] + [Nat n/<= n.<=] + [Nat n/> n.>] + [Nat n/>= n.>=] + + [Int i/+ i.+] + [Int i/- i.-] + [Int i/* i.*] + [Int i// i./] + [Int i/% i.%] + [Int i/= i.=] + [Int i/< i.<] + [Int i/<= i.<=] + [Int i/> i.>] + [Int i/>= i.>=] + + [Rev r/+ r.+] + [Rev r/- r.-] + [Rev r/* r.*] + [Rev r// r./] + [Rev r/% r.%] + [Rev r/= r.=] + [Rev r/< r.<] + [Rev r/<= r.<=] + [Rev r/> r.>] + [Rev r/>= r.>=] + + [Frac f/+ f.+] + [Frac f/- f.-] + [Frac f/* f.*] + [Frac f// f./] + [Frac f/% f.%] + [Frac f/= f.=] + [Frac f/< f.<] + [Frac f/<= f.<=] + [Frac f/> f.>] + [Frac f/>= f.>=] + ) + +(documentation: /.if + "If expression." + [(same? "then" + (||> (push true) + (push "then") + (push "else") + if))]) + +(documentation: /.call + "Executes an anonymous block on the stack.") + +(documentation: /.loop + "Executes a block as a loop until it yields #0 to stop.") + +(documentation: /.dip + "Executes a block on the stack, save for the topmost value.") + +(documentation: /.dip/2 + "Executes a block on the stack, save for the 2 topmost values.") + +(documentation: /.do + "Do-while loop expression." + [(n.= (inc sample) + (||> (push sample) + (push (push false)) + (push (|>> (push 1) n/+)) + do while))]) + +(documentation: /.while + "While loop expression." + [(n.= (n.+ distance start) + (||> (push start) + (push (|>> dup + (push start) n/- + (push distance) n/<)) + (push (|>> (push 1) n/+)) + while))]) + +(documentation: /.compose + "Function composition." + [(n.= (n.+ 2 sample) + (||> (push sample) + (push (|>> (push 1) n/+)) + (push (|>> (push 1) n/+)) + compose + call))]) + +(documentation: /.partial + "Partial application." + [(n.= (n.+ sample sample) + (||> (push sample) + (push sample) + (push n/+) + partial + call))]) + +(documentation: /.when + "Only execute the block when #1.") + +(documentation: /.? + "Choose the top value when #0 and the second-to-top when #1.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..=> + ..||> + ..word: + ..apply + ..apply/1 + ..apply/2 + ..apply/3 + ..apply/4 + ..apply/5 + ..apply/6 + ..apply/7 + ..apply/8 + ..push + ..drop + ..nip + ..dup + ..swap + ..rotL + ..rotR + ..&& + ..||L + ..||R + ..if + ..call + ..loop + ..dip + ..dip/2 + ..do + ..while + ..compose + ..partial + ..when + ..? + + ..n/+ + ..n/- + ..n/* + ..n// + ..n/% + ..n/= + ..n/< + ..n/<= + ..n/> + ..n/>= + ..i/+ + ..i/- + ..i/* + ..i// + ..i/% + ..i/= + ..i/< + ..i/<= + ..i/> + ..i/>= + ..r/+ + ..r/- + ..r/* + ..r// + ..r/% + ..r/= + ..r/< + ..r/<= + ..r/> + ..r/>= + ..f/+ + ..f/- + ..f/* + ..f// + ..f/% + ..f/= + ..f/< + ..f/<= + ..f/> + ..f/>=] + [])) diff --git a/stdlib/source/documentation/lux/control/concurrency.lux b/stdlib/source/documentation/lux/control/concurrency.lux new file mode 100644 index 000000000..f9b751494 --- /dev/null +++ b/stdlib/source/documentation/lux/control/concurrency.lux @@ -0,0 +1,28 @@ +(.module: + [library + [lux #* + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]] + [collection + ["." list]]]]] + ["." / #_ + ["#." actor] + ["#." async] + ["#." atom] + ["#." frp] + ["#." semaphore] + ["#." stm] + ["#." thread]]) + +(.def: .public documentation + (.List $.Module) + (list.joined + (list /actor.documentation + /async.documentation + /atom.documentation + /frp.documentation + /semaphore.documentation + /stm.documentation + /thread.documentation))) diff --git a/stdlib/source/documentation/lux/control/concurrency/actor.lux b/stdlib/source/documentation/lux/control/concurrency/actor.lux new file mode 100644 index 000000000..29513888c --- /dev/null +++ b/stdlib/source/documentation/lux/control/concurrency/actor.lux @@ -0,0 +1,131 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]] + [collection + ["." list ("#\." monad)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Actor + "An entity that can react to messages (mail) sent to it concurrently.") + +(documentation: /.Mail + "A one-way message sent to an actor, without expecting a reply.") + +(documentation: /.Obituary + "Details on the death of an actor.") + +(documentation: /.Behavior + "An actor's behavior when mail is received and when a fatal error occurs.") + +(documentation: /.spawn! + "Given a behavior and initial state, spawns an actor and returns it.") + +(documentation: /.obituary + "Await for an actor to stop working.") + +(documentation: /.mail! + "Send mail to an actor.") + +(documentation: /.Message + "A two-way message sent to an actor, expecting a reply.") + +(documentation: /.tell! + "Communicate with an actor through message-passing.") + +(documentation: /.default + "Default actor behavior.") + +(documentation: /.poison! + (format "Kills the actor by sending mail that will kill it upon processing," + \n "but allows the actor to handle previous mail.")) + +(with_expansions [<examples> (as_is (actor: .public (stack a) + {} + + (List a) + + ((on_mail mail state self) + (do (try.with async.monad) + [.let [_ (debug.log! "BEFORE")] + output (mail state self) + .let [_ (debug.log! "AFTER")]] + (in output))) + + (message: .public (push {value a} state self) + (List a) + (let [state' (#.Item value state)] + (async.resolved (#try.Success [state' state']))))) + + (actor: .public counter + {} + + Nat + + (message: .public (count! {increment Nat} state self) + Any + (let [state' (n.+ increment state)] + (async.resolved (#try.Success [state' state'])))) + + (message: .public (read! state self) + Nat + (async.resolved (#try.Success [state state])))))] + (documentation: /.actor: + (format "Defines a named actor, with its behavior and internal state." + \n "Messages for the actor must be defined after the on_mail handler.") + [<examples>]) + + (documentation: /.actor + (format "Defines an anonymous actor, with its behavior and internal state." + \n "Messages for the actor must be defined after the on_mail handler.") + [(actor {Nat + 123} + ((on_mail message state self) + (message (inc state) self)))]) + + (documentation: /.message: + (format "A message can access the actor's state through the state parameter." + \n "A message can also access the actor itself through the self parameter." + \n "A message's output must be an async containing a 2-tuple with the updated state and a return value." + \n "A message may succeed or fail (in case of failure, the actor dies).") + [<examples>])) + +(documentation: /.Stop + "A signal to stop an actor from observing a channel.") + +(documentation: /.observe! + (format "Use an actor to observe a channel by transforming each datum" + \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 + (.List $.Module) + ($.module /._ + "The actor model of concurrency." + [..Actor + ..Mail + ..Obituary + ..Behavior + ..spawn! + ..obituary + ..mail! + ..Message + ..tell! + ..default + ..poison! + ..actor: + ..actor + ..message: + ..Stop + ..observe! + ($.default /.poisoned) + ($.default /.dead) + ($.default /.alive?) + ($.default /.obituary')] + [])) diff --git a/stdlib/source/documentation/lux/control/concurrency/async.lux b/stdlib/source/documentation/lux/control/concurrency/async.lux new file mode 100644 index 000000000..2842ed06b --- /dev/null +++ b/stdlib/source/documentation/lux/control/concurrency/async.lux @@ -0,0 +1,96 @@ +(.module: + [library + [lux (#- or and) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Async + "Represents values produced by asynchronous computations (unlike IO, which is synchronous).") + +(documentation: /.Resolver + (format "The function used to give a value to an async." + \n "Will signal 'true' if the async has been resolved for the 1st time, 'false' otherwise.")) + +(documentation: /.resolved + "Produces an async that has already been resolved to the given value." + [(resolved value)]) + +(documentation: /.async + "Creates a fresh async that has not been resolved yet." + [(async _)]) + +(documentation: /.value + "Polls an async for its value.") + +(documentation: /.upon! + "Executes the given function as soon as the async has been resolved." + [(upon! function async)]) + +(documentation: /.resolved? + "Checks whether an async's value has already been resolved.") + +(documentation: /.and + "Combines the results of both asyncs, in-order." + [(and left right)]) + +(documentation: /.or + (format "Yields the results of whichever async gets resolved first." + \n "You can tell which one was resolved first through pattern-matching.") + [(or left right)]) + +(documentation: /.either + (format "Yields the results of whichever async gets resolved first." + \n "You cannot tell which one was resolved first.") + [(either left right)]) + +(documentation: /.schedule! + (format "Runs an I/O computation on its own thread (after a specified delay)." + \n "Returns an async that will eventually host its result.") + [(schedule! milli_seconds computation)]) + +(documentation: /.future + (format "Runs an I/O computation on its own thread." + \n "Returns an async that will eventually host its result.") + [(future computation)]) + +(documentation: /.delayed + "Delivers a value after a certain period has passed." + [(delayed milli_seconds value)]) + +(documentation: /.delay + "An async that will be resolved after the specified amount of milli-seconds." + [(delay milli_seconds)]) + +(documentation: /.time_out + "Wait for an async to be resolved within the specified amount of milli-seconds." + [(time_out milli_seconds async)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Async + ..Resolver + ..resolved + ..async + ..value + ..upon! + ..resolved? + ..and + ..or + ..either + ..schedule! + ..future + ..delayed + ..delay + ..time_out + ($.default /.functor) + ($.default /.apply) + ($.default /.monad)] + [])) diff --git a/stdlib/source/documentation/lux/control/concurrency/atom.lux b/stdlib/source/documentation/lux/control/concurrency/atom.lux new file mode 100644 index 000000000..8b35c1c7e --- /dev/null +++ b/stdlib/source/documentation/lux/control/concurrency/atom.lux @@ -0,0 +1,39 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Atom + "Atomic references that are safe to mutate concurrently.") + +(documentation: /.compare_and_swap! + (format "Only mutates an atom if you can present its current value." + \n "That guarantees that atom was not updated since you last read from it.")) + +(documentation: /.update! + (format "Updates an atom by applying a function to its current value." + \n "If it fails to update it (because some other process wrote to it first), it will retry until it succeeds." + \n "The retries will be done with the new values of the atom, as they show up.")) + +(documentation: /.write! + (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 + (.List $.Module) + ($.module /._ + "" + [..Atom + ..compare_and_swap! + ..update! + ..write! + ($.default /.atom) + ($.default /.read!)] + [])) diff --git a/stdlib/source/documentation/lux/control/concurrency/frp.lux b/stdlib/source/documentation/lux/control/concurrency/frp.lux new file mode 100644 index 000000000..71f740782 --- /dev/null +++ b/stdlib/source/documentation/lux/control/concurrency/frp.lux @@ -0,0 +1,66 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Channel + "An asynchronous channel to distribute values.") + +(documentation: /.Sink + "The tail-end of a channel, which can be written-to to fee the channel.") + +(documentation: /.channel + "Creates a brand-new channel and hands it over, along with the sink to write to it." + [(channel _)]) + +(documentation: /.Subscriber + "A function that can receive every value fed into a channel.") + +(documentation: /.only + (format "Produces a new channel based on the old one, only with values" + \n "that pass the test.") + [(only pass? channel)]) + +(documentation: /.of_async + "A one-element channel containing the output from an async." + [(of_async async)]) + +(documentation: /.fold + "Asynchronous fold over channels." + [(fold f init channel)]) + +(documentation: /.sequential + "Transforms the given list into a channel with the same elements." + [(sequential milli_seconds values)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Channel + ..Sink + ..channel + ..Subscriber + ..only + ..of_async + ..fold + ..sequential + ($.default /.channel_is_already_closed) + ($.default /.functor) + ($.default /.apply) + ($.default /.monad) + ($.default /.subscribe!) + ($.default /.folds) + ($.default /.poll) + ($.default /.periodic) + ($.default /.iterations) + ($.default /.distinct) + ($.default /.list)] + [])) diff --git a/stdlib/source/documentation/lux/control/concurrency/semaphore.lux b/stdlib/source/documentation/lux/control/concurrency/semaphore.lux new file mode 100644 index 000000000..4530b5455 --- /dev/null +++ b/stdlib/source/documentation/lux/control/concurrency/semaphore.lux @@ -0,0 +1,69 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Semaphore + "A tool for controlling access to resources by multiple concurrent processes.") + +(documentation: /.semaphore + "" + [(semaphore initial_open_positions)]) + +(documentation: /.wait! + (format "Wait on a semaphore until there are open positions." + \n "After finishing your work, you must 'signal' to the semaphore that you're done.") + [(wait! semaphore)]) + +(documentation: /.signal! + "Signal to a semaphore that you're done with your work, and that there is a new open position." + [(signal! semaphore)]) + +(documentation: /.Mutex + "A mutual-exclusion lock that can only be acquired by one process at a time.") + +(documentation: /.mutex + "Creates a brand-new mutex." + [(mutex _)]) + +(documentation: /.synchronize! + "Runs the procedure with exclusive control of the mutex." + [(synchronize! mutex procedure)]) + +(documentation: /.limit + "Produce a limit for a barrier.") + +(documentation: /.Limit + "A limit for barriers.") + +(documentation: /.Barrier + "A barrier that blocks all processes from proceeding until a given number of processes are parked at the barrier.") + +(documentation: /.block! + "Wait on a barrier until all processes have arrived and met the barrier's limit.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Semaphore + ..semaphore + ..wait! + ..signal! + ..Mutex + ..mutex + ..synchronize! + ..limit + ..Limit + ..Barrier + ..block! + ($.default /.semaphore_is_maxed_out) + ($.default /.barrier)] + [])) diff --git a/stdlib/source/documentation/lux/control/concurrency/stm.lux b/stdlib/source/documentation/lux/control/concurrency/stm.lux new file mode 100644 index 000000000..ebb46e87a --- /dev/null +++ b/stdlib/source/documentation/lux/control/concurrency/stm.lux @@ -0,0 +1,52 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Var + "A mutable cell containing a value, and observers that will be alerted of any change to it.") + +(documentation: /.var + "Creates a new STM var, with a default value." + [(var value)]) + +(documentation: /.follow! + "Creates a channel that will receive all changes to the value of the given var." + [(follow! target)]) + +(documentation: /.STM + "A computation which updates a transaction and produces a value.") + +(documentation: /.update + "Update a var's value, and return a tuple with the old and the new values." + [(update function var)]) + +(documentation: /.commit! + (format "Commits a transaction and returns its result (asynchronously)." + \n "Note that a transaction may be re-run an indeterminate number of times if other transactions involving the same variables successfully commit first." + \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 + (.List $.Module) + ($.module /._ + "" + [..Var + ..var + ..follow! + ..STM + ..update + ..commit! + ($.default /.read) + ($.default /.write) + ($.default /.functor) + ($.default /.apply) + ($.default /.monad)] + [])) diff --git a/stdlib/source/documentation/lux/control/concurrency/thread.lux b/stdlib/source/documentation/lux/control/concurrency/thread.lux new file mode 100644 index 000000000..6de9b7fb7 --- /dev/null +++ b/stdlib/source/documentation/lux/control/concurrency/thread.lux @@ -0,0 +1,26 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.parallelism + "How many processes can run in parallel.") + +(documentation: /.schedule! + "Executes an I/O procedure after some milli-seconds." + [(schedule! milli_seconds action)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..parallelism + ..schedule!] + [])) diff --git a/stdlib/source/documentation/lux/control/continuation.lux b/stdlib/source/documentation/lux/control/continuation.lux new file mode 100644 index 000000000..ebb778373 --- /dev/null +++ b/stdlib/source/documentation/lux/control/continuation.lux @@ -0,0 +1,53 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Cont + "Continuations.") + +(documentation: /.continued + "Continues a continuation thunk." + [(continued next cont)]) + +(documentation: /.result + "Forces a continuation thunk to be evaluated." + [(result cont)]) + +(documentation: /.with_current + "Call with current continuation." + [(with_current + (function (_ go) + (do /.monad + [.let [nexus (function (nexus val) + (go [nexus val]))] + _ (go [nexus init])] + (in (undefined)))))]) + +(documentation: /.pending + "Turns any expression into a function that is pending a continuation." + [(pending (some_function some_input))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Cont + ..continued + ..result + ..with_current + ..pending + ($.default /.reset) + ($.default /.shift) + ($.default /.functor) + ($.default /.apply) + ($.default /.monad) + ($.default /.portal)] + [])) diff --git a/stdlib/source/documentation/lux/control/exception.lux b/stdlib/source/documentation/lux/control/exception.lux new file mode 100644 index 000000000..ec225630a --- /dev/null +++ b/stdlib/source/documentation/lux/control/exception.lux @@ -0,0 +1,78 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Exception + "An exception provides a way to decorate error messages.") + +(documentation: /.match? + "Is this exception the cause of the error message?" + [(match? exception error)]) + +(documentation: /.when + (format "If a particular exception is detected on a possibly-erroneous value, handle it." + \n "If no exception was detected, or a different one from the one being checked, then pass along the original value.") + [(when exception then try)]) + +(documentation: /.otherwise + "If no handler could be found to catch the exception, then run a function as a last-resort measure." + [(otherwise else try)]) + +(documentation: /.error + "Constructs an error message from an exception." + [(error exception message)]) + +(documentation: /.except + "Decorate an error message with an Exception and lift it into the error-handling context." + [(except exception message)]) + +(documentation: /.exception: + (format "Define a new exception type." + \n "It mostly just serves as a way to tag error messages for later catching.") + ["Simple case:" + (exception: .public some_exception)] + ["Complex case:" + (exception: .public [arbitrary type variables] (some_exception {optional Text} {arguments Int}) + optional_body)]) + +(documentation: /.report + "An error report." + [(: Text + (report ["Row 0" value/0] + ["Row 1" value/1] + ,,, + ["Row N" value/N]))]) + +(documentation: /.listing + (format "A numbered report of the entries on a list." + \n "NOTE: 0-based numbering.") + [(listing format entries)]) + +(documentation: /.with + "If a computation fails, prepends the exception to the error." + [(with exception message computation)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Exception + ..match? + ..when + ..otherwise + ..error + ..except + ..exception: + ..report + ..listing + ..with + ($.default /.assertion)] + [])) diff --git a/stdlib/source/documentation/lux/control/function.lux b/stdlib/source/documentation/lux/control/function.lux new file mode 100644 index 000000000..889cc8655 --- /dev/null +++ b/stdlib/source/documentation/lux/control/function.lux @@ -0,0 +1,48 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.identity + (format "Identity function." + \n "Does nothing to its argument and just returns it.") + [(same? (identity value) + value)]) + +(documentation: /.composite + "Function composition." + [(= ((composite f g) "foo") + (f (g "foo")))]) + +(documentation: /.constant + "Create constant functions." + [(= ((constant "foo") "bar") + "foo")]) + +(documentation: /.flipped + "Flips the order of the arguments of a function." + [(= ((flipped f) "foo" "bar") + (f "bar" "foo"))]) + +(documentation: /.apply + "Simple 1-argument function application." + [(apply input function)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..identity + ..composite + ..constant + ..flipped + ..apply + ($.default /.monoid)] + [])) diff --git a/stdlib/source/documentation/lux/control/io.lux b/stdlib/source/documentation/lux/control/io.lux new file mode 100644 index 000000000..81cf08740 --- /dev/null +++ b/stdlib/source/documentation/lux/control/io.lux @@ -0,0 +1,36 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.IO + "A type that represents synchronous, effectful computations that may interact with the outside world.") + +(documentation: /.io + (format "Delays the evaluation of an expression, by wrapping it in an IO 'thunk'." + \n "Great for wrapping effectful computations (which will not be performed until the IO is 'run!').") + [(io (exec + (log! msg) + "Some value..."))]) + +(documentation: /.run! + "A way to execute IO computations and perform their side-effects.") + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..IO + ..io + ..run! + ($.default /.functor) + ($.default /.apply) + ($.default /.monad)] + [])) diff --git a/stdlib/source/documentation/lux/control/lazy.lux b/stdlib/source/documentation/lux/control/lazy.lux new file mode 100644 index 000000000..7a5b3217d --- /dev/null +++ b/stdlib/source/documentation/lux/control/lazy.lux @@ -0,0 +1,32 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.Lazy + (format "A value specified by an expression that is calculated only at the last moment possible." + \n "Afterwards, the value is cached for future reference.")) + +(documentation: /.lazy + "Specifies a lazy value by providing the expression that computes it." + [(lazy eager_computation)]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..Lazy + ..lazy + ($.default /.value) + ($.default /.equivalence) + ($.default /.functor) + ($.default /.apply) + ($.default /.monad)] + [])) diff --git a/stdlib/source/documentation/lux/control/maybe.lux b/stdlib/source/documentation/lux/control/maybe.lux new file mode 100644 index 000000000..dabdcde5e --- /dev/null +++ b/stdlib/source/documentation/lux/control/maybe.lux @@ -0,0 +1,57 @@ +(.module: + [library + [lux (#- if loop) + ["$" documentation (#+ documentation:)] + [data + [text (#+ \n) + ["%" format (#+ format)]]] + [macro + ["." template]]]] + [\\library + ["." /]]) + +(documentation: /.lifted + "Wraps a monadic value with Maybe machinery." + [(lifted monad)]) + +(documentation: /.else + (format "Allows you to provide a default value that will be used" + \n "if a (Maybe x) value turns out to be #.None." + \n "Note: the expression for the default value will not be computed if the base computation succeeds.") + [(else +20 (#.Some +10)) + "=>" + +10] + [(else +20 #.None) + "=>" + +20]) + +(documentation: /.trusted + (format "Assumes that a Maybe value is a #.Some and yields its value." + \n "Raises/throws a runtime error otherwise." + \n "WARNING: Use with caution.") + [(trusted trusted_computation)]) + +(documentation: /.when + "Can be used as a guard in (co)monadic be/do expressions." + [(do monad + [value (do_something 1 2 3) + /.when (passes_test? value)] + (do_something_else 4 5 6))]) + +(.def: .public documentation + (.List $.Module) + ($.module /._ + "" + [..lifted + ..else + ..trusted + ..when + ($.default /.monoid) + ($.default /.functor) + ($.default /.apply) + ($.default /.monad) + ($.default /.equivalence) + ($.default /.hash) + ($.default /.with) + ($.default /.list)] + [])) diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index f534a51d9..f9be2bf36 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -1981,7 +1981,7 @@ (failure "Wrong syntax for <|")} (list\reverse tokens))) -(def:''' .private (compose f g) +(def:''' .private (function\composite f g) (list [(tag$ ["library/lux" "doc"]) (text$ "Function composition.")]) (All [a b c] @@ -2097,7 +2097,7 @@ #1 ("lux i64 =" reference sample))) -(def:''' .private (list\join xs) +(def:''' .private (list\joined xs) #End (All [a] (-> ($' List ($' List a)) ($' List a))) @@ -2119,8 +2119,8 @@ (if (every? (function' [size] ("lux i64 =" num_bindings size)) (list\map list\size data')) (|> data' - (list\map (compose apply (replacement_environment bindings'))) - list\join + (list\map (function\composite apply (replacement_environment bindings'))) + list\joined in_meta) (failure "Irregular arguments tuples for template."))) @@ -2355,7 +2355,7 @@ (do meta_monad [top_level_expansion (("lux type as" Macro' macro) args) recursive_expansion (monad\map meta_monad expansion top_level_expansion)] - (in (list\join recursive_expansion))) + (in (list\joined recursive_expansion))) #None (in_meta (list token))} @@ -2376,23 +2376,23 @@ (do meta_monad [expansion (("lux type as" Macro' macro) args) expansion' (monad\map meta_monad full_expansion expansion)] - (in (list\join expansion'))) + (in (list\joined expansion'))) #None (do meta_monad [args' (monad\map meta_monad full_expansion args)] - (in (list (form$ (#Item (identifier$ name) (list\join args'))))))} + (in (list (form$ (#Item (identifier$ name) (list\joined args'))))))} ?macro)) [_ (#Form members)] (do meta_monad [members' (monad\map meta_monad full_expansion members)] - (in (list (form$ (list\join members'))))) + (in (list (form$ (list\joined members'))))) [_ (#Tuple members)] (do meta_monad [members' (monad\map meta_monad full_expansion members)] - (in (list (tuple$ (list\join members'))))) + (in (list (tuple$ (list\joined members'))))) [_ (#Record pairs)] (do meta_monad @@ -2807,7 +2807,7 @@ _ (let' [pairs (|> patterns (list\map (function' [pattern] (list pattern body))) - (list\join))] + (list\joined))] (in_meta (list\compose pairs branches)))) _ (failure "Wrong syntax for ^or"))) @@ -3568,10 +3568,10 @@ _ (failure "Invalid implementation member.")))) - (list\join tokens'))] + (list\joined tokens'))] (in (list (record$ members))))) -(def: (text\join_with separator parts) +(def: (text\interposed separator parts) (-> Text (List Text) Text) (case parts #End @@ -3822,7 +3822,7 @@ _ (failure "Interfaces require typed members!")))) - (list\join methods'))) + (list\joined methods'))) .let [def_name (local_identifier$ name) interface_type (record$ (list\map (: (-> [Text Code] [Code Code]) (function (_ [module_name m_type]) @@ -4010,23 +4010,14 @@ (relative_ups ("lux i64 +" 1 relatives) input) relatives))) -(def: (list\take amount list) - (All [a] (-> Nat (List a) (List a))) - (case [amount list] - (^or [0 _] [_ #End]) - #End - - [_ (#Item head tail)] - (#Item head (list\take ("lux i64 -" 1 amount) tail)))) - -(def: (list\drop amount list) +(def: (list\after amount list) (All [a] (-> Nat (List a) (List a))) (case [amount list] (^or [0 _] [_ #End]) list [_ (#Item _ tail)] - (list\drop ("lux i64 -" 1 amount) tail))) + (list\after ("lux i64 -" 1 amount) tail))) (def: (absolute_module_name nested? relative_root module) (-> Bit Text Text (Meta Text)) @@ -4042,10 +4033,9 @@ (if (n/< (list\size parts) jumps) (let [prefix (|> parts list\reverse - (list\drop jumps) + (list\after jumps) list\reverse - (list\interposed ..module_separator) - (text\join_with "")) + (text\interposed ..module_separator)) clean ("lux text clip" relatives (|> module "lux text size" ("lux i64 -" relatives)) module) output (case ("lux text size" clean) 0 prefix @@ -4130,7 +4120,7 @@ "Wrong syntax for import @ " current_module ..\n (code\encode token))))))) imports)] - (in (list\join imports')))) + (in (list\joined imports')))) (def: (exported_definitions module state) (-> Text (Meta (List Text))) @@ -4155,7 +4145,7 @@ (list))))) (let [{#module_hash _ #module_aliases _ #definitions definitions #imports _ #tags tags #types types #module_annotations _ #module_state _} =module] definitions))] - (#Right state (list\join to_alias))) + (#Right state (list\joined to_alias))) #None (#Left ($_ text\compose @@ -4541,7 +4531,7 @@ (function (_ [sub_tag_index sname stype]) (open_declaration alias tags' sub_tag_index sname source+ stype))) (enumeration (zipped/2 tags' members')))] - (in_meta (list\join decls'))) + (in_meta (list\joined decls'))) _ (in_meta (list (` ("lux def" (~ (local_identifier$ (..module_alias "" short alias))) @@ -4576,7 +4566,7 @@ (function (_ [tag_index sname stype]) (open_declaration alias tags tag_index sname source stype))) (enumeration (zipped/2 tags members)))] - (in_meta (list\join decls'))) + (in_meta (list\joined decls'))) _ (failure (text\compose "Can only 'open:' structs: " (type\encode struct_type))))) @@ -4685,7 +4675,7 @@ (list\map (function (_ name) (` (open: (~ (text$ alias)) (~ (identifier$ [module_name name]))))) structs)))) - list\join)]] + list\joined)]] (in (list\compose defs openings)))) (macro: (refer tokens) @@ -4851,7 +4841,7 @@ (#Item (list new_binding old_record) accesses')])) [record (: (List (List Code)) #End)] pairs) - accesses (list\join (list\reverse accesses'))]] + accesses (list\joined (list\reverse accesses'))]] (in (list (` (let [(~+ accesses)] (~ update_expr))))))) @@ -4998,8 +4988,8 @@ (let [apply (: (-> Replacement_Environment (List Code)) (function (_ env) (list\map (realized_template env) templates)))] (|> data' - (list\map (compose apply (replacement_environment bindings'))) - list\join + (list\map (function\composite apply (replacement_environment bindings'))) + list\joined in)) #None)))) (#Some output) @@ -5074,9 +5064,9 @@ (def: (location_padding baseline [_ old_line old_column] [_ new_line new_column]) (-> Nat Location Location Text) (if ("lux i64 =" old_line new_line) - (text\join_with "" (repeated (.int ("lux i64 -" old_column new_column)) " ")) - (let [extra_lines (text\join_with "" (repeated (.int ("lux i64 -" old_line new_line)) ..\n)) - space_padding (text\join_with "" (repeated (.int ("lux i64 -" baseline new_column)) " "))] + (text\interposed "" (repeated (.int ("lux i64 -" old_column new_column)) " ")) + (let [extra_lines (text\interposed "" (repeated (.int ("lux i64 -" old_line new_line)) ..\n)) + space_padding (text\interposed "" (repeated (.int ("lux i64 -" baseline new_column)) " "))] (text\compose extra_lines space_padding)))) (def: (text\size x) @@ -5093,7 +5083,7 @@ (function (_ [left right]) (list left right)))] (|>> (list\map pair_list) - list\join))) + list\joined))) (def: (example_documentation prev_location baseline example) (-> Location Nat Code [Location Text]) @@ -5139,7 +5129,7 @@ (|> comment (text\all_split_by ..\n) (list\map (function (_ line) ($_ text\compose "... " line ..\n))) - (text\join_with "")) + (text\interposed "")) (#Documentation_Example example) (let [baseline (baseline_column example) @@ -5162,7 +5152,7 @@ (in_meta (list (` [(~ location_code) (#.Text (~ (|> tokens (list\map (|>> ..documentation_fragment ..fragment_documentation)) - (text\join_with "") + (text\interposed "") text$)))])))) (def: (interleaved xs ys) @@ -5324,7 +5314,7 @@ [[location (<tag> elems)] (do maybe_monad [placements (monad\map maybe_monad (with_expansions' label tokens) elems)] - (in (list [location (<tag> (list\join placements))])))]) + (in (list [location (<tag> (list\joined placements))])))]) ([#Tuple] [#Form]) @@ -5973,7 +5963,7 @@ .let [[labels labelled] =raw]] (in (list (` (with_expansions [(~+ (|> labels (list\map (function (_ [label expansion]) (list label expansion))) - list\join))] + list\joined))] (~ labelled)))))) _ diff --git a/stdlib/source/library/lux/abstract/apply.lux b/stdlib/source/library/lux/abstract/apply.lux index adac4d3a2..7b57f5671 100644 --- a/stdlib/source/library/lux/abstract/apply.lux +++ b/stdlib/source/library/lux/abstract/apply.lux @@ -12,13 +12,14 @@ (-> (f (-> a b)) (f a) (f b))) apply)) -(implementation: .public (compose f_monad f_apply g_apply) +(implementation: .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)))))) - (def: &functor (functor.compose (get@ #&functor f_apply) (get@ #&functor g_apply))) + (def: &functor + (functor.composite (get@ #&functor f_apply) (get@ #&functor g_apply))) (def: (apply fgf fgx) ... TODO: Switch from this version to the one below (in comments) ASAP. diff --git a/stdlib/source/library/lux/abstract/codec.lux b/stdlib/source/library/lux/abstract/codec.lux index 0c3901361..53c95a816 100644 --- a/stdlib/source/library/lux/abstract/codec.lux +++ b/stdlib/source/library/lux/abstract/codec.lux @@ -13,7 +13,7 @@ (: (-> m (Try a)) decode)) -(implementation: .public (compose cb_codec ba_codec) +(implementation: .public (composite cb_codec ba_codec) (All [a b c] (-> (Codec c b) (Codec b a) (Codec c a))) diff --git a/stdlib/source/library/lux/abstract/fold.lux b/stdlib/source/library/lux/abstract/fold.lux index 1a7ba054f..ba8a93381 100644 --- a/stdlib/source/library/lux/abstract/fold.lux +++ b/stdlib/source/library/lux/abstract/fold.lux @@ -5,13 +5,11 @@ [monoid (#+ Monoid)]]) (interface: .public (Fold F) - {#.doc "Iterate over a structure's values to build a summary value."} (: (All [a b] (-> (-> b a a) a (F b) a)) fold)) (def: .public (with_monoid monoid fold value) - {#.doc "Fold over a foldable structure using the monoid's identity as the initial value."} (All [F a] (-> (Monoid a) (Fold F) (F a) a)) (let [(^open "/\.") monoid] diff --git a/stdlib/source/library/lux/abstract/functor.lux b/stdlib/source/library/lux/abstract/functor.lux index d06f82ed7..6f7053018 100644 --- a/stdlib/source/library/lux/abstract/functor.lux +++ b/stdlib/source/library/lux/abstract/functor.lux @@ -38,7 +38,7 @@ (type: .public (Then f g) (All [a] (f (g a)))) -(def: .public (compose (^open "f\.") (^open "g\.")) +(def: .public (composite (^open "f\.") (^open "g\.")) (All [F G] (-> (Functor F) (Functor G) (Functor (..Then F G)))) (implementation (def: (map f fga) diff --git a/stdlib/source/library/lux/abstract/functor/contravariant.lux b/stdlib/source/library/lux/abstract/functor/contravariant.lux index 1cf16ce24..9c5fe673a 100644 --- a/stdlib/source/library/lux/abstract/functor/contravariant.lux +++ b/stdlib/source/library/lux/abstract/functor/contravariant.lux @@ -3,8 +3,6 @@ [lux #*]]) (interface: .public (Functor f) - {#.doc (example "The contravariant functor.")} - (: (All [a b] (-> (-> b a) (-> (f a) (f b)))) diff --git a/stdlib/source/library/lux/abstract/hash.lux b/stdlib/source/library/lux/abstract/hash.lux index 3a27317de..3180691f3 100644 --- a/stdlib/source/library/lux/abstract/hash.lux +++ b/stdlib/source/library/lux/abstract/hash.lux @@ -7,8 +7,6 @@ ["." contravariant]]]) (interface: .public (Hash a) - {#.doc (example "A way to produce hash-codes for a type's instances." - "A necessity when working with some data-structures, such as dictionaries or sets.")} (: (Equivalence a) &equivalence) (: (-> a Nat) diff --git a/stdlib/source/library/lux/abstract/interval.lux b/stdlib/source/library/lux/abstract/interval.lux index 5961039b9..cea44c57b 100644 --- a/stdlib/source/library/lux/abstract/interval.lux +++ b/stdlib/source/library/lux/abstract/interval.lux @@ -8,7 +8,6 @@ [enum (#+ Enum)]]) (interface: .public (Interval a) - {#.doc "A representation of top and bottom boundaries for an ordered type."} (: (Enum a) &enum) @@ -70,13 +69,11 @@ ) (def: .public (borders? interval elem) - {#.doc (example "Where a value is at the border of an interval.")} (All [a] (-> (Interval a) a Bit)) (or (starts_with? elem interval) (ends_with? elem interval))) (implementation: .public (union left right) - {#.doc (example "An interval that spans both predecessors.")} (All [a] (-> (Interval a) (Interval a) (Interval a))) (def: &enum (get@ #&enum right)) @@ -84,7 +81,6 @@ (def: top (order.max (\ right &order) (\ left top) (\ right top)))) (implementation: .public (intersection left right) - {#.doc (example "An interval spanned by both predecessors.")} (All [a] (-> (Interval a) (Interval a) (Interval a))) (def: &enum (get@ #&enum right)) @@ -92,7 +88,6 @@ (def: top (order.min (\ right &order) (\ left top) (\ right top)))) (implementation: .public (complement interval) - {#.doc (example "The inverse of an interval.")} (All [a] (-> (Interval a) (Interval a))) (def: &enum (get@ #&enum interval)) @@ -122,7 +117,6 @@ ) (def: .public (meets? reference sample) - {#.doc (example "Whether an interval meets another one on its bottom/lower side.")} (All [a] (-> (Interval a) (Interval a) Bit)) (let [(^open ",\.") reference limit (\ reference bottom)] diff --git a/stdlib/source/library/lux/abstract/monoid.lux b/stdlib/source/library/lux/abstract/monoid.lux index 4e55a9a3b..53c3288c6 100644 --- a/stdlib/source/library/lux/abstract/monoid.lux +++ b/stdlib/source/library/lux/abstract/monoid.lux @@ -10,7 +10,7 @@ (: (-> a a a) compose)) -(def: .public (compose left right) +(def: .public (composite left right) (All [l r] (-> (Monoid l) (Monoid r) (Monoid [l r]))) (implementation (def: identity diff --git a/stdlib/source/library/lux/abstract/order.lux b/stdlib/source/library/lux/abstract/order.lux index 17bb2109d..279c3beb0 100644 --- a/stdlib/source/library/lux/abstract/order.lux +++ b/stdlib/source/library/lux/abstract/order.lux @@ -9,8 +9,6 @@ ["." contravariant]]]) (interface: .public (Order a) - {#.doc "A signature for types that possess some sense of ordering among their elements."} - (: (Equivalence a) &equivalence) @@ -19,37 +17,30 @@ ) (type: .public (Comparison a) - {#.doc (example "An arbitrary comparison between two values, with the knowledge of how to order them.")} (-> (Order a) a a Bit)) (def: .public (<= order parameter subject) - {#.doc (example "Less than or equal.")} Comparison (or (\ order < parameter subject) (\ order = parameter subject))) (def: .public (> order parameter subject) - {#.doc (example "Greater than.")} Comparison (\ order < subject parameter)) (def: .public (>= order parameter subject) - {#.doc (example "Greater than or equal.")} Comparison (or (\ order < subject parameter) (\ order = subject parameter))) (type: .public (Choice a) - {#.doc (example "A choice comparison between two values, with the knowledge of how to order them.")} (-> (Order a) a a a)) (def: .public (min order x y) - {#.doc (example "Minimum.")} Choice (if (\ order < y x) x y)) (def: .public (max order x y) - {#.doc (example "Maximum.")} Choice (if (\ order < y x) y x)) diff --git a/stdlib/source/library/lux/abstract/predicate.lux b/stdlib/source/library/lux/abstract/predicate.lux index a3702c20c..20101f7a9 100644 --- a/stdlib/source/library/lux/abstract/predicate.lux +++ b/stdlib/source/library/lux/abstract/predicate.lux @@ -9,29 +9,21 @@ ["." contravariant]]]) (type: .public (Predicate a) - {#.doc (example "A question that can be asked of a value, yield either false (#0) or true (#1).")} (-> a Bit)) -(template [<identity_name> <identity_value> <composition_name> <composition> - <identity_doc> <composition_doc>] +(template [<identity_name> <identity_value> <composition_name> <composition>] [(def: .public <identity_name> - {#.doc <identity_doc>} Predicate (function.constant <identity_value>)) (def: .public (<composition_name> left right) - {#.doc <composition_doc>} (All [a] (-> (Predicate a) (Predicate a) (Predicate a))) (function (_ value) (<composition> (left value) (right value))))] - [none #0 or .or - (example "A predicate that always fails.") - (example "A predicate that meets either predecessor.")] - [all #1 and .and - (example "A predicate that always succeeds.") - (example "A predicate that meets both predecessors.")] + [none #0 or .or] + [all #1 and .and] ) (template [<name> <identity> <composition>] @@ -46,19 +38,16 @@ ) (def: .public (complement predicate) - {#.doc (example "The opposite of a predicate.")} (All [a] (-> (Predicate a) (Predicate a))) (|>> predicate not)) (def: .public (difference sub base) - {#.doc (example "A predicate that meeds 'base', but not 'sub'.")} (All [a] (-> (Predicate a) (Predicate a) (Predicate a))) (function (_ value) (.and (base value) (not (sub value))))) (def: .public (rec predicate) - {#.doc (example "Ties the knot for a recursive predicate.")} (All [a] (-> (-> (Predicate a) (Predicate a)) (Predicate a))) diff --git a/stdlib/source/library/lux/control/concatenative.lux b/stdlib/source/library/lux/control/concatenative.lux index 2dbcfda97..03ae8afe6 100644 --- a/stdlib/source/library/lux/control/concatenative.lux +++ b/stdlib/source/library/lux/control/concatenative.lux @@ -26,7 +26,8 @@ ["<>" parser ("#\." monad) ["<.>" code (#+ Parser)]]]) -(type: Alias [Text Code]) +(type: Alias + [Text Code]) (type: Stack {#bottom (Maybe Nat) @@ -67,20 +68,11 @@ _ (meta.failure (format "Cannot expand to more than a single AST/Code node:" text.new_line - (|> expansion (list\map %.code) (text.join_with " "))))))) + (|> expansion (list\map %.code) (text.interposed " "))))))) (syntax: .public (=> [aliases aliases^ inputs stack^ outputs stack^]) - {#.doc (example "Concatenative function types." - (=> [Nat] [Nat]) - (All [a] (-> a (=> [] [a]))) - (All [t] (=> [t] [])) - (All [a b c] (=> [a b c] [b c a])) - (All [___a ___z] - (=> {then (=> ___a ___z) - else (=> ___a ___z)} - ___a [Bit then else] ___z)))} (let [de_alias (function (_ aliased) (list\fold (function (_ [from to] pre) (code.replaced (code.local_identifier from) to pre)) @@ -104,7 +96,9 @@ (-> (~ (de_alias inputC)) (~ (de_alias outputC)))))))))))) -(def: begin! Any []) +(def: begin! + Any + []) (def: end! (All [a] (-> [Any a] a)) @@ -112,13 +106,6 @@ top)) (syntax: .public (||> [commands (<>.some <code>.any)]) - {#.doc (example "A self-contained sequence of concatenative instructions." - (same? value - (||> (..push sample))) - - (||> (push 123) - dup - n/=))} (in (list (` (|> (~! ..begin!) (~+ commands) ((~! ..end!))))))) (def: word @@ -135,21 +122,12 @@ ))) (syntax: .public (word: [[export_policy name annotations type commands] ..word]) - {#.doc (example "A named concatenative function." - (word: square - (=> [Nat] [Nat]) - - dup - (apply/2 n.*)))} (in (list (` (def: (~ export_policy) (~ (code.local_identifier name)) (~ (|annotations|.format annotations)) (~ type) (|>> (~+ commands))))))) (syntax: .public (apply [arity (<>.only (n.> 0) <code>.nat)]) - {#.doc (example "A generator for functions that turn arity N functions into arity N concatenative functions." - (: (=> [Nat] [Nat]) - ((apply 1) inc)))} (with_identifiers [g! g!func g!stack g!output] (monad.do {! meta.monad} [g!inputs (|> (macro.identifier "input") (list.repeated arity) (monad.seq !))] @@ -161,80 +139,65 @@ [(~ g!stack) ((~ g!func) (~+ g!inputs))]))))))))) (template [<arity>] - [(with_expansions [<name> (template.identifier ["apply/" <arity>]) - <doc> (template.text ["Lift a function of arity " <arity> - " into a concatenative function of arity " <arity> "."])] - (def: .public <name> - {#.doc (example <doc>)} - (apply <arity>)))] + [(`` (def: .public (~~ (template.identifier ["apply/" <arity>])) + (..apply <arity>)))] [1] [2] [3] [4] [5] [6] [7] [8] ) (def: .public (push x) - {#.doc (example "Push a value onto the stack.")} (All [a] (-> a (=> [] [a]))) (function (_ stack) [stack x])) (def: .public drop - {#.doc (example "Drop/pop a value from the top of the stack.")} (All [t] (=> [t] [])) (function (_ [stack top]) stack)) (def: .public nip - {#.doc (example "Drop the second-to-last value from the top of the stack.")} (All [_ a] (=> [_ a] [a])) (function (_ [[stack _] top]) [stack top])) (def: .public dup - {#.doc (example "Duplicate the top of the stack.")} (All [a] (=> [a] [a a])) (function (_ [stack top]) [[stack top] top])) (def: .public swap - {#.doc (example "Swaps the 2 topmost stack values.")} (All [a b] (=> [a b] [b a])) (function (_ [[stack l] r]) [[stack r] l])) (def: .public rotL - {#.doc (example "Rotes the 3 topmost stack values to the left.")} (All [a b c] (=> [a b c] [b c a])) (function (_ [[[stack a] b] c]) [[[stack b] c] a])) (def: .public rotR - {#.doc (example "Rotes the 3 topmost stack values to the right.")} (All [a b c] (=> [a b c] [c a b])) (function (_ [[[stack a] b] c]) [[[stack c] a] b])) (def: .public && - {#.doc (example "Groups the 2 topmost stack values as a 2-tuple.")} (All [a b] (=> [a b] [(Tuple a b)])) (function (_ [[stack l] r]) [stack [l r]])) (def: .public ||L - {#.doc (example "Left-injects the top into sum.")} (All [a b] (=> [a] [(Or a b)])) (function (_ [stack l]) [stack (0 #0 l)])) (def: .public ||R - {#.doc (example "Right-injects the top into sum.")} (All [a b] (=> [b] [(Or a b)])) (function (_ [stack r]) [stack (0 #1 r)])) (template [<input> <output> <word> <func>] [(`` (def: .public <word> - {#.doc (example (~~ (template.text [<func> " for " <input> " arithmetic."])))} (=> [<input> <input>] [<output>]) (function (_ [[stack subject] param]) [stack (<func> param subject)])))] @@ -285,12 +248,6 @@ ) (def: .public if - {#.doc (example "If expression." - (same? "then" - (||> (push true) - (push "then") - (push "else") - if)))} (All [___a ___z] (=> {then (=> ___a ___z) else (=> ___a ___z)} @@ -301,7 +258,6 @@ (else stack)))) (def: .public call - {#.doc (example "Executes an anonymous block on the stack.")} (All [___a ___z] (=> {quote (=> ___a ___z)} ___a [quote] ___z)) @@ -309,7 +265,6 @@ (quote stack))) (def: .public loop - {#.doc (example "Executes a block as a loop until it yields #0 to stop.")} (All [___] (=> {test (=> ___ ___ [Bit])} ___ [test] ___)) @@ -320,7 +275,6 @@ stack')))) (def: .public dip - {#.doc (example "Executes a block on the stack, save for the topmost value.")} (All [___ a] (=> ___ [a (=> ___ ___)] ___ [a])) @@ -328,7 +282,6 @@ [(quote stack) a])) (def: .public dip/2 - {#.doc (example "Executes a block on the stack, save for the 2 topmost values.")} (All [___ a b] (=> ___ [a b (=> ___ ___)] ___ [a b])) @@ -336,12 +289,6 @@ [[(quote stack) a] b])) (def: .public do - {#.doc (example "Do-while loop expression." - (n.= (inc sample) - (||> (push sample) - (push (push false)) - (push (|>> (push 1) n/+)) - do while)))} (All [___a ___z] (=> {body (=> ___a ___z) pred (=> ___z ___a [Bit])} @@ -351,14 +298,6 @@ [[(body stack) pred] body])) (def: .public while - {#.doc (example "While loop expression." - (n.= (n.+ distance start) - (||> (push start) - (push (|>> dup - (push start) n/- - (push distance) n/<)) - (push (|>> (push 1) n/+)) - while)))} (All [___a ___z] (=> {body (=> ___z ___a) pred (=> ___a ___z [Bit])} @@ -371,13 +310,6 @@ stack')))) (def: .public compose - {#.doc (example "Function composition." - (n.= (n.+ 2 sample) - (||> (push sample) - (push (|>> (push 1) n/+)) - (push (|>> (push 1) n/+)) - compose - call)))} (All [___a ___ ___z] (=> [(=> ___a ___) (=> ___ ___z)] [(=> ___a ___z)])) @@ -385,13 +317,6 @@ [stack (|>> f g)])) (def: .public partial - {#.doc (example "Partial application." - (n.= (n.+ sample sample) - (||> (push sample) - (push sample) - (push n/+) - partial - call)))} (All [___a ___z a] (=> ___a [a (=> ___a [a] ___z)] ___a [(=> ___a ___z)])) @@ -399,7 +324,6 @@ [stack (|>> (push arg) quote)])) (word: .public when - {#.doc (example "Only execute the block when #1.")} (All [___] (=> {body (=> ___ ___)} ___ [Bit body] @@ -410,7 +334,6 @@ if) (word: .public ? - {#.doc (example "Choose the top value when #0 and the second-to-top when #1.")} (All [a] (=> [Bit a a] [a])) rotL diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux index 1557a9f89..e51be0b98 100644 --- a/stdlib/source/library/lux/control/concurrency/actor.lux +++ b/stdlib/source/library/lux/control/concurrency/actor.lux @@ -1,5 +1,4 @@ (.module: - {#.doc "The actor model of concurrency."} [library [lux #* ["." debug] @@ -64,27 +63,23 @@ (in #.End)))) (abstract: .public (Actor s) - {#.doc (example "An entity that can react to messages (mail) sent to it concurrently.")} + {} {#obituary [(Async <Obituary>) (Resolver <Obituary>)] #mailbox (Atom <Mailbox>)} (type: .public (Mail s) - {#.doc (example "A one-way message sent to an actor, without expecting a reply.")} <Mail>) (type: .public (Obituary s) - {#.doc (example "Details on the death of an actor.")} <Obituary>) (type: .public (Behavior o s) - {#.doc (example "An actor's behavior when mail is received and when a fatal error occurs.")} {#on_init (-> o s) #on_mail (-> (Mail s) s (Actor s) (Async (Try s)))}) (def: .public (spawn! behavior init) - {#.doc (example "Given a behavior and initial state, spawns an actor and returns it.")} (All [o s] (-> (Behavior o s) o (IO (Actor s)))) (io (let [[on_init on_mail] behavior self (:sharing [o s] @@ -130,14 +125,12 @@ (async.value obituary))) (def: .public obituary - {#.doc (example "Await for an actor to stop working.")} (All [s] (-> (Actor s) (Async (Obituary s)))) (|>> :representation (get@ #obituary) product.left)) (def: .public (mail! mail actor) - {#.doc (example "Send mail to an actor.")} (All [s] (-> (Mail s) (Actor s) (IO (Try Any)))) (do {! io.monad} [alive? (..alive? actor)] @@ -163,7 +156,6 @@ (in (exception.except ..dead []))))) (type: .public (Message s o) - {#.doc (example "A two-way message sent to an actor, expecting a reply.")} (-> s (Actor s) (Async (Try [s o])))) (def: (mail message) @@ -191,7 +183,6 @@ (async.resolved (#try.Failure error))))))])) (def: .public (tell! message actor) - {#.doc (example "Communicate with an actor through message-passing.")} (All [s o] (-> (Message s o) (Actor s) (Async (Try o)))) (let [[async mail] (..mail message)] (do async.monad @@ -210,14 +201,11 @@ (mail state self)) (def: .public default - {#.doc (example "Default actor behavior.")} (All [s] (Behavior s s)) {#on_init function.identity #on_mail ..default_on_mail}) (def: .public (poison! actor) - {#.doc (example "Kills the actor by sending mail that will kill it upon processing," - "but allows the actor to handle previous mail.")} (All [s] (-> (Actor s) (IO (Try Any)))) (..mail! (function (_ state self) (async.resolved (exception.except ..poisoned []))) @@ -270,151 +258,102 @@ (<>.and <code>.any private) (<>.and (<>\in (` .private)) private)))) -(with_expansions [<examples> (as_is (actor: .public (stack a) - {} - - (List a) - - ((on_mail mail state self) - (do (try.with async.monad) - [.let [_ (debug.log! "BEFORE")] - output (mail state self) - .let [_ (debug.log! "AFTER")]] - (in output))) - - (message: .public (push {value a} state self) - (List a) - (let [state' (#.Item value state)] - (async.resolved (#try.Success [state' state']))))) - - (actor: .public counter - {} - - Nat - - (message: .public (count! {increment Nat} state self) - Any - (let [state' (n.+ increment state)] - (async.resolved (#try.Success [state' state'])))) - - (message: .public (read! state self) - Nat - (async.resolved (#try.Success [state state])))))] - (syntax: .public (actor: [[export_policy [name vars] annotations state_type [?on_mail messages]] ..actorP]) - {#.doc (example "Defines a named actor, with its behavior and internal state." - "Messages for the actor must be defined after the on_mail handler." - <examples>)} - (with_identifiers [g!_] - (do meta.monad - [g!type (macro.identifier (format name "_abstract_type")) - .let [g!actor (code.local_identifier name) - g!vars (list\map code.local_identifier vars)]] - (in (list (` ((~! abstract:) (~ export_policy) ((~ g!type) (~+ g!vars)) - {} - - (~ state_type) - - (def: (~ export_policy) (~ g!actor) - (All [(~+ g!vars)] - (..Behavior (~ state_type) ((~ g!type) (~+ g!vars)))) - {#..on_init (|>> ((~! abstract.:abstraction) (~ g!type))) - #..on_mail (~ (..on_mail g!_ ?on_mail))}) - - (~+ messages)))))))) - - (syntax: .public (actor [[state_type init] (<code>.record (<>.and <code>.any <code>.any)) - [?on_mail messages] behavior^]) - {#.doc (example "Defines an anonymous actor, with its behavior and internal state." - "Messages for the actor must be defined after the on_mail handler." - (actor {Nat - 123} - ((on_mail message state self) - (message (inc state) self))))} - (with_identifiers [g!_] - (in (list (` (: ((~! io.IO) (..Actor (~ state_type))) - (..spawn! (: (..Behavior (~ state_type) (~ state_type)) - {#..on_init (|>>) - #..on_mail (~ (..on_mail g!_ ?on_mail))}) - (: (~ state_type) - (~ init))))))))) - - (type: Signature - {#vars (List Text) - #name Text - #inputs (List |input|.Input) - #state Text - #self Text}) - - (def: signature^ - (Parser Signature) - (<code>.form ($_ <>.and - (<>.else (list) (<code>.tuple (<>.some <code>.local_identifier))) - <code>.local_identifier - (<>.some |input|.parser) - <code>.local_identifier - <code>.local_identifier))) - - (def: reference^ - (Parser [Name (List Text)]) - (<>.either (<code>.form (<>.and <code>.identifier (<>.some <code>.local_identifier))) - (<>.and <code>.identifier (\ <>.monad in (list))))) - - (def: messageP - (Parser [Code Signature |annotations|.Annotations Code Code]) - (let [private ($_ <>.and - ..signature^ - (<>.else |annotations|.empty |annotations|.parser) - <code>.any - <code>.any)] - ($_ <>.either - (<>.and <code>.any private) - (<>.and (<>\in (` .private)) private)))) - - (syntax: .public (message: [[export_policy signature annotations output_type body] ..messageP]) - {#.doc (example "A message can access the actor's state through the state parameter." - "A message can also access the actor itself through the self parameter." - "A message's output must be an async containing a 2-tuple with the updated state and a return value." - "A message may succeed or fail (in case of failure, the actor dies)." - - <examples>)} - (with_identifiers [g!_ g!return] - (do meta.monad - [actor_scope abstract.current - .let [g!type (code.local_identifier (get@ #abstract.name actor_scope)) - g!message (code.local_identifier (get@ #name signature)) - g!actor_vars (get@ #abstract.type_vars actor_scope) - g!all_vars (|> signature (get@ #vars) (list\map code.local_identifier) (list\compose g!actor_vars)) - g!inputsC (|> signature (get@ #inputs) (list\map product.left)) - g!inputsT (|> signature (get@ #inputs) (list\map product.right)) - g!state (|> signature (get@ #state) code.local_identifier) - g!self (|> signature (get@ #self) code.local_identifier)]] - (in (list (` (def: (~ export_policy) ((~ g!message) (~+ g!inputsC)) - (~ (|annotations|.format annotations)) - (All [(~+ g!all_vars)] - (-> (~+ g!inputsT) - (..Message (~ (get@ #abstract.abstraction actor_scope)) - (~ output_type)))) - (function ((~ g!_) (~ g!state) (~ g!self)) - (let [(~ g!state) (:as (~ (get@ #abstract.representation actor_scope)) - (~ g!state))] - (|> (~ body) - (: ((~! async.Async) ((~! try.Try) [(~ (get@ #abstract.representation actor_scope)) - (~ output_type)]))) - (:as ((~! async.Async) ((~! try.Try) [(~ (get@ #abstract.abstraction actor_scope)) - (~ output_type)])))))))) - )))))) +(syntax: .public (actor: [[export_policy [name vars] annotations state_type [?on_mail messages]] ..actorP]) + (with_identifiers [g!_] + (do meta.monad + [g!type (macro.identifier (format name "_abstract_type")) + .let [g!actor (code.local_identifier name) + g!vars (list\map code.local_identifier vars)]] + (in (list (` ((~! abstract:) (~ export_policy) ((~ g!type) (~+ g!vars)) + {} + + (~ state_type) + + (def: (~ export_policy) (~ g!actor) + (All [(~+ g!vars)] + (..Behavior (~ state_type) ((~ g!type) (~+ g!vars)))) + {#..on_init (|>> ((~! abstract.:abstraction) (~ g!type))) + #..on_mail (~ (..on_mail g!_ ?on_mail))}) + + (~+ messages)))))))) + +(syntax: .public (actor [[state_type init] (<code>.record (<>.and <code>.any <code>.any)) + [?on_mail messages] behavior^]) + (with_identifiers [g!_] + (in (list (` (: ((~! io.IO) (..Actor (~ state_type))) + (..spawn! (: (..Behavior (~ state_type) (~ state_type)) + {#..on_init (|>>) + #..on_mail (~ (..on_mail g!_ ?on_mail))}) + (: (~ state_type) + (~ init))))))))) + +(type: Signature + {#vars (List Text) + #name Text + #inputs (List |input|.Input) + #state Text + #self Text}) + +(def: signature^ + (Parser Signature) + (<code>.form ($_ <>.and + (<>.else (list) (<code>.tuple (<>.some <code>.local_identifier))) + <code>.local_identifier + (<>.some |input|.parser) + <code>.local_identifier + <code>.local_identifier))) + +(def: reference^ + (Parser [Name (List Text)]) + (<>.either (<code>.form (<>.and <code>.identifier (<>.some <code>.local_identifier))) + (<>.and <code>.identifier (\ <>.monad in (list))))) + +(def: messageP + (Parser [Code Signature |annotations|.Annotations Code Code]) + (let [private ($_ <>.and + ..signature^ + (<>.else |annotations|.empty |annotations|.parser) + <code>.any + <code>.any)] + ($_ <>.either + (<>.and <code>.any private) + (<>.and (<>\in (` .private)) private)))) + +(syntax: .public (message: [[export_policy signature annotations output_type body] ..messageP]) + (with_identifiers [g!_ g!return] + (do meta.monad + [actor_scope abstract.current + .let [g!type (code.local_identifier (get@ #abstract.name actor_scope)) + g!message (code.local_identifier (get@ #name signature)) + g!actor_vars (get@ #abstract.type_vars actor_scope) + g!all_vars (|> signature (get@ #vars) (list\map code.local_identifier) (list\compose g!actor_vars)) + g!inputsC (|> signature (get@ #inputs) (list\map product.left)) + g!inputsT (|> signature (get@ #inputs) (list\map product.right)) + g!state (|> signature (get@ #state) code.local_identifier) + g!self (|> signature (get@ #self) code.local_identifier)]] + (in (list (` (def: (~ export_policy) ((~ g!message) (~+ g!inputsC)) + (~ (|annotations|.format annotations)) + (All [(~+ g!all_vars)] + (-> (~+ g!inputsT) + (..Message (~ (get@ #abstract.abstraction actor_scope)) + (~ output_type)))) + (function ((~ g!_) (~ g!state) (~ g!self)) + (let [(~ g!state) (:as (~ (get@ #abstract.representation actor_scope)) + (~ g!state))] + (|> (~ body) + (: ((~! async.Async) ((~! try.Try) [(~ (get@ #abstract.representation actor_scope)) + (~ output_type)]))) + (:as ((~! async.Async) ((~! try.Try) [(~ (get@ #abstract.abstraction actor_scope)) + (~ output_type)])))))))) + ))))) (type: .public Stop - {#.doc (example "A signal to stop an actor from observing a channel.")} (IO Any)) (def: continue! true) (def: stop! false) (def: .public (observe! action channel actor) - {#.doc (example "Use an actor to observe a channel by transforming each datum" - "flowing through the channel into mail the actor can process." - "Can stop observing the channel by executing the Stop value.")} (All [e s] (-> (-> e Stop (Mail s)) (Channel e) (Actor s) (IO Any))) (let [signal (: (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 32f1913b6..3dcb864b6 100644 --- a/stdlib/source/library/lux/control/concurrency/async.lux +++ b/stdlib/source/library/lux/control/concurrency/async.lux @@ -18,13 +18,11 @@ ["." atom (#+ Atom atom)]]) (abstract: .public (Async a) - {#.doc "Represents values produced by asynchronous computations (unlike IO, which is synchronous)."} + {} (Atom [(Maybe a) (List (-> a (IO Any)))]) (type: .public (Resolver a) - {#.doc (example "The function used to give a value to an async." - "Will signal 'true' if the async has been resolved for the 1st time, 'false' otherwise.")} (-> a (IO Bit))) (def: (resolver async) @@ -50,25 +48,21 @@ (resolve value)))))))) (def: .public (resolved value) - {#.doc (example "Produces an async that has already been resolved to the given value.")} (All [a] (-> a (Async a))) (:abstraction (atom [(#.Some value) (list)]))) (def: .public (async _) - {#.doc (example "Creates a fresh async that has not been resolved yet.")} (All [a] (-> Any [(Async a) (Resolver a)])) (let [async (:abstraction (atom [#.None (list)]))] [async (..resolver async)])) (def: .public value - {#.doc "Polls an async for its value."} (All [a] (-> (Async a) (IO (Maybe a)))) (|>> :representation atom.read! (\ io.functor map product.left))) (def: .public (upon! f async) - {#.doc (example "Executes the given function as soon as the async has been resolved.")} (All [a] (-> (-> a (IO Any)) (Async a) (IO Any))) (do {! io.monad} [.let [async (:representation async)] @@ -87,7 +81,6 @@ ) (def: .public resolved? - {#.doc "Checks whether an async's value has already been resolved."} (All [a] (-> (Async a) (IO Bit))) (|>> ..value (\ io.functor map @@ -133,7 +126,6 @@ ma)))) (def: .public (and left right) - {#.doc (example "Combines the results of both asyncs, in-order.")} (All [a b] (-> (Async a) (Async b) (Async [a b]))) (let [[read! write!] (:sharing [a b] [(Async a) (Async b)] @@ -150,8 +142,6 @@ read!)) (def: .public (or left right) - {#.doc (example "Yields the results of whichever async gets resolved first." - "You can tell which one was resolved first through pattern-matching.")} (All [a b] (-> (Async a) (Async b) (Async (Or a b)))) (let [[a|b resolve] (..async [])] (with_expansions @@ -166,8 +156,6 @@ a|b)))) (def: .public (either left right) - {#.doc (example "Yields the results of whichever async gets resolved first." - "You cannot tell which one was resolved first.")} (All [a] (-> (Async a) (Async a) (Async a))) (let [[left||right resolve] (..async [])] (`` (exec @@ -179,8 +167,6 @@ left||right)))) (def: .public (schedule! milli_seconds computation) - {#.doc (example "Runs an I/O computation on its own thread (after a specified delay)." - "Returns an async that will eventually host its result.")} (All [a] (-> Nat (IO a) (Async a))) (let [[!out resolve] (..async [])] (exec @@ -192,22 +178,17 @@ !out))) (def: .public future - {#.doc (example "Runs an I/O computation on its own thread." - "Returns an async that will eventually host its result.")} (All [a] (-> (IO a) (Async a))) (..schedule! 0)) (def: .public (delayed milli_seconds value) - {#.doc "Delivers a value after a certain period has passed."} (All [a] (-> Nat a (Async a))) (..schedule! milli_seconds (io value))) (def: .public (delay milli_seconds) - {#.doc "An async that will be resolved after the specified amount of milli-seconds."} (-> Nat (Async Any)) (..delayed milli_seconds [])) (def: .public (time_out milli_seconds async) - {#.doc "Wait for an async to be resolved within the specified amount of milli-seconds."} (All [a] (-> Nat (Async a) (Async (Maybe a)))) (..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 07e2640f8..b6d9461f0 100644 --- a/stdlib/source/library/lux/control/concurrency/atom.lux +++ b/stdlib/source/library/lux/control/concurrency/atom.lux @@ -47,7 +47,7 @@ @.scheme "scheme array read"} (as_is))] (abstract: .public (Atom a) - {#.doc "Atomic references that are safe to mutate concurrently."} + {} (with_expansions [<jvm> (java/util/concurrent/atomic/AtomicReference a)] (for {@.old <jvm> @@ -69,8 +69,6 @@ (<read> 0 (:representation atom)))))) (def: .public (compare_and_swap! current new atom) - {#.doc (example "Only mutates an atom if you can present its current value." - "That guarantees that atom was not updated since you last read from it.")} (All [a] (-> a a (Atom a) (IO Bit))) (io.io (with_expansions [<jvm> (java/util/concurrent/atomic/AtomicReference::compareAndSet current new (:representation atom))] (for {@.old <jvm> @@ -83,9 +81,6 @@ )) (def: .public (update! f atom) - {#.doc (example "Updates an atom by applying a function to its current value." - "If it fails to update it (because some other process wrote to it first), it will retry until it succeeds." - "The retries will be done with the new values of the atom, as they show up.")} (All [a] (-> (-> a a) (Atom a) (IO [a a]))) (loop [_ []] (do io.monad @@ -97,8 +92,6 @@ (recur []))))) (def: .public (write! value atom) - {#.doc (example "Writes the given value to an atom." - "If it fails to write it (because some other process wrote to it first), it will retry until it succeeds.")} (All [a] (-> a (Atom a) (IO a))) (|> 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 676aa0b8a..e14fb6505 100644 --- a/stdlib/source/library/lux/control/concurrency/frp.lux +++ b/stdlib/source/library/lux/control/concurrency/frp.lux @@ -18,13 +18,11 @@ ["." async (#+ Async) ("#\." functor)]]) (type: .public (Channel a) - {#.doc "An asynchronous channel to distribute values."} (Async (Maybe [a (Channel a)]))) (exception: .public channel_is_already_closed) (interface: .public (Sink a) - {#.doc (example "The tail-end of a channel, which can be written-to to fee the channel.")} (: (IO (Try Any)) close) (: (-> a (IO (Try Any))) @@ -80,7 +78,6 @@ (recur [])))))))))) (def: .public (channel _) - {#.doc (example "Creates a brand-new channel and hands it over, along with the sink to write to it.")} (All [a] (-> Any [(Channel a) (Sink a)])) (let [[async resolve] (async.async [])] [async (..sink resolve)])) @@ -150,7 +147,6 @@ output)))) (type: .public (Subscriber a) - {#.doc (example "A function that can receive every value fed into a channel.")} (-> a (IO (Maybe Any)))) (def: .public (subscribe! subscriber channel) @@ -174,8 +170,6 @@ []))) (def: .public (only pass? channel) - {#.doc (example "Produces a new channel based on the old one, only with values" - "that pass the test.")} (All [a] (-> (-> a Bit) (Channel a) (Channel a))) (do async.monad [item channel] @@ -190,14 +184,12 @@ (in #.None)))) (def: .public (of_async async) - {#.doc (example "A one-element channel containing the output from an async.")} (All [a] (-> (Async a) (Channel a))) (async\map (function (_ value) (#.Some [value ..empty])) async)) (def: .public (fold f init channel) - {#.doc "Asynchronous fold over channels."} (All [a b] (-> (-> b a (Async a)) a (Channel b) (Async a))) @@ -291,7 +283,6 @@ (in #.End)))) (def: .public (sequential milli_seconds values) - {#.doc (example "Transforms the given list into a channel with the same elements.")} (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 f7f4f5f50..c266617a5 100644 --- a/stdlib/source/library/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/library/lux/control/concurrency/semaphore.lux @@ -30,7 +30,7 @@ #waiting_list (Queue (Resolver Any))}) (abstract: .public Semaphore - {#.doc "A tool for controlling access to resources by multiple concurrent processes."} + {} (Atom State) @@ -46,25 +46,24 @@ #waiting_list queue.empty})))) (def: .public (wait! semaphore) - {#.doc (example "Wait on a semaphore until there are open positions." - "After finishing your work, you must 'signal' to the semaphore that you're done.")} (Ex [k] (-> Semaphore (Async Any))) (let [semaphore (:representation semaphore) [signal sink] (: [(Async Any) (Resolver Any)] (async.async []))] - (exec (io.run! - (with_expansions [<had_open_position?> (as_is (get@ #open_positions) (i.> -1))] - (do io.monad - [[_ state'] (atom.update! (|>> (update@ #open_positions dec) - (if> [<had_open_position?>] - [] - [(update@ #waiting_list (queue.end sink))])) - semaphore)] - (with_expansions [<go_ahead> (sink []) - <get_in_line> (in false)] - (if (|> state' <had_open_position?>) - <go_ahead> - <get_in_line>))))) + (exec + (io.run! + (with_expansions [<had_open_position?> (as_is (get@ #open_positions) (i.> -1))] + (do io.monad + [[_ state'] (atom.update! (|>> (update@ #open_positions dec) + (if> [<had_open_position?>] + [] + [(update@ #waiting_list (queue.end sink))])) + semaphore)] + (with_expansions [<go_ahead> (sink []) + <get_in_line> (in false)] + (if (|> state' <had_open_position?>) + <go_ahead> + <get_in_line>))))) signal))) (exception: .public (semaphore_is_maxed_out {max_positions Nat}) @@ -72,7 +71,6 @@ ["Max Positions" (%.nat max_positions)])) (def: .public (signal! semaphore) - {#.doc (example "Signal to a semaphore that you're done with your work, and that there is a new open position.")} (Ex [k] (-> Semaphore (Async (Try Int)))) (let [semaphore (:representation semaphore)] (async.future @@ -98,12 +96,11 @@ ) (abstract: .public Mutex - {#.doc "A mutual-exclusion lock that can only be acquired by one process at a time."} + {} Semaphore (def: .public (mutex _) - {#.doc (example "Creates a brand-new mutex.")} (-> Any Mutex) (:abstraction (semaphore 1))) @@ -116,7 +113,6 @@ (|>> :representation ..signal!)) (def: .public (synchronize! mutex procedure) - {#.doc (example "Runs the procedure with exclusive control of the mutex.")} (All [a] (-> Mutex (IO (Async a)) (Async a))) (do async.monad [_ (..acquire! mutex) @@ -126,15 +122,13 @@ ) (def: .public limit - {#.doc (example "Produce a limit for a barrier.")} (refinement.refiner (n.> 0))) (type: .public Limit - {#.doc (example "A limit for barriers.")} (:~ (refinement.type limit))) (abstract: .public Barrier - {#.doc "A barrier that blocks all processes from proceeding until a given number of processes are parked at the barrier."} + {} {#limit Limit #count (Atom Nat) @@ -174,7 +168,6 @@ ) (def: .public (block! barrier) - {#.doc (example "Wait on a barrier until all processes have arrived and met the barrier's limit.")} (-> 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 f3bdbcbb6..a41d12aba 100644 --- a/stdlib/source/library/lux/control/concurrency/stm.lux +++ b/stdlib/source/library/lux/control/concurrency/stm.lux @@ -24,12 +24,11 @@ (-> a (IO Any))) (abstract: .public (Var a) - {#.doc "A mutable cell containing a value, and observers that will be alerted of any change to it."} + {} (Atom [a (List (Sink a))]) (def: .public (var value) - {#.doc "Creates a new STM var, with a default value."} (All [a] (-> a (Var a))) (:abstraction (atom.atom [value (list)]))) @@ -67,7 +66,6 @@ (write! new_value var)))) (def: .public (follow! target) - {#.doc "Creates a channel that will receive all changes to the value of the given var."} (All [a] (-> (Var a) (IO [(Channel a) (Sink a)]))) (do io.monad [.let [[channel sink] (frp.channel [])] @@ -86,7 +84,6 @@ (List (Ex [a] (Tx_Frame a)))) (type: .public (STM a) - {#.doc "A computation which updates a transaction and produces a value."} (-> Tx [Tx a])) (def: (var_value var tx) @@ -175,7 +172,6 @@ (ma tx'))))) (def: .public (update f var) - {#.doc "Update a var's value, and return a tuple with the old and the new values."} (All [a] (-> (-> a a) (Var a) (STM [a a]))) (do ..monad [a (..read var) @@ -261,9 +257,6 @@ ))) (def: .public (commit! stm_proc) - {#.doc (example "Commits a transaction and returns its result (asynchronously)." - "Note that a transaction may be re-run an indeterminate number of times if other transactions involving the same variables successfully commit first." - "For this reason, it's important to note that transactions must be free from side-effects, such as I/O.")} (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 6d47059b0..e067d1ac5 100644 --- a/stdlib/source/library/lux/control/concurrency/thread.lux +++ b/stdlib/source/library/lux/control/concurrency/thread.lux @@ -65,7 +65,6 @@ )) (def: .public parallelism - {#.doc (example "How many processes can run in parallel.")} Nat (with_expansions [<jvm> (|> (java/lang/Runtime::getRuntime) (java/lang/Runtime::availableProcessors) @@ -102,7 +101,6 @@ [])) (def: .public (schedule! milli_seconds action) - {#.doc (example "Executes an I/O procedure after some milli-seconds.")} (-> Nat (IO Any) (IO Any)) (with_expansions [<jvm> (as_is (let [runnable (ffi.object [] [java/lang/Runnable] [] diff --git a/stdlib/source/library/lux/control/continuation.lux b/stdlib/source/library/lux/control/continuation.lux index e9b702f55..9a65c9d3e 100644 --- a/stdlib/source/library/lux/control/continuation.lux +++ b/stdlib/source/library/lux/control/continuation.lux @@ -14,21 +14,17 @@ ["." code]]]]) (type: .public (Cont i o) - {#.doc "Continuations."} (-> (-> i o) o)) -(def: .public (continue next cont) - {#.doc "Continues a continuation thunk."} +(def: .public (continued next cont) (All [i o] (-> (-> i o) (Cont i o) o)) (cont next)) -(def: .public (result cont) - {#.doc "Forces a continuation thunk to be evaluated."} +(def: .public result (All [a] (-> (Cont a a) a)) - (cont function.identity)) + (..continued function.identity)) -(def: .public (call/cc f) - {#.doc "Call with current continuation."} +(def: .public (with_current f) (All [a b z] (-> (-> (-> a (Cont b z)) (Cont a z)) @@ -38,8 +34,6 @@ k))) (syntax: .public (pending [expr <code>.any]) - {#.doc (example "Turns any expression into a function that is pending a continuation." - (pending (some_function some_input)))} (with_identifiers [g!_ g!k] (in (list (` (.function ((~ g!_) (~ g!k)) ((~ g!k) (~ expr)))))))) @@ -61,7 +55,8 @@ (All [o] (Functor (All [i] (Cont i o)))) (def: (map f fv) - (function (_ k) (fv (function.compose k f))))) + (function (_ k) + (fv (function.composite k f))))) (implementation: .public apply (All [o] (Apply (All [i] (Cont i o)))) @@ -84,7 +79,7 @@ (def: (join ffa) (function (_ k) - (ffa (continue k))))) + (ffa (continued k))))) (def: .public (portal init) (All [i o z] @@ -92,9 +87,10 @@ (Cont [(-> i (Cont o z)) i] z))) - (call/cc (function (_ k) - (do ..monad - [.let [nexus (function (nexus val) - (k [nexus val]))] - _ (k [nexus init])] - (in (undefined)))))) + (with_current + (function (_ k) + (do ..monad + [.let [nexus (function (nexus val) + (k [nexus val]))] + _ (k [nexus init])] + (in (undefined)))))) diff --git a/stdlib/source/library/lux/control/exception.lux b/stdlib/source/library/lux/control/exception.lux index 9a9e7f845..f89611e19 100644 --- a/stdlib/source/library/lux/control/exception.lux +++ b/stdlib/source/library/lux/control/exception.lux @@ -28,18 +28,14 @@ ["//" try (#+ Try)]]) (type: .public (Exception a) - {#.doc "An exception provides a way to decorate error messages."} {#label Text #constructor (-> a Text)}) (def: .public (match? exception error) - {#.doc (example "Is this exception the cause of the error message?")} (All [e] (-> (Exception e) Text Bit)) (text.starts_with? (get@ #label exception) error)) (def: .public (when exception then try) - {#.doc (example "If a particular exception is detected on a possibly-erroneous value, handle it." - "If no exception was detected, or a different one from the one being checked, then pass along the original value.")} (All [e a] (-> (Exception e) (-> Text a) (Try a) (Try a))) @@ -52,12 +48,11 @@ (if (text.starts_with? reference error) (#//.Success (|> error (text.clip' (text.size reference)) - maybe.assume + maybe.trusted then)) (#//.Failure error))))) (def: .public (otherwise else try) - {#.doc "If no handler could be found to catch the exception, then run a function as a last-resort measure."} (All [a] (-> (-> Text a) (Try a) a)) (case try @@ -68,12 +63,10 @@ (else error))) (def: .public (error exception message) - {#.doc "Constructs an error message from an exception."} (All [e] (-> (Exception e) e Text)) ((get@ #..constructor exception) message)) (def: .public (except exception message) - {#.doc "Decorate an error message with an Exception and lift it into the error-handling context."} (All [e a] (-> (Exception e) e (Try a))) (#//.Failure (..error exception message))) @@ -98,15 +91,9 @@ ))) (syntax: .public (exception: [[export_policy t_vars [name inputs] body] ..exception]) - {#.doc (example "Define a new exception type." - "It mostly just serves as a way to tag error messages for later catching." + {#.doc (example "" - "Simple case:" - (exception: .public some_exception) - "" - "Complex case:" - (exception: .public [arbitrary type variables] (some_exception {optional Text} {arguments Int}) - optional_body))} + )} (macro.with_identifiers [g!descriptor] (do meta.monad [current_module meta.current_module_name @@ -132,14 +119,14 @@ on_new_line (|> " " (list.repeated (n.+ (text.size header_separator) largest_header_size)) - (text.join_with "") + text.joined (text\compose text.new_line)) on_entry (: (-> [Text Text] Text) (function (_ [header message]) (let [padding (|> " " (list.repeated (n.- (text.size header) largest_header_size)) - (text.join_with ""))] + text.joined)] (|> message (text.replaced text.new_line on_new_line) ($_ text\compose padding header header_separator)))))] @@ -154,19 +141,11 @@ tail)))) (syntax: .public (report [entries (<>.many (<code>.tuple (<>.and <code>.any <code>.any)))]) - {#.doc (example "An error report." - (: Text - (report ["Row 0" value/0] - ["Row 1" value/1] - ,,, - ["Row N" value/N])))} (in (list (` ((~! report') (list (~+ (|> entries (list\map (function (_ [header message]) (` [(~ header) (~ message)]))))))))))) (def: .public (listing format entries) - {#.doc (example "A numbered report of the entries on a list." - "NOTE: 0-based numbering.")} (All [a] (-> (-> a Text) (List a) Text)) (|> entries @@ -181,7 +160,7 @@ (def: separator (let [gap ($_ "lux text concat" text.new_line text.new_line) - horizontal_line (|> "-" (list.repeated 64) (text.join_with ""))] + horizontal_line (|> "-" (list.repeated 64) text.joined)] ($_ "lux text concat" gap horizontal_line @@ -195,7 +174,6 @@ error)) (def: .public (with exception message computation) - {#.doc (example "If a computation fails, prepends the exception to the error.")} (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 d0bc286ae..865ea6930 100644 --- a/stdlib/source/library/lux/control/function.lux +++ b/stdlib/source/library/lux/control/function.lux @@ -5,38 +5,24 @@ [monoid (#+ Monoid)]]]]) (def: .public identity - {#.doc (example "Identity function." - "Does nothing to its argument and just returns it." - (same? (identity value) - value))} (All [a] (-> a a)) (|>>)) -(def: .public (compose f g) - {#.doc (example "Function composition." - (= ((compose f g) "foo") - (f (g "foo"))))} +(def: .public (composite f g) (All [a b c] (-> (-> b c) (-> a b) (-> a c))) (|>> g f)) (def: .public (constant value) - {#.doc (example "Create constant functions." - (= ((constant "foo") "bar") - "foo"))} (All [o] (-> o (All [i] (-> i o)))) (function (_ _) value)) (def: .public (flipped f) - {#.doc (example "Flips the order of the arguments of a function." - (= ((flipped f) "foo" "bar") - (f "bar" "foo")))} (All [a b c] (-> (-> a b c) (-> b a c))) (function (_ x y) (f y x))) (def: .public (apply input function) - {#.doc (example "Simple 1-argument function application.")} (All [i o] (-> i (-> i o) o)) (function input)) @@ -45,4 +31,4 @@ (All [a] (Monoid (-> a a))) (def: identity ..identity) - (def: compose ..compose)) + (def: compose ..composite)) diff --git a/stdlib/source/library/lux/control/io.lux b/stdlib/source/library/lux/control/io.lux index 321b7159e..1b3b58f7b 100644 --- a/stdlib/source/library/lux/control/io.lux +++ b/stdlib/source/library/lux/control/io.lux @@ -16,7 +16,7 @@ ["." template]]]]) (abstract: .public (IO a) - {#.doc "A type that represents synchronous, effectful computations that may interact with the outside world."} + {} (-> Any a) @@ -34,17 +34,11 @@ [((:representation io) [])]) (syntax: .public (io [computation <code>.any]) - {#.doc (example "Delays the evaluation of an expression, by wrapping it in an IO 'thunk'." - "Great for wrapping effectful computations (which will not be performed until the IO is 'run!')." - (io (exec - (log! msg) - "Some value...")))} (with_identifiers [g!func g!arg] (in (list (` ((~! ..label) (function ((~ g!func) (~ g!arg)) (~ computation)))))))) (def: .public run! - {#.doc "A way to execute IO computations and perform their side-effects."} (All [a] (-> (IO a) a)) (|>> run!')) diff --git a/stdlib/source/library/lux/control/lazy.lux b/stdlib/source/library/lux/control/lazy.lux index dec12c5f5..46901a3c1 100644 --- a/stdlib/source/library/lux/control/lazy.lux +++ b/stdlib/source/library/lux/control/lazy.lux @@ -18,8 +18,7 @@ abstract]]]) (abstract: .public (Lazy a) - {#.doc (example "A value specified by an expression that is calculated only at the last moment possible." - "Afterwards, the value is cached for future reference.")} + {} (-> [] a) @@ -42,7 +41,6 @@ ((:representation lazy) []))) (syntax: .public (lazy [expression <code>.any]) - {#.doc (example "Specifies a lazy value by providing the expression that computes it.")} (with_identifiers [g!_] (in (list (` ((~! lazy') (function ((~ g!_) (~ g!_)) (~ expression)))))))) diff --git a/stdlib/source/library/lux/control/maybe.lux b/stdlib/source/library/lux/control/maybe.lux index 2d9b56039..74b5f06d2 100644 --- a/stdlib/source/library/lux/control/maybe.lux +++ b/stdlib/source/library/lux/control/maybe.lux @@ -96,7 +96,8 @@ (implementation: .public (with monad) (All [M] (-> (Monad M) (Monad (All [a] (M (Maybe a)))))) - (def: &functor (functor.compose (get@ #monad.&functor monad) ..functor)) + (def: &functor + (functor.composite (get@ #monad.&functor monad) ..functor)) (def: in (|>> (\ ..monad in) (\ monad in))) @@ -110,22 +111,11 @@ (#.Some Mma) Mma)))) -(def: .public (lift monad) - {#.doc (example "Wraps a monadic value with Maybe machinery.")} +(def: .public (lifted monad) (All [M a] (-> (Monad M) (-> (M a) (M (Maybe a))))) (\ monad map (\ ..monad in))) (macro: .public (else tokens state) - {#.doc (example "Allows you to provide a default value that will be used" - "if a (Maybe x) value turns out to be #.None." - "Note: the expression for the default value will not be computed if the base computation succeeds." - (else +20 (#.Some +10)) - "=>" - +10 - -------------------------- - (else +20 #.None) - "=>" - +20)} (case tokens (^ (.list else maybe)) (let [g!temp (: Code [location.dummy (#.Identifier ["" ""])])] @@ -139,10 +129,7 @@ _ (#.Left "Wrong syntax for else"))) -(def: .public assume - {#.doc (example "Assumes that a Maybe value is a #.Some and yields its value." - "Raises/throws a runtime error otherwise." - "WARNING: Use with caution.")} +(def: .public trusted (All [a] (-> (Maybe a) a)) (|>> (..else (undefined)))) @@ -156,11 +143,6 @@ (#.Item value #.End))) (macro: .public (when tokens state) - {#.doc (example "Can be used as a guard in (co)monadic be/do expressions." - (do monad - [value (do_something 1 2 3) - ..when (passes_test? value)] - (do_something_else 4 5 6)))} (case tokens (^ (.list test then)) (#.Right [state (.list (` (.if (~ test) diff --git a/stdlib/source/library/lux/control/parser.lux b/stdlib/source/library/lux/control/parser.lux index 4c86373f5..f4e304045 100644 --- a/stdlib/source/library/lux/control/parser.lux +++ b/stdlib/source/library/lux/control/parser.lux @@ -230,7 +230,7 @@ (function (_ input) (#try.Failure message))) -(def: .public (lift operation) +(def: .public (lifted operation) {#.doc (example "Lift a potentially failed computation into a parser.")} (All [s a] (-> (Try a) (Parser s a))) (function (_ input) diff --git a/stdlib/source/library/lux/control/parser/analysis.lux b/stdlib/source/library/lux/control/parser/analysis.lux index 94e7ca9c1..fb32f4608 100644 --- a/stdlib/source/library/lux/control/parser/analysis.lux +++ b/stdlib/source/library/lux/control/parser/analysis.lux @@ -37,8 +37,7 @@ (format text.new_line "Remaining input: " (|> asts (list\map /.%analysis) - (list.interposed " ") - (text.join_with "")))) + (text.interposed " ")))) (exception: .public (cannot_parse {input (List Analysis)}) (exception.report diff --git a/stdlib/source/library/lux/control/parser/binary.lux b/stdlib/source/library/lux/control/parser/binary.lux index 7cf526d41..d2d195888 100644 --- a/stdlib/source/library/lux/control/parser/binary.lux +++ b/stdlib/source/library/lux/control/parser/binary.lux @@ -121,7 +121,7 @@ (^template [<number> <tag> <parser>] [<number> (\ ! map (|>> <tag>) <parser>)]) ((~~ (template.spliced <case>+))) - _ (//.lift (exception.except ..invalid_tag [(~~ (template.amount <case>+)) flag])))))]) + _ (//.lifted (exception.except ..invalid_tag [(~~ (template.amount <case>+)) flag])))))]) (def: .public (or left right) (All [l r] (-> (Parser l) (Parser r) (Parser (Or l r)))) @@ -153,7 +153,7 @@ (case value 0 (in #0) 1 (in #1) - _ (//.lift (exception.except ..not_a_bit [value]))))) + _ (//.lifted (exception.except ..not_a_bit [value]))))) (def: .public (segment size) {#.doc (example "Parses a chunk of data of a given size.")} @@ -185,7 +185,7 @@ (Parser Text) (do //.monad [utf8 <binary>] - (//.lift (\ utf8.codec decode utf8)))))] + (//.lifted (\ utf8.codec decode utf8)))))] [08 utf8/8 ..binary/8] [16 utf8/16 ..binary/16] diff --git a/stdlib/source/library/lux/control/parser/cli.lux b/stdlib/source/library/lux/control/parser/cli.lux index cc9bf19ab..3dd50a349 100644 --- a/stdlib/source/library/lux/control/parser/cli.lux +++ b/stdlib/source/library/lux/control/parser/cli.lux @@ -24,7 +24,7 @@ (#try.Success output) _ - (#try.Failure (format "Remaining CLI inputs: " (text.join_with " " remaining)))) + (#try.Failure (format "Remaining CLI inputs: " (text.interposed " " remaining)))) (#try.Failure try) (#try.Failure try))) @@ -85,7 +85,7 @@ (function (_ inputs) (case inputs #.End (#try.Success [inputs []]) - _ (#try.Failure (format "Unknown parameters: " (text.join_with " " inputs)))))) + _ (#try.Failure (format "Unknown parameters: " (text.interposed " " inputs)))))) (def: .public (named name value) {#.doc (example "Parses a named parameter and yields its value.")} diff --git a/stdlib/source/library/lux/control/parser/code.lux b/stdlib/source/library/lux/control/parser/code.lux index d22039f4a..93a2f65d9 100644 --- a/stdlib/source/library/lux/control/parser/code.lux +++ b/stdlib/source/library/lux/control/parser/code.lux @@ -31,10 +31,11 @@ {#.doc "A Lux code parser."} (//.Parser (List Code))) -(def: (remaining_inputs codes) +(def: remaining_inputs (-> (List Code) Text) - ($_ text\compose text.new_line "Remaining input: " - (|> codes (list\map code.format) (list.interposed " ") (text.join_with "")))) + (|>> (list\map code.format) + (text.interposed " ") + ($_ text\compose text.new_line "Remaining input: "))) (def: .public any {#.doc "Yields the next input without applying any logic."} @@ -189,9 +190,10 @@ (#try.Success value) _ - (#try.Failure (text\compose "Unconsumed inputs: " - (|> (list\map code.format unconsumed) - (text.join_with ", "))))))) + (#try.Failure (|> unconsumed + (list\map code.format) + (text.interposed ", ") + (text\compose "Unconsumed inputs: ")))))) (def: .public (local inputs parser) {#.doc "Runs parser against the given list of inputs."} diff --git a/stdlib/source/library/lux/control/parser/text.lux b/stdlib/source/library/lux/control/parser/text.lux index ffe6e6f27..fb2c59128 100644 --- a/stdlib/source/library/lux/control/parser/text.lux +++ b/stdlib/source/library/lux/control/parser/text.lux @@ -39,7 +39,7 @@ (def: (remaining' offset tape) (-> Offset Text Text) - (|> tape (/.split_at offset) maybe.assume product.right)) + (|> tape (/.split_at offset) maybe.trusted product.right)) (exception: .public (unconsumed_input {offset Offset} {tape Text}) (exception.report @@ -174,7 +174,7 @@ (-> Nat Nat (Parser Text)) (do //.monad [char any - .let [char' (maybe.assume (/.char 0 char))] + .let [char' (maybe.trusted (/.char 0 char))] _ (//.assertion ($_ /\compose "Character is not within range: " (/.of_char bottom) "-" (/.of_char top)) (.and (n.>= bottom char') (n.<= top char')))] @@ -392,4 +392,4 @@ (//.Parser s a))) (do //.monad [raw text] - (//.lift (..result structured raw)))) + (//.lifted (..result structured raw)))) diff --git a/stdlib/source/library/lux/control/parser/type.lux b/stdlib/source/library/lux/control/parser/type.lux index 619526cdb..8016080b5 100644 --- a/stdlib/source/library/lux/control/parser/type.lux +++ b/stdlib/source/library/lux/control/parser/type.lux @@ -58,7 +58,7 @@ (exception.report ["Types" (|> remaining (list\map (|>> %.type (format text.new_line "* "))) - (text.join_with ""))])) + (text.interposed ""))])) (type: .public Env {#.doc (example "An environment for type parsing.")} diff --git a/stdlib/source/library/lux/control/reader.lux b/stdlib/source/library/lux/control/reader.lux index 73737cb54..09fcd2058 100644 --- a/stdlib/source/library/lux/control/reader.lux +++ b/stdlib/source/library/lux/control/reader.lux @@ -57,9 +57,11 @@ {#.doc "Monad transformer for Reader."} (All [M] (-> (Monad M) (All [e] (Monad (All [a] (Reader e (M a))))))) - (def: &functor (functor.compose ..functor (get@ #monad.&functor monad))) + (def: &functor + (functor.composite ..functor (get@ #monad.&functor monad))) - (def: in (|>> (\ monad in) (\ ..monad in))) + (def: in + (|>> (\ monad in) (\ ..monad in))) (def: (join eMeMa) (function (_ env) @@ -67,7 +69,7 @@ [eMa (result env eMeMa)] (result env eMa))))) -(def: .public lift +(def: .public lifted {#.doc "Lift monadic values to the Reader wrapper."} (All [M e a] (-> (M a) (Reader e (M a)))) (\ ..monad in)) diff --git a/stdlib/source/library/lux/control/region.lux b/stdlib/source/library/lux/control/region.lux index ba3962400..191c6a328 100644 --- a/stdlib/source/library/lux/control/region.lux +++ b/stdlib/source/library/lux/control/region.lux @@ -154,7 +154,7 @@ (All [r] (Region r ! a)))) (failure monad (exception.error exception message))) -(def: .public (lift monad operation) +(def: .public (lifted monad operation) {#.doc (example "Lift an effectful computation into a region-based computation.")} (All [! a] (-> (Monad !) (! a) diff --git a/stdlib/source/library/lux/control/state.lux b/stdlib/source/library/lux/control/state.lux index 9cb56fb89..470751832 100644 --- a/stdlib/source/library/lux/control/state.lux +++ b/stdlib/source/library/lux/control/state.lux @@ -142,7 +142,7 @@ [[state' sMa] (sMsMa state)] (sMa state'))))) -(def: .public (lift monad ma) +(def: .public (lifted monad ma) {#.doc "Lift monadic values to the +State wrapper."} (All [M s a] (-> (Monad M) (M a) (+State M s a))) (function (_ state) diff --git a/stdlib/source/library/lux/control/try.lux b/stdlib/source/library/lux/control/try.lux index 7e785b6fa..c7dc9f1d9 100644 --- a/stdlib/source/library/lux/control/try.lux +++ b/stdlib/source/library/lux/control/try.lux @@ -65,7 +65,7 @@ (All [!] (-> (Monad !) (Monad (All [a] (! (Try a)))))) (def: &functor - (functor.compose (get@ #monad.&functor monad) ..functor)) + (functor.composite (get@ #monad.&functor monad) ..functor)) (def: in (|>> (\ ..monad in) @@ -101,7 +101,7 @@ false ))) -(def: .public (assumed try) +(def: .public (trusted try) {#.doc (example "Assumes a Try value succeeded, and yields its value." "If it didn't, raises the error as a runtime error." "WARNING: Use with caution.")} diff --git a/stdlib/source/library/lux/control/writer.lux b/stdlib/source/library/lux/control/writer.lux index fe7511a68..18a0fc7e1 100644 --- a/stdlib/source/library/lux/control/writer.lux +++ b/stdlib/source/library/lux/control/writer.lux @@ -55,8 +55,8 @@ (All [l M] (-> (Monoid l) (Monad M) (Monad (All [a] (M (Writer l a)))))) (def: &functor - (functor.compose (get@ #monad.&functor monad) - ..functor)) + (functor.composite (get@ #monad.&functor monad) + ..functor)) (def: in (let [writer (..monad monoid)] @@ -72,7 +72,7 @@ [l2 a] Mla] (in [(\ monoid compose l1 l2) a])))) -(def: .public (lift monoid monad) +(def: .public (lifted monoid monad) {#.doc (example "Wraps a monadic value with Writer machinery.")} (All [l M a] (-> (Monoid l) (Monad M) diff --git a/stdlib/source/library/lux/data/bit.lux b/stdlib/source/library/lux/data/bit.lux index 22ff7fe2f..efdca1f5b 100644 --- a/stdlib/source/library/lux/data/bit.lux +++ b/stdlib/source/library/lux/data/bit.lux @@ -64,4 +64,4 @@ {#.doc (example "Generates the complement of a predicate." "That is a predicate that returns the oposite of the original predicate.")} (All [a] (-> (-> a Bit) (-> a Bit))) - (function.compose not)) + (function.composite not)) diff --git a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux index e6b05bf51..84e883b1d 100644 --- a/stdlib/source/library/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/library/lux/data/collection/dictionary/ordered.lux @@ -266,7 +266,7 @@ outcome (recur side_root)] (if (same? side_root outcome) ?root - (#.Some (<add> (maybe.assume outcome) + (#.Some (<add> (maybe.trusted outcome) root))))] [_\< #left ..with_left] diff --git a/stdlib/source/library/lux/data/collection/list.lux b/stdlib/source/library/lux/data/collection/list.lux index 7298a5039..8cba7efb2 100644 --- a/stdlib/source/library/lux/data/collection/list.lux +++ b/stdlib/source/library/lux/data/collection/list.lux @@ -592,9 +592,11 @@ {#.doc (.example "Enhances a monad with List functionality.")} (All [M] (-> (Monad M) (Monad (All [a] (M (List a)))))) - (def: &functor (functor.compose (get@ #monad.&functor monad) ..functor)) + (def: &functor + (functor.composite (get@ #monad.&functor monad) ..functor)) - (def: in (|>> (\ ..monad in) (\ monad in))) + (def: in + (|>> (\ ..monad in) (\ monad in))) (def: (join MlMla) (do {! monad} @@ -606,7 +608,7 @@ (monad.seq ! lMla))] (in (..joined lla))))) -(def: .public (lift monad) +(def: .public (lifted monad) {#.doc (.example "Wraps a monadic value with List machinery.")} (All [M a] (-> (Monad M) (-> (M a) (M (List a))))) (\ monad map (\ ..monad in))) diff --git a/stdlib/source/library/lux/data/collection/row.lux b/stdlib/source/library/lux/data/collection/row.lux index 230de34a1..6a4b88587 100644 --- a/stdlib/source/library/lux/data/collection/row.lux +++ b/stdlib/source/library/lux/data/collection/row.lux @@ -126,13 +126,13 @@ (array.copy! tail_size 0 tail 0) (array.write! tail_size val)))) -(def: (put' level idx val hierarchy) +(def: (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.read! sub_idx hierarchy) (#.Some (#Hierarchy sub_node)) (|> (array.clone hierarchy) - (array.write! sub_idx (#Hierarchy (put' (level_down level) idx val sub_node)))) + (array.write! sub_idx (#Hierarchy (has' (level_down level) idx val sub_node)))) (^multi (#.Some (#Base base)) (n.= 0 (level_down level))) @@ -279,7 +279,7 @@ #.None (exception.except ..incorrect_row_structure [])))) -(def: .public (put idx val row) +(def: .public (has idx val row) (All [a] (-> Nat a (Row a) (Try (Row a)))) (let [row_size (get@ #size row)] (if (within_bounds? row idx) @@ -289,7 +289,7 @@ (|>> array.clone (array.write! (branch_idx idx) val)))} (|>> array.clone (array.write! (branch_idx idx) val))) row) - (update@ #root (put' (get@ #level row) idx val) + (update@ #root (has' (get@ #level row) idx val) row))) (exception.except ..index_out_of_bounds [row idx])))) @@ -297,7 +297,7 @@ (All [a] (-> Nat (-> a a) (Row a) (Try (Row a)))) (do try.monad [val (..item idx row)] - (..put idx (f val) row))) + (..has idx (f val) row))) (def: .public (pop row) (All [a] (-> (Row a) (Row a))) @@ -316,7 +316,7 @@ (update@ #size dec) (set@ #tail (|> (array.empty new_tail_size) (array.copy! new_tail_size 0 old_tail 0))))) - (maybe.assume + (maybe.trusted (do maybe.monad [new_tail (base_for (n.- 2 row_size) row) .let [[level' root'] (let [init_level (get@ #level row)] diff --git a/stdlib/source/library/lux/data/collection/sequence.lux b/stdlib/source/library/lux/data/collection/sequence.lux index d60fd99d4..a7d2cc0b4 100644 --- a/stdlib/source/library/lux/data/collection/sequence.lux +++ b/stdlib/source/library/lux/data/collection/sequence.lux @@ -23,11 +23,12 @@ {#.doc "An infinite sequence of values."} (Cont [a (Sequence a)])) -(def: .public (iterations f x) - {#.doc "Create a sequence by applying a function to a value, and to its result, on and on..."} - (All [a] - (-> (-> a a) a (Sequence a))) - (//.pending [x (iterations f (f x))])) +(def: .public (iterations step init) + {#.doc "A stateful way of infinitely calculating the values of a sequence."} + (All [a b] + (-> (-> a [a b]) a (Sequence b))) + (let [[next x] (step init)] + (//.pending [x (iterations step next)]))) (def: .public (repeated x) {#.doc "Repeat a value forever."} @@ -101,13 +102,6 @@ [split_at Nat (n.= 0 pred) (dec pred)] ) -(def: .public (unfold step init) - {#.doc "A stateful way of infinitely calculating the values of a sequence."} - (All [a b] - (-> (-> a [a b]) a (Sequence b))) - (let [[next x] (step init)] - (//.pending [x (unfold step next)]))) - (def: .public (only predicate sequence) {#.doc (example "A new sequence only with items that satisfy the predicate.")} (All [a] (-> (-> a Bit) (Sequence a) (Sequence a))) diff --git a/stdlib/source/library/lux/data/format/binary.lux b/stdlib/source/library/lux/data/format/binary.lux index e16c2cebd..e23ade3fb 100644 --- a/stdlib/source/library/lux/data/format/binary.lux +++ b/stdlib/source/library/lux/data/format/binary.lux @@ -78,7 +78,7 @@ [(n.+ <size> offset) (|> binary (<write> offset value) - try.assumed)])]))] + try.trusted)])]))] [bits/8 /.size/8 binary.write/8!] [bits/16 /.size/16 binary.write/16!] @@ -97,7 +97,7 @@ (function (_ [offset binary]) (|> binary (binary.write/8! offset <number>) - try.assumed + try.trusted [(.inc offset)] caseT))])]) ([0 #.Left left] @@ -142,7 +142,7 @@ [size (function (_ [offset binary]) [(n.+ size offset) - (try.assumed + (try.trusted (binary.copy (n.min size (binary.size value)) 0 value @@ -159,7 +159,7 @@ [size' (function (_ [offset binary]) [(n.+ size' offset) - (try.assumed + (try.trusted (do try.monad [_ (<write> offset size binary)] (binary.copy size 0 value (n.+ <size> offset) binary)))])]))))] @@ -202,7 +202,7 @@ specification\identity))] [(n.+ <size> size) (function (_ [offset binary]) - (try.assumed + (try.trusted (do try.monad [_ (<write> offset capped_count binary)] (in (mutation [(n.+ <size> offset) binary])))))])))] @@ -247,7 +247,7 @@ (function (_ [offset binary]) (|> binary (binary.write/8! offset <number>) - try.assumed + try.trusted [(.inc offset)] caseT))])]) ([0 #.Primitive (..and ..text (..list recur))] @@ -282,7 +282,7 @@ (function (_ [offset binary]) (|> binary (binary.write/8! offset <number>) - try.assumed + try.trusted [(.inc offset)] caseT))])]) ([0 #.Bit ..bit] diff --git a/stdlib/source/library/lux/data/format/css.lux b/stdlib/source/library/lux/data/format/css.lux index d86deb7e5..7ec9a0d35 100644 --- a/stdlib/source/library/lux/data/format/css.lux +++ b/stdlib/source/library/lux/data/format/css.lux @@ -67,7 +67,7 @@ with_unicode) (list\map (function (_ [property value]) (format property ": " value ";"))) - (text.join_with /style.separator) + (text.interposed /style.separator) (text.enclosed ["{" "}"]) (format "@font-face") :abstraction))) @@ -98,7 +98,7 @@ (format (/value.percentage (get@ #when frame)) " {" (/style.inline (get@ #what frame)) "}"))) - (text.join_with ..css_separator)) + (text.interposed ..css_separator)) "}"))) (template: (!compose <pre> <post>) @@ -115,7 +115,7 @@ :representation (text.all_split_by ..css_separator) (list\map (|>> (format (/selector.selector (|> selector (combinator (/selector.tag ""))))))) - (text.join_with ..css_separator) + (text.interposed ..css_separator) :abstraction)) (def: .public (dependent combinator selector style inner) diff --git a/stdlib/source/library/lux/data/format/css/value.lux b/stdlib/source/library/lux/data/format/css/value.lux index c2fb914c2..0c8e8f70f 100644 --- a/stdlib/source/library/lux/data/format/css/value.lux +++ b/stdlib/source/library/lux/data/format/css/value.lux @@ -61,7 +61,7 @@ (let [raw (%.frac value)] (if (f.< +0.0 value) raw - (|> raw (text.split_at 1) maybe.assume product.right)))) + (|> raw (text.split_at 1) maybe.trusted product.right)))) (abstract: .public (Value brand) {} @@ -786,7 +786,7 @@ (def: (apply name inputs) (-> Text (List Text) Value) (|> inputs - (text.join_with ..value_separator) + (text.interposed ..value_separator) (text.enclosed ["(" ")"]) (format name) :abstraction)) @@ -1042,7 +1042,7 @@ (|> blur (maybe.else ..default_shadow_length) :representation) (|> spread (maybe.else ..default_shadow_length) :representation) (:representation color)) - (text.join_with " ") + (text.interposed " ") (list) (..apply "drop-shadow"))) @@ -1119,7 +1119,7 @@ (|> spread (maybe.else ..default_shadow_length) :representation) (:representation color) with_inset) - (text.join_with " ") + (text.interposed " ") :abstraction))) (type: .public Rectangle @@ -1172,7 +1172,7 @@ (#.Item _) (|> options (list\map ..font_name) - (text.join_with ",") + (text.interposed ",") (:abstraction Value)) #.End @@ -1212,9 +1212,9 @@ (:abstraction "."))] (|>> (list\map (|>> (list\map (|>> (maybe.else empty) :representation)) - (text.join_with ..grid_column_separator) + (text.interposed ..grid_column_separator) (text.enclosed ["'" "'"]))) - (text.join_with ..grid_row_separator) + (text.interposed ..grid_row_separator) :abstraction))) (def: .public (resolution dpi) @@ -1248,7 +1248,7 @@ (-> [Quote Quote] [Quote Quote] (Value Quotes)) (|> (list left0 right0 left1 right1) (list\map (|>> ..quote_text %.text)) - (text.join_with ..quote_separator) + (text.interposed ..quote_separator) :abstraction)) (def: .public (matrix_2d [a b] [c d] [tx ty]) diff --git a/stdlib/source/library/lux/data/format/html.lux b/stdlib/source/library/lux/data/format/html.lux index 3c3566a56..3a8daf5c0 100644 --- a/stdlib/source/library/lux/data/format/html.lux +++ b/stdlib/source/library/lux/data/format/html.lux @@ -64,7 +64,7 @@ (-> Attributes Text) (|>> (list\map (function (_ [key val]) (format key "=" text.double_quote (..safe val) text.double_quote))) - (text.join_with " "))) + (text.interposed " "))) (def: (open tag attributes) (-> Tag Attributes Text) @@ -259,7 +259,7 @@ (Format Polygon) (|> (list& first second third extra) (list\map %coord) - (text.join_with ..coord_separator))) + (text.interposed ..coord_separator))) (type: .public Shape (#Rectangle Rectangle) diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux index 7f6ca24a8..c6a7ebef0 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -227,7 +227,7 @@ value (let [raw (\ f.decimal encode value)] (if (f.< +0.0 value) raw - (|> raw (text.split_at 1) maybe.assume product.right)))))) + (|> raw (text.split_at 1) maybe.trusted product.right)))))) (def: escape "\") (def: escaped_dq (text\compose ..escape text.double_quote)) @@ -256,7 +256,7 @@ (-> (-> JSON Text) (-> Array Text)) (|>> (row\map format) row.list - (text.join_with ..value_separator) + (text.interposed ..value_separator) (text.enclosed [..array_start ..array_end]))) (def: (kv_format format [key value]) @@ -271,7 +271,7 @@ (-> (-> JSON Text) (-> Object Text)) (|>> dictionary.entries (list\map (..kv_format format)) - (text.join_with ..value_separator) + (text.interposed ..value_separator) (text.enclosed [..object_start ..object_end]))) (def: .public (format json) diff --git a/stdlib/source/library/lux/data/format/markdown.lux b/stdlib/source/library/lux/data/format/markdown.lux index 281425105..11254a92c 100644 --- a/stdlib/source/library/lux/data/format/markdown.lux +++ b/stdlib/source/library/lux/data/format/markdown.lux @@ -93,7 +93,7 @@ (if (text.empty? line) line (format with line)))) - (text.join_with text.new_line))) + (text.interposed text.new_line))) (def: indent (-> Text Text) @@ -121,7 +121,7 @@ #.None "")))) - (text.join_with text.new_line) + (text.interposed text.new_line) ..block)) (def: .public bullet_list @@ -139,7 +139,7 @@ #.None "")))) - (text.join_with text.new_line) + (text.interposed text.new_line) ..block)) (def: .public snippet diff --git a/stdlib/source/library/lux/data/format/tar.lux b/stdlib/source/library/lux/data/format/tar.lux index 8dd91b2ee..7f1346df1 100644 --- a/stdlib/source/library/lux/data/format/tar.lux +++ b/stdlib/source/library/lux/data/format/tar.lux @@ -44,7 +44,7 @@ max_size) padding (|> "0" (list.repeated padding_size) - (text.join_with ""))] + text.joined)] (format padding number))) (def: blank " ") @@ -132,9 +132,9 @@ (Parser Small) (do <>.monad [digits (<binary>.segment ..small_size) - digits (<>.lift (\ utf8.codec decode digits)) + digits (<>.lifted (\ utf8.codec decode digits)) _ ..small_suffix] - (<>.lift + (<>.lifted (do {! try.monad} [value (\ n.octal decode digits)] (..small value))))) @@ -143,12 +143,12 @@ (Parser Big) (do <>.monad [digits (<binary>.segment ..big_size) - digits (<>.lift (\ utf8.codec decode digits)) + digits (<>.lifted (\ utf8.codec decode digits)) end <binary>.bits/8 _ (let [expected (`` (char (~~ (static ..blank))))] (<>.assertion (exception.error ..wrong_character [expected end]) (n.= expected end)))] - (<>.lift + (<>.lifted (do {! try.monad} [value (\ n.octal decode digits)] (..big value))))) @@ -201,9 +201,9 @@ (Parser [Nat Checksum]) (do <>.monad [ascii (<binary>.segment ..small_size) - digits (<>.lift (\ utf8.codec decode ascii)) + digits (<>.lifted (\ utf8.codec decode ascii)) _ ..small_suffix - value (<>.lift + value (<>.lifted (\ n.octal decode digits))] (in [value (:abstraction (format digits ..checksum_suffix))]))) @@ -285,7 +285,7 @@ .let [expected (`` (char (~~ (static ..null))))] _ (<>.assertion (exception.error ..wrong_character [expected end]) (n.= expected end))] - (<>.lift + (<>.lifted (do {! try.monad} [ascii (..un_padded string) text (\ utf8.codec decode ascii)] @@ -293,7 +293,7 @@ (def: .public <none> <type> - (try.assumed (<in> ""))) + (try.trusted (<in> ""))) )] [Name Text ..name_size name_is_too_long name from_name name_writer name_parser anonymous] @@ -329,7 +329,7 @@ .let [expected (`` (char (~~ (static ..null))))] _ (<>.assertion (exception.error ..wrong_character [expected end]) (n.= expected end))] - (<>.lift + (<>.lifted (\ try.monad map (|>> :abstraction) (\ utf8.codec decode string))))) ) @@ -436,7 +436,7 @@ (<options>) _ - (<>.lift + (<>.lifted (exception.except ..invalid_link_flag [(.nat linkflag)])))))) ) @@ -459,7 +459,7 @@ (Writer Mode) (|>> :representation ..small - try.assumed + try.trusted ..small_writer)) (exception: .public (invalid_mode {value Nat}) @@ -520,7 +520,7 @@ (if (n.<= (:representation ..maximum_mode) value) (in (:abstraction value)) - (<>.lift + (<>.lifted (exception.except ..invalid_mode [value])))))) ) @@ -584,7 +584,7 @@ (def: no_device Device - (try.assumed (..small 0))) + (try.trusted (..small 0))) (type: .public Tar (Row Entry)) @@ -777,7 +777,7 @@ modification_time ..big_parser [actual checksum_code] ..checksum_parser _ (let [expected (expected_checksum checksum_code binary_header)] - (<>.lift + (<>.lifted (exception.assertion ..wrong_checksum [expected actual] (n.= expected actual)))) link_flag ..link_flag_parser @@ -817,7 +817,7 @@ .let [size (get@ #size header) rounded_size (..rounded_content_size size)] content (<binary>.segment (..from_big size)) - content (<>.lift (..content content)) + content (<>.lifted (..content content)) _ (<binary>.segment (n.- (..from_big size) rounded_size))] (in [(get@ #path header) (|> header @@ -838,7 +838,7 @@ (-> Link_Flag (-> Header Path) (Parser Path)) (do <>.monad [header ..header_parser - _ (<>.lift + _ (<>.lifted (exception.assertion ..wrong_link_flag [expected (get@ #link_flag header)] (n.= (..link_flag expected) (..link_flag (get@ #link_flag header)))))] @@ -864,7 +864,7 @@ (do <>.monad [block (<binary>.segment ..block_size)] (let [actual (..checksum block)] - (<>.lift + (<>.lifted (exception.assertion ..wrong_checksum [0 actual] (n.= 0 actual)))))) @@ -875,7 +875,7 @@ (do <>.monad [_ (<>.at_most 2 end_of_archive_block_parser) done? <binary>.end?] - (<>.lift + (<>.lifted (exception.assertion ..invalid_end_of_archive [] done?)))) diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux index 637ba71f7..67722607c 100644 --- a/stdlib/source/library/lux/data/format/xml.lux +++ b/stdlib/source/library/lux/data/format/xml.lux @@ -239,7 +239,7 @@ dictionary.entries (list\map (function (_ [key value]) ($_ text\compose (..attribute key) "=" text.double_quote (sanitize_value value) text.double_quote))) - (text.join_with " "))))] + (text.interposed " "))))] (function (_ input) ($_ text\compose ..xml_header text.new_line @@ -269,7 +269,7 @@ ($_ text\compose prefix "<" tag attrs ">" (|> xml_children (list\map (|>> (recur (text\compose prefix text.tab)) (text\compose text.new_line))) - (text.join_with "")) + text.joined) text.new_line prefix "</" tag ">"))))) )))) (def: decode diff --git a/stdlib/source/library/lux/data/text.lux b/stdlib/source/library/lux/data/text.lux index e2f781d64..2670bdae3 100644 --- a/stdlib/source/library/lux/data/text.lux +++ b/stdlib/source/library/lux/data/text.lux @@ -297,7 +297,7 @@ (|>> list.reversed (list\fold compose identity)))) -(def: .public (join_with separator texts) +(def: .public (interposed separator texts) (-> Text (List Text) Text) (case separator "" (..joined texts) diff --git a/stdlib/source/library/lux/data/text/escape.lux b/stdlib/source/library/lux/data/text/escape.lux index fe56f754b..f46331176 100644 --- a/stdlib/source/library/lux/data/text/escape.lux +++ b/stdlib/source/library/lux/data/text/escape.lux @@ -23,7 +23,7 @@ (template [<char> <sigil>] [(def: <char> - (|> <sigil> (//.char 0) maybe.assume))] + (|> <sigil> (//.char 0) maybe.trusted))] [sigil_char ..sigil] [\u_sigil "u"] @@ -31,7 +31,7 @@ (template [<literal> <sigil> <escaped>] [(def: <sigil> - (|> <literal> (//.char 0) maybe.assume)) + (|> <literal> (//.char 0) maybe.trusted)) (def: <escaped> (format ..sigil <literal>))] @@ -50,7 +50,7 @@ (template [<char> <text>] [(def: <char> - (|> <text> (//.char 0) maybe.assume))] + (|> <text> (//.char 0) maybe.trusted))] [\0 //.\0] [\a //.\a] diff --git a/stdlib/source/library/lux/data/text/format.lux b/stdlib/source/library/lux/data/text/format.lux index 3438e3f96..1a274b692 100644 --- a/stdlib/source/library/lux/data/text/format.lux +++ b/stdlib/source/library/lux/data/text/format.lux @@ -121,7 +121,7 @@ (def: .public (list formatter) (All [a] (-> (Format a) (Format (List a)))) (|>> (list\map (|>> formatter (format " "))) - (text.join_with "") + text.joined (text.enclosed ["(list" ")"]))) (def: .public (maybe format) diff --git a/stdlib/source/library/lux/data/text/regex.lux b/stdlib/source/library/lux/data/text/regex.lux index 795bee383..4998e9ce9 100644 --- a/stdlib/source/library/lux/data/text/regex.lux +++ b/stdlib/source/library/lux/data/text/regex.lux @@ -52,11 +52,9 @@ (-> Text (Parser Text)) (<>.after (<text>.this reference) (<>\in reference))) -(def: (join_text^ part^) +(def: join_text^ (-> (Parser (List Text)) (Parser Text)) - (do <>.monad - [parts part^] - (in (//.join_with "" parts)))) + (\ <>.monad map //.joined)) (def: name_char^ (Parser Text) @@ -87,9 +85,9 @@ (def: re_range^ (Parser Code) (do {! <>.monad} - [from (|> regex_char^ (\ ! map (|>> (//.char 0) maybe.assume))) + [from (|> regex_char^ (\ ! map (|>> (//.char 0) maybe.trusted))) _ (<text>.this "-") - to (|> regex_char^ (\ ! map (|>> (//.char 0) maybe.assume)))] + to (|> regex_char^ (\ ! map (|>> (//.char 0) maybe.trusted)))] (in (` ((~! <text>.range) (~ (code.nat from)) (~ (code.nat to))))))) (def: re_char^ diff --git a/stdlib/source/library/lux/data/text/unicode/set.lux b/stdlib/source/library/lux/data/text/unicode/set.lux index ab3c1672b..be47d038a 100644 --- a/stdlib/source/library/lux/data/text/unicode/set.lux +++ b/stdlib/source/library/lux/data/text/unicode/set.lux @@ -31,7 +31,7 @@ (Tree :@: Block []) - (def: .public (compose left right) + (def: .public (composite left right) (-> Set Set Set) (:abstraction (\ builder branch @@ -47,7 +47,7 @@ (-> [Block (List Block)] Set) (list\fold (: (-> Block Set Set) (function (_ block set) - (..compose (..singleton block) set))) + (..composite (..singleton block) set))) (..singleton head) tail)) @@ -154,7 +154,7 @@ (def: .public character Set - ($_ ..compose + ($_ ..composite ..character/0 ..character/1 ..character/2 @@ -197,7 +197,7 @@ (def: .public full Set - ($_ ..compose + ($_ ..composite ..character ..non_character )) diff --git a/stdlib/source/library/lux/debug.lux b/stdlib/source/library/lux/debug.lux index 488933f58..8183fb6ff 100644 --- a/stdlib/source/library/lux/debug.lux +++ b/stdlib/source/library/lux/debug.lux @@ -137,7 +137,7 @@ <adaption> array.list (list\map inspection) - (text.join_with " ") + (text.interposed " ") (text.enclosed ["[" "]"]))))) (def: .public (inspection value) diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux index 798bf3056..8651dbdcc 100644 --- a/stdlib/source/library/lux/documentation.lux +++ b/stdlib/source/library/lux/documentation.lux @@ -72,13 +72,15 @@ (def: (padding reference_column [_ old_line old_column] [_ new_line new_column]) (-> Nat Location Location Text) (if (n.= old_line new_line) - (text.joined (list.repeated (n.- old_column new_column) " ")) - (format (if (n.< new_line old_line) - (text.joined (list.repeated (n.- old_line new_line) \n)) - "") - (if (n.< new_column reference_column) - (text.joined (list.repeated (n.- reference_column new_column) " ")) - "")))) + (if (n.< old_column new_column) + "" + (text.joined (list.repeated (n.- old_column new_column) " "))) + (format (if (n.< old_line new_line) + "" + (text.joined (list.repeated (n.- old_line new_line) \n))) + (if (n.< reference_column new_column) + "" + (text.joined (list.repeated (n.- reference_column new_column) " ")))))) (def: un_paired (All [a] (-> (List [a a]) (List a))) @@ -186,7 +188,7 @@ (-> Example Code) (|>> (list\map ..fragment_documentation) (list.interposed ..blank_line) - (text.join_with "") + (text.interposed "") code.text)) (syntax: (minimal_definition_documentation @@ -239,6 +241,7 @@ (type: .public #rec Module {#module Text + #description Text #expected (Set Text) #definitions (List Definition)}) @@ -284,20 +287,23 @@ (|>> (text.all_split_by ..expected_separator) (set.of_list text.hash))) -(def: (module' name expected definitions) - (-> Text Text (List Definition) Module) +(def: (module' name description expected definitions) + (-> Text Text Text (List Definition) Module) {#module name + #description description #expected (..expected expected) #definitions definitions}) (syntax: .public (module [[name _] ..qualified_identifier + description <code>.any definitions (<code>.tuple (<>.some <code>.any)) subs (<code>.tuple (<>.some <code>.any))]) (do meta.monad [expected (meta.exports name)] (in (list (` (: (List Module) - (list& ((~! module') + (list& ((~! ..module') (~ (code.text name)) + (~ description) (~ (code.text (|> expected (list\map product.left) ..expected_format))) @@ -321,6 +327,10 @@ ($_ md.then ... Name (md.heading/1 (get@ #module module)) + ... Description + (<| md.paragraph + md.text + (get@ #description module)) ... Definitions (md.heading/2 "Definitions") (|> module diff --git a/stdlib/source/library/lux/extension.lux b/stdlib/source/library/lux/extension.lux index 0f81e4bda..acc859dba 100644 --- a/stdlib/source/library/lux/extension.lux +++ b/stdlib/source/library/lux/extension.lux @@ -19,33 +19,12 @@ [compiler ["." phase]]]]]) -(type: Input - {#variable Text - #parser Code}) - -(def: (simple default) - (-> Code (Parser Input)) - ($_ <>.and - <c>.local_identifier - (<>\in default))) - -(def: complex - (Parser Input) - (<c>.record ($_ <>.and - <c>.local_identifier - <c>.any))) - -(def: (input default) - (-> Code (Parser Input)) - (<>.either (..simple default) - ..complex)) - (type: Declaration {#name Code #label Text #phase Text #archive Text - #inputs (List Input)}) + #inputs (List Code)}) (def: (declaration default) (-> Code (Parser Declaration)) @@ -54,28 +33,25 @@ <c>.local_identifier <c>.local_identifier <c>.local_identifier - (<>.some (..input default))))) + (<c>.tuple (<>.some <c>.any))))) (template [<any> <end> <and> <result> <extension> <name>] [(syntax: .public (<name> [[name extension phase archive inputs] (..declaration (` <any>)) body <c>.any]) - (let [g!parser (case (list\map product.right inputs) - #.End - (` <end>) - - parsers - (` (.$_ <and> (~+ parsers)))) - g!name (code.local_identifier extension) + (let [g!name (code.local_identifier extension) g!phase (code.local_identifier phase) g!archive (code.local_identifier archive)] - (with_identifiers [g!handler g!inputs g!error] + (with_identifiers [g!handler g!inputs g!error g!_] (in (list (` (<extension> (~ name) (.function ((~ g!handler) (~ g!name) (~ g!phase) (~ g!archive) (~ g!inputs)) - (.case ((~! <result>) (~ g!parser) (~ g!inputs)) - (#.Right [(~+ (list\map (|>> product.left - code.local_identifier) - inputs))]) - (~ body) + (.case ((~! <result>) + ((~! monad.do) (~! <>.monad) + [(~+ inputs) + (~ g!_) <end>] + (.\ (~! <>.monad) (~' in) (~ body))) + (~ g!inputs)) + (#.Right (~ g!_)) + (~ g!_) (#.Left (~ g!error)) ((~! phase.failure) (~ g!error))) diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index 1030a353a..52fdef075 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -1,6 +1,6 @@ (.module: [library - ["." lux (#- Type type int char interface:) + ["." lux (#- Type type int char interface: :as) ["#_." type ("#\." equivalence)] [abstract ["." monad (#+ Monad do)] @@ -1455,8 +1455,8 @@ ... else (let [g!temp (` ((~' ~') (~ (code.identifier ["" " Ω "]))))] (` (let [(~ g!temp) (~ return_term)] - (if (not (..null? (:as (primitive "java.lang.Object") - (~ g!temp)))) + (if (not (..null? (.:as (primitive "java.lang.Object") + (~ g!temp)))) (~ g!temp) (panic! "Cannot produce null references from method calls.")))))) @@ -1729,11 +1729,11 @@ (|>> ("jvm member invoke virtual" [] "java.lang.Class" "isInterface" []) "jvm object cast" (: ..Boolean) - (:as Bit))) + (.:as Bit))) (def: load_class (-> External (Try (primitive "java.lang.Class" [Any]))) - (|>> (:as (primitive "java.lang.String")) + (|>> (.:as (primitive "java.lang.String")) ["Ljava/lang/String;"] ("jvm member invoke static" [] "java.lang.Class" "forName" []) try)) @@ -1897,7 +1897,7 @@ (text.starts_with? descriptor.array_prefix name) (case params #.End - (let [[_ unprefixed] (maybe.assume (text.split_by descriptor.array_prefix name))] + (let [[_ unprefixed] (maybe.trusted (text.split_by descriptor.array_prefix name))] (\ meta.monad map type.array (lux_type->jvm_type (#.Primitive unprefixed (list))))) @@ -2062,8 +2062,8 @@ ["Signature" (..signature type)] ["Reflection" (..reflection type)])) -(syntax: .public (:cast [type (..type^ (list)) - object <code>.any]) +(syntax: .public (:as [type (..type^ (list)) + object <code>.any]) (case [(parser.array? type) (parser.class? type)] (^or [(#.Some _) _] [_ (#.Some _)]) diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index 0e041f5a1..29c286b23 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -299,7 +299,7 @@ (code.identifier ["" name]) (#.Some [pname pbounds]) - (class_type' mode type_params in_array? (maybe.assume (list.head pbounds)))) + (class_type' mode type_params in_array? (maybe.trusted (list.head pbounds)))) (#GenericClass name+params) (generic_class_type' mode type_params in_array? name+params @@ -352,7 +352,7 @@ type_var_class (#.Some [pname pbounds]) - (simple_class$ env (maybe.assume (list.head pbounds)))) + (simple_class$ env (maybe.trusted (list.head pbounds)))) (^or (#GenericWildcard #.None) (#GenericWildcard (#.Some [#LowerBound _]))) type_var_class @@ -451,7 +451,7 @@ (<code>.form (<>.after (<code>.this! (' ::new!)) (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) .let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]] - (in (` ((~ (code.text (format "jvm new" ":" class_name ":" (text.join_with "," arg_decls')))) + (in (` ((~ (code.text (format "jvm new" ":" class_name ":" (text.interposed "," arg_decls')))) (~+ args)))))) (def: (static_method_parser params class_name method_name arg_decls) @@ -462,7 +462,7 @@ (<code>.form (<>.after (<code>.this! (code.identifier ["" dotted_name])) (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) .let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]] - (in (`' ((~ (code.text (format "jvm invokestatic" ":" class_name ":" method_name ":" (text.join_with "," arg_decls')))) + (in (`' ((~ (code.text (format "jvm invokestatic" ":" class_name ":" method_name ":" (text.interposed "," arg_decls')))) (~+ args)))))) (template [<name> <jvm_op>] @@ -474,7 +474,7 @@ (<code>.form (<>.after (<code>.this! (code.identifier ["" dotted_name])) (<code>.tuple (<>.exactly (list.size arg_decls) <code>.any))))) .let [arg_decls' (: (List Text) (list\map (|>> product.right (simple_class$ params)) arg_decls))]] - (in (`' ((~ (code.text (format <jvm_op> ":" class_name ":" method_name ":" (text.join_with "," arg_decls')))) + (in (`' ((~ (code.text (format <jvm_op> ":" class_name ":" method_name ":" (text.interposed "," arg_decls')))) (~' _jvm_this) (~+ args))))))] [special_method_parser "jvm invokespecial"] @@ -949,7 +949,7 @@ (def: spaced (-> (List JVM_Code) JVM_Code) - (text.join_with " ")) + (text.interposed " ")) (def: (privacy_modifier$ pm) (-> Privacy JVM_Code) @@ -972,7 +972,7 @@ (def: (annotation$ [name params]) (-> Annotation JVM_Code) - (format "(" name " " "{" (text.join_with text.tab (list\map annotation_param$ params)) "}" ")")) + (format "(" name " " "{" (text.interposed text.tab (list\map annotation_param$ params)) "}" ")")) (def: (bound_kind$ kind) (-> BoundKind JVM_Code) @@ -1100,7 +1100,7 @@ (in (`' ((~ (code.text (format "jvm invokespecial" ":" (get@ #super_class_name super_class) ":" name - ":" (text.join_with "," arg_decls')))) + ":" (text.interposed "," arg_decls')))) (~' _jvm_this) (~+ args)))))))] (with_parens (spaced (list "override" @@ -1528,7 +1528,7 @@ (#ConstructorDecl [commons _]) (do meta.monad [.let [def_name (code.identifier ["" (..import_name import_format method_prefix (get@ #import_member_alias commons))]) - jvm_extension (code.text (format "jvm new" ":" full_name ":" (text.join_with "," arg_classes))) + jvm_extension (code.text (format "jvm new" ":" full_name ":" (text.interposed "," arg_classes))) jvm_interop (|> (` ((~ jvm_extension) (~+ (jvm_extension_inputs (get@ #import_member_mode commons) arg_classes arg_function_inputs)))) (decorate_return_maybe class member) @@ -1559,7 +1559,7 @@ ["invokeinterface" (list g!obj)] ))) - jvm_extension (code.text (format "jvm " jvm_op ":" full_name ":" import_method_name ":" (text.join_with "," arg_classes))) + jvm_extension (code.text (format "jvm " jvm_op ":" full_name ":" import_method_name ":" (text.interposed "," arg_classes))) jvm_interop (|> [(simple_class$ (list) (get@ #import_method_return method)) (` ((~ jvm_extension) (~+ (list\map un_quote object_ast)) (~+ (jvm_extension_inputs (get@ #import_member_mode commons) arg_classes arg_function_inputs))))] diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux index 2067663ad..cdb788bc9 100644 --- a/stdlib/source/library/lux/macro/syntax.lux +++ b/stdlib/source/library/lux/macro/syntax.lux @@ -114,7 +114,7 @@ ((~ g!body) (~ g!state)) (#.Left (~ g!error)) - (#.Left ((~! text.join_with) (~! text.new_line) (list (~ error_msg) (~ g!error))))} + (#.Left ((~! text.interposed) (~! text.new_line) (list (~ error_msg) (~ g!error))))} ((~! </>.result) (: ((~! </>.Parser) (Meta (List Code))) ((~! do) (~! <>.monad) diff --git a/stdlib/source/library/lux/macro/syntax/definition.lux b/stdlib/source/library/lux/macro/syntax/definition.lux index b0322f507..7ebf281d4 100644 --- a/stdlib/source/library/lux/macro/syntax/definition.lux +++ b/stdlib/source/library/lux/macro/syntax/definition.lux @@ -108,7 +108,7 @@ me_raw (|> raw macro.full_expansion (meta.result compiler) - <>.lift)] + <>.lifted)] (<| (<code>.local me_raw) <code>.form (<>.after (<code>.text! ..extension)) @@ -138,5 +138,5 @@ (in []) (#.Right _) - (<>.lift (exception.except ..lacks_type! [definition])))] + (<>.lifted (exception.except ..lacks_type! [definition])))] (in definition))) diff --git a/stdlib/source/library/lux/macro/template.lux b/stdlib/source/library/lux/macro/template.lux index b5a364ffd..8de4f2501 100644 --- a/stdlib/source/library/lux/macro/template.lux +++ b/stdlib/source/library/lux/macro/template.lux @@ -91,7 +91,7 @@ (text [#0 123 +456 +789.0 "abc" .def ..ghi]) "=>" "#0123+456+789.0abcdefghi")} - (in (list (|> simple (text.join_with "") code.text)))) + (in (list (|> simple (text.interposed "") code.text)))) (template [<a/an> <name> <simple> <complex> <short_example> <full_example>] [(`` (syntax: .public (<name> [name (<>.or (<>.and (..part true) (..part false)) @@ -107,11 +107,11 @@ <full_example>)} (case name (#.Left [simple complex]) - (in (list (<complex> [(text.join_with "" simple) - (text.join_with "" complex)]))) + (in (list (<complex> [(text.interposed "" simple) + (text.interposed "" complex)]))) (#.Right simple) - (in (list (|> simple (text.join_with "") <simple>))))))] + (in (list (|> simple (text.interposed "") <simple>))))))] ["An" identifier code.local_identifier code.identifier abcdefghi diff --git a/stdlib/source/library/lux/math/modulus.lux b/stdlib/source/library/lux/math/modulus.lux index 92d9a5903..3c360bf60 100644 --- a/stdlib/source/library/lux/math/modulus.lux +++ b/stdlib/source/library/lux/math/modulus.lux @@ -55,7 +55,7 @@ "Failure!" (literal 0))} - (meta.lift + (meta.lifted (do try.monad [_ (..modulus divisor)] - (in (list (` ((~! try.assumed) (..modulus (~ (code.int divisor)))))))))) + (in (list (` ((~! try.trusted) (..modulus (~ (code.int divisor)))))))))) diff --git a/stdlib/source/library/lux/math/number/frac.lux b/stdlib/source/library/lux/math/number/frac.lux index 981424626..9e49975f8 100644 --- a/stdlib/source/library/lux/math/number/frac.lux +++ b/stdlib/source/library/lux/math/number/frac.lux @@ -233,7 +233,7 @@ [(def: <name> (|> <hex> (\ //nat.hex decode) - try.assumed + try.trusted <cast>))] [.i64 "FFF8000000000000" not_a_number_bits] diff --git a/stdlib/source/library/lux/math/number/i16.lux b/stdlib/source/library/lux/math/number/i16.lux index 3bbbbe6f4..59d067f31 100644 --- a/stdlib/source/library/lux/math/number/i16.lux +++ b/stdlib/source/library/lux/math/number/i16.lux @@ -10,7 +10,7 @@ ["." i64 (#+ Sub)]]) (def: sub - (maybe.assume (i64.sub 16))) + (maybe.trusted (i64.sub 16))) (def: .public I16 {#.doc (example "A 16-bit integer.")} diff --git a/stdlib/source/library/lux/math/number/i32.lux b/stdlib/source/library/lux/math/number/i32.lux index bd0a705cf..75e6c6ec3 100644 --- a/stdlib/source/library/lux/math/number/i32.lux +++ b/stdlib/source/library/lux/math/number/i32.lux @@ -10,7 +10,7 @@ ["." i64 (#+ Sub)]]) (def: sub - (maybe.assume (i64.sub 32))) + (maybe.trusted (i64.sub 32))) (def: .public I32 {#.doc (example "A 32-bit integer.")} diff --git a/stdlib/source/library/lux/math/number/i64.lux b/stdlib/source/library/lux/math/number/i64.lux index df8d01dbe..fd0c5545b 100644 --- a/stdlib/source/library/lux/math/number/i64.lux +++ b/stdlib/source/library/lux/math/number/i64.lux @@ -169,7 +169,7 @@ (repetitions size "1") (repetitions size "0"))) - high (try.assumed (\ n.binary decode pattern)) + high (try.trusted (\ n.binary decode pattern)) low (..right_rotated size high)] (function (_ value) (..or (..right_shifted size (..and high value)) diff --git a/stdlib/source/library/lux/math/number/i8.lux b/stdlib/source/library/lux/math/number/i8.lux index ba935b2d8..e0721117c 100644 --- a/stdlib/source/library/lux/math/number/i8.lux +++ b/stdlib/source/library/lux/math/number/i8.lux @@ -10,7 +10,7 @@ ["." i64 (#+ Sub)]]) (def: sub - (maybe.assume (i64.sub 8))) + (maybe.trusted (i64.sub 8))) (def: .public I8 {#.doc (example "An 8-bit integer.")} diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index 72f0b2b51..b415adb91 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -298,7 +298,7 @@ (-> (List Text) Text) (|>> ..without_lux_runtime (list.sorted text\<) - (text.join_with ..listing_separator))) + (text.interposed ..listing_separator))) (def: .public (definition name) {#.doc "Looks-up a definition's whole data in the available modules (including the current one)."} @@ -344,7 +344,7 @@ #.None)))))) list.joined (list.sorted text\<) - (text.join_with ..listing_separator)) + (text.interposed ..listing_separator)) imports (|> this_module (get@ #.imports) ..module_listing) @@ -352,7 +352,7 @@ (get@ #.module_aliases) (list\map (function (_ [alias real]) ($_ text\compose alias " => " real))) (list.sorted text\<) - (text.join_with ..listing_separator))] + (text.interposed ..listing_separator))] ($_ text\compose " Candidates: " candidates text.new_line " Imports: " imports text.new_line @@ -536,7 +536,7 @@ " Known tags: " (|> =module (get@ #.tags) (list\map (|>> product.left [module] name\encode (text.prefix text.new_line))) - (text.join_with "")) + text.joined) ))))) (def: .public (tag_lists module) @@ -591,7 +591,7 @@ (function (_ lux) (#try.Success [lux (get@ #.type_context lux)]))) -(def: .public (lift result) +(def: .public (lifted result) (All [a] (-> (Try a) (Meta a))) (case result (#try.Success output) diff --git a/stdlib/source/library/lux/target/common_lisp.lux b/stdlib/source/library/lux/target/common_lisp.lux index b57326480..a53fac36f 100644 --- a/stdlib/source/library/lux/target/common_lisp.lux +++ b/stdlib/source/library/lux/target/common_lisp.lux @@ -147,7 +147,7 @@ (def: .public args (-> (List Var/1) Var/*) (|>> (list\map ..code) - (text.join_with " ") + (text.interposed " ") ..as_form :abstraction)) @@ -160,7 +160,7 @@ (#.Item _) (|> singles (list\map ..code) - (text.join_with " ") + (text.interposed " ") (text.suffix " "))) (format "&rest " (:representation rest)) ..as_form @@ -169,7 +169,7 @@ (def: form (-> (List (Expression Any)) Expression) (|>> (list\map ..code) - (text.join_with " ") + (text.interposed " ") ..as_form :abstraction)) diff --git a/stdlib/source/library/lux/target/js.lux b/stdlib/source/library/lux/target/js.lux index 2e3d62147..95c49a200 100644 --- a/stdlib/source/library/lux/target/js.lux +++ b/stdlib/source/library/lux/target/js.lux @@ -120,7 +120,7 @@ (def: .public array (-> (List Expression) Computation) (|>> (list\map ..code) - (text.join_with ..argument_separator) + (text.interposed ..argument_separator) ..element :abstraction)) @@ -140,7 +140,7 @@ (-> Expression (List Expression) Computation) (|> inputs (list\map ..code) - (text.join_with ..argument_separator) + (text.interposed ..argument_separator) ..expression (format (:representation function)) :abstraction)) @@ -153,7 +153,7 @@ (-> (List [Text Expression]) Computation) (|>> (list\map (.function (_ [key val]) (format (:representation (..string key)) ..field_separator (:representation val)))) - (text.join_with ..argument_separator) + (text.interposed ..argument_separator) (text.enclosed ["{" "}"]) ..expression :abstraction)) @@ -185,7 +185,7 @@ (format "function " (:representation name) (|> inputs (list\map ..code) - (text.join_with ..argument_separator) + (text.interposed ..argument_separator) ..expression) " ") :abstraction)) @@ -204,7 +204,7 @@ (format "function" (|> inputs (list\map ..code) - (text.join_with ..argument_separator) + (text.interposed ..argument_separator) ..expression) " ") ..expression @@ -286,7 +286,7 @@ (|> (format "new " (:representation constructor) (|> inputs (list\map ..code) - (text.join_with ..argument_separator) + (text.interposed ..argument_separator) ..expression)) ..expression :abstraction)) @@ -411,9 +411,9 @@ (list\map (.function (_ [when then]) (format (|> when (list\map (|>> :representation (text.enclosed ["case " ":"]))) - (text.join_with text.new_line)) + (text.interposed text.new_line)) (..nested (:representation then))))) - (text.join_with text.new_line)) + (text.interposed text.new_line)) text.new_line (case default (#.Some default) diff --git a/stdlib/source/library/lux/target/jvm/attribute.lux b/stdlib/source/library/lux/target/jvm/attribute.lux index 72e054d5f..1dd3c323e 100644 --- a/stdlib/source/library/lux/target/jvm/attribute.lux +++ b/stdlib/source/library/lux/target/jvm/attribute.lux @@ -87,7 +87,7 @@ (def: (constant' @name index) (-> (Index UTF8) (Constant Any) Attribute) (#Constant {#name @name - #length (|> /constant.length //unsigned.u4 try.assumed) + #length (|> /constant.length //unsigned.u4 try.trusted) #info index})) (def: .public (constant index) @@ -104,7 +104,7 @@ #length (|> specification (/code.length ..length) //unsigned.u4 - try.assumed) + try.trusted) #info specification})) (def: .public (code specification) diff --git a/stdlib/source/library/lux/target/jvm/bytecode.lux b/stdlib/source/library/lux/target/jvm/bytecode.lux index b742f16cc..87b0a75c5 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode.lux @@ -198,7 +198,7 @@ []]])))) (template [<name> <frames>] - [(def: <name> U2 (|> <frames> //unsigned.u2 try.assumed))] + [(def: <name> U2 (|> <frames> //unsigned.u2 try.trusted))] [$0 0] [$1 1] @@ -210,7 +210,7 @@ ) (template [<name> <registry>] - [(def: <name> Registry (|> <registry> //unsigned.u2 try.assumed /registry.registry))] + [(def: <name> Registry (|> <registry> //unsigned.u2 try.trusted /registry.registry))] [@_ 0] [@0 1] @@ -436,7 +436,7 @@ (-> S1 (Bytecode Any)) (..bytecode $0 $1 @_ _.bipush [byte])) -(def: (lift resource) +(def: (lifted resource) (All [a] (-> (Resource a) (Bytecode a))) @@ -450,7 +450,7 @@ (def: .public (string value) (-> //constant.UTF8 (Bytecode Any)) (do ..monad - [index (..lift (//constant/pool.string value))] + [index (..lifted (//constant/pool.string value))] (case (|> index //index.value //unsigned.value //unsigned.u1) (#try.Success index) (..bytecode $0 $1 @_ _.ldc [index]) @@ -475,7 +475,7 @@ <specializations> _ (do ..monad - [index (..lift (<constant> (<constructor> value)))] + [index (..lifted (<constant> (<constructor> value)))] (case (|> index //index.value //unsigned.value //unsigned.u1) (#try.Success index) (..bytecode $0 $1 @_ _.ldc [index]) @@ -497,7 +497,7 @@ (def: (arbitrary_float value) (-> java/lang/Float (Bytecode Any)) (do ..monad - [index (..lift (//constant/pool.float (//constant.float value)))] + [index (..lifted (//constant/pool.float (//constant.float value)))] (case (|> index //index.value //unsigned.value //unsigned.u1) (#try.Success index) (..bytecode $0 $1 @_ _.ldc [index]) @@ -537,7 +537,7 @@ <specializations> _ (do ..monad - [index (..lift (<constant> (<constructor> value)))] + [index (..lifted (<constant> (<constructor> value)))] (..bytecode $0 $2 @_ <wide> [index]))))] [long Int //constant.long //constant/pool.long _.ldc2_w/long @@ -549,7 +549,7 @@ (def: (arbitrary_double value) (-> java/lang/Double (Bytecode Any)) (do ..monad - [index (..lift (//constant/pool.double (//constant.double (:as Frac value))))] + [index (..lifted (//constant/pool.double (//constant.double (:as Frac value))))] (..bytecode $0 $2 @_ _.ldc2_w/double [index]))) (def: double_bits @@ -821,7 +821,7 @@ (in [..no_exceptions (bytecode jump)])] [goto_w _.goto_w (in [..no_exceptions (bytecode jump)]) - (in [..no_exceptions (bytecode (/jump.lift jump))])] + (in [..no_exceptions (bytecode (/jump.lifted jump))])] ) (def: (big_jump jump) @@ -831,7 +831,7 @@ big (#.Right small) - (/jump.lift small))) + (/jump.lifted small))) (exception: .public invalid_tableswitch) @@ -924,7 +924,7 @@ (-> (Type <category>) (Bytecode Any)) (do ..monad [... TODO: Make sure it's impossible to have indexes greater than U2. - index (..lift (//constant/pool.class (//name.internal (..reflection class))))] + index (..lifted (//constant/pool.class (//name.internal (..reflection class))))] (..bytecode <consumption> <production> @_ <instruction> [index])))] [$0 $1 new Class _.new] @@ -949,8 +949,8 @@ (case (|> dimensions //unsigned.value) 0 (..except ..multiarray_cannot_be_zero_dimensional [class]) _ (in []))) - index (..lift (//constant/pool.class (//name.internal (..reflection class))))] - (..bytecode (//unsigned.lift/2 dimensions) $1 @_ _.multianewarray [index dimensions]))) + index (..lifted (//constant/pool.class (//name.internal (..reflection class))))] + (..bytecode (//unsigned.lifted/2 dimensions) $1 @_ _.multianewarray [index dimensions]))) (def: (type_size type) (-> (Type Return) Nat) @@ -969,7 +969,7 @@ (-> (Type Class) Text (Type Method) (Bytecode Any)) (let [[type_variables inputs output exceptions] (parser.method type)] (do ..monad - [index (<| ..lift + [index (<| ..lifted (<method> (..reflection class)) {#//constant/pool.name method #//constant/pool.descriptor (type.descriptor type)}) @@ -977,10 +977,10 @@ (list\map ..type_size) (list\fold n.+ (if <static?> 0 1)) //unsigned.u1 - try.assumed) - production (|> output ..type_size //unsigned.u1 try.assumed)]] - (..bytecode (//unsigned.lift/2 consumption) - (//unsigned.lift/2 production) + try.trusted) + production (|> output ..type_size //unsigned.u1 try.trusted)]] + (..bytecode (//unsigned.lifted/2 consumption) + (//unsigned.lifted/2 production) @_ <instruction> [index consumption production]))))] @@ -994,7 +994,7 @@ [(def: .public (<name> class field type) (-> (Type Class) Text (Type Value) (Bytecode Any)) (do ..monad - [index (<| ..lift + [index (<| ..lifted (//constant/pool.field (..reflection class)) {#//constant/pool.name field #//constant/pool.descriptor (type.descriptor type)})] @@ -1017,7 +1017,7 @@ (def: .public (try @start @end @handler catch) (-> Label Label Label (Type Class) (Bytecode Any)) (do ..monad - [@catch (..lift (//constant/pool.class (//name.internal (..reflection catch))))] + [@catch (..lifted (//constant/pool.class (//name.internal (..reflection catch))))] (function (_ [pool environment tracker]) (#try.Success [[pool @@ -1038,7 +1038,7 @@ _.empty]))) []]])))) -(def: .public (compose pre post) +(def: .public (composite pre post) (All [pre post] (-> (Bytecode pre) (Bytecode post) (Bytecode post))) (do ..monad diff --git a/stdlib/source/library/lux/target/jvm/bytecode/address.lux b/stdlib/source/library/lux/target/jvm/bytecode/address.lux index d7f2f612f..669b49548 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/address.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/address.lux @@ -34,7 +34,7 @@ (def: .public start Address - (|> 0 ///unsigned.u2 try.assumed :abstraction)) + (|> 0 ///unsigned.u2 try.trusted :abstraction)) (def: .public (move distance) (-> U2 (-> Address (Try Address))) 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 ddc600162..43cb70e87 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 @@ -78,10 +78,10 @@ (template [<name> <extra>] [(def: .public <name> (-> Register Registry) - (let [extra (|> <extra> /////unsigned.u2 try.assumed)] - (|>> /////unsigned.lift/2 + (let [extra (|> <extra> /////unsigned.u2 try.trusted)] + (|>> /////unsigned.lifted/2 (/////unsigned.+/2 extra) - try.assumed + try.trusted :abstraction)))] [for ..normal] 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 5499207cf..ac3934f87 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 @@ -25,7 +25,7 @@ (template [<frames> <name>] [(def: .public <name> Stack - (|> <frames> /////unsigned.u2 maybe.assume :abstraction))] + (|> <frames> /////unsigned.u2 maybe.trusted :abstraction))] [0 empty] [1 catch] diff --git a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux index 22777c083..7f8638dca 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/instruction.lux @@ -59,7 +59,7 @@ (type: Opcode Nat) (template [<name> <size>] - [(def: <name> Size (|> <size> ///unsigned.u2 try.assumed))] + [(def: <name> Size (|> <size> ///unsigned.u2 try.trusted))] [opcode_size 1] [register_size 1] @@ -74,7 +74,7 @@ (function (_ [offset binary]) [(n.+ (///unsigned.value ..opcode_size) offset) - (try.assumed + (try.trusted (binary.write/8! offset opcode binary))])) (def: nullary @@ -90,7 +90,7 @@ Size (|> ..opcode_size (///unsigned.+/2 <size>) - try.assumed))] + try.trusted))] [size/1 ..register_size] [size/2 ..index_size] @@ -103,7 +103,7 @@ (-> Opcode <inputT> Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value <shift>) offset) - (try.assumed + (try.trusted (do try.monad [_ (binary.write/8! offset opcode binary)] (<writer> (n.+ (///unsigned.value ..opcode_size) offset) @@ -129,7 +129,7 @@ (-> Opcode <inputT> Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value <shift>) offset) - (try.assumed + (try.trusted (do try.monad [_ (binary.write/8! offset opcode binary)] (<writer> (n.+ (///unsigned.value ..opcode_size) offset) @@ -150,14 +150,14 @@ (def: size/11 Size (|> ..opcode_size - (///unsigned.+/2 ..register_size) try.assumed - (///unsigned.+/2 ..byte_size) try.assumed)) + (///unsigned.+/2 ..register_size) try.trusted + (///unsigned.+/2 ..byte_size) try.trusted)) (def: (binary/11' opcode input0 input1) (-> Opcode U1 U1 Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value ..size/11) offset) - (try.assumed + (try.trusted (do try.monad [_ (binary.write/8! offset opcode binary) _ (binary.write/8! (n.+ (///unsigned.value ..opcode_size) offset) @@ -177,14 +177,14 @@ (def: size/21 Size (|> ..opcode_size - (///unsigned.+/2 ..index_size) try.assumed - (///unsigned.+/2 ..byte_size) try.assumed)) + (///unsigned.+/2 ..index_size) try.trusted + (///unsigned.+/2 ..byte_size) try.trusted)) (def: (binary/21' opcode input0 input1) (-> Opcode U2 U1 Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value ..size/21) offset) - (try.assumed + (try.trusted (do try.monad [_ (binary.write/8! offset opcode binary) _ (binary.write/16! (n.+ (///unsigned.value ..opcode_size) offset) @@ -204,15 +204,15 @@ (def: size/211 Size (|> ..opcode_size - (///unsigned.+/2 ..index_size) try.assumed - (///unsigned.+/2 ..byte_size) try.assumed - (///unsigned.+/2 ..byte_size) try.assumed)) + (///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) (-> Opcode U2 U1 U1 Mutation) (function (_ [offset binary]) [(n.+ (///unsigned.value ..size/211) offset) - (try.assumed + (try.trusted (do try.monad [_ (binary.write/8! offset opcode binary) _ (binary.write/16! (n.+ (///unsigned.value ..opcode_size) offset) @@ -242,7 +242,7 @@ (|>> :representation)) (template [<code> <name>] - [(def: .public <name> (|> <code> ///unsigned.u1 try.assumed :abstraction))] + [(def: .public <name> (|> <code> ///unsigned.u1 try.trusted :abstraction))] [04 t_boolean] [05 t_char] @@ -573,7 +573,7 @@ [["C5" multianewarray [[index (Index Class)] [count U1]] [(///index.value index) count]]]] [..trinary/211 - [["B9" invokeinterface [[index (Index (Reference Method))] [count U1] [output_count U1]] [(///index.value index) count (try.assumed (///unsigned.u1 0))]]]] + [["B9" invokeinterface [[index (Index (Reference Method))] [count U1] [output_count U1]] [(///index.value index) count (try.trusted (///unsigned.u1 0))]]]] )) (def: (switch_padding offset) @@ -598,14 +598,14 @@ (n.* (///unsigned.value ..big_jump_size) (inc amount_of_afterwards))) ///unsigned.u2 - try.assumed)))] + try.trusted)))] [estimator (function (_ minimum default [at_minimum afterwards]) (let [amount_of_afterwards (list.size afterwards) estimator (estimator amount_of_afterwards)] (function (_ [size mutation]) (let [padding (switch_padding size) - tableswitch_size (try.assumed + tableswitch_size (try.trusted (do {! try.monad} [size (///unsigned.u2 size)] (\ ! map (|>> estimator ///unsigned.value) @@ -613,7 +613,7 @@ tableswitch_mutation (: Mutation (function (_ [offset binary]) [(n.+ tableswitch_size offset) - (try.assumed + (try.trusted (do {! try.monad} [amount_of_afterwards (|> amount_of_afterwards .int ///signed.s4) maximum (///signed.+/4 minimum amount_of_afterwards) @@ -662,14 +662,14 @@ (///unsigned.value ..integer_size) (n.* amount_of_cases case_size)) ///unsigned.u2 - try.assumed)))] + try.trusted)))] [estimator (function (_ default cases) (let [amount_of_cases (list.size cases) estimator (estimator amount_of_cases)] (function (_ [size mutation]) (let [padding (switch_padding size) - lookupswitch_size (try.assumed + lookupswitch_size (try.trusted (do {! try.monad} [size (///unsigned.u2 size)] (\ ! map (|>> estimator ///unsigned.value) @@ -677,7 +677,7 @@ lookupswitch_mutation (: Mutation (function (_ [offset binary]) [(n.+ lookupswitch_size offset) - (try.assumed + (try.trusted (do {! try.monad} [_ (binary.write/8! offset (hex "AB") binary) .let [offset (n.+ (///unsigned.value ..opcode_size) offset)] diff --git a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux index 53fdd6081..74821d838 100644 --- a/stdlib/source/library/lux/target/jvm/bytecode/jump.lux +++ b/stdlib/source/library/lux/target/jvm/bytecode/jump.lux @@ -22,6 +22,6 @@ (type: .public Big_Jump S4) -(def: .public lift +(def: .public lifted (-> Jump Big_Jump) - ///signed.lift/4) + ///signed.lifted/4) diff --git a/stdlib/source/library/lux/target/jvm/constant/pool.lux b/stdlib/source/library/lux/target/jvm/constant/pool.lux index a82683e1b..2278889b8 100644 --- a/stdlib/source/library/lux/target/jvm/constant/pool.lux +++ b/stdlib/source/library/lux/target/jvm/constant/pool.lux @@ -154,5 +154,5 @@ (def: .public empty Pool - [(|> 1 //unsigned.u2 try.assumed //index.index) + [(|> 1 //unsigned.u2 try.trusted //index.index) row.empty]) diff --git a/stdlib/source/library/lux/target/jvm/constant/tag.lux b/stdlib/source/library/lux/target/jvm/constant/tag.lux index 7d53837f0..54b4dbba1 100644 --- a/stdlib/source/library/lux/target/jvm/constant/tag.lux +++ b/stdlib/source/library/lux/target/jvm/constant/tag.lux @@ -28,7 +28,7 @@ (template [<code> <name>] [(def: .public <name> Tag - (|> <code> ///unsigned.u1 try.assumed :abstraction))] + (|> <code> ///unsigned.u1 try.trusted :abstraction))] [01 utf8] [03 integer] diff --git a/stdlib/source/library/lux/target/jvm/encoding/signed.lux b/stdlib/source/library/lux/target/jvm/encoding/signed.lux index 196f60380..8fed13354 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/signed.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/signed.lux @@ -93,8 +93,8 @@ (-> <from> <to>) (|>> :transmutation))] - [lift/2 S1 S2] - [lift/4 S2 S4] + [lifted/2 S1 S2] + [lifted/4 S2 S4] ) (template [<writer_name> <type> <writer>] diff --git a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux index e9084bb9d..8a889a1ad 100644 --- a/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux +++ b/stdlib/source/library/lux/target/jvm/encoding/unsigned.lux @@ -107,8 +107,8 @@ (-> <from> <to>) (|>> :transmutation))] - [lift/2 U1 U2] - [lift/4 U2 U4] + [lifted/2 U1 U2] + [lifted/4 U2 U4] ) (template [<writer_name> <type> <writer>] diff --git a/stdlib/source/library/lux/target/jvm/magic.lux b/stdlib/source/library/lux/target/jvm/magic.lux index c08360f9e..b2b547fcf 100644 --- a/stdlib/source/library/lux/target/jvm/magic.lux +++ b/stdlib/source/library/lux/target/jvm/magic.lux @@ -14,7 +14,9 @@ (def: .public code Magic - (|> (hex "CAFEBABE") //unsigned.u4 try.assumed)) + (|> (hex "CAFEBABE") + //unsigned.u4 + try.trusted)) (def: .public writer //unsigned.writer/4) diff --git a/stdlib/source/library/lux/target/jvm/modifier.lux b/stdlib/source/library/lux/target/jvm/modifier.lux index 523a9a722..c7eb021b2 100644 --- a/stdlib/source/library/lux/target/jvm/modifier.lux +++ b/stdlib/source/library/lux/target/jvm/modifier.lux @@ -43,7 +43,7 @@ (template: (!wrap value) [(|> value //unsigned.u2 - try.assumed + try.trusted :abstraction)]) (template: (!unwrap value) diff --git a/stdlib/source/library/lux/target/jvm/type/alias.lux b/stdlib/source/library/lux/target/jvm/type/alias.lux index 6b3a2ee45..5ba678bf6 100644 --- a/stdlib/source/library/lux/target/jvm/type/alias.lux +++ b/stdlib/source/library/lux/target/jvm/type/alias.lux @@ -128,4 +128,4 @@ return (..return aliasing) exceptions (<>.some (..exception aliasing))] (in (//.method [type_variables inputs return exceptions])))) - try.assumed)) + try.trusted)) diff --git a/stdlib/source/library/lux/target/jvm/type/descriptor.lux b/stdlib/source/library/lux/target/jvm/type/descriptor.lux index 60e8eead3..9c0f56021 100644 --- a/stdlib/source/library/lux/target/jvm/type/descriptor.lux +++ b/stdlib/source/library/lux/target/jvm/type/descriptor.lux @@ -98,7 +98,7 @@ (:abstraction (format (|> inputs (list\map ..descriptor) - (text.join_with "") + text.joined (text.enclosed ["(" ")"])) (:representation output)))) @@ -122,5 +122,5 @@ (n.- prefix_size) (n.- suffix_size))) (\ maybe.monad map ///name.internal) - maybe.assume)))))) + maybe.trusted)))))) ) diff --git a/stdlib/source/library/lux/target/jvm/type/parser.lux b/stdlib/source/library/lux/target/jvm/type/parser.lux index 6712f7ee0..2bbbca6ca 100644 --- a/stdlib/source/library/lux/target/jvm/type/parser.lux +++ b/stdlib/source/library/lux/target/jvm/type/parser.lux @@ -98,7 +98,7 @@ (|>> //.signature //signature.signature (<text>.result ..var') - try.assumed)) + try.trusted)) (template [<name> <prefix> <constructor>] [(def: <name> @@ -166,7 +166,7 @@ (|>> //.signature //signature.signature (<text>.result (..class'' ..parameter)) - try.assumed)) + try.trusted)) (def: .public value (Parser (Type Value)) @@ -224,7 +224,7 @@ (|>> //.signature //signature.signature (<text>.result parser) - try.assumed))) + try.trusted))) (template [<name> <category> <parser>] [(def: .public <name> @@ -262,4 +262,4 @@ (|>> //.signature //signature.signature (<text>.result ..declaration') - try.assumed)) + try.trusted)) diff --git a/stdlib/source/library/lux/target/jvm/type/signature.lux b/stdlib/source/library/lux/target/jvm/type/signature.lux index 23038130a..683ba1432 100644 --- a/stdlib/source/library/lux/target/jvm/type/signature.lux +++ b/stdlib/source/library/lux/target/jvm/type/signature.lux @@ -94,7 +94,7 @@ (format ..parameters_start (|> parameters (list\map ..signature) - (text.join_with "")) + text.joined) ..parameters_end)) //descriptor.class_suffix))) @@ -130,18 +130,18 @@ (|> type_variables (list\map (|>> ..var_name (text.suffix ..class_bound))) - (text.join_with "") + text.joined (text.enclosed [..parameters_start ..parameters_end]))) (|> inputs (list\map ..signature) - (text.join_with "") + text.joined (text.enclosed [..arguments_start ..arguments_end])) (:representation output) (|> exceptions (list\map (|>> :representation (format ..exception_prefix))) - (text.join_with ""))))) + text.joined)))) (implementation: .public equivalence (All [category] (Equivalence (Signature category))) diff --git a/stdlib/source/library/lux/target/jvm/version.lux b/stdlib/source/library/lux/target/jvm/version.lux index f5db348ef..7fbf55c35 100644 --- a/stdlib/source/library/lux/target/jvm/version.lux +++ b/stdlib/source/library/lux/target/jvm/version.lux @@ -13,12 +13,16 @@ (def: .public default_minor Minor - (|> 0 //unsigned.u2 try.assumed)) + (|> 0 + //unsigned.u2 + try.trusted)) (template [<number> <name>] [(def: .public <name> Major - (|> <number> //unsigned.u2 try.assumed))] + (|> <number> + //unsigned.u2 + try.trusted))] [45 v1_1] [46 v1_2] diff --git a/stdlib/source/library/lux/target/lua.lux b/stdlib/source/library/lux/target/lua.lux index 0bf872340..b79db8fc4 100644 --- a/stdlib/source/library/lux/target/lua.lux +++ b/stdlib/source/library/lux/target/lua.lux @@ -141,13 +141,13 @@ (def: .public multi (-> (List Expression) Literal) (|>> (list\map ..code) - (text.join_with ..input_separator) + (text.interposed ..input_separator) :abstraction)) (def: .public array (-> (List Expression) Literal) (|>> (list\map ..code) - (text.join_with ..input_separator) + (text.interposed ..input_separator) (text.enclosed ["{" "}"]) :abstraction)) @@ -155,7 +155,7 @@ (-> (List [Text Expression]) Literal) (|>> (list\map (.function (_ [key value]) (format key " = " (:representation value)))) - (text.join_with ..input_separator) + (text.interposed ..input_separator) (text.enclosed ["{" "}"]) :abstraction)) @@ -177,7 +177,7 @@ (-> (List Expression) Expression Computation) (|> args (list\map ..code) - (text.join_with ..input_separator) + (text.interposed ..input_separator) (text.enclosed ["(" ")"]) (format (:representation func)) :abstraction)) @@ -186,7 +186,7 @@ (-> Text (List Expression) Expression Computation) (|> args (list\map ..code) - (text.join_with ..input_separator) + (text.interposed ..input_separator) (text.enclosed ["(" ")"]) (format (:representation table) ":" method) :abstraction)) @@ -256,7 +256,7 @@ (def: locations (-> (List Location) Text) (|>> (list\map ..code) - (text.join_with ..input_separator))) + (text.interposed ..input_separator))) (def: .public (local vars) (-> (List Var) Statement) @@ -306,7 +306,7 @@ (:abstraction (format "for " (|> vars (list\map ..code) - (text.join_with ..input_separator)) + (text.interposed ..input_separator)) " in " (:representation source) " do" (..nested (:representation body!)) text.new_line "end"))) diff --git a/stdlib/source/library/lux/target/php.lux b/stdlib/source/library/lux/target/php.lux index 16ebbe5af..11aea7808 100644 --- a/stdlib/source/library/lux/target/php.lux +++ b/stdlib/source/library/lux/target/php.lux @@ -183,7 +183,7 @@ (def: arguments (-> (List Expression) Text) - (|>> (list\map ..code) (text.join_with ..input_separator) ..group)) + (|>> (list\map ..code) (text.interposed ..input_separator) ..group)) (def: .public (apply/* args func) (-> (List Expression) Expression Computation) @@ -201,7 +201,7 @@ (.if reference? (format "&" (:representation var)) (:representation var)))) - (text.join_with ..input_separator) + (text.interposed ..input_separator) ..group)) (template [<name> <reference?>] @@ -310,7 +310,7 @@ (-> (List Expression) Literal) (|> values (list\map ..code) - (text.join_with ..input_separator) + (text.interposed ..input_separator) ..group (format "array") :abstraction)) @@ -324,7 +324,7 @@ (|> kvs (list\map (function (_ [key value]) (format (:representation key) " => " (:representation value)))) - (text.join_with ..input_separator) + (text.interposed ..input_separator) ..group (format "array") :abstraction)) @@ -493,7 +493,7 @@ text.new_line (|> excepts (list\map catch) - (text.join_with text.new_line))))) + (text.interposed text.new_line))))) (template [<name> <keyword>] [(def: .public <name> diff --git a/stdlib/source/library/lux/target/python.lux b/stdlib/source/library/lux/target/python.lux index 4fd525f46..c8a62c58b 100644 --- a/stdlib/source/library/lux/target/python.lux +++ b/stdlib/source/library/lux/target/python.lux @@ -192,7 +192,7 @@ (format left_delimiter (|> entries (list\map entry_serializer) - (text.join_with ", ")) + (text.interposed ", ")) right_delimiter)))) (template [<name> <pre> <post>] @@ -224,7 +224,7 @@ (-> (Expression Any) (List (Expression Any)) (Computation Any)) (<| :abstraction ... ..expression - (format (:representation func) "(" (text.join_with ", " (list\map ..code args)) ")"))) + (format (:representation func) "(" (text.interposed ", " (list\map ..code args)) ")"))) (template [<name> <brand> <prefix>] [(def: (<name> var) @@ -243,7 +243,7 @@ (format (:representation func) (format "(" (|> args (list\map (function (_ arg) (format (:representation arg) ", "))) - (text.join_with "")) + text.joined) (<splat> extra) ")"))))] [apply_poly splat_poly] @@ -323,13 +323,13 @@ (-> (List (Var Any)) (Expression Any) (Computation Any)) (<| :abstraction ..expression - (format "lambda " (|> arguments (list\map ..code) (text.join_with ", ")) ": " + (format "lambda " (|> arguments (list\map ..code) (text.interposed ", ")) ": " (:representation body)))) (def: .public (set vars value) (-> (List (Location Any)) (Expression Any) (Statement Any)) (:abstraction - (format (|> vars (list\map ..code) (text.join_with ", ")) + (format (|> vars (list\map ..code) (text.interposed ", ")) " = " (:representation value)))) @@ -406,10 +406,10 @@ (..nested (:representation body!)) (|> excepts (list\map (function (_ [classes exception catch!]) - (format text.new_line "except (" (text.join_with ", " (list\map ..code classes)) + (format text.new_line "except (" (text.interposed ", " (list\map ..code classes)) ") as " (:representation exception) ":" (..nested (:representation catch!))))) - (text.join_with ""))))) + text.joined)))) (template [<name> <keyword> <pre>] [(def: .public (<name> value) @@ -437,7 +437,7 @@ (-> SVar (List (Ex [k] (Var k))) (Statement Any) (Statement Any)) (:abstraction (format "def " (:representation name) - "(" (|> args (list\map ..code) (text.join_with ", ")) "):" + "(" (|> args (list\map ..code) (text.interposed ", ")) "):" (..nested (:representation body))))) (def: .public (import module_name) diff --git a/stdlib/source/library/lux/target/r.lux b/stdlib/source/library/lux/target/r.lux index a41440b7a..15804b77b 100644 --- a/stdlib/source/library/lux/target/r.lux +++ b/stdlib/source/library/lux/target/r.lux @@ -168,12 +168,14 @@ (def: .public (apply args func) (-> (List Expression) Expression Expression) (let [func (:representation func) - spacing (|> " " (list.repeated (text.size func)) (text.join_with ""))] + spacing (|> " " + (list.repeated (text.size func)) + text.joined)] (:abstraction (format func "(" (|> args (list\map ..code) - (text.join_with (format "," text.new_line)) + (text.interposed (format "," text.new_line)) ..nested) ")")))) @@ -197,10 +199,10 @@ (..self_contained (format (:representation func) (format "(" - (text.join_with "," (list\map ..code args)) "," - (text.join_with "," (list\map (.function (_ [key val]) - (format key "=" (:representation val))) - kw_args)) + (text.interposed "," (list\map ..code args)) "," + (text.interposed "," (list\map (.function (_ [key val]) + (format key "=" (:representation val))) + kw_args)) ")")))) (syntax: (arity_inputs [arity <code>.nat]) @@ -326,7 +328,7 @@ (def: .public (function inputs body) (-> (List (Ex [k] (Var k))) Expression Expression) - (let [args (|> inputs (list\map ..code) (text.join_with ", "))] + (let [args (|> inputs (list\map ..code) (text.interposed ", "))] (..self_contained (format "function(" args ") " (.._block (:representation body)))))) diff --git a/stdlib/source/library/lux/target/ruby.lux b/stdlib/source/library/lux/target/ruby.lux index b717ef7cb..032ebb265 100644 --- a/stdlib/source/library/lux/target/ruby.lux +++ b/stdlib/source/library/lux/target/ruby.lux @@ -201,7 +201,7 @@ (def: .public array (-> (List Expression) Literal) (|>> (list\map (|>> :representation)) - (text.join_with ..input_separator) + (text.interposed ..input_separator) (text.enclosed ["[" "]"]) :abstraction)) @@ -209,7 +209,7 @@ (-> (List [Expression Expression]) Literal) (|>> (list\map (.function (_ [k v]) (format (:representation k) " => " (:representation v)))) - (text.join_with ..input_separator) + (text.interposed ..input_separator) (text.enclosed ["{" "}"]) :abstraction)) @@ -217,7 +217,7 @@ (-> (List Expression) Expression Computation) (|> args (list\map (|>> :representation)) - (text.join_with ..input_separator) + (text.interposed ..input_separator) (text.enclosed ["(" ")"]) (format (:representation func)) :abstraction)) @@ -226,7 +226,7 @@ (-> (List Expression) Expression Computation) (|> args (list\map (|>> :representation)) - (text.join_with ..input_separator) + (text.interposed ..input_separator) (text.enclosed ["[" "]"]) (format (:representation lambda)) :abstraction)) @@ -268,7 +268,7 @@ (:abstraction (format (|> vars (list\map (|>> :representation)) - (text.join_with ..input_separator)) + (text.interposed ..input_separator)) " = " (:representation value) ..statement_suffix))) (def: (block content) @@ -318,10 +318,10 @@ (format "begin" (..nested (:representation body!)) (|> rescues (list\map (.function (_ [classes exception rescue]) - (format text.new_line "rescue " (text.join_with ..input_separator classes) + (format text.new_line "rescue " (text.interposed ..input_separator classes) " => " (:representation exception) (..nested (:representation rescue))))) - (text.join_with text.new_line))))) + (text.interposed text.new_line))))) (def: .public (catch expectation body!) (-> Expression Statement Statement) @@ -357,7 +357,7 @@ (format "def " (:representation name) (|> args (list\map (|>> :representation)) - (text.join_with ..input_separator) + (text.interposed ..input_separator) (text.enclosed ["(" ")"])) (..nested (:representation body!))))) @@ -365,7 +365,7 @@ (-> (Maybe LVar) (List Var) Statement Literal) (let [proc (|> (format (|> args (list\map (|>> :representation)) - (text.join_with ..input_separator) + (text.interposed ..input_separator) (text.enclosed' "|")) (..nested (:representation body!))) (text.enclosed ["{" "}"]) diff --git a/stdlib/source/library/lux/target/scheme.lux b/stdlib/source/library/lux/target/scheme.lux index 6dcc744ca..7e910a91f 100644 --- a/stdlib/source/library/lux/target/scheme.lux +++ b/stdlib/source/library/lux/target/scheme.lux @@ -86,14 +86,14 @@ (|> (format " . " (:representation rest)) (format (|> mandatory (list\map ..code) - (text.join_with " "))) + (text.interposed " "))) (text.enclosed ["(" ")"]) :abstraction)) #.None (|> mandatory (list\map ..code) - (text.join_with " ") + (text.interposed " ") (text.enclosed ["(" ")"]) :abstraction))) @@ -164,7 +164,7 @@ (|> tail (list\map (|>> :representation ..nested)) (#.Item (:representation head)) - (text.join_with nested_new_line) + (text.interposed nested_new_line) (text.enclosed ["(" ")"]) :abstraction))))) diff --git a/stdlib/source/library/lux/test.lux b/stdlib/source/library/lux/test.lux index 867304aa7..dbd87627e 100644 --- a/stdlib/source/library/lux/test.lux +++ b/stdlib/source/library/lux/test.lux @@ -116,7 +116,7 @@ [tally (|> documentation (text.all_split_by ..separator) (list\map (|>> (format context_prefix))) - (text.join_with ..separator) + (text.interposed ..separator) (format description ..separator))])))) (def: failure_prefix "[Failure] ") @@ -143,7 +143,7 @@ (-> Text Bit Test) (random\in (..assertion message condition))) -(def: .public (lift message random) +(def: .public (lifted message random) (-> Text (Random Bit) Test) (random\map (..assertion message) random)) @@ -273,7 +273,7 @@ (-> (List Name) Bit Assertion) (let [message (|> coverage (list\map %.name) - (text.join_with " & ")) + (text.interposed " & ")) coverage (set.of_list name.hash coverage)] (|> (..assertion message condition) (async\map (function (_ [tally documentation]) @@ -289,7 +289,7 @@ (-> (List Name) Test Test) (let [context (|> coverage (list\map %.name) - (text.join_with " & ")) + (text.interposed " & ")) coverage (set.of_list name.hash coverage)] (random\map (async\map (function (_ [tally documentation]) [(update@ #actual_coverage (set.union coverage) tally) @@ -441,7 +441,7 @@ (list\fold ..total ..start)) (|> assertions (list\map product.right) - (text.join_with ..separator))])) + (text.interposed ..separator))])) (in [])))) (run! test))) (list.enumeration tests)))]] diff --git a/stdlib/source/library/lux/time.lux b/stdlib/source/library/lux/time.lux index 9429e7081..eb0928f5c 100644 --- a/stdlib/source/library/lux/time.lux +++ b/stdlib/source/library/lux/time.lux @@ -74,7 +74,7 @@ [value <sub_parser>] (if (n.< <maximum> value) (in value) - (<>.lift (exception.except <exception> [value])))))] + (<>.lifted (exception.except <exception> [value])))))] [..hours hour_parser invalid_hour ..section_parser] [..minutes minute_parser invalid_minute ..section_parser] diff --git a/stdlib/source/library/lux/time/date.lux b/stdlib/source/library/lux/time/date.lux index 310be7a0e..75e5609ea 100644 --- a/stdlib/source/library/lux/time/date.lux +++ b/stdlib/source/library/lux/time/date.lux @@ -87,7 +87,7 @@ (def: .public epoch Date - (try.assumed + (try.trusted (..date //year.epoch #//month.January ..minimum_day))) @@ -166,7 +166,7 @@ (if (and (n.>= <minimum> value) (n.<= <maximum> value)) (in value) - (<>.lift (exception.except <exception> [value])))))] + (<>.lifted (exception.except <exception> [value])))))] [1 12 month_parser invalid_month] ) @@ -178,9 +178,9 @@ _ (<text>.this ..separator) utc_month ..month_parser _ (<text>.this ..separator) - .let [month (maybe.assume (dictionary.value utc_month ..month_by_number))] + .let [month (maybe.trusted (dictionary.value utc_month ..month_by_number))] utc_day ..section_parser] - (<>.lift (..date utc_year month utc_day)))) + (<>.lifted (..date utc_year month utc_day)))) (def: (format value) (-> Date Text) @@ -337,9 +337,9 @@ (inc year) year)] ... Coercing, because the year is already in internal form. - (try.assumed + (try.trusted (..date (:as Year year) - (maybe.assume (dictionary.value month ..month_by_number)) + (maybe.trusted (dictionary.value month ..month_by_number)) day)))) (implementation: .public enum diff --git a/stdlib/source/library/lux/time/instant.lux b/stdlib/source/library/lux/time/instant.lux index cc19a4ecc..36e0b2504 100644 --- a/stdlib/source/library/lux/time/instant.lux +++ b/stdlib/source/library/lux/time/instant.lux @@ -122,7 +122,7 @@ duration.millis .nat //.of_millis - try.assumed)) + try.trusted)) (def: (format instant) (-> Instant Text) diff --git a/stdlib/source/library/lux/time/year.lux b/stdlib/source/library/lux/time/year.lux index e7ed644ce..dd303ed85 100644 --- a/stdlib/source/library/lux/time/year.lux +++ b/stdlib/source/library/lux/time/year.lux @@ -125,9 +125,9 @@ [sign (<>.or (<text>.this "-") (in [])) digits (<text>.many <text>.decimal) raw_year (<>.codec i.decimal (in (text\compose "+" digits)))] - (<>.lift (..year (case sign - (#.Left _) (i.* -1 raw_year) - (#.Right _) raw_year))))) + (<>.lifted (..year (case sign + (#.Left _) (i.* -1 raw_year) + (#.Right _) raw_year))))) (implementation: .public codec {#.doc (example "Based on ISO 8601." diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux index 6af02e080..e8b91db8c 100644 --- a/stdlib/source/library/lux/tool/compiler/default/init.lux +++ b/stdlib/source/library/lux/tool/compiler/default/init.lux @@ -127,7 +127,7 @@ (do ///phase.monad [.let [module (get@ #///.module input)] _ (///directive.set_current_module module)] - (///directive.lift_analysis + (///directive.lifted_analysis (do {! ///phase.monad} [_ (module.create hash module) _ (monad.map ! module.import dependencies) @@ -141,15 +141,15 @@ (All [anchor expression directive] (///directive.Operation anchor expression directive [.Module (Payload directive)]))) (do ///phase.monad - [_ (///directive.lift_analysis + [_ (///directive.lifted_analysis (module.set_compiled module)) analysis_module (<| (: (Operation .Module)) - ///directive.lift_analysis - extension.lift + ///directive.lifted_analysis + extension.lifted meta.current_module) - final_buffer (///directive.lift_generation + final_buffer (///directive.lifted_generation ///generation.buffer) - final_registry (///directive.lift_generation + final_registry (///directive.lifted_generation ///generation.get_registry)] (in [analysis_module [final_buffer final_registry]]))) @@ -162,9 +162,9 @@ (///directive.Operation anchor expression directive (Payload directive))))) (do ///phase.monad - [buffer (///directive.lift_generation + [buffer (///directive.lifted_generation ///generation.buffer) - registry (///directive.lift_generation + registry (///directive.lifted_generation ///generation.get_registry)] (in [buffer registry]))) @@ -177,9 +177,9 @@ [Requirements (Payload directive)])))) (do ///phase.monad [.let [[pre_buffer pre_registry] pre_payoad] - _ (///directive.lift_generation + _ (///directive.lifted_generation (///generation.set_buffer pre_buffer)) - _ (///directive.lift_generation + _ (///directive.lifted_generation (///generation.set_registry pre_registry)) requirements (let [execute! (directiveP.phase expander)] (execute! archive code)) @@ -193,7 +193,7 @@ (///directive.Operation anchor expression directive [Source Requirements (Payload directive)])))) (do ///phase.monad - [[source code] (///directive.lift_analysis + [[source code] (///directive.lifted_analysis (..read source reader)) [requirements post_payload] (process_directive archive expander pre_payload code)] (in [source requirements post_payload]))) @@ -205,7 +205,7 @@ (///directive.Operation anchor expression directive (Maybe [Source Requirements (Payload directive)]))))) (do ///phase.monad - [reader (///directive.lift_analysis + [reader (///directive.lifted_analysis (..reader module aliases source))] (function (_ state) (case (///phase.result' state (..iteration' archive expander reader source pre_payload)) @@ -273,12 +273,12 @@ (recur (<| (///phase.result' state) (do {! ///phase.monad} [analysis_module (<| (: (Operation .Module)) - ///directive.lift_analysis - extension.lift + ///directive.lifted_analysis + extension.lifted meta.current_module) - _ (///directive.lift_generation + _ (///directive.lifted_generation (///generation.set_buffer temporary_buffer)) - _ (///directive.lift_generation + _ (///directive.lifted_generation (///generation.set_registry temporary_registry)) _ (|> requirements (get@ #///directive.referrals) diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux index f19ec248c..53cb07e22 100644 --- a/stdlib/source/library/lux/tool/compiler/default/platform.lux +++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux @@ -150,14 +150,14 @@ (///directive.Operation <type_vars> [Archive [Descriptor (Document .Module) Output]]))) (do ///phase.monad - [[registry payload] (///directive.lift_generation + [[registry payload] (///directive.lifted_generation (..compile_runtime! platform)) .let [[descriptor document] [(..runtime_descriptor registry) ..runtime_document]] - archive (///phase.lift (if (archive.reserved? archive archive.runtime_module) - (archive.has archive.runtime_module [descriptor document payload] archive) - (do try.monad - [[_ archive] (archive.reserve archive.runtime_module archive)] - (archive.has archive.runtime_module [descriptor document payload] archive))))] + archive (///phase.lifted (if (archive.reserved? archive archive.runtime_module) + (archive.has archive.runtime_module [descriptor document payload] archive) + (do try.monad + [[_ archive] (archive.reserve archive.runtime_module archive)] + (archive.has archive.runtime_module [descriptor document payload] archive))))] (in [archive [descriptor document payload]]))) (def: (initialize_state extender @@ -182,13 +182,13 @@ (///directive.Operation <type_vars> Any) (do ///phase.monad - [_ (///directive.lift_analysis + [_ (///directive.lifted_analysis (///analysis.install analysis_state)) - _ (///directive.lift_analysis + _ (///directive.lifted_analysis (extension.with extender analysers)) - _ (///directive.lift_synthesis + _ (///directive.lifted_synthesis (extension.with extender synthesizers)) - _ (///directive.lift_generation + _ (///directive.lifted_generation (extension.with extender (:expected generators))) _ (extension.with extender (:expected directives))] (in []))) @@ -201,7 +201,7 @@ (let [phase_wrapper (get@ #phase_wrapper platform)] (|> archive phase_wrapper - ///directive.lift_generation + ///directive.lifted_generation (///phase.result' state)))) (def: (complete_extensions host_directive_bundle phase_wrapper [analysers synthesizers generators directives]) @@ -520,7 +520,7 @@ (-> Module <State+> <State+>)) (|> (///directive.set_current_module module) (///phase.result' state) - try.assumed + try.trusted product.left)) (def: .public (compile import static expander platform compilation context) @@ -586,7 +586,7 @@ .let [archive (|> archive,document+ (list\map product.left) (list\fold archive.merged archive))]] - (in [archive (try.assumed + (in [archive (try.trusted (..updated_state archive state))]))) (async\in (exception.except ..cannot_import_twice [module duplicates])))] (case ((get@ #///.process compilation) @@ -594,7 +594,7 @@ ... TODO: The context shouldn't need to be re-set either. (|> (///directive.set_current_module module) (///phase.result' state) - try.assumed + try.trusted product.left) archive) (#try.Success [state more|done]) 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 eb325ddd0..571185dee 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux @@ -355,7 +355,7 @@ (#Tuple members) (|> members (list\map %analysis) - (text.join_with " ") + (text.interposed " ") (text.enclosed ["[" "]"]))) (#Reference reference) @@ -369,7 +369,7 @@ (format " ") (format (|> environment (list\map %analysis) - (text.join_with " ") + (text.interposed " ") (text.enclosed ["[" "]"]))) (text.enclosed ["(" ")"])) @@ -378,13 +378,13 @@ ..application #.Item (list\map %analysis) - (text.join_with " ") + (text.interposed " ") (text.enclosed ["(" ")"])) (#Extension name parameters) (|> parameters (list\map %analysis) - (text.join_with " ") + (text.interposed " ") (format (%.text name) " ") (text.enclosed ["(" ")"])))) 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 5ae124d96..1859802d6 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 @@ -46,12 +46,12 @@ (do phase.monad [exprA (type.with_type type (analyze archive exprC)) - module (extensionP.lift + module (extensionP.lifted meta.current_module_name)] - (phase.lift (do try.monad - [exprS (|> exprA (synthesisP.phase archive) (phase.result synthesis_state))] - (phase.result generation_state - (do phase.monad - [exprO (generate archive exprS) - module_id (generation.module_id module archive)] - (generation.evaluate! (..context [module_id count]) exprO))))))))) + (phase.lifted (do try.monad + [exprS (|> exprA (synthesisP.phase archive) (phase.result synthesis_state))] + (phase.result generation_state + (do phase.monad + [exprO (generate archive exprS) + module_id (generation.module_id module archive)] + (generation.evaluate! (..context [module_id count]) exprO))))))))) 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 5383d2ae4..478697fd4 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/directive.lux @@ -80,18 +80,18 @@ (Operation anchor expression directive output))) (|>> (phase.sub [(get@ [<component> #..state]) (set@ [<component> #..state])]) - extension.lift))] + extension.lifted))] - [lift_analysis #..analysis analysis.Operation] - [lift_synthesis #..synthesis synthesis.Operation] - [lift_generation #..generation (generation.Operation anchor expression directive)] + [lifted_analysis #..analysis analysis.Operation] + [lifted_synthesis #..synthesis synthesis.Operation] + [lifted_generation #..generation (generation.Operation anchor expression directive)] ) (def: .public (set_current_module module) (All [anchor expression directive] (-> Module (Operation anchor expression directive Any))) (do phase.monad - [_ (..lift_analysis + [_ (..lifted_analysis (analysis.set_current_module module))] - (..lift_generation + (..lifted_generation (generation.enter_module module)))) 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 b9b230b42..c8cfe9c0e 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 @@ -116,11 +116,11 @@ (case functionA (#/.Reference (#reference.Constant def_name)) (do ! - [?macro (//extension.lift (meta.macro def_name))] + [?macro (//extension.lifted (meta.macro def_name))] (case ?macro (#.Some macro) (do ! - [expansion (//extension.lift (/macro.expand_one expander def_name macro argsC+))] + [expansion (//extension.lifted (/macro.expand_one expander def_name macro argsC+))] (compile archive expansion)) _ 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 2188bb54a..9463eeb8f 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 @@ -102,7 +102,7 @@ (do ///.monad [[var_id varT] (//type.with_env check.var)] - (recur envs (maybe.assume (type.applied (list varT) caseT)))) + (recur envs (maybe.trusted (type.applied (list varT) caseT)))) (#.Apply inputT funcT) (.case funcT @@ -277,7 +277,7 @@ [[ex_id exT] (//type.with_env check.existential)] (analyse_pattern num_tags - (maybe.assume (type.applied (list exT) inputT')) + (maybe.trusted (type.applied (list exT) inputT')) pattern next)) @@ -287,8 +287,8 @@ (^ [location (#.Form (list& [_ (#.Tag tag)] values))]) (/.with_location location (do ///.monad - [tag (///extension.lift (meta.normal tag)) - [idx group variantT] (///extension.lift (meta.tag tag)) + [tag (///extension.lifted (meta.normal tag)) + [idx group variantT] (///extension.lifted (meta.tag tag)) _ (//type.with_env (check.check inputT variantT)) .let [[lefts right?] (/.choice (list.size group) idx)]] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux index 996272df7..25c85514e 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/case/coverage.lux @@ -80,7 +80,7 @@ dictionary.entries (list\map (function (_ [idx coverage]) (format (%.nat idx) " " (%coverage coverage)))) - (text.join_with " ") + (text.interposed " ") (text.enclosed ["{" "}"]) (format (%.nat (..cases ?max_cases)) " ") (text.enclosed ["(#Variant " ")"])) 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 8063f450d..69e75f374 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 @@ -40,12 +40,12 @@ list.enumeration (list\map (.function (_ [idx argC]) (format (%.nat idx) " " (%.code argC)))) - (text.join_with text.new_line))])) + (text.interposed text.new_line))])) (def: .public (function analyse function_name arg_name archive body) (-> Phase Text Text Phase) (do {! ///.monad} - [functionT (///extension.lift meta.expected_type)] + [functionT (///extension.lifted meta.expected_type)] (loop [expectedT functionT] (/.with_stack ..cannot_analyse [expectedT function_name arg_name body] (case expectedT @@ -64,7 +64,7 @@ [(<tag> _) (do ! [[_ instanceT] (//type.with_env <instancer>)] - (recur (maybe.assume (type.applied (list instanceT) expectedT))))]) + (recur (maybe.trusted (type.applied (list instanceT) expectedT))))]) ([#.UnivQ check.existential] [#.ExQ check.var]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux index af25a5856..6282980be 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/inference.lux @@ -96,7 +96,7 @@ (def: new_named_type (Operation Type) (do ///.monad - [location (///extension.lift meta.location) + [location (///extension.lifted meta.location) [ex_id _] (//type.with_env check.existential)] (in (named_type location ex_id)))) @@ -123,13 +123,13 @@ (#.UnivQ _) (do ///.monad [[var_id varT] (//type.with_env check.var)] - (general archive analyse (maybe.assume (type.applied (list varT) inferT)) args)) + (general archive analyse (maybe.trusted (type.applied (list varT) inferT)) args)) (#.ExQ _) (do {! ///.monad} [[var_id varT] (//type.with_env check.var) output (general archive analyse - (maybe.assume (type.applied (list varT) inferT)) + (maybe.trusted (type.applied (list varT) inferT)) args) bound? (//type.with_env (check.bound? var_id)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux index db51c3d77..d5e2fd691 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/module.lux @@ -36,7 +36,7 @@ (template [<name>] [(exception: .public (<name> {tags (List Text)} {owner Type}) (exception.report - ["Tags" (text.join_with " " tags)] + ["Tags" (text.interposed " " tags)] ["Type" (%.type owner)]))] [cannot_declare_tags_for_unnamed_type] @@ -80,7 +80,7 @@ (def: .public (set_annotations annotations) (-> Code (Operation Any)) - (///extension.lift + (///extension.lifted (do ///.monad [self_name meta.current_module_name self meta.current_module] @@ -97,7 +97,7 @@ (def: .public (import module) (-> Text (Operation Any)) - (///extension.lift + (///extension.lifted (do ///.monad [self_name meta.current_module_name] (function (_ state) @@ -112,7 +112,7 @@ (def: .public (alias alias module) (-> Text Text (Operation Any)) - (///extension.lift + (///extension.lifted (do ///.monad [self_name meta.current_module_name] (function (_ state) @@ -124,7 +124,7 @@ (def: .public (exists? module) (-> Text (Operation Bit)) - (///extension.lift + (///extension.lifted (function (_ state) (|> state (get@ #.modules) @@ -134,7 +134,7 @@ (def: .public (define name definition) (-> Text Global (Operation Any)) - (///extension.lift + (///extension.lifted (do ///.monad [self_name meta.current_module_name self meta.current_module] @@ -155,7 +155,7 @@ (def: .public (create hash name) (-> Nat Text (Operation Any)) - (///extension.lift + (///extension.lifted (function (_ state) (#try.Success [(update@ #.modules (plist.has name (..empty hash)) @@ -168,13 +168,13 @@ [_ (create hash name) output (/.with_current_module name action) - module (///extension.lift (meta.module name))] + module (///extension.lifted (meta.module name))] (in [module output]))) (template [<setter> <asker> <tag>] [(def: .public (<setter> module_name) (-> Text (Operation Any)) - (///extension.lift + (///extension.lifted (function (_ state) (case (|> state (get@ #.modules) (plist.value module_name)) (#.Some module) @@ -194,7 +194,7 @@ (def: .public (<asker> module_name) (-> Text (Operation Bit)) - (///extension.lift + (///extension.lifted (function (_ state) (case (|> state (get@ #.modules) (plist.value module_name)) (#.Some module) @@ -214,7 +214,7 @@ (template [<name> <tag> <type>] [(def: (<name> module_name) (-> Text (Operation <type>)) - (///extension.lift + (///extension.lifted (function (_ state) (case (|> state (get@ #.modules) (plist.value module_name)) (#.Some module) @@ -246,7 +246,7 @@ (def: .public (declare_tags tags exported? type) (-> (List Tag) Bit Type (Operation Any)) (do ///.monad - [self_name (///extension.lift meta.current_module_name) + [self_name (///extension.lifted meta.current_module_name) [type_module type_name] (case type (#.Named type_name _) (in type_name) @@ -256,7 +256,7 @@ _ (ensure_undeclared_tags self_name tags) _ (///.assertion cannot_declare_tags_for_foreign_type [tags type] (text\= self_name type_module))] - (///extension.lift + (///extension.lifted (function (_ state) (case (|> state (get@ #.modules) (plist.value self_name)) (#.Some module) 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 92e43368e..92a7a8f9c 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 @@ -33,7 +33,7 @@ (-> Name (Operation Analysis)) (with_expansions [<return> (in (|> def_name ///reference.constant #/.Reference))] (do {! ///.monad} - [constant (///extension.lift (meta.definition def_name))] + [constant (///extension.lifted (meta.definition def_name))] (case constant (#.Left real_def_name) (definition real_def_name) @@ -41,13 +41,13 @@ (#.Right [exported? actualT def_anns _]) (do ! [_ (//type.infer actualT) - (^@ def_name [::module ::name]) (///extension.lift (meta.normal def_name)) - current (///extension.lift meta.current_module_name)] + (^@ def_name [::module ::name]) (///extension.lifted (meta.normal def_name)) + current (///extension.lifted meta.current_module_name)] (if (text\= current ::module) <return> (if exported? (do ! - [imported! (///extension.lift (meta.imported_by? ::module current))] + [imported! (///extension.lifted (meta.imported_by? ::module current))] (if imported! <return> (/.except foreign_module_has_not_been_imported [current ::module]))) @@ -78,7 +78,7 @@ #.None (do ! - [this_module (///extension.lift meta.current_module_name)] + [this_module (///extension.lifted meta.current_module_name)] (definition [this_module simple_name])))) _ diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux index 98c36ec05..052173d1f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/scope.lux @@ -78,7 +78,7 @@ (def: .public (find name) (-> Text (Operation (Maybe [Type Variable]))) - (///extension.lift + (///extension.lifted (function (_ state) (let [[inner outer] (|> state (get@ #.scopes) @@ -183,7 +183,7 @@ (def: .public next_local (Operation Register) - (///extension.lift + (///extension.lifted (function (_ state) (case (get@ #.scopes state) (#.Item top _) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux index 8f254c5d6..56924a102 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/structure.lux @@ -95,7 +95,7 @@ (let [tag (/.tag lefts right?)] (function (recur valueC) (do {! ///.monad} - [expectedT (///extension.lift meta.expected_type) + [expectedT (///extension.lifted meta.expected_type) expectedT' (//type.with_env (check.clean expectedT))] (/.with_stack ..cannot_analyse_variant [expectedT' tag valueC] @@ -135,7 +135,7 @@ [(<tag> _) (do ! [[instance_id instanceT] (//type.with_env <instancer>)] - (//type.with_type (maybe.assume (type.applied (list instanceT) expectedT)) + (//type.with_type (maybe.trusted (type.applied (list instanceT) expectedT)) (recur valueC)))]) ([#.UnivQ check.existential] [#.ExQ check.var]) @@ -168,7 +168,7 @@ (def: (typed_product archive analyse members) (-> Archive Phase (List Code) (Operation Analysis)) (do {! ///.monad} - [expectedT (///extension.lift meta.expected_type) + [expectedT (///extension.lifted meta.expected_type) membersA+ (: (Operation (List Analysis)) (loop [membersT+ (type.flat_tuple expectedT) membersC+ members] @@ -195,7 +195,7 @@ (def: .public (product archive analyse membersC) (-> Archive Phase (List Code) (Operation Analysis)) (do {! ///.monad} - [expectedT (///extension.lift meta.expected_type)] + [expectedT (///extension.lifted meta.expected_type)] (/.with_stack ..cannot_analyse_tuple [expectedT membersC] (case expectedT (#.Product _) @@ -228,7 +228,7 @@ [(<tag> _) (do ! [[instance_id instanceT] (//type.with_env <instancer>)] - (//type.with_type (maybe.assume (type.applied (list instanceT) expectedT)) + (//type.with_type (maybe.trusted (type.applied (list instanceT) expectedT)) (product archive analyse membersC)))]) ([#.UnivQ check.existential] [#.ExQ check.var]) @@ -262,17 +262,17 @@ (def: .public (tagged_sum analyse tag archive valueC) (-> Phase Name Phase) (do {! ///.monad} - [tag (///extension.lift (meta.normal tag)) - [idx group variantT] (///extension.lift (meta.tag tag)) + [tag (///extension.lifted (meta.normal tag)) + [idx group variantT] (///extension.lifted (meta.tag tag)) .let [case_size (list.size group) [lefts right?] (/.choice case_size idx)] - expectedT (///extension.lift meta.expected_type)] + expectedT (///extension.lifted meta.expected_type)] (case expectedT (#.Var _) (do ! [inferenceT (//inference.variant idx case_size variantT) [inferredT valueA+] (//inference.general archive analyse inferenceT (list valueC))] - (in (/.variant [lefts right? (|> valueA+ list.head maybe.assume)]))) + (in (/.variant [lefts right? (|> valueA+ list.head maybe.trusted)]))) _ (..sum analyse lefts right? archive valueC)))) @@ -288,7 +288,7 @@ (case key [_ (#.Tag key)] (do ///.monad - [key (///extension.lift (meta.normal key))] + [key (///extension.lifted (meta.normal key))] (in [key val])) _ @@ -307,8 +307,8 @@ (#.Item [head_k head_v] _) (do {! ///.monad} - [head_k (///extension.lift (meta.normal head_k)) - [_ tag_set recordT] (///extension.lift (meta.tag head_k)) + [head_k (///extension.lifted (meta.normal head_k)) + [_ tag_set recordT] (///extension.lifted (meta.tag head_k)) .let [size_record (list.size record) size_ts (list.size tag_set)] _ (if (n.= size_ts size_record) @@ -319,7 +319,7 @@ idx->val (monad.fold ! (function (_ [key val] idx->val) (do ! - [key (///extension.lift (meta.normal key))] + [key (///extension.lifted (meta.normal key))] (case (dictionary.value key tag->idx) (#.Some idx) (if (dictionary.key? idx->val idx) @@ -331,7 +331,8 @@ (: (Dictionary Nat Code) (dictionary.empty n.hash)) record) - .let [ordered_tuple (list\map (function (_ idx) (maybe.assume (dictionary.value idx idx->val))) + .let [ordered_tuple (list\map (function (_ idx) + (maybe.trusted (dictionary.value idx idx->val))) tuple_range)]] (in [ordered_tuple recordT])) )) @@ -349,7 +350,7 @@ (do {! ///.monad} [members (normal members) [membersC recordT] (order members) - expectedT (///extension.lift meta.expected_type)] + expectedT (///extension.lifted meta.expected_type)] (case expectedT (#.Var _) (do ! diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux index 374663c95..ed980b1e6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/analysis/type.lux @@ -40,7 +40,7 @@ (def: .public (infer actualT) (-> Type (Operation Any)) (do ///.monad - [expectedT (///extension.lift meta.expected_type)] + [expectedT (///extension.lifted meta.expected_type)] (with_env (check.check expectedT actualT)))) 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 8bb5d475f..81fc21caa 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 @@ -47,21 +47,21 @@ (^ [_ (#.Form (list& macro inputs))]) (do {! //.monad} - [expansion (/.lift_analysis + [expansion (/.lifted_analysis (do ! [macroA (//analysis/type.with_type Macro (analyze archive macro))] (case macroA (^ (///analysis.constant macro_name)) (do ! - [?macro (//extension.lift (meta.macro macro_name)) + [?macro (//extension.lifted (meta.macro macro_name)) macro (case ?macro (#.Some macro) (in macro) #.None (//.except ..macro_was_not_found macro_name))] - (//extension.lift (///analysis/macro.expand expander macro_name macro inputs))) + (//extension.lifted (///analysis/macro.expand expander macro_name macro inputs))) _ (//.except ..invalid_macro_call 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 354f40fd2..206ae9f64 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 @@ -164,7 +164,7 @@ (function (_ [bundle state]) (#try.Success [[bundle (transform state)] []]))) -(def: .public (lift action) +(def: .public (lifted action) (All [s i o v] (-> (//.Operation s v) (//.Operation [(Bundle s i o) s] v))) 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 6fc53dd20..aa1730655 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 @@ -137,7 +137,7 @@ (def: (ensure_fresh_class! class_loader name) (-> java/lang/ClassLoader External (Operation Any)) (do phase.monad - [class (phase.lift (reflection!.load class_loader name))] + [class (phase.lifted (reflection!.load class_loader name))] (phase.assertion ..deprecated_class [name] (|> class java/lang/Class::getDeclaredAnnotations @@ -401,7 +401,7 @@ (|> objectJ ..signature (<text>.result jvm_parser.array) - phase.lift))) + phase.lifted))) (def: (primitive_array_length_handler primitive_type) (-> (Type Primitive) Handler) @@ -460,7 +460,7 @@ (do phase.monad [lengthA (typeA.with_type ..int (analyse archive lengthC)) - expectedT (///.lift meta.expected_type) + expectedT (///.lifted meta.expected_type) expectedJT (jvm_array_type expectedT) elementJT (case (jvm_parser.array? expectedJT) (#.Some elementJT) @@ -556,7 +556,7 @@ [jvm.char])) (text.starts_with? descriptor.array_prefix name) - (let [[_ unprefixed] (maybe.assume (text.split_by descriptor.array_prefix name))] + (let [[_ unprefixed] (maybe.trusted (text.split_by descriptor.array_prefix name))] (\ phase.monad map jvm.array (check_jvm (#.Primitive unprefixed (list))))) @@ -750,7 +750,7 @@ (case args (^ (list)) (do phase.monad - [expectedT (///.lift meta.expected_type) + [expectedT (///.lifted meta.expected_type) _ (check_object expectedT)] (in (#/////analysis.Extension extension_name (list)))) @@ -797,7 +797,7 @@ [exceptionT exceptionA] (typeA.with_inference (analyse archive exceptionC)) exception_class (check_object exceptionT) - ? (phase.lift (reflection!.sub? class_loader "java.lang.Throwable" exception_class)) + ? (phase.lifted (reflection!.sub? class_loader "java.lang.Throwable" exception_class)) _ (: (Operation Any) (if ? (in []) @@ -817,7 +817,7 @@ (do phase.monad [_ (..ensure_fresh_class! class_loader class) _ (typeA.infer (#.Primitive "java.lang.Class" (list (#.Primitive class (list))))) - _ (phase.lift (reflection!.load class_loader class))] + _ (phase.lifted (reflection!.load class_loader class))] (in (#/////analysis.Extension extension_name (list (/////analysis.text class))))) _ @@ -837,7 +837,7 @@ [objectT objectA] (typeA.with_inference (analyse archive objectC)) object_class (check_object objectT) - ? (phase.lift (reflection!.sub? class_loader object_class sub_class))] + ? (phase.lifted (reflection!.sub? class_loader object_class sub_class))] (if ? (in (#/////analysis.Extension extension_name (list (/////analysis.text sub_class) objectA))) (/////analysis.except cannot_possibly_be_an_instance (format sub_class " !<= " object_class)))))])) @@ -862,14 +862,14 @@ (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.lift (reflection!.load class_loader source_name)) - mapping (phase.lift (reflection!.correspond source_class fromT))] + [source_class (phase.lifted (reflection!.load class_loader source_name)) + mapping (phase.lifted (reflection!.correspond source_class fromT))] (monad.map ! (function (_ superJT) (do ! - [superJT (phase.lift (reflection!.type superJT)) + [superJT (phase.lifted (reflection!.type superJT)) .let [super_name (|> superJT ..reflection)] - super_class (phase.lift (reflection!.load class_loader super_name)) + super_class (phase.lifted (reflection!.load class_loader super_name)) superT (reflection_type mapping superJT)] (in [[super_name superT] (java/lang/Class::isAssignableFrom super_class target_class)]))) (case (java/lang/Class::getGenericSuperclass source_class) @@ -890,7 +890,7 @@ (function (_ superT) (do {! phase.monad} [super_name (\ ! map ..reflection (check_jvm superT)) - super_class (phase.lift (reflection!.load class_loader super_name))] + super_class (phase.lifted (reflection!.load class_loader super_name))] (in [[super_name superT] (java/lang/Class::isAssignableFrom super_class target_class)]))) (list& super_classT super_interfacesT+)) @@ -904,7 +904,7 @@ (case args (^ (list fromC)) (do {! phase.monad} - [toT (///.lift meta.expected_type) + [toT (///.lifted meta.expected_type) target_name (\ ! map ..reflection (check_jvm toT)) [fromT fromA] (typeA.with_inference (analyse archive fromC)) @@ -934,11 +934,11 @@ (not (dictionary.key? ..boxes source_name))) _ (phase.assertion ..primitives_are_not_objects [target_name] (not (dictionary.key? ..boxes target_name))) - target_class (phase.lift (reflection!.load class_loader target_name)) + target_class (phase.lifted (reflection!.load class_loader target_name)) _ (if (text\= ..inheritance_relationship_type_name source_name) (in []) (do ! - [source_class (phase.lift (reflection!.load class_loader source_name))] + [source_class (phase.lifted (reflection!.load class_loader source_name))] (phase.assertion ..cannot_cast [fromT toT fromC] (java/lang/Class::isAssignableFrom source_class target_class))))] (loop [[current_name currentT] [source_name fromT]] @@ -986,7 +986,7 @@ (function (_ extension_name analyse archive [class field]) (do phase.monad [_ (..ensure_fresh_class! class_loader class) - [final? deprecated? fieldJT] (phase.lift + [final? deprecated? fieldJT] (phase.lifted (do try.monad [class (reflection!.load class_loader class)] (reflection!.static_field field class))) @@ -1007,7 +1007,7 @@ (do phase.monad [_ (..ensure_fresh_class! class_loader class) _ (typeA.infer Any) - [final? deprecated? fieldJT] (phase.lift + [final? deprecated? fieldJT] (phase.lifted (do try.monad [class (reflection!.load class_loader class)] (reflection!.static_field field class))) @@ -1032,7 +1032,7 @@ [_ (..ensure_fresh_class! class_loader class) [objectT objectA] (typeA.with_inference (analyse archive objectC)) - [deprecated? mapping fieldJT] (phase.lift + [deprecated? mapping fieldJT] (phase.lifted (do try.monad [class (reflection!.load class_loader class) [final? deprecated? fieldJT] (reflection!.virtual_field field class) @@ -1058,7 +1058,7 @@ [objectT objectA] (typeA.with_inference (analyse archive objectC)) _ (typeA.infer objectT) - [final? deprecated? mapping fieldJT] (phase.lift + [final? deprecated? mapping fieldJT] (phase.lifted (do try.monad [class (reflection!.load class_loader class) [final? deprecated? fieldJT] (reflection!.virtual_field field class) @@ -1091,7 +1091,7 @@ [parameters (|> (java/lang/reflect/Method::getGenericParameterTypes method) array.list (monad.map try.monad reflection!.type) - phase.lift) + phase.lifted) .let [modifiers (java/lang/reflect/Method::getModifiers method) correct_class? (java/lang/Object::equals class (java/lang/reflect/Method::getDeclaringClass method)) correct_method? (text\= method_name (java/lang/reflect/Method::getName method)) @@ -1137,7 +1137,7 @@ [parameters (|> (java/lang/reflect/Constructor::getGenericParameterTypes constructor) array.list (monad.map try.monad reflection!.type) - phase.lift)] + phase.lifted)] (in (and (java/lang/Object::equals class (java/lang/reflect/Constructor::getDeclaringClass constructor)) (n.= (list.size inputsJT) (list.size parameters)) (list\fold (function (_ [expectedJC actualJC] prev) @@ -1191,18 +1191,18 @@ (do {! phase.monad} [inputsT (|> (java/lang/reflect/Method::getGenericParameterTypes method) array.list - (monad.map ! (|>> reflection!.type phase.lift)) + (monad.map ! (|>> reflection!.type phase.lifted)) (phase\map (monad.map ! (..reflection_type mapping))) phase\join) outputT (|> method java/lang/reflect/Method::getGenericReturnType reflection!.return - phase.lift + phase.lifted (phase\map (..reflection_return mapping)) phase\join) exceptionsT (|> (java/lang/reflect/Method::getGenericExceptionTypes method) array.list - (monad.map ! (|>> reflection!.type phase.lift)) + (monad.map ! (|>> reflection!.type phase.lifted)) (phase\map (monad.map ! (..reflection_type mapping))) phase\join) .let [methodT (<| (type.univ_q (dictionary.size mapping)) @@ -1231,12 +1231,12 @@ (do {! phase.monad} [inputsT (|> (java/lang/reflect/Constructor::getGenericParameterTypes constructor) array.list - (monad.map ! (|>> reflection!.type phase.lift)) + (monad.map ! (|>> reflection!.type phase.lifted)) (phase\map (monad.map ! (reflection_type mapping))) phase\join) exceptionsT (|> (java/lang/reflect/Constructor::getGenericExceptionTypes constructor) array.list - (monad.map ! (|>> reflection!.type phase.lift)) + (monad.map ! (|>> reflection!.type phase.lifted)) (phase\map (monad.map ! (reflection_type mapping))) phase\join) .let [objectT (#.Primitive (java/lang/Class::getName owner) owner_tvarsT) @@ -1285,7 +1285,7 @@ (def: (method_candidate class_loader actual_class_tvars class_name actual_method_tvars method_name method_style inputsJT) (-> java/lang/ClassLoader (List (Type Var)) External (List (Type Var)) Text Method_Style (List (Type Value)) (Operation Method_Signature)) (do {! phase.monad} - [class (phase.lift (reflection!.load class_loader class_name)) + [class (phase.lifted (reflection!.load class_loader class_name)) .let [expected_class_tvars (class_type_variables class)] candidates (|> class java/lang/Class::getDeclaredMethods @@ -1318,7 +1318,7 @@ (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.lift (reflection!.load class_loader class_name)) + [class (phase.lifted (reflection!.load class_loader class_name)) .let [expected_class_tvars (class_type_variables class)] candidates (|> class java/lang/Class::getConstructors @@ -1436,7 +1436,7 @@ (do phase.monad [_ (..ensure_fresh_class! class_loader class_name) .let [argsT (list\map product.left argsTC)] - class (phase.lift (reflection!.load class_loader class_name)) + class (phase.lifted (reflection!.load class_loader class_name)) _ (phase.assertion non_interface class_name (java/lang/reflect/Modifier::isInterface (java/lang/Class::getModifiers class))) [methodT deprecated? exceptionsT] (..method_candidate class_loader class_tvars class_name method_tvars method #Interface argsT) @@ -1914,14 +1914,14 @@ [parent_parameters (|> parent_parameters (monad.map maybe.monad jvm_parser.var?) try.of_maybe - phase.lift)] + phase.lifted)] (|> super_parameters (monad.map ! (..reflection_type mapping)) (\ ! map (|>> (list.zipped/2 parent_parameters))))) - (phase.lift (exception.except ..mismatched_super_parameters [parent_name expected_count actual_count])))) + (phase.lifted (exception.except ..mismatched_super_parameters [parent_name expected_count actual_count])))) #.None - (phase.lift (exception.except ..unknown_super [parent_name supers]))))) + (phase.lifted (exception.except ..unknown_super [parent_name supers]))))) (def: .public (with_fresh_type_vars vars mapping) (-> (List (Type Var)) Mapping (Operation Mapping)) @@ -2060,7 +2060,7 @@ (-> java/lang/ClassLoader (Type Class) (Operation Aliasing)) (do phase.monad [.let [[name actual_parameters] (jvm_parser.read_class class)] - class (phase.lift (reflection!.load class_loader name)) + class (phase.lifted (reflection!.load class_loader name)) .let [expected_parameters (|> (java/lang/Class::getTypeParameters class) array.list (list\map (|>> java/lang/reflect/TypeVariable::getName)))] @@ -2086,8 +2086,8 @@ (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.lift (all_abstract_methods class_loader supers)) - available_methods (phase.lift (all_methods class_loader supers)) + [required_abstract_methods (phase.lifted (all_abstract_methods class_loader supers)) + available_methods (phase.lifted (all_methods class_loader supers)) overriden_methods (monad.map ! (function (_ [parent_type method_name strict_fp? annotations type_vars self_name arguments return exceptions @@ -2139,12 +2139,12 @@ (monad.map check.monad (|>> ..signature (luxT.check (luxT.class mapping))) super_interfaces)) - selfT (///.lift (do meta.monad - [where meta.current_module_name - id meta.seed] - (in (inheritance_relationship_type (#.Primitive (..anonymous_class_name where id) (list)) - super_classT - super_interfaceT+)))) + selfT (///.lifted (do meta.monad + [where meta.current_module_name + id meta.seed] + (in (inheritance_relationship_type (#.Primitive (..anonymous_class_name where id) (list)) + super_classT + super_interfaceT+)))) _ (typeA.infer selfT) constructor_argsA+ (monad.map ! (function (_ [type term]) (do ! 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 979af197a..d26820e9a 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 @@ -90,7 +90,7 @@ (do <>.monad [raw <code>.text] (case (text.size raw) - 1 (in (|> raw (text.char 0) maybe.assume)) + 1 (in (|> raw (text.char 0) maybe.trusted)) _ (<>.failure (exception.error ..char_text_must_be_size_1 [raw]))))) (def: lux::syntax_char_case! @@ -104,7 +104,7 @@ (do {! ////.monad} [input (typeA.with_type text.Char (phase archive input)) - expectedT (///.lift meta.expected_type) + expectedT (///.lifted meta.expected_type) conditionals (monad.map ! (function (_ [cases branch]) (do ! [branch (typeA.with_type expectedT @@ -164,7 +164,7 @@ (case args (^ (list typeC valueC)) (do {! ////.monad} - [seed (///.lift meta.seed) + [seed (///.lifted meta.seed) actualT (\ ! map (|>> (:as Type)) (eval archive seed Type typeC)) _ (typeA.infer actualT)] @@ -180,7 +180,7 @@ (case args (^ (list typeC valueC)) (do {! ////.monad} - [seed (///.lift meta.seed) + [seed (///.lifted meta.seed) actualT (\ ! map (|>> (:as Type)) (eval archive seed Type typeC)) _ (typeA.infer actualT) @@ -210,7 +210,7 @@ [_ (typeA.infer .Macro) input_type (loop [input_name (name_of .Macro')] (do ! - [input_type (///.lift (meta.definition (name_of .Macro')))] + [input_type (///.lifted (meta.definition (name_of .Macro')))] (case input_type (#.Definition [exported? def_type def_data def_value]) (in (:as Type def_value)) 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 04e197099..61f4e3763 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 @@ -223,7 +223,7 @@ (function (_ methodC) (do phase.monad [methodA (: (Operation analysis.Analysis) - (directive.lift_analysis + (directive.lifted_analysis (case methodC (#Constructor method) (jvm.analyse_constructor_method analyse selfT mapping method) @@ -236,7 +236,7 @@ (#Overriden_Method method) (jvm.analyse_overriden_method analyse selfT mapping method))))] - (directive.lift_synthesis + (directive.lifted_synthesis (synthesize methodA))))) (def: jvm::class @@ -260,17 +260,17 @@ fields methods]) (do {! phase.monad} - [parameters (directive.lift_analysis + [parameters (directive.lifted_analysis (typeA.with_env (jvm.parameter_types parameters))) .let [mapping (list\fold (function (_ [parameterJ parameterT] mapping) (dictionary.has (parser.name parameterJ) parameterT mapping)) luxT.fresh parameters)] - super_classT (directive.lift_analysis + super_classT (directive.lifted_analysis (typeA.with_env (luxT.check (luxT.class mapping) (..signature super_class)))) - super_interfaceT+ (directive.lift_analysis + super_interfaceT+ (directive.lifted_analysis (typeA.with_env (monad.map check.monad (|>> ..signature (luxT.check (luxT.class mapping))) @@ -278,13 +278,13 @@ .let [selfT (jvm.inheritance_relationship_type (#.Primitive name (list\map product.right parameters)) super_classT super_interfaceT+)] - state (extension.lift phase.get_state) + state (extension.lifted phase.get_state) .let [analyse (get@ [#directive.analysis #directive.phase] state) synthesize (get@ [#directive.synthesis #directive.phase] state) generate (get@ [#directive.generation #directive.phase] state)] methods (monad.map ! (..method_definition [mapping selfT] [analyse synthesize generate]) methods) - ... _ (directive.lift_generation + ... _ (directive.lifted_generation ... (generation.save! true ["" name] ... [name ... (class.class version.v6_0 @@ -294,7 +294,7 @@ ... (list\map ..field_definition fields) ... (list) ... TODO: Add methods ... (row.row))])) - _ (directive.lift_generation + _ (directive.lifted_generation (generation.log! (format "Class " name)))] (in directive.no_requirements)))])) 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 04df2b765..604292cdd 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 @@ -73,7 +73,7 @@ Type Synthesis (Operation anchor expression directive [Type expression Any]))) - (/////directive.lift_generation + (/////directive.lifted_generation (do phase.monad [module /////generation.module id /////generation.next @@ -86,16 +86,16 @@ (All [anchor expression directive] (-> Archive Type Code (Operation anchor expression directive [Type expression Any]))) (do phase.monad - [state (///.lift phase.get_state) + [state (///.lifted phase.get_state) .let [analyse (get@ [#/////directive.analysis #/////directive.phase] state) synthesize (get@ [#/////directive.synthesis #/////directive.phase] state) generate (get@ [#/////directive.generation #/////directive.phase] state)] - [_ codeA] (/////directive.lift_analysis + [_ codeA] (/////directive.lifted_analysis (/////analysis.with_scope (typeA.with_fresh_env (typeA.with_type type (analyse archive codeC))))) - codeS (/////directive.lift_synthesis + codeS (/////directive.lifted_synthesis (synthesize archive codeA))] (evaluate!' archive generate type codeS))) @@ -108,11 +108,11 @@ Type Synthesis (Operation anchor expression directive [Type expression Any]))) - (/////directive.lift_generation + (/////directive.lifted_generation (do phase.monad [codeG (generate archive codeS) id (/////generation.learn name) - module_id (phase.lift (archive.id module archive)) + module_id (phase.lifted (archive.id module archive)) [target_name value directive] (/////generation.define! [module_id id] #.None codeG) _ (/////generation.save! id #.None directive)] (in [code//type codeG value])))) @@ -122,11 +122,11 @@ (-> Archive Name (Maybe Type) Code (Operation anchor expression directive [Type expression Any]))) (do {! phase.monad} - [state (///.lift phase.get_state) + [state (///.lifted phase.get_state) .let [analyse (get@ [#/////directive.analysis #/////directive.phase] state) synthesize (get@ [#/////directive.synthesis #/////directive.phase] state) generate (get@ [#/////directive.generation #/////directive.phase] state)] - [_ code//type codeA] (/////directive.lift_analysis + [_ code//type codeA] (/////directive.lifted_analysis (/////analysis.with_scope (typeA.with_fresh_env (case expected @@ -143,7 +143,7 @@ [codeA (typeA.with_type expected (analyse archive codeC))] (in [expected codeA])))))) - codeS (/////directive.lift_synthesis + codeS (/////directive.lifted_synthesis (synthesize archive codeA))] (definition' archive generate name code//type codeS))) @@ -158,12 +158,12 @@ Synthesis (Operation anchor expression directive [expression Any]))) (do phase.monad - [current_module (/////directive.lift_analysis - (///.lift meta.current_module_name))] - (/////directive.lift_generation + [current_module (/////directive.lifted_analysis + (///.lifted meta.current_module_name))] + (/////directive.lifted_generation (do phase.monad [codeG (generate archive codeS) - module_id (phase.lift (archive.id current_module archive)) + module_id (phase.lifted (archive.id current_module archive)) id (<learn> extension) [target_name value directive] (/////generation.define! [module_id id] #.None codeG) _ (/////generation.save! id #.None directive)] @@ -174,16 +174,16 @@ (-> Archive Text Type Code (Operation anchor expression directive [expression Any]))) (do phase.monad - [state (///.lift phase.get_state) + [state (///.lifted phase.get_state) .let [analyse (get@ [#/////directive.analysis #/////directive.phase] state) synthesize (get@ [#/////directive.synthesis #/////directive.phase] state) generate (get@ [#/////directive.generation #/////directive.phase] state)] - [_ codeA] (/////directive.lift_analysis + [_ codeA] (/////directive.lifted_analysis (/////analysis.with_scope (typeA.with_fresh_env (typeA.with_type codeT (analyse archive codeC))))) - codeS (/////directive.lift_synthesis + codeS (/////directive.lifted_synthesis (synthesize archive codeA))] (<partial> archive generate extension codeT codeS)))] @@ -212,7 +212,7 @@ (def: (announce_definition! short type) (All [anchor expression directive] (-> Text Type (Operation anchor expression directive Any))) - (/////directive.lift_generation + (/////directive.lifted_generation (/////generation.log! (format short " : " (%.type type))))) (def: (lux::def expander host_analysis) @@ -221,13 +221,13 @@ (case inputsC+ (^ (list [_ (#.Identifier ["" short_name])] valueC annotationsC exported?C)) (do phase.monad - [current_module (/////directive.lift_analysis - (///.lift meta.current_module_name)) + [current_module (/////directive.lifted_analysis + (///.lifted meta.current_module_name)) .let [full_name [current_module short_name]] [type valueT value] (..definition archive full_name #.None valueC) [_ _ exported?] (evaluate! archive Bit exported?C) [_ _ annotations] (evaluate! archive Code annotationsC) - _ (/////directive.lift_analysis + _ (/////directive.lifted_analysis (module.define short_name (#.Right [(:as Bit exported?) type (:as Code annotations) value]))) _ (..refresh expander host_analysis) _ (..announce_definition! short_name type)] @@ -242,15 +242,15 @@ [($_ <>.and <code>.local_identifier <code>.any <code>.any (<code>.tuple (<>.some <code>.text)) <code>.any) (function (_ extension_name phase archive [short_name valueC annotationsC tags exported?C]) (do phase.monad - [current_module (/////directive.lift_analysis - (///.lift meta.current_module_name)) + [current_module (/////directive.lifted_analysis + (///.lifted meta.current_module_name)) .let [full_name [current_module short_name]] [_ _ exported?] (evaluate! archive Bit exported?C) [_ _ annotations] (evaluate! archive Code annotationsC) .let [exported? (:as Bit exported?) annotations (:as Code annotations)] [type valueT value] (..definition archive full_name (#.Some .Type) valueC) - _ (/////directive.lift_analysis + _ (/////directive.lifted_analysis (do phase.monad [_ (module.define short_name (#.Right [exported? type annotations value]))] (module.declare_tags tags exported? (:as Type value)))) @@ -272,7 +272,7 @@ (do {! phase.monad} [[_ _ annotationsV] (evaluate! archive Code annotationsC) .let [annotationsV (:as Code annotationsV)] - _ (/////directive.lift_analysis + _ (/////directive.lifted_analysis (do ! [_ (monad.map ! (function (_ [module alias]) (do ! @@ -294,8 +294,8 @@ (def: (define_alias alias original) (-> Text Name (/////analysis.Operation Any)) (do phase.monad - [current_module (///.lift meta.current_module_name) - constant (///.lift (meta.definition original))] + [current_module (///.lifted meta.current_module_name) + constant (///.lifted (meta.definition original))] (case constant (#.Left de_aliased) (phase.except ..cannot_alias_an_alias [[current_module alias] original de_aliased]) @@ -309,7 +309,7 @@ [($_ <>.and <code>.local_identifier <code>.identifier) (function (_ extension_name phase archive [alias def_name]) (do phase.monad - [_ (///.lift + [_ (///.lifted (phase.sub [(get@ [#/////directive.analysis #/////directive.state]) (set@ [#/////directive.analysis #/////directive.state])] (define_alias alias def_name)))] @@ -336,7 +336,7 @@ <type> (:expected handlerV))) - _ (/////directive.lift_generation + _ (/////directive.lifted_generation (/////generation.log! (format <description> " " (%.text (:as Text name)))))] (in /////directive.no_requirements)) @@ -346,17 +346,17 @@ ["Analysis" def::analysis /////analysis.Handler /////analysis.Handler - /////directive.lift_analysis + /////directive.lifted_analysis ..analyser] ["Synthesis" def::synthesis /////synthesis.Handler /////synthesis.Handler - /////directive.lift_synthesis + /////directive.lifted_synthesis ..synthesizer] ["Generation" def::generation (/////generation.Handler anchorT expressionT directiveT) (/////generation.Handler anchor expression directive) - /////directive.lift_generation + /////directive.lifted_generation ..generator] ["Directive" def::directive @@ -376,12 +376,12 @@ Code (Operation anchor expression directive Synthesis))) (do phase.monad - [[_ programA] (/////directive.lift_analysis + [[_ programA] (/////directive.lifted_analysis (/////analysis.with_scope (typeA.with_fresh_env (typeA.with_type (type (-> (List Text) (IO Any))) (analyse archive programC)))))] - (/////directive.lift_synthesis + (/////directive.lifted_synthesis (synthesize archive programA)))) (def: (define_program archive module_id generate program programS) @@ -404,15 +404,15 @@ (case inputsC+ (^ (list programC)) (do phase.monad - [state (///.lift phase.get_state) + [state (///.lifted phase.get_state) .let [analyse (get@ [#/////directive.analysis #/////directive.phase] state) synthesize (get@ [#/////directive.synthesis #/////directive.phase] state) generate (get@ [#/////directive.generation #/////directive.phase] state)] programS (prepare_program archive analyse synthesize programC) - current_module (/////directive.lift_analysis - (///.lift meta.current_module_name)) - module_id (phase.lift (archive.id current_module archive)) - _ (/////directive.lift_generation + current_module (/////directive.lifted_analysis + (///.lifted meta.current_module_name)) + module_id (phase.lifted (archive.id current_module archive)) + _ (/////directive.lifted_generation (define_program archive module_id generate program programS))] (in /////directive.no_requirements)) 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 770e1cce0..a8caf13bf 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 @@ -67,13 +67,13 @@ (def: lux_int (Bytecode Any) - ($_ _.compose + ($_ _.composite _.i2l (///value.wrap type.long))) (def: jvm_int (Bytecode Any) - ($_ _.compose + ($_ _.composite (///value.unwrap type.long) _.l2i)) @@ -87,7 +87,7 @@ (do _.monad [@then _.new_label @end _.new_label] - ($_ _.compose + ($_ _.composite (bytecode @then) (_.getstatic $Boolean "FALSE" $Boolean) (_.goto @end) @@ -116,9 +116,9 @@ [branchG (phase archive branch) @branch ///runtime.forge_label] (in [(list\map (function (_ char) - [(try.assumed (signed.s4 (.int char))) @branch]) + [(try.trusted (signed.s4 (.int char))) @branch]) chars) - ($_ _.compose + ($_ _.composite (_.set_label @branch) branchG (_.goto @end))]))) @@ -131,7 +131,7 @@ (monad.seq _.monad))]] (in (do _.monad [@else _.new_label] - ($_ _.compose + ($_ _.composite inputG (///value.unwrap type.long) _.l2i (_.lookupswitch @else table) conditionalsG @@ -142,14 +142,14 @@ (def: (lux::is [referenceG sampleG]) (Binary (Bytecode Any)) - ($_ _.compose + ($_ _.composite referenceG sampleG (..predicate _.if_acmpeq))) (def: (lux::try riskyG) (Unary (Bytecode Any)) - ($_ _.compose + ($_ _.composite riskyG (_.checkcast ///function.class) ///runtime.try)) @@ -164,7 +164,7 @@ (template [<name> <op>] [(def: (<name> [maskG inputG]) (Binary (Bytecode Any)) - ($_ _.compose + ($_ _.composite inputG (///value.unwrap type.long) maskG (///value.unwrap type.long) <op> (///value.wrap type.long)))] @@ -177,7 +177,7 @@ (template [<name> <op>] [(def: (<name> [shiftG inputG]) (Binary (Bytecode Any)) - ($_ _.compose + ($_ _.composite inputG (///value.unwrap type.long) shiftG ..jvm_int <op> (///value.wrap type.long)))] @@ -189,7 +189,7 @@ (template [<name> <type> <op>] [(def: (<name> [paramG subjectG]) (Binary (Bytecode Any)) - ($_ _.compose + ($_ _.composite subjectG (///value.unwrap <type>) paramG (///value.unwrap <type>) <op> (///value.wrap <type>)))] @@ -211,7 +211,7 @@ [(template [<name> <reference>] [(def: (<name> [paramG subjectG]) (Binary (Bytecode Any)) - ($_ _.compose + ($_ _.composite subjectG (///value.unwrap <type>) paramG (///value.unwrap <type>) <cmp> @@ -232,27 +232,27 @@ (template [<name> <prepare> <transform>] [(def: (<name> inputG) (Unary (Bytecode Any)) - ($_ _.compose + ($_ _.composite inputG <prepare> <transform>))] [i64::f64 (///value.unwrap type.long) - ($_ _.compose + ($_ _.composite _.l2d (///value.wrap type.double))] [i64::char (///value.unwrap type.long) - ($_ _.compose + ($_ _.composite _.l2i _.i2c (..::toString ..$Character type.char))] [f64::i64 (///value.unwrap type.double) - ($_ _.compose + ($_ _.composite _.d2l (///value.wrap type.long))] @@ -301,7 +301,7 @@ (def: (text::size inputG) (Unary (Bytecode Any)) - ($_ _.compose + ($_ _.composite inputG ..ensure_string (_.invokevirtual ..$String "length" (type.method [(list) type.int (list)])) @@ -312,7 +312,7 @@ (template [<name> <pre_subject> <pre_param> <op> <post>] [(def: (<name> [paramG subjectG]) (Binary (Bytecode Any)) - ($_ _.compose + ($_ _.composite subjectG <pre_subject> paramG <pre_param> <op> <post>))] @@ -330,14 +330,14 @@ (def: (text::concat [leftG rightG]) (Binary (Bytecode Any)) - ($_ _.compose + ($_ _.composite leftG ..ensure_string rightG ..ensure_string (_.invokevirtual ..$String "concat" (type.method [(list ..$String) ..$String (list)])))) (def: (text::clip [startG endG subjectG]) (Trinary (Bytecode Any)) - ($_ _.compose + ($_ _.composite subjectG ..ensure_string startG ..jvm_int endG ..jvm_int @@ -349,7 +349,7 @@ (do _.monad [@not_found _.new_label @end _.new_label] - ($_ _.compose + ($_ _.composite textG ..ensure_string partG ..ensure_string startG ..jvm_int @@ -380,7 +380,7 @@ (def: string_method (type.method [(list ..$String) type.void (list)])) (def: (io::log messageG) (Unary (Bytecode Any)) - ($_ _.compose + ($_ _.composite (_.getstatic ..$System "out" ..$PrintStream) messageG ..ensure_string @@ -389,7 +389,7 @@ (def: (io::error messageG) (Unary (Bytecode Any)) - ($_ _.compose + ($_ _.composite (_.new ..$Error) _.dup messageG 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 a79807c28..a749fb6cd 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 @@ -72,7 +72,7 @@ (template [<name> <0> <1>] [(def: <name> (Bytecode Any) - ($_ _.compose + ($_ _.composite <0> <1>))] @@ -86,7 +86,7 @@ (Unary (Bytecode Any)) (if (same? _.nop <conversion>) inputG - ($_ _.compose + ($_ _.composite inputG <conversion>)))] @@ -149,7 +149,7 @@ (template [<name> <op>] [(def: (<name> [xG yG]) (Binary (Bytecode Any)) - ($_ _.compose + ($_ _.composite xG yG <op>))] @@ -201,7 +201,7 @@ (do _.monad [@then _.new_label @end _.new_label] - ($_ _.compose + ($_ _.composite xG yG (<op> @then) @@ -224,7 +224,7 @@ (do _.monad [@then _.new_label @end _.new_label] - ($_ _.compose + ($_ _.composite xG yG <op> @@ -357,7 +357,7 @@ (function (_ extension_name generate archive arrayS) (do //////.monad [arrayG (generate archive arrayS)] - (in ($_ _.compose + (in ($_ _.composite arrayG (_.checkcast (type.array jvm_primitive)) _.arraylength))))])) @@ -369,7 +369,7 @@ (function (_ extension_name generate archive [elementJT arrayS]) (do //////.monad [arrayG (generate archive arrayS)] - (in ($_ _.compose + (in ($_ _.composite arrayG (_.checkcast (type.array elementJT)) _.arraylength))))])) @@ -381,7 +381,7 @@ (function (_ extension_name generate archive [lengthS]) (do //////.monad [lengthG (generate archive lengthS)] - (in ($_ _.compose + (in ($_ _.composite lengthG (_.newarray jvm_primitive)))))])) @@ -392,7 +392,7 @@ (function (_ extension_name generate archive [objectJT lengthS]) (do //////.monad [lengthG (generate archive lengthS)] - (in ($_ _.compose + (in ($_ _.composite lengthG (_.anewarray objectJT)))))])) @@ -404,7 +404,7 @@ (do //////.monad [arrayG (generate archive arrayS) idxG (generate archive idxS)] - (in ($_ _.compose + (in ($_ _.composite arrayG (_.checkcast (type.array jvm_primitive)) idxG @@ -418,7 +418,7 @@ (do //////.monad [arrayG (generate archive arrayS) idxG (generate archive idxS)] - (in ($_ _.compose + (in ($_ _.composite arrayG (_.checkcast (type.array elementJT)) idxG @@ -433,7 +433,7 @@ [arrayG (generate archive arrayS) idxG (generate archive idxS) valueG (generate archive valueS)] - (in ($_ _.compose + (in ($_ _.composite arrayG (_.checkcast (type.array jvm_primitive)) _.dup @@ -450,7 +450,7 @@ [arrayG (generate archive arrayS) idxG (generate archive idxS) valueG (generate archive valueS)] - (in ($_ _.compose + (in ($_ _.composite arrayG (_.checkcast (type.array elementJT)) _.dup @@ -517,7 +517,7 @@ (do _.monad [@then _.new_label @end _.new_label] - ($_ _.compose + ($_ _.composite objectG (_.ifnull @then) ..falseG @@ -528,7 +528,7 @@ (def: (object::synchronized [monitorG exprG]) (Binary (Bytecode Any)) - ($_ _.compose + ($_ _.composite monitorG _.dup _.monitorenter @@ -538,7 +538,7 @@ (def: (object::throw exceptionG) (Unary (Bytecode Any)) - ($_ _.compose + ($_ _.composite exceptionG _.athrow)) @@ -552,7 +552,7 @@ (function (_ extension_name generate archive [class]) (do //////.monad [] - (in ($_ _.compose + (in ($_ _.composite (_.string class) (_.invokestatic ..$Class "forName" (type.method [(list ..$String) ..$Class (list)]))))))])) @@ -563,7 +563,7 @@ (function (_ extension_name generate archive [class objectS]) (do //////.monad [objectG (generate archive objectS)] - (in ($_ _.compose + (in ($_ _.composite objectG (_.instanceof (type.class class (list))) (_.invokestatic ..$Boolean "valueOf" (type.method [(list type.boolean) ..$Boolean (list)]))))))])) @@ -586,7 +586,7 @@ (text\= <object> to)) (let [$<object> (type.class <object> (list))] - ($_ _.compose + ($_ _.composite valueG (_.invokestatic $<object> "valueOf" (type.method [(list <type>) $<object> (list)])))) @@ -595,7 +595,7 @@ (text\= (..reflection <type>) to)) (let [$<object> (type.class <object> (list))] - ($_ _.compose + ($_ _.composite valueG (_.checkcast $<object>) (_.invokevirtual $<object> <unwrap> (type.method [(list) <type> (list)]))))] @@ -662,13 +662,13 @@ .let [$class (type.class class (list))]] (case (dictionary.value unboxed ..primitives) (#.Some primitive) - (in ($_ _.compose + (in ($_ _.composite valueG (_.putstatic $class field primitive) ..unitG)) #.None - (in ($_ _.compose + (in ($_ _.composite valueG (_.checkcast $class) (_.putstatic $class field $class) @@ -688,7 +688,7 @@ #.None (_.getfield $class field (type.class unboxed (list))))]] - (in ($_ _.compose + (in ($_ _.composite objectG (_.checkcast $class) getG))))])) @@ -708,10 +708,10 @@ #.None (let [$unboxed (type.class unboxed (list))] - ($_ _.compose + ($_ _.composite (_.checkcast $unboxed) (_.putfield $class field $unboxed))))]] - (in ($_ _.compose + (in ($_ _.composite objectG (_.checkcast $class) _.dup @@ -733,7 +733,7 @@ (in [valueT valueG]) (#.Left valueT) - (in [valueT ($_ _.compose + (in [valueT ($_ _.composite valueG (_.checkcast valueT))])))) @@ -753,7 +753,7 @@ (function (_ extension_name generate archive [class method outputT inputsTS]) (do {! //////.monad} [inputsTG (monad.map ! (generate_input generate archive) inputsTS)] - (in ($_ _.compose + (in ($_ _.composite (monad.map _.monad product.right inputsTG) (_.invokestatic class method (type.method [(list\map product.left inputsTG) outputT (list)])) (prepare_output outputT)))))])) @@ -767,7 +767,7 @@ (do {! //////.monad} [objectG (generate archive objectS) inputsTG (monad.map ! (generate_input generate archive) inputsTS)] - (in ($_ _.compose + (in ($_ _.composite objectG (_.checkcast class) (monad.map _.monad product.right inputsTG) @@ -786,7 +786,7 @@ (function (_ extension_name generate archive [class inputsTS]) (do {! //////.monad} [inputsTG (monad.map ! (generate_input generate archive) inputsTS)] - (in ($_ _.compose + (in ($_ _.composite (_.new class) _.dup (monad.map _.monad product.right inputsTG) @@ -946,13 +946,13 @@ list.size list.indices (monad.map _.monad (.function (_ register) - ($_ _.compose + ($_ _.composite (_.aload 0) (_.aload (inc register)) (_.putfield class (///reference.foreign_name register) $Object)))))] (method.method method.public "<init>" (anonymous_init_method env) (list) - (#.Some ($_ _.compose + (#.Some ($_ _.composite (_.aload 0) (monad.map _.monad product.right inputsTG) (_.invokespecial super_class "<init>" (type.method [(list\map product.left inputsTG) type.void (list)])) @@ -963,7 +963,7 @@ (-> Phase Archive (Type category.Class) (Environment Synthesis) (Operation (Bytecode Any))) (do {! //////.monad} [captureG+ (monad.map ! (generate archive) env)] - (in ($_ _.compose + (in ($_ _.composite (_.new class) _.dup (monad.seq _.monad captureG+) @@ -978,7 +978,7 @@ (#.Left returnT) (case (type.primitive? returnT) (#.Left returnT) - ($_ _.compose + ($_ _.composite (_.checkcast returnT) _.areturn) @@ -1040,7 +1040,7 @@ [(#//////variable.Foreign foreign_id) (|> global_mapping (dictionary.value capture) - maybe.assume)])) + maybe.trusted)])) (dictionary.from_list //////variable.hash))] [ownerT name strict_fp? annotations vars @@ -1066,12 +1066,12 @@ returnT exceptionsT]) (list) - (#.Some ($_ _.compose + (#.Some ($_ _.composite bodyG (returnG returnT))))))) normalized_methods) bytecode (<| (\ ! map (format.result class.writer)) - //////.lift + //////.lifted (class.class version.v6_0 ($_ modifier\compose class.public class.final) (name.internal anonymous_class_name) (name.internal (..reflection super_class)) 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 d7a20b360..aebb30404 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 @@ -42,7 +42,7 @@ 1 _.pop 2 _.pop2 _ ... (n.> 2) - ($_ _.compose + ($_ _.composite _.pop2 (pop_alt (n.- 2 stack_depth))))) @@ -60,19 +60,19 @@ (def: peek (Bytecode Any) - ($_ _.compose + ($_ _.composite _.dup (//runtime.get //runtime.stack_head))) (def: pop (Bytecode Any) - ($_ _.compose + ($_ _.composite (//runtime.get //runtime.stack_tail) (_.checkcast //type.stack))) (def: (left_projection lefts) (-> Nat (Bytecode Any)) - ($_ _.compose + ($_ _.composite (_.checkcast //type.tuple) (..int lefts) (.case lefts @@ -84,7 +84,7 @@ (def: (right_projection lefts) (-> Nat (Bytecode Any)) - ($_ _.compose + ($_ _.composite (_.checkcast //type.tuple) (..int lefts) //runtime.right_projection)) @@ -96,14 +96,14 @@ (operation\in ..pop) (#synthesis.Bind register) - (operation\in ($_ _.compose + (operation\in ($_ _.composite ..peek (_.astore register))) (#synthesis.Then bodyS) (do phase.monad [bodyG (phase archive bodyS)] - (in ($_ _.compose + (in ($_ _.composite (..pop_alt stack_depth) bodyG (_.goto @end)))) @@ -114,7 +114,7 @@ (do _.monad [@success _.new_label @fail _.new_label] - ($_ _.compose + ($_ _.composite ..peek (_.checkcast //type.variant) (//structure.tag lefts <right?>) @@ -133,7 +133,7 @@ (^template [<pattern> <projection>] [(^ (<pattern> lefts)) - (operation\in ($_ _.compose + (operation\in ($_ _.composite ..peek (<projection> lefts) //runtime.push))]) @@ -146,7 +146,7 @@ (synthesis.!bind_top register thenP))) (do phase.monad [thenG (path' stack_depth @else @end phase archive thenP)] - (in ($_ _.compose + (in ($_ _.composite ..peek (_.checkcast //type.tuple) _.iconst_0 @@ -161,7 +161,7 @@ (synthesis.!bind_top register thenP))) (do phase.monad [then! (path' stack_depth @else @end phase archive thenP)] - (in ($_ _.compose + (in ($_ _.composite ..peek (_.checkcast //type.tuple) (..int lefts) @@ -176,7 +176,7 @@ [@alt_else //runtime.forge_label left! (path' (inc stack_depth) @alt_else @end phase archive leftP) right! (path' stack_depth @else @end phase archive rightP)] - (in ($_ _.compose + (in ($_ _.composite _.dup left! (_.set_label @alt_else) @@ -187,7 +187,7 @@ (do phase.monad [left! (path' stack_depth @else @end phase archive leftP) right! (path' stack_depth @else @end phase archive rightP)] - (in ($_ _.compose + (in ($_ _.composite left! right!))) @@ -200,7 +200,7 @@ (do phase.monad [@else //runtime.forge_label pathG (..path' 1 @else @end phase archive path)] - (in ($_ _.compose + (in ($_ _.composite pathG (_.set_label @else) _.pop @@ -217,7 +217,7 @@ (in (do _.monad [@else _.new_label @end _.new_label] - ($_ _.compose + ($_ _.composite conditionG (//value.unwrap type.boolean) (_.ifeq @else) @@ -232,7 +232,7 @@ (do phase.monad [inputG (phase archive inputS) bodyG (phase archive bodyS)] - (in ($_ _.compose + (in ($_ _.composite inputG (_.astore register) bodyG)))) @@ -248,7 +248,7 @@ (#.Right lefts) (..right_projection lefts))] - (_.compose so_far next))) + (_.composite so_far next))) recordG (list.reversed path))))) @@ -258,7 +258,7 @@ [@end //runtime.forge_label valueG (phase archive valueS) pathG (..path @end phase archive path)] - (in ($_ _.compose + (in ($_ _.composite _.aconst_null valueG //runtime.push 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 095c973b4..f3938db06 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 @@ -104,13 +104,13 @@ (generate archive bodyS))) .let [function_class (//runtime.class_name function_context)] [fields methods instance] (..with generate archive @begin function_class environment arity bodyG) - class (phase.lift (class.class version.v6_0 - ..modifier - (name.internal function_class) - (..internal /abstract.class) (list) - fields - methods - (row.row))) + class (phase.lifted (class.class version.v6_0 + ..modifier + (name.internal function_class) + (..internal /abstract.class) (list) + fields + methods + (row.row))) .let [bytecode (format.result class.writer class)] _ (generation.execute! [function_class bytecode]) _ (generation.save! function_class #.None [function_class bytecode])] @@ -121,13 +121,13 @@ (do {! phase.monad} [abstractionG (generate archive abstractionS) inputsG (monad.map ! (generate archive) inputsS)] - (in ($_ _.compose + (in ($_ _.composite abstractionG (|> inputsG (list.sub /arity.maximum) (monad.map _.monad (function (_ batchG) - ($_ _.compose + ($_ _.composite (_.checkcast /abstract.class) (monad.seq _.monad batchG) (_.invokevirtual /abstract.class //runtime.apply::name (//runtime.apply::type (list.size batchG))) 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 328921a19..ba69187b8 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 @@ -25,14 +25,14 @@ (def: .public (get class name) (-> (Type Class) Text (Bytecode Any)) - ($_ _.compose + ($_ _.composite ////reference.this (_.getfield class name ..type) )) (def: .public (put naming class register value) (-> (-> Register Text) (Type Class) Register (Bytecode Any) (Bytecode Any)) - ($_ _.compose + ($_ _.composite ////reference.this value (_.putfield class (naming register) ..type))) 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 0b4208bec..57d285e8a 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 @@ -32,7 +32,7 @@ (def: .public (initial amount) (-> Nat (Bytecode Any)) - ($_ _.compose + ($_ _.composite (|> _.aconst_null (list.repeated amount) (monad.seq _.monad)) @@ -53,7 +53,7 @@ (def: .public (new arity) (-> Arity (Bytecode Any)) (if (arity.multiary? arity) - ($_ _.compose + ($_ _.composite /count.initial (initial (n.- ///arity.minimum arity))) (_\in []))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial/count.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial/count.lux index 4bc179078..30f27def6 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial/count.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/function/field/variable/partial/count.lux @@ -18,14 +18,17 @@ (def: .public initial (Bytecode Any) - (|> +0 signed.s1 try.assumed _.bipush)) + (|> +0 + signed.s1 + try.trusted + _.bipush)) (def: this _.aload_0) (def: .public value (Bytecode Any) - ($_ _.compose + ($_ _.composite ..this (_.getfield /////abstract.class ..field ..type) )) 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 f90f1999b..da3292be8 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 @@ -49,13 +49,13 @@ (def: (increment by) (-> Nat (Bytecode Any)) - ($_ _.compose + ($_ _.composite (<| _.int .i64 by) _.iadd)) (def: (inputs offset amount) (-> Register Nat (Bytecode Any)) - ($_ _.compose + ($_ _.composite (|> amount list.indices (monad.map _.monad (|>> (n.+ offset) _.aload))) @@ -65,7 +65,7 @@ (def: (apply offset amount) (-> Register Nat (Bytecode Any)) (let [arity (n.min amount ///arity.maximum)] - ($_ _.compose + ($_ _.composite (_.checkcast ///abstract.class) (..inputs offset arity) (_.invokevirtual ///abstract.class ////runtime.apply::name (////runtime.apply::type arity)) @@ -86,7 +86,7 @@ (////runtime.apply::type apply_arity) (list) (#.Some (case num_partials - 0 ($_ _.compose + 0 ($_ _.composite ////reference.this (..inputs ..this_offset apply_arity) (_.invokevirtual class //implementation.name (//implementation.type function_arity)) @@ -107,10 +107,10 @@ already_partial? (n.> 0 stage) exact_match? (i.= over_extent (.int stage)) has_more_than_necessary? (i.> over_extent (.int stage))] - ($_ _.compose + ($_ _.composite (_.set_label @case) (cond exact_match? - ($_ _.compose + ($_ _.composite ////reference.this (if already_partial? (_.invokevirtual class //reset.name (//reset.type class)) @@ -123,7 +123,7 @@ has_more_than_necessary? (let [arity_inputs (|> function_arity (n.- stage)) additional_inputs (|> apply_arity (n.- arity_inputs))] - ($_ _.compose + ($_ _.composite ////reference.this (_.invokevirtual class //reset.name (//reset.type class)) current_partials @@ -139,7 +139,7 @@ missing_partials (|> _.aconst_null (list.repeated (|> num_partials (n.- apply_arity) (n.- stage))) (monad.seq _.monad))] - ($_ _.compose + ($_ _.composite (_.new class) _.dup current_environment @@ -151,7 +151,7 @@ (_.invokevirtual class //init.name (//init.type environment function_arity)) _.areturn))))))) (monad.seq _.monad))]] - ($_ _.compose + ($_ _.composite ///partial/count.value - (_.tableswitch (try.assumed (signed.s4 +0)) @default [@labelsH @labelsT]) + (_.tableswitch (try.trusted (signed.s4 +0)) @default [@labelsH @labelsT]) cases))))))) 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 a43a4c0bc..a6bd0ef6b 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 @@ -31,7 +31,7 @@ (method.method //.modifier name (..type arity) (list) - (#.Some ($_ _.compose + (#.Some ($_ _.composite (_.set_label @begin) body _.areturn 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 ac11c1cf3..cd92f4aca 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 @@ -56,12 +56,16 @@ type.void (list)])) -(def: no_partials (|> 0 unsigned.u1 try.assumed _.bipush)) +(def: no_partials + (|> 0 + unsigned.u1 + try.trusted + _.bipush)) (def: .public (super environment_size arity) (-> Nat Arity (Bytecode Any)) (let [arity_register (inc environment_size)] - ($_ _.compose + ($_ _.composite (if (arity.unary? arity) ..no_partials (_.iload arity_register)) @@ -90,7 +94,7 @@ (method.method //.modifier ..name (..type environment arity) (list) - (#.Some ($_ _.compose + (#.Some ($_ _.composite ////reference.this (..super environment_size arity) (store_all environment_size (///foreign.put class) offset_foreign) 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 45ea0b010..d153b35e9 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 @@ -44,7 +44,7 @@ (def: .public (instance' foreign_setup class environment arity) (-> (List (Bytecode Any)) (Type Class) (Environment Synthesis) Arity (Bytecode Any)) - ($_ _.compose + ($_ _.composite (_.new class) _.dup (monad.seq _.monad foreign_setup) @@ -69,7 +69,7 @@ (method.method //.modifier //init.name (//init.type environment arity) (list) - (#.Some ($_ _.compose + (#.Some ($_ _.composite ////reference.this (//init.super environment_size arity) (monad.map _.monad (function (_ register) 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 615cc0388..d787bf16e 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 @@ -43,7 +43,7 @@ (method.method //.modifier ..name (..type class) (list) - (#.Some ($_ _.compose + (#.Some ($_ _.composite (if (arity.multiary? arity) (//new.instance' (..current_environment class environment) class environment arity) ////reference.this) 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 4db70e828..4915e010a 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 @@ -108,7 +108,7 @@ (list (method.method ..init::modifier "<clinit>" ..init::type (list) (#.Some - ($_ _.compose + ($_ _.composite valueG (_.putstatic (type.class bytecode_name (list)) ..value::field ..value::type) _.return)))) @@ -128,7 +128,7 @@ [existing_class? (|> (atom.read! library) (\ io.monad map (function (_ library) (dictionary.key? library class_name))) - (try.lift io.monad) + (try.lifted io.monad) (: (IO (Try Bit)))) _ (if existing_class? (in []) 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 3e009b116..6757bc987 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 @@ -53,7 +53,7 @@ [fetchG (translate archive updateS) .let [storeG (_.astore register)]] (in [fetchG storeG]))))))] - (in ($_ _.compose + (in ($_ _.composite ... It may look weird that first I fetch all the values separately, ... and then I store them all. ... It must be done that way in order to avoid a potential bug. @@ -80,11 +80,11 @@ (translate archive iterationS)) .let [initializationG (|> (list.enumeration initsI+) (list\map (function (_ [index initG]) - ($_ _.compose + ($_ _.composite initG (_.astore (n.+ offset index))))) (monad.seq _.monad))]] - (in ($_ _.compose + (in ($_ _.composite initializationG (_.set_label @begin) iterationG)))) 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 f7ba0eb93..419c4eac9 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 @@ -58,19 +58,19 @@ (def: amount_of_inputs (Bytecode Any) - ($_ _.compose + ($_ _.composite _.aload_0 _.arraylength)) (def: decrease (Bytecode Any) - ($_ _.compose + ($_ _.composite _.iconst_1 _.isub)) (def: head (Bytecode Any) - ($_ _.compose + ($_ _.composite _.dup _.aload_0 _.swap @@ -81,7 +81,7 @@ (def: pair (Bytecode Any) - ($_ _.compose + ($_ _.composite _.iconst_2 (_.anewarray ^Object) _.dup_x1 @@ -102,7 +102,7 @@ (do _.monad [@loop _.new_label @end _.new_label] - ($_ _.compose + ($_ _.composite ..nil ..amount_of_inputs (_.set_label @loop) @@ -122,7 +122,7 @@ (def: run_io (Bytecode Any) - ($_ _.compose + ($_ _.composite (_.checkcast //function/abstract.class) _.aconst_null //runtime.apply)) @@ -132,7 +132,7 @@ (let [super_class (|> ..^Object type.reflection reflection.reflection name.internal) main (method.method ..main::modifier "main" ..main::type (list) - (#.Some ($_ _.compose + (#.Some ($_ _.composite program ..input_list ..feed_inputs @@ -140,7 +140,7 @@ _.return)))] [..class (<| (format.result class.writer) - try.assumed + try.trusted (class.class version.v6_0 ..program::modifier (name.internal ..class) 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 d983068b9..3dafea811 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 @@ -44,7 +44,7 @@ (do {! ////.monad} [bytecode_name (\ ! map //runtime.class_name (generation.context archive))] - (in ($_ _.compose + (in ($_ _.composite ..this (_.getfield (type.class bytecode_name (list)) (..foreign_name variable) 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 8fcd70360..f11c871c1 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 @@ -113,13 +113,13 @@ (def: .public (get index) (-> (Bytecode Any) (Bytecode Any)) - ($_ _.compose + ($_ _.composite index _.aaload)) (def: (set! index value) (-> (Bytecode Any) (Bytecode Any) (Bytecode Any)) - ($_ _.compose + ($_ _.composite ... A _.dup ... AA index ... AAI @@ -138,10 +138,10 @@ (def: variant_value _.iconst_2) (def: variant::method - (let [new_variant ($_ _.compose + (let [new_variant ($_ _.composite _.iconst_3 (_.anewarray //type.value)) - $tag ($_ _.compose + $tag ($_ _.composite _.iload_0 (//value.wrap type.int)) $last? _.aload_1 @@ -149,7 +149,7 @@ (method.method ..modifier ..variant::name ..variant::type (list) - (#.Some ($_ _.compose + (#.Some ($_ _.composite new_variant ... A[3] (..set! ..variant_tag $tag) ... A[3] (..set! ..variant_last? $last?) ... A[3] @@ -161,7 +161,7 @@ (def: .public left_injection (Bytecode Any) - ($_ _.compose + ($_ _.composite _.iconst_0 ..left_flag _.dup2_x1 @@ -170,7 +170,7 @@ (def: .public right_injection (Bytecode Any) - ($_ _.compose + ($_ _.composite _.iconst_1 ..right_flag _.dup2_x1 @@ -181,7 +181,7 @@ (def: .public none_injection (Bytecode Any) - ($_ _.compose + ($_ _.composite _.iconst_0 ..left_flag ..unit @@ -192,7 +192,7 @@ (do _.monad [@try _.new_label @handler _.new_label] - ($_ _.compose + ($_ _.composite (_.try @try @handler @handler //type.error) (_.set_label @try) $unsafe @@ -213,7 +213,7 @@ (list) (#.Some (..risky - ($_ _.compose + ($_ _.composite _.aload_0 (_.invokestatic //type.frac "parseDouble" (type.method [(list) (list //type.text) type.double (list)])) (//value.wrap type.double) @@ -226,7 +226,7 @@ out (_.getstatic ^System "out" ^PrintStream) print_type (type.method [(list) (list //type.value) type.void (list)]) print! (function (_ method) (_.invokevirtual ^PrintStream method print_type))] - ($_ _.compose + ($_ _.composite out (_.string "LUX LOG: ") (print! "print") out _.swap (print! "println")))) @@ -234,7 +234,7 @@ (def: (illegal_state_exception message) (-> Text (Bytecode Any)) (let [^IllegalStateException (type.class "java.lang.IllegalStateException" (list))] - ($_ _.compose + ($_ _.composite (_.new ^IllegalStateException) _.dup (_.string message) @@ -249,7 +249,7 @@ ..failure::type (list) (#.Some - ($_ _.compose + ($_ _.composite (..illegal_state_exception message) _.athrow)))) @@ -271,12 +271,12 @@ ..push::type (list) (#.Some - (let [new_stack_frame! ($_ _.compose + (let [new_stack_frame! ($_ _.composite _.iconst_2 (_.anewarray //type.value)) $head _.aload_1 $tail _.aload_0] - ($_ _.compose + ($_ _.composite new_stack_frame! (..set! ..stack_head $head) (..set! ..stack_tail $tail) @@ -296,7 +296,7 @@ @tags_match! _.new_label @maybe_nested _.new_label @mismatch! _.new_label - .let [::tag ($_ _.compose + .let [::tag ($_ _.composite (..get ..variant_tag) (//value.unwrap type.int)) ::last? (..get ..variant_last?) @@ -309,29 +309,29 @@ not_found _.aconst_null update_$tag _.isub - update_$variant ($_ _.compose + update_$variant ($_ _.composite $variant ::value (_.checkcast //type.variant) _.astore_0) recur (: (-> Label (Bytecode Any)) (function (_ @loop_start) - ($_ _.compose + ($_ _.composite ... tag, sumT update_$variant ... tag, sumT update_$tag ... sub_tag (_.goto @loop_start)))) - super_nested_tag ($_ _.compose + super_nested_tag ($_ _.composite ... tag, sumT _.swap ... sumT, tag _.isub) - super_nested ($_ _.compose + super_nested ($_ _.composite ... tag, sumT super_nested_tag ... super_tag $variant ::last? ... super_tag, super_last $variant ::value ... super_tag, super_last, super_value ..variant)]] - ($_ _.compose + ($_ _.composite $tag (_.set_label @loop) $variant ::tag @@ -369,23 +369,23 @@ (def: projection::method2 [(Resource Method) (Resource Method)] (let [$tuple _.aload_0 - $tuple::size ($_ _.compose + $tuple::size ($_ _.composite $tuple _.arraylength) $lefts _.iload_1 - $last_right ($_ _.compose + $last_right ($_ _.composite $tuple::size _.iconst_1 _.isub) - update_$lefts ($_ _.compose + update_$lefts ($_ _.composite $lefts $last_right _.isub _.istore_1) - update_$tuple ($_ _.compose + update_$tuple ($_ _.composite $tuple $last_right _.aaload (_.checkcast //type.tuple) _.astore_0) recur (: (-> Label (Bytecode Any)) (function (_ @loop) - ($_ _.compose + ($_ _.composite update_$lefts update_$tuple (_.goto @loop)))) @@ -397,9 +397,9 @@ (do _.monad [@loop _.new_label @recursive _.new_label - .let [::left ($_ _.compose + .let [::left ($_ _.composite $lefts _.aaload)]] - ($_ _.compose + ($_ _.composite (_.set_label @loop) $lefts $last_right (_.if_icmpge @recursive) $tuple ::left @@ -416,19 +416,19 @@ [@loop _.new_label @not_tail _.new_label @slice _.new_label - .let [$right ($_ _.compose + .let [$right ($_ _.composite $lefts _.iconst_1 _.iadd) - $::nested ($_ _.compose + $::nested ($_ _.composite $tuple _.swap _.aaload) - super_nested ($_ _.compose + super_nested ($_ _.composite $tuple $right $tuple::size (_.invokestatic (type.class "java.util.Arrays" (list)) "copyOfRange" (type.method [(list) (list //type.tuple //type.index //type.index) //type.tuple (list)])))]] - ($_ _.compose + ($_ _.composite (_.set_label @loop) $last_right $right _.dup2 (_.if_icmpne @not_tail) @@ -472,13 +472,13 @@ unit _.aconst_null ^StringWriter (type.class "java.io.StringWriter" (list)) - string_writer ($_ _.compose + string_writer ($_ _.composite (_.new ^StringWriter) _.dup (_.invokespecial ^StringWriter "<init>" (type.method [(list) (list) type.void (list)]))) ^PrintWriter (type.class "java.io.PrintWriter" (list)) - print_writer ($_ _.compose + print_writer ($_ _.composite ... WTW (_.new ^PrintWriter) ... WTWP _.dup_x1 ... WTPWP @@ -487,7 +487,7 @@ (_.invokespecial ^PrintWriter "<init>" (type.method [(list) (list (type.class "java.io.Writer" (list)) type.boolean) type.void (list)])) ... WTP )]] - ($_ _.compose + ($_ _.composite (_.try @try @handler @handler //type.error) (_.set_label @try) $unsafe unit ..apply @@ -516,7 +516,7 @@ class.public class.final)) bytecode (<| (format.result class.writer) - try.assumed + try.trusted (class.class jvm/version.v6_0 modifier (name.internal class) @@ -551,7 +551,7 @@ (let [previous_inputs (|> arity list.indices (monad.map _.monad _.aload))] - ($_ _.compose + ($_ _.composite previous_inputs (_.invokevirtual //function.class ..apply::name (..apply::type (dec arity))) (_.checkcast //function.class) @@ -566,7 +566,7 @@ (list) (#.Some (let [$partials _.iload_1] - ($_ _.compose + ($_ _.composite ..this (_.invokespecial ^Object "<init>" (type.method [(list) (list) type.void (list)])) ..this @@ -584,7 +584,7 @@ //function/count.type (row.row))) bytecode (<| (format.result class.writer) - try.assumed + try.trusted (class.class jvm/version.v6_0 modifier (name.internal class) 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 fa7627b97..2eff33115 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 @@ -44,6 +44,6 @@ (def: .public (unwrap type) (-> (Type Primitive) (Bytecode Any)) (let [wrapper (type.class (primitive_wrapper type) (list))] - ($_ _.compose + ($_ _.composite (_.checkcast wrapper) (_.invokevirtual wrapper (primitive_unwrap type) (type.method [(list) (list) type (list)]))))) 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 2b9202239..c234f9902 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 @@ -100,4 +100,4 @@ Phase (do phase.monad [synthesis (..optimization archive analysis)] - (phase.lift (/variable.optimization synthesis)))) + (phase.lifted (/variable.optimization synthesis)))) 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 78dc5dce1..feadf7fa5 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 @@ -241,7 +241,7 @@ dictionary.entries (list\map (function (_ [register redundant?]) (%.format (%.nat register) ": " (%.bit redundant?)))) - (text.join_with ", "))) + (text.interposed ", "))) (def: (path_optimization optimization) (-> (Optimization Synthesis) (Optimization Path)) 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 806fdc3c9..58dc336dd 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -279,7 +279,7 @@ (|> (#.Item item) (list\map (function (_ [test then]) (format (<format> test) " " (%path' %then then)))) - (text.join_with " ") + (text.interposed " ") (text.enclosed ["(? " ")"]))]) ([#I64_Fork (|>> .int %.int)] [#F64_Fork %.frac] @@ -341,7 +341,7 @@ (#analysis.Tuple members) (|> members (list\map %synthesis) - (text.join_with " ") + (text.interposed " ") (text.enclosed ["[" "]"]))) (#Reference reference) @@ -354,7 +354,7 @@ (#Abstraction [environment arity body]) (let [environment' (|> environment (list\map %synthesis) - (text.join_with " ") + (text.interposed " ") (text.enclosed ["[" "]"]))] (|> (format environment' " " (%.nat arity) " " (%synthesis body)) (text.enclosed ["(#function " ")"]))) @@ -362,7 +362,7 @@ (#Apply func args) (|> args (list\map %synthesis) - (text.join_with " ") + (text.interposed " ") (format (%synthesis func) " ") (text.enclosed ["(" ")"]))) @@ -392,7 +392,7 @@ (|> (format (%.nat (get@ #start scope)) " " (|> (get@ #inits scope) (list\map %synthesis) - (text.join_with " ") + (text.interposed " ") (text.enclosed ["[" "]"])) " " (%synthesis (get@ #iteration scope))) (text.enclosed ["(#loop " ")"])) @@ -400,12 +400,12 @@ (#Recur args) (|> args (list\map %synthesis) - (text.join_with " ") + (text.interposed " ") (text.enclosed ["(#recur " ")"])))) (#Extension [name args]) (|> (list\map %synthesis args) - (text.join_with " ") + (text.interposed " ") (format (%.text name) " ") (text.enclosed ["(" ")"])))) diff --git a/stdlib/source/library/lux/tool/compiler/phase.lux b/stdlib/source/library/lux/tool/compiler/phase.lux index d1cecbe50..92680654d 100644 --- a/stdlib/source/library/lux/tool/compiler/phase.lux +++ b/stdlib/source/library/lux/tool/compiler/phase.lux @@ -70,13 +70,13 @@ (def: .public failure (-> Text Operation) - (|>> #try.Failure (state.lift try.monad))) + (|>> #try.Failure (state.lifted try.monad))) (def: .public (except exception parameters) (All [e] (-> (Exception e) e Operation)) (..failure (ex.error exception parameters))) -(def: .public (lift error) +(def: .public (lifted error) (All [s a] (-> (Try a) (Operation s a))) (function (_ state) (try\map (|>> [state]) error))) @@ -93,7 +93,7 @@ (function (_ archive input state) (#try.Success [state input]))) -(def: .public (compose 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/interpreter.lux b/stdlib/source/library/lux/tool/interpreter.lux index 14f53e927..6e28d5c1a 100644 --- a/stdlib/source/library/lux/tool/interpreter.lux +++ b/stdlib/source/library/lux/tool/interpreter.lux @@ -60,7 +60,7 @@ (def: enter_module (All [anchor expression directive] (Operation anchor expression directive Any)) - (directive.lift_analysis + (directive.lifted_analysis (do phase.monad [_ (module.create 0 ..module)] (analysis.set_current_module ..module)))) @@ -101,11 +101,11 @@ (All [anchor expression directive] (-> Code <Interpretation>)) (do {! phase.monad} - [state (extension.lift phase.get_state) + [state (extension.lifted phase.get_state) .let [analyse (get@ [#directive.analysis #directive.phase] state) synthesize (get@ [#directive.synthesis #directive.phase] state) generate (get@ [#directive.generation #directive.phase] state)] - [_ codeT codeA] (directive.lift_analysis + [_ codeT codeA] (directive.lifted_analysis (analysis.with_scope (type.with_fresh_env (do ! @@ -114,9 +114,9 @@ codeT (type.with_env (check.clean codeT))] (in [codeT codeA]))))) - codeS (directive.lift_synthesis + codeS (directive.lifted_synthesis (synthesize codeA))] - (directive.lift_generation + (directive.lifted_generation (generation.with_buffer (do ! [codeH (generate codeS) diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux index 97cdf5a3d..c6be00945 100644 --- a/stdlib/source/library/lux/type.lux +++ b/stdlib/source/library/lux/type.lux @@ -1,7 +1,7 @@ (.module: {#.doc "Basic functionality for working with types."} [library - [lux (#- function) + [lux (#- function :as) ["@" target] [abstract [equivalence (#+ Equivalence)] @@ -132,7 +132,7 @@ (^template [<tag> <desc>] [(<tag> env body) - ($_ text\compose "(" <desc> " {" (|> env (list\map format) (text.join_with " ")) "} " (format body) ")")]) + ($_ text\compose "(" <desc> " {" (|> env (list\map format) (text.interposed " ")) "} " (format body) ")")]) ([#.UnivQ "All"] [#.ExQ "Ex"]) @@ -174,7 +174,7 @@ ($_ text\compose (n\encode index) " " (..format type)))) - (text.join_with (text\compose text.new_line " "))))) + (text.interposed (text\compose text.new_line " "))))) (list.item idx env)) _ @@ -441,18 +441,18 @@ (Parser (List Text)) (<code>.tuple (<>.some <code>.local_identifier))) -(syntax: .public (:cast [type_vars type_parameters - input <code>.any - output <code>.any - value (<>.maybe <code>.any)]) +(syntax: .public (:as [type_vars type_parameters + input <code>.any + output <code>.any + value (<>.maybe <code>.any)]) {#.doc (example "Casts a value to a specific type." "The specified type can depend on type variables of the original type of the value." (: (Bar Bit Nat Text) - (:cast [a b c] - (Foo a [b c]) - (Bar a b c) - (: (Foo Bit [Nat Text]) - (foo expression)))) + (:as [a b c] + (Foo a [b c]) + (Bar a b c) + (: (Foo Bit [Nat Text]) + (foo expression)))) "NOTE: Careless use of type-casts is an easy way to introduce bugs. USE WITH CAUTION.")} (let [casterC (` (: (All [(~+ (list\map code.local_identifier type_vars))] (-> (~ input) (~ output))) @@ -478,13 +478,13 @@ computation ..typed]) {#.doc (example "Allows specifing the type of an expression as sharing type-variables with the type of another expression." (: (Bar Bit Nat Text) - (:cast [a b c] - (Foo a [b c]) - (: (Foo Bit [Nat Text]) - (foo expression)) - - (Bar a b c) - (bar expression))))} + (:sharing [a b c] + (Foo a [b c]) + (: (Foo Bit [Nat Text]) + (foo expression)) + + (Bar a b c) + (bar expression))))} (macro.with_identifiers [g!_] (let [shareC (` (: (All [(~+ (list\map code.local_identifier type_vars))] (-> (~ (get@ #type exemplar)) diff --git a/stdlib/source/library/lux/type/abstract.lux b/stdlib/source/library/lux/type/abstract.lux index 362167393..25c864755 100644 --- a/stdlib/source/library/lux/type/abstract.lux +++ b/stdlib/source/library/lux/type/abstract.lux @@ -1,7 +1,6 @@ (.module: [library [lux #* - [type (#+ :cast)] ["." meta] [abstract [monad (#+ Monad do)]] @@ -17,7 +16,8 @@ [macro ["." code] [syntax (#+ syntax:) - ["|.|" annotations]]]]]) + ["|.|" annotations]]]]] + ["." //]) (type: Stack List) @@ -185,7 +185,7 @@ value))))} (do meta.monad [[name type_vars abstraction representation] (peek! frame)] - (in (list (` ((~! :cast) [(~+ type_vars)] (~ <from>) (~ <to>) + (in (list (` ((~! //.:as) [(~+ type_vars)] (~ <from>) (~ <to>) (~ value)))))))] [:abstraction representation abstraction] diff --git a/stdlib/source/library/lux/type/implicit.lux b/stdlib/source/library/lux/type/implicit.lux index 6d5195708..99cafdcda 100644 --- a/stdlib/source/library/lux/type/implicit.lux +++ b/stdlib/source/library/lux/type/implicit.lux @@ -170,7 +170,7 @@ [[id var] check.var] (|> func (type.applied (list var)) - maybe.assume + maybe.trusted (on_argument arg))) (#.Function input output) @@ -187,7 +187,7 @@ (#.UnivQ _) (do check.monad [[id var] check.var - [ids final_output] (concrete_type (maybe.assume (type.applied (list var) type)))] + [ids final_output] (concrete_type (maybe.trusted (type.applied (list var) type)))] (in [(#.Item id ids) final_output])) @@ -359,7 +359,7 @@ (meta.failure (format "Too many implementations available: " (|> chosen_ones (list\map (|>> product.left %.name)) - (text.join_with ", ")) + (text.interposed ", ")) " --- for type: " (%.type sig_type))))) (#.Right [args _]) diff --git a/stdlib/source/library/lux/macro/poly.lux b/stdlib/source/library/lux/type/poly.lux index a4aa6ba23..edd21a88c 100644 --- a/stdlib/source/library/lux/macro/poly.lux +++ b/stdlib/source/library/lux/type/poly.lux @@ -85,13 +85,13 @@ (#.Parameter idx) (let [idx (<type>.adjusted_idx env idx)] (if (n.= 0 idx) - (|> (dictionary.value idx env) maybe.assume product.left (code env)) + (|> (dictionary.value idx env) maybe.trusted product.left (code env)) (` (.$ (~ (code.nat (dec idx))))))) (#.Apply (#.Named [(~~ (static .prelude_module)) "Nothing"] _) (#.Parameter idx)) (let [idx (<type>.adjusted_idx env idx)] (if (n.= 0 idx) - (|> (dictionary.value idx env) maybe.assume product.left (code env)) + (|> (dictionary.value idx env) maybe.trusted product.left (code env)) (undefined))) (^template [<tag>] diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux index c171f3b3e..4e1a88c09 100644 --- a/stdlib/source/library/lux/type/refinement.lux +++ b/stdlib/source/library/lux/type/refinement.lux @@ -40,7 +40,7 @@ [predicate (Predicate t) #predicate] ) - (def: .public (lift transform) + (def: .public (lifted transform) {#.doc (example "Yields a function that can work on refined values." "Respects the constraints of the refinement.")} (All [t %] diff --git a/stdlib/source/library/lux/type/resource.lux b/stdlib/source/library/lux/type/resource.lux index 8a815c47b..5ee949bd3 100644 --- a/stdlib/source/library/lux/type/resource.lux +++ b/stdlib/source/library/lux/type/resource.lux @@ -174,7 +174,7 @@ (in (row.add input to)))) (: (Row Code) row.empty) swaps) - maybe.assume + maybe.trusted row.list) g!inputsT+ (list\map (|>> (~) (..Key ..Commutative) (`)) g!inputs) g!outputsT+ (list\map (|>> (~) (..Key ..Commutative) (`)) g!outputs)]] diff --git a/stdlib/source/library/lux/world/db/sql.lux b/stdlib/source/library/lux/world/db/sql.lux index ce9842b8d..a3b7aff6a 100644 --- a/stdlib/source/library/lux/world/db/sql.lux +++ b/stdlib/source/library/lux/world/db/sql.lux @@ -109,7 +109,7 @@ (def: listing (-> (List (SQL Any)) Text) (|>> (list\map (|>> :representation)) - (text.join_with ", "))) + (text.interposed ", "))) ... Value (def: .public ? Placeholder (:abstraction "?")) @@ -219,7 +219,7 @@ (if (text\= ..no_alias alias) (:representation column) (format (:representation column) " AS " alias)))) - (text.join_with ", "))) + (text.interposed ", "))) " FROM " (:representation source))))] @@ -298,7 +298,7 @@ (|> pairs (list\map (.function (_ [value order]) (format (:representation value) " " (:representation order)))) - (text.join_with ", ")))))) + (text.interposed ", ")))))) (def: .public (group_by pairs query) (All [where having order limit offset] @@ -324,7 +324,7 @@ " VALUES " (|> rows (list\map (|>> ..listing ..parenthesize)) - (text.join_with ", ")) + (text.interposed ", ")) ))) (def: .public (update table pairs) @@ -338,7 +338,7 @@ (format " SET " (|> pairs (list\map (.function (_ [column value]) (format (:representation column) "=" (:representation value)))) - (text.join_with ", "))))))) + (text.interposed ", "))))))) (def: .public delete (-> Table (Command No_Where No_Having)) diff --git a/stdlib/source/library/lux/world/net/http/request.lux b/stdlib/source/library/lux/world/net/http/request.lux index 5c8d162c6..6d9e94b8e 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 @@ (def: (merge inputs) (-> (List Binary) Binary) - (let [[_ output] (try.assumed + (let [[_ output] (try.trusted (monad.fold try.monad (function (_ input [offset output]) (let [amount (binary.size input)] diff --git a/stdlib/source/library/lux/world/net/http/route.lux b/stdlib/source/library/lux/world/net/http/route.lux index d9519a95d..a650f53d2 100644 --- a/stdlib/source/library/lux/world/net/http/route.lux +++ b/stdlib/source/library/lux/world/net/http/route.lux @@ -58,7 +58,7 @@ (server [identification protocol (update@ #//.uri - (|>> (text.clip' (text.size path)) maybe.assume) + (|>> (text.clip' (text.size path)) maybe.trusted) resource) message]) (async.resolved //response.not_found)))) diff --git a/stdlib/source/library/lux/world/program.lux b/stdlib/source/library/lux/world/program.lux index d5195e39f..05f9cd8a6 100644 --- a/stdlib/source/library/lux/world/program.lux +++ b/stdlib/source/library/lux/world/program.lux @@ -319,7 +319,7 @@ (#.Some process/env) (|> (Object::entries [process/env]) array.list - (list\map (|>> (array.read! 0) maybe.assume))) + (list\map (|>> (array.read! 0) maybe.trusted))) #.None (list)) diff --git a/stdlib/source/poly/lux/abstract/equivalence.lux b/stdlib/source/poly/lux/abstract/equivalence.lux index 805576e18..b311d97ec 100644 --- a/stdlib/source/poly/lux/abstract/equivalence.lux +++ b/stdlib/source/poly/lux/abstract/equivalence.lux @@ -22,8 +22,7 @@ ["." tree]]] [macro [syntax (#+ syntax:)] - ["." code] - ["." poly (#+ poly:)]] + ["." code]] [math [number ["." nat ("#\." decimal)] @@ -37,6 +36,7 @@ ["." day] ["." month]] ["." type + ["." poly (#+ poly:)] ["." unit]]]] [\\library ["." /]]) diff --git a/stdlib/source/poly/lux/abstract/functor.lux b/stdlib/source/poly/lux/abstract/functor.lux index db011ca27..57f047798 100644 --- a/stdlib/source/poly/lux/abstract/functor.lux +++ b/stdlib/source/poly/lux/abstract/functor.lux @@ -1,7 +1,6 @@ (.module: [library [lux #* - ["." type] [abstract [monad (#+ Monad do)]] [control @@ -16,11 +15,12 @@ ["." list ("#\." monad monoid)]]] [macro [syntax (#+ syntax:)] - ["." code] - ["." poly (#+ poly:)]] + ["." code]] [math [number - ["n" nat]]]]] + ["n" nat]]] + ["." type + ["." poly (#+ poly:)]]]] [\\library ["." /]]) diff --git a/stdlib/source/poly/lux/data/format/json.lux b/stdlib/source/poly/lux/data/format/json.lux index a77ef5980..42f0ed7d8 100644 --- a/stdlib/source/poly/lux/data/format/json.lux +++ b/stdlib/source/poly/lux/data/format/json.lux @@ -21,8 +21,7 @@ ["." dictionary]]] [macro [syntax (#+ syntax:)] - ["." code] - ["." poly (#+ poly:)]] + ["." code]] [math [number ["n" nat ("#\." decimal)] @@ -36,7 +35,8 @@ ["." day] ["." month]] ["." type - ["." unit]]]] + ["." unit] + ["." poly (#+ poly:)]]]] [\\library ["." / (#+ JSON)]]) diff --git a/stdlib/source/program/aedifex/artifact.lux b/stdlib/source/program/aedifex/artifact.lux index e37894330..cd53db5c4 100644 --- a/stdlib/source/program/aedifex/artifact.lux +++ b/stdlib/source/program/aedifex/artifact.lux @@ -88,7 +88,7 @@ (-> Text Group Text) (|> group (text.all_split_by ..group_separator) - (text.join_with separator))) + (text.interposed separator))) (def: .public (uri version artifact) (-> Version Artifact URI) diff --git a/stdlib/source/program/aedifex/artifact/time/date.lux b/stdlib/source/program/aedifex/artifact/time/date.lux index 6e84811e6..c3c0b9cc1 100644 --- a/stdlib/source/program/aedifex/artifact/time/date.lux +++ b/stdlib/source/program/aedifex/artifact/time/date.lux @@ -76,9 +76,9 @@ (Parser Date) (do <>.monad [year (<>.codec n.decimal (<text>.exactly 4 <text>.decimal)) - year (<>.lift (year.year (.int year))) + year (<>.lifted (year.year (.int year))) month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) - month (<>.lift (month.by_number month)) + month (<>.lifted (month.by_number month)) day_of_month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) - date (<>.lift (date.date year month day_of_month))] + date (<>.lifted (date.date year month day_of_month))] (in (:abstraction date))))) diff --git a/stdlib/source/program/aedifex/artifact/time/time.lux b/stdlib/source/program/aedifex/artifact/time/time.lux index 8b33d5732..0db035d56 100644 --- a/stdlib/source/program/aedifex/artifact/time/time.lux +++ b/stdlib/source/program/aedifex/artifact/time/time.lux @@ -32,8 +32,8 @@ [hour (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) minute (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) second (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))] - (<>.lift (time.time - {#time.hour hour - #time.minute minute - #time.second second - #time.milli_second 0})))) + (<>.lifted (time.time + {#time.hour hour + #time.minute minute + #time.second second + #time.milli_second 0})))) diff --git a/stdlib/source/program/aedifex/command/build.lux b/stdlib/source/program/aedifex/command/build.lux index 41668665e..ff469d896 100644 --- a/stdlib/source/program/aedifex/command/build.lux +++ b/stdlib/source/program/aedifex/command/build.lux @@ -245,7 +245,7 @@ (-> (List Path) Text) (|> host_dependencies (#.Item ".") - (text.join_with ..jvm_class_path_separator) + (text.interposed ..jvm_class_path_separator) %.text)) (def: .public (with_jvm_class_path host_dependencies runtime) diff --git a/stdlib/source/program/aedifex/metadata/artifact.lux b/stdlib/source/program/aedifex/metadata/artifact.lux index f4971546f..0d6f86c2c 100644 --- a/stdlib/source/program/aedifex/metadata/artifact.lux +++ b/stdlib/source/program/aedifex/metadata/artifact.lux @@ -115,11 +115,11 @@ (<text>.Parser Date) (do <>.monad [year (<>.codec n.decimal (<text>.exactly 4 <text>.decimal)) - year (<>.lift (year.year (.int year))) + year (<>.lifted (year.year (.int year))) month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) - month (<>.lift (month.by_number month)) + month (<>.lifted (month.by_number month)) day_of_month (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))] - (<>.lift (date.date year month day_of_month)))) + (<>.lifted (date.date year month day_of_month)))) (def: time_parser (<text>.Parser Time) @@ -127,11 +127,11 @@ [hour (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) minute (<>.codec n.decimal (<text>.exactly 2 <text>.decimal)) second (<>.codec n.decimal (<text>.exactly 2 <text>.decimal))] - (<>.lift (time.time - {#time.hour hour - #time.minute minute - #time.second second - #time.milli_second 0})))) + (<>.lifted (time.time + {#time.hour hour + #time.minute minute + #time.second second + #time.milli_second 0})))) (def: last_updated_parser (Parser Instant) diff --git a/stdlib/source/program/aedifex/pom.lux b/stdlib/source/program/aedifex/pom.lux index f3a945d66..36e3ff440 100644 --- a/stdlib/source/program/aedifex/pom.lux +++ b/stdlib/source/program/aedifex/pom.lux @@ -168,7 +168,7 @@ [properties (\ ! map (dictionary.of_list name.hash) (<| (<xml>.node ["" ..dependency_tag]) (<>.some ..property_parser)))] - (<| <>.lift + (<| <>.lifted try.of_maybe (do maybe.monad [group (dictionary.value ["" ..group_tag] properties) diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index efe7a6b28..1a6e7356e 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -178,6 +178,6 @@ ... (do {! async.monad} ... [console (|> console.default ... async.future - ... (\ ! map (|>> try.assumed console.async)))] + ... (\ ! map (|>> try.trusted console.async)))] ... (interpreter.run! (try.with async.monad) console platform interpretation generation_bundle))) )))) diff --git a/stdlib/source/program/scriptum.lux b/stdlib/source/program/scriptum.lux index ab4c2e787..dbe3ea022 100644 --- a/stdlib/source/program/scriptum.lux +++ b/stdlib/source/program/scriptum.lux @@ -95,7 +95,7 @@ (|> lines (text.all_split_by text.new_line) (list\map (|>> (format prefix))) - (text.join_with text.new_line))) + (text.interposed text.new_line))) (def: (pprint_type_definition level type_func_info tags module interface? recursive_type? type) (-> Nat [Text (List Text)] (List Name) Text Bit Bit Type Text) @@ -113,7 +113,7 @@ (format "(primitive " (%.text name) ")") _ - (format "(primitive " (%.text name) " " (|> params (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.join_with " ")) ")")) + (format "(primitive " (%.text name) " " (|> params (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.interposed " ")) ")")) [_ (#.Sum _)] (let [members (type.flat_variant type)] @@ -122,7 +122,7 @@ (format "(Or " (|> members (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) - (text.join_with " ")) + (text.interposed " ")) ")") _ @@ -135,18 +135,18 @@ (format "(#" t_name " " (|> types (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) - (text.join_with " ")) + (text.interposed " ")) ")")) _ (format "(#" t_name " " (pprint_type_definition level type_func_info #.None module interface? recursive_type? type) ")")))) - (text.join_with text.new_line)))) + (text.interposed text.new_line)))) [_ (#.Product _)] (let [members (type.flat_tuple type)] (case tags #.End - (format "[" (|> members (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.join_with " ")) "]") + (format "[" (|> members (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.interposed " ")) "]") _ (let [member_docs (|> members @@ -155,14 +155,14 @@ (if interface? (format "(: " (pprint_type_definition level type_func_info #.None module interface? recursive_type? type) text.new_line " " t_name ")") (format "#" t_name " " (pprint_type_definition level type_func_info #.None module interface? recursive_type? type))))) - (text.join_with (format text.new_line " ")))] + (text.interposed (format text.new_line " ")))] (if interface? member_docs (format "{" member_docs "}"))))) [_ (#.Function input output)] (let [[ins out] (type.flat_function type)] - (format "(-> " (|> ins (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.join_with " ")) + (format "(-> " (|> ins (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.interposed " ")) " " (pprint_type_definition level type_func_info #.None module interface? recursive_type? out) ")")) @@ -181,7 +181,7 @@ (let [[level' body] (<flat> type) args (level_parameters level level') body_doc (pprint_type_definition (n.+ level level') type_func_info tags module interface? recursive_type? body)] - (format "(" <name> " " "[" (text.join_with " " args) "]" + (format "(" <name> " " "[" (text.interposed " " args) "]" (case tags #.End (format " " body_doc) @@ -197,7 +197,7 @@ [_ (#.Apply param fun)] (let [[type_func type_arguments] (type.flat_application type)] - (format "(" (pprint_type_definition level type_func_info tags module interface? recursive_type? type_func) " " (|> type_arguments (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.join_with " ")) ")")) + (format "(" (pprint_type_definition level type_func_info tags module interface? recursive_type? type_func) " " (|> type_arguments (list\map (pprint_type_definition level type_func_info #.None module interface? recursive_type?)) (text.interposed " ")) ")")) [_ (#.Named [_module _name] type)] (if (text\= module _module) @@ -214,20 +214,20 @@ (format "(primitive " (%.text name) ")") _ - (format "(primitive " (%.text name) " " (|> params (list\map (pprint_type level type_func_name module)) (list.interposed " ") (text.join_with "")) ")")) + (format "(primitive " (%.text name) " " (|> params (list\map (pprint_type level type_func_name module)) (text.interposed " ")) ")")) (#.Sum _) (let [members (type.flat_variant type)] - (format "(Or " (|> members (list\map (pprint_type level type_func_name module)) (list.interposed " ") (text.join_with "")) ")")) + (format "(Or " (|> members (list\map (pprint_type level type_func_name module)) (text.interposed " ")) ")")) (#.Product _) (let [members (type.flat_tuple type)] - (format "[" (|> members (list\map (pprint_type level type_func_name module)) (list.interposed " ") (text.join_with "")) "]")) + (format "[" (|> members (list\map (pprint_type level type_func_name module)) (text.interposed " ")) "]")) (#.Function input output) (let [[ins out] (type.flat_function type)] (format "(-> " - (|> ins (list\map (pprint_type level type_func_name module)) (list.interposed " ") (text.join_with "")) + (|> ins (list\map (pprint_type level type_func_name module)) (text.interposed " ")) " " (pprint_type level type_func_name module out) ")")) @@ -246,7 +246,7 @@ (let [[level' body] (<flat> type) args (level_parameters level level') body_doc (pprint_type (n.+ level level') type_func_name module body)] - (format "(" <name> " " "[" (|> args (list.interposed " ") (text.join_with "")) "]" + (format "(" <name> " " "[" (|> args (text.interposed " ")) "]" (format " " body_doc) ")"))]) ([#.UnivQ "All" type.flat_univ_q] @@ -254,7 +254,7 @@ (#.Apply param fun) (let [[type_func type_arguments] (type.flat_application type)] - (format "(" (pprint_type level type_func_name module type_func) " " (|> type_arguments (list\map (pprint_type level type_func_name module)) (list.interposed " ") (text.join_with "")) ")")) + (format "(" (pprint_type level type_func_name module type_func) " " (|> type_arguments (list\map (pprint_type level type_func_name module)) (text.interposed " ")) ")")) (#.Named [_module _name] type) (if (text\= module _module) @@ -363,7 +363,7 @@ _name _ - (format "(" (text.join_with " " (list& _name type_arguments)) ")")) + (format "(" (text.interposed " " (list& _name type_arguments)) ")")) nesting (list.size type_arguments)]] (in (md.code (format (if interface? "(interface: " "(type: ") (if recursive_type? "#rec " "") @@ -374,7 +374,7 @@ (pprint_type_definition (dec nesting) [_name type_arguments] (maybe.else (list) tags) module interface? recursive_type?) (text.all_split_by text.new_line) (list\map (|>> (format " "))) - (text.join_with text.new_line)) + (text.interposed text.new_line)) ")")))) _ @@ -433,7 +433,7 @@ name args - (format "(" (text.join_with " " (list& name args)) ")"))] + (format "(" (text.interposed " " (list& name args)) ")"))] ($_ md.then (md.heading/3 usage) (case ?doc @@ -455,7 +455,7 @@ (|> block (text.all_split_by text.new_line) (list\map (text.enclosed pre+post)) - (text.join_with text.new_line))) + (text.interposed text.new_line))) (def: (document_module [[module_name module] organization]) (-> [[Text Module] Organization] (Meta [Text (Markdown Block)])) @@ -505,9 +505,9 @@ (do {! meta.monad} [all_modules meta.modules .let [lux_modules (|> all_modules - (list.only (function.compose lux_module? product.left)) + (list.only (function.composite lux_module? product.left)) (list.sorted name_sort))] - lux_exports (monad.map ! (function.compose meta.exports product.left) + lux_exports (monad.map ! (function.composite meta.exports product.left) lux_modules) module_documentation (|> (list\map organize_definitions lux_exports) (list.zipped/2 lux_modules) diff --git a/stdlib/source/specification/compositor/generation/case.lux b/stdlib/source/specification/compositor/generation/case.lux index e3b4f361b..371a89162 100644 --- a/stdlib/source/specification/compositor/generation/case.lux +++ b/stdlib/source/specification/compositor/generation/case.lux @@ -231,7 +231,7 @@ (def: special_pattern_path Path ($_ synthesis.path/alt - (<| try.assumed + (<| try.trusted (phase.result [extension/synthesis.bundle synthesis.init]) (case.path phase/synthesis.phase diff --git a/stdlib/source/specification/compositor/generation/common.lux b/stdlib/source/specification/compositor/generation/common.lux index 93dd3bba5..6387b3013 100644 --- a/stdlib/source/specification/compositor/generation/common.lux +++ b/stdlib/source/specification/compositor/generation/common.lux @@ -187,8 +187,8 @@ concatenatedS (#synthesis.Extension "lux text concat" (list sample_lowerS sample_upperS)) pre_rep_once (format sample_lower sample_upper) post_rep_once (format sample_lower sample_alpha) - pre_rep_all (|> sample_lower (list.repeated sample_size) (text.join_with sample_upper)) - post_rep_all (|> sample_lower (list.repeated sample_size) (text.join_with sample_alpha))]] + pre_rep_all (|> sample_lower (list.repeated sample_size) (text.interposed sample_upper)) + post_rep_all (|> sample_lower (list.repeated sample_size) (text.interposed sample_alpha))]] ($_ _.and (_.test "Can compare texts for equality." (and (|> (#synthesis.Extension "lux text =" (list sample_lowerS sample_lowerS)) diff --git a/stdlib/source/specification/compositor/generation/function.lux b/stdlib/source/specification/compositor/generation/function.lux index f4697bd38..c3143b958 100644 --- a/stdlib/source/specification/compositor/generation/function.lux +++ b/stdlib/source/specification/compositor/generation/function.lux @@ -53,7 +53,7 @@ [[arity local functionS] ..function partial_arity (|> r.nat (\ ! map (|>> (n.% arity) (n.max 1)))) inputs (r.list arity r.safe_frac) - .let [expectation (maybe.assume (list.item (dec local) inputs)) + .let [expectation (maybe.trusted (list.item (dec local) inputs)) inputsS (list\map (|>> synthesis.f64) inputs)]] ($_ _.and (_.test "Can read arguments." diff --git a/stdlib/source/specification/compositor/generation/structure.lux b/stdlib/source/specification/compositor/generation/structure.lux index 7cd303c52..b1f0e5666 100644 --- a/stdlib/source/specification/compositor/generation/structure.lux +++ b/stdlib/source/specification/compositor/generation/structure.lux @@ -45,9 +45,9 @@ (case> (#try.Success valueT) (let [valueT (:as (Array Any) valueT)] (and (n.= 3 (array.size valueT)) - (let [tag_out (:as java/lang/Integer (maybe.assume (array.read! 0 valueT))) + (let [tag_out (:as java/lang/Integer (maybe.trusted (array.read! 0 valueT))) last?_out (array.read! 1 valueT) - value_out (:as Any (maybe.assume (array.read! 2 valueT))) + value_out (:as Any (maybe.trusted (array.read! 2 valueT))) same_tag? (|> tag_out ffi.int_to_long (:as Nat) (n.= tag_in)) same_flag? (case last?_out (#.Some last?_out') diff --git a/stdlib/source/specification/lux/abstract/apply.lux b/stdlib/source/specification/lux/abstract/apply.lux index 9aaa00eac..71df69a83 100644 --- a/stdlib/source/specification/lux/abstract/apply.lux +++ b/stdlib/source/specification/lux/abstract/apply.lux @@ -53,7 +53,7 @@ (_.test "Composition." ((comparison n.=) (_$ \apply - (injection function.compose) + (injection function.composite) (injection increase) (injection decrease) (injection sample)) diff --git a/stdlib/source/test/aedifex/command/deps.lux b/stdlib/source/test/aedifex/command/deps.lux index c4311fc2c..0c6676488 100644 --- a/stdlib/source/test/aedifex/command/deps.lux +++ b/stdlib/source/test/aedifex/command/deps.lux @@ -75,12 +75,12 @@ dependee_pom (|> (\ ///.monoid identity) (set@ #///.identity (#.Some dependee_artifact)) ///pom.write - try.assumed) + try.trusted) depender_pom (|> (\ ///.monoid identity) (set@ #///.identity (#.Some depender_artifact)) (set@ #///.dependencies (set.of_list ///dependency.hash (list dependee))) ///pom.write - try.assumed) + try.trusted) dependee_package (|> dependee_package (set@ #///package.origin (#///repository/origin.Remote "")) diff --git a/stdlib/source/test/aedifex/dependency/deployment.lux b/stdlib/source/test/aedifex/dependency/deployment.lux index 9ddabee88..ae97a70ca 100644 --- a/stdlib/source/test/aedifex/dependency/deployment.lux +++ b/stdlib/source/test/aedifex/dependency/deployment.lux @@ -137,7 +137,7 @@ [[profile package] $///package.random .let [artifact (|> profile (get@ #profile.identity) - maybe.assume) + maybe.trusted) dependency (: Dependency [artifact artifact/type.lux_library])]] diff --git a/stdlib/source/test/aedifex/dependency/resolution.lux b/stdlib/source/test/aedifex/dependency/resolution.lux index da101dfa2..c7f7d6d40 100644 --- a/stdlib/source/test/aedifex/dependency/resolution.lux +++ b/stdlib/source/test/aedifex/dependency/resolution.lux @@ -368,16 +368,16 @@ dependee_pom (|> (\ ///.monoid identity) (set@ #///.identity (#.Some dependee_artifact)) ///pom.write - try.assumed) + try.trusted) depender_pom (|> (\ ///.monoid identity) (set@ #///.identity (#.Some depender_artifact)) (set@ #///.dependencies (set.of_list ///dependency.hash (list dependee))) ///pom.write - try.assumed) + try.trusted) ignored_pom (|> (\ ///.monoid identity) (set@ #///.identity (#.Some ignored_artifact)) ///pom.write - try.assumed) + try.trusted) dependee_package (set@ #///package.pom [dependee_pom diff --git a/stdlib/source/test/aedifex/metadata/artifact.lux b/stdlib/source/test/aedifex/metadata/artifact.lux index 7bcb0bd91..46ebf4eae 100644 --- a/stdlib/source/test/aedifex/metadata/artifact.lux +++ b/stdlib/source/test/aedifex/metadata/artifact.lux @@ -54,7 +54,7 @@ hour (\ ! map (n.% 24) random.nat) minute (\ ! map (n.% 60) random.nat) second (\ ! map (n.% 60) random.nat)] - (in (try.assumed + (in (try.trusted (do try.monad [year (year.year year) month (month.by_number month) diff --git a/stdlib/source/test/aedifex/metadata/snapshot.lux b/stdlib/source/test/aedifex/metadata/snapshot.lux index 5683178c4..d5dc8595e 100644 --- a/stdlib/source/test/aedifex/metadata/snapshot.lux +++ b/stdlib/source/test/aedifex/metadata/snapshot.lux @@ -58,7 +58,7 @@ hour (\ ! map (n.% 24) random.nat) minute (\ ! map (n.% 60) random.nat) second (\ ! map (n.% 60) random.nat)] - (in (try.assumed + (in (try.trusted (do try.monad [year (year.year year) month (month.by_number month) diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux index b2c6790ee..a0e00fdd4 100644 --- a/stdlib/source/test/lux.lux +++ b/stdlib/source/test/lux.lux @@ -748,7 +748,7 @@ [left (random.ascii/lower 1) mid (random.ascii/lower 1) right (random.ascii/lower 1) - .let [expected (text.join_with "" (list left mid right))]] + .let [expected (text.interposed "" (list left mid right))]] (_.cover [/.$_ /._$] (with_expansions [<left_association> (/._$ format left diff --git a/stdlib/source/test/lux/abstract/apply.lux b/stdlib/source/test/lux/abstract/apply.lux index 26bb2cc7e..fcdf5d793 100644 --- a/stdlib/source/test/lux/abstract/apply.lux +++ b/stdlib/source/test/lux/abstract/apply.lux @@ -23,9 +23,9 @@ right random.nat] (<| (_.covering /._) ($_ _.and - (_.cover [/.compose] + (_.cover [/.composite] (let [expected (n.+ left right)] - (case (\ (/.compose maybe.monad maybe.apply list.apply) apply + (case (\ (/.composite maybe.monad maybe.apply list.apply) apply (#.Some (list (n.+ left))) (#.Some (list right))) (^ (#.Some (list actual))) diff --git a/stdlib/source/test/lux/abstract/codec.lux b/stdlib/source/test/lux/abstract/codec.lux index fe3a58e71..e3fd09626 100644 --- a/stdlib/source/test/lux/abstract/codec.lux +++ b/stdlib/source/test/lux/abstract/codec.lux @@ -31,14 +31,14 @@ (def: codec (Codec Text Bit) - (/.compose json.codec ..json)) + (/.composite json.codec ..json)) (def: .public test Test (do random.monad [expected random.bit] (<| (_.covering /._) - (_.cover [/.compose] + (_.cover [/.composite] (case (|> expected (\ ..codec encode) (\ ..codec decode)) (#try.Success actual) (bit\= expected actual) diff --git a/stdlib/source/test/lux/abstract/functor.lux b/stdlib/source/test/lux/abstract/functor.lux index 252e9b999..522707615 100644 --- a/stdlib/source/test/lux/abstract/functor.lux +++ b/stdlib/source/test/lux/abstract/functor.lux @@ -51,8 +51,8 @@ _ false)) - (_.cover [/.Then /.compose] - (case (\ (/.compose maybe.functor list.functor) map + (_.cover [/.Then /.composite] + (case (\ (/.composite maybe.functor list.functor) map (n.+ shift) (#.Some (list left))) (^ (#.Some (list actual))) diff --git a/stdlib/source/test/lux/abstract/monoid.lux b/stdlib/source/test/lux/abstract/monoid.lux index 98c33068a..75eee67c6 100644 --- a/stdlib/source/test/lux/abstract/monoid.lux +++ b/stdlib/source/test/lux/abstract/monoid.lux @@ -23,8 +23,8 @@ intR random.int] (<| (_.covering /._) ($_ _.and - (_.cover [/.compose] - (let [[natLR intLR] (\ (/.compose nat.addition int.multiplication) compose + (_.cover [/.composite] + (let [[natLR intLR] (\ (/.composite nat.addition int.multiplication) compose [natL intL] [natR intR])] (and (nat.= (\ nat.addition compose natL natR) natLR) diff --git a/stdlib/source/test/lux/control/concurrency/semaphore.lux b/stdlib/source/test/lux/control/concurrency/semaphore.lux index 40cc7d703..a57e3bcd6 100644 --- a/stdlib/source/test/lux/control/concurrency/semaphore.lux +++ b/stdlib/source/test/lux/control/concurrency/semaphore.lux @@ -100,8 +100,8 @@ (do {! random.monad} [repetitions (|> random.nat (\ ! map (|>> (n.% 100) (n.max 10)))) .let [resource (atom.atom "") - expected_As (text.join_with "" (list.repeated repetitions "A")) - expected_Bs (text.join_with "" (list.repeated repetitions "B")) + expected_As (text.joined (list.repeated repetitions "A")) + expected_Bs (text.joined (list.repeated repetitions "B")) mutex (/.mutex []) processA (<| (/.synchronize! mutex) io.io @@ -156,13 +156,13 @@ false))) (do {! random.monad} [limit (\ ! map (|>> (n.% 9) inc) random.nat) - .let [barrier (/.barrier (maybe.assume (/.limit limit))) + .let [barrier (/.barrier (maybe.trusted (/.limit limit))) resource (atom.atom "")]] (in (do {! async.monad} [.let [suffix "_" expected_ending (|> suffix (list.repeated limit) - (text.join_with "")) + text.joined) expected_ids (enum.range n.enum 0 (dec limit))] _ (|> expected_ids (list\map (function (_ id) diff --git a/stdlib/source/test/lux/control/continuation.lux b/stdlib/source/test/lux/control/continuation.lux index 03f3ae2c3..4844e521f 100644 --- a/stdlib/source/test/lux/control/continuation.lux +++ b/stdlib/source/test/lux/control/continuation.lux @@ -46,17 +46,17 @@ (_.cover [/.result] (n.= sample (/.result (_\in sample)))) - (_.cover [/.call/cc] + (_.cover [/.with_current] (n.= (n.* 2 sample) (/.result (do {! /.monad} - [value (/.call/cc - (function (_ k) - (do ! - [temp (k sample)] - ... If this code where to run, - ... the output would be - ... (n.* 4 sample) - (k temp))))] + [value (/.with_current + (function (_ k) + (do ! + [temp (k sample)] + ... If this code where to run, + ... the output would be + ... (n.* 4 sample) + (k temp))))] (in (n.* 2 value)))))) (_.cover [/.portal] (n.= (n.+ 100 sample) @@ -84,13 +84,13 @@ (visit output)))))] (list\= elems (/.result (/.reset (visit elems)))))) - (_.cover [/.continue] - (/.continue (same? sample) - (: (/.Cont Nat Bit) - (function (_ next) - (next sample))))) + (_.cover [/.continued] + (/.continued (same? sample) + (: (/.Cont Nat Bit) + (function (_ next) + (next sample))))) (_.cover [/.pending] - (/.continue (same? sample) - (: (/.Cont Nat Bit) - (/.pending sample)))) + (/.continued (same? sample) + (: (/.Cont Nat Bit) + (/.pending sample)))) ))) diff --git a/stdlib/source/test/lux/control/function.lux b/stdlib/source/test/lux/control/function.lux index 01da979e6..369a018e0 100644 --- a/stdlib/source/test/lux/control/function.lux +++ b/stdlib/source/test/lux/control/function.lux @@ -44,9 +44,9 @@ (_.cover [/.identity] (n.= expected (/.identity expected))) - (_.cover [/.compose] + (_.cover [/.composite] (n.= (f0 (f1 expected)) - ((/.compose f0 f1) expected))) + ((/.composite f0 f1) expected))) (_.cover [/.constant] (n.= expected ((/.constant expected) dummy))) diff --git a/stdlib/source/test/lux/control/maybe.lux b/stdlib/source/test/lux/control/maybe.lux index 5d9a04a0b..6f4213268 100644 --- a/stdlib/source/test/lux/control/maybe.lux +++ b/stdlib/source/test/lux/control/maybe.lux @@ -49,10 +49,10 @@ [left random.nat right random.nat .let [expected (n.+ left right)]] - (let [lift (/.lift io.monad)] - (_.cover [/.with /.lift] + (let [lifted (/.lifted io.monad)] + (_.cover [/.with /.lifted] (|> (io.run! (do (/.with io.monad) - [a (lift (io\in left)) + [a (lifted (io\in left)) b (in right)] (in (n.+ a b)))) (case> (#.Some actual) @@ -71,8 +71,8 @@ (#.Some value)))))) (do random.monad [value random.nat] - (_.cover [/.assume] - (same? value (/.assume (#.Some value))))) + (_.cover [/.trusted] + (same? value (/.trusted (#.Some value))))) (do random.monad [value random.nat] (_.cover [/.list] diff --git a/stdlib/source/test/lux/control/parser.lux b/stdlib/source/test/lux/control/parser.lux index bb81f4383..f45ba2111 100644 --- a/stdlib/source/test/lux/control/parser.lux +++ b/stdlib/source/test/lux/control/parser.lux @@ -368,12 +368,12 @@ (|> (list) (/.result (/.failure failure)) (should_fail failure))) - (_.cover [/.lift] + (_.cover [/.lifted] (and (|> (list) - (/.result (/.lift (#try.Success expected))) + (/.result (/.lifted (#try.Success expected))) (match actual (n.= expected actual))) (|> (list) - (/.result (/.lift (#try.Failure failure))) + (/.result (/.lifted (#try.Failure failure))) (should_fail failure)))) (_.cover [/.assertion] (and (|> (list (code.bit #1) (code.int +123)) diff --git a/stdlib/source/test/lux/control/parser/text.lux b/stdlib/source/test/lux/control/parser/text.lux index 35c509e00..7be2416d0 100644 --- a/stdlib/source/test/lux/control/parser/text.lux +++ b/stdlib/source/test/lux/control/parser/text.lux @@ -157,11 +157,11 @@ (random.set n.hash num_options) (\ ! map (|>> set.list (list\map text.of_char) - (text.join_with "")))) + text.joined))) expected (\ ! map (function (_ value) (|> options (text.char (n.% num_options value)) - maybe.assume)) + maybe.trusted)) random.nat) invalid (random.only (function (_ char) (not (text.contains? (text.of_char char) options))) @@ -183,11 +183,11 @@ (random.set n.hash num_options) (\ ! map (|>> set.list (list\map text.of_char) - (text.join_with "")))) + text.joined))) invalid (\ ! map (function (_ value) (|> options (text.char (n.% num_options value)) - maybe.assume)) + maybe.trusted)) random.nat) expected (random.only (function (_ char) (not (text.contains? (text.of_char char) options))) diff --git a/stdlib/source/test/lux/control/reader.lux b/stdlib/source/test/lux/control/reader.lux index 9b17a19fa..78ea0d961 100644 --- a/stdlib/source/test/lux/control/reader.lux +++ b/stdlib/source/test/lux/control/reader.lux @@ -49,10 +49,10 @@ (n.= (n.* factor sample) (/.result sample (/.local (n.* factor) /.read)))) (let [(^open "io\.") io.monad] - (_.cover [/.with /.lift] + (_.cover [/.with /.lifted] (|> (: (/.Reader Any (IO Nat)) (do (/.with io.monad) - [a (/.lift (io\in sample)) + [a (/.lifted (io\in sample)) b (in factor)] (in (n.* b a)))) (/.result []) diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux index 4f135a57d..caabbadf6 100644 --- a/stdlib/source/test/lux/control/region.lux +++ b/stdlib/source/test/lux/control/region.lux @@ -172,14 +172,14 @@ (..throws? /.clean_up_error outcome)) (n.= expected_clean_ups actual_clean_ups)))))) - (_.cover [/.lift] + (_.cover [/.lifted] (thread.result (do {! thread.monad} [clean_up_counter (thread.box 0) .let [//@ !] outcome (/.run! ! (do (/.monad !) - [_ (/.lift //@ (thread.write! expected_clean_ups clean_up_counter))] + [_ (/.lifted //@ (thread.write! expected_clean_ups clean_up_counter))] (in []))) actual_clean_ups (thread.read! clean_up_counter)] (in (and (..success? outcome) diff --git a/stdlib/source/test/lux/control/state.lux b/stdlib/source/test/lux/control/state.lux index 3f2123211..864c16bd9 100644 --- a/stdlib/source/test/lux/control/state.lux +++ b/stdlib/source/test/lux/control/state.lux @@ -108,10 +108,10 @@ left random.nat right random.nat] (let [(^open "io\.") io.monad] - (_.cover [/.+State /.with /.lift /.result'] + (_.cover [/.+State /.with /.lifted /.result'] (|> (: (/.+State io.IO Nat Nat) (do (/.with io.monad) - [a (/.lift io.monad (io\in left)) + [a (/.lifted io.monad (io\in left)) b (in right)] (in (n.+ a b)))) (/.result' state) diff --git a/stdlib/source/test/lux/control/try.lux b/stdlib/source/test/lux/control/try.lux index 3c030bdcc..55bcc0b4f 100644 --- a/stdlib/source/test/lux/control/try.lux +++ b/stdlib/source/test/lux/control/try.lux @@ -55,9 +55,9 @@ (_.for [/.monad] ($monad.spec ..injection ..comparison /.monad)) - (_.cover [/.assumed] + (_.cover [/.trusted] (n.= expected - (/.assumed (#/.Success expected)))) + (/.trusted (#/.Success expected)))) (_.cover [/.of_maybe] (case [(/.of_maybe (#.Some expected)) (/.of_maybe #.None)] diff --git a/stdlib/source/test/lux/control/writer.lux b/stdlib/source/test/lux/control/writer.lux index 9d43ef5f8..5ef2c76c4 100644 --- a/stdlib/source/test/lux/control/writer.lux +++ b/stdlib/source/test/lux/control/writer.lux @@ -50,11 +50,11 @@ (_.cover [/.write] (text\= log (product.left (/.write log)))) - (_.cover [/.with /.lift] - (let [lift (/.lift text.monoid io.monad) + (_.cover [/.with /.lifted] + (let [lifted (/.lifted text.monoid io.monad) (^open "io\.") io.monad] (|> (do (/.with text.monoid io.monad) - [a (lift (io\in left)) + [a (lifted (io\in left)) b (in right)] (in (n.+ a b))) io.run! diff --git a/stdlib/source/test/lux/data/binary.lux b/stdlib/source/test/lux/data/binary.lux index aab56834f..372aed7de 100644 --- a/stdlib/source/test/lux/data/binary.lux +++ b/stdlib/source/test/lux/data/binary.lux @@ -38,7 +38,7 @@ (if (n.< size idx) (do random.monad [byte random.nat] - (exec (try.assumed (/.write/8! idx byte output)) + (exec (try.trusted (/.write/8! idx byte output)) (recur (inc idx)))) (\ random.monad in output))))) @@ -113,7 +113,7 @@ (_.cover [/.read/64! /.write/64!] (..binary_io 3 /.read/64! /.write/64! value)))) (_.cover [/.slice] - (let [random_slice (try.assumed (/.slice offset length sample)) + (let [random_slice (try.trusted (/.slice offset length sample)) idxs (: (List Nat) (case length 0 (list) diff --git a/stdlib/source/test/lux/data/collection/dictionary.lux b/stdlib/source/test/lux/data/collection/dictionary.lux index 82e421d28..080e09001 100644 --- a/stdlib/source/test/lux/data/collection/dictionary.lux +++ b/stdlib/source/test/lux/data/collection/dictionary.lux @@ -174,7 +174,7 @@ cannot_put_old_keys! (or (n.= 0 size) - (let [first_key (|> dict /.keys list.head maybe.assume)] + (let [first_key (|> dict /.keys list.head maybe.trusted)] (case (/.has' first_key test_val dict) (#try.Success _) false @@ -239,13 +239,13 @@ (_.cover [/.re_bound] (or (n.= 0 size) - (let [first_key (|> dict /.keys list.head maybe.assume) + (let [first_key (|> dict /.keys list.head maybe.trusted) rebound (/.re_bound first_key non_key dict)] (and (n.= (/.size dict) (/.size rebound)) (/.key? rebound non_key) (not (/.key? rebound first_key)) - (n.= (maybe.assume (/.value first_key dict)) - (maybe.assume (/.value non_key rebound))))))) + (n.= (maybe.trusted (/.value first_key dict)) + (maybe.trusted (/.value non_key rebound))))))) ))) (def: .public test diff --git a/stdlib/source/test/lux/data/collection/list.lux b/stdlib/source/test/lux/data/collection/list.lux index ce86a80c7..8ba430845 100644 --- a/stdlib/source/test/lux/data/collection/list.lux +++ b/stdlib/source/test/lux/data/collection/list.lux @@ -68,12 +68,12 @@ (do {! random.monad} [parameter random.nat subject random.nat] - (let [lift (/.lift io.monad) + (let [lifted (/.lifted io.monad) (^open "io\.") io.monad expected (n.+ parameter subject)] - (_.cover [/.with /.lift] + (_.cover [/.with /.lifted] (|> (io.run! (do (/.with io.monad) - [a (lift (io\in parameter)) + [a (lifted (io\in parameter)) b (in subject)] (in (n.+ a b)))) (case> (^ (list actual)) diff --git a/stdlib/source/test/lux/data/collection/row.lux b/stdlib/source/test/lux/data/collection/row.lux index 3ae89efba..2515f284f 100644 --- a/stdlib/source/test/lux/data/collection/row.lux +++ b/stdlib/source/test/lux/data/collection/row.lux @@ -98,16 +98,16 @@ (#try.Failure error) false)) - (_.cover [/.put] + (_.cover [/.has] (<| (try.else false) (do try.monad - [sample (/.put good_index non_member sample) + [sample (/.has good_index non_member sample) actual (/.item good_index sample)] (in (same? non_member actual))))) (_.cover [/.revised] (<| (try.else false) (do try.monad - [sample (/.put good_index non_member sample) + [sample (/.has good_index non_member sample) sample (/.revised good_index inc sample) actual (/.item good_index sample)] (in (n.= (inc non_member) actual))))) @@ -124,7 +124,7 @@ (#try.Failure error) (exception.match? /.index_out_of_bounds error))))] (and (fails! (/.item bad_index sample)) - (fails! (/.put bad_index non_member sample)) + (fails! (/.has bad_index non_member sample)) (fails! (/.revised bad_index inc sample))))) )) ))) diff --git a/stdlib/source/test/lux/data/collection/sequence.lux b/stdlib/source/test/lux/data/collection/sequence.lux index 19183f1b1..ebac1772b 100644 --- a/stdlib/source/test/lux/data/collection/sequence.lux +++ b/stdlib/source/test/lux/data/collection/sequence.lux @@ -29,6 +29,15 @@ (/.first 100 reference) (/.first 100 subject)))) +(def: (iterations step) + (All [a] + (-> (-> a a) + (-> a (/.Sequence a)))) + (/.iterations + (function (_ state) + (let [state' (step state)] + [state' state])))) + (def: .public test Test (<| (_.covering /._) @@ -47,67 +56,67 @@ (_.for [/.comonad] ($comonad.spec /.repeated ..equivalence /.comonad)) - (_.cover [/.iterations /.item] + (_.cover [/.item] (n.= (n.+ offset index) - (/.item index (/.iterations inc offset)))) + (/.item index (..iterations inc offset)))) (_.cover [/.repeated] (n.= repeated (/.item index (/.repeated repeated)))) (_.cover [/.first] (list\= (enum.range n.enum offset (dec (n.+ size offset))) - (/.first size (/.iterations inc offset)))) + (/.first size (..iterations inc offset)))) (_.cover [/.after] (list\= (enum.range n.enum offset (dec (n.+ size offset))) - (/.first size (/.after offset (/.iterations inc 0))))) + (/.first size (/.after offset (..iterations inc 0))))) (_.cover [/.split_at] - (let [[drops takes] (/.split_at size (/.iterations inc 0))] + (let [[drops takes] (/.split_at size (..iterations inc 0))] (and (list\= (enum.range n.enum 0 (dec size)) drops) (list\= (enum.range n.enum size (dec (n.* 2 size))) (/.first size takes))))) (_.cover [/.while] (list\= (enum.range n.enum 0 (dec size)) - (/.while (n.< size) (/.iterations inc 0)))) + (/.while (n.< size) (..iterations inc 0)))) (_.cover [/.until] (list\= (enum.range n.enum offset (dec (n.+ size offset))) (/.while (n.< (n.+ size offset)) - (/.until (n.< offset) (/.iterations inc 0))))) + (/.until (n.< offset) (..iterations inc 0))))) (_.cover [/.split_when] - (let [[drops takes] (/.split_when (n.= size) (/.iterations inc 0))] + (let [[drops takes] (/.split_when (n.= size) (..iterations inc 0))] (and (list\= (enum.range n.enum 0 (dec size)) drops) (list\= (enum.range n.enum size (dec (n.* 2 size))) (/.while (n.< (n.* 2 size)) takes))))) (_.cover [/.head] (n.= offset - (/.head (/.iterations inc offset)))) + (/.head (..iterations inc offset)))) (_.cover [/.tail] (list\= (enum.range n.enum (inc offset) (n.+ size offset)) - (/.first size (/.tail (/.iterations inc offset))))) + (/.first size (/.tail (..iterations inc offset))))) (_.cover [/.only] (list\= (list\map (n.* 2) (enum.range n.enum 0 (dec size))) - (/.first size (/.only n.even? (/.iterations inc 0))))) + (/.first size (/.only n.even? (..iterations inc 0))))) (_.cover [/.partition] - (let [[evens odds] (/.partition n.even? (/.iterations inc 0))] + (let [[evens odds] (/.partition n.even? (..iterations inc 0))] (and (n.= (n.* 2 offset) (/.item offset evens)) (n.= (inc (n.* 2 offset)) (/.item offset odds))))) - (_.cover [/.unfold] + (_.cover [/.iterations] (let [(^open "/\.") /.functor (^open "list\.") (list.equivalence text.equivalence)] (list\= (/.first size - (/\map %.nat (/.iterations inc offset))) + (/\map %.nat (..iterations inc offset))) (/.first size - (/.unfold (function (_ n) [(inc n) (%.nat n)]) - offset))))) + (/.iterations (function (_ n) [(inc n) (%.nat n)]) + offset))))) (_.cover [/.cycle] (let [cycle (list& cycle_start cycle_next)] (list\= (list.joined (list.repeated size cycle)) (/.first (n.* size (list.size cycle)) (/.cycle [cycle_start cycle_next]))))) (_.cover [/.^sequence&] - (let [(/.^sequence& first second third next) (/.iterations inc offset)] + (let [(/.^sequence& first second third next) (..iterations inc offset)] (and (n.= offset first) (n.= (n.+ 1 offset) second) (n.= (n.+ 2 offset) third)))) diff --git a/stdlib/source/test/lux/data/format/tar.lux b/stdlib/source/test/lux/data/format/tar.lux index 0c43ada46..fe0083c95 100644 --- a/stdlib/source/test/lux/data/format/tar.lux +++ b/stdlib/source/test/lux/data/format/tar.lux @@ -164,7 +164,7 @@ chunks (\ ! map (n.% 100) random.nat) .let [content (|> chunk (list.repeated chunks) - (text.join_with "") + text.joined (\ utf8.codec encode))]] (`` ($_ _.and (~~ (template [<type> <tag>] diff --git a/stdlib/source/test/lux/data/format/xml.lux b/stdlib/source/test/lux/data/format/xml.lux index 4fef01a10..0ce833e92 100644 --- a/stdlib/source/test/lux/data/format/xml.lux +++ b/stdlib/source/test/lux/data/format/xml.lux @@ -37,7 +37,7 @@ (Random Nat) (do {! random.monad} [idx (|> random.nat (\ ! map (n.% (text.size char_range))))] - (in (maybe.assume (text.char idx char_range))))) + (in (maybe.trusted (text.char idx char_range))))) (def: (size bottom top) (-> Nat Nat (Random Nat)) diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux index 1efa4ebfe..aa012a5ae 100644 --- a/stdlib/source/test/lux/data/text.lux +++ b/stdlib/source/test/lux/data/text.lux @@ -195,15 +195,15 @@ (_.cover [/.joined] (n.= (set.size characters) (/.size (/.joined (set.list characters))))) - (_.cover [/.join_with /.all_split_by] + (_.cover [/.interposed /.all_split_by] (and (|> (set.list characters) - (/.join_with separator) + (/.interposed separator) (/.all_split_by separator) (set.of_list /.hash) (\ set.equivalence = characters)) (\ /.equivalence = (/.joined (set.list characters)) - (/.join_with "" (set.list characters))))) + (/.interposed "" (set.list characters))))) (_.cover [/.replaced/1] (\ /.equivalence = (\ /.monoid compose post static) diff --git a/stdlib/source/test/lux/data/text/encoding.lux b/stdlib/source/test/lux/data/text/encoding.lux index 34d6ee08d..46dba6ded 100644 --- a/stdlib/source/test/lux/data/text/encoding.lux +++ b/stdlib/source/test/lux/data/text/encoding.lux @@ -215,7 +215,7 @@ (let [options (list.size ..all_encodings)] (do {! random.monad} [choice (\ ! map (n.% options) random.nat)] - (in (maybe.assume (list.item choice ..all_encodings)))))) + (in (maybe.trusted (list.item choice ..all_encodings)))))) (def: .public test Test diff --git a/stdlib/source/test/lux/data/text/format.lux b/stdlib/source/test/lux/data/text/format.lux index f2887f530..24746c45d 100644 --- a/stdlib/source/test/lux/data/text/format.lux +++ b/stdlib/source/test/lux/data/text/format.lux @@ -160,7 +160,7 @@ (text\= (/.list /.nat members) (|> members (list\map /.nat) - (text.join_with " ") + (text.interposed " ") list (/.list (|>>)))))) (do random.monad diff --git a/stdlib/source/test/lux/data/text/unicode/set.lux b/stdlib/source/test/lux/data/text/unicode/set.lux index 6efe6cb14..84ebef798 100644 --- a/stdlib/source/test/lux/data/text/unicode/set.lux +++ b/stdlib/source/test/lux/data/text/unicode/set.lux @@ -64,9 +64,9 @@ (_.cover [/.member?] (bit\= (block.within? block inside) (/.member? (/.set [block (list)]) inside))) - (_.cover [/.compose] - (let [composed (/.compose (/.set [left (list)]) - (/.set [right (list)]))] + (_.cover [/.composite] + (let [composed (/.composite (/.set [left (list)]) + (/.set [right (list)]))] (and (n.= (n.min (block.start left) (block.start right)) (/.start composed)) diff --git a/stdlib/source/test/lux/debug.lux b/stdlib/source/test/lux/debug.lux index 2f94947a5..151dd34c2 100644 --- a/stdlib/source/test/lux/debug.lux +++ b/stdlib/source/test/lux/debug.lux @@ -211,7 +211,7 @@ (text\= (|> (list sample_bit sample_int sample_frac sample_text) (: (List Any)) (list\map /.inspection) - (text.join_with " ") + (text.interposed " ") (text.enclosed ["[" "]"])) (/.inspection [sample_bit sample_int sample_frac sample_text])) ))))) diff --git a/stdlib/source/test/lux/documentation.lux b/stdlib/source/test/lux/documentation.lux index b8a34a752..72417f5c5 100644 --- a/stdlib/source/test/lux/documentation.lux +++ b/stdlib/source/test/lux/documentation.lux @@ -2,13 +2,15 @@ [library [lux #* ["_" test (#+ Test)] + ["." meta] [control ["." try] ["." exception] [parser ["<.>" code]]] [data - ["." text ("#\." equivalence)] + ["." text ("#\." equivalence) + ["%" format]] [format ["md" markdown]]] ["." macro @@ -27,67 +29,80 @@ (#try.Success _) (#try.Failure "OOPS!")))) -(template.with_locals [g!default - g!description] - (as_is (def: g!default - Nat - 123) +(syntax: (description []) + (\ meta.monad map + (|>> %.nat code.text list) + meta.seed)) - (`` (/.documentation: /.documentation: - (~~ (template.text [g!description])))) +(template.with_locals [g!default] + (with_expansions ['definition_description' (..description) + 'sub_description' (..description) + 'super_description' (..description)] + (as_is (def: g!default + Nat + 123) - (def: .public test - Test - (<| (_.covering /._) - ($_ _.and - (_.for [/.Definition] - ($_ _.and - (_.cover [/.default] - (let [definition (`` (/.default (~~ (template.identifier [.._] [g!default]))))] - (and (|> definition + (/.documentation: /.documentation: + 'definition_description') + + (def: .public test + Test + (<| (_.covering /._) + ($_ _.and + (_.for [/.Definition] + ($_ _.and + (_.cover [/.default] + (let [definition (`` (/.default (~~ (template.identifier [.._] [g!default]))))] + (and (|> definition + (get@ #/.definition) + (text\= (template.text [g!default]))) + (|> definition + (get@ #/.documentation) + md.markdown + (text\= "") + not)))) + (_.cover [/.documentation:] + (and (|> ..documentation: (get@ #/.definition) - (text\= (template.text [g!default]))) - (|> definition + (text\= (template.text [/.documentation:]))) + (|> ..documentation: (get@ #/.documentation) md.markdown - (text\= "") - not)))) - (_.cover [/.documentation:] - (and (|> ..documentation: - (get@ #/.definition) - (text\= (template.text [/.documentation:]))) - (|> ..documentation: - (get@ #/.documentation) - md.markdown - (text.contains? (template.text [g!description])) - not))) - )) - (_.for [/.Module] - ($_ _.and - (_.cover [/.module /.documentation] - (let [sub (/.module /._ - [] - []) - super (/.module .._ - [..documentation:] - [sub])] - (and (text.contains? (/.documentation sub) - (/.documentation super)) - (text.contains? (md.markdown (get@ #/.documentation ..documentation:)) - (/.documentation super))))) - )) - (_.cover [/.unqualified_identifier] - (`` (and (~~ (template [<example>] - [(<| (text.contains? (get@ #exception.label /.unqualified_identifier)) - macro_error - <example>)] + (text.contains? 'definition_description')))) + )) + (_.for [/.Module] + ($_ _.and + (_.cover [/.module /.documentation] + (let [sub (`` (/.module /._ + (~~ (template.text ['sub_description'])) + [] + [])) + super (`` (/.module .._ + (~~ (template.text ['super_description'])) + [..documentation:] + [sub]))] + (and (text.contains? (template.text ['sub_description']) + (/.documentation sub)) + (text.contains? (/.documentation sub) + (/.documentation super)) + (text.contains? (template.text ['super_description']) + (/.documentation super)) + (text.contains? (md.markdown (get@ #/.documentation ..documentation:)) + (/.documentation super))))) + )) + (_.cover [/.unqualified_identifier] + (`` (and (~~ (template [<example>] + [(<| (text.contains? (get@ #exception.label /.unqualified_identifier)) + macro_error + <example>)] - [(/.default g!default)] - [(/.documentation: g!default - (~~ (template.text [g!description])))] - [(/.module g!default - [..documentation:] - [sub])] - ))))) - )))) + [(/.default g!default)] + [(/.documentation: g!default + (~~ (template.text ['definition_description'])))] + [(/.module g!default + "" + [..documentation:] + [sub])] + ))))) + ))))) ) diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux index e28e013cc..68a945f9c 100644 --- a/stdlib/source/test/lux/extension.lux +++ b/stdlib/source/test/lux/extension.lux @@ -56,45 +56,45 @@ (as_is ... Analysis - (analysis: (..my_analysis self phase archive {pass_through <code>.any}) + (analysis: (..my_analysis self phase archive [pass_through <code>.any]) (phase archive pass_through)) ... Synthesis - (analysis: (..my_synthesis self phase archive {parameters (<>.some <code>.any)}) + (analysis: (..my_synthesis self phase archive [parameters (<>.some <code>.any)]) (let [! phase.monad] (|> parameters (monad.map ! (phase archive)) (\ ! map (|>> (#analysis.Extension self)))))) - (synthesis: (..my_synthesis self phase archive {pass_through <analysis>.any}) + (synthesis: (..my_synthesis self phase archive [pass_through <analysis>.any]) (phase archive pass_through)) ... Generation - (analysis: (..my_generation self phase archive {parameters (<>.some <code>.any)}) + (analysis: (..my_generation self phase archive [parameters (<>.some <code>.any)]) (let [! phase.monad] (|> parameters (monad.map ! (phase archive)) (\ ! map (|>> (#analysis.Extension self)))))) - (synthesis: (..my_generation self phase archive {parameters (<>.some <analysis>.any)}) + (synthesis: (..my_generation self phase archive [parameters (<>.some <analysis>.any)]) (let [! phase.monad] (|> parameters (monad.map ! (phase archive)) (\ ! map (|>> (#synthesis.Extension self)))))) - (generation: (..my_generation self phase archive {pass_through <synthesis>.any}) + (generation: (..my_generation self phase archive [pass_through <synthesis>.any]) (for {@.jvm (\ phase.monad map (|>> #jvm.Embedded row.row) (phase archive pass_through))} (phase archive pass_through))) - (analysis: (..dummy_generation self phase archive) + (analysis: (..dummy_generation self phase archive []) (\ phase.monad in (#analysis.Extension self (list)))) - (synthesis: (..dummy_generation self phase archive) + (synthesis: (..dummy_generation self phase archive []) (\ phase.monad in (#synthesis.Extension self (list)))) - (generation: (..dummy_generation self phase archive) + (generation: (..dummy_generation self phase archive []) (\ phase.monad in (for {@.jvm (row.row (#jvm.Constant (#jvm.LDC (#jvm.String self)))) @@ -107,7 +107,7 @@ @.scheme (scheme.string self)}))) ... Directive - (directive: (..my_directive self phase archive {parameters (<>.some <code>.any)}) + (directive: (..my_directive self phase archive [parameters (<>.some <code>.any)]) (do phase.monad [.let [_ (debug.log! (format "Successfully installed directive " (%.text self) "!"))]] (in directive.no_requirements))) diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux index 24c4c6f11..55c812d72 100644 --- a/stdlib/source/test/lux/ffi.jvm.lux +++ b/stdlib/source/test/lux/ffi.jvm.lux @@ -199,10 +199,10 @@ )) (_.cover [/.cannot_cast_to_non_object] (text.contains? (get@ #exception.label /.cannot_cast_to_non_object) - (macro_error (/.:cast boolean (: /.Boolean boolean))))) - (_.cover [/.:cast] + (macro_error (/.:as boolean (: /.Boolean boolean))))) + (_.cover [/.:as] (|> string - (/.:cast java/lang/Object) + (/.:as java/lang/Object) (same? (:as java/lang/Object string)))) (_.cover [/.type] (and (and (type\= /.Boolean (/.type java/lang/Boolean)) diff --git a/stdlib/source/test/lux/locale/language.lux b/stdlib/source/test/lux/locale/language.lux index 9c272f1bc..29389ae9f 100644 --- a/stdlib/source/test/lux/locale/language.lux +++ b/stdlib/source/test/lux/locale/language.lux @@ -283,7 +283,7 @@ (do {! random.monad} [choice (\ ! map (n.% (list.size options)) random.nat)] - (in (maybe.assume (list.item choice options)))))) + (in (maybe.trusted (list.item choice options)))))) (def: .public test Test diff --git a/stdlib/source/test/lux/locale/territory.lux b/stdlib/source/test/lux/locale/territory.lux index 2388bdecf..fa7aff326 100644 --- a/stdlib/source/test/lux/locale/territory.lux +++ b/stdlib/source/test/lux/locale/territory.lux @@ -209,7 +209,7 @@ (do {! random.monad} [choice (\ ! map (n.% (list.size options)) random.nat)] - (in (maybe.assume (list.item choice options)))))) + (in (maybe.trusted (list.item choice options)))))) (def: .public test Test diff --git a/stdlib/source/test/lux/macro.lux b/stdlib/source/test/lux/macro.lux index 3ac184b75..93f2f8530 100644 --- a/stdlib/source/test/lux/macro.lux +++ b/stdlib/source/test/lux/macro.lux @@ -29,7 +29,6 @@ ["." / #_ ["#." code] ["#." local] - ["#." poly] ["#." syntax] ["#." template]]) @@ -184,6 +183,5 @@ /code.test /local.test /syntax.test - /poly.test /template.test ))) diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux index 1403d6ee8..5c84f9c38 100644 --- a/stdlib/source/test/lux/meta.lux +++ b/stdlib/source/test/lux/meta.lux @@ -930,11 +930,11 @@ (do random.monad [expected_value random.nat expected_error (random.ascii/upper 1)] - (_.cover [/.lift] + (_.cover [/.lifted] (and (|> expected_error #try.Failure (: (Try Nat)) - /.lift + /.lifted (/.result expected_lux) (!expect (^multi (#try.Failure actual) (text\= (location.with expected_location expected_error) @@ -942,7 +942,7 @@ (|> expected_value #try.Success (: (Try Nat)) - /.lift + /.lifted (/.result expected_lux) (!expect (^multi (#try.Success actual) (same? expected_value actual))))))) diff --git a/stdlib/source/test/lux/target/jvm.lux b/stdlib/source/test/lux/target/jvm.lux index f503c8779..ae4685790 100644 --- a/stdlib/source/test/lux/target/jvm.lux +++ b/stdlib/source/test/lux/target/jvm.lux @@ -306,13 +306,13 @@ Test (do {! random.monad} [expected (\ ! map (i64.and (i64.mask <bits>)) random.nat)] - (<| (_.lift <message>) + (<| (_.lifted <message>) (..bytecode (for {@.old (|>> (:as <type>) <to_long> ("jvm leq" expected)) @.jvm (|>> (:as <type>) <to_long> "jvm object cast" ("jvm long =" ("jvm object cast" (:as java/lang/Long expected))))})) (do /.monad - [_ (<push> (|> expected .int <signed> try.assumed))] + [_ (<push> (|> expected .int <signed> try.trusted))] <wrap>))))] [byte 7 java/lang/Byte /.bipush ..$Byte::wrap "BIPUSH" ffi.byte_to_long /signed.s1] @@ -391,35 +391,35 @@ _ (..$Integer::literal parameter)] instruction))))) literal ($_ _.and - (_.lift "ICONST_M1" (int (ffi.long_to_int (:as java/lang/Long -1)) /.iconst_m1)) - (_.lift "ICONST_0" (int (ffi.long_to_int (:as java/lang/Long +0)) /.iconst_0)) - (_.lift "ICONST_1" (int (ffi.long_to_int (:as java/lang/Long +1)) /.iconst_1)) - (_.lift "ICONST_2" (int (ffi.long_to_int (:as java/lang/Long +2)) /.iconst_2)) - (_.lift "ICONST_3" (int (ffi.long_to_int (:as java/lang/Long +3)) /.iconst_3)) - (_.lift "ICONST_4" (int (ffi.long_to_int (:as java/lang/Long +4)) /.iconst_4)) - (_.lift "ICONST_5" (int (ffi.long_to_int (:as java/lang/Long +5)) /.iconst_5)) - (_.lift "LDC_W/INTEGER" - (do random.monad - [expected ..$Integer::random] - (int expected (..$Integer::literal expected))))) + (_.lifted "ICONST_M1" (int (ffi.long_to_int (:as java/lang/Long -1)) /.iconst_m1)) + (_.lifted "ICONST_0" (int (ffi.long_to_int (:as java/lang/Long +0)) /.iconst_0)) + (_.lifted "ICONST_1" (int (ffi.long_to_int (:as java/lang/Long +1)) /.iconst_1)) + (_.lifted "ICONST_2" (int (ffi.long_to_int (:as java/lang/Long +2)) /.iconst_2)) + (_.lifted "ICONST_3" (int (ffi.long_to_int (:as java/lang/Long +3)) /.iconst_3)) + (_.lifted "ICONST_4" (int (ffi.long_to_int (:as java/lang/Long +4)) /.iconst_4)) + (_.lifted "ICONST_5" (int (ffi.long_to_int (:as java/lang/Long +5)) /.iconst_5)) + (_.lifted "LDC_W/INTEGER" + (do random.monad + [expected ..$Integer::random] + (int expected (..$Integer::literal expected))))) arithmetic ($_ _.and - (_.lift "IADD" (binary (int/2 "jvm iadd" "jvm int +") /.iadd)) - (_.lift "ISUB" (binary (int/2 "jvm isub" "jvm int -") /.isub)) - (_.lift "IMUL" (binary (int/2 "jvm imul" "jvm int *") /.imul)) - (_.lift "IDIV" (binary (int/2 "jvm idiv" "jvm int /") /.idiv)) - (_.lift "IREM" (binary (int/2 "jvm irem" "jvm int %") /.irem)) - (_.lift "INEG" (unary (function (_ value) - ((int/2 "jvm isub" "jvm int -") - value - (ffi.long_to_int (:as java/lang/Long +0)))) - /.ineg))) + (_.lifted "IADD" (binary (int/2 "jvm iadd" "jvm int +") /.iadd)) + (_.lifted "ISUB" (binary (int/2 "jvm isub" "jvm int -") /.isub)) + (_.lifted "IMUL" (binary (int/2 "jvm imul" "jvm int *") /.imul)) + (_.lifted "IDIV" (binary (int/2 "jvm idiv" "jvm int /") /.idiv)) + (_.lifted "IREM" (binary (int/2 "jvm irem" "jvm int %") /.irem)) + (_.lifted "INEG" (unary (function (_ value) + ((int/2 "jvm isub" "jvm int -") + value + (ffi.long_to_int (:as java/lang/Long +0)))) + /.ineg))) bitwise ($_ _.and - (_.lift "IAND" (binary (int/2 "jvm iand" "jvm int and") /.iand)) - (_.lift "IOR" (binary (int/2 "jvm ior" "jvm int or") /.ior)) - (_.lift "IXOR" (binary (int/2 "jvm ixor" "jvm int xor") /.ixor)) - (_.lift "ISHL" (shift (int/2 "jvm ishl" "jvm int shl") /.ishl)) - (_.lift "ISHR" (shift (int/2 "jvm ishr" "jvm int shr") /.ishr)) - (_.lift "IUSHR" (shift (int/2 "jvm iushr" "jvm int ushr") /.iushr)))] + (_.lifted "IAND" (binary (int/2 "jvm iand" "jvm int and") /.iand)) + (_.lifted "IOR" (binary (int/2 "jvm ior" "jvm int or") /.ior)) + (_.lifted "IXOR" (binary (int/2 "jvm ixor" "jvm int xor") /.ixor)) + (_.lifted "ISHL" (shift (int/2 "jvm ishl" "jvm int shl") /.ishl)) + (_.lifted "ISHR" (shift (int/2 "jvm ishr" "jvm int shr") /.ishr)) + (_.lifted "IUSHR" (shift (int/2 "jvm iushr" "jvm int ushr") /.iushr)))] ($_ _.and (<| (_.context "literal") literal) @@ -470,53 +470,53 @@ _ (..$Integer::literal (ffi.long_to_int parameter))] instruction))))) literal ($_ _.and - (_.lift "LCONST_0" (long (:as java/lang/Long +0) /.lconst_0)) - (_.lift "LCONST_1" (long (:as java/lang/Long +1) /.lconst_1)) - (_.lift "LDC2_W/LONG" - (do random.monad - [expected ..$Long::random] - (long expected (..$Long::literal expected))))) + (_.lifted "LCONST_0" (long (:as java/lang/Long +0) /.lconst_0)) + (_.lifted "LCONST_1" (long (:as java/lang/Long +1) /.lconst_1)) + (_.lifted "LDC2_W/LONG" + (do random.monad + [expected ..$Long::random] + (long expected (..$Long::literal expected))))) arithmetic ($_ _.and - (_.lift "LADD" (binary (long/2 "jvm ladd" "jvm long +") /.ladd)) - (_.lift "LSUB" (binary (long/2 "jvm lsub" "jvm long -") /.lsub)) - (_.lift "LMUL" (binary (long/2 "jvm lmul" "jvm long *") /.lmul)) - (_.lift "LDIV" (binary (long/2 "jvm ldiv" "jvm long /") /.ldiv)) - (_.lift "LREM" (binary (long/2 "jvm lrem" "jvm long %") /.lrem)) - (_.lift "LNEG" (unary (function (_ value) - ((long/2 "jvm lsub" "jvm long -") - value - (:as java/lang/Long +0))) - /.lneg))) + (_.lifted "LADD" (binary (long/2 "jvm ladd" "jvm long +") /.ladd)) + (_.lifted "LSUB" (binary (long/2 "jvm lsub" "jvm long -") /.lsub)) + (_.lifted "LMUL" (binary (long/2 "jvm lmul" "jvm long *") /.lmul)) + (_.lifted "LDIV" (binary (long/2 "jvm ldiv" "jvm long /") /.ldiv)) + (_.lifted "LREM" (binary (long/2 "jvm lrem" "jvm long %") /.lrem)) + (_.lifted "LNEG" (unary (function (_ value) + ((long/2 "jvm lsub" "jvm long -") + value + (:as java/lang/Long +0))) + /.lneg))) bitwise ($_ _.and - (_.lift "LAND" (binary (long/2 "jvm land" "jvm long and") /.land)) - (_.lift "LOR" (binary (long/2 "jvm lor" "jvm long or") /.lor)) - (_.lift "LXOR" (binary (long/2 "jvm lxor" "jvm long xor") /.lxor)) - (_.lift "LSHL" (shift (int+long/2 "jvm lshl" "jvm long shl") /.lshl)) - (_.lift "LSHR" (shift (int+long/2 "jvm lshr" "jvm long shr") /.lshr)) - (_.lift "LUSHR" (shift (int+long/2 "jvm lushr" "jvm long ushr") /.lushr))) - comparison (_.lift "LCMP" - (do random.monad - [reference ..$Long::random - subject ..$Long::random - .let [expected (cond (i.= (:as Int reference) (:as Int subject)) - (:as java/lang/Long +0) + (_.lifted "LAND" (binary (long/2 "jvm land" "jvm long and") /.land)) + (_.lifted "LOR" (binary (long/2 "jvm lor" "jvm long or") /.lor)) + (_.lifted "LXOR" (binary (long/2 "jvm lxor" "jvm long xor") /.lxor)) + (_.lifted "LSHL" (shift (int+long/2 "jvm lshl" "jvm long shl") /.lshl)) + (_.lifted "LSHR" (shift (int+long/2 "jvm lshr" "jvm long shr") /.lshr)) + (_.lifted "LUSHR" (shift (int+long/2 "jvm lushr" "jvm long ushr") /.lushr))) + comparison (_.lifted "LCMP" + (do random.monad + [reference ..$Long::random + subject ..$Long::random + .let [expected (cond (i.= (:as Int reference) (:as Int subject)) + (:as java/lang/Long +0) - (i.> (:as Int reference) (:as Int subject)) - (:as java/lang/Long +1) + (i.> (:as Int reference) (:as Int subject)) + (:as java/lang/Long +1) - ... (i.< (:as Int reference) (:as Int subject)) - (:as java/lang/Long -1))]] - (<| (..bytecode (for {@.old - (|>> (:as Int) (i.= expected)) - - @.jvm - (|>> (:as java/lang/Long) "jvm object cast" ("jvm long =" ("jvm object cast" expected)))})) - (do /.monad - [_ (..$Long::literal subject) - _ (..$Long::literal reference) - _ /.lcmp - _ /.i2l] - ..$Long::wrap))))] + ... (i.< (:as Int reference) (:as Int subject)) + (:as java/lang/Long -1))]] + (<| (..bytecode (for {@.old + (|>> (:as Int) (i.= expected)) + + @.jvm + (|>> (:as java/lang/Long) "jvm object cast" ("jvm long =" ("jvm object cast" expected)))})) + (do /.monad + [_ (..$Long::literal subject) + _ (..$Long::literal reference) + _ /.lcmp + _ /.i2l] + ..$Long::wrap))))] ($_ _.and (<| (_.context "literal") literal) @@ -569,24 +569,24 @@ _ (..$Float::literal parameter)] instruction))))) literal ($_ _.and - (_.lift "FCONST_0" (float (ffi.double_to_float (:as java/lang/Double +0.0)) /.fconst_0)) - (_.lift "FCONST_1" (float (ffi.double_to_float (:as java/lang/Double +1.0)) /.fconst_1)) - (_.lift "FCONST_2" (float (ffi.double_to_float (:as java/lang/Double +2.0)) /.fconst_2)) - (_.lift "LDC_W/FLOAT" - (do random.monad - [expected ..$Float::random] - (float expected (..$Float::literal expected))))) + (_.lifted "FCONST_0" (float (ffi.double_to_float (:as java/lang/Double +0.0)) /.fconst_0)) + (_.lifted "FCONST_1" (float (ffi.double_to_float (:as java/lang/Double +1.0)) /.fconst_1)) + (_.lifted "FCONST_2" (float (ffi.double_to_float (:as java/lang/Double +2.0)) /.fconst_2)) + (_.lifted "LDC_W/FLOAT" + (do random.monad + [expected ..$Float::random] + (float expected (..$Float::literal expected))))) arithmetic ($_ _.and - (_.lift "FADD" (binary (float/2 "jvm fadd" "jvm float +") /.fadd)) - (_.lift "FSUB" (binary (float/2 "jvm fsub" "jvm float -") /.fsub)) - (_.lift "FMUL" (binary (float/2 "jvm fmul" "jvm float *") /.fmul)) - (_.lift "FDIV" (binary (float/2 "jvm fdiv" "jvm float /") /.fdiv)) - (_.lift "FREM" (binary (float/2 "jvm frem" "jvm float %") /.frem)) - (_.lift "FNEG" (unary (function (_ value) - ((float/2 "jvm fsub" "jvm float -") - value - (ffi.double_to_float (:as java/lang/Double +0.0)))) - /.fneg))) + (_.lifted "FADD" (binary (float/2 "jvm fadd" "jvm float +") /.fadd)) + (_.lifted "FSUB" (binary (float/2 "jvm fsub" "jvm float -") /.fsub)) + (_.lifted "FMUL" (binary (float/2 "jvm fmul" "jvm float *") /.fmul)) + (_.lifted "FDIV" (binary (float/2 "jvm fdiv" "jvm float /") /.fdiv)) + (_.lifted "FREM" (binary (float/2 "jvm frem" "jvm float %") /.frem)) + (_.lifted "FNEG" (unary (function (_ value) + ((float/2 "jvm fsub" "jvm float -") + value + (ffi.double_to_float (:as java/lang/Double +0.0)))) + /.fneg))) comparison (: (-> (Bytecode Any) (-> java/lang/Float java/lang/Float Bit) (Random Bit)) (function (_ instruction standard) (do random.monad @@ -618,8 +618,8 @@ @.jvm ("jvm float <" ("jvm object cast" subject) ("jvm object cast" reference))}))) comparison ($_ _.and - (_.lift "FCMPL" (comparison /.fcmpl comparison_standard)) - (_.lift "FCMPG" (comparison /.fcmpg comparison_standard)))] + (_.lifted "FCMPL" (comparison /.fcmpl comparison_standard)) + (_.lifted "FCMPG" (comparison /.fcmpg comparison_standard)))] ($_ _.and (<| (_.context "literal") literal) @@ -666,23 +666,23 @@ _ (..$Double::literal parameter)] instruction))))) literal ($_ _.and - (_.lift "DCONST_0" (double (:as java/lang/Double +0.0) /.dconst_0)) - (_.lift "DCONST_1" (double (:as java/lang/Double +1.0) /.dconst_1)) - (_.lift "LDC2_W/DOUBLE" - (do random.monad - [expected ..$Double::random] - (double expected (..$Double::literal expected))))) + (_.lifted "DCONST_0" (double (:as java/lang/Double +0.0) /.dconst_0)) + (_.lifted "DCONST_1" (double (:as java/lang/Double +1.0) /.dconst_1)) + (_.lifted "LDC2_W/DOUBLE" + (do random.monad + [expected ..$Double::random] + (double expected (..$Double::literal expected))))) arithmetic ($_ _.and - (_.lift "DADD" (binary (double/2 "jvm dadd" "jvm double +") /.dadd)) - (_.lift "DSUB" (binary (double/2 "jvm dsub" "jvm double -") /.dsub)) - (_.lift "DMUL" (binary (double/2 "jvm dmul" "jvm double *") /.dmul)) - (_.lift "DDIV" (binary (double/2 "jvm ddiv" "jvm double /") /.ddiv)) - (_.lift "DREM" (binary (double/2 "jvm drem" "jvm double %") /.drem)) - (_.lift "DNEG" (unary (function (_ value) - ((double/2 "jvm dsub" "jvm double -") - value - (:as java/lang/Double +0.0))) - /.dneg))) + (_.lifted "DADD" (binary (double/2 "jvm dadd" "jvm double +") /.dadd)) + (_.lifted "DSUB" (binary (double/2 "jvm dsub" "jvm double -") /.dsub)) + (_.lifted "DMUL" (binary (double/2 "jvm dmul" "jvm double *") /.dmul)) + (_.lifted "DDIV" (binary (double/2 "jvm ddiv" "jvm double /") /.ddiv)) + (_.lifted "DREM" (binary (double/2 "jvm drem" "jvm double %") /.drem)) + (_.lifted "DNEG" (unary (function (_ value) + ((double/2 "jvm dsub" "jvm double -") + value + (:as java/lang/Double +0.0))) + /.dneg))) comparison (: (-> (Bytecode Any) (-> java/lang/Double java/lang/Double Bit) (Random Bit)) (function (_ instruction standard) (do random.monad @@ -713,8 +713,8 @@ @.jvm ("jvm double <" ("jvm object cast" subject) ("jvm object cast" reference))}))) comparison ($_ _.and - (_.lift "DCMPL" (comparison /.dcmpl comparison_standard)) - (_.lift "DCMPG" (comparison /.dcmpg comparison_standard)))] + (_.lifted "DCMPL" (comparison /.dcmpl comparison_standard)) + (_.lifted "DCMPG" (comparison /.dcmpg comparison_standard)))] ($_ _.and (<| (_.context "literal") literal) @@ -749,13 +749,13 @@ _ /.dup] (/.invokespecial ..$Object "<init>" (/type.method [(list) (list) /type.void (list)]))))] ($_ _.and - (<| (_.lift "ACONST_NULL") + (<| (_.lifted "ACONST_NULL") (..bytecode (|>> (:as Bit) not)) (do /.monad [_ /.aconst_null _ (/.instanceof ..$String)] ..$Boolean::wrap)) - (<| (_.lift "INSTANCEOF") + (<| (_.lifted "INSTANCEOF") (do random.monad [value ..$String::random]) (..bytecode (|>> (:as Bit))) @@ -763,14 +763,14 @@ [_ (/.string (:as Text value)) _ (/.instanceof ..$String)] ..$Boolean::wrap)) - (<| (_.lift "NEW & CHECKCAST") + (<| (_.lifted "NEW & CHECKCAST") (..bytecode (|>> (:as Bit))) (do /.monad [_ !object _ (/.checkcast ..$Object) _ (/.instanceof ..$Object)] ..$Boolean::wrap)) - (<| (_.lift "MONITORENTER & MONITOREXIT") + (<| (_.lifted "MONITORENTER & MONITOREXIT") (do random.monad [value ..$String::random]) (..bytecode (|>> (:as Bit))) @@ -785,7 +785,7 @@ (def: method Test ($_ _.and - (<| (_.lift "INVOKESTATIC") + (<| (_.lifted "INVOKESTATIC") (do random.monad [expected (random.only (|>> (:as Frac) f.not_a_number? not) ..$Double::random)]) @@ -797,7 +797,7 @@ (do /.monad [_ (/.double expected)] (/.invokestatic ..$Double "valueOf" (/type.method [(list) (list /type.double) ..$Double (list)])))) - (<| (_.lift "INVOKEVIRTUAL") + (<| (_.lifted "INVOKEVIRTUAL") (do random.monad [expected ..$Double::random]) (..bytecode (|>> (:as Bit) (bit\= (f.not_a_number? (:as Frac expected))))) @@ -806,7 +806,7 @@ _ ..$Double::wrap _ (/.invokevirtual ..$Double "isNaN" (/type.method [(list) (list) /type.boolean (list)]))] ..$Boolean::wrap)) - (<| (_.lift "INVOKESPECIAL") + (<| (_.lifted "INVOKESPECIAL") (do random.monad [expected (random.only (|>> (:as Frac) f.not_a_number? not) ..$Double::random)]) @@ -820,7 +820,7 @@ _ /.dup _ (/.double expected)] (/.invokespecial ..$Double "<init>" (/type.method [(list) (list /type.double) /type.void (list)])))) - (<| (_.lift "INVOKEINTERFACE") + (<| (_.lifted "INVOKEINTERFACE") (do random.monad [subject ..$String::random]) (..bytecode (|>> (:as Nat) (n.= (text.size (:as Text subject))))) @@ -886,7 +886,7 @@ _ ..$Long::wrap] /.areturn)))) (row.row)) - try.assumed + try.trusted (format.result /class.writer)) loader (/loader.memory (/loader.new_library []))]] (_.test "PUTSTATIC & PUTFIELD & GETFIELD & GETSTATIC" @@ -946,9 +946,9 @@ [size (\ ! map (|>> (n.% 1024) (n.max 1)) random.nat) value random] ($_ _.and - (<| (_.lift "length") + (<| (_.lifted "length") (length size constructor)) - (<| (_.lift "write and read") + (<| (_.lifted "write and read") (write_and_read size constructor value literal [*store *load *wrap] test))))))] ($_ _.and (_.context "boolean" @@ -1026,12 +1026,12 @@ (case dimensions 0 type _ (recur (dec dimensions) (/type.array type))))]] - (<| (_.lift "MULTIANEWARRAY") + (<| (_.lifted "MULTIANEWARRAY") (..bytecode (|>> (:as Nat) (n.= sizesH))) (do {! /.monad} [_ (monad.map ! (|>> (:as java/lang/Long) ffi.long_to_int ..$Integer::literal) (#.Item sizesH sizesT)) - _ (/.multianewarray type (|> dimensions /unsigned.u1 try.assumed)) + _ (/.multianewarray type (|> dimensions /unsigned.u1 try.trusted)) _ ?length] $Long::wrap)))) ))) @@ -1065,40 +1065,40 @@ ($_ _.and (<| (_.context "int") ($_ _.and - (_.lift "I2L" (conversion ..$Integer::primitive ..$Long::primitive /.i2l (|>> ffi.int_to_long) long::=)) - (_.lift "I2F" (conversion ..$Integer::primitive ..$Float::primitive /.i2f (|>> ffi.int_to_float) float::=)) - (_.lift "I2D" (conversion ..$Integer::primitive ..$Double::primitive /.i2d (|>> ffi.int_to_double) double::=)) - (_.lift "I2B" (conversion ..$Integer::primitive ..$Byte::primitive /.i2b (|>> ffi.int_to_byte) - (function (_ expected) - (for {@.old - (|>> (:as java/lang/Byte) ffi.byte_to_long ("jvm leq" (ffi.byte_to_long expected))) - - @.jvm - (|>> (:as java/lang/Byte) ffi.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.byte_to_long (:as java/lang/Byte expected)))))})))) - (_.lift "I2C" (conversion ..$Integer::primitive ..$Character::primitive /.i2c (|>> ffi.int_to_char) - (!::= java/lang/Character "jvm ceq" "jvm char ="))) - (_.lift "I2S" (conversion ..$Integer::primitive ..$Short::primitive /.i2s (|>> ffi.int_to_short) - (function (_ expected) - (for {@.old - (|>> (:as java/lang/Short) ffi.short_to_long ("jvm leq" (ffi.short_to_long expected))) - - @.jvm - (|>> (:as java/lang/Short) ffi.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.short_to_long (:as java/lang/Short expected)))))})))))) + (_.lifted "I2L" (conversion ..$Integer::primitive ..$Long::primitive /.i2l (|>> ffi.int_to_long) long::=)) + (_.lifted "I2F" (conversion ..$Integer::primitive ..$Float::primitive /.i2f (|>> ffi.int_to_float) float::=)) + (_.lifted "I2D" (conversion ..$Integer::primitive ..$Double::primitive /.i2d (|>> ffi.int_to_double) double::=)) + (_.lifted "I2B" (conversion ..$Integer::primitive ..$Byte::primitive /.i2b (|>> ffi.int_to_byte) + (function (_ expected) + (for {@.old + (|>> (:as java/lang/Byte) ffi.byte_to_long ("jvm leq" (ffi.byte_to_long expected))) + + @.jvm + (|>> (:as java/lang/Byte) ffi.byte_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.byte_to_long (:as java/lang/Byte expected)))))})))) + (_.lifted "I2C" (conversion ..$Integer::primitive ..$Character::primitive /.i2c (|>> ffi.int_to_char) + (!::= java/lang/Character "jvm ceq" "jvm char ="))) + (_.lifted "I2S" (conversion ..$Integer::primitive ..$Short::primitive /.i2s (|>> ffi.int_to_short) + (function (_ expected) + (for {@.old + (|>> (:as java/lang/Short) ffi.short_to_long ("jvm leq" (ffi.short_to_long expected))) + + @.jvm + (|>> (:as java/lang/Short) ffi.short_to_long "jvm object cast" ("jvm long =" ("jvm object cast" (ffi.short_to_long (:as java/lang/Short expected)))))})))))) (<| (_.context "long") ($_ _.and - (_.lift "L2I" (conversion ..$Long::primitive ..$Integer::primitive /.l2i (|>> ffi.long_to_int) int::=)) - (_.lift "L2F" (conversion ..$Long::primitive ..$Float::primitive /.l2f (|>> ffi.long_to_float) float::=)) - (_.lift "L2D" (conversion ..$Long::primitive ..$Double::primitive /.l2d (|>> ffi.long_to_double) double::=)))) + (_.lifted "L2I" (conversion ..$Long::primitive ..$Integer::primitive /.l2i (|>> ffi.long_to_int) int::=)) + (_.lifted "L2F" (conversion ..$Long::primitive ..$Float::primitive /.l2f (|>> ffi.long_to_float) float::=)) + (_.lifted "L2D" (conversion ..$Long::primitive ..$Double::primitive /.l2d (|>> ffi.long_to_double) double::=)))) (<| (_.context "float") ($_ _.and - (_.lift "F2I" (conversion ..$Float::primitive ..$Integer::primitive /.f2i (|>> ffi.float_to_int) int::=)) - (_.lift "F2L" (conversion ..$Float::primitive ..$Long::primitive /.f2l (|>> ffi.float_to_long) long::=)) - (_.lift "F2D" (conversion ..$Float::primitive ..$Double::primitive /.f2d (|>> ffi.float_to_double) double::=)))) + (_.lifted "F2I" (conversion ..$Float::primitive ..$Integer::primitive /.f2i (|>> ffi.float_to_int) int::=)) + (_.lifted "F2L" (conversion ..$Float::primitive ..$Long::primitive /.f2l (|>> ffi.float_to_long) long::=)) + (_.lifted "F2D" (conversion ..$Float::primitive ..$Double::primitive /.f2d (|>> ffi.float_to_double) double::=)))) (<| (_.context "double") ($_ _.and - (_.lift "D2I" (conversion ..$Double::primitive ..$Integer::primitive /.d2i (|>> ffi.double_to_int) int::=)) - (_.lift "D2L" (conversion ..$Double::primitive ..$Long::primitive /.d2l (|>> ffi.double_to_long) long::=)) - (_.lift "D2F" (conversion ..$Double::primitive ..$Float::primitive /.d2f (|>> ffi.double_to_float) float::=)))) + (_.lifted "D2I" (conversion ..$Double::primitive ..$Integer::primitive /.d2i (|>> ffi.double_to_int) int::=)) + (_.lifted "D2L" (conversion ..$Double::primitive ..$Long::primitive /.d2l (|>> ffi.double_to_long) long::=)) + (_.lifted "D2F" (conversion ..$Double::primitive ..$Float::primitive /.d2f (|>> ffi.double_to_float) float::=)))) ))) (def: value @@ -1139,94 +1139,94 @@ (<| (_.context "int") (let [test (!::= java/lang/Integer "jvm ieq" "jvm int =")] ($_ _.and - (_.lift "ISTORE_0/ILOAD_0" - (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore_0) (function.constant /.iload_0)] test)) - (_.lift "ISTORE_1/ILOAD_1" - (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore_1) (function.constant /.iload_1)] test)) - (_.lift "ISTORE_2/ILOAD_2" - (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore_2) (function.constant /.iload_2)] test)) - (_.lift "ISTORE_3/ILOAD_3" - (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore_3) (function.constant /.iload_3)] test)) - (_.lift "ISTORE/ILOAD" - (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [/.istore /.iload] test)) - (_.lift "IINC" - (do {! random.monad} - [base ..$Byte::random - increment (\ ! map (|>> (n.% 100) /unsigned.u1 try.assumed) - random.nat) - .let [expected (: java/lang/Long - (for {@.old - ("jvm ladd" - (ffi.byte_to_long base) - (.int (/unsigned.value increment))) - - @.jvm - ("jvm object cast" - ("jvm long +" - ("jvm object cast" (ffi.byte_to_long base)) - ("jvm object cast" (:as java/lang/Long (/unsigned.value increment)))))}))]] - (..bytecode (|>> (:as Int) (i.= (:as Int expected))) - (do /.monad - [_ (..$Byte::literal base) - _ /.istore_0 - _ (/.iinc 0 increment) - _ /.iload_0 - _ /.i2l] - ..$Long::wrap))))))) + (_.lifted "ISTORE_0/ILOAD_0" + (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore_0) (function.constant /.iload_0)] test)) + (_.lifted "ISTORE_1/ILOAD_1" + (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore_1) (function.constant /.iload_1)] test)) + (_.lifted "ISTORE_2/ILOAD_2" + (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore_2) (function.constant /.iload_2)] test)) + (_.lifted "ISTORE_3/ILOAD_3" + (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [(function.constant /.istore_3) (function.constant /.iload_3)] test)) + (_.lifted "ISTORE/ILOAD" + (store_and_load ..$Integer::random ..$Integer::literal ..$Integer::wrap [/.istore /.iload] test)) + (_.lifted "IINC" + (do {! random.monad} + [base ..$Byte::random + increment (\ ! map (|>> (n.% 100) /unsigned.u1 try.trusted) + random.nat) + .let [expected (: java/lang/Long + (for {@.old + ("jvm ladd" + (ffi.byte_to_long base) + (.int (/unsigned.value increment))) + + @.jvm + ("jvm object cast" + ("jvm long +" + ("jvm object cast" (ffi.byte_to_long base)) + ("jvm object cast" (:as java/lang/Long (/unsigned.value increment)))))}))]] + (..bytecode (|>> (:as Int) (i.= (:as Int expected))) + (do /.monad + [_ (..$Byte::literal base) + _ /.istore_0 + _ (/.iinc 0 increment) + _ /.iload_0 + _ /.i2l] + ..$Long::wrap))))))) (<| (_.context "long") (let [test (!::= java/lang/Long "jvm leq" "jvm long =")] ($_ _.and - (_.lift "LSTORE_0/LLOAD_0" - (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore_0) (function.constant /.lload_0)] test)) - (_.lift "LSTORE_1/LLOAD_1" - (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore_1) (function.constant /.lload_1)] test)) - (_.lift "LSTORE_2/LLOAD_2" - (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore_2) (function.constant /.lload_2)] test)) - (_.lift "LSTORE_3/LLOAD_3" - (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore_3) (function.constant /.lload_3)] test)) - (_.lift "LSTORE/LLOAD" - (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [/.lstore /.lload] test))))) + (_.lifted "LSTORE_0/LLOAD_0" + (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore_0) (function.constant /.lload_0)] test)) + (_.lifted "LSTORE_1/LLOAD_1" + (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore_1) (function.constant /.lload_1)] test)) + (_.lifted "LSTORE_2/LLOAD_2" + (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore_2) (function.constant /.lload_2)] test)) + (_.lifted "LSTORE_3/LLOAD_3" + (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [(function.constant /.lstore_3) (function.constant /.lload_3)] test)) + (_.lifted "LSTORE/LLOAD" + (store_and_load ..$Long::random ..$Long::literal ..$Long::wrap [/.lstore /.lload] test))))) (<| (_.context "float") (let [test (!::= java/lang/Float "jvm feq" "jvm float =")] ($_ _.and - (_.lift "FSTORE_0/FLOAD_0" - (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [(function.constant /.fstore_0) (function.constant /.fload_0)] test)) - (_.lift "FSTORE_1/FLOAD_1" - (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [(function.constant /.fstore_1) (function.constant /.fload_1)] test)) - (_.lift "FSTORE_2/FLOAD_2" - (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [(function.constant /.fstore_2) (function.constant /.fload_2)] test)) - (_.lift "FSTORE_3/FLOAD_3" - (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [(function.constant /.fstore_3) (function.constant /.fload_3)] test)) - (_.lift "FSTORE/FLOAD" - (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [/.fstore /.fload] test))))) + (_.lifted "FSTORE_0/FLOAD_0" + (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [(function.constant /.fstore_0) (function.constant /.fload_0)] test)) + (_.lifted "FSTORE_1/FLOAD_1" + (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [(function.constant /.fstore_1) (function.constant /.fload_1)] test)) + (_.lifted "FSTORE_2/FLOAD_2" + (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [(function.constant /.fstore_2) (function.constant /.fload_2)] test)) + (_.lifted "FSTORE_3/FLOAD_3" + (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [(function.constant /.fstore_3) (function.constant /.fload_3)] test)) + (_.lifted "FSTORE/FLOAD" + (store_and_load ..valid_float ..$Float::literal ..$Float::wrap [/.fstore /.fload] test))))) (<| (_.context "double") (let [test (!::= java/lang/Double "jvm deq" "jvm double =")] ($_ _.and - (_.lift "DSTORE_0/DLOAD_0" - (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [(function.constant /.dstore_0) (function.constant /.dload_0)] test)) - (_.lift "DSTORE_1/DLOAD_1" - (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [(function.constant /.dstore_1) (function.constant /.dload_1)] test)) - (_.lift "DSTORE_2/DLOAD_2" - (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [(function.constant /.dstore_2) (function.constant /.dload_2)] test)) - (_.lift "DSTORE_3/DLOAD_3" - (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [(function.constant /.dstore_3) (function.constant /.dload_3)] test)) - (_.lift "DSTORE/DLOAD" - (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [/.dstore /.dload] test))))) + (_.lifted "DSTORE_0/DLOAD_0" + (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [(function.constant /.dstore_0) (function.constant /.dload_0)] test)) + (_.lifted "DSTORE_1/DLOAD_1" + (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [(function.constant /.dstore_1) (function.constant /.dload_1)] test)) + (_.lifted "DSTORE_2/DLOAD_2" + (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [(function.constant /.dstore_2) (function.constant /.dload_2)] test)) + (_.lifted "DSTORE_3/DLOAD_3" + (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [(function.constant /.dstore_3) (function.constant /.dload_3)] test)) + (_.lifted "DSTORE/DLOAD" + (store_and_load ..valid_double ..$Double::literal ..$Double::wrap [/.dstore /.dload] test))))) (<| (_.context "object") (let [test (: (-> java/lang/String Any Bit) (function (_ expected actual) (|> actual (:as Text) (text\= (:as Text expected)))))] ($_ _.and - (_.lift "ASTORE_0/ALOAD_0" - (store_and_load ..$String::random ..$String::literal /.nop [(function.constant /.astore_0) (function.constant /.aload_0)] test)) - (_.lift "ASTORE_1/ALOAD_1" - (store_and_load ..$String::random ..$String::literal /.nop [(function.constant /.astore_1) (function.constant /.aload_1)] test)) - (_.lift "ASTORE_2/ALOAD_2" - (store_and_load ..$String::random ..$String::literal /.nop [(function.constant /.astore_2) (function.constant /.aload_2)] test)) - (_.lift "ASTORE_3/ALOAD_3" - (store_and_load ..$String::random ..$String::literal /.nop [(function.constant /.astore_3) (function.constant /.aload_3)] test)) - (_.lift "ASTORE/ALOAD" - (store_and_load ..$String::random ..$String::literal /.nop [/.astore /.aload] test))))) + (_.lifted "ASTORE_0/ALOAD_0" + (store_and_load ..$String::random ..$String::literal /.nop [(function.constant /.astore_0) (function.constant /.aload_0)] test)) + (_.lifted "ASTORE_1/ALOAD_1" + (store_and_load ..$String::random ..$String::literal /.nop [(function.constant /.astore_1) (function.constant /.aload_1)] test)) + (_.lifted "ASTORE_2/ALOAD_2" + (store_and_load ..$String::random ..$String::literal /.nop [(function.constant /.astore_2) (function.constant /.aload_2)] test)) + (_.lifted "ASTORE_3/ALOAD_3" + (store_and_load ..$String::random ..$String::literal /.nop [(function.constant /.astore_3) (function.constant /.aload_3)] test)) + (_.lifted "ASTORE/ALOAD" + (store_and_load ..$String::random ..$String::literal /.nop [/.astore /.aload] test))))) ))) (def: stack @@ -1237,20 +1237,20 @@ (|>> (:as Text) (text\= (:as Text expected/1))))] dummy/1 $String::random .let [single ($_ _.and - (<| (_.lift "DUP & POP") + (<| (_.lifted "DUP & POP") (..bytecode object_test) (do /.monad [_ ($String::literal expected/1) _ /.dup] /.pop)) - (<| (_.lift "DUP_X1 & POP2") + (<| (_.lifted "DUP_X1 & POP2") (..bytecode object_test) (do /.monad [_ ($String::literal dummy/1) _ ($String::literal expected/1) _ /.dup_x1] /.pop2)) - (<| (_.lift "DUP_X2") + (<| (_.lifted "DUP_X2") (..bytecode object_test) (do /.monad [_ ($String::literal dummy/1) @@ -1259,7 +1259,7 @@ _ /.dup_x2 _ /.pop2] /.pop)) - (<| (_.lift "SWAP") + (<| (_.lifted "SWAP") (..bytecode object_test) (do /.monad [_ ($String::literal dummy/1) @@ -1272,14 +1272,14 @@ (|>> (:as Int) (i.= (:as Int expected/2))))] dummy/2 $Long::random .let [double ($_ _.and - (<| (_.lift "DUP2") + (<| (_.lifted "DUP2") (..bytecode long_test) (do /.monad [_ ($Long::literal expected/2) _ /.dup2 _ /.pop2] ..$Long::wrap)) - (<| (_.lift "DUP2_X1") + (<| (_.lifted "DUP2_X1") (..bytecode long_test) (do /.monad [_ ($String::literal dummy/1) @@ -1288,7 +1288,7 @@ _ /.pop2 _ /.pop] ..$Long::wrap)) - (<| (_.lift "DUP2_X2") + (<| (_.lifted "DUP2_X2") (..bytecode long_test) (do /.monad [_ ($Long::literal dummy/2) @@ -1367,20 +1367,20 @@ false) ))))] ($_ _.and - (_.lift "IRETURN" (primitive_return ..$Integer::primitive /.ireturn #.None (!::= java/lang/Integer "jvm ieq" "jvm int ="))) - (_.lift "LRETURN" (primitive_return ..$Long::primitive /.lreturn #.None (!::= java/lang/Long "jvm leq" "jvm long ="))) - (_.lift "FRETURN" (primitive_return ..$Float::primitive /.freturn #.None (!::= java/lang/Float "jvm feq" "jvm float ="))) - (_.lift "DRETURN" (primitive_return ..$Double::primitive /.dreturn #.None (!::= java/lang/Double "jvm deq" "jvm double ="))) - (_.lift "ARETURN" (primitive_return ..$String::primitive /.areturn #.None (function (_ expected actual) (text\= (:as Text expected) (:as Text actual))))) - (_.lift "RETURN" (primitive_return (: (Primitive java/lang/String) - {#unboxed /type.void - #boxed ..$String - #wrap /.nop - #random ..$String::random - #literal (function.constant /.nop)}) - /.return - (#.Some ..$String::literal) - (function (_ expected actual) (text\= (:as Text expected) (:as Text actual))))) + (_.lifted "IRETURN" (primitive_return ..$Integer::primitive /.ireturn #.None (!::= java/lang/Integer "jvm ieq" "jvm int ="))) + (_.lifted "LRETURN" (primitive_return ..$Long::primitive /.lreturn #.None (!::= java/lang/Long "jvm leq" "jvm long ="))) + (_.lifted "FRETURN" (primitive_return ..$Float::primitive /.freturn #.None (!::= java/lang/Float "jvm feq" "jvm float ="))) + (_.lifted "DRETURN" (primitive_return ..$Double::primitive /.dreturn #.None (!::= java/lang/Double "jvm deq" "jvm double ="))) + (_.lifted "ARETURN" (primitive_return ..$String::primitive /.areturn #.None (function (_ expected actual) (text\= (:as Text expected) (:as Text actual))))) + (_.lifted "RETURN" (primitive_return (: (Primitive java/lang/String) + {#unboxed /type.void + #boxed ..$String + #wrap /.nop + #random ..$String::random + #literal (function.constant /.nop)}) + /.return + (#.Some ..$String::literal) + (function (_ expected actual) (text\= (:as Text expected) (:as Text actual))))) ))) (def: branching @@ -1403,15 +1403,15 @@ _ (/.set_label @end)] ..$Long::wrap)))) comparison_against_zero ($_ _.and - (_.lift "IFEQ" (if! /.ifeq /.iconst_0)) - (_.lift "IFNE" (if! /.ifne /.iconst_1)) - (_.lift "IFLT" (if! /.iflt /.iconst_m1)) - (_.lift "IFLE" (if! /.ifle /.iconst_0)) - (_.lift "IFGT" (if! /.ifgt /.iconst_1)) - (_.lift "IFGE" (if! /.ifge /.iconst_0))) + (_.lifted "IFEQ" (if! /.ifeq /.iconst_0)) + (_.lifted "IFNE" (if! /.ifne /.iconst_1)) + (_.lifted "IFLT" (if! /.iflt /.iconst_m1)) + (_.lifted "IFLE" (if! /.ifle /.iconst_0)) + (_.lifted "IFGT" (if! /.ifgt /.iconst_1)) + (_.lifted "IFGE" (if! /.ifge /.iconst_0))) null_test ($_ _.and - (_.lift "IFNULL" (if! /.ifnull /.aconst_null)) - (_.lift "IFNONNULL" (if! /.ifnonnull (/.string ""))))] + (_.lifted "IFNULL" (if! /.ifnull /.aconst_null)) + (_.lifted "IFNONNULL" (if! /.ifnonnull (/.string ""))))] reference ..$Integer::random subject (|> ..$Integer::random (random.only (|>> ((!::= java/lang/Integer "jvm ieq" "jvm int =") reference) not))) @@ -1423,20 +1423,20 @@ [reference subject] [subject reference]) int_comparison ($_ _.and - (_.lift "IF_ICMPEQ" (if! /.if_icmpeq (do /.monad [_ (..$Integer::literal reference)] /.dup))) - (_.lift "IF_ICMPNE" (if! /.if_icmpne (do /.monad [_ (..$Integer::literal reference)] (..$Integer::literal subject)))) - (_.lift "IF_ICMPLT" (if! /.if_icmplt (do /.monad [_ (..$Integer::literal lesser)] (..$Integer::literal greater)))) - (_.lift "IF_ICMPLE" (if! /.if_icmple (do /.monad [_ (..$Integer::literal lesser)] (..$Integer::literal greater)))) - (_.lift "IF_ICMPGT" (if! /.if_icmpgt (do /.monad [_ (..$Integer::literal greater)] (..$Integer::literal lesser)))) - (_.lift "IF_ICMPGE" (if! /.if_icmpge (do /.monad [_ (..$Integer::literal greater)] (..$Integer::literal lesser))))) + (_.lifted "IF_ICMPEQ" (if! /.if_icmpeq (do /.monad [_ (..$Integer::literal reference)] /.dup))) + (_.lifted "IF_ICMPNE" (if! /.if_icmpne (do /.monad [_ (..$Integer::literal reference)] (..$Integer::literal subject)))) + (_.lifted "IF_ICMPLT" (if! /.if_icmplt (do /.monad [_ (..$Integer::literal lesser)] (..$Integer::literal greater)))) + (_.lifted "IF_ICMPLE" (if! /.if_icmple (do /.monad [_ (..$Integer::literal lesser)] (..$Integer::literal greater)))) + (_.lifted "IF_ICMPGT" (if! /.if_icmpgt (do /.monad [_ (..$Integer::literal greater)] (..$Integer::literal lesser)))) + (_.lifted "IF_ICMPGE" (if! /.if_icmpge (do /.monad [_ (..$Integer::literal greater)] (..$Integer::literal lesser))))) new_object (: (Bytecode Any) (do /.monad [_ (/.new ..$Object) _ /.dup] (/.invokespecial ..$Object "<init>" (/type.method [(list) (list) /type.void (list)])))) reference_comparison ($_ _.and - (_.lift "IF_ACMPEQ" (if! /.if_acmpeq (do /.monad [_ new_object] /.dup))) - (_.lift "IF_ACMPNE" (if! /.if_acmpne (do /.monad [_ new_object] new_object))) + (_.lifted "IF_ACMPEQ" (if! /.if_acmpeq (do /.monad [_ new_object] /.dup))) + (_.lifted "IF_ACMPNE" (if! /.if_acmpne (do /.monad [_ new_object] new_object))) )]] ($_ _.and comparison_against_zero @@ -1466,17 +1466,17 @@ _ (/.set_label @end)] ..$Long::wrap))))]] ($_ _.and - (_.lift "GOTO" (jump /.goto)) - (_.lift "GOTO_W" (jump /.goto_w))))) + (_.lifted "GOTO" (jump /.goto)) + (_.lifted "GOTO_W" (jump /.goto_w))))) (def: switch Test ($_ _.and - (<| (_.lift "TABLESWITCH") + (<| (_.lifted "TABLESWITCH") (do {! random.monad} [expected ..$Long::random dummy ..$Long::random - minimum (\ ! map (|>> (n.% 100) .int /signed.s4 try.assumed) + minimum (\ ! map (|>> (n.% 100) .int /signed.s4 try.trusted) random.nat) afterwards (\ ! map (n.% 10) random.nat)]) (..bytecode ((!::= java/lang/Long "jvm leq" "jvm long =") expected)) @@ -1484,7 +1484,7 @@ [@right /.new_label @wrong /.new_label @return /.new_label - _ (/.bipush (|> minimum /signed.value .int /signed.s1 try.assumed)) + _ (/.bipush (|> minimum /signed.value .int /signed.s1 try.trusted)) _ (/.tableswitch minimum @wrong [@right (list.repeated afterwards @wrong)]) _ (/.set_label @wrong) _ (..$Long::literal dummy) @@ -1493,7 +1493,7 @@ _ (..$Long::literal expected) _ (/.set_label @return)] ..$Long::wrap)) - (<| (_.lift "LOOKUPSWITCH") + (<| (_.lifted "LOOKUPSWITCH") (do {! random.monad} [options (\ ! map (|>> (n.% 10) (n.+ 1)) random.nat) @@ -1502,7 +1502,7 @@ (\ ! map (|>> (:as java/lang/Long) ffi.long_to_int ffi.int_to_long (:as Int))) (random.set i.hash options) (\ ! map set.list)) - .let [choice (maybe.assume (list.item choice options))] + .let [choice (maybe.trusted (list.item choice options))] expected ..$Long::random dummy ..$Long::random]) (..bytecode ((!::= java/lang/Long "jvm leq" "jvm long =") expected)) @@ -1512,7 +1512,7 @@ @return /.new_label _ (..$Integer::literal (ffi.long_to_int (:as java/lang/Long choice))) _ (/.lookupswitch @wrong (list\map (function (_ option) - [(|> option /signed.s4 try.assumed) + [(|> option /signed.s4 try.trusted) (if (i.= choice option) @right @wrong)]) options)) _ (/.set_label @wrong) @@ -1530,7 +1530,7 @@ [expected ..$Long::random dummy ..$Long::random exception ..$String::random] - (<| (_.lift "ATHROW") + (<| (_.lifted "ATHROW") (..bytecode ((!::= java/lang/Long "jvm leq" "jvm long =") expected)) (do /.monad [.let [$Exception (/type.class "java.lang.Exception" (list))] @@ -1634,7 +1634,7 @@ (list (/method.method ($_ /modifier\compose /method.public /method.abstract) interface_method method::type (list) #.None)) (row.row)) - try.assumed + try.trusted (format.result /class.writer)) abstract_bytecode (|> (/class.class /version.v6_0 ($_ /modifier\compose /class.public /class.abstract) (/name.internal abstract_class) @@ -1654,7 +1654,7 @@ (/method.method ($_ /modifier\compose /method.public /method.abstract) abstract_method method::type (list) #.None)) (row.row)) - try.assumed + try.trusted (format.result /class.writer)) invoke (: (-> (Type Class) Text (Bytecode Any)) (function (_ class method) @@ -1701,7 +1701,7 @@ _ ..$Long::wrap] /.areturn)))) (row.row)) - try.assumed + try.trusted (format.result /class.writer)) loader (/loader.memory (/loader.new_library []))]] (_.test "Class & interface inheritance" diff --git a/stdlib/source/test/lux/test.lux b/stdlib/source/test/lux/test.lux index fe60e832c..eef7b91e7 100644 --- a/stdlib/source/test/lux/test.lux +++ b/stdlib/source/test/lux/test.lux @@ -286,12 +286,12 @@ (and (n.= 0 (get@ #/.successes failure_tally)) (n.= 1 (get@ #/.failures failure_tally)))))))) (do ! - [success_assertion (/.lift expected_message/0 (in true)) - failure_assertion (/.lift expected_message/0 (in false))] + [success_assertion (/.lifted expected_message/0 (in true)) + failure_assertion (/.lifted expected_message/0 (in false))] (in (do async.monad [[success_tally success_message] success_assertion [failure_tally failure_message] failure_assertion] - (/.cover' [/.lift] + (/.cover' [/.lifted] (and (text.contains? expected_message/0 success_message) (text.contains? expected_message/0 failure_message) (and (n.= 1 (get@ #/.successes success_tally)) diff --git a/stdlib/source/test/lux/time/year.lux b/stdlib/source/test/lux/time/year.lux index 82cdbf713..513b1b92d 100644 --- a/stdlib/source/test/lux/time/year.lux +++ b/stdlib/source/test/lux/time/year.lux @@ -79,9 +79,9 @@ (_.for [/.Period] (_.cover [/.leap /.century /.era] (n.= /.leap (n./ /.century /.era)))) - (let [leap (try.assumed (/.year (.int /.leap))) - century (try.assumed (/.year (.int /.century))) - era (try.assumed (/.year (.int /.era)))] + (let [leap (try.trusted (/.year (.int /.leap))) + century (try.trusted (/.year (.int /.century))) + era (try.trusted (/.year (.int /.era)))] ($_ _.and (_.cover [/.leap?] (and (/.leap? leap) 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 f694d0629..aa4443cdb 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 @@ -124,8 +124,8 @@ (r\map product.right _primitive.primitive) (do {! r.monad} [choice (|> r.nat (\ ! map (n.% (list.size variant_tags)))) - .let [choiceT (maybe.assume (list.item choice variant_tags)) - choiceC (maybe.assume (list.item choice primitivesC))]] + .let [choiceT (maybe.trusted (list.item choice variant_tags)) + choiceC (maybe.trusted (list.item choice primitivesC))]] (in (` ((~ choiceT) (~ choiceC))))) (do {! r.monad} [size (|> r.nat (\ ! map (n.% 3))) @@ -190,7 +190,7 @@ .let [redundant_branchesC (<| (list!map (branch outputC)) list.joined (list (list.first redundancy_idx redundant_patterns) - (list (maybe.assume (list.item redundancy_idx redundant_patterns))) + (list (maybe.trusted (list.item redundancy_idx redundant_patterns))) (list.after redundancy_idx redundant_patterns)))]] (_.test "Will reject redundant pattern-matching." (|> (analyse_pm redundant_branchesC) @@ -200,7 +200,7 @@ _primitive.primitive) heterogeneous_idx (|> r.nat (\ ! map (n.% (list.size exhaustive_patterns)))) .let [heterogeneous_branchesC (list.joined (list (list.first heterogeneous_idx exhaustive_branchesC) - (list (let [[_pattern _body] (maybe.assume (list.item heterogeneous_idx exhaustive_branchesC))] + (list (let [[_pattern _body] (maybe.trusted (list.item heterogeneous_idx exhaustive_branchesC))] [_pattern heterogeneousC])) (list.after (inc heterogeneous_idx) exhaustive_branchesC)))]] (_.test "Will reject pattern-matching if the bodies of the branches do not all have the same type." 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 b0027b15d..42b1e366c 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 @@ -96,7 +96,7 @@ (list varT) (list.after (inc var_idx) inputsT)))) varT) - poly_inputT (maybe.assume (list.item var_idx inputsT)) + poly_inputT (maybe.trusted (list.item var_idx inputsT)) partial_poly_inputsT (list.after (inc var_idx) inputsT) partial_polyT1 (<| (type.function partial_poly_inputsT) poly_inputT) diff --git a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux index bc4890efe..d27b85baf 100644 --- a/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux +++ b/stdlib/source/test/lux/tool/compiler/language/lux/phase/analysis/structure.lux @@ -124,12 +124,12 @@ +choice (|> r.nat (\ ! map (n.% (inc size)))) [_ +valueC] _primitive.primitive .let [variantT (type.variant (list\map product.left primitives)) - [valueT valueC] (maybe.assume (list.item choice primitives)) + [valueT valueC] (maybe.trusted (list.item choice primitives)) +size (inc size) +primitives (list.joined (list (list.first choice primitives) (list [(#.Parameter 1) +valueC]) (list.after choice primitives))) - [+valueT +valueC] (maybe.assume (list.item +choice +primitives)) + [+valueT +valueC] (maybe.trusted (list.item +choice +primitives)) +variantT (type.variant (list\map product.left +primitives))]] (<| (_.context (%.name (name_of /.sum))) ($_ _.and @@ -175,7 +175,7 @@ choice (|> r.nat (\ ! map (n.% size))) [_ +valueC] _primitive.primitive .let [tupleT (type.tuple (list\map product.left primitives)) - [singletonT singletonC] (|> primitives (list.item choice) maybe.assume) + [singletonT singletonC] (|> primitives (list.item choice) maybe.trusted) +primitives (list.joined (list (list.first choice primitives) (list [(#.Parameter 1) +valueC]) (list.after choice primitives))) @@ -240,15 +240,15 @@ .let [with_name (|>> (#.Named [module_name type_name])) varT (#.Parameter 1) primitivesT (list\map product.left primitives) - [choiceT choiceC] (maybe.assume (list.item choice primitives)) - [other_choiceT other_choiceC] (maybe.assume (list.item other_choice primitives)) + [choiceT choiceC] (maybe.trusted (list.item choice primitives)) + [other_choiceT other_choiceC] (maybe.trusted (list.item other_choice primitives)) monoT (type.variant primitivesT) polyT (|> (type.variant (list.joined (list (list.first choice primitivesT) (list varT) (list.after (inc choice) primitivesT)))) (type.univ_q 1)) - choice_tag (maybe.assume (list.item choice tags)) - other_choice_tag (maybe.assume (list.item other_choice tags))]] + choice_tag (maybe.trusted (list.item choice tags)) + other_choice_tag (maybe.trusted (list.item other_choice tags))]] (<| (_.context (%.name (name_of /.tagged_sum))) ($_ _.and (_.test "Can infer." diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux index 078aef4e2..8c135b590 100644 --- a/stdlib/source/test/lux/type.lux +++ b/stdlib/source/test/lux/type.lux @@ -28,6 +28,7 @@ ["#." check] ["#." dynamic] ["#." implicit] + ["#." poly] ["#." quotient] ["#." refinement] ["#." resource] @@ -207,10 +208,10 @@ [left random.nat right (random.ascii/lower 1) .let [left,right [left right]]] - (_.cover [/.:cast] + (_.cover [/.:as] (|> left,right - (/.:cast [l r] (And l r) (Or l r)) - (/.:cast [l r] (Or l r) (And l r)) + (/.:as [l r] (And l r) (Or l r)) + (/.:as [l r] (Or l r) (And l r)) (same? left,right)))) (do random.monad [expected random.nat] @@ -239,6 +240,7 @@ /check.test /dynamic.test /implicit.test + /poly.test /quotient.test /refinement.test /resource.test diff --git a/stdlib/source/test/lux/macro/poly.lux b/stdlib/source/test/lux/type/poly.lux index 1ffe2cf61..1ffe2cf61 100644 --- a/stdlib/source/test/lux/macro/poly.lux +++ b/stdlib/source/test/lux/type/poly.lux diff --git a/stdlib/source/test/lux/macro/poly/equivalence.lux b/stdlib/source/test/lux/type/poly/equivalence.lux index 6de4e4019..14c763226 100644 --- a/stdlib/source/test/lux/macro/poly/equivalence.lux +++ b/stdlib/source/test/lux/type/poly/equivalence.lux @@ -1,7 +1,6 @@ (.module: [library [lux (#- Variant) - ["%" data/text/format (#+ format)] ["_" test (#+ Test)] [abstract [monad (#+ do)] @@ -17,13 +16,13 @@ ["." text] [collection ["." list]]] - [macro - [poly (#+ derived:)]] [math ["." random (#+ Random)] [number ["n" nat] - ["i" int]]]]]) + ["i" int]]] + [type + [poly (#+ derived:)]]]]) (type: Variant (#Case0 Bit) diff --git a/stdlib/source/test/lux/macro/poly/functor.lux b/stdlib/source/test/lux/type/poly/functor.lux index b98541232..da5b00391 100644 --- a/stdlib/source/test/lux/macro/poly/functor.lux +++ b/stdlib/source/test/lux/type/poly/functor.lux @@ -1,7 +1,6 @@ (.module: [library [lux #* - ["%" data/text/format (#+ format)] [abstract [monad (#+ do)] [functor @@ -13,7 +12,7 @@ ["." state]] [data ["." identity]] - [macro + [type [poly (#+ derived:)]]]]) (derived: maybe_functor (/.functor .Maybe)) diff --git a/stdlib/source/test/lux/macro/poly/json.lux b/stdlib/source/test/lux/type/poly/json.lux index d99b3364e..16a466ed5 100644 --- a/stdlib/source/test/lux/macro/poly/json.lux +++ b/stdlib/source/test/lux/type/poly/json.lux @@ -19,8 +19,7 @@ [json (#+)]]] [data ["." bit] - ["." text - ["%" format (#+ format)]] + ["." text] [format [json (#+) [\\poly @@ -29,9 +28,8 @@ [row (#+ row)] ["d" dictionary] ["." list]]] - [macro - [poly (#+ derived:)]] [type + [poly (#+ derived:)] ["." unit]] [math ["." random (#+ Random)] diff --git a/stdlib/source/test/lux/type/refinement.lux b/stdlib/source/test/lux/type/refinement.lux index 64a0b60bd..cf69e9243 100644 --- a/stdlib/source/test/lux/type/refinement.lux +++ b/stdlib/source/test/lux/type/refinement.lux @@ -53,14 +53,14 @@ (|> (/.refiner predicate modulus) (maybe\map (|>> /.value (n.= modulus))) (maybe.else false))) - (_.cover [/.lift] + (_.cover [/.lifted] (and (|> (/.refiner predicate modulus) - (maybe\map (/.lift (n.+ modulus))) + (maybe\map (/.lifted (n.+ modulus))) maybe\join (maybe\map (|>> /.value (n.= (n.+ modulus modulus)))) (maybe.else false)) (|> (/.refiner predicate modulus) - (maybe\map (/.lift (n.+ (inc modulus)))) + (maybe\map (/.lifted (n.+ (inc modulus)))) maybe\join (maybe\map (|>> /.value (n.= (n.+ modulus (inc modulus))))) (maybe.else false) diff --git a/stdlib/source/test/lux/world/input/keyboard.lux b/stdlib/source/test/lux/world/input/keyboard.lux index 0060dc9a4..67ce892fe 100644 --- a/stdlib/source/test/lux/world/input/keyboard.lux +++ b/stdlib/source/test/lux/world/input/keyboard.lux @@ -141,7 +141,7 @@ (let [count (list.size ..listing)] (do {! random.monad} [choice (\ ! map (n.% count) random.nat)] - (in (maybe.assume (list.item choice ..listing)))))) + (in (maybe.trusted (list.item choice ..listing)))))) (def: .public test Test diff --git a/stdlib/source/test/lux/world/output/video/resolution.lux b/stdlib/source/test/lux/world/output/video/resolution.lux index 543dcb3f7..b6b18505a 100644 --- a/stdlib/source/test/lux/world/output/video/resolution.lux +++ b/stdlib/source/test/lux/world/output/video/resolution.lux @@ -48,7 +48,7 @@ (let [count (list.size ..listing)] (do {! random.monad} [choice (\ ! map (n.% count) random.nat)] - (in (maybe.assume (list.item choice ..listing)))))) + (in (maybe.trusted (list.item choice ..listing)))))) (def: .public test Test |