aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/meta
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library/lux/meta')
-rw-r--r--stdlib/source/library/lux/meta/compiler.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/default/platform.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux.lux29
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/analysis/complex.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/analysis/coverage.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux46
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/analysis/scope.lux6
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/analysis/simple.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/generation.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/complex.lux140
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux24
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/when.lux46
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux63
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/synthesis/simple.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/meta/archive.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/meta/archive/artifact/category.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/meta/archive/signature.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/meta/archive/unit.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/meta/cache/dependency/module.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/meta/cli.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/meta/context.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/meta/io/archive.lux17
-rw-r--r--stdlib/source/library/lux/meta/compiler/phase.lux2
-rw-r--r--stdlib/source/library/lux/meta/compiler/reference/variable.lux2
-rw-r--r--stdlib/source/library/lux/meta/target/jvm/attribute.lux2
-rw-r--r--stdlib/source/library/lux/meta/target/jvm/constant.lux2
-rw-r--r--stdlib/source/library/lux/meta/target/jvm/constant/tag.lux2
-rw-r--r--stdlib/source/library/lux/meta/target/jvm/type.lux2
-rw-r--r--stdlib/source/library/lux/meta/type/implicit.lux16
-rw-r--r--stdlib/source/library/lux/meta/type/row.lux2
33 files changed, 169 insertions, 266 deletions
diff --git a/stdlib/source/library/lux/meta/compiler.lux b/stdlib/source/library/lux/meta/compiler.lux
index 64f5a38fd..5f2d00605 100644
--- a/stdlib/source/library/lux/meta/compiler.lux
+++ b/stdlib/source/library/lux/meta/compiler.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Module Code)
+ [lux (.except Module Code #module)
[control
["<>" parser (.only)]
["[0]" try (.only Try)]
diff --git a/stdlib/source/library/lux/meta/compiler/default/platform.lux b/stdlib/source/library/lux/meta/compiler/default/platform.lux
index 1d60192d3..427625283 100644
--- a/stdlib/source/library/lux/meta/compiler/default/platform.lux
+++ b/stdlib/source/library/lux/meta/compiler/default/platform.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Module)
+ [lux (.except Module #host)
["[0]" debug]
[abstract
["[0]" monad (.only Monad do)]]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux.lux
index 14adeb6d6..1176afc91 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux.lux
@@ -24,21 +24,11 @@
(Format .Module)
(let [definition (is (Format Definition)
(all _.and _.bit _.type _.any))
- labels (is (Format [Text (List Text)])
- (_.and _.text (_.list _.text)))
- global_type (is (Format [Bit Type (Either [Text (List Text)]
- [Text (List Text)])])
- (all _.and _.bit _.type (_.or labels labels)))
- global_label (is (Format .Label)
- (all _.and _.bit _.type (_.list _.text) _.nat))
alias (is (Format Alias)
(_.and _.text _.text))
global (is (Format Global)
(all _.or
definition
- global_type
- global_label
- global_label
alias))]
(all _.and
... #module_hash
@@ -59,22 +49,6 @@
<binary>.bit
<binary>.type
<binary>.any))
- labels (is (Parser [Text (List Text)])
- (all <>.and
- <binary>.text
- (<binary>.list <binary>.text)))
- global_type (is (Parser [Bit Type (Either [Text (List Text)]
- [Text (List Text)])])
- (all <>.and
- <binary>.bit
- <binary>.type
- (<binary>.or labels labels)))
- global_label (is (Parser .Label)
- (all <>.and
- <binary>.bit
- <binary>.type
- (<binary>.list <binary>.text)
- <binary>.nat))
alias (is (Parser Alias)
(all <>.and
<binary>.text
@@ -82,9 +56,6 @@
global (is (Parser Global)
(all <binary>.or
definition
- global_type
- global_label
- global_label
alias))]
(all <>.and
... #module_hash
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux
index 7df0d6232..2b8a26b2b 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Tuple Variant Pattern nat int rev when local except)
+ [lux (.except Tuple Variant Pattern #Function #Apply nat int rev when local except)
[abstract
[equivalence (.only Equivalence)]
[hash (.only Hash)]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/complex.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/complex.lux
index 40d90f729..7d3f9f1cf 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/complex.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/complex.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Tuple Variant)
+ [lux (.except Tag Tuple Variant #Variant #Tuple)
[abstract
[equivalence (.only Equivalence)]
[hash (.only Hash)]]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/coverage.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/coverage.lux
index 8799f8b57..c4c6da56d 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/coverage.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/coverage.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Variant Pattern)
+ [lux (.except Variant Pattern #Bit #Nat #Int #Rev #Frac #Text #Variant)
[abstract
[equivalence (.except)]
["[0]" monad (.only do)]]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux
index e6f531191..98df6e6ad 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/module.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Label with)
+ [lux (.except with)
["[0]" meta]
[abstract
["[0]" monad (.only do)]]
@@ -21,25 +21,11 @@
[///
["[1]" phase]]]])
-(type .public Label
- Text)
-
(exception.def .public (unknown_module module)
(Exception Text)
(exception.report
(list ["Module" module])))
-(with_template [<name>]
- [(exception.def .public (<name> [labels owner])
- (Exception [(List Label) Type])
- (exception.report
- (list ["Labels" (text.interposed " " labels)]
- ["Type" (%.type owner)])))]
-
- [cannot_declare_labels_for_anonymous_type]
- [cannot_declare_labels_for_foreign_type]
- )
-
(exception.def .public (cannot_define_more_than_once [name already_existing])
(Exception [Symbol Global])
(exception.report
@@ -49,16 +35,7 @@
(format "alias " (%.symbol alias))
{.#Definition definition}
- (format "definition " (%.symbol name))
-
- {.#Type _}
- (format "type " (%.symbol name))
-
- {.#Tag _}
- (format "tag " (%.symbol name))
-
- {.#Slot _}
- (format "slot " (%.symbol name)))])))
+ (format "definition " (%.symbol name)))])))
(exception.def .public (can_only_change_state_of_active_module [module state])
(Exception [Text Module_State])
@@ -207,22 +184,3 @@
[set_compiled compiled? .#Compiled]
[set_cached cached? .#Cached]
)
-
-(def .public (declare_labels record? labels exported? type)
- (-> Bit (List Label) Bit Type (Operation Any))
- (do [! ///.monad]
- [self_name (///extension.lifted meta.current_module_name)
- [type_module type_name] (when type
- {.#Named type_name _}
- (in type_name)
-
- _
- (/.except ..cannot_declare_labels_for_anonymous_type [labels type]))
- _ (///.assertion ..cannot_declare_labels_for_foreign_type [labels type]
- (text#= self_name type_module))]
- (monad.each ! (function (_ [index short])
- (..define short
- (if record?
- {.#Slot [exported? type labels index]}
- {.#Tag [exported? type labels index]})))
- (list.enumeration labels))))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/scope.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/scope.lux
index ba360a38b..833bb997c 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/scope.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/scope.lux
@@ -144,9 +144,9 @@
(let [bindings (is Bindings
[.#counter 0
.#mappings (list)])]
- [.#name (list)
- .#inner 0
- .#locals bindings
+ [.#scope_name (list)
+ .#inner_scopes 0
+ .#locals bindings
.#captured bindings]))
(def .public (reset action)
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/simple.lux b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/simple.lux
index 239bb848c..b848b2a4e 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/analysis/simple.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/analysis/simple.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except #Bit #Nat #Int #Rev #Frac #Text)
[abstract
[equivalence (.only Equivalence)]]
[data
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux b/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux
index 1f2b4505a..8eff3ed65 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/declaration.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Module)
+ [lux (.except Module #module #imports)
[abstract
[monad (.only do)]]
[control
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/generation.lux b/stdlib/source/library/lux/meta/compiler/language/lux/generation.lux
index 93e1420f8..78587f280 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/generation.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/generation.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except symbol)
+ [lux (.except #module #counter #host symbol)
[abstract
[monad (.only do)]]
[control
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 21c5fba14..885f2c364 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,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except Tag)
[abstract
["[0]" monad (.only do)]]
[control
@@ -21,7 +21,7 @@
["[0]" meta (.only)
["[0]" symbol]
["[0]" code]
- ["[0]" type (.only)
+ ["[0]" type (.use "[1]#[0]" equivalence)
["[0]" check]]]]]
["[0]" //
["[1][0]" simple]
@@ -74,6 +74,17 @@
["Tag" (%.symbol tag)]
["Expression" (%.code code)])))
+(exception.def .public (cannot_order_record [@ code])
+ (Exception [Code (List [Symbol Code])])
+ (exception.report
+ (list ["@" (%.code @)]
+ ["Expression" (|> code
+ (list#each (function (_ [slot value])
+ (list (code.symbol slot) value)))
+ list#conjoint
+ code.tuple
+ %.code)])))
+
(exception.def .public (cannot_repeat_slot [key record])
(Exception [Symbol (List [Symbol Code])])
(exception.report
@@ -176,9 +187,13 @@
(-> Phase Symbol Phase)
(do [! ///.monad]
[tag (///extension.lifted (meta.normal tag))
- [idx group variantT] (///extension.lifted (meta.tag tag))
- .let [case_size (list.size group)
- [lefts right?] (/complex.choice case_size idx)]
+ [lefts,right? variantT] (///extension.lifted (meta.tag tag))
+ [lefts right?] (when lefts,right?
+ {.#Some [lefts right? family]}
+ (in [lefts right?])
+
+ {.#None}
+ (in [0 false]))
expectedT (///extension.lifted meta.expected_type)]
(when expectedT
{.#Var _}
@@ -323,45 +338,83 @@
(list.any? (list.any? (|>> product.left (text#= name))))
meta.locals))
+(def (slot it)
+ (-> Symbol (Meta Label))
+ (do meta.monad
+ [it (meta.normal it)]
+ (meta.slot it)))
+
+(def (slot_type [[_ it] _])
+ (-> [Label Code] Type)
+ it)
+
+(def (same_record? it)
+ (-> (List [Label Code]) Bit)
+ (when it
+ (list.partial head tail)
+ (let [expected (slot_type head)]
+ (list.every? (|>> slot_type (type#= expected)) tail))
+
+ (list)
+ false))
+
+(def (complete_record? it)
+ (-> (List [Label Code]) Bit)
+ (loop (again [expected_lefts 0
+ remaining it])
+ (when remaining
+ {.#Item [[{.#Some [lefts .true family]} type] value] {.#End}}
+ (n.= (-- expected_lefts) lefts)
+
+ {.#Item [[{.#None} type] value] {.#End}}
+ (n.= 0 expected_lefts)
+
+ {.#Item [[{.#Some [lefts .false family]} type] value] tail}
+ (and (n.= expected_lefts lefts)
+ (again (++ expected_lefts) tail))
+
+ _
+ false)))
+
+(def sorted_record
+ (-> (List [Label Code]) (List [Label Code]))
+ (list.sorted (function (_ left right)
+ (when [left right]
+ [[[{.#Some [leftsL right?L familyL]} typeL] valueL]
+ [[{.#Some [leftsR right?R familyR]} typeR] valueR]]
+ (if (n.= leftsL leftsR)
+ (not right?R)
+ (n.< leftsL leftsR))
+
+ _
+ false))))
+
... Lux already possesses the means to analyse tuples, so
... re-implementing the same functionality for records makes no sense.
... Records, thus, get transformed into tuples by ordering the elements.
-(def (order' head_k record)
+(def (order' head_k original_record)
(-> Symbol (List [Symbol Code]) (Operation (Maybe [Nat (List Code) Type])))
(do [! ///.monad]
- [slotH' (///extension.lifted
- (do meta.monad
- [head_k (meta.normal head_k)]
- (meta.try (meta.slot head_k))))]
- (when slotH'
- {try.#Success [_ slot_set recordT]}
+ [record (<| ///extension.lifted
+ meta.try
+ (monad.each ! (function (_ [slot value])
+ (do !
+ [slot (..slot slot)]
+ (in [slot value])))
+ original_record))]
+ (when record
+ {try.#Success record}
(do !
- [.let [size_record (list.size record)
- size_ts (list.size slot_set)]
- _ (if (n.= size_ts size_record)
- (in [])
- (/.except ..record_size_mismatch [size_ts size_record recordT record]))
- .let [tuple_range (list.indices size_ts)
- tag->idx (dictionary.of_list symbol.hash (list.zipped_2 slot_set tuple_range))]
- idx->val (monad.mix !
- (function (_ [key val] idx->val)
- (do !
- [key (///extension.lifted (meta.normal key))]
- (when (dictionary.value key tag->idx)
- {.#Some idx}
- (if (dictionary.key? idx->val idx)
- (/.except ..cannot_repeat_slot [key record])
- (in (dictionary.has idx val idx->val)))
-
- {.#None}
- (/.except ..slot_does_not_belong_to_record [key recordT]))))
- (is (Dictionary Nat Code)
- (dictionary.empty n.hash))
- record)
- .let [ordered_tuple (list#each (function (_ idx)
- (maybe.trusted (dictionary.value idx idx->val)))
- tuple_range)]]
- (in {.#Some [size_ts ordered_tuple recordT]}))
+ [.let [record (sorted_record record)]
+ _ (///.assertion ..cannot_order_record [(` same_record?) original_record]
+ (same_record? record))
+ _ (///.assertion ..cannot_order_record [(` complete_record?) original_record]
+ (complete_record? record))]
+ (in (do maybe.monad
+ [[[_ :record:] _] (list.head record)]
+ (in [(list.size record)
+ (list#each product.right record)
+ :record:]))))
{try.#Failure error}
(in {.#None}))))
@@ -402,10 +455,13 @@
[head_k (///extension.lifted (meta.normal pseudo_slot))
slot (///extension.lifted (meta.try (meta.slot head_k)))]
(when slot
- {try.#Success [_ slot_set recordT]}
- (when (list.size slot_set)
- 1 (analyse archive singletonC)
- _ (..product analyse archive members))
+ {try.#Success [lefts,right? recordT]}
+ (when lefts,right?
+ {.#None}
+ (analyse archive singletonC)
+
+ _
+ (..product analyse archive members))
_
(..product analyse archive members)))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux
index 51816df59..26831fe0a 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/reference.lux
@@ -63,29 +63,7 @@
(text#= quoted_module ::module))
<return>
(/.except ..foreign_module_has_not_been_imported [current ::module quoted_module def_name])))
- (/.except ..definition_has_not_been_exported def_name))))
-
- {.#Type [exported? value labels]}
- (do !
- [_ (/type.inference .Type)
- (^.let 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.lifted (meta.imported_by? ::module current))]
- (if (or imported!
- (text#= quoted_module ::module))
- <return>
- (/.except ..foreign_module_has_not_been_imported [current ::module quoted_module def_name])))
- (/.except ..definition_has_not_been_exported def_name))))
-
- {.#Tag _}
- (/.except ..labels_are_not_definitions [def_name])
-
- {.#Slot _}
- (/.except ..labels_are_not_definitions [def_name])))))
+ (/.except ..definition_has_not_been_exported def_name))))))))
(def (variable var_name)
(-> Text (Operation (Maybe Analysis)))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/when.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/when.lux
index 84fd24cc2..3378f2a4c 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/when.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/analysis/when.lux
@@ -160,7 +160,7 @@
(def (tuple_pattern_analysis pattern_analysis :input: sub_patterns next)
(All (_ a)
- (-> (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a]))
+ (-> (-> Type Code (Operation a) (Operation [Pattern a]))
Type (List Code) (Operation a) (Operation [Pattern a])))
(do [! ///.monad]
[[@ex_var+ :input:'] (/type.check (..tuple :input:))]
@@ -194,9 +194,9 @@
(Operation [(List Pattern) a])))
(function (_ [memberT memberC] then)
(do !
- [[memberP [memberP+ thenA]] ((as (All (_ a) (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a])))
+ [[memberP [memberP+ thenA]] ((as (All (_ a) (-> Type Code (Operation a) (Operation [Pattern a])))
pattern_analysis)
- {.#None} memberT memberC then)]
+ memberT memberC then)]
(in [(list.partial memberP memberP+) thenA]))))
(do !
[nextA next]
@@ -225,8 +225,8 @@
... body expressions.
... That is why the body must be analysed in the context of the
... pattern, and not separately.
-(def (pattern_analysis num_tags :input: pattern next)
- (All (_ a) (-> (Maybe Nat) Type Code (Operation a) (Operation [Pattern a])))
+(def (pattern_analysis :input: pattern next)
+ (All (_ a) (-> Type Code (Operation a) (Operation [Pattern a])))
(.when pattern
[location {.#Symbol ["" name]}]
(/.with_location location
@@ -248,7 +248,7 @@
[Any {.#Tuple {.#End}} {/simple.#Unit}])
[location {.#Tuple (list singleton)}]
- (pattern_analysis {.#None} :input: singleton next)
+ (pattern_analysis :input: singleton next)
[location {.#Tuple sub_patterns}]
(/.with_location location
@@ -276,7 +276,7 @@
(in []))]
(.when members
(list singleton)
- (pattern_analysis {.#None} :input: singleton next)
+ (pattern_analysis :input: singleton next)
_
(..tuple_pattern_analysis pattern_analysis :input: members next)))
@@ -292,19 +292,17 @@
{.#Sum _}
(let [flat_sum (type.flat_variant :input:')
size_sum (list.size flat_sum)
- num_cases (maybe.else size_sum num_tags)
idx (/complex.tag right? lefts)]
(.when (list.item idx flat_sum)
(^.multi {.#Some caseT}
- (n.< num_cases idx))
+ (n.< size_sum idx))
(do ///.monad
- [[testP nextA] (if (and (n.> num_cases size_sum)
- (n.= (-- num_cases) idx))
- (pattern_analysis {.#None}
- (type.variant (list.after (-- num_cases) flat_sum))
+ [[testP nextA] (if (and (n.> size_sum size_sum)
+ (n.= (-- size_sum) idx))
+ (pattern_analysis (type.variant (list.after (-- size_sum) flat_sum))
(` [(,* values)])
next)
- (pattern_analysis {.#None} caseT (` [(,* values)]) next))
+ (pattern_analysis caseT (` [(,* values)]) next))
_ (/type.check (monad.each check.monad check.forget! @ex_var+))]
(in [(/pattern.variant [lefts right? testP])
nextA]))
@@ -315,8 +313,7 @@
{.#UnivQ _}
(do ///.monad
[[ex_id exT] (/type.check check.existential)
- it (pattern_analysis num_tags
- (maybe.trusted (type.applied (list exT) :input:'))
+ it (pattern_analysis (maybe.trusted (type.applied (list exT) :input:'))
pattern
next)
_ (/type.check (monad.each check.monad check.forget! @ex_var+))]
@@ -329,10 +326,15 @@
(/.with_location location
(do ///.monad
[tag (///extension.lifted (meta.normal tag))
- [idx group variantT] (///extension.lifted (meta.tag tag))
- _ (/type.check (check.check :input: variantT))
- .let [[lefts right?] (/complex.choice (list.size group) idx)]]
- (pattern_analysis {.#Some (list.size group)} :input: (` {(, (code.nat lefts)) (, (code.bit right?)) (,* values)}) next)))
+ [lefts,right? variantT] (///extension.lifted (meta.tag tag))
+ [lefts right?] (in (.when lefts,right?
+ {.#Some [lefts right? family]}
+ [lefts right?]
+
+ {.#None}
+ [0 false]))
+ _ (/type.check (check.check :input: variantT))]
+ (pattern_analysis :input: (` {(, (code.nat lefts)) (, (code.bit right?)) (,* values)}) next)))
_
(/.except ..invalid [pattern])
@@ -345,10 +347,10 @@
(do [! ///.monad]
[[:input: inputA] (<| /type.inferring
(analyse archive inputC))
- outputH (pattern_analysis {.#None} :input: patternH (analyse archive bodyH))
+ outputH (pattern_analysis :input: patternH (analyse archive bodyH))
outputT (monad.each !
(function (_ [patternT bodyT])
- (pattern_analysis {.#None} :input: patternT (analyse archive bodyT)))
+ (pattern_analysis :input: patternT (analyse archive bodyT)))
branchesT)
outputHC (|> outputH product.left /coverage.coverage /.of_try)
outputTC (monad.each ! (|>> product.left /coverage.coverage /.of_try) outputT)
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 050c6263d..2ea6deb7d 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
@@ -262,53 +262,6 @@
_
(phase.except ///.invalid_syntax [extension_name %.code inputsC+]))))
-(def (announce_labels! labels owner)
- (All (_ anchor expression declaration)
- (-> (List Text) Type (Operation anchor expression declaration (List Any))))
- (/////declaration.lifted_generation
- (monad.each phase.monad
- (function (_ tag)
- (/////generation.log! (format tag " : Tag of " (%.type owner))))
- labels)))
-
-(def (def_type_tagged expander host_analysis)
- (-> Expander /////analysis.Bundle Handler)
- (..custom
- [(all <>.and <code>.local <code>.any
- (<>.or (<code>.variant (<>.some <code>.text))
- (<code>.tuple (<>.some <code>.text)))
- <code>.any)
- (function (_ extension_name phase archive [short_name valueC labels exported?C])
- (do phase.monad
- [current_module (/////declaration.lifted_analysis
- (///.lifted meta.current_module_name))
- .let [full_name [current_module short_name]]
- [_ _ exported?] (evaluate! archive Bit exported?C)
- .let [exported? (as Bit exported?)]
- [type valueT value] (..definition archive full_name {.#Some .Type} valueC)
- labels (/////declaration.lifted_analysis
- (do phase.monad
- [.let [[record? labels] (when labels
- {.#Left tags}
- [false tags]
-
- {.#Right slots}
- [true slots])]
- _ (when labels
- {.#End}
- (moduleA.define short_name {.#Definition [exported? type value]})
-
- {.#Item labels}
- (moduleA.define short_name {.#Type [exported? (as .Type value) (if record?
- {.#Right labels}
- {.#Left labels})]}))
- _ (moduleA.declare_labels record? labels exported? (as .Type value))]
- (in labels)))
- _ (..refresh expander host_analysis)
- _ (..announce_definition! short_name type)
- _ (..announce_labels! labels (as Type value))]
- (in /////declaration.no_requirements)))]))
-
(def imports
(Parser (List Import))
(|> (<code>.tuple (<>.and <code>.text <code>.text))
@@ -339,12 +292,6 @@
["Foreign alias" (%.symbol foreign)]
["Target definition" (%.symbol target)])))
-(exception.def .public (cannot_alias_a_label [local foreign])
- (Exception [Alias Alias])
- (exception.report
- (list ["Alias" (%.symbol local)]
- ["Label" (%.symbol foreign)])))
-
(def (define_alias alias original)
(-> Text Symbol (/////analysis.Operation Any))
(do phase.monad
@@ -354,13 +301,8 @@
{.#Alias de_aliased}
(phase.except ..cannot_alias_an_alias [[current_module alias] original de_aliased])
- (^.or {.#Definition _}
- {.#Type _})
- (moduleA.define alias {.#Alias original})
-
- (^.or {.#Tag _}
- {.#Slot _})
- (phase.except ..cannot_alias_a_label [[current_module alias] original]))))
+ {.#Definition _}
+ (moduleA.define alias {.#Alias original}))))
(def defalias
Handler
@@ -491,7 +433,6 @@
(|> ///bundle.empty
(dictionary.has "module" defmodule)
(dictionary.has "alias" defalias)
- (dictionary.has "type tagged" (def_type_tagged expander host_analysis))
(dictionary.has "analysis" (def_analysis anchorT,expressionT,declarationT extender))
(dictionary.has "synthesis" (def_synthesis anchorT,expressionT,declarationT extender))
(dictionary.has "generation" (def_generation anchorT,expressionT,declarationT extender))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux
index 29b3604b8..377e232b1 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/synthesis.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Scope i64)
+ [lux (.except Scope #Function #Apply #locals i64)
[abstract
[monad (.only do)]
[equivalence (.only Equivalence)]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/synthesis/simple.lux b/stdlib/source/library/lux/meta/compiler/language/lux/synthesis/simple.lux
index a44021d1f..80d6447b9 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/synthesis/simple.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/synthesis/simple.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except #Bit #Text)
[abstract
[equivalence (.only Equivalence)]
[hash (.only Hash)]]
diff --git a/stdlib/source/library/lux/meta/compiler/meta/archive.lux b/stdlib/source/library/lux/meta/compiler/meta/archive.lux
index 994b6cd4b..46ede92f0 100644
--- a/stdlib/source/library/lux/meta/compiler/meta/archive.lux
+++ b/stdlib/source/library/lux/meta/compiler/meta/archive.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Module has)
+ [lux (.except Module #module has)
[abstract
["[0]" equivalence (.only Equivalence)]
["[0]" monad (.only do)]]
diff --git a/stdlib/source/library/lux/meta/compiler/meta/archive/artifact/category.lux b/stdlib/source/library/lux/meta/compiler/meta/archive/artifact/category.lux
index 0afb9adc5..5c547a425 100644
--- a/stdlib/source/library/lux/meta/compiler/meta/archive/artifact/category.lux
+++ b/stdlib/source/library/lux/meta/compiler/meta/archive/artifact/category.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Definition)
+ [lux (.except Definition #Definition)
[abstract
[equivalence (.only Equivalence)]]
[control
diff --git a/stdlib/source/library/lux/meta/compiler/meta/archive/signature.lux b/stdlib/source/library/lux/meta/compiler/meta/archive/signature.lux
index e9220d028..5d3ff086c 100644
--- a/stdlib/source/library/lux/meta/compiler/meta/archive/signature.lux
+++ b/stdlib/source/library/lux/meta/compiler/meta/archive/signature.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except #version)
[abstract
[equivalence (.only Equivalence)]]
[control
diff --git a/stdlib/source/library/lux/meta/compiler/meta/archive/unit.lux b/stdlib/source/library/lux/meta/compiler/meta/archive/unit.lux
index 82d29c16b..5f7b20e00 100644
--- a/stdlib/source/library/lux/meta/compiler/meta/archive/unit.lux
+++ b/stdlib/source/library/lux/meta/compiler/meta/archive/unit.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except #module)
[abstract
[equivalence (.only Equivalence)]
[hash (.only Hash)]]
diff --git a/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/module.lux b/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/module.lux
index 60e4af536..9b8f0934a 100644
--- a/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/module.lux
+++ b/stdlib/source/library/lux/meta/compiler/meta/cache/dependency/module.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except #module #imports)
[abstract
["[0]" monad (.only do)]]
[control
diff --git a/stdlib/source/library/lux/meta/compiler/meta/cli.lux b/stdlib/source/library/lux/meta/compiler/meta/cli.lux
index 37adb69f4..1c590b24b 100644
--- a/stdlib/source/library/lux/meta/compiler/meta/cli.lux
+++ b/stdlib/source/library/lux/meta/compiler/meta/cli.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Module Source)
+ [lux (.except Module Source #module #target #configuration)
[abstract
[monad (.only do)]
[equivalence (.only Equivalence)]]
diff --git a/stdlib/source/library/lux/meta/compiler/meta/context.lux b/stdlib/source/library/lux/meta/compiler/meta/context.lux
index 668d828e2..ef520917a 100644
--- a/stdlib/source/library/lux/meta/compiler/meta/context.lux
+++ b/stdlib/source/library/lux/meta/compiler/meta/context.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except #host #target)
[meta
["@" target (.only Target)]]
[world
diff --git a/stdlib/source/library/lux/meta/compiler/meta/io/archive.lux b/stdlib/source/library/lux/meta/compiler/meta/io/archive.lux
index 29b8539ac..1d1aaca4b 100644
--- a/stdlib/source/library/lux/meta/compiler/meta/io/archive.lux
+++ b/stdlib/source/library/lux/meta/compiler/meta/io/archive.lux
@@ -221,12 +221,8 @@
content (document.content $.key document)
definitions (monad.each ! (function (_ [def_name def_global])
(when def_global
- (^.with_template [<tag>]
- [{<tag> payload}
- (in [def_name {<tag> payload}])])
- ([.#Alias]
- [.#Tag]
- [.#Slot])
+ {.#Alias payload}
+ (in [def_name def_global])
{.#Definition [exported? type _]}
(|> definitions
@@ -234,14 +230,7 @@
try.of_maybe
(at ! each (|>> [exported? type]
{.#Definition}
- [def_name])))
-
- {.#Type [exported? _ labels]}
- (|> definitions
- (dictionary.value def_name)
- try.of_maybe
- (at ! each (function (_ def_value)
- [def_name {.#Type [exported? (as .Type def_value) labels]}])))))
+ [def_name])))))
(the .#definitions content))]
(in [(document.document $.key (has .#definitions definitions content))
bundles])))
diff --git a/stdlib/source/library/lux/meta/compiler/phase.lux b/stdlib/source/library/lux/meta/compiler/phase.lux
index b5d04c40e..77574a4aa 100644
--- a/stdlib/source/library/lux/meta/compiler/phase.lux
+++ b/stdlib/source/library/lux/meta/compiler/phase.lux
@@ -108,7 +108,7 @@
(try#each (|>> [state]) error)))
(def .public assertion
- (template (assertion exception message test)
+ (template (_ exception message test)
[(if test
(at ..monad in [])
(..except exception message))]))
diff --git a/stdlib/source/library/lux/meta/compiler/reference/variable.lux b/stdlib/source/library/lux/meta/compiler/reference/variable.lux
index 0e038ed06..7de1dee16 100644
--- a/stdlib/source/library/lux/meta/compiler/reference/variable.lux
+++ b/stdlib/source/library/lux/meta/compiler/reference/variable.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except #Local)
[abstract
[equivalence (.only Equivalence)]
[hash (.only Hash)]]
diff --git a/stdlib/source/library/lux/meta/target/jvm/attribute.lux b/stdlib/source/library/lux/meta/target/jvm/attribute.lux
index c6ff2472f..21578c4e5 100644
--- a/stdlib/source/library/lux/meta/target/jvm/attribute.lux
+++ b/stdlib/source/library/lux/meta/target/jvm/attribute.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Info Code Type)
+ [lux (.except Info Code Type #info)
[abstract
[monad (.only do)]
["[0]" equivalence (.only Equivalence)]]
diff --git a/stdlib/source/library/lux/meta/target/jvm/constant.lux b/stdlib/source/library/lux/meta/target/jvm/constant.lux
index d05df9511..7c23d49c7 100644
--- a/stdlib/source/library/lux/meta/target/jvm/constant.lux
+++ b/stdlib/source/library/lux/meta/target/jvm/constant.lux
@@ -23,7 +23,7 @@
["^" pattern]
["[0]" template]]
[type
- [primitive (.except)]]]]]
+ [primitive (.except #name)]]]]]
["[0]" /
["[1][0]" tag]
["/[1]" //
diff --git a/stdlib/source/library/lux/meta/target/jvm/constant/tag.lux b/stdlib/source/library/lux/meta/target/jvm/constant/tag.lux
index bcd1d4209..f6917a5d0 100644
--- a/stdlib/source/library/lux/meta/target/jvm/constant/tag.lux
+++ b/stdlib/source/library/lux/meta/target/jvm/constant/tag.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except)
+ [lux (.except Tag)
[abstract
[equivalence (.only Equivalence)]]
[control
diff --git a/stdlib/source/library/lux/meta/target/jvm/type.lux b/stdlib/source/library/lux/meta/target/jvm/type.lux
index f9944b0eb..aabf16518 100644
--- a/stdlib/source/library/lux/meta/target/jvm/type.lux
+++ b/stdlib/source/library/lux/meta/target/jvm/type.lux
@@ -16,7 +16,7 @@
["n" nat]]]
[meta
[type
- [primitive (.except)]]]]]
+ [primitive (.except #name)]]]]]
["[0]" //
[encoding
["[1][0]" name (.only External)]]]
diff --git a/stdlib/source/library/lux/meta/type/implicit.lux b/stdlib/source/library/lux/meta/type/implicit.lux
index df5da5767..f265ac780 100644
--- a/stdlib/source/library/lux/meta/type/implicit.lux
+++ b/stdlib/source/library/lux/meta/type/implicit.lux
@@ -99,13 +99,13 @@
tag_lists)]]
(when candidates
{.#End}
- (///.failure (format "Unknown tag: " (%.symbol member)))
+ (///.failure (format "Unknown slot: " (%.symbol member)))
{.#Item winner {.#End}}
(in winner)
_
- (///.failure (format "Too many candidate tags: " (%.list %.symbol candidates))))))
+ (///.failure (format "Too many candidate slots: " (%.list %.symbol candidates))))))
_
(at ///.monad in member)))
@@ -114,8 +114,16 @@
(-> Symbol (Meta [Nat Type]))
(do ///.monad
[member (member_name member)
- [idx tag_list sig_type] (///.slot member)]
- (in [idx sig_type])))
+ [lefts,right? sig_type] (///.slot member)]
+ (when lefts,right?
+ {.#Some [lefts right? family]}
+ (in [(if right?
+ (++ lefts)
+ lefts)
+ sig_type])
+
+ {.#None}
+ (in [0 sig_type]))))
(def (compatible_type? interface candidate)
(-> Type Type Bit)
diff --git a/stdlib/source/library/lux/meta/type/row.lux b/stdlib/source/library/lux/meta/type/row.lux
index 1966a4768..a51add3cd 100644
--- a/stdlib/source/library/lux/meta/type/row.lux
+++ b/stdlib/source/library/lux/meta/type/row.lux
@@ -1,7 +1,7 @@
... https://en.wikipedia.org/wiki/Row_polymorphism
(.require
[library
- [lux (.except macro type the has revised)
+ [lux (.except Slot macro type the has revised)
[abstract
["[0]" monad (.only do)]]
[control