aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library
diff options
context:
space:
mode:
authorEduardo Julian2022-10-02 19:25:33 -0400
committerEduardo Julian2022-10-02 19:25:33 -0400
commited779c7bbbf3c625461fd1c09c1a3c39eaabd9d6 (patch)
tree0875aef89507986149c24f771feb7852c7170a89 /stdlib/source/library
parentba150e8a206ffba1c5313c26fa88c6dcba6a08aa (diff)
New format for extensions [part 4]
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux/meta/compiler/default/init.lux10
-rw-r--r--stdlib/source/library/lux/meta/compiler/default/platform.lux7
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis.lux6
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux37
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/declaration/lux.lux17
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/js/runtime.lux13
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/runtime.lux10
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/lua/runtime.lux13
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/python/runtime.lux13
-rw-r--r--stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/ruby/runtime.lux13
-rw-r--r--stdlib/source/library/lux/meta/extension.lux72
-rw-r--r--stdlib/source/library/lux/world/net.lux8
-rw-r--r--stdlib/source/library/lux/world/net/http.lux18
13 files changed, 132 insertions, 105 deletions
diff --git a/stdlib/source/library/lux/meta/compiler/default/init.lux b/stdlib/source/library/lux/meta/compiler/default/init.lux
index 477ebd416..519224bb7 100644
--- a/stdlib/source/library/lux/meta/compiler/default/init.lux
+++ b/stdlib/source/library/lux/meta/compiler/default/init.lux
@@ -53,13 +53,12 @@
["[0]" descriptor]
["[0]" document]]]]]])
-(def .public (state target module configuration extender expander anchor,expression,declaration host_analysis host generate generation_bundle)
+(def .public (state target module configuration extender expander host_analysis host generate generation_bundle)
(All (_ anchor expression declaration)
(-> Target
descriptor.Module
Configuration
extension.Extender Expander
- [Type Type Type]
///analysis.Bundle
(///generation.Host expression declaration)
(-> extension.Extender Lux (///generation.Phase anchor expression declaration))
@@ -72,7 +71,7 @@
eval (///analysis/evaluation.evaluator analysis_phase
[synthesis_state (synthesisP.phase extender lux)]
[generation_state (generate extender lux)])
- analysis_state [(analysisE.bundle eval anchor,expression,declaration host_analysis)
+ analysis_state [(analysisE.bundle eval host_analysis)
lux]]
[extension.empty
[///declaration.#analysis [///declaration.#state analysis_state
@@ -82,17 +81,16 @@
///declaration.#generation [///declaration.#state generation_state
///declaration.#phase (generate extender)]]]))
-(def .public (with_default_declarations host_analysis program anchorT,expressionT,declarationT extender)
+(def .public (with_default_declarations host_analysis program extender)
(All (_ anchor expression declaration)
(-> ///analysis.Bundle
(Program expression declaration)
- [Type Type Type]
(Extender anchor expression declaration)
(-> (///declaration.State+ anchor expression declaration)
(///declaration.State+ anchor expression declaration))))
(function (_ [declaration_extensions sub_state])
[(dictionary.composite declaration_extensions
- (luxD.bundle host_analysis program anchorT,expressionT,declarationT extender))
+ (luxD.bundle host_analysis program extender))
sub_state]))
(type Reader
diff --git a/stdlib/source/library/lux/meta/compiler/default/platform.lux b/stdlib/source/library/lux/meta/compiler/default/platform.lux
index 732b86614..5608be3b2 100644
--- a/stdlib/source/library/lux/meta/compiler/default/platform.lux
+++ b/stdlib/source/library/lux/meta/compiler/default/platform.lux
@@ -239,7 +239,7 @@
generators
(dictionary.composite declarations host_declaration_bundle)])
- (def .public (initialize context module expander host_analysis platform generation_bundle host_declaration_bundle program anchor,expression,declaration extender
+ (def .public (initialize context module expander host_analysis platform generation_bundle host_declaration_bundle program extender
import compilation_sources compilation_configuration)
(All (_ <type_vars>)
(-> context.Context
@@ -250,7 +250,7 @@
<Bundle>
(///declaration.Bundle <type_vars>)
(Program expression declaration)
- [Type Type Type] extension.Extender
+ extension.Extender
Import (List _io.Context) Configuration
(Async (Try [<State+> Archive ///phase.Wrapper]))))
(do [! ..monad]
@@ -260,7 +260,6 @@
compilation_configuration
extender
expander
- anchor,expression,declaration
host_analysis
(the #host platform)
(the #phase platform)
@@ -277,7 +276,7 @@
(initialize_state extender
(as_expected (..complete_extensions host_declaration_bundle (as_expected bundles)))
analysis_state)
- (try#each (//init.with_default_declarations host_analysis program anchor,expression,declaration extender))
+ (try#each (//init.with_default_declarations host_analysis program extender))
async#in)))]]
(if (archive.archived? archive descriptor.runtime)
(do !
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis.lux
index d74041df9..a7ef77615 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis.lux
@@ -10,7 +10,7 @@
["[0]" /
["[1][0]" lux]])
-(def .public (bundle eval anchor,expression,declaration host_specific)
- (-> Eval [Type Type Type] Bundle Bundle)
- (|> (/lux.bundle eval anchor,expression,declaration)
+(def .public (bundle eval host_specific)
+ (-> Eval Bundle Bundle)
+ (|> (/lux.bundle eval)
(dictionary.composite host_specific)))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux
index 076b2c39b..b80344bc1 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/extension/analysis/lux.lux
@@ -276,40 +276,8 @@
(///bundle.install "clip" (trinary Nat Nat Text Text))
)))
-(def (lux_extension handler_type extension_type)
- (-> Type Type Handler)
- (..custom
- [<code>.any
- (function (_ extension_name phase archive [it])
- (do [! ////.monad]
- [it (<| (typeA.expecting handler_type)
- (phase archive it))
- _ (typeA.inference extension_type)]
- (in it)))]))
-
-(def (host_extension handler_type extension_type [anchor expression declaration])
- (-> Type Type [Type Type Type] Handler)
- (..custom
- [<code>.any
- (function (_ extension_name phase archive [it])
- (do [! ////.monad]
- [it (<| (typeA.expecting (type_literal (handler_type anchor expression declaration)))
- (phase archive it))
- _ (typeA.inference extension_type)]
- (in it)))]))
-
-(def (extension anchor,expression,declaration)
- (-> [Type Type Type] Bundle)
- (<| (///bundle.prefix "extension")
- (|> ///bundle.empty
- (///bundle.install "analysis" (lux_extension analysis.Handler .Analysis))
- (///bundle.install "synthesis" (lux_extension synthesis.Handler .Synthesis))
- (///bundle.install "generation" (host_extension generation.Handler .Generation anchor,expression,declaration))
- (///bundle.install "declaration" (host_extension declaration.Handler .Declaration anchor,expression,declaration))
- )))
-
-(def .public (bundle eval anchor,expression,declaration)
- (-> Eval [Type Type Type] Bundle)
+(def .public (bundle eval)
+ (-> Eval Bundle)
(<| (///bundle.prefix "lux")
(|> ///bundle.empty
(dictionary.composite (bundle::lux eval))
@@ -317,5 +285,4 @@
(dictionary.composite bundle::f64)
(dictionary.composite bundle::text)
(dictionary.composite bundle::io)
- (dictionary.composite (extension anchor,expression,declaration))
)))
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 0273d1a26..50054b9cb 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
@@ -221,9 +221,9 @@
)
... TODO: Get rid of this function ASAP.
-(def (refresh anchor,expression,declaration host_analysis)
+(def (refresh host_analysis)
(All (_ anchor expression declaration)
- (-> [Type Type Type] /////analysis.Bundle (Operation anchor expression declaration Any)))
+ (-> /////analysis.Bundle (Operation anchor expression declaration Any)))
(do phase.monad
[[bundle state] phase.state
.let [analysis_state (the [/////declaration.#analysis /////declaration.#state ///.#state] state)
@@ -239,7 +239,7 @@
(is (-> /////analysis.State+ /////analysis.State+)
(|>> product.right
[(|> previous_analysis_extensions
- (dictionary.composite (///analysis.bundle eval anchor,expression,declaration host_analysis)))]))
+ (dictionary.composite (///analysis.bundle eval host_analysis)))]))
state)])))
(def (announce_definition! short type)
@@ -248,8 +248,8 @@
(/////declaration.lifted_generation
(/////generation.log! (format short " : " (%.type type)))))
-(def (lux::def anchor,expression,declaration host_analysis)
- (-> [Type Type Type] /////analysis.Bundle Handler)
+(def (lux::def host_analysis)
+ (-> /////analysis.Bundle Handler)
(function (_ extension_name phase archive inputsC+)
(when inputsC+
(list [_ {.#Symbol ["" short_name]}] valueC exported?C)
@@ -261,7 +261,7 @@
[_ _ exported?] (evaluate! archive Bit exported?C)
_ (/////declaration.lifted_analysis
(moduleA.define short_name {.#Definition [(as Bit exported?) type value]}))
- _ (..refresh anchor,expression,declaration host_analysis)
+ _ (..refresh host_analysis)
_ (..announce_definition! short_name type)]
(in /////declaration.no_requirements))
@@ -378,14 +378,13 @@
(dictionary.has "alias" def_alias)
)))
-(def .public (bundle host_analysis program anchor,expression,declaration extender)
+(def .public (bundle host_analysis program extender)
(All (_ anchor expression declaration)
(-> /////analysis.Bundle
(Program expression declaration)
- [Type Type Type]
(Extender anchor expression declaration)
(Bundle anchor expression declaration)))
(<| (///bundle.prefix "lux")
(|> ///bundle.empty
- (dictionary.has "def" (lux::def anchor,expression,declaration host_analysis))
+ (dictionary.has "def" (lux::def host_analysis))
(dictionary.composite (..bundle::def host_analysis program extender)))))
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/js/runtime.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/js/runtime.lux
index 506287a9c..ad0ee82b2 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/js/runtime.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/js/runtime.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except i64 left right)
+ [lux (.except Synthesis Declaration i64 left right)
[abstract
["[0]" monad (.only do)]]
[control
@@ -39,9 +39,18 @@
["[0]" registry (.only Registry)]
["[0]" unit]]]]]])
+(type .public Anchor
+ [Register Text])
+
+(type .public Value
+ Expression)
+
+(type .public Declaration
+ Statement)
+
(with_template [<name> <base>]
[(type .public <name>
- (<base> [Register Text] Expression Statement))]
+ (<base> Anchor Value Declaration))]
[Operation /////generation.Operation]
[Phase /////generation.Phase]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/runtime.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/runtime.lux
index d3592f33b..c1ffb137b 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/runtime.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/jvm/runtime.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Type Definition Label when false true try)
+ [lux (.except Type Definition Label Declaration when false true try)
[abstract
["[0]" monad (.only do)]
["[0]" enum]]
@@ -72,9 +72,15 @@
(type .public Anchor
[Label Register])
+(type .public Value
+ (Bytecode Any))
+
+(type .public Declaration
+ Definition)
+
(with_template [<name> <base>]
[(type .public <name>
- (<base> Anchor (Bytecode Any) Definition))]
+ (<base> Anchor Value Declaration))]
[Operation generation.Operation]
[Phase generation.Phase]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/lua/runtime.lux
index b365b536e..c16856732 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/lua/runtime.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/lua/runtime.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except Label Location left right)
+ [lux (.except Label Location Synthesis Declaration left right)
[abstract
["[0]" monad (.only do)]]
[control
@@ -39,9 +39,18 @@
["[0]" registry (.only Registry)]
["[0]" unit]]]]]])
+(type .public Anchor
+ [Register Label])
+
+(type .public Value
+ Expression)
+
+(type .public Declaration
+ Statement)
+
(with_template [<name> <base>]
[(type .public <name>
- (<base> [Register Label] Expression Statement))]
+ (<base> Anchor Value Declaration))]
[Operation /////generation.Operation]
[Phase /////generation.Phase]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/python/runtime.lux
index 38c5d87e3..2c2ca91fc 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/python/runtime.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/python/runtime.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except ++ left right)
+ [lux (.except Synthesis Declaration ++ left right)
[abstract
["[0]" monad (.only do)]]
[control
@@ -41,9 +41,18 @@
["[0]" registry (.only Registry)]
["[0]" unit]]]]]])
+(type .public Anchor
+ Register)
+
+(type .public Value
+ (Expression Any))
+
+(type .public Declaration
+ (Statement Any))
+
(with_template [<name> <base>]
[(type .public <name>
- (<base> Register (Expression Any) (Statement Any)))]
+ (<base> Anchor Value Declaration))]
[Operation /////generation.Operation]
[Phase /////generation.Phase]
diff --git a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/ruby/runtime.lux
index 9cb620e31..2766c41e1 100644
--- a/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/ruby/runtime.lux
+++ b/stdlib/source/library/lux/meta/compiler/language/lux/phase/generation/ruby/runtime.lux
@@ -1,6 +1,6 @@
(.require
[library
- [lux (.except i64 left right)
+ [lux (.except Synthesis Declaration i64 left right)
[abstract
["[0]" monad (.only do)]]
[control
@@ -40,9 +40,18 @@
["[0]" unit]
["[0]" registry (.only Registry)]]]]]])
+(type .public Anchor
+ Register)
+
+(type .public Value
+ Expression)
+
+(type .public Declaration
+ Statement)
+
(with_template [<name> <base>]
[(type .public <name>
- (<base> Register Expression Statement))]
+ (<base> Anchor Value Declaration))]
[Operation /////generation.Operation]
[Phase /////generation.Phase]
diff --git a/stdlib/source/library/lux/meta/extension.lux b/stdlib/source/library/lux/meta/extension.lux
index 7fb2bf9c7..a713dd596 100644
--- a/stdlib/source/library/lux/meta/extension.lux
+++ b/stdlib/source/library/lux/meta/extension.lux
@@ -10,20 +10,38 @@
[collection
["[0]" list (.use "[1]#[0]" functor)]]]
[meta
+ ["@" target (.only)
+ [jvm
+ ["_" bytecode (.only Bytecode)]]]
["[0]" code (.only)
["<c>" \\parser (.only Parser)]]
[macro (.only with_symbols)
- [syntax (.only syntax)]]
+ [syntax (.only syntax)]
+ ["[0]" template]]
[compiler
["[0]" phase]
[language
[lux
- [analysis
+ ["[0]" analysis (.only)
["<a>" \\parser]]
- [synthesis
- ["<s>" \\parser]]]]]]]])
+ ["[0]" synthesis (.only)
+ ["<s>" \\parser]]
+ ["[0]" generation]
+ ["[0]" declaration]
+ [phase
+ [generation
+ ["[0]" jvm
+ ["[1]" runtime]]
+ ["[0]" js
+ ["[1]" runtime]]
+ ["[0]" lua
+ ["[1]" runtime]]
+ ["[0]" python
+ ["[1]" runtime]]
+ ["[0]" ruby
+ ["[1]" runtime]]]]]]]]]])
-(with_template [<any> <end> <and> <result> <extension> <name> <type>]
+(with_template [<any> <end> <and> <result> <name> <extension_type> <handler_type>]
[(def .public <name>
(syntax (_ [[handler extension phase archive inputs] (<c>.form (all <>.and
<c>.local
@@ -37,22 +55,34 @@
g!phase (code.local phase)
g!archive (code.local archive)]
(with_symbols [g!inputs g!error g!_]
- (in (list (` (<extension> (.function ((, g!handler) (, g!name) (, g!phase) (, g!archive) (, g!inputs))
- (.when (<result>
- (monad.do <>.monad
- [(,* inputs)
- (, g!_) <end>]
- (.at <>.monad (,' in) (, body)))
- (, g!inputs))
- {.#Right (, g!_)}
- (, g!_)
+ (in (list (` (<| (as <extension_type>)
+ (is <handler_type>)
+ (.function ((, g!handler) (, g!name) (, g!phase) (, g!archive) (, g!inputs))
+ (.when (<result>
+ (monad.do <>.monad
+ [(,* inputs)
+ (, g!_) <end>]
+ (.at <>.monad (,' in) (, body)))
+ (, g!inputs))
+ {.#Right (, g!_)}
+ (, g!_)
- {.#Left (, g!error)}
- (phase.failure (, g!error)))
- )))))))))]
+ {.#Left (, g!error)}
+ (phase.failure (, g!error)))
+ )))))))))]
- [<c>.any <c>.end <c>.and <c>.result "lux extension analysis" analysis .Analysis]
- [<a>.any <a>.end <a>.and <a>.result "lux extension synthesis" synthesis .Synthesis]
- [<s>.any <s>.end <s>.and <s>.result "lux extension generation" generation .Generation]
- [<c>.any <c>.end <c>.and <c>.result "lux extension declaration" declaration .Declaration]
+ [<c>.any <c>.end <c>.and <c>.result analysis .Analysis analysis.Handler]
+ [<a>.any <a>.end <a>.and <a>.result synthesis .Synthesis synthesis.Handler]
+ [<s>.any <s>.end <s>.and <s>.result generation .Generation
+ (for @.jvm (generation.Handler jvm.Anchor jvm.Value jvm.Declaration)
+ @.js (generation.Handler js.Anchor js.Value js.Declaration)
+ @.lua (generation.Handler lua.Anchor lua.Value lua.Declaration)
+ @.python (generation.Handler python.Anchor python.Value python.Declaration)
+ @.ruby (generation.Handler ruby.Anchor ruby.Value ruby.Declaration))]
+ [<c>.any <c>.end <c>.and <c>.result declaration .Declaration
+ (for @.jvm (declaration.Handler jvm.Anchor jvm.Value jvm.Declaration)
+ @.js (declaration.Handler js.Anchor js.Value js.Declaration)
+ @.lua (declaration.Handler lua.Anchor lua.Value lua.Declaration)
+ @.python (declaration.Handler python.Anchor python.Value python.Declaration)
+ @.ruby (declaration.Handler ruby.Anchor ruby.Value ruby.Declaration))]
)
diff --git a/stdlib/source/library/lux/world/net.lux b/stdlib/source/library/lux/world/net.lux
index 93716afa9..fccb47177 100644
--- a/stdlib/source/library/lux/world/net.lux
+++ b/stdlib/source/library/lux/world/net.lux
@@ -1,8 +1,8 @@
(.require
[library
- [lux (.except Location)]])
+ [lux (.except #host)]])
-(type .public Address
+(type .public Host
Text)
(type .public Port
@@ -11,7 +11,7 @@
(type .public URL
Text)
-(type .public Location
+(type .public Address
(Record
- [#address Address
+ [#host Host
#port Port]))
diff --git a/stdlib/source/library/lux/world/net/http.lux b/stdlib/source/library/lux/world/net/http.lux
index 0ca8327aa..b90c770f5 100644
--- a/stdlib/source/library/lux/world/net/http.lux
+++ b/stdlib/source/library/lux/world/net/http.lux
@@ -7,7 +7,7 @@
[frp (.only Channel)]]]
[data
[binary (.only Binary)]]]]
- [// (.only URL)
+ [// (.only Address)
[uri (.only URI)]
[//
["[0]" environment
@@ -28,9 +28,6 @@
{#Options}
{#Trace}))
-(type .public Port
- Nat)
-
(type .public Status
Nat)
@@ -52,30 +49,25 @@
{#HTTP}
{#HTTPS}))
-(type .public Address
- (Record
- [#port Port
- #host Text]))
-
(type .public Identification
(Record
- [#local Address
+ [#local Address
#remote Address]))
(type .public Protocol
(Record
[#version Version
- #scheme Scheme]))
+ #scheme Scheme]))
(type .public Resource
(Record
[#method Method
- #uri URI]))
+ #uri URI]))
(type .public (Message !)
(Record
[#headers Headers
- #body (Body !)]))
+ #body (Body !)]))
(type .public (Request !)
[Identification Protocol Resource (Message !)])