Skip to content

Commit

Permalink
Added = aliases for most equivalences.
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Sep 4, 2023
1 parent ad2bd2a commit 1bead83
Show file tree
Hide file tree
Showing 432 changed files with 2,448 additions and 2,157 deletions.
2 changes: 1 addition & 1 deletion lux-r/source/program.lux
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@

(the %%code
(syntax.macro (_ [term <code>.any])
(wrap (list (code.text (%.code term))))))
(wrap (list (code.text (code.as_text term))))))

(the (host_value value)
(-> Any org/renjin/sexp/SEXP)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/source/documentation/lux.lux
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@
... \n "Useful in situations where the result of a branch depends on further refinements on the values being matched.")
... ($.example (' (when (split (size static) uri)
... (^multi {#Some [chunk uri']}
... [(text#= static chunk) .true])
... [(text.= static chunk) .true])
... (match_uri endpoint? parts' uri')

... _
Expand All @@ -760,7 +760,7 @@
... ($.comment "The example above can be rewritten as...")
... ($.example (' (when (split (size static) uri)
... (^multi {#Some [chunk uri']}
... (text#= static chunk))
... (text.= static chunk))
... (match_uri endpoint? parts' uri')

... _
Expand Down
11 changes: 6 additions & 5 deletions stdlib/source/documentation/lux/meta/static.lux
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[collection
["[0]" list]]]
[meta
["[0]" code]
[macro
["[0]" template]]]]]
[\\library
Expand All @@ -20,9 +21,9 @@
(List $.Documentation)
(let [literal (list (,, (template.with [<name> <type>]
[($.definition <name>
(%.code (' (<name>
(is <type>
(value generating expression))))))]
(code.as_text (' (<name>
(is <type>
(value generating expression))))))]

[/.nat .Nat]
[/.int .Int]
Expand All @@ -40,8 +41,8 @@
(value generating expression)))))))
random (list (,, (template.with [<name> <type>]
[($.definition <name>
(%.code (' (is <type>
(<name>)))))]
(code.as_text (' (is <type>
(<name>)))))]

[/.random_nat .Nat]
[/.random_int .Int]
Expand Down
4 changes: 2 additions & 2 deletions stdlib/source/experiment/tool/interpreter.lux
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
["[0]" try (.only Try)]
["ex" exception (.only Exception)]]
[data
["[0]" text (.use "[1]#[0]" equivalence)
["[0]" text (.only)
["%" \\injection]]]
[type (.only sharing)
["[0]" check]]
Expand Down Expand Up @@ -210,7 +210,7 @@
(of Console<!> write "> "))
line (of Console<!> read_line)]
(if (and (not multi_line?)
(text#= ..exit_command line))
(text.= ..exit_command line))
(of Console<!> write ..farewell_message)
(when (read_eval_print (revised #source (add_line line) context))
{try.#Success [context' representation]}
Expand Down
33 changes: 21 additions & 12 deletions stdlib/source/injection/lux/data/binary.lux
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
[lux (.except and or nat int rev list symbol type)
[ffi (.only)]
[abstract
[monoid (.only Monoid)]
[monad (.only Monad do)]
[equivalence (.only Equivalence)]]
[monoid (.only Monoid)]]
[control
["<>" projection (.use "[1]#[0]" monad)]
["[0]" pipe]
["|" pipe]
["[0]" function]]
[data
["[0]" product]
Expand Down Expand Up @@ -52,7 +49,8 @@
(the mask
(-> Size
(I64 Any))
(|>> (n#* i64.bits_per_byte) i64.mask))
(|>> (n#* i64.bits_per_byte)
i64.mask))

(.every .public Mutation
(-> [Offset Binary]
Expand All @@ -68,7 +66,11 @@
(the .public (instance [size mutation])
(-> Specification
Binary)
(|> size \\unsafe.empty [0] mutation product.right))
(|> size
\\unsafe.empty
[0]
mutation
product.right))

(the .public monoid
(Monoid Specification)
Expand Down Expand Up @@ -145,7 +147,7 @@

(the .public bit
(Injection Bit)
(|>> (pipe.when #0 0 #1 1) ..bits_8))
(|>> (|.when #0 0 #1 1) ..bits_8))

(template.with [<name> <type>]
[(the .public <name>
Expand Down Expand Up @@ -180,7 +182,9 @@
(Injection Binary)
(let [mask (..mask <size>)]
(function (_ value)
(let [size (|> value \\unsafe.size (i64.and mask))
(let [size (|> value
\\unsafe.size
(i64.and mask))
size' (n#+ <size> size)]
[size'
(function (_ [offset binary])
Expand All @@ -198,7 +202,8 @@
(template.with [<name> <binary>]
[(the .public <name>
(Injection Text)
(|>> (of utf8.format injection) <binary>))]
(|>> (of utf8.format injection)
<binary>))]

[utf8_8 ..binary_8]
[utf8_16 ..binary_16]
Expand All @@ -219,7 +224,10 @@
original_count)
value (if (n#= original_count capped_count)
value
(|> value sequence.list (list.first capped_count) sequence.of_list))
(|> value
sequence.list
(list.first capped_count)
sequence.of_list))
(open "specification#[0]") ..monoid
specification/* (sequence#each valueW value)
size (|> specification/*
Expand Down Expand Up @@ -261,7 +269,8 @@
(for_any (_ of)
(-> (Injection of)
(Injection (Set of))))
(|>> set.list (..list value)))
(|>> set.list
(..list value)))

(the .public symbol
(Injection Symbol)
Expand Down
17 changes: 2 additions & 15 deletions stdlib/source/injection/lux/data/text.lux
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,11 @@
["[0]" nat]
["[0]" int]
["[0]" rev]
["[0]" dec]
["[0]" frac]
["[0]" complex]]
["[0]" dec]]
[arithmetic
["[0]" modular]]]
[meta
["[0]" location]
["[0]" symbol]
["[0]" type]
["[0]" code (.only)
["[0]" code
["<[1]>" \\projection]]
[macro
["[0]" syntax]
Expand All @@ -50,14 +45,6 @@
[rev Rev (of rev.decimal injection)]
[dec Dec (of dec.decimal injection)]
[text Text text.injection]

[frac frac.Frac (of frac.format injection)]
[complex complex.Complex complex.injection]

[symbol Symbol (of symbol.absolute injection)]
[location Location location.injection]
[code Code code.absolute]
[type Type type.absolute_injection]
)

(template.with [<name>]
Expand Down
3 changes: 3 additions & 0 deletions stdlib/source/library/lux/abstract/interval.lux
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@
(and (,#= ,#bottom (of actual bottom))
(,#= ,#top (of actual top)))))))

(alias [=]
..equivalence)

(the .public (nested? reference it)
(for_any (_ of)
(-> (Interval of)
Expand Down
19 changes: 10 additions & 9 deletions stdlib/source/library/lux/control/aspect.lux
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
["[0]" function (.only)
[predicate (.only Predicate)]]]
[data
["[0]" text (.use "[1]#[0]" equivalence)
["[0]" text (.only)
["%" \\injection]]
[collection
["[0]" list (.use "[1]#[0]" mix)
Expand All @@ -24,6 +24,7 @@
[extension (.only analysis declaration)]
["[0]" binding]
["[0]" module]
["[0]" symbol]
["[0]" code (.only)
["?[1]" \\projection]]
["[0]" macro (.only)
Expand Down Expand Up @@ -143,21 +144,21 @@
(when it
{.#Definition [type value]}
(if (or exported?
(text#= current_module_name normal_module))
(text.= current_module_name normal_module))
(in [exported? it])
(meta.failure (%.message "Global is not an export: " (%.symbol name))))
(meta.failure (%.message "Global is not an export: " (symbol.as_text name))))

{.#Default [type value]}
(if (or exported?
(text#= current_module_name normal_module))
(text.= current_module_name normal_module))
(in [exported? it])
(meta.failure (%.message "Global is not an export: " (%.symbol name))))
(meta.failure (%.message "Global is not an export: " (symbol.as_text name))))

{.#Alias de_aliased}
(again de_aliased))

{.#None it}
(meta.failure (%.message "Unknown global: " (%.symbol name)))))))
(meta.failure (%.message "Unknown global: " (symbol.as_text name)))))))

(the (with_cached_analysis name then)
(for_any (_ of)
Expand All @@ -166,7 +167,7 @@
(do phase.monad
['cache (macro.symbol "'cache")
[exported? global] (global_reference name)
.let [cache_name (%.code 'cache)]
.let [cache_name (code.as_text 'cache)]
_ (moduleA.define cache_name [exported? global])
it (then ['cache global])
[current_module_name _] module.current
Expand All @@ -182,7 +183,7 @@
(macro.symbol "'cache"))
[exported? global] (declaration.of_analysis
(global_reference name))
.let [cache_name (%.code 'cache)]
.let [cache_name (code.as_text 'cache)]
_ (declaration.of_analysis
(moduleA.define cache_name [exported? global]))
it (then ['cache global])
Expand Down Expand Up @@ -232,7 +233,7 @@
(analysis.Operation of))))
(do phase.monad
['cache (macro.symbol "'cache")
.let [cache_name (%.code 'cache)]
.let [cache_name (code.as_text 'cache)]
_ (moduleA.define cache_name [false {.#Definition [Analysis (expression type term)]}])
it (then 'cache)
[current_module_name _] module.current
Expand Down
8 changes: 4 additions & 4 deletions stdlib/source/library/lux/control/function/contract.lux
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@
[number
["i" int]]]
[meta
["[0]" code (.only)
["<[1]>" \\projection]]
[macro (.only with_symbols)
["[0]" syntax]
["[0]" template]]
["[0]" code (.only)
["<[1]>" \\projection]]]]])
["[0]" template]]]]])

(template.with [<name>]
[(exception.the .public (<name> condition)
(Exception Code)
(exception.report
(list ["Condition" (%.code condition)])))]
(list ["Condition" (code.as_text condition)])))]

[pre_condition_failed]
[post_condition_failed]
Expand Down
5 changes: 3 additions & 2 deletions stdlib/source/library/lux/control/function/named.lux
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
[number
["n" nat]]]
["[0]" meta (.only)
["[0]" symbol]
["[0]" module]
["[0]" code (.only)
["?[1]" \\projection]]
Expand All @@ -33,13 +34,13 @@
(exception.the .public (duplicate_parameters [definition parameters])
(Exception [Symbol (List Text)])
(exception.report
(list ["Definition" (%.symbol definition)]
(list ["Definition" (symbol.as_text definition)]
["Parameters" (%.list %.text parameters)])))

(exception.the .public (invalid_parameters [definition expected actual])
(Exception [Symbol (List Text) (List Text)])
(exception.report
(list ["Definition" (%.symbol definition)]
(list ["Definition" (symbol.as_text definition)]
["Expected" (%.list %.text expected)]
["Actual" (%.list %.text actual)])))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
["[0]" predicate (.only Predicate)]]]
[data
["[0]" product]
["[0]" text (.use "[1]#[0]" equivalence)]
["[0]" text]
[collection
["[0]" set (.only Set)]
["[0]" list (.use "[1]#[0]" functor)]]]
Expand Down Expand Up @@ -185,7 +185,7 @@
(do [! meta.monad]
[.let [criterion (is (Predicate Polymorphism)
(|>> (its #function)
(text#= (its #name signature))))]
(text.= (its #name signature))))]
it (context.search criterion ..stack)]
(with_symbols [g!self g!predicate g!parameters g!context g!_ g!next g!again]
(do !
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
["?" projection (.use "[1]#[0]" monad)]]
[data
["[0]" product]
["[0]" text (.use "[1]#[0]" equivalence)]
["[0]" text]
[collection
["[0]" list (.use "[1]#[0]" functor)]]]
["[0]" meta (.only)
Expand Down Expand Up @@ -123,7 +123,7 @@
(do [! meta.monad]
[.let [criterion (is (-> Polymorphism Bit)
(|>> (its #function)
(text#= (its #name signature))))]
(text.= (its #name signature))))]
it (context.search criterion ..stack)]
(with_symbols [g!self]
(do !
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[control
["?" projection (.use "[1]#[0]" monad)]]
[data
["[0]" text (.use "[1]#[0]" equivalence)]
["[0]" text]
[collection
["[0]" list (.use "[1]#[0]" functor)]]]
["[0]" meta (.only)
Expand Down Expand Up @@ -75,7 +75,7 @@
(?code.tuple (?.many ?code.any))
?code.any)])
(do meta.monad
[it (context.search (|>> (its #name) (text#= name)) ..stack)
[it (context.search (|>> (its #name) (text.= name)) ..stack)
.let [name (code.local name)]]
(with_symbols ['self]
(in (list (` (.the (, (its #export_policy it)) (, 'self)
Expand Down
Loading

0 comments on commit 1bead83

Please sign in to comment.