aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/format/lux/data/text.lux4
-rw-r--r--stdlib/source/library/lux/data/format/xml.lux2
-rw-r--r--stdlib/source/library/lux/ffi.old.lux4
-rw-r--r--stdlib/source/library/lux/math/arithmetic/fixed_point.lux1
-rw-r--r--stdlib/source/library/lux/meta.lux118
-rw-r--r--stdlib/source/library/lux/meta/code.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux6
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux11
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux6
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux (renamed from stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/structure.lux)58
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/primitive.lux4
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux6
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux5
-rw-r--r--stdlib/source/library/lux/meta/compiler/target/jvm/bytecode.lux18
-rw-r--r--stdlib/source/library/lux/meta/macro.lux2
-rw-r--r--stdlib/source/library/lux/meta/macro/context.lux2
-rw-r--r--stdlib/source/library/lux/meta/macro/expansion.lux2
-rw-r--r--stdlib/source/library/lux/meta/macro/vocabulary.lux4
-rw-r--r--stdlib/source/library/lux/meta/symbol.lux4
-rw-r--r--stdlib/source/library/lux/meta/type.lux102
-rw-r--r--stdlib/source/library/lux/meta/type/check.lux12
-rw-r--r--stdlib/source/library/lux/meta/type/nominal.lux2
-rw-r--r--stdlib/source/parser/lux/data/format/xml.lux2
-rw-r--r--stdlib/source/polytypic/lux/data/format/json.lux4
-rw-r--r--stdlib/source/test/lux/data/text.lux4
-rw-r--r--stdlib/source/test/lux/meta.lux49
-rw-r--r--stdlib/source/test/lux/meta/compiler/language/lux/phase.lux4
-rw-r--r--stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux135
-rw-r--r--stdlib/source/test/lux/meta/compiler/target/jvm.lux8
-rw-r--r--stdlib/source/test/lux/meta/symbol.lux8
-rw-r--r--stdlib/source/test/lux/meta/type.lux4
-rw-r--r--stdlib/source/test/lux/world/file.lux7
32 files changed, 413 insertions, 187 deletions
diff --git a/stdlib/source/format/lux/data/text.lux b/stdlib/source/format/lux/data/text.lux
index 512ada54f..d998310ae 100644
--- a/stdlib/source/format/lux/data/text.lux
+++ b/stdlib/source/format/lux/data/text.lux
@@ -71,10 +71,10 @@
[text Text text.format]
[ratio ratio.Ratio (of ratio.codec encoded)]
- [symbol Symbol (of symbol.codec encoded)]
+ [symbol Symbol (of symbol.absolute encoded)]
[location Location location.format]
[code Code code.format]
- [type Type type.format]
+ [type Type type.absolute_format]
[instant instant.Instant (of instant.codec encoded)]
[duration duration.Duration (of duration.codec encoded)]
diff --git a/stdlib/source/library/lux/data/format/xml.lux b/stdlib/source/library/lux/data/format/xml.lux
index 3a63629a9..b704a4cfc 100644
--- a/stdlib/source/library/lux/data/format/xml.lux
+++ b/stdlib/source/library/lux/data/format/xml.lux
@@ -23,7 +23,7 @@
["n" nat]
["[0]" int]]]
[meta
- ["[0]" symbol (.use "[1]#[0]" equivalence codec)]]]])
+ ["[0]" symbol (.use "[1]#[0]" equivalence absolute)]]]])
(type .public Tag
Symbol)
diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux
index fa6dea601..7fec7dba4 100644
--- a/stdlib/source/library/lux/ffi.old.lux
+++ b/stdlib/source/library/lux/ffi.old.lux
@@ -1679,7 +1679,7 @@
{.#Apply A F}
(when (type.applied (list A) F)
{.#None}
- (meta.failure (format "Cannot apply type: " (type.format F) " to " (type.format A)))
+ (meta.failure (format "Cannot apply type: " (%.type F) " to " (%.type A)))
{.#Some type'}
(type_class_name type'))
@@ -1688,7 +1688,7 @@
(type_class_name type')
_
- (meta.failure (format "Cannot convert to JvmType: " (type.format type))))))
+ (meta.failure (format "Cannot convert to JvmType: " (%.type type))))))
(def .public read!
(syntax (_ [idx <code>.any
diff --git a/stdlib/source/library/lux/math/arithmetic/fixed_point.lux b/stdlib/source/library/lux/math/arithmetic/fixed_point.lux
index e6ac5834b..4498bce85 100644
--- a/stdlib/source/library/lux/math/arithmetic/fixed_point.lux
+++ b/stdlib/source/library/lux/math/arithmetic/fixed_point.lux
@@ -112,6 +112,7 @@
Rev))
(|>> nominal.representation
(i64.and (i64.mask (nominal.representation Point @)))
+ (i64.left_shifted (n.- (nominal.representation Point @) i64.width))
.rev))
(with_template [<composite_type> <post_processing> <fp> <int>]
diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux
index d581c3a7e..3a45da32d 100644
--- a/stdlib/source/library/lux/meta.lux
+++ b/stdlib/source/library/lux/meta.lux
@@ -23,7 +23,7 @@
["i" int]]]]]
[/
["[0]" location]
- ["[0]" symbol (.use "[1]#[0]" codec equivalence)]
+ ["[0]" symbol (.use "[1]#[0]" absolute equivalence)]
["[0]" code]])
... (.type (Meta a)
@@ -79,11 +79,15 @@
{try.#Failure msg})))))
(def .public (result' lux action)
- (All (_ a) (-> Lux (Meta a) (Try [Lux a])))
+ (All (_ of)
+ (-> Lux (Meta of)
+ (Try [Lux of])))
(action lux))
(def .public (result lux action)
- (All (_ a) (-> Lux (Meta a) (Try a)))
+ (All (_ of)
+ (-> Lux (Meta of)
+ (Try of)))
(when (action lux)
{try.#Success [_ output]}
{try.#Success output}
@@ -92,7 +96,9 @@
{try.#Failure error}))
(def .public (either left right)
- (All (_ a) (-> (Meta a) (Meta a) (Meta a)))
+ (All (_ of)
+ (-> (Meta of) (Meta of)
+ (Meta of)))
(function (_ lux)
(when (left lux)
{try.#Success [lux' output]}
@@ -102,20 +108,23 @@
(right lux))))
(def .public (assertion message test)
- (-> Text Bit (Meta Any))
+ (-> Text Bit
+ (Meta Any))
(function (_ lux)
(if test
{try.#Success [lux []]}
{try.#Failure message})))
(def .public (failure error)
- (All (_ a)
- (-> Text (Meta a)))
+ (All (_ of)
+ (-> Text
+ (Meta of)))
(function (_ state)
{try.#Failure (location.with (the .#location state) error)}))
(def .public (module name)
- (-> Text (Meta Module))
+ (-> Text
+ (Meta Module))
(function (_ lux)
(when (property.value name (the .#modules lux))
{.#Some module}
@@ -142,7 +151,8 @@
/#conjoint)))
(def (macro_type? type)
- (-> Type Bit)
+ (-> Type
+ Bit)
(when type
{.#Named [.prelude "Macro"]
{.#Nominal "#Macro" {.#End}}}
@@ -152,7 +162,8 @@
false))
(def .public (normal name)
- (-> Symbol (Meta Symbol))
+ (-> Symbol
+ (Meta Symbol))
(when name
["" name]
(do ..monad
@@ -163,7 +174,8 @@
(of ..monad in name)))
(def .public (macro full_name)
- (-> Symbol (Meta (Maybe Macro)))
+ (-> Symbol
+ (Meta (Maybe Macro)))
(do ..monad
[[module name] (..normal full_name)]
(is (Meta (Maybe Macro))
@@ -203,7 +215,8 @@
(the .#seed lux)]}))
(def .public (module_exists? module)
- (-> Text (Meta Bit))
+ (-> Text
+ (Meta Bit))
(function (_ lux)
{try.#Success [lux (when (property.value module (the .#modules lux))
{.#Some _}
@@ -213,14 +226,19 @@
false)]}))
(def (on_either f x1 x2)
- (All (_ a b)
- (-> (-> a (Maybe b)) a a (Maybe b)))
+ (All (_ input output)
+ (-> (-> input (Maybe output)) input input
+ (Maybe output)))
(when (f x1)
- {.#None} (f x2)
- {.#Some y} {.#Some y}))
+ {.#None}
+ (f x2)
+
+ some
+ some))
(def (type_variable idx bindings)
- (-> Nat (List [Nat (Maybe Type)]) (Maybe Type))
+ (-> Nat (List [Nat (Maybe Type)])
+ (Maybe Type))
(when bindings
{.#End}
{.#None}
@@ -231,7 +249,8 @@
(type_variable idx bindings'))))
(`` (def (clean_type type)
- (-> Type (Meta Type))
+ (-> Type
+ (Meta Type))
(when type
{.#Var var}
(function (_ lux)
@@ -253,7 +272,8 @@
(of ..monad in type))))
(def .public (var_type name)
- (-> Text (Meta Type))
+ (-> Text
+ (Meta Type))
(function (_ lux)
(let [test (is (-> [Text [Type Any]] Bit)
(|>> product.left (text#= name)))]
@@ -277,7 +297,8 @@
{try.#Failure (all text#composite "Unknown variable: " name)}))))
(def without_lux_runtime
- (-> (List Text) (List Text))
+ (-> (List Text)
+ (List Text))
... The Lux runtime shows up as ""
... so I'm excluding it.
(list.only (|>> text.empty? not)))
@@ -287,14 +308,16 @@
(all text#composite text.new_line " "))
(def module_listing
- (-> (List Text) Text)
+ (-> (List Text)
+ Text)
(|>> ..without_lux_runtime
(list.sorted text#<)
(text.interposed ..listing_separator)))
(with_template [<name> <yes>]
[(def .public (<name> name)
- (-> Symbol (Meta [Bit Global]))
+ (-> Symbol
+ (Meta [Bit Global]))
(do ..monad
[name (..normal name)
.let [[normal_module normal_short] name]]
@@ -360,7 +383,8 @@
)
(def .public (export name)
- (-> Symbol (Meta Definition))
+ (-> Symbol
+ (Meta Definition))
(do [! ..monad]
[name (..normal name)
.let [[expected _] name]
@@ -385,7 +409,8 @@
(symbol#encoded name))))))
(def .public (default name)
- (-> Symbol (Meta Default))
+ (-> Symbol
+ (Meta Default))
(do [! ..monad]
[name (..normal name)
[exported? definition] (..default' name)]
@@ -439,7 +464,8 @@
)
(def .public (definition_type name)
- (-> Symbol (Meta Type))
+ (-> Symbol
+ (Meta Type))
(do ..monad
[[exported? definition] (definition name)]
(when definition
@@ -455,7 +481,8 @@
(symbol#encoded name))))))
(def .public (type name)
- (-> Symbol (Meta Type))
+ (-> Symbol
+ (Meta Type))
(when name
["" _name]
(either (var_type _name)
@@ -465,7 +492,8 @@
(definition_type name)))
(def .public (type_definition name)
- (-> Symbol (Meta Type))
+ (-> Symbol
+ (Meta Type))
(do ..monad
[[exported? definition] (definition name)]
(when definition
@@ -485,7 +513,8 @@
(..failure (all text#composite "Default is not a type: " (symbol#encoded name))))))
(def .public (globals module)
- (-> Text (Meta (List [Text [Bit Global]])))
+ (-> Text
+ (Meta (List [Text [Bit Global]])))
(function (_ lux)
(when (property.value module (the .#modules lux))
{.#Some module}
@@ -495,7 +524,8 @@
{try.#Failure (all text#composite "Unknown module: " module)})))
(def .public (definitions module)
- (-> Text (Meta (List [Text [Bit Definition]])))
+ (-> Text
+ (Meta (List [Text [Bit Definition]])))
(of ..monad each
(list.all (function (_ [name [exported? global]])
(when global
@@ -510,7 +540,8 @@
(..globals module)))
(def .public (resolved_globals module)
- (-> Text (Meta (List [Text [Bit Definition]])))
+ (-> Text
+ (Meta (List [Text [Bit Definition]])))
(do [! ..monad]
[it (..globals module)
.let [input (is (List [Text Bit (Either Symbol Definition)])
@@ -563,7 +594,8 @@
{try.#Failure error})))))))
(def .public (exports module_name)
- (-> Text (Meta (List [Text Definition])))
+ (-> Text
+ (Meta (List [Text Definition])))
(do ..monad
[constants (..definitions module_name)]
(in (do list.monad
@@ -587,7 +619,8 @@
(`` (.in_module# (,, (static .prelude)) .type#encoded)))
(def .public (tags_of type_name)
- (-> Symbol (Meta (Maybe (List Symbol))))
+ (-> Symbol
+ (Meta (Maybe (List Symbol))))
(do ..monad
[.let [[module_name name] type_name]
module (..module module_name)]
@@ -631,26 +664,30 @@
{try.#Failure "Not expecting any type."})))
(def .public (imported_modules module_name)
- (-> Text (Meta (List Text)))
+ (-> Text
+ (Meta (List Text)))
(do ..monad
[(open "_[0]") (..module module_name)]
(in _#imports)))
(def .public (imported_by? import module)
- (-> Text Text (Meta Bit))
+ (-> Text Text
+ (Meta Bit))
(do ..monad
[(open "_[0]") (..module module)]
(in (list.any? (text#= import) _#imports))))
(def .public (imported? import)
- (-> Text (Meta Bit))
+ (-> Text
+ (Meta Bit))
(of ..functor each
(|>> (the .#imports) (list.any? (text#= import)))
..current_module))
(with_template [<name> <description> <type>]
[(def .public (<name> label_name)
- (-> Symbol (Meta Label))
+ (-> Symbol
+ (Meta Label))
(do ..monad
[.let [[module name] label_name]
=module (..module module)
@@ -673,7 +710,8 @@
)
(def .public (tag_lists module)
- (-> Text (Meta (List [(List Symbol) Type])))
+ (-> Text
+ (Meta (List [(List Symbol) Type])))
(do ..monad
[=module (..module module)
this_module_name ..current_module_name]
@@ -719,7 +757,8 @@
{try.#Failure "No local environment"})))
(def .public (de_aliased def_name)
- (-> Symbol (Meta Symbol))
+ (-> Symbol
+ (Meta Symbol))
(do ..monad
[[exported? constant] (..definition def_name)]
(in (when constant
@@ -744,7 +783,8 @@
(..failure error)))
(def .public (eval type code)
- (-> Type Code (Meta Any))
+ (-> Type Code
+ (Meta Any))
(do [! ..monad]
[eval (of ! each (the .#eval)
..compiler_state)]
diff --git a/stdlib/source/library/lux/meta/code.lux b/stdlib/source/library/lux/meta/code.lux
index 480ea56c9..9065e8232 100644
--- a/stdlib/source/library/lux/meta/code.lux
+++ b/stdlib/source/library/lux/meta/code.lux
@@ -101,7 +101,7 @@
[.#Int int.decimal]
[.#Rev rev.decimal]
[.#Frac frac.decimal]
- [.#Symbol symbol.codec]))
+ [.#Symbol symbol.absolute]))
[_ {.#Text value}]
(text.format value)
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux
index d71d0b0c6..acb4a676e 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux
@@ -1,10 +1,10 @@
+... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
(.require
[library
[lux (.except Tag Analysis)
[abstract
-... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
-... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
-
["[0]" monad (.only do)]]
[control
["[0]" maybe]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux
index 2fffba00c..1a8b75275 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux
@@ -16,7 +16,7 @@
["[0]" binary]
["[0]" product]
["[0]" text
- ["%" \\format (.only format)]]
+ ["%" \\format]]
[collection
["[0]" dictionary]
["[0]" array]
@@ -192,11 +192,12 @@
(in [])))]
(in [])))
-(def (announce_definition! short type)
+(def (announce_definition! module short type)
(All (_ anchor expression declaration)
- (-> Text Type (Operation anchor expression declaration Any)))
+ (-> Text Text Type
+ (Operation anchor expression declaration Any)))
(/////declaration.of_translation
- (/////translation.log! (format short " : " (%.type type)))))
+ (/////translation.log! (%.format short " : " (type.relative_format module type)))))
(def lux::def
Handler
@@ -233,7 +234,7 @@
[_ _ exported?] (evaluate! archive Bit exported?C)
_ (/////declaration.of_analysis
(moduleA.define short_name [(as Bit exported?) {.#Definition [type value]}]))
- _ (..announce_definition! short_name type)]
+ _ (..announce_definition! current_module short_name type)]
(in /////declaration.no_requirements))))]))
(def imports
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux
index 4ddfd3fd4..15a4a8057 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm.lux
@@ -29,7 +29,7 @@
["[0]" /
[runtime (.only Operation Phase Handler)]
["[1][0]" primitive]
- ["[1][0]" structure]
+ ["[1][0]" complex]
["[1][0]" reference]
["[1][0]" function]
["[1][0]" when]
@@ -73,11 +73,11 @@
(synthesis.variant @ variantS)
(with_source_mapping @
- (/structure.variant phase archive variantS))
+ (/complex.variant phase archive variantS))
(synthesis.tuple @ members)
(with_source_mapping @
- (/structure.tuple phase archive members))
+ (/complex.tuple phase archive members))
[@ {synthesis.#Reference reference}]
(with_source_mapping @
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/structure.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux
index b06724932..a449ffa45 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/structure.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux
@@ -32,34 +32,9 @@
[analysis
[complex (.only Variant Tuple)]]]])
-(def .public (tuple phase archive membersS)
- (Translator (Tuple Synthesis))
- (when membersS
- {.#End}
- (of phase.monad in //runtime.unit)
-
- {.#Item singletonS {.#End}}
- (phase archive singletonS)
-
- _
- (do [! phase.monad]
- [membersI (|> membersS
- list.enumeration
- (monad.each ! (function (_ [idx member])
- (do !
- [memberI (phase archive member)]
- (in (do _.monad
- [_ _.dup
- _ (_.int (.i64 idx))
- _ memberI]
- _.aastore))))))]
- (in (do [! _.monad]
- [_ (_.int (.i64 (list.size membersS)))
- _ (_.anewarray //type.value)]
- (monad.all ! membersI))))))
-
(def .public (lefts lefts)
- (-> Nat (Bytecode Any))
+ (-> Nat
+ (Bytecode Any))
(when lefts
0 _.iconst_0
1 _.iconst_1
@@ -80,7 +55,8 @@
(_.int (.i64 lefts))))))
(def .public (right? right?)
- (-> Bit (Bytecode Any))
+ (-> Bit
+ (Bytecode Any))
(if right?
//runtime.right_right?
//runtime.left_right?))
@@ -98,3 +74,29 @@
(list //type.lefts //type.right? //type.value)
//type.variant
(list)]))))))
+
+(def .public (tuple phase archive membersS)
+ (Translator (Tuple Synthesis))
+ (when membersS
+ {.#End}
+ (of phase.monad in //runtime.unit)
+
+ {.#Item singletonS {.#End}}
+ (phase archive singletonS)
+
+ _
+ (do [! phase.monad]
+ [membersI (|> membersS
+ list.enumeration
+ (monad.each ! (function (_ [idx member])
+ (do !
+ [memberI (phase archive member)]
+ (in (do _.monad
+ [_ _.dup
+ _ (_.int (.i64 idx))
+ _ memberI]
+ _.aastore))))))]
+ (in (do [! _.monad]
+ [_ (_.int (.i64 (list.size membersS)))
+ _ (_.anewarray //type.value)]
+ (monad.all ! membersI))))))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/primitive.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/primitive.lux
index 86ffa8239..fdcf78041 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/primitive.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/primitive.lux
@@ -137,10 +137,12 @@
..double_bits
(i.= ..d0_bits))
_.dconst_0
- (_.double (as java/lang/Double value)))]
+ (_.double value))]
(do _.monad
[_ constantI]
..wrap_f64))))
(def .public text
+ (-> Text
+ (Bytecode Any))
_.string)
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux
index c2d2536b4..558353ad8 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/jvm/when.lux
@@ -33,7 +33,7 @@
["[1][0]" type]
["[1][0]" runtime (.only Operation Phase Translator)]
["[1][0]" value]
- ["[1][0]" structure]
+ ["[1][0]" complex]
[////
["[0]" phase (.use "operation#[0]" monad)]
["[0]" translation]
@@ -195,8 +195,8 @@
(all _.composite
..peek
(_.checkcast //type.variant)
- (//structure.lefts lefts)
- (//structure.right? right?)
+ (//complex.lefts lefts)
+ (//complex.right? right?)
//runtime.when
_.dup
(_.ifnonnull @success)
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux
index 355b45be8..389716606 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/translation/python.lux
@@ -11,8 +11,9 @@
[meta
[macro
["^" pattern]]
- [target
- ["_" python]]]]]
+ [compiler
+ [target
+ ["_" python]]]]]]
["[0]" /
[runtime (.only Phase)]
["[1][0]" primitive]
diff --git a/stdlib/source/library/lux/meta/compiler/target/jvm/bytecode.lux b/stdlib/source/library/lux/meta/compiler/target/jvm/bytecode.lux
index 20d7be577..abaf5e2c9 100644
--- a/stdlib/source/library/lux/meta/compiler/target/jvm/bytecode.lux
+++ b/stdlib/source/library/lux/meta/compiler/target/jvm/bytecode.lux
@@ -631,7 +631,10 @@
(as Int)))
(def negative_zero_float_bits
- (|> -0.0 (as java/lang/Double) ffi.double_to_float ..float_bits))
+ (|> -0.0
+ (as java/lang/Double)
+ ffi.double_to_float
+ ..float_bits))
(def .public (float value)
(-> java/lang/Float (Bytecode Any))
@@ -666,21 +669,22 @@
)
(def (arbitrary_double value)
- (-> java/lang/Double (Bytecode Any))
+ (-> Frac (Bytecode Any))
(do ..monad
- [index (..lifted (//constant/pool.double (//constant.double (as Frac value))))]
+ [index (..lifted (//constant/pool.double (//constant.double value)))]
(..bytecode $0 $2 @_ _.ldc2_w/double [index])))
(def double_bits
- (-> java/lang/Double Int)
- (|>> java/lang/Double::doubleToRawLongBits
+ (-> Frac Int)
+ (|>> (as java/lang/Double)
+ java/lang/Double::doubleToRawLongBits
(as Int)))
(def negative_zero_double_bits
- (..double_bits (as java/lang/Double -0.0)))
+ (..double_bits -0.0))
(def .public (double value)
- (-> java/lang/Double (Bytecode Any))
+ (-> Frac (Bytecode Any))
(if (i.= ..negative_zero_double_bits
(..double_bits value))
(..arbitrary_double value)
diff --git a/stdlib/source/library/lux/meta/macro.lux b/stdlib/source/library/lux/meta/macro.lux
index ee01882f1..4cf514b07 100644
--- a/stdlib/source/library/lux/meta/macro.lux
+++ b/stdlib/source/library/lux/meta/macro.lux
@@ -17,7 +17,7 @@
["[1][0]" expansion]]
["[0]" // (.only)
["[0]" code]
- ["[0]" symbol (.use "[1]#[0]" codec)]])
+ ["[0]" symbol (.use "[1]#[0]" absolute)]])
(def .public (symbol prefix)
(-> Text (Meta Code))
diff --git a/stdlib/source/library/lux/meta/macro/context.lux b/stdlib/source/library/lux/meta/macro/context.lux
index 1afd92690..2ed4963c1 100644
--- a/stdlib/source/library/lux/meta/macro/context.lux
+++ b/stdlib/source/library/lux/meta/macro/context.lux
@@ -20,7 +20,7 @@
["[0]" property]]]]
["[0]" meta (.only)
[type (.only sharing by_example)]
- ["[0]" symbol (.use "[1]#[0]" codec)]
+ ["[0]" symbol (.use "[1]#[0]" absolute)]
["[0]" code (.only)
["?[1]" \\parser]]]]]
["[0]" // (.only)
diff --git a/stdlib/source/library/lux/meta/macro/expansion.lux b/stdlib/source/library/lux/meta/macro/expansion.lux
index d7171c0e3..936234ed1 100644
--- a/stdlib/source/library/lux/meta/macro/expansion.lux
+++ b/stdlib/source/library/lux/meta/macro/expansion.lux
@@ -13,7 +13,7 @@
["[0]" /// (.only)
["[0]" code]
["[0]" location]
- ["[0]" symbol (.use "[1]#[0]" codec)]])
+ ["[0]" symbol (.use "[1]#[0]" absolute)]])
(def wrong_syntax_error
(-> Symbol Text)
diff --git a/stdlib/source/library/lux/meta/macro/vocabulary.lux b/stdlib/source/library/lux/meta/macro/vocabulary.lux
index 2d236372c..48ae4bff6 100644
--- a/stdlib/source/library/lux/meta/macro/vocabulary.lux
+++ b/stdlib/source/library/lux/meta/macro/vocabulary.lux
@@ -23,8 +23,8 @@
(exception.def .public (invalid_type [expected actual])
(Exception [Type Type])
(exception.report
- (list ["Expected" (type.format expected)]
- ["Actual" (type.format actual)])))
+ (list ["Expected" (type.absolute_format expected)]
+ ["Actual" (type.absolute_format actual)])))
(.def local
(Parser [Code Code])
diff --git a/stdlib/source/library/lux/meta/symbol.lux b/stdlib/source/library/lux/meta/symbol.lux
index 3e8fbf768..b6436066c 100644
--- a/stdlib/source/library/lux/meta/symbol.lux
+++ b/stdlib/source/library/lux/meta/symbol.lux
@@ -46,7 +46,7 @@
(def .public separator
".")
-(def .public codec
+(def .public absolute
(Codec Text Symbol)
(implementation
(def (encoded [module short])
@@ -68,7 +68,7 @@
_
{.#Left (text#composite "Invalid format for Symbol: " input)}))))
-(def .public (relative_codec expected)
+(def .public (relative expected)
(-> Text
(Codec Text Symbol))
(implementation
diff --git a/stdlib/source/library/lux/meta/type.lux b/stdlib/source/library/lux/meta/type.lux
index afe41bec4..7952b99d8 100644
--- a/stdlib/source/library/lux/meta/type.lux
+++ b/stdlib/source/library/lux/meta/type.lux
@@ -6,7 +6,8 @@
[lux (.except function as let)
[abstract
[equivalence (.only Equivalence)]
- [monad (.only Monad do)]]
+ [monad (.only Monad do)]
+ [codec (.only Codec)]]
[control
["<>" parser]
["[0]" function]
@@ -22,7 +23,7 @@
["n" nat (.use "[1]#[0]" decimal)]]]
["[0]" meta (.only)
["[0]" location]
- ["[0]" symbol (.use "[1]#[0]" equivalence codec)]
+ ["[0]" symbol (.use "[1]#[0]" equivalence)]
["[0]" code (.only)
["<[1]>" \\parser (.only Parser)]]
["[0]" macro (.only)
@@ -33,7 +34,8 @@
(with_template [<name> <tag>]
[(def .public (<name> type)
- (-> Type [Nat Type])
+ (-> Type
+ [Nat Type])
(loop (again [num_args 0
type type])
(when type
@@ -48,7 +50,8 @@
)
(def .public (flat_function type)
- (-> Type [(List Type) Type])
+ (-> Type
+ [(List Type) Type])
(when type
{.#Function in out'}
(.let [[ins out] (flat_function out')]
@@ -58,7 +61,8 @@
[(list) type]))
(def .public (flat_application type)
- (-> Type [Type (List Type)])
+ (-> Type
+ [Type (List Type)])
(when type
{.#Apply arg func'}
(.let [[func args] (flat_application func')]
@@ -69,7 +73,8 @@
(with_template [<name> <tag>]
[(def .public (<name> type)
- (-> Type (List Type))
+ (-> Type
+ (List Type))
(when type
{<tag> left right}
(list.partial left (<name> right))
@@ -81,15 +86,16 @@
[flat_tuple .#Product]
)
-(`` (def .public (format type)
- (-> Type Text)
+(`` (def (format symbol_codec type)
+ (-> (Codec Text Symbol) Type
+ Text)
(when type
{.#Nominal name params}
(all text#composite
"(Nominal "
(text.enclosed' text.double_quote name)
(|> params
- (list#each (|>> format (text#composite " ")))
+ (list#each (|>> (format symbol_codec) (text#composite " ")))
(list#mix (function.flipped text#composite) ""))
")")
@@ -97,7 +103,7 @@
[{<tag> _}
(all text#composite <open>
(|> (<flat> type)
- (list#each format)
+ (list#each (format symbol_codec))
list.reversed
(list.interposed " ")
(list#mix text#composite ""))
@@ -110,11 +116,11 @@
(.let [[ins out] (flat_function type)]
(all text#composite "(-> "
(|> ins
- (list#each format)
+ (list#each (format symbol_codec))
list.reversed
(list.interposed " ")
(list#mix text#composite ""))
- " " (format out) ")"))
+ " " (format symbol_codec out) ")"))
{.#Parameter idx}
(n#encoded idx)
@@ -127,22 +133,33 @@
{.#Apply param fun}
(.let [[type_func type_args] (flat_application type)]
- (all text#composite "(" (format type_func) " " (|> type_args (list#each format) list.reversed (list.interposed " ") (list#mix text#composite "")) ")"))
+ (all text#composite "(" (format symbol_codec type_func) " " (|> type_args (list#each (format symbol_codec)) list.reversed (list.interposed " ") (list#mix text#composite "")) ")"))
(,, (with_template [<tag> <desc>]
[{<tag> env body}
- (all text#composite "(" <desc> " {" (|> env (list#each format) (text.interposed " ")) "} " (format body) ")")]
+ (all text#composite "(" <desc> " {" (|> env (list#each (format symbol_codec)) (text.interposed " ")) "} " (format symbol_codec body) ")")]
[.#UnivQ "All"]
[.#ExQ "Ex"]))
{.#Named name type}
- (symbol#encoded name)
+ (of symbol_codec encoded name)
)))
+(def .public absolute_format
+ (-> Type
+ Text)
+ (..format symbol.absolute))
+
+(def .public (relative_format module)
+ (-> Text Type
+ Text)
+ (..format (symbol.relative module)))
+
... https://en.wikipedia.org/wiki/Lambda_calculus#%CE%B2-reduction
(`` (def (reduced env type)
- (-> (List Type) Type Type)
+ (-> (List Type) Type
+ Type)
(when type
{.#Nominal name params}
{.#Nominal name (list#each (reduced env) params)}
@@ -175,7 +192,7 @@
(list#each (.function (_ [index type])
(all text#composite
(n#encoded index)
- " " (..format type))))
+ " " (..absolute_format type))))
(text.interposed (text#composite text.new_line " ")))))
(list.item idx env))
@@ -240,7 +257,8 @@
))))))
(`` (def .public (applied params func)
- (-> (List Type) Type (Maybe Type))
+ (-> (List Type) Type
+ (Maybe Type))
(when params
{.#End}
{.#Some func}
@@ -266,7 +284,8 @@
{.#None}))))
(`` (def .public (code type)
- (-> Type Code)
+ (-> Type
+ Code)
(when type
{.#Nominal name params}
(` {.#Nominal (, (code.text name))
@@ -303,7 +322,8 @@
)))
(def .public (de_aliased type)
- (-> Type Type)
+ (-> Type
+ Type)
(when type
{.#Named _ {.#Named name type'}}
(de_aliased {.#Named name type'})
@@ -312,7 +332,8 @@
type))
(def .public (anonymous type)
- (-> Type Type)
+ (-> Type
+ Type)
(when type
{.#Named name type'}
(anonymous type')
@@ -322,7 +343,8 @@
(with_template [<name> <base> <ctor>]
[(def .public (<name> types)
- (-> (List Type) Type)
+ (-> (List Type)
+ Type)
(when types
{.#End}
<base>
@@ -338,7 +360,8 @@
)
(def .public (function inputs output)
- (-> (List Type) Type Type)
+ (-> (List Type) Type
+ Type)
(when inputs
{.#End}
output
@@ -347,7 +370,8 @@
{.#Function input (function inputs' output)}))
(def .public (application params quant)
- (-> (List Type) Type Type)
+ (-> (List Type) Type
+ Type)
(when params
{.#End}
quant
@@ -357,7 +381,8 @@
(with_template [<name> <tag>]
[(def .public (<name> size body)
- (-> Nat Type Type)
+ (-> Nat Type
+ Type)
(when size
0 body
_ (|> body (<name> (-- size)) {<tag> (list)})))]
@@ -367,7 +392,8 @@
)
(`` (def .public (quantified? type)
- (-> Type Bit)
+ (-> Type
+ Bit)
(when type
{.#Named [module name] _type}
(quantified? _type)
@@ -388,7 +414,8 @@
false)))
(def .public (array depth element_type)
- (-> Nat Type Type)
+ (-> Nat Type
+ Type)
(when depth
0 element_type
_ (|> element_type
@@ -397,7 +424,8 @@
{.#Nominal array.nominal})))
(def .public (flat_array type)
- (-> Type [Nat Type])
+ (-> Type
+ [Nat Type])
(with_expansions [<default> [0 type]]
(when type
{.#Nominal name (list element_type)}
@@ -410,7 +438,8 @@
<default>)))
(def .public array?
- (-> Type Bit)
+ (-> Type
+ Bit)
(|>> ..flat_array
product.left
(n.> 0)))
@@ -432,16 +461,17 @@
(do meta.monad
[location meta.location
valueT (meta.type valueN)
- .let [_ (.log!# (all text#composite
- (symbol#encoded (symbol ..log!)) " " (location.format location) text.new_line
+ .let [[@ _ _] location
+ _ (.log!# (all text#composite
+ (of symbol.absolute encoded (symbol ..log!)) " " (location.format location) text.new_line
"Expression: " (when valueC
{.#Some valueC}
(code.format valueC)
{.#None}
- (symbol#encoded valueN))
+ (of symbol.absolute encoded valueN))
text.new_line
- " Type: " (..format valueT)))]]
+ " Type: " (..relative_format @ valueT)))]]
(in (list (code.symbol valueN))))
{.#Right valueC}
@@ -475,7 +505,8 @@
#expression Code]))
(def (typed lux)
- (-> Lux (Parser Typed))
+ (-> Lux
+ (Parser Typed))
(do <>.monad
[it <code>.any
type_check (<>.of_try (meta.result lux (expansion.complete it)))]
@@ -510,7 +541,8 @@
(.as .Nothing [])))))))))
(`` (def .public (replaced before after)
- (-> Type Type Type Type)
+ (-> Type Type Type
+ Type)
(.function (again it)
(if (of ..equivalence = before it)
after
diff --git a/stdlib/source/library/lux/meta/type/check.lux b/stdlib/source/library/lux/meta/type/check.lux
index 72dc101b3..62242e421 100644
--- a/stdlib/source/library/lux/meta/type/check.lux
+++ b/stdlib/source/library/lux/meta/type/check.lux
@@ -49,21 +49,21 @@
(exception.def .public (invalid_type_application [funcT argT])
(Exception [Type Type])
(exception.report
- (list ["Type function" (//.format funcT)]
- ["Type argument" (//.format argT)])))
+ (list ["Type function" (//.absolute_format funcT)]
+ ["Type argument" (//.absolute_format argT)])))
(exception.def .public (cannot_rebind_var [id type bound])
(Exception [Nat Type Type])
(exception.report
(list ["Var" (n#encoded id)]
- ["Wanted type" (//.format type)]
- ["Current type" (//.format bound)])))
+ ["Wanted type" (//.absolute_format type)]
+ ["Current type" (//.absolute_format bound)])))
(exception.def .public (type_check_failed [expected actual])
(Exception [Type Type])
(exception.report
- (list ["Expected" (//.format expected)]
- ["Actual" (//.format actual)])))
+ (list ["Expected" (//.absolute_format expected)]
+ ["Actual" (//.absolute_format actual)])))
(type .public Var
Nat)
diff --git a/stdlib/source/library/lux/meta/type/nominal.lux b/stdlib/source/library/lux/meta/type/nominal.lux
index a9ddf084d..73e776829 100644
--- a/stdlib/source/library/lux/meta/type/nominal.lux
+++ b/stdlib/source/library/lux/meta/type/nominal.lux
@@ -14,7 +14,7 @@
[collection
["[0]" list (.use "[1]#[0]" functor)]]]
[meta
- ["[0]" symbol (.use "[1]#[0]" codec)]
+ ["[0]" symbol (.use "[1]#[0]" absolute)]
["[0]" code (.only)
["<[1]>" \\parser (.only Parser)]]
["[0]" macro (.only)
diff --git a/stdlib/source/parser/lux/data/format/xml.lux b/stdlib/source/parser/lux/data/format/xml.lux
index d413db61e..6f25d82ba 100644
--- a/stdlib/source/parser/lux/data/format/xml.lux
+++ b/stdlib/source/parser/lux/data/format/xml.lux
@@ -17,7 +17,7 @@
["[0]" list]
["[0]" dictionary]]]
[meta
- ["[0]" symbol (.use "[1]#[0]" equivalence codec)]]]]
+ ["[0]" symbol (.use "[1]#[0]" equivalence absolute)]]]]
[\\library
["[0]" / (.only Attribute Attrs Tag XML)]])
diff --git a/stdlib/source/polytypic/lux/data/format/json.lux b/stdlib/source/polytypic/lux/data/format/json.lux
index 3953675da..575fbd58b 100644
--- a/stdlib/source/polytypic/lux/data/format/json.lux
+++ b/stdlib/source/polytypic/lux/data/format/json.lux
@@ -226,7 +226,7 @@
<type>.parameter
<type>.recursive_call
... If all else fails...
- (<>.failure (format "Cannot create JSON encoder for: " (type.format inputT)))
+ (<>.failure (format "Cannot create JSON encoder for: " (type.absolute_format inputT)))
)))))
(def decoded
@@ -330,7 +330,7 @@
<type>.parameter
<type>.recursive_call
... If all else fails...
- (<>.failure (format "Cannot create JSON decoder for: " (type.format inputT)))
+ (<>.failure (format "Cannot create JSON decoder for: " (type.absolute_format inputT)))
)))))
(def .public codec
diff --git a/stdlib/source/test/lux/data/text.lux b/stdlib/source/test/lux/data/text.lux
index c9b3a70d3..fb008dc84 100644
--- a/stdlib/source/test/lux/data/text.lux
+++ b/stdlib/source/test/lux/data/text.lux
@@ -123,7 +123,7 @@
[\\format.rev rev.decimal random.rev]
[\\format.frac frac.decimal random.frac]
[\\format.ratio ratio.codec random.ratio]
- [\\format.symbol symbol.codec ($//symbol.random 5 5)]
+ [\\format.symbol symbol.absolute ($//symbol.random 5 5)]
[\\format.xml xml.codec $//xml.random]
[\\format.json json.codec $//json.random]
[\\format.day day.codec random.day]
@@ -185,7 +185,7 @@
[\\format.text /.format (random.unicode 5)]
[\\format.code code.format $//code.random]
- [\\format.type type.format ($//type.random 0)]
+ [\\format.type type.absolute_format ($//type.random 0)]
[\\format.location location.format
(all random.and
(random.unicode 5)
diff --git a/stdlib/source/test/lux/meta.lux b/stdlib/source/test/lux/meta.lux
index 7b329a804..8fd22359c 100644
--- a/stdlib/source/test/lux/meta.lux
+++ b/stdlib/source/test/lux/meta.lux
@@ -812,7 +812,7 @@
label_module (random.upper_cased 2)
name_0 (random.upper_cased 3)
- ... name_1 (random.upper_cased 4)
+ name_1 (random.upper_cased 4)
.let [random_tag (of ! each (|>> [label_module])
(random.upper_cased 1))
@@ -827,13 +827,9 @@
(of ! each set.list)
(random.and (in head))))))]
tags_0 (random_labels 5)
- ... tags_1 (let [set/0 (set.of_list text.hash {.#Item tags_0})]
- ... (random.only (|>> {.#Item}
- ... (list.any? (set.member? set/0))
- ... not)
- ... random_labels))
+ tags_1 (random_labels 6)
.let [type_0 {.#Nominal name_0 (list)}
- ... type_1 {.#Nominal name_1 (list)}
+ type_1 {.#Nominal name_1 (list)}
expected_lux
(is Lux
@@ -854,7 +850,7 @@
[.#module_hash 0
.#module_aliases (list)
.#definitions (list.partial [name_0 [true {.#Definition [.Type type_0]}]]
- ... [name_1 {.#Type [true type_1 {.#Right tags_1}]}]
+ [name_1 [true {.#Definition [.Type type_1]}]]
(all list#composite
(let [cohort (is (List Symbol)
(list#each (|>> [label_module])
@@ -867,12 +863,19 @@
[short [true {.#Definition [.Tag
(|> [{.#Some [index (right? index) cohort]} type_0]
(is Label)
- (as Tag))]}]]))))
- ... (|> {.#Item tags_1}
- ... list.enumeration
- ... (list#each (function (_ [index short])
- ... [short {.#Slot [true type_1 {.#Item tags_1} index]}])))
- ))
+ (as .Tag))]}]]))))
+ (let [cohort (is (List Symbol)
+ (list#each (|>> [label_module])
+ {.#Item tags_1}))
+ last (-- (list.size cohort))
+ right? (n.= last)]
+ (|> {.#Item tags_1}
+ list.enumeration
+ (list#each (function (_ [index short])
+ [short [true {.#Definition [.Slot
+ (|> [{.#Some [index (right? index) cohort]} type_1]
+ (is Label)
+ (as .Slot))]}]]))))))
.#imports (list)
.#module_state {.#Active}]])
.#scopes (list)
@@ -893,17 +896,15 @@
type.equivalence))]
(|> (/.tag_lists label_module)
(/.result expected_lux)
- (try#each (of equivalence = (list [(list#each (|>> [label_module]) {.#Item tags_0})
- type_0]
- ... [(list#each (|>> [label_module]) {.#Item tags_1})
- ... type_1]
- )))
+ (try#each (of equivalence = (list [(list#each (|>> [label_module]) {.#Item tags_1})
+ type_1])))
(try.else false))))
- ... (_.coverage [/.tags_of]
- ... (|> (/.tags_of [label_module name_1])
- ... (/.result expected_lux)
- ... (try#each (of (maybe.equivalence (list.equivalence symbol.equivalence)) = {.#Some (list#each (|>> [label_module]) {.#Item tags_1})}))
- ... (try.else false)))
+ (_.coverage [/.tags_of]
+ (|> (/.tags_of [label_module name_1])
+ (/.result expected_lux)
+ (try#each (of (maybe.equivalence (list.equivalence symbol.equivalence)) =
+ {.#Some (list#each (|>> [label_module]) {.#Item tags_1})}))
+ (try.else false)))
... (_.coverage [/.tag]
... (|> {.#Item tags_0}
... list.enumeration
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase.lux
index e111c6971..6998809be 100644
--- a/stdlib/source/test/lux/meta/compiler/language/lux/phase.lux
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase.lux
@@ -35,7 +35,8 @@
["[1]/[0]" primitive]
["[1]/[0]" type]
["[1]/[0]" value]
- ["[1]/[0]" runtime]]]])
+ ["[1]/[0]" runtime]
+ ["[1]/[0]" complex]]]])
(def (injection value)
(All (_ of)
@@ -224,4 +225,5 @@
/translation/jvm/type.test
/translation/jvm/value.test
/translation/jvm/runtime.test
+ /translation/jvm/complex.test
)))
diff --git a/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux
new file mode 100644
index 000000000..4e8d8b010
--- /dev/null
+++ b/stdlib/source/test/lux/meta/compiler/language/lux/phase/translation/jvm/complex.lux
@@ -0,0 +1,135 @@
+... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
+... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
+
+(.require
+ [library
+ [lux (.except)
+ [abstract
+ [monad (.only do)]]
+ [control
+ ["[0]" io]
+ ["[0]" try]]
+ [data
+ ["[0]" bit (.use "[1]#[0]" equivalence)]
+ ["[0]" text (.use "[1]#[0]" equivalence)]]
+ [math
+ ["[0]" random (.only Random)]
+ [number
+ ["[0]" i64 (.use "[1]#[0]" equivalence)]]]
+ [meta
+ ["[0]" location]
+ [compiler
+ [language
+ [lux
+ ["[0]" synthesis]]]
+ [meta
+ ["[0]" archive]]]]
+ [test
+ ["_" property (.only Test)]]]]
+ [\\library
+ ["[0]" / (.only)
+ ["[0]" // (.only)
+ ["[0]" host]
+ ["[0]" runtime]
+ [///
+ ["[0]" extension]
+ [//
+ ["[0]" phase]
+ ["[0]" translation]]]]]])
+
+(type Variant/3
+ (Or Bit (I64 Any) Text))
+
+(type Tuple/3
+ (And Bit (I64 Any) Text))
+
+(def lux
+ Lux
+ [.#info [.#target ""
+ .#version ""
+ .#mode {.#Build}
+ .#configuration (list)]
+ .#source [location.dummy 0 ""]
+ .#location location.dummy
+ .#current_module {.#None}
+ .#modules (list)
+ .#scopes (list)
+ .#type_context [.#ex_counter 0
+ .#var_counter 0
+ .#var_bindings (list)]
+ .#expected {.#None}
+ .#seed 0
+ .#scope_type_vars (list)
+ .#extensions []
+ .#eval (as (-> Type Code (Meta Any)) [])
+ .#host []])
+
+(def .public test
+ Test
+ (<| (_.covering /._)
+ (do [! random.monad]
+ [module (random.lower_cased 1)
+
+ expected_bit random.bit
+ expected_i64 random.i64
+ expected_text (random.upper_cased 2)
+
+ .let [extender (is extension.Extender
+ (function (_ _)
+ (undefined)))
+ phase (//.translate extender ..lux)
+ $unit [0 0]]])
+ (all _.and
+ (_.coverage [/.variant]
+ (`` (and (,, (with_template [<lefts> <right?> <synthesis> <expected> <=>]
+ [(|> (do try.monad
+ [.let [[_ host] (io.run! host.host)
+ state (is runtime.State
+ (translation.state host module))]
+ _ (phase.result state
+ (do phase.monad
+ [_ (translation.set_buffer translation.empty_buffer)
+ it (/.variant phase archive.empty
+ [<lefts> <right?> (<synthesis> location.dummy <expected>)])]
+ (in (when (of host evaluate $unit [{.#None} it])
+ {try.#Success actual}
+ (when (as Variant/3 actual)
+ {<lefts> <right?> actual}
+ (<=> <expected> actual)
+
+ _
+ false)
+
+ {try.#Failure error}
+ false))))]
+ (in true))
+ (try.else false))]
+
+ [0 #0 synthesis.bit expected_bit bit#=]
+ [1 #0 synthesis.i64 expected_i64 i64#=]
+ [1 #1 synthesis.text expected_text text#=]
+ )))))
+ (_.coverage [/.tuple]
+ (|> (do try.monad
+ [.let [[_ host] (io.run! host.host)
+ state (is runtime.State
+ (translation.state host module))]
+ _ (phase.result state
+ (do phase.monad
+ [_ (translation.set_buffer translation.empty_buffer)
+ it (/.tuple phase archive.empty
+ (list (synthesis.bit location.dummy expected_bit)
+ (synthesis.i64 location.dummy expected_i64)
+ (synthesis.text location.dummy expected_text)))]
+ (in (when (of host evaluate $unit [{.#None} it])
+ {try.#Success actual}
+ (let [[actual_bit actual_i64 actual_text] (as Tuple/3 actual)]
+ (and (bit#= expected_bit actual_bit)
+ (i64#= expected_i64 actual_i64)
+ (text#= expected_text actual_text)))
+
+ {try.#Failure error}
+ false))))]
+ (in true))
+ (try.else false)))
+ )))
diff --git a/stdlib/source/test/lux/meta/compiler/target/jvm.lux b/stdlib/source/test/lux/meta/compiler/target/jvm.lux
index b8a09e42a..3abe5e315 100644
--- a/stdlib/source/test/lux/meta/compiler/target/jvm.lux
+++ b/stdlib/source/test/lux/meta/compiler/target/jvm.lux
@@ -275,7 +275,7 @@
(def $Double::random (as (Random java/lang/Double) random.frac))
(def $Double::literal
(-> java/lang/Double (Bytecode Any))
- /.double)
+ (|>> (as Frac) /.double))
(def valid_double
(Random java/lang/Double)
(random.only (|>> (as Frac) f.not_a_number? not)
@@ -822,14 +822,14 @@
@.jvm
(|>> (as java/lang/Double) .jvm_object_cast# (.jvm_double_=# (.jvm_object_cast# expected)))))
(do /.monad
- [_ (/.double expected)]
+ [_ (/.double (as Frac expected))]
(/.invokestatic ..$Double "valueOf" (/type.method [(list) (list /type.double) ..$Double (list)]))))
(<| (_.lifted "INVOKEVIRTUAL")
(do random.monad
[expected ..$Double::random])
(..bytecode (|>> (as Bit) (bit#= (f.not_a_number? (as Frac expected)))))
(do /.monad
- [_ (/.double expected)
+ [_ (/.double (as Frac expected))
_ ..$Double::wrap
_ (/.invokevirtual ..$Double "isNaN" (/type.method [(list) (list) /type.boolean (list)]))]
..$Boolean::wrap))
@@ -845,7 +845,7 @@
(do /.monad
[_ (/.new ..$Double)
_ /.dup
- _ (/.double expected)]
+ _ (/.double (as Frac expected))]
(/.invokespecial ..$Double "<init>" (/type.method [(list) (list /type.double) /type.void (list)]))))
(<| (_.lifted "INVOKEINTERFACE")
(do random.monad
diff --git a/stdlib/source/test/lux/meta/symbol.lux b/stdlib/source/test/lux/meta/symbol.lux
index 0fdd94870..f7c2d7db4 100644
--- a/stdlib/source/test/lux/meta/symbol.lux
+++ b/stdlib/source/test/lux/meta/symbol.lux
@@ -55,15 +55,15 @@
(hashT.spec /.hash)))
(_.for [/.order]
(orderT.spec /.order (..random sizeM1 sizeS1)))
- (_.for [/.codec]
- (_.and (codecT.spec /.equivalence /.codec (..random sizeM1 sizeS1))
+ (_.for [/.absolute]
+ (_.and (codecT.spec /.equivalence /.absolute (..random sizeM1 sizeS1))
(_.test "Encoding a symbol without a module component results in text equal to the short of the symbol."
(if (text.empty? module1)
- (same? short1 (of /.codec encoded symbol1))
+ (same? short1 (of /.absolute encoded symbol1))
true))))
(_.coverage [/.separator]
- (let [it (of /.codec encoded symbol1)]
+ (let [it (of /.absolute encoded symbol1)]
(if (text.empty? module1)
(same? short1 it)
(text.contains? /.separator it))))
diff --git a/stdlib/source/test/lux/meta/type.lux b/stdlib/source/test/lux/meta/type.lux
index 674c15d58..4f02f6fe8 100644
--- a/stdlib/source/test/lux/meta/type.lux
+++ b/stdlib/source/test/lux/meta/type.lux
@@ -559,9 +559,9 @@
(_.coverage [/.code]
(bit#= (/#= left right)
(code#= (/.code left) (/.code right))))
- (_.coverage [/.format]
+ (_.coverage [/.absolute_format]
(bit#= (/#= left right)
- (text#= (/.format left) (/.format right))))
+ (text#= (/.absolute_format left) (/.absolute_format right))))
))
..\\parser
diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux
index 0926872ac..40eeae890 100644
--- a/stdlib/source/test/lux/world/file.lux
+++ b/stdlib/source/test/lux/world/file.lux
@@ -211,7 +211,12 @@
move&delete
(..move&delete fs parent child alternate_child)])
- (unit.coverage [/.System]
+ (unit.coverage [/.System
+ /.separator
+ /.file? /.directory?
+ /.make_directory /.directory_files /.sub_directories
+ /.file_size /.last_modified /.can_execute? /.read /.delete
+ /.modify /.write /.append /.move]
(and directory?&make_directory
file?&write
file_size&read&append