diff options
Diffstat (limited to 'stdlib/source/library/lux/tool/compiler/meta')
12 files changed, 154 insertions, 146 deletions
diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/archive.lux index e1ea19e37..d326a2bbb 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive.lux @@ -77,8 +77,9 @@ (abstract: .public Archive {} - {#next ID - #resolver (Dictionary Module [ID (Maybe [Descriptor (Document Any) Output])])} + (Record + {#next ID + #resolver (Dictionary Module [ID (Maybe [Descriptor (Document Any) Output])])}) (def: next (-> Archive ID) @@ -188,8 +189,8 @@ (|>> :representation (value@ #resolver) dictionary.entries - (list\map (function (_ [module [id _]]) - [module id])))) + (list\each (function (_ [module [id _]]) + [module id])))) (def: .public (merged additions archive) (-> Archive Archive Archive) @@ -252,7 +253,7 @@ (-> (List Reservation) Bit) (n.= (list.size reservations) (|> reservations - (list\map product.left) + (list\each product.left) (set.of_list text.hash) set.size))) @@ -260,7 +261,7 @@ (-> (List Reservation) Bit) (n.= (list.size reservations) (|> reservations - (list\map product.right) + (list\each product.right) (set.of_list n.hash) set.size))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux index af69bbdc9..7a2d25b1a 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/artifact.lux @@ -25,23 +25,26 @@ Nat) (type: .public Category - #Anonymous - (#Definition Text) - (#Analyser Text) - (#Synthesizer Text) - (#Generator Text) - (#Directive Text) - (#Custom Text)) + (Variant + #Anonymous + (#Definition Text) + (#Analyser Text) + (#Synthesizer Text) + (#Generator Text) + (#Directive Text) + (#Custom Text))) (type: .public Artifact - {#id ID - #category Category}) + (Record + {#id ID + #category Category})) (abstract: .public Registry {} - {#artifacts (Row Artifact) - #resolver (Dictionary Text ID)} + (Record + {#artifacts (Row Artifact) + #resolver (Dictionary Text ID)}) (def: .public empty Registry @@ -120,7 +123,7 @@ (binary.row/64 category))] (|>> :representation (value@ #artifacts) - (row\map (value@ #category)) + (row\each (value@ #category)) artifacts))) (exception: .public (invalid_category {tag Nat}) @@ -134,7 +137,7 @@ [tag <binary>.nat] (case tag (^template [<nat> <tag> <parser>] - [<nat> (\ ! map (|>> <tag>) <parser>)]) + [<nat> (\ ! each (|>> <tag>) <parser>)]) ([0 #Anonymous <binary>.any] [1 #Definition <binary>.text] [2 #Analyser <binary>.text] @@ -145,21 +148,21 @@ _ (<>.failure (exception.error ..invalid_category [tag])))))] (|> (<binary>.row/64 category) - (\ <>.monad map (row\mix (function (_ artifact registry) - (product.right - (case artifact - #Anonymous - (..resource registry) - - (^template [<tag> <create>] - [(<tag> name) - (<create> name registry)]) - ([#Definition ..definition] - [#Analyser ..analyser] - [#Synthesizer ..synthesizer] - [#Generator ..generator] - [#Directive ..directive] - [#Custom ..custom]) - ))) - ..empty))))) + (\ <>.monad each (row\mix (function (_ artifact registry) + (product.right + (case artifact + #Anonymous + (..resource registry) + + (^template [<tag> <create>] + [(<tag> name) + (<create> name registry)]) + ([#Definition ..definition] + [#Analyser ..analyser] + [#Synthesizer ..synthesizer] + [#Generator ..generator] + [#Directive ..directive] + [#Custom ..custom]) + ))) + ..empty))))) ) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux index 59f1981bc..5a30c2c50 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/descriptor.lux @@ -19,12 +19,13 @@ Text) (type: .public Descriptor - {#name Module - #file Path - #hash Nat - #state Module_State - #references (Set Module) - #registry Registry}) + (Record + {#name Module + #file Path + #hash Nat + #state Module_State + #references (Set Module) + #registry Registry})) (def: .public writer (Writer Descriptor) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux index a14d708d5..8858eefa3 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/document.lux @@ -28,8 +28,9 @@ (abstract: .public (Document d) {} - {#signature Signature - #content d} + (Record + {#signature Signature + #content d}) (def: .public (read key document) (All [d] (-> (Key d) (Document Any) (Try d))) @@ -70,5 +71,5 @@ (def: .public parser (All [d] (-> (Parser d) (Parser (Document d)))) (|>> (<>.and signature.parser) - (\ <>.monad map (|>> :abstraction)))) + (\ <>.monad each (|>> :abstraction)))) ) diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux index 8b4dfedb8..ebe18755a 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/archive/signature.lux @@ -20,8 +20,9 @@ [version (#+ Version)]]) (type: .public Signature - {#name Name - #version Version}) + (Record + {#name Name + #version Version})) (def: .public equivalence (Equivalence Signature) diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux index e2a3ef238..9796bdcfb 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/cache/dependency.lux @@ -41,8 +41,9 @@ dictionary.keys) (type: Dependency - {#module Module - #imports Ancestry}) + (Record + {#module Module + #imports Ancestry})) (def: .public graph (-> (List Dependency) Graph) @@ -61,7 +62,7 @@ (#try.Failure error) ..fresh)] - ancestors (monad.map ! recur (set.list parents))] + ancestors (monad.each ! recur (set.list parents))] (in (list\mix set.union parents ancestors))))) ancestry (memo.open memo)] (list\mix (function (_ module memory) @@ -88,10 +89,10 @@ (|> ancestry dictionary.keys (list.sorted (..dependency? ancestry)) - (monad.map try.monad - (function (_ module) - (do try.monad - [module_id (archive.id module archive) - [descriptor document output] (archive.find module archive) - document (document.check key document)] - (in [module [module_id [descriptor document output]]]))))))) + (monad.each try.monad + (function (_ module) + (do try.monad + [module_id (archive.id module archive) + [descriptor document output] (archive.find module archive) + document (document.check key document)] + (in [module [module_id [descriptor document output]]]))))))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux index 45f489e8b..efb13c9e8 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux @@ -110,13 +110,13 @@ _ (ensure_directory fs (..versioned_lux_archive fs static))] (|> module (\ fs make_directory) - (\ ! map (|>> (case> (#try.Success output) - (#try.Success []) + (\ ! each (|>> (case> (#try.Success output) + (#try.Success []) - (#try.Failure error) - (exception.except ..cannot_prepare [(..archive fs static) - module_id - error]))))))))) + (#try.Failure error) + (exception.except ..cannot_prepare [(..archive fs static) + module_id + error]))))))))) (def: .public (write fs static module_id artifact_id content) (-> (file.System Async) Static archive.ID artifact.ID Binary (Async (Try Any))) @@ -168,12 +168,12 @@ (-> Target Archive (Try .Lux)) (do {! try.monad} [modules (: (Try (List [Module .Module])) - (monad.map ! (function (_ module) - (do ! - [[descriptor document output] (archive.find module archive) - content (document.read $.key document)] - (in [module content]))) - (archive.archived archive)))] + (monad.each ! (function (_ module) + (do ! + [[descriptor document output] (archive.find module archive) + content (document.read $.key document)] + (in [module content]))) + (archive.archived archive)))] (in (with@ #.modules modules (fresh_analysis_state host))))) (def: (cached_artifacts fs static module_id) @@ -181,15 +181,15 @@ (let [! (try.with async.monad)] (|> (..module fs static module_id) (\ fs directory_files) - (\ ! map (|>> (list\map (function (_ file) - [(file.name fs file) file])) - (list.only (|>> product.left (text\= ..module_descriptor_file) not)) - (monad.map ! (function (_ [name path]) - (|> path - (\ fs read) - (\ ! map (|>> [name]))))) - (\ ! map (dictionary.of_list text.hash)))) - (\ ! join)))) + (\ ! each (|>> (list\each (function (_ file) + [(file.name fs file) file])) + (list.only (|>> product.left (text\= ..module_descriptor_file) not)) + (monad.each ! (function (_ [name path]) + (|> path + (\ fs read) + (\ ! each (|>> [name]))))) + (\ ! each (dictionary.of_list text.hash)))) + (\ ! conjoint)))) (type: Definitions (Dictionary Text Any)) (type: Analysers (Dictionary Text analysis.Handler)) @@ -321,19 +321,19 @@ #.End (#try.Success [definitions bundles output]))))) content (document.read $.key document) - definitions (monad.map ! (function (_ [def_name def_global]) - (case def_global - (#.Alias alias) - (in [def_name (#.Alias alias)]) - - (#.Definition [exported? type annotations _]) - (|> definitions - (dictionary.value def_name) - try.of_maybe - (\ ! map (|>> [exported? type annotations] - #.Definition - [def_name]))))) - (value@ #.definitions content))] + definitions (monad.each ! (function (_ [def_name def_global]) + (case def_global + (#.Alias alias) + (in [def_name (#.Alias alias)]) + + (#.Definition [exported? type annotations _]) + (|> definitions + (dictionary.value def_name) + try.of_maybe + (\ ! each (|>> [exported? type annotations] + #.Definition + [def_name]))))) + (value@ #.definitions content))] (in [(document.write $.key (with@ #.definitions definitions content)) bundles]))) @@ -355,8 +355,8 @@ [.let [cache (..module fs static module_id)] _ (|> cache (\ fs directory_files) - (\ ! map (monad.map ! (\ fs delete))) - (\ ! join))] + (\ ! each (monad.each ! (\ fs delete))) + (\ ! conjoint))] (\ fs delete cache))) (def: (valid_cache? expected actual) @@ -409,37 +409,37 @@ (do {! (try.with async.monad)} [pre_loaded_caches (|> archive archive.reservations - (monad.map ! (function (_ [module_name module_id]) - (do ! - [data (..read_module_descriptor fs static module_id) - [descriptor document] (async\in (<binary>.result ..parser data))] - (if (text\= archive.runtime_module module_name) - (in [true - [module_name [module_id [descriptor document]]]]) - (do ! - [input (//context.read fs ..pseudo_module import contexts (value@ #static.host_module_extension static) module_name)] - (in [(..valid_cache? descriptor input) - [module_name [module_id [descriptor document]]]]))))))) + (monad.each ! (function (_ [module_name module_id]) + (do ! + [data (..read_module_descriptor fs static module_id) + [descriptor document] (async\in (<binary>.result ..parser data))] + (if (text\= archive.runtime_module module_name) + (in [true + [module_name [module_id [descriptor document]]]]) + (do ! + [input (//context.read fs ..pseudo_module import contexts (value@ #static.host_module_extension static) module_name)] + (in [(..valid_cache? descriptor input) + [module_name [module_id [descriptor document]]]]))))))) load_order (|> pre_loaded_caches - (list\map product.right) + (list\each product.right) (monad.mix try.monad (function (_ [module [module_id [descriptor document]]] archive) (archive.has module [descriptor document (: Output row.empty)] archive)) archive) - (\ try.monad map (dependency.load_order $.key)) - (\ try.monad join) + (\ try.monad each (dependency.load_order $.key)) + (\ try.monad conjoint) async\in) .let [purge (..full_purge pre_loaded_caches load_order)] _ (|> purge dictionary.entries - (monad.map ! (..purge! fs static))) + (monad.each ! (..purge! fs static))) loaded_caches (|> load_order (list.only (|>> product.left (dictionary.key? purge) not)) - (monad.map ! (function (_ [module_name [module_id [descriptor document _]]]) - (do ! - [[descriptor,document,output bundles] (..load_definitions fs static module_id host_environment descriptor document)] - (in [[module_name descriptor,document,output] - bundles])))))] + (monad.each ! (function (_ [module_name [module_id [descriptor document _]]]) + (do ! + [[descriptor,document,output bundles] (..load_definitions fs static module_id host_environment descriptor document)] + (in [[module_name descriptor,document,output] + bundles])))))] (async\in (do {! try.monad} [archive (monad.mix ! diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux index 74d5aab33..fe83f0fb3 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/io/context.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/io/context.lux @@ -83,14 +83,14 @@ (#try.Success path) (|> path (\ fs read) - (\ (try.with !) map (|>> [path]))) + (\ (try.with !) each (|>> [path]))) (#try.Failure _) (do {! (try.with !)} [path (..find_source_file fs importer contexts module ..lux_extension)] (|> path (\ fs read) - (\ ! map (|>> [path]))))))) + (\ ! each (|>> [path]))))))) (def: (find_library_source_file importer import partial_host_extension module) (-> Module Import Extension Module (Try [file.Path Binary])) @@ -145,18 +145,18 @@ (do {! (try.with async.monad)} [enumeration (|> directory (\ fs directory_files) - (\ ! map (monad.mix ! (function (_ file enumeration) - (if (text.ends_with? ..lux_extension file) - (do ! - [source_code (\ fs read file)] - (async\in (dictionary.has' (text.replaced context "" file) source_code enumeration))) - (in enumeration))) - enumeration)) - (\ ! join))] + (\ ! each (monad.mix ! (function (_ file enumeration) + (if (text.ends_with? ..lux_extension file) + (do ! + [source_code (\ fs read file)] + (async\in (dictionary.has' (text.replaced context "" file) source_code enumeration))) + (in enumeration))) + enumeration)) + (\ ! conjoint))] (|> directory (\ fs sub_directories) - (\ ! map (monad.mix ! (context_listing fs context) enumeration)) - (\ ! join)))) + (\ ! each (monad.mix ! (context_listing fs context) enumeration)) + (\ ! conjoint)))) (def: Action (type (All [a] (Async (Try a))))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager.lux b/stdlib/source/library/lux/tool/compiler/meta/packager.lux index 744d0ecb9..f846a28a8 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager.lux @@ -33,10 +33,10 @@ (def: .public order (-> dependency.Order Order) - (list\map (function (_ [module [module_id [descriptor document]]]) - (|> descriptor - (value@ #descriptor.registry) - artifact.artifacts - row.list - (list\map (|>> (value@ #artifact.id))) - [module_id])))) + (list\each (function (_ [module [module_id [descriptor document]]]) + (|> descriptor + (value@ #descriptor.registry) + artifact.artifacts + row.list + (list\each (|>> (value@ #artifact.id))) + [module_id])))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux index ffee37de6..832c6f8f6 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/jvm.lux @@ -141,7 +141,7 @@ (-> Static archive.ID artifact.ID (Maybe Text) Binary java/util/jar/JarOutputStream (Try java/util/jar/JarOutputStream)) (let [class_path (|> custom - (maybe\map (|>> name.internal name.read)) + (maybe\each (|>> name.internal name.read)) (maybe.else (runtime.class_name [module artifact])) (text.suffix (value@ #static.artifact_extension static)))] (do try.monad @@ -249,8 +249,8 @@ [order (dependency.load_order $.key archive) .let [buffer (java/io/ByteArrayOutputStream::new (.int ..mebi_byte))] sink (|> order - (list\map (function (_ [module [module_id [descriptor document output]]]) - [module_id output])) + (list\each (function (_ [module [module_id [descriptor document output]]]) + [module_id output])) (monad.mix ! (..write_module static) (java/util/jar/JarOutputStream::new buffer (..manifest program)))) [entries duplicates sink] (|> host_dependencies diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux index f888e6975..c1fdd9d5d 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux @@ -57,12 +57,12 @@ (def: bundle_module (-> Output (Try _.Expression)) (|>> row.list - (list\map product.right) + (list\each product.right) (monad.mix try.monad (function (_ content so_far) (|> content (\ encoding.utf8 decoded) - (\ try.monad map + (\ try.monad each (|>> :expected (:sharing [directive] directive @@ -107,7 +107,7 @@ (value@ #descriptor.references) set.list (list.all (function (_ module) (dictionary.value module mapping))) - (list\map (|>> ..module_file _.string _.load_relative/1)) + (list\each (|>> ..module_file _.string _.load_relative/1)) (list\mix ..then bundle) (: _.Expression) _.code @@ -122,11 +122,11 @@ (do {! try.monad} [order (dependency.load_order $.key archive) .let [mapping (|> order - (list\map (function (_ [module [module_id [descriptor document output]]]) - [module module_id])) + (list\each (function (_ [module [module_id [descriptor document output]]]) + [module module_id])) (dictionary.of_list text.hash) (: (Dictionary Module archive.ID)))] - entries (monad.map ! (..write_module now mapping) order)] + entries (monad.each ! (..write_module now mapping) order)] (in (|> entries row.of_list (binary.result tar.writer)))))) diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux index 9b49232e3..0beeffa1c 100644 --- a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux +++ b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux @@ -39,12 +39,12 @@ (Try directive))) (|> output row.list - (list\map (|>> product.right product.right)) + (list\each (|>> product.right product.right)) (monad.mix try.monad (function (_ content so_far) (|> content (\ utf8.codec decoded) - (\ try.monad map + (\ try.monad each (|>> :expected (:sharing [directive] directive @@ -65,7 +65,7 @@ (do {! try.monad} [order (dependency.load_order $.key archive)] (|> order - (list\map (function (_ [module [module_id [descriptor document output]]]) - [module_id output])) + (list\each (function (_ [module [module_id [descriptor document output]]]) + [module_id output])) (monad.mix ! (..write_module sequence) header) - (\ ! map (|>> scope code (\ utf8.codec encoded))))))) + (\ ! each (|>> scope code (\ utf8.codec encoded))))))) |