aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.gitignore6
-rw-r--r--commands.md4
-rw-r--r--documentation/bookmark/Type theory/Cost analysis.md4
-rw-r--r--documentation/bookmark/Type theory/Dependent types.md1
-rw-r--r--documentation/bookmark/Type theory/Refinement.md4
-rw-r--r--documentation/bookmark/concurrency/Capsule-oriented Programming.md4
-rw-r--r--documentation/bookmark/text_editor & ide.md1
-rw-r--r--lux-bootstrapper/code_of_conduct.md (renamed from luxc/code_of_conduct.md)0
-rw-r--r--lux-bootstrapper/project.clj (renamed from luxc/project.clj)2
-rw-r--r--lux-bootstrapper/src/lux.clj (renamed from luxc/src/lux.clj)0
-rw-r--r--lux-bootstrapper/src/lux/analyser.clj (renamed from luxc/src/lux/analyser.clj)0
-rw-r--r--lux-bootstrapper/src/lux/analyser/base.clj (renamed from luxc/src/lux/analyser/base.clj)0
-rw-r--r--lux-bootstrapper/src/lux/analyser/case.clj (renamed from luxc/src/lux/analyser/case.clj)0
-rw-r--r--lux-bootstrapper/src/lux/analyser/env.clj (renamed from luxc/src/lux/analyser/env.clj)0
-rw-r--r--lux-bootstrapper/src/lux/analyser/function.clj (renamed from luxc/src/lux/analyser/function.clj)0
-rw-r--r--lux-bootstrapper/src/lux/analyser/lux.clj (renamed from luxc/src/lux/analyser/lux.clj)0
-rw-r--r--lux-bootstrapper/src/lux/analyser/module.clj (renamed from luxc/src/lux/analyser/module.clj)0
-rw-r--r--lux-bootstrapper/src/lux/analyser/parser.clj (renamed from luxc/src/lux/analyser/parser.clj)0
-rw-r--r--lux-bootstrapper/src/lux/analyser/proc/common.clj (renamed from luxc/src/lux/analyser/proc/common.clj)0
-rw-r--r--lux-bootstrapper/src/lux/analyser/proc/jvm.clj (renamed from luxc/src/lux/analyser/proc/jvm.clj)0
-rw-r--r--lux-bootstrapper/src/lux/analyser/record.clj (renamed from luxc/src/lux/analyser/record.clj)0
-rw-r--r--lux-bootstrapper/src/lux/base.clj (renamed from luxc/src/lux/base.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler.clj (renamed from luxc/src/lux/compiler.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/cache.clj (renamed from luxc/src/lux/compiler/cache.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/cache/ann.clj (renamed from luxc/src/lux/compiler/cache/ann.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/cache/type.clj (renamed from luxc/src/lux/compiler/cache/type.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/core.clj (renamed from luxc/src/lux/compiler/core.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/io.clj (renamed from luxc/src/lux/compiler/io.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/jvm.clj (renamed from luxc/src/lux/compiler/jvm.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/jvm/base.clj (renamed from luxc/src/lux/compiler/jvm/base.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/jvm/cache.clj (renamed from luxc/src/lux/compiler/jvm/cache.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/jvm/case.clj (renamed from luxc/src/lux/compiler/jvm/case.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/jvm/function.clj (renamed from luxc/src/lux/compiler/jvm/function.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/jvm/lux.clj (renamed from luxc/src/lux/compiler/jvm/lux.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/jvm/proc/common.clj (renamed from luxc/src/lux/compiler/jvm/proc/common.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/jvm/proc/host.clj (renamed from luxc/src/lux/compiler/jvm/proc/host.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/jvm/rt.clj (renamed from luxc/src/lux/compiler/jvm/rt.clj)0
-rw-r--r--lux-bootstrapper/src/lux/compiler/parallel.clj (renamed from luxc/src/lux/compiler/parallel.clj)0
-rw-r--r--lux-bootstrapper/src/lux/host.clj (renamed from luxc/src/lux/host.clj)0
-rw-r--r--lux-bootstrapper/src/lux/host/generics.clj (renamed from luxc/src/lux/host/generics.clj)0
-rw-r--r--lux-bootstrapper/src/lux/lexer.clj (renamed from luxc/src/lux/lexer.clj)0
-rw-r--r--lux-bootstrapper/src/lux/lib/loader.clj (renamed from luxc/src/lux/lib/loader.clj)0
-rw-r--r--lux-bootstrapper/src/lux/optimizer.clj (renamed from luxc/src/lux/optimizer.clj)0
-rw-r--r--lux-bootstrapper/src/lux/parser.clj (renamed from luxc/src/lux/parser.clj)0
-rw-r--r--lux-bootstrapper/src/lux/reader.clj (renamed from luxc/src/lux/reader.clj)0
-rw-r--r--lux-bootstrapper/src/lux/repl.clj (renamed from luxc/src/lux/repl.clj)0
-rw-r--r--lux-bootstrapper/src/lux/type.clj (renamed from luxc/src/lux/type.clj)0
-rw-r--r--lux-bootstrapper/src/lux/type/host.clj (renamed from luxc/src/lux/type/host.clj)0
-rw-r--r--lux-jvm/project.clj2
-rw-r--r--lux-lein/src/leiningen/lux/utils.clj2
-rwxr-xr-xshell/lux.sh31
-rw-r--r--stdlib/project.clj2
-rw-r--r--stdlib/source/lux.lux4
-rw-r--r--stdlib/source/lux/data/number/frac.lux8
-rw-r--r--stdlib/source/lux/data/number/int.lux47
-rw-r--r--stdlib/source/program/aedifex.lux132
-rw-r--r--stdlib/source/program/compositor/import.lux6
-rw-r--r--stdlib/source/test/lux/data/number/frac.lux240
-rw-r--r--stdlib/source/test/lux/data/number/i64.lux26
-rw-r--r--stdlib/source/test/lux/data/number/int.lux179
60 files changed, 453 insertions, 252 deletions
diff --git a/.gitignore b/.gitignore
index 0900603b4..59455a52a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,9 +8,9 @@ pom.xml.asc
/jbe
-/luxc/target
-/luxc/classes
-/luxc/checkouts
+/lux-bootstrapper/target
+/lux-bootstrapper/classes
+/lux-bootstrapper/checkouts
/stdlib/target
diff --git a/commands.md b/commands.md
index 26e5d971a..c0d75ae8b 100644
--- a/commands.md
+++ b/commands.md
@@ -9,7 +9,7 @@ cd ~/lux/ && find . -name '*.lux' | xargs wc -l
# Clean all
```
-cd ~/lux/luxc/ && lein clean && \
+cd ~/lux/lux-bootstrapper/ && lein clean && \
cd ~/lux/stdlib/ && lein clean
```
@@ -28,7 +28,7 @@ cd ~/lux/jbe/ && ./jbe.sh
## Build & install
```
-cd ~/lux/luxc/ && lein clean && lein install
+cd ~/lux/lux-bootstrapper/ && lein clean && lein install
```
## Run JBE
diff --git a/documentation/bookmark/Type theory/Cost analysis.md b/documentation/bookmark/Type theory/Cost analysis.md
new file mode 100644
index 000000000..6e92c792e
--- /dev/null
+++ b/documentation/bookmark/Type theory/Cost analysis.md
@@ -0,0 +1,4 @@
+# Reference
+
+1. [Liquidate Your Assets: Reasoning about Resource Usage in Liquid Haskell](http://www.cs.nott.ac.uk/~pszgmh/liquidate.pdf)
+
diff --git a/documentation/bookmark/Type theory/Dependent types.md b/documentation/bookmark/Type theory/Dependent types.md
index 8269310db..9f8700676 100644
--- a/documentation/bookmark/Type theory/Dependent types.md
+++ b/documentation/bookmark/Type theory/Dependent types.md
@@ -5,6 +5,7 @@
# Reference
+1. [Program = Proof](http://www.lix.polytechnique.fr/Labo/Samuel.Mimram/teaching/INF551/course.pdf)
1. [Multimodal Dependent Type Theory](https://arxiv.org/abs/2011.15021)
1. [Thorsten Altenkirch - The power of Π - Lambda Days 2020](https://www.youtube.com/watch?v=3zT5eVHpQwA)
1. [A Path To DOT: Formalizing Fully Path-Dependent Types](https://arxiv.org/abs/1904.07298)
diff --git a/documentation/bookmark/Type theory/Refinement.md b/documentation/bookmark/Type theory/Refinement.md
new file mode 100644
index 000000000..f0d0a1f06
--- /dev/null
+++ b/documentation/bookmark/Type theory/Refinement.md
@@ -0,0 +1,4 @@
+# Reference
+
+1. [Refinement Kinds: Type-safe Programming with Practical Type-level Computation (Extended Version)](https://arxiv.org/abs/1908.00441)
+
diff --git a/documentation/bookmark/concurrency/Capsule-oriented Programming.md b/documentation/bookmark/concurrency/Capsule-oriented Programming.md
new file mode 100644
index 000000000..63afce9e9
--- /dev/null
+++ b/documentation/bookmark/concurrency/Capsule-oriented Programming.md
@@ -0,0 +1,4 @@
+# Reference
+
+1. [Capsule-oriented Programming](http://design.cs.iastate.edu/papers/TR-13-01/capsule-oriented.pdf)
+
diff --git a/documentation/bookmark/text_editor & ide.md b/documentation/bookmark/text_editor & ide.md
index b39b0a075..8ffbb5bb9 100644
--- a/documentation/bookmark/text_editor & ide.md
+++ b/documentation/bookmark/text_editor & ide.md
@@ -213,6 +213,7 @@
## Structured editing
+1. [Dion Systems - The How And Why Of Reinventing The Wheel](https://vimeo.com/485177664)
1. [Towards Tactic Metaprogramming in Haskell](https://reasonablypolymorphic.com/blog/towards-tactics/index.html)
1. https://github.com/Raathigesh/waypoint
1. [Going beyond regular expressions with structural code search](https://about.sourcegraph.com/blog/going-beyond-regular-expressions-with-structural-code-search)
diff --git a/luxc/code_of_conduct.md b/lux-bootstrapper/code_of_conduct.md
index 01b8644f1..01b8644f1 100644
--- a/luxc/code_of_conduct.md
+++ b/lux-bootstrapper/code_of_conduct.md
diff --git a/luxc/project.clj b/lux-bootstrapper/project.clj
index f7f7735ed..e0525c2bb 100644
--- a/luxc/project.clj
+++ b/lux-bootstrapper/project.clj
@@ -1,4 +1,4 @@
-(defproject com.github.luxlang/luxc-jvm "0.6.0-SNAPSHOT"
+(defproject com.github.luxlang/lux-bootstrapper "0.6.0-SNAPSHOT"
:min-lein-version "2.1.0" ;; 2.1.0 introduced jar classifiers
:description "The JVM compiler for the Lux programming language."
:url "https://github.com/LuxLang/lux"
diff --git a/luxc/src/lux.clj b/lux-bootstrapper/src/lux.clj
index dc6066669..dc6066669 100644
--- a/luxc/src/lux.clj
+++ b/lux-bootstrapper/src/lux.clj
diff --git a/luxc/src/lux/analyser.clj b/lux-bootstrapper/src/lux/analyser.clj
index af272fa91..af272fa91 100644
--- a/luxc/src/lux/analyser.clj
+++ b/lux-bootstrapper/src/lux/analyser.clj
diff --git a/luxc/src/lux/analyser/base.clj b/lux-bootstrapper/src/lux/analyser/base.clj
index d6787280f..d6787280f 100644
--- a/luxc/src/lux/analyser/base.clj
+++ b/lux-bootstrapper/src/lux/analyser/base.clj
diff --git a/luxc/src/lux/analyser/case.clj b/lux-bootstrapper/src/lux/analyser/case.clj
index d059ce189..d059ce189 100644
--- a/luxc/src/lux/analyser/case.clj
+++ b/lux-bootstrapper/src/lux/analyser/case.clj
diff --git a/luxc/src/lux/analyser/env.clj b/lux-bootstrapper/src/lux/analyser/env.clj
index a2b6e5ad3..a2b6e5ad3 100644
--- a/luxc/src/lux/analyser/env.clj
+++ b/lux-bootstrapper/src/lux/analyser/env.clj
diff --git a/luxc/src/lux/analyser/function.clj b/lux-bootstrapper/src/lux/analyser/function.clj
index 3db24acef..3db24acef 100644
--- a/luxc/src/lux/analyser/function.clj
+++ b/lux-bootstrapper/src/lux/analyser/function.clj
diff --git a/luxc/src/lux/analyser/lux.clj b/lux-bootstrapper/src/lux/analyser/lux.clj
index b7d78aa23..b7d78aa23 100644
--- a/luxc/src/lux/analyser/lux.clj
+++ b/lux-bootstrapper/src/lux/analyser/lux.clj
diff --git a/luxc/src/lux/analyser/module.clj b/lux-bootstrapper/src/lux/analyser/module.clj
index d41eb73d5..d41eb73d5 100644
--- a/luxc/src/lux/analyser/module.clj
+++ b/lux-bootstrapper/src/lux/analyser/module.clj
diff --git a/luxc/src/lux/analyser/parser.clj b/lux-bootstrapper/src/lux/analyser/parser.clj
index 6a46bab3c..6a46bab3c 100644
--- a/luxc/src/lux/analyser/parser.clj
+++ b/lux-bootstrapper/src/lux/analyser/parser.clj
diff --git a/luxc/src/lux/analyser/proc/common.clj b/lux-bootstrapper/src/lux/analyser/proc/common.clj
index 6a1521909..6a1521909 100644
--- a/luxc/src/lux/analyser/proc/common.clj
+++ b/lux-bootstrapper/src/lux/analyser/proc/common.clj
diff --git a/luxc/src/lux/analyser/proc/jvm.clj b/lux-bootstrapper/src/lux/analyser/proc/jvm.clj
index cc77bf72c..cc77bf72c 100644
--- a/luxc/src/lux/analyser/proc/jvm.clj
+++ b/lux-bootstrapper/src/lux/analyser/proc/jvm.clj
diff --git a/luxc/src/lux/analyser/record.clj b/lux-bootstrapper/src/lux/analyser/record.clj
index 3d3d8169f..3d3d8169f 100644
--- a/luxc/src/lux/analyser/record.clj
+++ b/lux-bootstrapper/src/lux/analyser/record.clj
diff --git a/luxc/src/lux/base.clj b/lux-bootstrapper/src/lux/base.clj
index 5ef710a03..5ef710a03 100644
--- a/luxc/src/lux/base.clj
+++ b/lux-bootstrapper/src/lux/base.clj
diff --git a/luxc/src/lux/compiler.clj b/lux-bootstrapper/src/lux/compiler.clj
index a3e60e463..a3e60e463 100644
--- a/luxc/src/lux/compiler.clj
+++ b/lux-bootstrapper/src/lux/compiler.clj
diff --git a/luxc/src/lux/compiler/cache.clj b/lux-bootstrapper/src/lux/compiler/cache.clj
index 01e05c8de..01e05c8de 100644
--- a/luxc/src/lux/compiler/cache.clj
+++ b/lux-bootstrapper/src/lux/compiler/cache.clj
diff --git a/luxc/src/lux/compiler/cache/ann.clj b/lux-bootstrapper/src/lux/compiler/cache/ann.clj
index 4c08af276..4c08af276 100644
--- a/luxc/src/lux/compiler/cache/ann.clj
+++ b/lux-bootstrapper/src/lux/compiler/cache/ann.clj
diff --git a/luxc/src/lux/compiler/cache/type.clj b/lux-bootstrapper/src/lux/compiler/cache/type.clj
index 7c622d2c4..7c622d2c4 100644
--- a/luxc/src/lux/compiler/cache/type.clj
+++ b/lux-bootstrapper/src/lux/compiler/cache/type.clj
diff --git a/luxc/src/lux/compiler/core.clj b/lux-bootstrapper/src/lux/compiler/core.clj
index 88da626bd..88da626bd 100644
--- a/luxc/src/lux/compiler/core.clj
+++ b/lux-bootstrapper/src/lux/compiler/core.clj
diff --git a/luxc/src/lux/compiler/io.clj b/lux-bootstrapper/src/lux/compiler/io.clj
index d3658edd3..d3658edd3 100644
--- a/luxc/src/lux/compiler/io.clj
+++ b/lux-bootstrapper/src/lux/compiler/io.clj
diff --git a/luxc/src/lux/compiler/jvm.clj b/lux-bootstrapper/src/lux/compiler/jvm.clj
index 07c28dfac..07c28dfac 100644
--- a/luxc/src/lux/compiler/jvm.clj
+++ b/lux-bootstrapper/src/lux/compiler/jvm.clj
diff --git a/luxc/src/lux/compiler/jvm/base.clj b/lux-bootstrapper/src/lux/compiler/jvm/base.clj
index b5e520de5..b5e520de5 100644
--- a/luxc/src/lux/compiler/jvm/base.clj
+++ b/lux-bootstrapper/src/lux/compiler/jvm/base.clj
diff --git a/luxc/src/lux/compiler/jvm/cache.clj b/lux-bootstrapper/src/lux/compiler/jvm/cache.clj
index f54eacc92..f54eacc92 100644
--- a/luxc/src/lux/compiler/jvm/cache.clj
+++ b/lux-bootstrapper/src/lux/compiler/jvm/cache.clj
diff --git a/luxc/src/lux/compiler/jvm/case.clj b/lux-bootstrapper/src/lux/compiler/jvm/case.clj
index b7cdb7571..b7cdb7571 100644
--- a/luxc/src/lux/compiler/jvm/case.clj
+++ b/lux-bootstrapper/src/lux/compiler/jvm/case.clj
diff --git a/luxc/src/lux/compiler/jvm/function.clj b/lux-bootstrapper/src/lux/compiler/jvm/function.clj
index eb779a7b6..eb779a7b6 100644
--- a/luxc/src/lux/compiler/jvm/function.clj
+++ b/lux-bootstrapper/src/lux/compiler/jvm/function.clj
diff --git a/luxc/src/lux/compiler/jvm/lux.clj b/lux-bootstrapper/src/lux/compiler/jvm/lux.clj
index 043fc2273..043fc2273 100644
--- a/luxc/src/lux/compiler/jvm/lux.clj
+++ b/lux-bootstrapper/src/lux/compiler/jvm/lux.clj
diff --git a/luxc/src/lux/compiler/jvm/proc/common.clj b/lux-bootstrapper/src/lux/compiler/jvm/proc/common.clj
index d4c825282..d4c825282 100644
--- a/luxc/src/lux/compiler/jvm/proc/common.clj
+++ b/lux-bootstrapper/src/lux/compiler/jvm/proc/common.clj
diff --git a/luxc/src/lux/compiler/jvm/proc/host.clj b/lux-bootstrapper/src/lux/compiler/jvm/proc/host.clj
index ec934ae7b..ec934ae7b 100644
--- a/luxc/src/lux/compiler/jvm/proc/host.clj
+++ b/lux-bootstrapper/src/lux/compiler/jvm/proc/host.clj
diff --git a/luxc/src/lux/compiler/jvm/rt.clj b/lux-bootstrapper/src/lux/compiler/jvm/rt.clj
index 7fabd27ed..7fabd27ed 100644
--- a/luxc/src/lux/compiler/jvm/rt.clj
+++ b/lux-bootstrapper/src/lux/compiler/jvm/rt.clj
diff --git a/luxc/src/lux/compiler/parallel.clj b/lux-bootstrapper/src/lux/compiler/parallel.clj
index 28716b45b..28716b45b 100644
--- a/luxc/src/lux/compiler/parallel.clj
+++ b/lux-bootstrapper/src/lux/compiler/parallel.clj
diff --git a/luxc/src/lux/host.clj b/lux-bootstrapper/src/lux/host.clj
index 562d582f6..562d582f6 100644
--- a/luxc/src/lux/host.clj
+++ b/lux-bootstrapper/src/lux/host.clj
diff --git a/luxc/src/lux/host/generics.clj b/lux-bootstrapper/src/lux/host/generics.clj
index 9e0359760..9e0359760 100644
--- a/luxc/src/lux/host/generics.clj
+++ b/lux-bootstrapper/src/lux/host/generics.clj
diff --git a/luxc/src/lux/lexer.clj b/lux-bootstrapper/src/lux/lexer.clj
index 49e29710a..49e29710a 100644
--- a/luxc/src/lux/lexer.clj
+++ b/lux-bootstrapper/src/lux/lexer.clj
diff --git a/luxc/src/lux/lib/loader.clj b/lux-bootstrapper/src/lux/lib/loader.clj
index 97e6ee684..97e6ee684 100644
--- a/luxc/src/lux/lib/loader.clj
+++ b/lux-bootstrapper/src/lux/lib/loader.clj
diff --git a/luxc/src/lux/optimizer.clj b/lux-bootstrapper/src/lux/optimizer.clj
index 6e235e084..6e235e084 100644
--- a/luxc/src/lux/optimizer.clj
+++ b/lux-bootstrapper/src/lux/optimizer.clj
diff --git a/luxc/src/lux/parser.clj b/lux-bootstrapper/src/lux/parser.clj
index dd33129b8..dd33129b8 100644
--- a/luxc/src/lux/parser.clj
+++ b/lux-bootstrapper/src/lux/parser.clj
diff --git a/luxc/src/lux/reader.clj b/lux-bootstrapper/src/lux/reader.clj
index 14914cc2e..14914cc2e 100644
--- a/luxc/src/lux/reader.clj
+++ b/lux-bootstrapper/src/lux/reader.clj
diff --git a/luxc/src/lux/repl.clj b/lux-bootstrapper/src/lux/repl.clj
index d980ac9ec..d980ac9ec 100644
--- a/luxc/src/lux/repl.clj
+++ b/lux-bootstrapper/src/lux/repl.clj
diff --git a/luxc/src/lux/type.clj b/lux-bootstrapper/src/lux/type.clj
index 8853224b5..8853224b5 100644
--- a/luxc/src/lux/type.clj
+++ b/lux-bootstrapper/src/lux/type.clj
diff --git a/luxc/src/lux/type/host.clj b/lux-bootstrapper/src/lux/type/host.clj
index 36e969046..36e969046 100644
--- a/luxc/src/lux/type/host.clj
+++ b/lux-bootstrapper/src/lux/type/host.clj
diff --git a/lux-jvm/project.clj b/lux-jvm/project.clj
index 301740923..ed3221411 100644
--- a/lux-jvm/project.clj
+++ b/lux-jvm/project.clj
@@ -20,7 +20,7 @@
:scm {:name "git"
:url ~(str repo ".git")}
- :dependencies [[com.github.luxlang/luxc-jvm ~version]
+ :dependencies [[com.github.luxlang/lux-bootstrapper ~version]
[com.github.luxlang/stdlib ~version]
;; JVM Bytecode (TODO: Remove ASAP)
[org.ow2.asm/asm-all "5.0.3"]]
diff --git a/lux-lein/src/leiningen/lux/utils.clj b/lux-lein/src/leiningen/lux/utils.clj
index a0bb5abe2..23466e92f 100644
--- a/lux-lein/src/leiningen/lux/utils.clj
+++ b/lux-lein/src/leiningen/lux/utils.clj
@@ -31,7 +31,7 @@
[(get project :group) (get project :name)])
(def ^:private lux-group "com.github.luxlang")
-(def ^:private compiler-id [lux-group "luxc-jvm"])
+(def ^:private compiler-id [lux-group "lux-bootstrapper"])
(def ^:private jvm-compiler-id [lux-group "lux-jvm"])
(def ^:private stdlib-id [lux-group "stdlib"])
diff --git a/shell/lux.sh b/shell/lux.sh
new file mode 100755
index 000000000..3ff27a556
--- /dev/null
+++ b/shell/lux.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+
+home() {
+ # Find out where the script is located.
+ # This is because it is assumed that the Aedifex JAR will be in the same directory.
+ local SCRIPT_SOURCE="${BASH_SOURCE[0]}"
+ while [ -h "$SCRIPT_SOURCE" ]; do
+ # resolve $SCRIPT_SOURCE until the file is no longer a symlink
+ local SCRIPT_HOME="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" >/dev/null 2>&1 && pwd )"
+ SCRIPT_SOURCE="$(readlink "$SCRIPT_SOURCE")"
+ # if $SCRIPT_SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
+ [[ $SCRIPT_SOURCE != /* ]] && SCRIPT_SOURCE="$SCRIPT_HOME/$SCRIPT_SOURCE"
+ done
+ echo "$( cd -P "$( dirname "$SCRIPT_SOURCE" )" >/dev/null 2>&1 && pwd )"
+}
+
+aedifex() {
+ echo "$(home)/aedifex.jar"
+}
+
+command() {
+ local COMMAND=""
+ while [ $# -gt 0 ]; do
+ COMMAND="$COMMAND $1"
+ shift
+ done
+ echo $COMMAND
+}
+
+java -jar $(aedifex) $(command "$@")
+
diff --git a/stdlib/project.clj b/stdlib/project.clj
index dcaec7c4c..62474fea1 100644
--- a/stdlib/project.clj
+++ b/stdlib/project.clj
@@ -20,7 +20,7 @@
:manifest {"lux" ~version}
:source-paths ["source"]
- :dependencies [[com.github.luxlang/luxc-jvm ~version]]
+ :dependencies [[com.github.luxlang/lux-bootstrapper ~version]]
:profiles {:bibliotheca {:description "Standard library for the Lux programming language."
:dependencies []
:lux {:test "test/lux"}}
diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux
index a5ee64cab..8a64392e4 100644
--- a/stdlib/source/lux.lux
+++ b/stdlib/source/lux.lux
@@ -2244,9 +2244,9 @@
#Nil
(-> Int Text)
(if ("lux i64 =" +0 value)
- "0"
+ "+0"
(let' [sign (if ("lux i64 <" value +0)
- ""
+ "+"
"-")]
(("lux check" (-> Int Text Text)
(function' recur [input output]
diff --git a/stdlib/source/lux/data/number/frac.lux b/stdlib/source/lux/data/number/frac.lux
index d8bc34f93..34b2d6532 100644
--- a/stdlib/source/lux/data/number/frac.lux
+++ b/stdlib/source/lux/data/number/frac.lux
@@ -417,3 +417,11 @@
(..- standard)
..abs
(..< margin-of-error)))
+
+(def: #export (mod divisor dividend)
+ (All [m] (-> Frac Frac Frac))
+ (if (..= (..signum divisor) (..signum dividend))
+ (..% divisor dividend)
+ (case (..% divisor dividend)
+ +0.0 +0.0
+ rem (..+ divisor rem))))
diff --git a/stdlib/source/lux/data/number/int.lux b/stdlib/source/lux/data/number/int.lux
index 38a0dc63a..087302b8d 100644
--- a/stdlib/source/lux/data/number/int.lux
+++ b/stdlib/source/lux/data/number/int.lux
@@ -87,7 +87,9 @@
[(../ param subject)
(..% param subject)])
-(def: #export negate (-> Int Int) (..* -1))
+(def: #export (negate value)
+ (-> Int Int)
+ (..- value +0))
(def: #export (abs x)
(-> Int Int)
@@ -102,13 +104,13 @@
## else
+1))
-(def: #export (mod param subject)
+(def: #export (mod divisor dividend)
(All [m] (-> Int Int Int))
- (let [raw (..% param subject)]
- (if (..< +0 raw)
- (let [shift (if (..< +0 param) ..- ..+)]
- (|> raw (shift param)))
- raw)))
+ (if (..= (..signum divisor) (..signum dividend))
+ (..% divisor dividend)
+ (case (..% divisor dividend)
+ +0 +0
+ rem (..+ divisor rem))))
(def: #export even?
(-> Int Bit)
@@ -185,23 +187,26 @@
[minimum ..min (\ ..interval top)]
)
+(def: -sign "-")
+(def: +sign "+")
+
(def: (sign!! value)
(-> Int Text)
(if (..< +0 value)
- "-"
- "+"))
+ ..-sign
+ ..+sign))
(def: (sign?? representation)
(-> Text (Maybe Int))
- (case ("lux text char" 0 representation)
- (^ (char "-"))
- (#.Some -1)
+ (`` (case ("lux text char" 0 representation)
+ (^ (char (~~ (static ..-sign))))
+ (#.Some -1)
- (^ (char "+"))
- (#.Some +1)
+ (^ (char (~~ (static ..+sign))))
+ (#.Some +1)
- _
- #.None))
+ _
+ #.None)))
(def: (int-decode-loop input-size repr sign <base> <to-value> <error>)
(-> Nat Text Int Int (-> Char (Maybe Nat)) Text (Try Int))
@@ -217,7 +222,7 @@
(|> output (..* <base>) (..+ (.int digit-value)))))
(#try.Success (..* sign output)))))
-(template [<struct> <base> <to-character> <to-value> <error>]
+(template [<base> <struct> <to-character> <to-value> <error>]
[(structure: #export <struct>
(Codec Text Int)
@@ -245,10 +250,10 @@
(#try.Failure <error>))
(#try.Failure <error>)))))]
- [binary +2 //nat.binary-character //nat.binary-value "Invalid binary syntax for Int: "]
- [octal +8 //nat.octal-character //nat.octal-value "Invalid octal syntax for Int: "]
- [decimal +10 //nat.decimal-character //nat.decimal-value "Invalid syntax for Int: "]
- [hex +16 //nat.hexadecimal-character //nat.hexadecimal-value "Invalid hexadecimal syntax for Int: "]
+ [+02 binary //nat.binary-character //nat.binary-value "Invalid binary syntax for Int: "]
+ [+08 octal //nat.octal-character //nat.octal-value "Invalid octal syntax for Int: "]
+ [+10 decimal //nat.decimal-character //nat.decimal-value "Invalid syntax for Int: "]
+ [+16 hex //nat.hexadecimal-character //nat.hexadecimal-value "Invalid hexadecimal syntax for Int: "]
)
(structure: #export hash
diff --git a/stdlib/source/program/aedifex.lux b/stdlib/source/program/aedifex.lux
index 06b75afd5..d804fd552 100644
--- a/stdlib/source/program/aedifex.lux
+++ b/stdlib/source/program/aedifex.lux
@@ -5,7 +5,7 @@
[control
[pipe (#+ do>)]
["." io (#+ IO)]
- ["." try (#+ Try)]
+ ["." try (#+ Try) ("#\." functor)]
["." exception (#+ exception:)]
[parser
["." cli (#+ program:)]
@@ -86,70 +86,80 @@
(program: [{[profile operation] /cli.command}]
(do {! io.monad}
- [?profile (/input.read io.monad file.default profile)
- ?console console.default]
- (case [?profile ?console]
- [(#try.Success profile) (#try.Success console)]
- (let [console (console.async console)]
- (case operation
- #/cli.Version
- (exec (/command/version.do! console profile)
- (wrap []))
-
- #/cli.Clean
- (exec (/command/clean.do! console (file.async file.default) profile)
- (wrap []))
+ [?console console.default]
+ (case (try\map console.async ?console)
+ (#try.Failure error)
+ (wrap (log! error))
- #/cli.POM
- (exec (/command/pom.do! console (file.async file.default) profile)
- (wrap []))
-
- #/cli.Install
- (exec (/command/install.do! console (file.async file.default) profile)
- (wrap []))
+ (#try.Success console)
+ (case operation
+ #/cli.Version
+ (exec (/command/version.do! console (\ /.monoid identity))
+ (wrap []))
- (#/cli.Deploy repository identity)
- (exec (case [(get@ #/.identity profile)
- (dictionary.get repository (get@ #/.deploy-repositories profile))]
- [(#.Some artifact) (#.Some repository)]
- (/command/deploy.do! console
- (/repository.async (/repository.remote repository))
- (file.async file.default)
- identity
- artifact
- profile)
+ _
+ (do !
+ [?profile (/input.read io.monad file.default profile)]
+ (case ?profile
+ (#try.Failure error)
+ (wrap (log! error))
- [#.None _]
- (promise\wrap (exception.throw /.no-identity []))
+ (#try.Success profile)
+ (case operation
+ #/cli.Version
+ (wrap [])
+
+ #/cli.Clean
+ (exec (/command/clean.do! console (file.async file.default) profile)
+ (wrap []))
+
+ #/cli.POM
+ (exec (/command/pom.do! console (file.async file.default) profile)
+ (wrap []))
+
+ #/cli.Install
+ (exec (/command/install.do! console (file.async file.default) profile)
+ (wrap []))
- [_ #.None]
- (promise\wrap (exception.throw ..cannot-find-repository [repository (get@ #/.deploy-repositories profile)])))
- (wrap []))
-
- #/cli.Dependencies
- (exec (/command/deps.do! console (file.async file.default) (..repositories profile) profile)
- (wrap []))
+ (#/cli.Deploy repository identity)
+ (exec (case [(get@ #/.identity profile)
+ (dictionary.get repository (get@ #/.deploy-repositories profile))]
+ [(#.Some artifact) (#.Some repository)]
+ (/command/deploy.do! console
+ (/repository.async (/repository.remote repository))
+ (file.async file.default)
+ identity
+ artifact
+ profile)
- (#/cli.Compilation compilation)
- (case compilation
- #/cli.Build (exec (..with-dependencies console /command/build.do! profile)
- (wrap []))
- #/cli.Test (exec (..with-dependencies console /command/test.do! profile)
- (wrap [])))
+ [#.None _]
+ (promise\wrap (exception.throw /.no-identity []))
- (#/cli.Auto auto)
- (do !
- [?watcher watch.default]
- (case ?watcher
- (#try.Failure error)
- (wrap (log! error))
+ [_ #.None]
+ (promise\wrap (exception.throw ..cannot-find-repository [repository (get@ #/.deploy-repositories profile)])))
+ (wrap []))
- (#try.Success watcher)
- (exec (case auto
- #/cli.Build (..with-dependencies console (/command/auto.do! watcher /command/build.do!) profile)
- #/cli.Test (..with-dependencies console (/command/auto.do! watcher /command/test.do!) profile))
- (wrap []))))))
-
- (^or [(#try.Failure error) _]
- [_ (#try.Failure error)])
- (wrap (log! error)))))
+ #/cli.Dependencies
+ (exec (/command/deps.do! console (file.async file.default) (..repositories profile) profile)
+ (wrap []))
+
+ (#/cli.Compilation compilation)
+ (case compilation
+ #/cli.Build (exec (..with-dependencies console /command/build.do! profile)
+ (wrap []))
+ #/cli.Test (exec (..with-dependencies console /command/test.do! profile)
+ (wrap [])))
+
+ (#/cli.Auto auto)
+ (do !
+ [?watcher watch.default]
+ (case ?watcher
+ (#try.Failure error)
+ (wrap (log! error))
+
+ (#try.Success watcher)
+ (exec (case auto
+ #/cli.Build (..with-dependencies console (/command/auto.do! watcher /command/build.do!) profile)
+ #/cli.Test (..with-dependencies console (/command/auto.do! watcher /command/test.do!) profile))
+ (wrap [])))))
+ ))))))
diff --git a/stdlib/source/program/compositor/import.lux b/stdlib/source/program/compositor/import.lux
index edc0160f5..54227c7f3 100644
--- a/stdlib/source/program/compositor/import.lux
+++ b/stdlib/source/program/compositor/import.lux
@@ -46,9 +46,9 @@
(def: (import-library system library import)
(-> (file.System Promise) Library Import (Action Import))
(do (try.with promise.monad)
- [library (: (Action (File Promise))
- (!.use (\ system file) [library]))
- binary (!.use (\ library content) [])]
+ [file (: (Action (File Promise))
+ (!.use (\ system file) [library]))
+ binary (!.use (\ file content) [])]
(promise\wrap
(do {! try.monad}
[tar (<b>.run tar.parser binary)]
diff --git a/stdlib/source/test/lux/data/number/frac.lux b/stdlib/source/test/lux/data/number/frac.lux
index fd963a3ef..193b4a960 100644
--- a/stdlib/source/test/lux/data/number/frac.lux
+++ b/stdlib/source/test/lux/data/number/frac.lux
@@ -12,9 +12,7 @@
["$." monoid]
["$." codec]]}]
[data
- ["." bit ("#\." equivalence)]
- [text
- ["%" format (#+ format)]]]
+ ["." bit ("#\." equivalence)]]
[math
["." random (#+ Random)]]]
{1
@@ -29,31 +27,6 @@
(Random Frac)
(\ random.monad map (|>> (i.% +1,000,000) i.frac) random.int))
-(def: signature
- Test
- (`` ($_ _.and
- (_.with-cover [/.equivalence /.=]
- ($equivalence.spec /.equivalence random.safe-frac))
- (_.with-cover [/.order /.<]
- ($order.spec /.order random.safe-frac))
- (~~ (template [<compose> <monoid>]
- [(_.with-cover [<monoid> <compose>]
- ($monoid.spec /.equivalence <monoid> ..random))]
-
- [/.+ /.addition]
- [/.* /.multiplication]
-
- [/.min /.minimum]
- [/.max /.maximum]
- ))
- (~~ (template [<codec>]
- [(_.with-cover [<codec>]
- ($codec.spec /.equivalence <codec> random.safe-frac))]
-
- [/.binary] [/.octal] [/.decimal] [/.hex]
- ))
- )))
-
(def: constant
Test
(do random.monad
@@ -117,6 +90,31 @@
(|> expected r.frac /.rev (r.= expected))))
))
+(def: signature
+ Test
+ (`` ($_ _.and
+ (_.with-cover [/.equivalence /.=]
+ ($equivalence.spec /.equivalence random.safe-frac))
+ (_.with-cover [/.order /.<]
+ ($order.spec /.order random.safe-frac))
+ (~~ (template [<compose> <monoid>]
+ [(_.with-cover [<monoid> <compose>]
+ ($monoid.spec /.equivalence <monoid> ..random))]
+
+ [/.+ /.addition]
+ [/.* /.multiplication]
+
+ [/.min /.minimum]
+ [/.max /.maximum]
+ ))
+ (~~ (template [<codec>]
+ [(_.with-cover [<codec>]
+ ($codec.spec /.equivalence <codec> random.safe-frac))]
+
+ [/.binary] [/.octal] [/.decimal] [/.hex]
+ ))
+ )))
+
(with-expansions [<jvm> (as-is (host.import: java/lang/Double
["#::."
(#static doubleToRawLongBits #manual [double] long)
@@ -128,92 +126,104 @@
Test
(<| (_.covering /._)
(_.with-cover [.Frac])
- (`` ($_ _.and
- (do random.monad
- [left random.safe-frac
- right random.safe-frac]
- ($_ _.and
- (_.cover [/.>]
- (bit\= (/.> left right)
- (/.< right left)))
- (_.cover [/.<= /.>=]
- (bit\= (/.<= left right)
- (/.>= right left)))
- ))
- (do random.monad
- [left ..random
- right ..random]
- ($_ _.and
- (_.cover [/.%]
- (let [rem (/.% left right)
- div (|> right (/.- rem) (/./ left))]
- (/.= right
- (|> div (/.* left) (/.+ rem)))))
- (_.cover [/./%]
- (let [[div rem] (/./% left right)]
- (and (/.= div (/./ left right))
- (/.= rem (/.% left right)))))
- ))
- (do random.monad
- [sample random.safe-frac]
- ($_ _.and
- (_.cover [/.-]
- (and (/.= +0.0 (/.- sample sample))
- (/.= sample (/.- +0.0 sample))
- (/.= (/.negate sample)
- (/.- sample +0.0))))
- (_.cover [/./]
- (and (/.= +1.0 (/./ sample sample))
- (/.= sample (/./ +1.0 sample))))
- (_.cover [/.abs]
- (bit\= (/.> sample (/.abs sample))
- (/.negative? sample)))
- (_.cover [/.signum]
- (/.= (/.abs sample)
- (/.* (/.signum sample) sample)))
- ))
- (with-expansions [<jvm> ($_ _.and
- (do random.monad
- [expected random.frac]
- (_.cover [/.to-bits]
- (n.= (.nat (java/lang/Double::doubleToRawLongBits expected))
- (/.to-bits expected))))
- (do random.monad
- [sample random.i64]
- (_.cover [/.from-bits]
- (let [expected (java/lang/Double::longBitsToDouble sample)
- actual (/.from-bits sample)]
- (or (/.= expected actual)
- (and (/.not-a-number? expected)
- (/.not-a-number? actual))))))
- )]
- (for {@.old <jvm>
- @.jvm <jvm>}
- (do random.monad
- [expected random.frac]
- (_.cover [/.to-bits /.from-bits]
- (let [actual (|> expected /.to-bits /.from-bits)]
- (or (/.= expected actual)
- (and (/.not-a-number? expected)
- (/.not-a-number? actual))))))))
- (do random.monad
- [sample random.frac]
- (_.cover [/.hash]
- (n.= (/.to-bits sample)
- (\ /.hash hash sample))))
- (do random.monad
- [expected random.safe-frac]
- (_.cover [/.negate]
- (let [subtraction!
- (/.= +0.0 (/.+ (/.negate expected) expected))
+ ($_ _.and
+ (do random.monad
+ [left random.safe-frac
+ right random.safe-frac]
+ ($_ _.and
+ (_.cover [/.>]
+ (bit\= (/.> left right)
+ (/.< right left)))
+ (_.cover [/.<= /.>=]
+ (bit\= (/.<= left right)
+ (/.>= right left)))
+ ))
+ (do random.monad
+ [sample random.safe-frac]
+ ($_ _.and
+ (_.cover [/.-]
+ (and (/.= +0.0 (/.- sample sample))
+ (/.= sample (/.- +0.0 sample))
+ (/.= (/.negate sample)
+ (/.- sample +0.0))))
+ (_.cover [/./]
+ (and (/.= +1.0 (/./ sample sample))
+ (/.= sample (/./ +1.0 sample))))
+ (_.cover [/.abs]
+ (bit\= (/.> sample (/.abs sample))
+ (/.negative? sample)))
+ (_.cover [/.signum]
+ (/.= (/.abs sample)
+ (/.* (/.signum sample) sample)))
+ ))
+ (do random.monad
+ [left ..random
+ right ..random]
+ ($_ _.and
+ (_.cover [/.%]
+ (let [rem (/.% left right)
+ div (|> right (/.- rem) (/./ left))]
+ (/.= right
+ (|> div (/.* left) (/.+ rem)))))
+ (_.cover [/./%]
+ (let [[div rem] (/./% left right)]
+ (and (/.= div (/./ left right))
+ (/.= rem (/.% left right)))))
+ (_.cover [/.mod]
+ (and (/.= (/.signum left)
+ (/.signum (/.mod left right)))
+ (/.= (/.signum right)
+ (/.signum (/.% left right)))
+ (if (/.= (/.signum left) (/.signum right))
+ (/.= (/.% left right)
+ (/.mod left right))
+ (or (and (/.= +0.0 (/.% left right))
+ (/.= +0.0 (/.mod left right)))
+ (/.= (/.+ left (/.% left right))
+ (/.mod left right))))))
+ ))
+ (with-expansions [<jvm> ($_ _.and
+ (do random.monad
+ [expected random.frac]
+ (_.cover [/.to-bits]
+ (n.= (.nat (java/lang/Double::doubleToRawLongBits expected))
+ (/.to-bits expected))))
+ (do random.monad
+ [sample random.i64]
+ (_.cover [/.from-bits]
+ (let [expected (java/lang/Double::longBitsToDouble sample)
+ actual (/.from-bits sample)]
+ (or (/.= expected actual)
+ (and (/.not-a-number? expected)
+ (/.not-a-number? actual))))))
+ )]
+ (for {@.old <jvm>
+ @.jvm <jvm>}
+ (do random.monad
+ [expected random.frac]
+ (_.cover [/.to-bits /.from-bits]
+ (let [actual (|> expected /.to-bits /.from-bits)]
+ (or (/.= expected actual)
+ (and (/.not-a-number? expected)
+ (/.not-a-number? actual))))))))
+ (do random.monad
+ [expected random.safe-frac]
+ (_.cover [/.negate]
+ (let [subtraction!
+ (/.= +0.0 (/.+ (/.negate expected) expected))
- inverse!
- (|> expected /.negate /.negate (/.= expected))]
- (and subtraction!
- inverse!))))
+ inverse!
+ (|> expected /.negate /.negate (/.= expected))]
+ (and subtraction!
+ inverse!))))
+ (do random.monad
+ [sample random.frac]
+ (_.cover [/.hash]
+ (n.= (/.to-bits sample)
+ (\ /.hash hash sample))))
- ..constant
- ..predicate
- ..conversion
- ..signature
- ))))
+ ..constant
+ ..predicate
+ ..conversion
+ ..signature
+ )))
diff --git a/stdlib/source/test/lux/data/number/i64.lux b/stdlib/source/test/lux/data/number/i64.lux
index 89dc6a669..a9cddc921 100644
--- a/stdlib/source/test/lux/data/number/i64.lux
+++ b/stdlib/source/test/lux/data/number/i64.lux
@@ -118,18 +118,20 @@
#let [spare (n.- size /.width)]
offset (\ ! map (n.% spare) random.nat)]
(_.cover [/.region]
- (\= (|> pattern
- ## NNNNYYYYNNNN
- (/.logic-right-shift offset)
- ## ____NNNNYYYY
- (/.left-shift spare)
- ## YYYY________
- (/.logic-right-shift spare)
- ## ________YYYY
- (/.left-shift offset)
- ## ____YYYY____
- )
- (/.and (/.region size offset) pattern))))
+ (case size
+ 0 (\= /.false (/.region size offset))
+ _ (\= (|> pattern
+ ## NNNNYYYYNNNN
+ (/.logic-right-shift offset)
+ ## ____NNNNYYYY
+ (/.left-shift spare)
+ ## YYYY________
+ (/.logic-right-shift spare)
+ ## ________YYYY
+ (/.left-shift offset)
+ ## ____YYYY____
+ )
+ (/.and (/.region size offset) pattern)))))
))))
(def: sub
diff --git a/stdlib/source/test/lux/data/number/int.lux b/stdlib/source/test/lux/data/number/int.lux
index 680def4f5..31b732b88 100644
--- a/stdlib/source/test/lux/data/number/int.lux
+++ b/stdlib/source/test/lux/data/number/int.lux
@@ -1,6 +1,5 @@
(.module:
[lux #*
- ["%" data/text/format (#+ format)]
["_" test (#+ Test)]
[abstract
[monad (#+ do)]
@@ -12,38 +11,160 @@
["$." interval]
["$." monoid]
["$." codec]]}]
+ [data
+ ["." bit ("#\." equivalence)]
+ [number
+ ["f" frac]
+ ["." i64 ("#\." hash)]]]
[math
- ["r" random]]]
+ ["." random]]]
{1
- ["." /
- //]})
+ ["." /]})
-(def: #export test
+(def: signature
Test
- (<| (_.context (%.name (name-of /._)))
- (`` ($_ _.and
- ($equivalence.spec /.equivalence r.int)
- ($order.spec /.order r.int)
- ($enum.spec /.enum r.int)
- ($interval.spec /.interval r.int)
- (~~ (template [<monoid>]
- [(<| (_.context (%.name (name-of <monoid>)))
- ($monoid.spec /.equivalence <monoid> r.int))]
+ (`` ($_ _.and
+ (_.with-cover [/.equivalence /.=]
+ ($equivalence.spec /.equivalence random.int))
+ (_.with-cover [/.order /.<]
+ ($order.spec /.order random.int))
+ (_.with-cover [/.enum]
+ ($enum.spec /.enum random.int))
+ (_.with-cover [/.interval]
+ ($interval.spec /.interval random.int))
+ (~~ (template [<compose> <monoid>]
+ [(_.with-cover [<monoid> <compose>]
+ ($monoid.spec /.equivalence <monoid> random.int))]
+
+ [/.+ /.addition]
+ [/.* /.multiplication]
+
+ [/.min /.minimum]
+ [/.max /.maximum]
+ ))
+ (~~ (template [<codec>]
+ [(_.with-cover [<codec>]
+ ($codec.spec /.equivalence <codec> random.int))]
- [/.addition] [/.multiplication] [/.minimum] [/.maximum]
- ))
- (~~ (template [<codec>]
- [(<| (_.context (%.name (name-of /.binary)))
- ($codec.spec /.equivalence <codec> r.int))]
+ [/.binary] [/.octal] [/.decimal] [/.hex]
+ ))
+ )))
+
+(def: predicate
+ Test
+ (do {! random.monad}
+ [sample random.int
+ shift (\ ! map /.abs random.int)]
+ ($_ _.and
+ (_.cover [/.negative?]
+ (bit\= (/.negative? sample)
+ (/.< +0 sample)))
+ (_.cover [/.positive?]
+ (bit\= (/.positive? sample)
+ (/.> +0 sample)))
+ (_.cover [/.zero?]
+ (bit\= (/.zero? sample)
+ (/.= +0 sample)))
+ (_.cover [/.even? /.odd?]
+ (bit\= (/.even? sample)
+ (not (/.odd? sample))))
+ )))
+
+(def: #export test
+ Test
+ (<| (_.covering /._)
+ (_.with-cover [.Int])
+ ($_ _.and
+ (do random.monad
+ [sample random.int]
+ ($_ _.and
+ (_.cover [/.-]
+ (and (/.= +0 (/.- sample sample))
+ (/.= sample (/.- +0 sample))
+ (/.= (/.negate sample)
+ (/.- sample +0))))
+ (_.cover [/./]
+ (and (/.= +1 (/./ sample sample))
+ (/.= sample (/./ +1 sample))))
+ (_.cover [/.abs]
+ (bit\= (/.> sample (/.abs sample))
+ (/.negative? sample)))
+ (_.cover [/.signum]
+ (/.= (/.abs sample)
+ (/.* (/.signum sample) sample)))
+ ))
+ (do random.monad
+ [left random.int
+ right random.int]
+ ($_ _.and
+ (_.cover [/.>]
+ (bit\= (/.> left right)
+ (/.< right left)))
+ (_.cover [/.<= /.>=]
+ (bit\= (/.<= left right)
+ (/.>= right left)))
+ ))
+ (do random.monad
+ [left (random.filter (|>> (/.= +0) not)
+ random.int)
+ right random.int]
+ ($_ _.and
+ (_.cover [/.%]
+ (let [rem (/.% left right)
+ div (|> right (/.- rem) (/./ left))]
+ (/.= right
+ (|> div (/.* left) (/.+ rem)))))
+ (_.cover [/./%]
+ (let [[div rem] (/./% left right)]
+ (and (/.= div (/./ left right))
+ (/.= rem (/.% left right)))))
+ (_.cover [/.mod]
+ (and (/.= (/.signum left)
+ (/.signum (/.mod left right)))
+ (/.= (/.signum right)
+ (/.signum (/.% left right)))
+ (if (/.= (/.signum left) (/.signum right))
+ (/.= (/.% left right)
+ (/.mod left right))
+ (or (and (/.= +0 (/.% left right))
+ (/.= +0 (/.mod left right)))
+ (/.= (/.+ left (/.% left right))
+ (/.mod left right))))))
+ ))
+ (do {! random.monad}
+ [#let [random (\ ! map (/.% +1,000) random.int)]
+ left random
+ right random]
+ ($_ _.and
+ (_.cover [/.gcd]
+ (let [gcd (/.gcd left right)]
+ (and (/.= +0 (/.% gcd left))
+ (/.= +0 (/.% gcd right)))))
+ (_.cover [/.lcm]
+ (let [lcm (/.lcm left right)]
+ (and (/.= +0 (/.% left lcm))
+ (/.= +0 (/.% right lcm)))))
+ ))
+ (do random.monad
+ [expected random.int]
+ (_.cover [/.negate]
+ (let [subtraction!
+ (/.= +0 (/.+ (/.negate expected) expected))
- [/.binary] [/.octal] [/.decimal] [/.hex]
- ))
+ inverse!
+ (|> expected /.negate /.negate (/.= expected))]
+ (and subtraction!
+ inverse!))))
+ (do {! random.monad}
+ [expected (\ ! map (/.% +1,000,000) random.int)]
+ (_.cover [/.frac]
+ (|> expected /.frac f.int (/.= expected))))
+ (do random.monad
+ [sample random.int]
+ (_.cover [/.hash]
+ (i64\= (i64\hash sample)
+ (\ /.hash hash sample))))
- (_.test "Alternate notations."
- (and (/.= (bin "+11001001")
- (bin "+11,00,10,01"))
- (/.= (oct "-615243")
- (oct "-615,243"))
- (/.= (hex "+deadBEEF")
- (hex "+dead,BEEF"))))
- ))))
+ ..predicate
+ ..signature
+ )))