aboutsummaryrefslogtreecommitdiff
path: root/stdlib
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
parent24986506e8beb5074f6aca048506389e90e196bd (diff)
Better syntax for the "sharing" and "by_example" macros.
Diffstat (limited to 'stdlib')
-rw-r--r--stdlib/source/documentation/lux/type.lux20
-rw-r--r--stdlib/source/library/lux/control/concurrency/actor.lux22
-rw-r--r--stdlib/source/library/lux/control/concurrency/async.lux63
-rw-r--r--stdlib/source/library/lux/control/concurrency/frp.lux20
-rw-r--r--stdlib/source/library/lux/control/concurrency/stm.lux9
-rw-r--r--stdlib/source/library/lux/control/lazy.lux9
-rw-r--r--stdlib/source/library/lux/data/collection/queue/priority.lux7
-rw-r--r--stdlib/source/library/lux/data/text/unicode/set.lux8
-rw-r--r--stdlib/source/library/lux/math/number/i16.lux7
-rw-r--r--stdlib/source/library/lux/math/number/i32.lux7
-rw-r--r--stdlib/source/library/lux/math/number/i8.lux7
-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
-rw-r--r--stdlib/source/library/lux/tool/interpreter.lux36
-rw-r--r--stdlib/source/library/lux/type.lux39
-rw-r--r--stdlib/source/library/lux/type/quotient.lux9
-rw-r--r--stdlib/source/library/lux/type/refinement.lux5
-rw-r--r--stdlib/source/library/lux/type/unit.lux5
-rw-r--r--stdlib/source/library/lux/type/unit/scale.lux5
-rw-r--r--stdlib/source/parser/lux/data/binary.lux9
-rw-r--r--stdlib/source/program/compositor.lux26
-rw-r--r--stdlib/source/test/lux/control/region.lux18
-rw-r--r--stdlib/source/test/lux/data/collection/tree/finger.lux7
-rw-r--r--stdlib/source/test/lux/documentation.lux41
-rw-r--r--stdlib/source/test/lux/type.lux16
30 files changed, 284 insertions, 329 deletions
diff --git a/stdlib/source/documentation/lux/type.lux b/stdlib/source/documentation/lux/type.lux
index 0d7a4da40..3c913198a 100644
--- a/stdlib/source/documentation/lux/type.lux
+++ b/stdlib/source/documentation/lux/type.lux
@@ -131,22 +131,20 @@
"Allows specifing the type of an expression as sharing type-variables with the type of another expression."
[(is (Bar Bit Nat Text)
(sharing [a b c]
- (Foo a [b c])
- (is (Foo Bit [Nat Text])
- (foo expression))
-
- (Bar a b c)
- (bar expression)))])
+ (is (Foo a [b c])
+ (is (Foo Bit [Nat Text])
+ (foo expression)))
+ (is (Bar a b c)
+ (bar expression))))])
(documentation: /.by_example
"Constructs a type that shares type-variables with an expression of some other type."
[(is Type
(by_example [a b c]
- (Foo a [b c])
- (is (Foo Bit [Nat Text])
- (foo expression))
-
- (Bar a b c)))
+ (is (Foo a [b c])
+ (is (Foo Bit [Nat Text])
+ (foo expression)))
+ (Bar a b c)))
"=>"
(.type (Bar Bit Nat Text))])
diff --git a/stdlib/source/library/lux/control/concurrency/actor.lux b/stdlib/source/library/lux/control/concurrency/actor.lux
index fc2033517..40bc65ec2 100644
--- a/stdlib/source/library/lux/control/concurrency/actor.lux
+++ b/stdlib/source/library/lux/control/concurrency/actor.lux
@@ -65,12 +65,11 @@
(def: .public (spawn! behavior init)
(All (_ s) (-> (Behavior s) s (IO (Actor s))))
(io (let [self (sharing [s]
- (Behavior s)
- behavior
-
- (Actor s)
- (abstraction [#obituary (async.async [])
- #mailbox (atom (async.async []))]))
+ (is (Behavior s)
+ behavior)
+ (is (Actor s)
+ (abstraction [#obituary (async.async [])
+ #mailbox (atom (async.async []))])))
process (loop (again [state init
[|mailbox| _] (io.run! (atom.read! (the #mailbox (representation self))))])
(do [! async.monad]
@@ -144,12 +143,11 @@
(def: (mail message)
(All (_ s o) (-> (Message s o) [(Async (Try o)) (Mail s)]))
(let [[async resolve] (sharing [s o]
- (Message s o)
- message
-
- [(Async (Try o))
- (Resolver (Try o))]
- (async.async []))]
+ (is (Message s o)
+ message)
+ (is [(Async (Try o))
+ (Resolver (Try o))]
+ (async.async [])))]
[async
(function (_ state self)
(do [! async.monad]
diff --git a/stdlib/source/library/lux/control/concurrency/async.lux b/stdlib/source/library/lux/control/concurrency/async.lux
index 20fabdb3b..192c4e24c 100644
--- a/stdlib/source/library/lux/control/concurrency/async.lux
+++ b/stdlib/source/library/lux/control/concurrency/async.lux
@@ -103,11 +103,10 @@
(implementation
(def: (each f fa)
(let [[fb resolve] (sharing [a b]
- (-> a b)
- f
-
- [(Async b) (Resolver b)]
- (..async []))]
+ (is (-> a b)
+ f)
+ (is [(Async b) (Resolver b)]
+ (..async [])))]
(exec
(io.run! (..upon! (|>> f resolve) fa))
fb)))))
@@ -119,11 +118,10 @@
(def: (on fa ff)
(let [[fb resolve] (sharing [a b]
- (Async (-> a b))
- ff
-
- [(Async b) (Resolver b)]
- (..async []))]
+ (is (Async (-> a b))
+ ff)
+ (is [(Async b) (Resolver b)]
+ (..async [])))]
(exec
(io.run! (..upon! (function (_ f)
(..upon! (|>> f resolve) fa))
@@ -139,11 +137,10 @@
(def: (conjoint mma)
(let [[ma resolve] (sharing [a]
- (Async (Async a))
- mma
-
- [(Async a) (Resolver a)]
- (..async []))]
+ (is (Async (Async a))
+ mma)
+ (is [(Async a) (Resolver a)]
+ (..async [])))]
(exec
(io.run! (..upon! (..upon! resolve) mma))
ma)))))
@@ -151,11 +148,10 @@
(def: .public (and left right)
(All (_ lr lw rr rw) (-> (Async' lr lw) (Async' rr rw) (Async [lr rr])))
(let [[read! write!] (sharing [lr lw rr rw]
- [(Async' lr lw) (Async' rr rw)]
- [left right]
-
- [(Async [lr rr]) (Resolver [lr rr])]
- (..async []))
+ (is [(Async' lr lw) (Async' rr rw)]
+ [left right])
+ (is [(Async [lr rr]) (Resolver [lr rr])]
+ (..async [])))
_ (io.run! (..upon! (function (_ left)
(..upon! (function (_ right)
(write! [left right]))
@@ -166,11 +162,10 @@
(def: .public (or left right)
(All (_ lr lw rr rw) (-> (Async' lr lw) (Async' rr rw) (Async (Or lr rr))))
(let [[left|right resolve] (sharing [lr lw rr rw]
- [(Async' lr lw) (Async' rr rw)]
- [left right]
-
- [(Async (Or lr rr)) (Resolver (Or lr rr))]
- (..async []))]
+ (is [(Async' lr lw) (Async' rr rw)]
+ [left right])
+ (is [(Async (Or lr rr)) (Resolver (Or lr rr))]
+ (..async [])))]
(with_expansions
[<sides> (with_template [<async> <tag>]
[(io.run! (upon! (|>> {<tag>} resolve) <async>))]
@@ -185,11 +180,10 @@
(def: .public (either left right)
(All (_ a lw rw) (-> (Async' a lw) (Async' a rw) (Async a)))
(let [[left||right resolve] (sharing [a lw rw]
- [(Async' a lw) (Async' a rw)]
- [left right]
-
- [(Async a) (Resolver a)]
- (..async []))]
+ (is [(Async' a lw) (Async' a rw)]
+ [left right])
+ (is [(Async a) (Resolver a)]
+ (..async [])))]
(`` (exec
(~~ (with_template [<async>]
[(io.run! (upon! resolve <async>))]
@@ -201,11 +195,10 @@
(def: .public (schedule! milli_seconds computation)
(All (_ a) (-> Nat (IO a) (Async a)))
(let [[!out resolve] (sharing [a]
- (IO a)
- computation
-
- [(Async a) (Resolver a)]
- (..async []))]
+ (is (IO a)
+ computation)
+ (is [(Async a) (Resolver a)]
+ (..async [])))]
(exec
(|> (do io.monad
[value computation]
diff --git a/stdlib/source/library/lux/control/concurrency/frp.lux b/stdlib/source/library/lux/control/concurrency/frp.lux
index e49a80418..43aae713f 100644
--- a/stdlib/source/library/lux/control/concurrency/frp.lux
+++ b/stdlib/source/library/lux/control/concurrency/frp.lux
@@ -63,12 +63,11 @@
(do [! io.monad]
[current (atom.read! sink)
.let [[next resolve_next] (sharing [a]
- (async.Resolver (Maybe [(Mutable a a) (Channel a)]))
- current
-
- [(Channel a)
- (async.Resolver (Maybe [(Mutable a a) (Channel a)]))]
- (async.async []))]
+ (is (async.Resolver (Maybe [(Mutable a a) (Channel a)]))
+ current)
+ (is [(Channel a)
+ (async.Resolver (Maybe [(Mutable a a) (Channel a)]))]
+ (async.async [])))]
fed? (current {.#Some [(variance.write value) next]})]
(if fed?
... I fed the sink.
@@ -130,11 +129,10 @@
(def: (conjoint mma)
(let [[output sink] (sharing [a]
- (Channel (Channel a))
- mma
-
- [(Channel a) (Sink a)]
- (channel []))]
+ (is (Channel (Channel a))
+ mma)
+ (is [(Channel a) (Sink a)]
+ (channel [])))]
(exec
(is (Async Any)
(loop (again [mma mma])
diff --git a/stdlib/source/library/lux/control/concurrency/stm.lux b/stdlib/source/library/lux/control/concurrency/stm.lux
index c5323c442..2a0ae3956 100644
--- a/stdlib/source/library/lux/control/concurrency/stm.lux
+++ b/stdlib/source/library/lux/control/concurrency/stm.lux
@@ -74,11 +74,10 @@
(All (_ a) (-> (Var a) (IO [(Channel a) (Sink a)])))
(do io.monad
[.let [[channel sink] (sharing [a]
- (Var a)
- target
-
- [(Channel a) (Sink a)]
- (frp.channel []))]
+ (is (Var a)
+ target)
+ (is [(Channel a) (Sink a)]
+ (frp.channel [])))]
_ (atom.update! (function (_ [value observers])
[value {.#Item (implementation
(def: close (at sink close))
diff --git a/stdlib/source/library/lux/control/lazy.lux b/stdlib/source/library/lux/control/lazy.lux
index c96a5f569..343f866f7 100644
--- a/stdlib/source/library/lux/control/lazy.lux
+++ b/stdlib/source/library/lux/control/lazy.lux
@@ -23,11 +23,10 @@
(def: (lazy' generator)
(All (_ a) (-> (-> [] a) (Lazy a)))
(let [cache (atom.atom (sharing [a]
- (-> [] a)
- generator
-
- (Maybe a)
- {.#None}))]
+ (is (-> [] a)
+ generator)
+ (is (Maybe a)
+ {.#None})))]
(abstraction (function (_ _)
(case (io.run! (atom.read! cache))
{.#Some value}
diff --git a/stdlib/source/library/lux/data/collection/queue/priority.lux b/stdlib/source/library/lux/data/collection/queue/priority.lux
index 2cf313bec..e3016e239 100644
--- a/stdlib/source/library/lux/data/collection/queue/priority.lux
+++ b/stdlib/source/library/lux/data/collection/queue/priority.lux
@@ -32,10 +32,9 @@
(def: :@:
(by_example [@]
- (tree.Builder @ Priority)
- ..builder
-
- @))
+ (is (tree.Builder @ Priority)
+ ..builder)
+ @))
(primitive .public (Queue a)
(Maybe (Tree :@: Priority a))
diff --git a/stdlib/source/library/lux/data/text/unicode/set.lux b/stdlib/source/library/lux/data/text/unicode/set.lux
index fdbf1955a..287c78ca0 100644
--- a/stdlib/source/library/lux/data/text/unicode/set.lux
+++ b/stdlib/source/library/lux/data/text/unicode/set.lux
@@ -21,10 +21,10 @@
(def: :@:
(by_example [@]
- (tree.Builder @ Block)
- ..builder
-
- @))
+ (is (tree.Builder @ Block)
+ ..builder)
+
+ @))
(primitive .public Set
(Tree :@: Block [])
diff --git a/stdlib/source/library/lux/math/number/i16.lux b/stdlib/source/library/lux/math/number/i16.lux
index 50f4290d8..76488032d 100644
--- a/stdlib/source/library/lux/math/number/i16.lux
+++ b/stdlib/source/library/lux/math/number/i16.lux
@@ -22,10 +22,9 @@
_
(undefined))
... (by_example [size]
- ... (Sub size)
- ... ..sub
-
- ... (I64 size))
+ ... (is (Sub size)
+ ... ..sub)
+ ... (I64 size))
)
(def: .public equivalence (Equivalence I16) (at ..sub sub_equivalence))
diff --git a/stdlib/source/library/lux/math/number/i32.lux b/stdlib/source/library/lux/math/number/i32.lux
index 11c2dc77a..42a35144c 100644
--- a/stdlib/source/library/lux/math/number/i32.lux
+++ b/stdlib/source/library/lux/math/number/i32.lux
@@ -24,10 +24,9 @@
_
(undefined))
... (by_example [size]
- ... (Sub size)
- ... ..sub
-
- ... (I64 size))
+ ... (is (Sub size)
+ ... ..sub)
+ ... (I64 size))
)
(def: .public equivalence (Equivalence I32) (at ..sub sub_equivalence))
diff --git a/stdlib/source/library/lux/math/number/i8.lux b/stdlib/source/library/lux/math/number/i8.lux
index 2467318e0..36bafd4d6 100644
--- a/stdlib/source/library/lux/math/number/i8.lux
+++ b/stdlib/source/library/lux/math/number/i8.lux
@@ -22,10 +22,9 @@
_
(undefined))
... (by_example [size]
- ... (Sub size)
- ... ..sub
-
- ... (I64 size))
+ ... (is (Sub size)
+ ... ..sub)
+ ... (I64 size))
)
(def: .public equivalence (Equivalence I8) (at ..sub sub_equivalence))
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)))
diff --git a/stdlib/source/library/lux/tool/interpreter.lux b/stdlib/source/library/lux/tool/interpreter.lux
index 3ba22ff82..f54f0ae59 100644
--- a/stdlib/source/library/lux/tool/interpreter.lux
+++ b/stdlib/source/library/lux/tool/interpreter.lux
@@ -130,11 +130,10 @@
(function (_ state)
(case (<| (phase.result' state)
(sharing [anchor expression directive]
- (State+ anchor expression directive)
- state
-
- <Interpretation>
- (interpret_directive code)))
+ (is (State+ anchor expression directive)
+ state)
+ (is <Interpretation>
+ (interpret_directive code))))
{try.#Success [state' output]}
{try.#Success [state' output]}
@@ -142,11 +141,10 @@
(if (ex.match? total.not_a_directive error)
(<| (phase.result' state)
(sharing [anchor expression directive]
- (State+ anchor expression directive)
- state
-
- <Interpretation>
- (interpret_expression code)))
+ (is (State+ anchor expression directive)
+ state)
+ (is <Interpretation>
+ (interpret_expression code))))
{try.#Failure error}))))
)
@@ -178,19 +176,17 @@
[source' input] (syntax.parse ..module syntax.no_aliases (text.size _code) (the #source context))
[state' representation] (let [... TODO: Simplify ASAP
state (sharing [anchor expression directive]
- <Context>
- context
-
- (State+ anchor expression directive)
- (the #state context))]
+ (is <Context>
+ context)
+ (is (State+ anchor expression directive)
+ (the #state context)))]
(<| (phase.result' state)
... TODO: Simplify ASAP
(sharing [anchor expression directive]
- <Context>
- context
-
- (Operation anchor expression directive Text)
- (execute (the #configuration context) input))))]
+ (is <Context>
+ context)
+ (is (Operation anchor expression directive Text)
+ (execute (the #configuration context) input)))))]
(in [(|> context
(has #state state')
(has #source source'))
diff --git a/stdlib/source/library/lux/type.lux b/stdlib/source/library/lux/type.lux
index e6a7504e9..52c70ada9 100644
--- a/stdlib/source/library/lux/type.lux
+++ b/stdlib/source/library/lux/type.lux
@@ -442,15 +442,21 @@
[#type Code
#expression Code]))
-(def: typed
- (Parser Typed)
- (<>.and <code>.any <code>.any))
+(def: (typed lux)
+ (-> Lux (Parser Typed))
+ (do <>.monad
+ [it <code>.any
+ type_check (<>.lifted (meta.result lux (macro.expansion it)))]
+ (<| (<code>.locally type_check)
+ <code>.form
+ (<>.after (<code>.this (` "lux type check")))
+ (<>.and <code>.any <code>.any))))
... TODO: Make sure the generated code always gets optimized away.
(def: .public sharing
- (syntax (_ [type_vars ..type_parameters
- exemplar ..typed
- computation ..typed])
+ (syntax (_ lux [type_vars ..type_parameters
+ exemplar (..typed lux)
+ computation (..typed lux)])
(macro.with_symbols [g!_]
(.let [typeC (` (All ((~ g!_) (~+ (list#each code.local type_vars)))
(-> (~ (the #type exemplar))
@@ -461,18 +467,15 @@
(in (list (` ((~ shareC) (~ (the #expression exemplar))))))))))
(def: .public by_example
- (syntax (_ [type_vars ..type_parameters
- exemplar ..typed
- extraction <code>.any])
- (in (list (` (.type_of ((~! ..sharing)
- [(~+ (list#each code.local type_vars))]
-
- (~ (the #type exemplar))
- (~ (the #expression exemplar))
-
- (~ extraction)
- ... The value of this expression will never be relevant, so it doesn't matter what it is.
- (.as .Nothing []))))))))
+ (syntax (_ lux [type_vars ..type_parameters
+ exemplar (..typed lux)
+ extraction <code>.any])
+ (in (list (` (.type_of ((~! ..sharing) [(~+ (list#each code.local type_vars))]
+ (is (~ (the #type exemplar))
+ (~ (the #expression exemplar)))
+ (is (~ extraction)
+ ... The value of this expression will never be relevant, so it doesn't matter what it is.
+ (.as .Nothing [])))))))))
(def: .public (replaced before after)
(-> Type Type Type Type)
diff --git a/stdlib/source/library/lux/type/quotient.lux b/stdlib/source/library/lux/type/quotient.lux
index 59f518ad8..da7c38025 100644
--- a/stdlib/source/library/lux/type/quotient.lux
+++ b/stdlib/source/library/lux/type/quotient.lux
@@ -57,12 +57,9 @@
(~ g!_)
(.undefined))))
- ... (` ((~! type.by_example)
- ... [(~ g!t) (~ g!c) (~ g!%)]
-
- ... (..Class (~ g!t) (~ g!c) (~ g!%))
- ... (~ class)
-
+ ... (` ((~! type.by_example) [(~ g!t) (~ g!c) (~ g!%)]
+ ... (is (..Class (~ g!t) (~ g!c) (~ g!%))
+ ... (~ class))
... (..Quotient (~ g!t) (~ g!c) (~ g!%))))
)))))
diff --git a/stdlib/source/library/lux/type/refinement.lux b/stdlib/source/library/lux/type/refinement.lux
index 102ba9c5a..0fb387039 100644
--- a/stdlib/source/library/lux/type/refinement.lux
+++ b/stdlib/source/library/lux/type/refinement.lux
@@ -99,8 +99,7 @@
(~ g!_)
(.undefined))))
... (` ((~! type.by_example) [(~ g!t) (~ g!%)]
- ... (..Refiner (~ g!t) (~ g!%))
- ... (~ refiner)
-
+ ... (is (..Refiner (~ g!t) (~ g!%))
+ ... (~ refiner))
... (..Refined (~ g!t) (~ g!%))))
)))))
diff --git a/stdlib/source/library/lux/type/unit.lux b/stdlib/source/library/lux/type/unit.lux
index 631cc79a5..9a84487e4 100644
--- a/stdlib/source/library/lux/type/unit.lux
+++ b/stdlib/source/library/lux/type/unit.lux
@@ -86,9 +86,8 @@
(syntax (_ [it <code>.any])
(macro.with_symbols [g!a]
(in (list (` ((~! //.by_example) [(~ g!a)]
- (..Unit (~ g!a))
- (~ it)
-
+ (is (..Unit (~ g!a))
+ (~ it))
(~ g!a))))))))
(with_template [<unit> <type>]
diff --git a/stdlib/source/library/lux/type/unit/scale.lux b/stdlib/source/library/lux/type/unit/scale.lux
index 3a956baf0..fe2d020bf 100644
--- a/stdlib/source/library/lux/type/unit/scale.lux
+++ b/stdlib/source/library/lux/type/unit/scale.lux
@@ -53,9 +53,8 @@
(syntax (_ [it <code>.any])
(macro.with_symbols [g!a]
(in (list (` ((~! ///.by_example) [(~ g!a)]
- (..Scale (~ g!a))
- (~ it)
-
+ (is (..Scale (~ g!a))
+ (~ it))
(~ g!a))))))))
(with_template [<order_of_magnitude> <up> <up_type> <down> <down_type>]
diff --git a/stdlib/source/parser/lux/data/binary.lux b/stdlib/source/parser/lux/data/binary.lux
index 1a49d5315..d09eeba86 100644
--- a/stdlib/source/parser/lux/data/binary.lux
+++ b/stdlib/source/parser/lux/data/binary.lux
@@ -223,11 +223,10 @@
<bits>)]
(loop (again [index 0
output (sharing [v]
- (Parser v)
- valueP
-
- (Sequence v)
- sequence.empty)])
+ (is (Parser v)
+ valueP)
+ (is (Sequence v)
+ sequence.empty))])
(if (n.< amount index)
(do //.monad
[value valueP]
diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux
index 4287a901f..5e71b0741 100644
--- a/stdlib/source/program/compositor.lux
+++ b/stdlib/source/program/compositor.lux
@@ -160,20 +160,18 @@
[.let [[compilation_host_dependencies compilation_libraries compilation_compilers compilation_sources compilation_target compilation_module compilation_configuration] compilation]
import (import.import (the platform.#file_system platform) compilation_libraries)
[state archive phase_wrapper] (sharing [<parameters>]
- (Platform <parameters>)
- platform
-
- (Async (Try [(directive.State+ <parameters>)
- Archive
- phase.Wrapper]))
- (as_expected (platform.initialize file_context compilation_module expander host_analysis platform generation_bundle host_directive_bundle program anchorT,expressionT,directiveT extender
- import compilation_sources compilation_configuration)))
+ (is (Platform <parameters>)
+ platform)
+ (is (Async (Try [(directive.State+ <parameters>)
+ Archive
+ phase.Wrapper]))
+ (as_expected (platform.initialize file_context compilation_module expander host_analysis platform generation_bundle host_directive_bundle program anchorT,expressionT,directiveT extender
+ import compilation_sources compilation_configuration))))
[archive state] (sharing [<parameters>]
- (Platform <parameters>)
- platform
-
- (Async (Try [Archive (directive.State+ <parameters>)]))
- (as_expected (platform.compile lux_compiler phase_wrapper import file_context expander platform compilation [archive state])))
+ (is (Platform <parameters>)
+ platform)
+ (is (Async (Try [Archive (directive.State+ <parameters>)]))
+ (as_expected (platform.compile lux_compiler phase_wrapper import file_context expander platform compilation [archive state]))))
_ (cache.cache! (the platform.#file_system platform) file_context archive)
host_dependencies (..load_host_dependencies (the platform.#file_system platform) compilation_host_dependencies)
_ (..package! (for @.old (file.async file.default)
@@ -191,7 +189,7 @@
(<| (or_crash! "Export failed:")
(do (try.with async.monad)
[_ (export.export (the platform.#file_system platform)
- export)]
+ export)]
(in (debug.log! "Export complete!"))))
{cli.#Interpretation interpretation}
diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux
index 258436915..999d1fa6b 100644
--- a/stdlib/source/test/lux/control/region.lux
+++ b/stdlib/source/test/lux/control/region.lux
@@ -59,17 +59,15 @@
(Comparison (All (_ a) (All (_ ! r) (Region r (Thread !) a))))
(function (_ == left right)
(case [(sharing [a]
- (Equivalence a)
- ==
-
- (Try a)
- (thread.result (as_expected (/.run! thread.monad left))))
+ (is (Equivalence a)
+ ==)
+ (is (Try a)
+ (thread.result (as_expected (/.run! thread.monad left)))))
(sharing [a]
- (Equivalence a)
- ==
-
- (Try a)
- (thread.result (as_expected (/.run! thread.monad right))))]
+ (is (Equivalence a)
+ ==)
+ (is (Try a)
+ (thread.result (as_expected (/.run! thread.monad right)))))]
[{try.#Success left} {try.#Success right}]
(== left right)
diff --git a/stdlib/source/test/lux/data/collection/tree/finger.lux b/stdlib/source/test/lux/data/collection/tree/finger.lux
index 65bf9e589..bb6d9ac98 100644
--- a/stdlib/source/test/lux/data/collection/tree/finger.lux
+++ b/stdlib/source/test/lux/data/collection/tree/finger.lux
@@ -23,10 +23,9 @@
(def: :@:
(by_example [@]
- (/.Builder @ Text)
- ..builder
-
- @))
+ (is (/.Builder @ Text)
+ ..builder)
+ @))
(def: .public test
Test
diff --git a/stdlib/source/test/lux/documentation.lux b/stdlib/source/test/lux/documentation.lux
index 9c4f1fc2a..600030da4 100644
--- a/stdlib/source/test/lux/documentation.lux
+++ b/stdlib/source/test/lux/documentation.lux
@@ -44,8 +44,9 @@
Nat
123)
- (/.documentation: /.documentation:
- 'definition_description')
+ (def: documentation
+ (/.documentation /.documentation
+ 'definition_description'))
(def: .public test
Test
@@ -67,13 +68,13 @@
_
false))
- (_.coverage [/.documentation:]
- (case ..documentation:
- (pattern (list documentation:))
- (and (|> documentation:
+ (_.coverage [/.documentation]
+ (case ..documentation
+ (pattern (list documentation))
+ (and (|> documentation
(the /.#definition)
- (text#= (template.text [/.documentation:])))
- (|> documentation:
+ (text#= (template.text [/.documentation])))
+ (|> documentation
(the /.#documentation)
md.markdown
(text.contains? 'definition_description')))
@@ -83,25 +84,25 @@
))
(_.for [/.Module]
(all _.and
- (_.coverage [/.module /.documentation]
+ (_.coverage [/.module /.markdown]
(let [sub (`` (/.module /._
(~~ (template.text ['sub_description']))
[]
[]))
super (`` (/.module .._
(~~ (template.text ['super_description']))
- [..documentation:]
+ [..documentation]
[sub]))]
(and (text.contains? (template.text ['sub_description'])
- (/.documentation sub))
- (text.contains? (/.documentation sub)
- (/.documentation super))
+ (/.markdown sub))
+ (text.contains? (/.markdown sub)
+ (/.markdown super))
(text.contains? (template.text ['super_description'])
- (/.documentation super))
- (case ..documentation:
- (pattern (list documentation:))
- (text.contains? (md.markdown (the /.#documentation documentation:))
- (/.documentation super))
+ (/.markdown super))
+ (case ..documentation
+ (pattern (list documentation))
+ (text.contains? (md.markdown (the /.#documentation documentation))
+ (/.markdown super))
_
false))))
@@ -111,11 +112,11 @@
[(macro_error <example>)]
[(/.default g!default)]
- [(/.documentation: g!default
+ [(/.documentation g!default
(~~ (template.text ['definition_description'])))]
[(/.module g!default
""
- [..documentation:]
+ [..documentation]
[sub])]
)))))
)))))
diff --git a/stdlib/source/test/lux/type.lux b/stdlib/source/test/lux/type.lux
index f14d09760..e365ab360 100644
--- a/stdlib/source/test/lux/type.lux
+++ b/stdlib/source/test/lux/type.lux
@@ -199,10 +199,9 @@
{.#None})]
(/#= (.type (List Nat))
(/.by_example [a]
- (Maybe a)
- example
-
- (List a)))))
+ (is (Maybe a)
+ example)
+ (List a)))))
(do random.monad
[sample random.nat]
(_.coverage [/.log!]
@@ -223,11 +222,10 @@
(_.coverage [/.sharing]
(n.= expected
(/.sharing [a]
- (I64 a)
- expected
-
- (I64 a)
- (.i64 expected)))))
+ (is (I64 a)
+ expected)
+ (is (I64 a)
+ (.i64 expected))))))
(do random.monad
[expected_left random.nat
expected_right random.nat]