aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler
diff options
context:
space:
mode:
authorEduardo Julian2022-06-15 23:13:48 -0400
committerEduardo Julian2022-06-15 23:13:48 -0400
commitf92c806ee8da63f04bbefbf558f6249bacdb47ea (patch)
treef0ff0c93cfcf68bded11c9676b65232f30032628 /stdlib/source/library/lux/tool/compiler
parent24986506e8beb5074f6aca048506389e90e196bd (diff)
Better syntax for the "sharing" and "by_example" macros.
Diffstat (limited to 'stdlib/source/library/lux/tool/compiler')
-rw-r--r--stdlib/source/library/lux/tool/compiler/default/platform.lux170
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux9
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux9
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux9
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux7
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux7
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/packager/script.lux7
7 files changed, 103 insertions, 115 deletions
diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux
index 1bea3c4e9..e999ae79d 100644
--- a/stdlib/source/library/lux/tool/compiler/default/platform.lux
+++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux
@@ -205,21 +205,20 @@
<State+>
(Try <State+>)))
(|> (sharing [<type_vars>]
- <State+>
- state
-
- (///directive.Operation <type_vars> Any)
- (do [! ///phase.monad]
- [_ (///directive.lifted_analysis
- (do !
- [_ (///analysis.set_state analysis_state)]
- (extension.with extender analysers)))
- _ (///directive.lifted_synthesis
- (extension.with extender synthesizers))
- _ (///directive.lifted_generation
- (extension.with extender (as_expected generators)))
- _ (extension.with extender (as_expected directives))]
- (in [])))
+ (is <State+>
+ state)
+ (is (///directive.Operation <type_vars> Any)
+ (do [! ///phase.monad]
+ [_ (///directive.lifted_analysis
+ (do !
+ [_ (///analysis.set_state analysis_state)]
+ (extension.with extender analysers)))
+ _ (///directive.lifted_synthesis
+ (extension.with extender synthesizers))
+ _ (///directive.lifted_generation
+ (extension.with extender (as_expected generators)))
+ _ (extension.with extender (as_expected directives))]
+ (in []))))
(///phase.result' state)
(at try.monad each product.left)))
@@ -497,73 +496,70 @@
(-> Lux_Compiler Lux_Importer)))
(let [current (stm.var initial)
pending (sharing [<type_vars>]
- Lux_Context
- initial
-
- (Var (Dictionary descriptor.Module Lux_Pending))
- (as_expected (stm.var (dictionary.empty text.hash))))
+ (is Lux_Context
+ initial)
+ (is (Var (Dictionary descriptor.Module Lux_Pending))
+ (as_expected (stm.var (dictionary.empty text.hash)))))
dependence (is (Var Dependence)
(stm.var ..independence))]
(function (_ compile)
(function (import! customs importer module)
(do [! async.monad]
[[return signal] (sharing [<type_vars>]
- Lux_Context
- initial
-
- (Async [Lux_Return (Maybe [Lux_Context
- module.ID
- Lux_Signal])])
- (as_expected
- (stm.commit!
- (do [! stm.monad]
- [dependence (if (text#= descriptor.runtime importer)
- (stm.read dependence)
- (do !
- [[_ dependence] (stm.update (..depend importer module) dependence)]
- (in dependence)))]
- (case (..verify_dependencies importer module dependence)
- {try.#Failure error}
- (in [(async.resolved {try.#Failure error})
- {.#None}])
-
- {try.#Success _}
- (do !
- [[archive state] (stm.read current)]
- (if (archive.archived? archive module)
- (in [(async#in {try.#Success [archive state]})
- {.#None}])
- (do !
- [@pending (stm.read pending)]
- (case (dictionary.value module @pending)
- {.#Some [return signal]}
- (in [return
- {.#None}])
-
- {.#None}
- (case (if (archive.reserved? archive module)
- (do try.monad
- [@module (archive.id module archive)]
- (in [@module archive]))
- (archive.reserve module archive))
- {try.#Success [@module archive]}
- (do !
- [_ (stm.write [archive state] current)
- .let [[return signal] (sharing [<type_vars>]
- Lux_Context
- initial
-
- Lux_Pending
- (async.async []))]
- _ (stm.update (dictionary.has module [return signal]) pending)]
- (in [return
- {.#Some [[archive state]
- @module
- signal]}]))
-
- {try.#Failure error}
- (in [(async#in {try.#Failure error})
- {.#None}])))))))))))
+ (is Lux_Context
+ initial)
+ (is (Async [Lux_Return (Maybe [Lux_Context
+ module.ID
+ Lux_Signal])])
+ (as_expected
+ (stm.commit!
+ (do [! stm.monad]
+ [dependence (if (text#= descriptor.runtime importer)
+ (stm.read dependence)
+ (do !
+ [[_ dependence] (stm.update (..depend importer module) dependence)]
+ (in dependence)))]
+ (case (..verify_dependencies importer module dependence)
+ {try.#Failure error}
+ (in [(async.resolved {try.#Failure error})
+ {.#None}])
+
+ {try.#Success _}
+ (do !
+ [[archive state] (stm.read current)]
+ (if (archive.archived? archive module)
+ (in [(async#in {try.#Success [archive state]})
+ {.#None}])
+ (do !
+ [@pending (stm.read pending)]
+ (case (dictionary.value module @pending)
+ {.#Some [return signal]}
+ (in [return
+ {.#None}])
+
+ {.#None}
+ (case (if (archive.reserved? archive module)
+ (do try.monad
+ [@module (archive.id module archive)]
+ (in [@module archive]))
+ (archive.reserve module archive))
+ {try.#Success [@module archive]}
+ (do !
+ [_ (stm.write [archive state] current)
+ .let [[return signal] (sharing [<type_vars>]
+ (is Lux_Context
+ initial)
+ (is Lux_Pending
+ (async.async [])))]
+ _ (stm.update (dictionary.has module [return signal]) pending)]
+ (in [return
+ {.#Some [[archive state]
+ @module
+ signal]}]))
+
+ {try.#Failure error}
+ (in [(async#in {try.#Failure error})
+ {.#None}]))))))))))))
_ (case signal
{.#None}
(in [])
@@ -725,12 +721,11 @@
(case more|done
{.#Left more}
(let [continue! (sharing [state document object]
- (///.Compilation state document object)
- custom_compilation
-
- (-> (..Context state) (///.Compilation state document object) (Set descriptor.Module)
- (..Return state))
- (as_expected again))]
+ (is (///.Compilation state document object)
+ custom_compilation)
+ (is (-> (..Context state) (///.Compilation state document object) (Set descriptor.Module)
+ (..Return state))
+ (as_expected again)))]
(continue! [archive state] more all_dependencies))
{.#Right entry}
@@ -765,12 +760,11 @@
(case more|done
{.#Left more}
(let [continue! (sharing [<type_vars>]
- <Platform>
- platform
-
- (-> Lux_Context (///.Compilation <State+> .Module Any) (Set descriptor.Module)
- (Action [Archive <State+>]))
- (as_expected again))]
+ (is <Platform>
+ platform)
+ (is (-> Lux_Context (///.Compilation <State+> .Module Any) (Set descriptor.Module)
+ (Action [Archive <State+>]))
+ (as_expected again)))]
(continue! [archive state] more all_dependencies))
{.#Right entry}
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux
index ec2db3996..2cc4503d9 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/analysis/evaluation.lux
@@ -63,11 +63,10 @@
(phase.result generation_state)
(do phase.monad
[@module (sharing [anchor expression artifact]
- (generation.Phase anchor expression artifact)
- generate
-
- (generation.Operation anchor expression artifact module.ID)
- (generation.module_id module archive))
+ (is (generation.Phase anchor expression artifact)
+ generate)
+ (is (generation.Operation anchor expression artifact module.ID)
+ (generation.module_id module archive)))
.let [[evals _] (io.run! (atom.update! (dictionary.revised' @module 0 ++) ..evals))
@eval (maybe.else 0 (dictionary.value @module evals))]
exprO (<| (generation.with_registry_shift (|> @module
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux
index 51f2e09be..47b487dea 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/directive/lux.lux
@@ -447,11 +447,10 @@
_ (<| <scope>
(///.install extender (as Text name))
(sharing [anchor expression directive]
- (Handler anchor expression directive)
- handler
-
- <type>
- (as_expected handlerV)))
+ (is (Handler anchor expression directive)
+ handler)
+ (is <type>
+ (as_expected handlerV))))
_ (/////directive.lifted_generation
(/////generation.log! (format <description> " " (%.text (as Text name)))))]
(in /////directive.no_requirements))
diff --git a/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux b/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux
index 753950787..56dd787be 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/archive/module/document.lux
@@ -37,11 +37,10 @@
(key.signature key)
document//signature)
{try.#Success (sharing [e]
- (Key e)
- key
-
- e
- (as_expected document//content))}
+ (is (Key e)
+ key)
+ (is e
+ (as_expected document//content)))}
(exception.except ..invalid_signature [(key.signature key)
document//signature]))))
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 95115a376..0937615cc 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/packager/ruby.lux
@@ -63,11 +63,10 @@
(at utf8.codec decoded)
(at ! each
(|>> as_expected
+ (is directive)
(sharing [directive]
- directive
- so_far
-
- directive)
+ (is directive
+ so_far))
(_.then so_far)))))
(_.comment "Lux module"
(_.statement (_.string "")))
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 836d56ba6..1fed07990 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/packager/scheme.lux
@@ -64,11 +64,10 @@
(at encoding.utf8 decoded)
(at try.monad each
(|>> as_expected
+ (is directive)
(sharing [directive]
- directive
- so_far
-
- directive)
+ (is directive
+ so_far))
(..then so_far)))))
(is _.Expression (_.manual "")))))
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 4c0a79c77..382536417 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/packager/script.lux
@@ -50,11 +50,10 @@
(at utf8.codec decoded)
(at try.monad each
(|>> as_expected
+ (is directive)
(sharing [directive]
- directive
- so_far
-
- directive)
+ (is directive
+ so_far))
(sequence so_far)))))
so_far)))