Skip to content

Commit

Permalink
New type for Lux (part 7).
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Apr 30, 2024
1 parent 205136e commit e0b5643
Show file tree
Hide file tree
Showing 20 changed files with 484 additions and 464 deletions.
18 changes: 9 additions & 9 deletions stdlib/source/library/lux/documentation.lux
Original file line number Diff line number Diff line change
Expand Up @@ -696,13 +696,13 @@
(text.of_character 31))

(the coverage_text
(-> (Stack Text)
(-> (List Text)
Text)
(stack#mix (function (_ proper aggregate)
(when aggregate
"" proper
_ (text aggregate ..coverage_delimiter proper)))
""))
(list#mix (function (_ proper aggregate)
(when aggregate
"" proper
_ (text aggregate ..coverage_delimiter proper)))
""))

(the (exported_non_default? [name [exported? global]])
(-> [Text [Bit Global]]
Expand All @@ -719,13 +719,13 @@
description ?list.any])
(do [! meta.monad]
[coverage (|> (binding.globals name)
(by ! each (|>> (stack.only exported_non_default?)
(stack#each product.left))))
(by ! each (|>> (list.only exported_non_default?)
(list#each product.left))))
dependees (import.all name)]
(in (list (` (is Documentation
{#Module [..#module (, (code.text name))
..#description (, description)
..#dependees (|> (list (,* (list.of_stack (stack#each code.text dependees))))
..#dependees (|> (list (,* (list#each code.text dependees)))
(set.of_list text.hash))
..#coverage (|> (, (code.text (..coverage_text coverage)))
(text.all_split_by (,, (static ..coverage_delimiter)))
Expand Down
14 changes: 7 additions & 7 deletions stdlib/source/library/lux/function/polymorphism/aspect.lux
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
["%" \\injection]]
[collection
["[0]" list (.use "[1]#[0]" mix)
["?[1]" \\projection]]
["[0]" stack (.use "[1]#[0]" mix)
["[0]" property]]]]
["?[1]" \\projection]
["[0]" property]]
["[0]" stack (.use "[1]#[0]" mix)]]]
["[0]" macro (.only)
["^" pattern]
["[0]" syntax]
Expand Down Expand Up @@ -118,13 +118,13 @@
(-> Name
(analysis.Operation Any))
(function (_ lux)
(let [without_global (is (-> (property.Stack [Bit .Global]) (property.Stack [Bit .Global]))
(let [without_global (is (Change (property.List [Bit .Global]))
(property.lacks proper))
without_global (is (-> .Module .Module)
without_global (is (Change .Module)
(revised .#definitions without_global))
without_global (is (-> (property.Stack .Module) (property.Stack .Module))
without_global (is (Change (property.List .Module))
(property.revised module without_global))
without_global (is (-> Lux Lux)
without_global (is (Change Lux)
(revised .#modules without_global))]
{.#Right [(without_global lux)
[]]})))
Expand Down
2 changes: 1 addition & 1 deletion stdlib/source/library/lux/macro/local.lux
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
(do meta.monad
[[module_name definition_name] (binding.normal name)
.let [definition (is Global {.#Definition [.Macro macro]})
add_macro! (is (-> (property.List [Bit Global]) (property.List [Bit Global]))
add_macro! (is (Change (property.List [Bit Global]))
(property.has definition_name [false definition]))]]
(..with_module module_name
(function (_ module)
Expand Down
10 changes: 5 additions & 5 deletions stdlib/source/library/lux/meta/global.lux
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
["%" \\injection]]
[collection
["[0]" list (.only)
["?[1]" \\projection]]
["[0]" stack (.use "[1]#[0]" functor mix)
["[0]" property]]]]
["?[1]" \\projection]
["[0]" property]]
["[0]" stack (.use "[1]#[0]" functor mix)]]]
["[0]" macro (.only)
["[0]" syntax]]
["[0]" meta (.only)
Expand All @@ -35,7 +35,7 @@
(function (_ lux)
{.#Right [(|> lux
(revised .#modules
(is (Change (property.Stack .Module))
(is (Change (property.List .Module))
(property.revised module (is (Change .Module)
(function (_ module)
(|> (do maybe.monad
Expand All @@ -57,7 +57,7 @@
(function (_ lux)
{.#Right [(|> lux
(revised .#modules
(is (Change (property.Stack .Module))
(is (Change (property.List .Module))
(property.revised module (is (Change .Module)
(function (_ module)
(|> (do maybe.monad
Expand Down
1 change: 0 additions & 1 deletion stdlib/source/library/lux/test/unit.lux
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@
[.let [module (name.module module)]
definitions (binding.resolved_globals module)
.let [coverage (|> definitions
list.of_stack
(list.all (function (_ [proper [exported? _]])
(if exported?
{.#Some proper}
Expand Down
37 changes: 19 additions & 18 deletions stdlib/source/library/lux/type/implicit.lux
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
["%" \\injection]]
[collection
["[0]" list (.use "[1]#[0]" monad mix)
["?[1]" \\projection]]
["?[1]" \\projection]
["[0]" property]]
["[0]" stack (.use "[1]#[0]" monad mix)]
["[0]" dictionary (.only Dictionary)]]]
[math
Expand All @@ -43,8 +44,8 @@
(the (type_var id env)
(-> Natural Type_Context
(Meta Type))
(when (stack.example (|>> product.left (n.= id))
(its .#var_bindings env))
(when (list.example (|>> product.left (n.= id))
(its .#var_bindings env))
{try.#Success [_ {.#Some type}]}
(when type
{.#Variable id'}
Expand Down Expand Up @@ -110,8 +111,8 @@
(do [! meta.monad]
[[this_module_name _] module.current
imp_mods (import.all this_module_name)
tag_stacks (stack.each' ! label.tag_stacks imp_mods)
.let [tag_stacks (|> tag_stacks stack#conjoint (stack#each product.left) stack#conjoint)
tag_stacks (list.each' ! label.tag_stacks imp_mods)
.let [tag_stacks (|> tag_stacks list.as_stack stack#conjoint (stack#each product.left) stack#conjoint)
candidates (stack.only (|>> product.right (text.= simple_name))
tag_stacks)]]
(when candidates
Expand Down Expand Up @@ -162,16 +163,16 @@
<found?>)))

(the (available_definitions sig_type source_module target_module constants aggregate)
(-> Type Text Text (Stack [Text [Bit Definition]])
(-> (Stack [Name Type]) (Stack [Name Type])))
(stack#mix (function (_ [name [exported? [def_type def_value]]] aggregate)
(if (and (or (text.= target_module source_module)
exported?)
(compatible_type? sig_type def_type))
{.#Top [[source_module name] def_type] aggregate}
aggregate))
aggregate
constants))
(-> Type Text Text (property.List [Bit Definition])
(Change (Stack [Name Type])))
(list#mix (function (_ [name [exported? [def_type def_value]]] aggregate)
(if (and (or (text.= target_module source_module)
exported?)
(compatible_type? sig_type def_type))
{.#Top [[source_module name] def_type] aggregate}
aggregate))
aggregate
constants))

(the (local_env sig_type)
(-> Type
Expand Down Expand Up @@ -205,12 +206,12 @@
(do [! meta.monad]
[[this_module_name _] module.current
imported_modules (import.all this_module_name)
accessible_definitions (stack.each' ! binding.resolved_globals imported_modules)]
accessible_definitions (list.each' ! binding.resolved_globals imported_modules)]
(in (list#mix (function (_ [imported_module definitions] tail)
(available_definitions sig_type imported_module this_module_name definitions tail))
{.#Empty}
(list.zipped_2 (list.of_stack imported_modules)
(list.of_stack accessible_definitions))))))
(list.zipped_2 imported_modules
accessible_definitions)))))

(the (on_argument arg func)
(-> Type Type
Expand Down
15 changes: 8 additions & 7 deletions stdlib/source/test/lux/compiler/language/lux.lux
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
["![1]" \\injection]
["?[1]" \\projection]]
[collection
["[0]" stack]]]
["[0]" stack]
["[0]" list]]]
[math
["[0]" random (.only Random) (.use "[1]#[0]" monad)]
[number
Expand Down Expand Up @@ -104,19 +105,19 @@
(Equivalence Module)
(all product.equivalence
natural.equivalence
(stack.equivalence (product.equivalence text.equivalence text.equivalence))
(stack.equivalence (all product.equivalence text.equivalence bit.equivalence global_equivalence))
(stack.equivalence text.equivalence)
(list.equivalence (product.equivalence text.equivalence text.equivalence))
(list.equivalence (all product.equivalence text.equivalence bit.equivalence global_equivalence))
(list.equivalence text.equivalence)
..module_state_equivalence
))

(the module
(Random Module)
(all random.and
random.natural
(random.stack 1 (random.and (random.upper_cased 2) (random.upper_cased 3)))
(random.stack 4 (all random.and (random.upper_cased 5) random.bit ..global))
(random.stack 6 (random.upper_cased 7))
(random.list 1 (random.and (random.upper_cased 2) (random.upper_cased 3)))
(random.list 4 (all random.and (random.upper_cased 5) random.bit ..global))
(random.list 6 (random.upper_cased 7))
..module_state
))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@

(the .public lux
Lux
[.#info [.#target ""
.#version ""
.#mode {.#Build}
.#configuration (stack)]
.#source [provenance.dummy 0 ""]
.#provenance provenance.dummy
.#current_module {.#None}
.#modules (stack)
.#scopes (stack)
.#type_context [.#ex_counter 0
.#var_counter 0
.#var_bindings (stack)]
.#expected {.#None}
.#seed 0
.#eval (as_expected [])])
[.#info [.#target ""
.#version ""
.#mode {.#Build}
.#configuration (list)]
.#source [provenance.dummy 0 ""]
.#provenance provenance.dummy
.#current_module {.#None}
.#modules (list)
.#scopes (stack)
.#type_context [.#ex_counter 0
.#var_counter 0
.#var_bindings (list)]
.#expected {.#None}
.#seed 0
.#eval (as_expected [])])

(the .public test
Test
Expand Down
72 changes: 36 additions & 36 deletions stdlib/source/test/lux/macro.lux
Original file line number Diff line number Diff line change
Expand Up @@ -81,38 +81,38 @@
current_module (name.module (name .._))]]
(in [seed
name_prefix
[.#info [.#target ""
.#version ""
.#mode {.#Build}
.#configuration (stack)]
.#source [provenance.dummy 0 ""]
.#provenance provenance.dummy
.#current_module {.#Some current_module}
.#modules (stack [macro_module
[.#module_hash 0
.#module_aliases (stack)
.#definitions (is (Stack [Text [Bit .Global]])
(stack (!global expansion.log_single!)
(!global expansion.log_complete!)
(!global expansion.log_total!)))
.#imports (stack)
.#module_state {.#Active}]]
[current_module
[.#module_hash 0
.#module_aliases (stack)
.#definitions (is (Stack [Text [Bit .Global]])
(stack (!global ..pow/2)
(!global ..pow/4)
(!global ..repeated)))
.#imports (stack)
.#module_state {.#Active}]])
.#scopes (stack)
.#type_context [.#ex_counter 0
.#var_counter 0
.#var_bindings (stack)]
.#expected {.#None}
.#seed seed
.#eval (as_expected [])]])))
[.#info [.#target ""
.#version ""
.#mode {.#Build}
.#configuration (list)]
.#source [provenance.dummy 0 ""]
.#provenance provenance.dummy
.#current_module {.#Some current_module}
.#modules (list [macro_module
[.#module_hash 0
.#module_aliases (list)
.#definitions (is (List [Text [Bit .Global]])
(list (!global expansion.log_single!)
(!global expansion.log_complete!)
(!global expansion.log_total!)))
.#imports (list)
.#module_state {.#Active}]]
[current_module
[.#module_hash 0
.#module_aliases (list)
.#definitions (is (List [Text [Bit .Global]])
(list (!global ..pow/2)
(!global ..pow/4)
(!global ..repeated)))
.#imports (list)
.#module_state {.#Active}]])
.#scopes (stack)
.#type_context [.#ex_counter 0
.#var_counter 0
.#var_bindings (list)]
.#expected {.#None}
.#seed seed
.#eval (as_expected [])]])))

(the iterated
(syntax.macro (_ [cycle <code>.natural
Expand All @@ -139,18 +139,18 @@
... [(_.coverage [<expander>]
... (|> (<expander> (` (..pow/4 (, pow/1))))
... (meta.value lux)
... (try#each (by (stack.equivalence code.equivalence) =
... (stack <expansion>)))
... (try#each (by (list.equivalence code.equivalence) =
... (list <expansion>)))
... (try.else false)))

... (_.coverage [<logger>]
... (and (|> (expansion.single (` (<logger> "omit" (..pow/4 (, pow/1)))))
... (meta.value lux)
... (try#each (by (stack.equivalence code.equivalence) = (stack)))
... (try#each (by (list.equivalence code.equivalence) = (list)))
... (try.else false))
... (|> (expansion.single (` (<logger> (..pow/4 (, pow/1)))))
... (meta.value lux)
... (try#each (by (stack.equivalence code.equivalence) = (stack <expansion>)))
... (try#each (by (list.equivalence code.equivalence) = (list <expansion>)))
... (try.else false))))]

... [expansion.single expansion.log_single! single_expansion]
Expand Down
8 changes: 3 additions & 5 deletions stdlib/source/test/lux/macro/local.lux
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@
[text
["%" \\injection]]
[collection
[stack
["[0]" property]]
["[0]" list
["?[1]" \\projection]]]]
["?[1]" \\projection]
["[0]" property]]]]
[math
["[0]" random (.only Random)]
[number
Expand Down Expand Up @@ -69,8 +68,7 @@
[pop! (/.push (list [name (..constant constant)]))
[module proper] (binding.normal name)
_ (if pre_remove
(let [remove_macro! (is (-> .Module
.Module)
(let [remove_macro! (is (Change .Module)
(revised .#definitions (property.lacks proper)))]
(function (_ lux)
{try.#Success [(revised .#modules (property.revised module remove_macro!) lux)
Expand Down
Loading

0 comments on commit e0b5643

Please sign in to comment.