Skip to content

Commit

Permalink
Adapting to new List type (part 6).
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Mar 18, 2024
1 parent 8084df9 commit d69eacf
Show file tree
Hide file tree
Showing 190 changed files with 2,141 additions and 1,931 deletions.
10 changes: 6 additions & 4 deletions stdlib/source/injection/lux/data/binary.lux
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
[encoding
["[0]" utf8]]]
[collection
["[0]" list]
["[0]" stack]
["[0]" sequence (.only Sequence) (.use "[1]#[0]" functor)]
["[0]" set (.only Set)]
Expand Down Expand Up @@ -223,9 +224,9 @@
value (if (n#= original_count capped_count)
value
(|> value
sequence.as_stack
(stack.first capped_count)
sequence.of_stack))
sequence.as_list
(list.first capped_count)
sequence.of_list))
(open "specification#[0]") ..monoid
specification/* (sequence#each valueW value)
size (|> specification/*
Expand Down Expand Up @@ -267,7 +268,8 @@
(for_any (_ it)
(-> (Injection it)
(Injection (Set it))))
(|>> set.stack
(|>> set.as_list
list.as_stack
(..stack value)))

(the .public name
Expand Down
57 changes: 30 additions & 27 deletions stdlib/source/library/lux/compiler/default/init.lux
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
["[0]" product]
["[0]" text (.use "[1]#[0]" hash)]
[collection
["[0]" list (.use "[1]#[0]" functor)]
["[0]" stack (.use "[1]#[0]" functor)]
["[0]" dictionary]
["[0]" set]
Expand Down Expand Up @@ -109,10 +110,10 @@
(do [! phase.monad]
[_ (|> bundle
dictionary.entries
(stack.each' !
(function (_ [name handler])
(///declaration.of_analysis
(moduleA.override_definition [.prelude name] [true {.#Default [.Analysis handler]}])))))]
(list.each' !
(function (_ [name handler])
(///declaration.of_analysis
(moduleA.override_definition [.prelude name] [true {.#Default [.Analysis handler]}])))))]
(in [])))

(the (with_synthesis_defaults bundle)
Expand All @@ -121,10 +122,10 @@
(do [! phase.monad]
[_ (|> bundle
dictionary.entries
(stack.each' !
(function (_ [name handler])
(///declaration.of_analysis
(moduleA.override_definition [.prelude name] [true {.#Default [.Synthesis handler]}])))))]
(list.each' !
(function (_ [name handler])
(///declaration.of_analysis
(moduleA.override_definition [.prelude name] [true {.#Default [.Synthesis handler]}])))))]
(in [])))

(the (with_translation_defaults bundle)
Expand All @@ -134,10 +135,10 @@
(do [! phase.monad]
[_ (|> bundle
dictionary.entries
(stack.each' !
(function (_ [name handler])
(///declaration.of_analysis
(moduleA.override_definition [.prelude name] [true {.#Default [.Translation handler]}])))))]
(list.each' !
(function (_ [name handler])
(///declaration.of_analysis
(moduleA.override_definition [.prelude name] [true {.#Default [.Translation handler]}])))))]
(in [])))

(the (with_declaration_defaults bundle)
Expand All @@ -147,12 +148,12 @@
(do [! phase.monad]
[_ (|> bundle
dictionary.entries
(stack.each' !
(function (_ [name handler])
(do !
[_ (///declaration.of_analysis
(moduleA.override_definition [.prelude name] [true {.#Default [.Declaration handler]}]))]
(in [])))))]
(list.each' !
(function (_ [name handler])
(do !
[_ (///declaration.of_analysis
(moduleA.override_definition [.prelude name] [true {.#Default [.Declaration handler]}]))]
(in [])))))]
(in [])))

(every .public (Extensions anchor expression declaration)
Expand Down Expand Up @@ -180,7 +181,7 @@

(the (begin dependencies hash input all_extensions)
(for_any (_ anchor expression declaration)
(-> (Stack descriptor.Module) Natural ///.Input
(-> (List descriptor.Module) Natural ///.Input
(Extensions anchor expression declaration)
(///declaration.Operation anchor expression declaration
[Source (Payload declaration)])))
Expand All @@ -192,7 +193,7 @@
_ (with_defaults module all_extensions)]
(///declaration.of_analysis
(do [! phase.monad]
[_ (stack.each' ! moduleA.import dependencies)
[_ (list.each' ! moduleA.import dependencies)
.let [source (///analysis.source (its ///.#module input) (its ///.#code input))]
_ (///analysis.set_source_code source)]
(in [source [///translation.empty_buffer
Expand Down Expand Up @@ -275,15 +276,17 @@
(exception.with ///.cannot_compile module {try.#Failure error}))))))

(the (default_dependencies prelude input)
(-> descriptor.Module ///.Input (Stack descriptor.Module))
(stack.partial descriptor.runtime
(if (text.= prelude (its ///.#module input))
(stack)
(stack prelude))))
(-> descriptor.Module ///.Input
(List descriptor.Module))
(if (text.= prelude (its ///.#module input))
(list descriptor.runtime)
(list descriptor.runtime prelude)))

(the module_aliases
(-> .Module Aliases)
(|>> (its .#module_aliases) (dictionary.of_stack text.hash)))
(|>> (its .#module_aliases)
list.of_stack
(dictionary.of_list text.hash)))

(expansion.let [<parameters> (these anchor expression declaration)]
(these (the (define_program! archive program global program_module program_definition)
Expand Down Expand Up @@ -341,7 +344,7 @@
.let [descriptor [descriptor.#hash hash
descriptor.#name module
descriptor.#file (its ///.#file input)
descriptor.#references (set.of_stack text.hash dependencies)
descriptor.#references (set.of_list text.hash dependencies)
descriptor.#state {.#Compiled}]]]
(in [state
{.#Right [[moduleM.#id (try.else moduleM.runtime (archive.id module archive))
Expand Down
28 changes: 16 additions & 12 deletions stdlib/source/library/lux/compiler/default/platform.lux
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
["[0]" dictionary (.only Dictionary)]
["[0]" sequence (.only Sequence) (.use "[1]#[0]" mix)]
["[0]" set (.only Set)]
["[0]" list (.use "[1]#[0]" monoid functor mix)]
["[0]" stack (.use "[1]#[0]" monoid functor mix)]]]
[macro
["[0]" expansion]]
Expand Down Expand Up @@ -128,14 +129,16 @@
(cache/module.enable! future.monad system @module))
_ (for .python (|> entry
(its archive.#output)
sequence.as_stack
sequence.as_list
list.as_stack
(stack.sub 128)
(stack.each' ! (stack.each' ! write_artifact!))
(is (Action (Stack (Stack Any)))))
(|> entry
(its archive.#output)
sequence.as_stack
(stack.each' ..monad write_artifact!)
sequence.as_list
list.as_stack
(list.each' ..monad write_artifact!)
(is (Action (Stack Any)))))
document (by future.monad in
(document.marked? key (its [archive.#module moduleM.#document] entry)))]
Expand Down Expand Up @@ -301,10 +304,10 @@
(|> mapping
(dictionary.revised' source ..empty (set.has target))
(dictionary.revised source (set.union forward)))]
(stack#mix (function (_ previous)
(dictionary.revised' previous ..empty (set.has target)))
with_dependence+transitives
(set.stack backward))))))]
(list#mix (function (_ previous)
(dictionary.revised' previous ..empty (set.has target)))
with_dependence+transitives
(set.as_list backward))))))]
(|> dependence
(revised #depends_on
(update_dependence
Expand Down Expand Up @@ -344,7 +347,7 @@
(Exception [descriptor.Module (Set descriptor.Module)])
(exception.report
(list ["Importer" (%.text importer)]
["Duplicates" (%.stack %.text (set.stack duplicates))])))
["Duplicates" (list.as_text %.text (set.as_list duplicates))])))

(the (verify_dependencies importer importee dependence)
(-> descriptor.Module descriptor.Module Dependence
Expand Down Expand Up @@ -495,8 +498,9 @@
(in [module lux_module])))
(archive.archived archive))
.let [additions (|> modules
(stack#each product.left)
(set.of_stack text.hash))
list.of_stack
(list#each product.left)
(set.of_list text.hash))
with_modules (is (for_any (_ <type_vars>)
(-> <State>
<State>))
Expand Down Expand Up @@ -626,7 +630,7 @@
(loop (again [[archive state] [archive state]
compilation custom_compilation
all_dependencies (is (Set descriptor.Module)
(set.of_stack text.hash (stack)))])
(set.empty text.hash))])
(do [! ..monad]
[.let [new_dependencies (its ///.#dependencies compilation)
[all_dependencies duplicates] (with_new_dependencies new_dependencies all_dependencies)]
Expand Down Expand Up @@ -691,7 +695,7 @@
(loop (again [[archive state] [archive (..set_current_module module state)]
compilation compilation
all_dependencies (is (Set descriptor.Module)
(set.of_stack text.hash (stack)))])
(set.empty text.hash))])
(do [! ..monad]
[.let [new_dependencies (its ///.#dependencies compilation)
[all_dependencies duplicates] (with_new_dependencies new_dependencies all_dependencies)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@
(,, (template.with [<tag> <injection>]
[{<tag> it}
(|> it
set.stack
(stack#each <injection>)
set.as_list
(list#each <injection>)
list.as_stack
(text.interposed " ")
(text.enclosed ["[" "]"]))]

Expand Down Expand Up @@ -201,7 +202,7 @@
... are too many possibilities as far as values go.
(,, (template.with [<from> <to> <hash>]
[{//pattern.#Simple {<from> it}}
{try.#Success {<to> (set.of_stack <hash> (stack it))}}]
{try.#Success {<to> (set.of_list <hash> (list it))}}]

[//simple.#Natural #Natural n.hash]
[//simple.#Integer #Integer i.hash]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,15 @@

(the .public boxes
(Dictionary external.Name [external.Name (Type Primitive)])
(|> (stack [(reflection.reflection reflection.boolean) [box.boolean jvm.boolean]]
[(reflection.reflection reflection.byte) [box.byte jvm.byte]]
[(reflection.reflection reflection.short) [box.short jvm.short]]
[(reflection.reflection reflection.int) [box.int jvm.int]]
[(reflection.reflection reflection.long) [box.long jvm.long]]
[(reflection.reflection reflection.float) [box.float jvm.float]]
[(reflection.reflection reflection.double) [box.double jvm.double]]
[(reflection.reflection reflection.char) [box.char jvm.char]])
(dictionary.of_stack text.hash)))
(|> (list [(reflection.reflection reflection.boolean) [box.boolean jvm.boolean]]
[(reflection.reflection reflection.byte) [box.byte jvm.byte]]
[(reflection.reflection reflection.short) [box.short jvm.short]]
[(reflection.reflection reflection.int) [box.int jvm.int]]
[(reflection.reflection reflection.long) [box.long jvm.long]]
[(reflection.reflection reflection.float) [box.float jvm.float]]
[(reflection.reflection reflection.double) [box.double jvm.double]]
[(reflection.reflection reflection.char) [box.char jvm.char]])
(dictionary.of_list text.hash)))

(the lux_array_type
(template.macro (_ :read: :write:)
Expand Down Expand Up @@ -1287,24 +1287,27 @@
{.#Parameter}))

(the (jvm_type_var_mapping owner_tvars method_tvars)
(-> (Stack Text) (Stack Text)
[(Stack .Type) Mapping])
(let [jvm_tvars (stack#composite owner_tvars method_tvars)
(-> (List Text) (List Text)
[(List .Type) Mapping])
(let [jvm_tvars (list#composite owner_tvars method_tvars)
lux_tvars (|> jvm_tvars
stack.reversed
stack.enumeration
(stack#each (function (_ [idx name])
[name (index_parameter idx)]))
stack.reversed)
num_owner_tvars (stack.size owner_tvars)
owner_tvarsT (|> lux_tvars (stack.first num_owner_tvars) (stack#each product.right))
mapping (dictionary.of_stack text.hash lux_tvars)]
list.reversed
list.enumeration
(list#each (function (_ [idx name])
[name (index_parameter idx)]))
list.reversed)
num_owner_tvars (list.size owner_tvars)
owner_tvarsT (|> lux_tvars
(list.first num_owner_tvars)
(list#each product.right))
mapping (dictionary.of_list text.hash lux_tvars)]
[owner_tvarsT mapping]))

(the (lux_class it)
(-> (java/lang/Class java/lang/Object)
(Type Class))
(jvm.class (stack) (ffi.of_string (java/lang/Class::getName [] it))))
(jvm.class (stack)
(ffi.of_string (java/lang/Class::getName [] it))))

(template.with [<name> <type> <params>]
[(`` (the <name>
Expand Down Expand Up @@ -1469,11 +1472,11 @@
)

(the (aliasing expected actual)
(-> (Stack (Type Var)) (Stack (Type Var))
(-> (List (Type Var)) (List (Type Var))
Aliasing)
(|> (stack.zipped_2 (stack#each projection.name actual)
(stack#each projection.name expected))
(dictionary.of_stack text.hash)))
(|> (list.zipped_2 (list#each projection.name actual)
(list#each projection.name expected))
(dictionary.of_list text.hash)))

(the (family_tree' it)
(-> (java/lang/Class java/lang/Object)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1271,8 +1271,7 @@
(|> global_mapping
(dictionary.value capture)
try.trusted)]))
list.as_stack
(dictionary.of_stack synthesis.hash))]
(dictionary.of_list synthesis.hash))]
[ownerT name
strict_fp? annotations vars
self_name arguments returnT exceptionsT
Expand All @@ -1282,13 +1281,15 @@
(-> (Stack [(Environment synthesis.Term) (/.Overriden_Method synthesis.Term)])
(Stack synthesis.Term))
(|> overriden_methods
list.of_stack
... Get all the environments.
(stack#each (|>> product.left list.as_stack))
(list#each product.left)
... Combine them.
stack#conjoint
list#conjoint
... Remove duplicates.
(set.of_stack synthesis.hash)
set.stack))
(set.of_list synthesis.hash)
set.as_list
list.as_stack))

(the (global_mapping total_environment)
(-> (List synthesis.Term)
Expand All @@ -1298,8 +1299,7 @@
list.enumeration
(list#each (function (_ [id capture])
[capture {//////variable.#Foreign id}]))
list.as_stack
(dictionary.of_stack synthesis.hash)))
(dictionary.of_list synthesis.hash)))

(the (method_definition phase archive artifact_id method)
(-> Phase Archive artifact.ID (/.Overriden_Method synthesis.Term)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
[collection
["[0]" dictionary]
["[0]" set]
["[0]" list (.use "[1]#[0]" functor mix)]
["[0]" stack (.use "[1]#[0]" functor mix)]]]
[macro
["[0]" template]]
Expand Down Expand Up @@ -73,8 +74,10 @@
(stack#each (|>> product.right synthesis.path/then //when.dependencies))
(stack.partial (//when.dependencies (synthesis.path/then else)))
stack.together
(set.of_stack _.hash)
set.stack)
list.of_stack
(set.of_list _.hash)
set.as_list
list.as_stack)
@expression (_.constant (reference.artifact [context_module context_artifact]))
declaration (_.define_function @expression (stack.partial (_.parameter @input) (stack#each _.reference foreigns))
(stack#mix (function (_ [test then] else)
Expand Down
Loading

0 comments on commit d69eacf

Please sign in to comment.