aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--documentation/bookmark/architecture/messaging.md4
-rw-r--r--documentation/bookmark/audio/plugin.md4
-rw-r--r--documentation/bookmark/business/competitiveness.md4
-rw-r--r--documentation/bookmark/business/leadership.md1
-rw-r--r--documentation/bookmark/business/monetization.md5
-rw-r--r--documentation/bookmark/competitive_programming.md4
-rw-r--r--documentation/bookmark/data/conversion.md4
-rw-r--r--documentation/bookmark/data/graphic.md4
-rw-r--r--documentation/bookmark/debugging.md1
-rw-r--r--documentation/bookmark/design/flexibility.md4
-rw-r--r--documentation/bookmark/design/onboarding.md4
-rw-r--r--documentation/bookmark/graphic/3d/rendering.md16
-rw-r--r--documentation/bookmark/math/number/dual.md1
-rw-r--r--documentation/bookmark/math/proof.md4
-rw-r--r--documentation/bookmark/open_source.md1
-rw-r--r--documentation/bookmark/optics.md1
-rw-r--r--documentation/bookmark/philanthropy.md4
-rw-r--r--documentation/bookmark/programming_language/implementation/stack.md4
-rw-r--r--documentation/bookmark/rendering.md15
-rw-r--r--documentation/bookmark/security/isolation.md4
-rw-r--r--documentation/bookmark/tool/text_editor/font.md2
-rw-r--r--documentation/bookmark/user_interface/animation.md1
-rw-r--r--documentation/bookmark/workflow.md1
-rw-r--r--lux-mode/lux-mode.el2
-rw-r--r--stdlib/source/documentation/lux/type/unit.lux13
-rw-r--r--stdlib/source/library/lux.lux61
-rw-r--r--stdlib/source/library/lux/target/jvm/class.lux27
-rw-r--r--stdlib/source/library/lux/target/jvm/field.lux25
-rw-r--r--stdlib/source/library/lux/target/jvm/method.lux31
-rw-r--r--stdlib/source/library/lux/target/jvm/modifier.lux2
-rw-r--r--stdlib/source/library/lux/target/jvm/modifier/inner.lux27
-rw-r--r--stdlib/source/library/lux/type/unit.lux137
-rw-r--r--stdlib/source/library/lux/type/unit/scale.lux79
-rw-r--r--stdlib/source/polytypic/lux/data/format/json.lux5
-rw-r--r--stdlib/source/test/lux/data/format/json.lux3
-rw-r--r--stdlib/source/test/lux/type/unit.lux105
-rw-r--r--stdlib/source/test/lux/type/unit/scale.lux97
37 files changed, 401 insertions, 306 deletions
diff --git a/documentation/bookmark/architecture/messaging.md b/documentation/bookmark/architecture/messaging.md
new file mode 100644
index 000000000..1e72299a5
--- /dev/null
+++ b/documentation/bookmark/architecture/messaging.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [NSQ: A realtime distributed messaging platform](https://nsq.io/)
+
diff --git a/documentation/bookmark/audio/plugin.md b/documentation/bookmark/audio/plugin.md
new file mode 100644
index 000000000..4db6e38a5
--- /dev/null
+++ b/documentation/bookmark/audio/plugin.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [CLAP: The New Audio Plug-in Standard](https://u-he.com/community/clap/)
+
diff --git a/documentation/bookmark/business/competitiveness.md b/documentation/bookmark/business/competitiveness.md
new file mode 100644
index 000000000..da4f83a26
--- /dev/null
+++ b/documentation/bookmark/business/competitiveness.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Moats: Durable competitive advantage](https://longform.asmartbear.com/posts/moats/)
+
diff --git a/documentation/bookmark/business/leadership.md b/documentation/bookmark/business/leadership.md
index 1cb296655..1d453f73d 100644
--- a/documentation/bookmark/business/leadership.md
+++ b/documentation/bookmark/business/leadership.md
@@ -1,5 +1,6 @@
# Reference
+0. [There’s No Such Thing as Constructive Criticism](https://hbr.org/2011/11/theres-no-such-thing-as-constr.html)
0. [How Patience Pays Off](https://www.permanentequity.com/writings/how-patience-pays-off)
0. [Why Agile Turns into Micromanagement](https://age-of-product.com/agile-micromanagement/)
diff --git a/documentation/bookmark/business/monetization.md b/documentation/bookmark/business/monetization.md
new file mode 100644
index 000000000..6a2d02e69
--- /dev/null
+++ b/documentation/bookmark/business/monetization.md
@@ -0,0 +1,5 @@
+# Reference
+
+0. [Awesome OSS Monetization](https://paydevs.github.io/awesome-oss-monetization/)
+0. [Grant for the Web](https://www.grantfortheweb.org/)
+
diff --git a/documentation/bookmark/competitive_programming.md b/documentation/bookmark/competitive_programming.md
new file mode 100644
index 000000000..d1d57ffa9
--- /dev/null
+++ b/documentation/bookmark/competitive_programming.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Competitive Programmer’s Handbook](https://cses.fi/book/book.pdf)
+
diff --git a/documentation/bookmark/data/conversion.md b/documentation/bookmark/data/conversion.md
new file mode 100644
index 000000000..49d0ef572
--- /dev/null
+++ b/documentation/bookmark/data/conversion.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Converting Integers to Floats Using Hyperfocus](https://blog.m-ou.se/floats/)
+
diff --git a/documentation/bookmark/data/graphic.md b/documentation/bookmark/data/graphic.md
new file mode 100644
index 000000000..eada12d92
--- /dev/null
+++ b/documentation/bookmark/data/graphic.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [A Very, Very Tiny Grammar of Graphics](https://observablehq.com/@joshpoll/vvt-gog)
+
diff --git a/documentation/bookmark/debugging.md b/documentation/bookmark/debugging.md
index 64e9bdbc6..4942f9cb3 100644
--- a/documentation/bookmark/debugging.md
+++ b/documentation/bookmark/debugging.md
@@ -20,6 +20,7 @@
# Reference
+0. [Traces vs. Snapshots: Print Statements and Debuggers](https://www.scott-a-s.com/traces-vs-snapshots/)
0. [Unobtrusive runtime warnings for libraries](https://www.pointfree.co/blog/posts/70-unobtrusive-runtime-warnings-for-libraries)
0. [Debugging in Clojure](https://blog.davemartin.me/posts/debugging-in-clojure/)
0. [The Debugging Book: Tools and Techniques for Automated Software Debugging](https://www.debuggingbook.org/)
diff --git a/documentation/bookmark/design/flexibility.md b/documentation/bookmark/design/flexibility.md
new file mode 100644
index 000000000..d860f1132
--- /dev/null
+++ b/documentation/bookmark/design/flexibility.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Pass-Through Lists](https://jonathanwarden.com/2014/06/19/pass-through-lists/)
+
diff --git a/documentation/bookmark/design/onboarding.md b/documentation/bookmark/design/onboarding.md
new file mode 100644
index 000000000..383a22b77
--- /dev/null
+++ b/documentation/bookmark/design/onboarding.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Feature onboarding](https://primer.style/design/ui-patterns/feature-onboarding)
+
diff --git a/documentation/bookmark/graphic/3d/rendering.md b/documentation/bookmark/graphic/3d/rendering.md
new file mode 100644
index 000000000..b0d400838
--- /dev/null
+++ b/documentation/bookmark/graphic/3d/rendering.md
@@ -0,0 +1,16 @@
+# Ray Tracing
+
+0. [Ray Tracing in One Weekend - The Book Series](https://raytracing.github.io/)
+0. [Ray Tracing Gems II Available Today as Free Digital Download](https://developer.nvidia.com/blog/ray-tracing-gems-ii-available-today-as-free-digital-download/)
+0. [Ray Tracing Gems II](https://link.springer.com/book/10.1007/978-1-4842-7185-8)
+
+# Physically Based Rendering
+
+0. [Physically-based Feature Line Rendering](http://lines.rexwe.st/)
+0. [Physically Based Rendering](https://www.pbr-book.org/3ed-2018/contents)
+0. [Physically Based Rendering in Filament](https://google.github.io/filament/Filament.html)
+
+# Reference
+
+0. [Geometry Types for Graphics Programming](https://www.cs.cornell.edu/~asampson/media/papers/gator-oopsla2020-preprint.pdf)
+
diff --git a/documentation/bookmark/math/number/dual.md b/documentation/bookmark/math/number/dual.md
index cda9d5d8e..501a8e9d4 100644
--- a/documentation/bookmark/math/number/dual.md
+++ b/documentation/bookmark/math/number/dual.md
@@ -1,5 +1,6 @@
# Reference
+0. [Automatic Differentiation: Forward and Reverse](https://jingnanshi.com/blog/autodiff.html)
0. [Dual/Codual numbers for Forward/Reverse Automatic Differentiation](https://higherlogics.blogspot.com/2020/05/dualcodual-numbers-for-forwardreverse.html)
0. [Sensitivity of y w.r.t. to x in y=f(x) where f is a routine](https://scicomp.stackexchange.com/questions/38899/sensitivity-of-y-w-r-t-to-x-in-y-fx-where-f-is-a-routine/38900#38900)
0. [Differentiable programming](https://en.wikipedia.org/wiki/Differentiable_programming)
diff --git a/documentation/bookmark/math/proof.md b/documentation/bookmark/math/proof.md
new file mode 100644
index 000000000..980c45c82
--- /dev/null
+++ b/documentation/bookmark/math/proof.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Book of Proof](https://www.people.vcu.edu/~rhammack/BookOfProof/BookOfProof.pdf)
+
diff --git a/documentation/bookmark/open_source.md b/documentation/bookmark/open_source.md
index f92461f6e..0bf73c741 100644
--- a/documentation/bookmark/open_source.md
+++ b/documentation/bookmark/open_source.md
@@ -1,5 +1,6 @@
# Reference
+0. [Awesome OSS Monetization](https://paydevs.github.io/awesome-oss-monetization/)
0. [Open Source Guides](https://opensource.guide/)
0. [Uncurled - everything I know and learned about running and maintaining Open Source projects for three decades.](https://un.curl.dev/)
0. [Why Modern Open Source Projects Fail](https://arxiv.org/abs/1707.02327)
diff --git a/documentation/bookmark/optics.md b/documentation/bookmark/optics.md
index e47bfa6a8..314505037 100644
--- a/documentation/bookmark/optics.md
+++ b/documentation/bookmark/optics.md
@@ -1,5 +1,6 @@
# Reference
+0. [Existential optics](https://www.tweag.io/blog/2022-05-05-existential-optics/)
0. [Optics vs Lenses, Operationally](https://www.brunogavranovic.com/posts/2022-02-10-optics-vs-lenses-operationally.html)
0. [Optics By Example](https://leanpub.com/optics-by-example)
0. [Profunctor optics, a categorical update](https://arxiv.org/abs/2001.07488)
diff --git a/documentation/bookmark/philanthropy.md b/documentation/bookmark/philanthropy.md
new file mode 100644
index 000000000..0793ef124
--- /dev/null
+++ b/documentation/bookmark/philanthropy.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Catalytic Philanthropy](https://ssir.org/articles/entry/catalytic_philanthropy)
+
diff --git a/documentation/bookmark/programming_language/implementation/stack.md b/documentation/bookmark/programming_language/implementation/stack.md
new file mode 100644
index 000000000..58349cf35
--- /dev/null
+++ b/documentation/bookmark/programming_language/implementation/stack.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [From folklore to fact: comparing implementations of stacks and continuations](https://par.nsf.gov/servlets/purl/10201136)
+
diff --git a/documentation/bookmark/rendering.md b/documentation/bookmark/rendering.md
deleted file mode 100644
index e8fb72658..000000000
--- a/documentation/bookmark/rendering.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# Ray Tracing
-
-1. [Ray Tracing in One Weekend - The Book Series](https://raytracing.github.io/)
-1. [Ray Tracing Gems II Available Today as Free Digital Download](https://developer.nvidia.com/blog/ray-tracing-gems-ii-available-today-as-free-digital-download/)
-1. [Ray Tracing Gems II](https://link.springer.com/book/10.1007/978-1-4842-7185-8)
-
-# Physically Based Rendering
-
-1. [Physically Based Rendering](https://www.pbr-book.org/3ed-2018/contents)
-1. [Physically Based Rendering in Filament](https://google.github.io/filament/Filament.html)
-
-# Reference
-
-1. [Geometry Types for Graphics Programming](https://www.cs.cornell.edu/~asampson/media/papers/gator-oopsla2020-preprint.pdf)
-
diff --git a/documentation/bookmark/security/isolation.md b/documentation/bookmark/security/isolation.md
new file mode 100644
index 000000000..d7a6ee2a0
--- /dev/null
+++ b/documentation/bookmark/security/isolation.md
@@ -0,0 +1,4 @@
+# Reference
+
+0. [Isolating Functions at the Hardware Limit with Virtines](https://arxiv.org/pdf/2104.11324.pdf)
+
diff --git a/documentation/bookmark/tool/text_editor/font.md b/documentation/bookmark/tool/text_editor/font.md
index fede11afd..8c8b0bbda 100644
--- a/documentation/bookmark/tool/text_editor/font.md
+++ b/documentation/bookmark/tool/text_editor/font.md
@@ -1,4 +1,6 @@
# Reference
+0. [Introduction to variable fonts on the web](https://web.dev/variable-fonts/)
+0. [Noto: A typeface for the world](https://fonts.google.com/noto)
0. [JetBrains Mono](https://www.jetbrains.com/lp/mono/)
diff --git a/documentation/bookmark/user_interface/animation.md b/documentation/bookmark/user_interface/animation.md
index 97fa415c0..b0f47f6b9 100644
--- a/documentation/bookmark/user_interface/animation.md
+++ b/documentation/bookmark/user_interface/animation.md
@@ -1,4 +1,5 @@
# Reference
+0. [Lottie](https://lottiefiles.com/what-is-lottie)
0. https://easings.net/
diff --git a/documentation/bookmark/workflow.md b/documentation/bookmark/workflow.md
index d3df0cccc..80cb3497a 100644
--- a/documentation/bookmark/workflow.md
+++ b/documentation/bookmark/workflow.md
@@ -1,4 +1,5 @@
# Reference
+0. [Windmill](https://docs.windmill.dev/)
0. [Common Workflow Language](https://www.commonwl.org/)
diff --git a/lux-mode/lux-mode.el b/lux-mode/lux-mode.el
index c395fb841..6af131eec 100644
--- a/lux-mode/lux-mode.el
+++ b/lux-mode/lux-mode.el
@@ -375,7 +375,6 @@ Called by `imenu--generic-function'."
"type"))
(type//checking (altRE "is" "as" "let" "as_expected" "type_of" "sharing" "by_example" "hole"))
(type//primitive (altRE "primitive:" "abstraction" "representation" "transmutation"))
- (type//unit (altRE "scale:"))
(type//poly (altRE "polytypic"))
(type//dynamic (altRE "dynamic" "static"))
(type//capability (altRE "capability:"))
@@ -407,7 +406,6 @@ Called by `imenu--generic-function'."
(type (altRE type//syntax
type//checking
type//primitive
- type//unit
type//poly
type//dynamic
type//capability))
diff --git a/stdlib/source/documentation/lux/type/unit.lux b/stdlib/source/documentation/lux/type/unit.lux
index 5218d140c..fd518779f 100644
--- a/stdlib/source/documentation/lux/type/unit.lux
+++ b/stdlib/source/documentation/lux/type/unit.lux
@@ -28,15 +28,14 @@
(documentation: /.Pure
"A pure, unit-less quantity.")
-(documentation: /.unit:
+(documentation: /.unit
(format "Define a unit of measurement."
\n "Both the name of the type, and the name of the Unit implementation must be specified.")
- [(unit: .public Feet feet)])
+ [(def: feet (unit []))])
-(documentation: /.scale:
+(documentation: /.scale
"Define a scale of magnitude."
- [(scale: .public Bajillion bajillion
- [1 1,234,567,890])])
+ [(def: bajillion (scale [1 1,234,567,890]))])
(documentation: /.re_scaled
""
@@ -75,8 +74,8 @@
..Unit
..Scale
..Pure
- ..unit:
- ..scale:
+ ..unit
+ ..scale
..re_scaled
..kilo
..mega
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux
index ee78bcc4b..483362c7d 100644
--- a/stdlib/source/library/lux.lux
+++ b/stdlib/source/library/lux.lux
@@ -5048,19 +5048,56 @@
=refers)
=refers)}))))
-(with_expansions [<Immediate_UnQuote> "#Macro/Immediate_UnQuote"]
- (these (type: .public Immediate_UnQuote
- (Primitive <Immediate_UnQuote>))
+(def: (symbol#= [moduleL shortL] [moduleR shortR])
+ (-> Symbol Symbol Bit)
+ (and (text#= moduleL moduleR)
+ (text#= shortL shortR)))
+
+(def: (type#= left right)
+ (-> Type Type Bit)
+ (case [left right]
+ [{#Primitive nameL parametersL} {#Primitive nameR parametersR}]
+ (and (text#= nameL nameR)
+ ("lux i64 =" (list#size parametersL) (list#size parametersR))
+ (every? (function (_ [itL itR])
+ (type#= itL itR))
+ (zipped_2 parametersL parametersR)))
- (def: .private (immediate_unquote_type? it)
- (-> Type Bit)
- (case it
- (pattern {#Named [(static ..prelude) "Immediate_UnQuote"]
- {#Primitive <Immediate_UnQuote> {#End}}})
- #1
+ (with_template#pattern [<tag>]
+ [[{<tag> leftL rightL} {<tag> leftR rightR}]
+ (and (type#= leftL leftR)
+ (type#= rightL rightR))])
+ ([#Sum]
+ [#Product]
+ [#Function]
+ [#Apply])
- _
- #0))))
+ (with_template#pattern [<tag>]
+ [[{<tag> idL} {<tag> idR}]
+ ("lux i64 =" idL idR)])
+ ([#Parameter]
+ [#Var]
+ [#Ex])
+
+ (with_template#pattern [<tag>]
+ [[{<tag> envL bodyL} {<tag> envR bodyR}]
+ (and ("lux i64 =" (list#size envL) (list#size envR))
+ (every? (function (_ [itL itR])
+ (type#= itL itR))
+ (zipped_2 envL envR))
+ (type#= bodyL bodyR))])
+ ([#UnivQ]
+ [#ExQ])
+
+ [{#Named nameL anonL} {#Named nameR anonR}]
+ (and (symbol#= nameL nameR)
+ (type#= anonL anonR))
+
+ _
+ #0))
+
+(type: .public Immediate_UnQuote
+ (Primitive "#Macro/Immediate_UnQuote"))
(def: .public immediate_unquote
(-> Macro Immediate_UnQuote)
@@ -5120,7 +5157,7 @@
<failure>
{#Right [type value]}
- (if (immediate_unquote_type? type)
+ (if (type#= ..Immediate_UnQuote type)
(do meta#monad
[bound ((immediate_unquote_macro (as Immediate_UnQuote value)) parameters)
g!expansion (..generated_symbol "g!expansion")]
diff --git a/stdlib/source/library/lux/target/jvm/class.lux b/stdlib/source/library/lux/target/jvm/class.lux
index 2f5e274e7..f93320b4c 100644
--- a/stdlib/source/library/lux/target/jvm/class.lux
+++ b/stdlib/source/library/lux/target/jvm/class.lux
@@ -14,7 +14,7 @@
[collection
["[0]" sequence (.only Sequence)]]]]]
["[0]" //
- ["[1][0]" modifier (.only Modifier modifiers:)]
+ ["[1][0]" modifier (.only Modifier modifiers)]
["[1][0]" version (.only Version Minor Major)]
["[1][0]" magic (.only Magic)]
["[1][0]" index (.only Index)]
@@ -45,16 +45,17 @@
#methods (Sequence Method)
#attributes (Sequence Attribute)])))
-(modifiers: Class
- ["0001" public]
- ["0010" final]
- ["0020" super]
- ["0200" interface]
- ["0400" abstract]
- ["1000" synthetic]
- ["2000" annotation]
- ["4000" enum]
- )
+(modifiers
+ Class
+ ["0001" public]
+ ["0010" final]
+ ["0020" super]
+ ["0200" interface]
+ ["0400" abstract]
+ ["1000" synthetic]
+ ["2000" annotation]
+ ["4000" enum]
+ )
(def: .public equivalence
(Equivalence Class)
@@ -87,8 +88,8 @@
(in [@this @super @interfaces])))
(def: .public (class version modifier
- this signature super interfaces
- fields methods attributes)
+ this signature super interfaces
+ fields methods attributes)
(-> Major (Modifier Class)
Internal (Maybe (Signature Inheritance)) Internal (List Internal)
(List (Resource Field))
diff --git a/stdlib/source/library/lux/target/jvm/field.lux b/stdlib/source/library/lux/target/jvm/field.lux
index 28b414914..b41782db2 100644
--- a/stdlib/source/library/lux/target/jvm/field.lux
+++ b/stdlib/source/library/lux/target/jvm/field.lux
@@ -11,7 +11,7 @@
[collection
["[0]" sequence (.only Sequence)]]]]]
["[0]" //
- ["[0]" modifier (.only Modifier modifiers:)]
+ ["[0]" modifier (.only Modifier modifiers)]
["[1][0]" constant (.only UTF8)
["[1]/[0]" pool (.only Pool Resource)]]
["[1][0]" index (.only Index)]
@@ -28,17 +28,18 @@
#descriptor (Index (Descriptor Value))
#attributes (Sequence Attribute)])))
-(modifiers: Field
- ["0001" public]
- ["0002" private]
- ["0004" protected]
- ["0008" static]
- ["0010" final]
- ["0040" volatile]
- ["0080" transient]
- ["1000" synthetic]
- ["4000" enum]
- )
+(modifiers
+ Field
+ ["0001" public]
+ ["0002" private]
+ ["0004" protected]
+ ["0008" static]
+ ["0010" final]
+ ["0040" volatile]
+ ["0080" transient]
+ ["1000" synthetic]
+ ["4000" enum]
+ )
(def: .public equivalence
(Equivalence Field)
diff --git a/stdlib/source/library/lux/target/jvm/method.lux b/stdlib/source/library/lux/target/jvm/method.lux
index 6e7dfa4bf..bdbe58f87 100644
--- a/stdlib/source/library/lux/target/jvm/method.lux
+++ b/stdlib/source/library/lux/target/jvm/method.lux
@@ -14,7 +14,7 @@
["[0]" sequence (.only Sequence)]
["[0]" list]]]]]
["[0]" //
- ["[1][0]" modifier (.only Modifier modifiers:)]
+ ["[1][0]" modifier (.only Modifier modifiers)]
["[1][0]" index (.only Index)]
["[1][0]" attribute (.only Attribute)
["[2][0]" code]]
@@ -36,20 +36,21 @@
#descriptor (Index (Descriptor //category.Method))
#attributes (Sequence Attribute)])))
-(modifiers: Method
- ["0001" public]
- ["0002" private]
- ["0004" protected]
- ["0008" static]
- ["0010" final]
- ["0020" synchronized]
- ["0040" bridge]
- ["0080" var_args]
- ["0100" native]
- ["0400" abstract]
- ["0800" strict]
- ["1000" synthetic]
- )
+(modifiers
+ Method
+ ["0001" public]
+ ["0002" private]
+ ["0004" protected]
+ ["0008" static]
+ ["0010" final]
+ ["0020" synchronized]
+ ["0040" bridge]
+ ["0080" var_args]
+ ["0100" native]
+ ["0400" abstract]
+ ["0800" strict]
+ ["1000" synthetic]
+ )
(def: .public (method modifier name with_signature? type attributes code)
(-> (Modifier Method) UTF8 Bit (Type //category.Method) (List (Resource Attribute)) (Maybe (Bytecode Any))
diff --git a/stdlib/source/library/lux/target/jvm/modifier.lux b/stdlib/source/library/lux/target/jvm/modifier.lux
index 4213dd66d..b76886f54 100644
--- a/stdlib/source/library/lux/target/jvm/modifier.lux
+++ b/stdlib/source/library/lux/target/jvm/modifier.lux
@@ -80,7 +80,7 @@
(|>> !wrap))
)
-(def: .public modifiers:
+(def: .public modifiers
(syntax (_ [ofT <code>.any
options (<>.many <code>.any)])
(with_symbols [g!modifier g!code]
diff --git a/stdlib/source/library/lux/target/jvm/modifier/inner.lux b/stdlib/source/library/lux/target/jvm/modifier/inner.lux
index 9ca1ce443..ee47de449 100644
--- a/stdlib/source/library/lux/target/jvm/modifier/inner.lux
+++ b/stdlib/source/library/lux/target/jvm/modifier/inner.lux
@@ -3,19 +3,20 @@
[lux (.except static)
[type
abstract]]]
- [// (.only modifiers:)])
+ [// (.only modifiers)])
(abstract: .public Inner Any)
-(modifiers: Inner
- ["0001" public]
- ["0002" private]
- ["0004" protected]
- ["0008" static]
- ["0010" final]
- ["0200" interface]
- ["0400" abstract]
- ["1000" synthetic]
- ["2000" annotation]
- ["4000" enum]
- )
+(modifiers
+ Inner
+ ["0001" public]
+ ["0002" private]
+ ["0004" protected]
+ ["0008" static]
+ ["0010" final]
+ ["0200" interface]
+ ["0400" abstract]
+ ["1000" synthetic]
+ ["2000" annotation]
+ ["4000" enum]
+ )
diff --git a/stdlib/source/library/lux/type/unit.lux b/stdlib/source/library/lux/type/unit.lux
index 6c6fec8a3..1d2cc20ca 100644
--- a/stdlib/source/library/lux/type/unit.lux
+++ b/stdlib/source/library/lux/type/unit.lux
@@ -1,53 +1,40 @@
(.using
[library
[lux (.except type)
- ["[0]" meta]
[abstract
- [monad (.only Monad do)]
[equivalence (.only Equivalence)]
[order (.only Order)]
[enum (.only Enum)]]
[control
- ["<>" parser (.open: "[1]#[0]" monad)
- ["<[0]>" code (.only Parser)]]]
- [data
- ["[0]" text (.only)
- ["%" \\format (.only format)]]]
+ [parser
+ ["<[0]>" code]]]
["[0]" macro (.only)
- ["[0]" code]
- ["[0]" template]
- [syntax (.only syntax)
- ["|[0]|" export]]]
+ [syntax (.only syntax)]]
[math
[number
- ["n" nat]
- ["i" int]
- ["[0]" ratio (.only Ratio)]]]]]
+ ["i" int]]]]]
["[0]" // (.only)
[primitive (.except)]])
-(primitive: .public (Qty unit)
+(primitive: .public (Qty scale unit)
Int
- (type: .public Pure
- (Qty Any))
-
- (def: .public pure
- (-> Int Pure)
+ (def: .public quantity
+ (All (_ scale unit) (-> Int (Qty scale unit)))
(|>> abstraction))
(def: .public number
- (-> Pure Int)
+ (All (_ scale unit) (-> (Qty scale unit) Int))
(|>> representation))
(def: .public equivalence
- (All (_ unit) (Equivalence (Qty unit)))
+ (All (_ scale unit) (Equivalence (Qty scale unit)))
(implementation
(def: (= reference sample)
(i.= (representation reference) (representation sample)))))
(def: .public order
- (All (_ unit) (Order (Qty unit)))
+ (All (_ scale unit) (Order (Qty scale unit)))
(implementation
(def: equivalence ..equivalence)
@@ -55,7 +42,7 @@
(i.< (representation reference) (representation sample)))))
(def: .public enum
- (All (_ unit) (Enum (Qty unit)))
+ (All (_ scale unit) (Enum (Qty scale unit)))
(implementation
(def: order ..order)
(def: succ (|>> representation ++ abstraction))
@@ -63,7 +50,7 @@
(with_template [<name> <op>]
[(def: .public (<name> param subject)
- (All (_ unit) (-> (Qty unit) (Qty unit) (Qty unit)))
+ (All (_ scale unit) (-> (Qty scale unit) (Qty scale unit) (Qty scale unit)))
(abstraction (<op> (representation param)
(representation subject))))]
@@ -73,7 +60,7 @@
(with_template [<name> <op> <p> <s> <p*s>]
[(def: .public (<name> param subject)
- (All (_ p s) (-> (Qty <p>) (Qty <s>) (Qty <p*s>)))
+ (All (_ scale p s) (-> (Qty scale <p>) (Qty scale <s>) (Qty scale <p*s>)))
(abstraction (<op> (representation param)
(representation subject))))]
@@ -83,31 +70,23 @@
(type: .public (Unit a)
(Interface
- (is (-> Int (Qty a))
+ (is (-> Int (Qty Any a))
in)
- (is (-> (Qty a) Int)
+ (is (-> (Qty Any a) Int)
out)))
(def: .public (unit _)
(Ex (_ a) (-> Any (Unit a)))
(implementation
- (def: in (|>> abstraction))
- (def: out (|>> representation))))
-
- (def: in'
- (All (_ unit) (-> Int (Qty unit)))
- (|>> abstraction))
-
- (def: out'
- (All (_ unit) (-> (Qty unit) Int))
- (|>> representation))
+ (def: in ..quantity)
+ (def: out ..number)))
)
(def: .public type
(syntax (_ [it <code>.any])
(macro.with_symbols [g!a]
(in (list (` ((~! //.by_example) [(~ g!a)]
- (Unit (~ g!a))
+ (..Unit (~ g!a))
(~ it)
(~ g!a))))))))
@@ -124,83 +103,3 @@
[litre Litre]
[second Second]
)
-
-(type: .public (Scale s)
- (Interface
- (is (All (_ u) (-> (Qty u) (Qty (s u))))
- scale)
- (is (All (_ u) (-> (Qty (s u)) (Qty u)))
- de_scale)
- (is Ratio
- ratio)))
-
-(def: scaleP
- (Parser Ratio)
- (<code>.tuple (do <>.monad
- [numerator <code>.nat
- _ (<>.assertion (format "Numerator must be positive: " (%.nat numerator))
- (n.> 0 numerator))
- denominator <code>.nat
- _ (<>.assertion (format "Denominator must be positive: " (%.nat denominator))
- (n.> 0 denominator))]
- (in [numerator denominator]))))
-
-(def: .public scale:
- (syntax (_ [[export_policy type_name scale_name ratio]
- (|export|.parser
- (all <>.and
- <code>.local
- <code>.local
- ..scaleP))])
- (do meta.monad
- [.let [(open "_[0]") ratio]
- @ meta.current_module_name
- .let [g!scale (code.local type_name)]]
- (in (list (` (type: (~ export_policy) ((~ g!scale) (~' u))
- (Primitive (~ (code.text (%.symbol [@ type_name]))) [(~' u)])))
-
- (` (def: (~ export_policy) (~ (code.local scale_name))
- (..Scale (~ g!scale))
- (implementation
- (def: (~' scale)
- (|>> ((~! ..out'))
- (i.* (~ (code.int (.int _#numerator))))
- (i./ (~ (code.int (.int _#denominator))))
- ((~! ..in'))))
- (def: (~' de_scale)
- (|>> ((~! ..out'))
- (i.* (~ (code.int (.int _#denominator))))
- (i./ (~ (code.int (.int _#numerator))))
- ((~! ..in'))))
- (def: (~' ratio)
- [(~ (code.nat _#numerator))
- (~ (code.nat _#denominator))]))))
- )))))
-
-(def: .public (re_scaled from to quantity)
- (All (_ si so u) (-> (Scale si) (Scale so) (Qty (si u)) (Qty (so u))))
- (let [[numerator denominator] (ratio./ (at from ratio)
- (at to ratio))]
- (|> quantity
- out'
- (i.* (.int numerator))
- (i./ (.int denominator))
- in')))
-
-(def: implementation_name
- (syntax (_ [type_name <code>.local])
- (in (list (code.local (text.lower_cased type_name))))))
-
-(with_template [<type> <from> <to>]
- [(`` (scale: .public <type>
- (~~ (implementation_name <type>))
- [<from> <to>]))]
-
- [Kilo 1 1,000]
- [Mega 1 1,000,000]
- [Giga 1 1,000,000,000]
-
- [Milli 1,000 1]
- [Micro 1,000,000 1]
- [Nano 1,000,000,000 1]
- )
diff --git a/stdlib/source/library/lux/type/unit/scale.lux b/stdlib/source/library/lux/type/unit/scale.lux
new file mode 100644
index 000000000..3a956baf0
--- /dev/null
+++ b/stdlib/source/library/lux/type/unit/scale.lux
@@ -0,0 +1,79 @@
+(.using
+ [library
+ [lux (.except type)
+ [control
+ [parser
+ ["<[0]>" code]]]
+ ["[0]" macro (.only)
+ [syntax (.only syntax)]]
+ [math
+ [number
+ ["i" int]
+ ["[0]" ratio (.only Ratio)]]]]]
+ ["[0]" // (.only)
+ ["/[1]" //]])
+
+(type: .public (Scale s)
+ (Interface
+ (is (All (_ u) (-> (//.Qty Any u) (//.Qty s u)))
+ up)
+ (is (All (_ u) (-> (//.Qty s u) (//.Qty Any u)))
+ down)
+ (is Ratio
+ ratio)))
+
+(def: .public (scale ratio)
+ (Ex (_ s) (-> Ratio (Scale s)))
+ (let [(open "/[0]") ratio]
+ (implementation
+ (def: up
+ (|>> //.number
+ (i.* (.int /#numerator))
+ (i./ (.int /#denominator))
+ //.quantity))
+ (def: down
+ (|>> //.number
+ (i.* (.int /#denominator))
+ (i./ (.int /#numerator))
+ //.quantity))
+ (def: ratio
+ ratio))))
+
+(def: .public (re_scaled from to quantity)
+ (All (_ si so u) (-> (Scale si) (Scale so) (//.Qty si u) (//.Qty so u)))
+ (let [(open "/[0]") (ratio./ (at from ratio)
+ (at to ratio))]
+ (|> quantity
+ //.number
+ (i.* (.int /#numerator))
+ (i./ (.int /#denominator))
+ //.quantity)))
+
+(def: .public type
+ (syntax (_ [it <code>.any])
+ (macro.with_symbols [g!a]
+ (in (list (` ((~! ///.by_example) [(~ g!a)]
+ (..Scale (~ g!a))
+ (~ it)
+
+ (~ g!a))))))))
+
+(with_template [<order_of_magnitude> <up> <up_type> <down> <down_type>]
+ [(def: .public <up>
+ (scale [ratio.#numerator <order_of_magnitude>
+ ratio.#denominator 1]))
+
+ (type: .public <up_type>
+ (~ (..type <up>)))
+
+ (def: .public <down>
+ (scale [ratio.#numerator 1
+ ratio.#denominator <order_of_magnitude>]))
+
+ (type: .public <down_type>
+ (~ (..type <down>)))]
+
+ [ 1,000 kilo Kilo milli Milli]
+ [ 1,000,000 mega Mega micro Micro]
+ [1,000,000,000 giga Giga nano Nano ]
+ )
diff --git a/stdlib/source/polytypic/lux/data/format/json.lux b/stdlib/source/polytypic/lux/data/format/json.lux
index b86f256a2..63017d5ba 100644
--- a/stdlib/source/polytypic/lux/data/format/json.lux
+++ b/stdlib/source/polytypic/lux/data/format/json.lux
@@ -1,7 +1,6 @@
(.using
[library
[lux (.except)
- ["[0]" debug]
[abstract
[monad (.only do)]
["[0]" codec]]
@@ -90,11 +89,11 @@
(codec.Codec JSON (unit.Qty unit)))
(implementation
(def: encoded
- (|>> ((debug.private unit.out'))
+ (|>> unit.number
(at ..int_codec encoded)))
(def: decoded
(|>> (at ..int_codec decoded)
- (at try.functor each (debug.private unit.in'))))))
+ (at try.functor each unit.quantity)))))
(def: encoded
(polytypic encoded
diff --git a/stdlib/source/test/lux/data/format/json.lux b/stdlib/source/test/lux/data/format/json.lux
index 2133f51f1..613767144 100644
--- a/stdlib/source/test/lux/data/format/json.lux
+++ b/stdlib/source/test/lux/data/format/json.lux
@@ -3,7 +3,6 @@
[lux (.except Variant Record)
["_" test (.only Test)]
["@" target]
- ["[0]" debug]
["[0]" meta]
[abstract
[codec (.except)]
@@ -87,7 +86,7 @@
(def: qty
(All (_ unit) (Random (unit.Qty unit)))
- (at random.monad each (debug.private unit.in') random.int))
+ (at random.monad each unit.quantity random.int))
(def: gen_record
(Random Record)
diff --git a/stdlib/source/test/lux/type/unit.lux b/stdlib/source/test/lux/type/unit.lux
index b4662133e..a4198429c 100644
--- a/stdlib/source/test/lux/type/unit.lux
+++ b/stdlib/source/test/lux/type/unit.lux
@@ -2,8 +2,6 @@
[library
[lux (.except)
["_" test (.only Test)]
- ["[0]" debug]
- ["[0]" meta]
[abstract
[monad (.only do)]
[equivalence (.only Equivalence)]
@@ -11,20 +9,18 @@
["$[0]" equivalence]
["$[0]" order]
["$[0]" enum]]]
- [macro
- [syntax (.only syntax)]
- ["[0]" code]]
[math
["[0]" random (.only Random)]
[number
- ["i" int]
- ["[0]" ratio (.open: "[1]#[0]" equivalence)]]]]]
+ ["i" int]]]]]
[\\library
- ["[0]" /]])
+ ["[0]" /]]
+ ["[0]" /
+ ["[1][0]" scale]])
(with_template [<name> <type> <unit>]
[(def: (<name> range)
- (-> Nat (Random (/.Qty <type>)))
+ (-> Nat (Random (/.Qty Any <type>)))
(|> random.int
(at random.monad each (i.% (.int range)))
(random.only (|>> (i.= +0) not))
@@ -66,100 +62,24 @@
[/.Litre /.litre]
[/.Second /.second]
))
- (_.coverage [/.Pure /.pure /.number]
+ (_.coverage [/.quantity /.number]
(|> expected
- /.pure
+ /.quantity
/.number
(i.= expected)))
(_.coverage [/.unit /.type]
(|> expected
(at ..what in)
- (is (/.Qty What))
+ (is (/.Qty Any What))
(at ..what out)
(i.= expected)))
)))))
-(def: natural
- (syntax (_ [])
- (at meta.monad each
- (|>> code.nat list)
- meta.seed)))
-
-(with_expansions [<from> (..natural)
- <to> (..natural)]
- (/.scale: How how
- [<from> <to>])
-
- (def: how::from <from>)
- (def: how::to <to>)
- )
-
-(def: scale
- Test
- (do [! random.monad]
- [small (|> random.int
- (at ! each (i.% +1,000))
- (at ! each (at /.meter in)))
- large (|> random.int
- (at ! each (i.% +1,000))
- (at ! each (i.* +1,000,000,000))
- (at ! each (at /.meter in)))
- .let [(open "meter#[0]") (is (Equivalence (/.Qty /.Meter))
- /.equivalence)]
- unscaled (|> random.int
- (at ! each (i.% +1,000))
- (at ! each (i.* (.int how::to)))
- (at ! each (at /.meter in)))]
- (_.for [/.Scale]
- (`` (all _.and
- (~~ (with_template [<type> <scale>]
- [(_.coverage [<type> <scale>]
- (|> large
- (at <scale> scale)
- (is (/.Qty (<type> /.Meter)))
- (at <scale> de_scale)
- (is (/.Qty /.Meter))
- (meter#= large)))]
-
- [/.Kilo /.kilo]
- [/.Mega /.mega]
- [/.Giga /.giga]
- ))
- (~~ (with_template [<type> <scale>]
- [(_.coverage [<type> <scale>]
- (|> small
- (at <scale> scale)
- (is (/.Qty (<type> /.Meter)))
- (at <scale> de_scale)
- (is (/.Qty /.Meter))
- (meter#= small)))]
-
- [/.Milli /.milli]
- [/.Micro /.micro]
- [/.Nano /.nano]
- ))
- (_.coverage [/.re_scaled]
- (|> large (is (/.Qty /.Meter))
- (at /.kilo scale) (is (/.Qty (/.Kilo /.Meter)))
- (/.re_scaled /.kilo /.milli) (is (/.Qty (/.Milli /.Meter)))
- (/.re_scaled /.milli /.kilo) (is (/.Qty (/.Kilo /.Meter)))
- (at /.kilo de_scale) (is (/.Qty /.Meter))
- (meter#= large)))
- (_.coverage [/.scale:]
- (and (|> unscaled
- (at ..how scale)
- (at ..how de_scale)
- (meter#= unscaled))
- (ratio#= [..how::from
- ..how::to]
- (at ..how ratio))))
- )))))
-
(def: arithmetic
Test
(do random.monad
[.let [zero (at /.meter in +0)
- (open "meter#[0]") (is (Equivalence (/.Qty /.Meter))
+ (open "meter#[0]") (is (Equivalence (/.Qty Any /.Meter))
/.equivalence)]
left (random.only (|>> (meter#= zero) not) (..meter 1,000))
right (..meter 1,000)
@@ -175,8 +95,8 @@
))
(_.coverage [/.*]
(let [expected (i.* (at /.meter out left) (at /.meter out right))
- actual ((debug.private /.out') (is (/.Qty [/.Meter /.Meter])
- (/.* left right)))]
+ actual (/.number (is (/.Qty Any [/.Meter /.Meter])
+ (/.* left right)))]
(i.= expected actual)))
(_.coverage [/./]
(|> right
@@ -192,6 +112,7 @@
(all _.and
..polymorphism
..unit
- ..scale
..arithmetic
+
+ /scale.test
)))
diff --git a/stdlib/source/test/lux/type/unit/scale.lux b/stdlib/source/test/lux/type/unit/scale.lux
new file mode 100644
index 000000000..569cdc0ba
--- /dev/null
+++ b/stdlib/source/test/lux/type/unit/scale.lux
@@ -0,0 +1,97 @@
+(.using
+ [library
+ [lux (.except)
+ ["_" test (.only Test)]
+ ["[0]" meta]
+ [abstract
+ [monad (.only do)]
+ [equivalence (.only Equivalence)]]
+ [macro
+ [syntax (.only syntax)]
+ ["[0]" code]]
+ [math
+ ["[0]" random (.only Random)]
+ [number
+ ["i" int]
+ ["[0]" ratio (.open: "[1]#[0]" equivalence)]]]]]
+ [\\library
+ ["[0]" / (.only)
+ ["/[1]" //]]])
+
+(def: natural
+ (syntax (_ [])
+ (at meta.monad each
+ (|>> code.nat list)
+ meta.seed)))
+
+(with_expansions [<from> (..natural)
+ <to> (..natural)]
+ (def: how (/.scale [ratio.#denominator <from> ratio.#numerator <to>]))
+ (def: How (/.type how))
+
+ (def: how::from <from>)
+ (def: how::to <to>)
+ )
+
+(def: .public test
+ Test
+ (<| (_.covering /._)
+ (_.for [/.Scale])
+ (do [! random.monad]
+ [small (|> random.int
+ (at ! each (i.% +1,000))
+ (at ! each (at //.meter in)))
+ large (|> random.int
+ (at ! each (i.% +1,000))
+ (at ! each (i.* +1,000,000,000))
+ (at ! each (at //.meter in)))
+ .let [(open "meter#[0]") (is (Equivalence (//.Qty Any //.Meter))
+ //.equivalence)]
+ unscaled (|> random.int
+ (at ! each (i.% +1,000))
+ (at ! each (i.* (.int how::to)))
+ (at ! each (at //.meter in)))]
+ (`` (all _.and
+ (~~ (with_template [<type> <scale>]
+ [(_.coverage [<type> <scale>]
+ (|> small
+ (at <scale> up)
+ (is (//.Qty <type> //.Meter))
+ (at <scale> down)
+ (is (//.Qty Any //.Meter))
+ (meter#= small)))]
+
+ [/.Kilo /.kilo]
+ [/.Mega /.mega]
+ [/.Giga /.giga]
+ ))
+ (~~ (with_template [<type> <scale>]
+ [(_.coverage [<type> <scale>]
+ (|> large
+ (at <scale> up)
+ (is (//.Qty <type> //.Meter))
+ (at <scale> down)
+ (is (//.Qty Any //.Meter))
+ (meter#= large)))]
+
+ [/.Milli /.milli]
+ [/.Micro /.micro]
+ [/.Nano /.nano]
+ ))
+ (_.coverage [/.re_scaled]
+ (|> large (is (//.Qty Any //.Meter))
+ (at /.kilo up) (is (//.Qty /.Kilo //.Meter))
+ (/.re_scaled /.kilo /.milli) (is (//.Qty /.Milli //.Meter))
+ (/.re_scaled /.milli /.kilo) (is (//.Qty /.Kilo //.Meter))
+ (at /.kilo down) (is (//.Qty Any //.Meter))
+ (meter#= large)))
+ (_.coverage [/.scale /.type]
+ (and (|> unscaled
+ (at ..how up)
+ (is (//.Qty How //.Meter))
+ (at ..how down)
+ (meter#= unscaled))
+ (ratio#= [ratio.#denominator ..how::from
+ ratio.#numerator ..how::to]
+ (at ..how ratio))))
+ )))))