aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/library')
-rw-r--r--stdlib/source/library/lux.lux16
-rw-r--r--stdlib/source/library/lux/data/collection/dictionary/plist.lux37
-rw-r--r--stdlib/source/library/lux/meta.lux16
-rw-r--r--stdlib/source/library/lux/meta/configuration.lux103
-rw-r--r--stdlib/source/library/lux/meta/version.lux47
-rw-r--r--stdlib/source/library/lux/tool/compiler/default/init.lux9
-rw-r--r--stdlib/source/library/lux/tool/compiler/default/platform.lux13
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux.lux7
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux10
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux3
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux5
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/version.lux9
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/cli.lux10
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/io/archive.lux30
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux3
15 files changed, 245 insertions, 73 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux
index 69f555fee..20122f66c 100644
--- a/stdlib/source/library/lux.lux
+++ b/stdlib/source/library/lux.lux
@@ -566,9 +566,10 @@
... (type: .public Info
... (Record
-... [#target Text
-... #version Text
-... #mode Mode]))
+... [#target Text
+... #version Text
+... #mode Mode
+... #configuration (List [Text Text])]))
("lux def type tagged" Info
{#Named [..prelude_module "Info"]
{#Product
@@ -577,9 +578,12 @@
{#Product
... version
Text
- ... mode
- Mode}}}
- ["#target" "#version" "#mode"]
+ {#Product
+ ... mode
+ Mode
+ ... configuration
+ {#Apply {#Product Text Text} List}}}}}
+ ["#target" "#version" "#mode" "#configuration"]
.public)
... (type: .public Lux
diff --git a/stdlib/source/library/lux/data/collection/dictionary/plist.lux b/stdlib/source/library/lux/data/collection/dictionary/plist.lux
index d646287c8..7eb2f4001 100644
--- a/stdlib/source/library/lux/data/collection/dictionary/plist.lux
+++ b/stdlib/source/library/lux/data/collection/dictionary/plist.lux
@@ -1,16 +1,17 @@
(.using
- [library
- [lux "*"
- [abstract
- [equivalence {"+" Equivalence}]]
- [data
- ["[0]" product]
- ["[0]" text ("[1]#[0]" equivalence)]
- [collection
- ["[0]" list ("[1]#[0]" functor)]]]
- [math
- [number
- ["n" nat]]]]])
+ [library
+ [lux "*"
+ [abstract
+ [equivalence {"+" Equivalence}]
+ [monoid {"+" Monoid}]]
+ [data
+ ["[0]" product]
+ ["[0]" text ("[1]#[0]" equivalence)]
+ [collection
+ ["[0]" list ("[1]#[0]" functor mix)]]]
+ [math
+ [number
+ ["n" nat]]]]])
... https://en.wikipedia.org/wiki/Property_list
(type: .public (PList a)
@@ -97,3 +98,15 @@
(All (_ a) (-> (Equivalence a) (Equivalence (PList a))))
(|>> (product.equivalence text.equivalence)
list.equivalence))
+
+(implementation: .public monoid
+ (All (_ a) (Monoid (PList a)))
+
+ (def: identity
+ ..empty)
+
+ (def: (composite left right)
+ (list#mix (function (_ [key val] it)
+ (..has key val it))
+ right
+ left)))
diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux
index d16ca46b9..8bf80bce5 100644
--- a/stdlib/source/library/lux/meta.lux
+++ b/stdlib/source/library/lux/meta.lux
@@ -665,8 +665,14 @@
{try.#Failure error}
{try.#Success [lux {try.#Failure error}]})))
-(def: .public target
- (Meta Text)
- (function (_ lux)
- {try.#Success [lux
- (value@ [.#info .#target] lux)]}))
+(template [<type> <name> <slot>]
+ [(def: .public <name>
+ (Meta <type>)
+ (function (_ lux)
+ {try.#Success [lux
+ (value@ [.#info <slot>] lux)]}))]
+
+ [Text target .#target]
+ [Text version .#version]
+ [(List [Text Text]) configuration .#configuration]
+ )
diff --git a/stdlib/source/library/lux/meta/configuration.lux b/stdlib/source/library/lux/meta/configuration.lux
new file mode 100644
index 000000000..057466051
--- /dev/null
+++ b/stdlib/source/library/lux/meta/configuration.lux
@@ -0,0 +1,103 @@
+(.using
+ [library
+ [lux {"-" for}
+ ["[0]" meta]
+ [abstract
+ [equivalence {"+" Equivalence}]
+ [monoid {"+" Monoid}]
+ [monad {"+" do}]]
+ [control
+ ["[0]" maybe ("[1]#[0]" functor)]
+ ["[0]" exception {"+" exception:}]
+ ["<>" parser
+ ["<[0]>" text {"+" Parser}]
+ ["<[0]>" code]]]
+ [data
+ ["[0]" text ("[1]#[0]" equivalence)
+ ["%" format]]
+ [collection
+ ["[0]" list ("[1]#[0]" functor mix)]
+ [dictionary
+ ["/" plist]]]]
+ [macro
+ [syntax {"+" syntax:}]
+ ["[0]" code]]
+ [math
+ [number {"+" hex}]]]])
+
+(type: .public Configuration
+ (/.PList Text))
+
+(def: .public equivalence
+ (Equivalence Configuration)
+ (/.equivalence text.equivalence))
+
+(def: .public monoid
+ (Monoid Configuration)
+ /.monoid)
+
+(def: .public empty
+ Configuration
+ /.empty)
+
+(template [<ascii> <name>]
+ [(def: <name>
+ Text
+ (text.of_char (hex <ascii>)))]
+
+ ["02" start]
+ ["03" end]
+ )
+
+(def: format'
+ (-> Text Text)
+ (text.enclosed [..start ..end]))
+
+(def: .public format
+ (%.Format Configuration)
+ (|>> (list#each (function (_ [feature value])
+ (%.format (..format' feature) (..format' value))))
+ text.together))
+
+(def: .public parser
+ (Parser Configuration)
+ (let [parser' (: (Parser Text)
+ (<| (<>.after (<text>.this ..start))
+ (<>.before (<text>.this ..end))
+ (<text>.slice (<text>.some! (<text>.none_of! ..end)))))]
+ (<>.some (<>.and parser' parser'))))
+
+(exception: .public invalid)
+
+(def: configuration
+ (<code>.Parser Configuration)
+ (<code>.tuple (<>.some (<>.and <code>.text <code>.text))))
+
+(def: (subsumes? actual expected)
+ (-> Configuration Configuration Bit)
+ (case expected
+ {.#End}
+ true
+
+ {.#Item [feature value] tail}
+ (and (|> actual
+ (/.value feature)
+ (maybe#each (text#= value))
+ (maybe.else false))
+ (subsumes? expected tail))))
+
+(syntax: .public (for [specializations (<code>.tuple (<>.some (<>.and ..configuration <code>.any)))
+ default (<>.maybe <code>.any)])
+ (do meta.monad
+ [actual meta.configuration]
+ (case (list#mix (function (_ [expected then] choice)
+ (if (subsumes? actual expected)
+ {.#Some then}
+ choice))
+ default
+ specializations)
+ {.#Some it}
+ (in (list it))
+
+ {.#None}
+ (meta.failure (exception.error ..invalid [])))))
diff --git a/stdlib/source/library/lux/meta/version.lux b/stdlib/source/library/lux/meta/version.lux
new file mode 100644
index 000000000..66bf8e6f5
--- /dev/null
+++ b/stdlib/source/library/lux/meta/version.lux
@@ -0,0 +1,47 @@
+(.using
+ [library
+ [lux {"-" for}
+ ["[0]" meta]
+ [abstract
+ [monad {"+" do}]]
+ [control
+ ["[0]" exception {"+" exception:}]
+ ["<>" parser
+ ["<[0]>" code]]]
+ [data
+ ["[0]" text ("[1]#[0]" equivalence)]
+ [collection
+ ["[0]" list ("[1]#[0]" mix)]]]
+ [macro
+ [syntax {"+" syntax:}]
+ ["[0]" code]]
+ [tool
+ [compiler
+ [version {"+" Version}]]]]])
+
+(def: .public latest
+ Version
+ 00,06,06)
+
+(syntax: .public (current [])
+ (do meta.monad
+ [it meta.version]
+ (in (list (code.text it)))))
+
+(exception: .public invalid)
+
+(syntax: .public (for [specializations (<code>.tuple (<>.some (<>.and <code>.text <code>.any)))
+ default (<>.maybe <code>.any)])
+ (do meta.monad
+ [current meta.version]
+ (case (list#mix (function (_ [when then] choice)
+ (if (text#= when current)
+ {.#Some then}
+ choice))
+ default
+ specializations)
+ {.#Some it}
+ (in (list it))
+
+ {.#None}
+ (meta.failure (exception.error ..invalid [])))))
diff --git a/stdlib/source/library/lux/tool/compiler/default/init.lux b/stdlib/source/library/lux/tool/compiler/default/init.lux
index fc7e1b637..7f815abf9 100644
--- a/stdlib/source/library/lux/tool/compiler/default/init.lux
+++ b/stdlib/source/library/lux/tool/compiler/default/init.lux
@@ -18,6 +18,9 @@
["[0]" dictionary]
["[0]" set]
["[0]" sequence ("[1]#[0]" functor)]]]
+ [meta
+ ["[0]" configuration {"+" Configuration}]
+ ["[0]" version]]
[world
["[0]" file]]]]
["[0]" // "_"
@@ -26,7 +29,6 @@
[language
[lux
[program {"+" Program}]
- ["[1][0]" version]
["[1][0]" syntax {"+" Aliases}]
["[1][0]" synthesis]
["[1][0]" directive {"+" Requirements}]
@@ -51,10 +53,11 @@
["[0]" descriptor]
["[0]" document]]]]]])
-(def: .public (state target module expander host_analysis host generate generation_bundle)
+(def: .public (state target module configuration expander host_analysis host generate generation_bundle)
(All (_ anchor expression directive)
(-> Target
descriptor.Module
+ Configuration
Expander
///analysis.Bundle
(///generation.Host expression directive)
@@ -65,7 +68,7 @@
generation_state [generation_bundle (///generation.state host module)]
eval (///analysis/evaluation.evaluator expander synthesis_state generation_state generate)
analysis_state [(analysisE.bundle eval host_analysis)
- (///analysis.state (///analysis.info ///version.version target))]]
+ (///analysis.state (///analysis.info version.latest target configuration))]]
[extension.empty
[///directive.#analysis [///directive.#state analysis_state
///directive.#phase (analysisP.phase expander)]
diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux
index 2ddc8a689..f489c1fb8 100644
--- a/stdlib/source/library/lux/tool/compiler/default/platform.lux
+++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux
@@ -3,7 +3,6 @@
[lux "*"
["@" target]
["[0]" debug]
- ["[0]" meta]
[abstract
["[0]" monad {"+" Monad do}]]
[control
@@ -27,6 +26,8 @@
["[0]" list ("[1]#[0]" monoid functor mix)]]
[format
["_" binary {"+" Writer}]]]
+ ["[0]" meta
+ ["[0]" configuration {"+" Configuration}]]
[type {"+" :sharing}
["[0]" check]]
[world
@@ -40,7 +41,6 @@
[lux
[program {"+" Program}]
["$" /]
- ["[1][0]" version]
["[0]" syntax]
["[1][0]" synthesis]
["[1][0]" generation {"+" Buffer}]
@@ -240,7 +240,7 @@
(dictionary.merged directives (host_directive_bundle phase_wrapper))])
(def: .public (initialize context module expander host_analysis platform generation_bundle host_directive_bundle program anchorT,expressionT,directiveT extender
- import compilation_sources)
+ import compilation_sources compilation_configuration)
(All (_ <type_vars>)
(-> Context
descriptor.Module
@@ -251,18 +251,19 @@
(-> ///phase.Wrapper (///directive.Bundle <type_vars>))
(Program expression directive)
[Type Type Type] (-> ///phase.Wrapper Extender)
- Import (List _io.Context)
+ Import (List _io.Context) Configuration
(Async (Try [<State+> Archive ///phase.Wrapper]))))
(do [! (try.with async.monad)]
[.let [state (//init.state (value@ context.#host context)
module
+ compilation_configuration
expander
host_analysis
(value@ #host platform)
(value@ #phase platform)
generation_bundle)]
_ (cache.enable! (value@ #&file_system platform) context)
- [archive analysis_state bundles] (ioW.thaw (value@ #host platform) (value@ #&file_system platform) context import compilation_sources)
+ [archive analysis_state bundles] (ioW.thaw compilation_configuration (value@ #host platform) (value@ #&file_system platform) context import compilation_sources)
.let [with_missing_extensions
(: (All (_ <type_vars>)
(-> <Platform> (Program expression directive) <State+>
@@ -753,7 +754,7 @@
(def: .public (compile phase_wrapper import file_context expander platform compilation context)
(All (_ <type_vars>)
(-> ///phase.Wrapper Import Context Expander <Platform> Compilation <Context> <Return>))
- (let [[host_dependencies libraries compilers sources target module] compilation
+ (let [[host_dependencies libraries compilers sources target module configuration] compilation
importer (|> (..compiler phase_wrapper expander platform)
(serial_compiler import file_context platform sources)
(..parallel context))]
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux.lux
index 566a7afa9..faf7f3b90 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux.lux
@@ -6,9 +6,10 @@
["<b>" binary {"+" Parser}]]]
[data
[format
- ["_" binary {"+" Writer}]]]]]
+ ["_" binary {"+" Writer}]]]
+ [meta
+ ["[0]" version]]]]
["[0]" / "_"
- ["[1][0]" version]
[analysis
["[0]" module]]
[///
@@ -86,5 +87,5 @@
(def: .public key
(Key .Module)
(key.key [signature.#name (symbol ..compiler)
- signature.#version /version.version]
+ signature.#version version.latest]
(module.empty 0)))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux
index 5ac2fda49..650842124 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis.lux
@@ -28,7 +28,8 @@
["r" rev]
["f" frac]]]
[meta
- ["[0]" location]]]]
+ ["[0]" location]
+ ["[0]" configuration {"+" Configuration}]]]]
["[0]" / "_"
["[1][0]" simple {"+" Simple}]
["[1][0]" complex {"+" Tuple Variant Complex}]
@@ -356,11 +357,12 @@
.#var_counter 0
.#var_bindings (list)])
-(def: .public (info version host)
- (-> Version Text Info)
+(def: .public (info version host configuration)
+ (-> Version Text Configuration Info)
[.#target host
.#version (version.format version)
- .#mode {.#Build}])
+ .#mode {.#Build}
+ .#configuration configuration])
(def: .public (state info)
(-> Info Lux)
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
index c9ad8c0eb..d4c947953 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/host.lux
@@ -38,9 +38,6 @@
["[0]" descriptor]]]]
[tool
[compiler
- [language
- [lux
- [version {"+" version}]]]
[meta
[io {"+" lux_context}]
[archive
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux
index fc96c025f..6031ed1db 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/jvm/runtime.lux
@@ -21,6 +21,8 @@
["n" nat]
["[0]" i32]
["[0]" i64]]]
+ [meta
+ ["[0]" version]]
[target
["[0]" jvm "_"
["_" bytecode {"+" Label Bytecode}]
@@ -48,7 +50,6 @@
["[1]/[0]" count]]]]
["//[1]" /// "_"
[//
- ["[0]" version]
["[0]" synthesis]
["[0]" generation]
[///
@@ -92,7 +93,7 @@
(def: .public (class_name [module id])
(-> unit.ID Text)
(format lux_context
- "." (%.nat version.version)
+ "." (%.nat version.latest)
"." (%.nat module)
"." (%.nat id)))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/version.lux b/stdlib/source/library/lux/tool/compiler/language/lux/version.lux
deleted file mode 100644
index cc044938c..000000000
--- a/stdlib/source/library/lux/tool/compiler/language/lux/version.lux
+++ /dev/null
@@ -1,9 +0,0 @@
-(.using
- [library
- [lux "*"]]
- [////
- [version {"+" Version}]])
-
-(def: .public version
- Version
- 00,06,06)
diff --git a/stdlib/source/library/lux/tool/compiler/meta/cli.lux b/stdlib/source/library/lux/tool/compiler/meta/cli.lux
index 056652661..f13f1596c 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/cli.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/cli.lux
@@ -18,7 +18,8 @@
[math
[number {"+" hex}]]
[meta
- ["[0]" symbol]]
+ ["[0]" symbol]
+ ["[0]" configuration {"+" Configuration}]]
[tool
[compiler
[meta
@@ -52,7 +53,8 @@
#compilers (List Compiler)
#sources (List Source)
#target Target
- #module Module]))
+ #module Module
+ #configuration Configuration]))
(type: .public Interpretation
..Compilation)
@@ -77,6 +79,7 @@
[source_parser "--source" Source <cli>.any]
[target_parser "--target" Target <cli>.any]
[module_parser "--module" Module <cli>.any]
+ [configuration_parser "--configuration" Configuration (<text>.then configuration.parser <cli>.any)]
)
(def: .public service
@@ -88,7 +91,8 @@
(<>.some ..compiler_parser)
(<>.some ..source_parser)
..target_parser
- ..module_parser))]
+ ..module_parser
+ ..configuration_parser))]
($_ <>.or
(<>.after (<cli>.this "build")
compiler)
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 4693a7d2f..13e848153 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux
@@ -26,6 +26,9 @@
[math
[number
["n" nat]]]
+ [meta
+ ["[0]" configuration {"+" Configuration}]
+ ["[0]" version]]
[world
["[0]" file]]]]
["[0]" //
@@ -46,7 +49,6 @@
["/[1]" // {"+" Input}
[language
["$" lux
- ["[0]" version]
["[0]" analysis]
["[0]" synthesis]
["[0]" generation]
@@ -145,12 +147,12 @@
..module_parser
registry.parser))
-(def: (fresh_analysis_state host)
- (-> Target .Lux)
- (analysis.state (analysis.info version.version host)))
+(def: (fresh_analysis_state host configuration)
+ (-> Target Configuration .Lux)
+ (analysis.state (analysis.info version.latest host configuration)))
-(def: (analysis_state host archive)
- (-> Target Archive (Try .Lux))
+(def: (analysis_state host configuration archive)
+ (-> Target Configuration Archive (Try .Lux))
(do [! try.monad]
[modules (: (Try (List [descriptor.Module .Module]))
(monad.each ! (function (_ module)
@@ -161,7 +163,7 @@
(document.content $.key))]
(in [module content])))
(archive.archived archive)))]
- (in (with@ .#modules modules (fresh_analysis_state host)))))
+ (in (with@ .#modules modules (fresh_analysis_state host configuration)))))
(def: (cached_artifacts fs context module_id)
(-> (file.System Async) Context module.ID (Async (Try (Dictionary Text Binary))))
@@ -463,9 +465,9 @@
bundles])))))]
(in it)))
-(def: (load_every_reserved_module host_environment fs context import contexts archive)
+(def: (load_every_reserved_module configuration host_environment fs context import contexts archive)
(All (_ expression directive)
- (-> (generation.Host expression directive) (file.System Async) Context Import (List //.Context) Archive
+ (-> Configuration (generation.Host expression directive) (file.System Async) Context Import (List //.Context) Archive
(Async (Try [Archive .Lux Bundles]))))
(do [! (try.with async.monad)]
[pre_loaded_caches (..pre_loaded_caches fs context import contexts archive)
@@ -482,7 +484,7 @@
(archive.has module entry archive))
archive
loaded_caches)
- analysis_state (..analysis_state (value@ context.#host context) archive)]
+ analysis_state (..analysis_state (value@ context.#host context) configuration archive)]
(in [archive
analysis_state
(list#mix (function (_ [_ [+analysers +synthesizers +generators +directives]]
@@ -494,9 +496,9 @@
..empty_bundles
loaded_caches)])))))
-(def: .public (thaw host_environment fs context import contexts)
+(def: .public (thaw configuration host_environment fs context import contexts)
(All (_ expression directive)
- (-> (generation.Host expression directive) (file.System Async) Context Import (List //.Context)
+ (-> Configuration (generation.Host expression directive) (file.System Async) Context Import (List //.Context)
(Async (Try [Archive .Lux Bundles]))))
(do async.monad
[binary (# fs read (..general_descriptor fs context))]
@@ -504,9 +506,9 @@
{try.#Success binary}
(do (try.with async.monad)
[archive (async#in (archive.import ///.version binary))]
- (..load_every_reserved_module host_environment fs context import contexts archive))
+ (..load_every_reserved_module configuration host_environment fs context import contexts archive))
{try.#Failure error}
(in {try.#Success [archive.empty
- (fresh_analysis_state (value@ context.#host context))
+ (fresh_analysis_state (value@ context.#host context) configuration)
..empty_bundles]}))))
diff --git a/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux b/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux
index 1bfd062fe..fb4d43410 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux
@@ -25,9 +25,6 @@
["_" ruby]]
[world
["[0]" file]]]]
- [program
- [compositor
- ["[0]" static {"+" Static}]]]
["[0]" // {"+" Packager}
[//
["[0]" archive {"+" Output}