From dff8878c13610ae8d1207aaabefbecc88cd3911f Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 28 Jul 2018 13:36:49 -0400 Subject: Temporary commit to get rid of "+" signs for Nat. --- luxc/src/lux/lexer.clj | 7 +- luxc/src/lux/parser.clj | 2 +- stdlib/source/lux.lux | 592 ++++++++++----------- stdlib/source/lux/compiler/default/cache.lux | 2 +- stdlib/source/lux/compiler/default/init.lux | 12 +- stdlib/source/lux/compiler/default/name.lux | 2 +- .../source/lux/compiler/default/phase/analysis.lux | 14 +- .../default/phase/analysis/case/coverage.lux | 4 +- .../compiler/default/phase/analysis/inference.lux | 12 +- .../lux/compiler/default/phase/analysis/scope.lux | 6 +- .../compiler/default/phase/analysis/structure.lux | 2 +- .../default/phase/extension/analysis/common.lux | 10 +- .../default/phase/extension/analysis/host.jvm.lux | 50 +- .../lux/compiler/default/phase/synthesis.lux | 4 +- .../default/phase/synthesis/expression.lux | 6 +- .../compiler/default/phase/synthesis/function.lux | 10 +- .../lux/compiler/default/phase/synthesis/loop.lux | 2 +- .../lux/compiler/default/phase/translation.lux | 6 +- .../translation/scheme/extension/common.jvm.lux | 18 +- .../phase/translation/scheme/function.jvm.lux | 4 +- .../phase/translation/scheme/runtime.jvm.lux | 8 +- stdlib/source/lux/compiler/default/reference.lux | 8 +- stdlib/source/lux/compiler/default/repl/type.lux | 2 +- stdlib/source/lux/compiler/default/syntax.lux | 40 +- stdlib/source/lux/compiler/meta/io/archive.lux | 2 +- stdlib/source/lux/concurrency/actor.lux | 4 +- stdlib/source/lux/concurrency/promise.lux | 2 +- stdlib/source/lux/concurrency/semaphore.lux | 16 +- stdlib/source/lux/control/comonad.lux | 4 +- stdlib/source/lux/control/concatenative.lux | 22 +- stdlib/source/lux/control/equivalence.lux | 4 +- stdlib/source/lux/control/exception.lux | 2 +- stdlib/source/lux/control/monad.lux | 6 +- stdlib/source/lux/control/parser.lux | 8 +- stdlib/source/lux/control/pipe.lux | 2 +- stdlib/source/lux/control/writer.lux | 2 +- stdlib/source/lux/data/bit.lux | 4 +- stdlib/source/lux/data/collection/array.lux | 30 +- stdlib/source/lux/data/collection/bits.lux | 28 +- stdlib/source/lux/data/collection/dictionary.lux | 48 +- .../lux/data/collection/dictionary/ordered.lux | 2 +- stdlib/source/lux/data/collection/list.lux | 74 +-- .../source/lux/data/collection/queue/priority.lux | 4 +- stdlib/source/lux/data/collection/row.lux | 56 +- stdlib/source/lux/data/collection/sequence.lux | 4 +- stdlib/source/lux/data/collection/set.lux | 4 +- stdlib/source/lux/data/collection/set/multi.lux | 22 +- .../lux/data/collection/tree/rose/zipper.lux | 8 +- stdlib/source/lux/data/color.lux | 20 +- stdlib/source/lux/data/format/binary.lux | 36 +- stdlib/source/lux/data/number.lux | 320 +++++------ stdlib/source/lux/data/number/complex.lux | 4 +- stdlib/source/lux/data/number/i64.lux | 22 +- stdlib/source/lux/data/number/ratio.lux | 8 +- stdlib/source/lux/data/sum.lux | 20 +- stdlib/source/lux/data/text.lux | 18 +- stdlib/source/lux/data/text/buffer.lux | 4 +- stdlib/source/lux/data/text/lexer.lux | 4 +- stdlib/source/lux/data/text/regex.lux | 14 +- stdlib/source/lux/data/text/unicode.lux | 246 ++++----- stdlib/source/lux/host.jvm.lux | 6 +- stdlib/source/lux/io.lux | 2 +- stdlib/source/lux/macro/code.lux | 2 +- stdlib/source/lux/macro/poly.lux | 36 +- stdlib/source/lux/macro/poly/equivalence.lux | 2 +- stdlib/source/lux/macro/poly/functor.lux | 8 +- stdlib/source/lux/macro/poly/json.lux | 10 +- stdlib/source/lux/math.lux | 8 +- stdlib/source/lux/math/random.lux | 34 +- stdlib/source/lux/test.lux | 24 +- stdlib/source/lux/time/date.lux | 50 +- stdlib/source/lux/time/instant.lux | 20 +- stdlib/source/lux/type.lux | 6 +- stdlib/source/lux/type/check.lux | 6 +- stdlib/source/lux/type/implicit.lux | 10 +- stdlib/source/lux/type/resource.lux | 2 +- stdlib/source/lux/world/binary.lux | 70 +-- stdlib/source/lux/world/net/udp.jvm.lux | 4 +- stdlib/test/test/lux.lux | 28 +- stdlib/test/test/lux/cli.lux | 10 +- .../lux/compiler/default/phase/analysis/case.lux | 26 +- .../compiler/default/phase/analysis/function.lux | 20 +- .../compiler/default/phase/analysis/primitive.lux | 8 +- .../default/phase/analysis/procedure/common.lux | 34 +- .../compiler/default/phase/analysis/reference.lux | 18 +- .../compiler/default/phase/analysis/structure.lux | 50 +- .../lux/compiler/default/phase/synthesis/case.lux | 8 +- .../compiler/default/phase/synthesis/function.lux | 24 +- .../compiler/default/phase/synthesis/primitive.lux | 6 +- .../compiler/default/phase/synthesis/structure.lux | 8 +- stdlib/test/test/lux/compiler/default/syntax.lux | 52 +- stdlib/test/test/lux/concurrency/actor.lux | 20 +- stdlib/test/test/lux/concurrency/atom.lux | 2 +- stdlib/test/test/lux/concurrency/frp.lux | 18 +- stdlib/test/test/lux/concurrency/promise.lux | 24 +- stdlib/test/test/lux/concurrency/semaphore.lux | 22 +- stdlib/test/test/lux/concurrency/stm.lux | 32 +- stdlib/test/test/lux/control/continuation.lux | 18 +- stdlib/test/test/lux/control/exception.lux | 2 +- stdlib/test/test/lux/control/interval.lux | 22 +- stdlib/test/test/lux/control/parser.lux | 38 +- stdlib/test/test/lux/control/region.lux | 20 +- stdlib/test/test/lux/control/state.lux | 18 +- stdlib/test/test/lux/control/thread.lux | 8 +- stdlib/test/test/lux/data/bit.lux | 2 +- stdlib/test/test/lux/data/collection/array.lux | 24 +- stdlib/test/test/lux/data/collection/bits.lux | 12 +- .../test/test/lux/data/collection/dictionary.lux | 14 +- .../lux/data/collection/dictionary/ordered.lux | 4 +- stdlib/test/test/lux/data/collection/list.lux | 20 +- stdlib/test/test/lux/data/collection/queue.lux | 6 +- .../test/lux/data/collection/queue/priority.lux | 8 +- stdlib/test/test/lux/data/collection/row.lux | 12 +- stdlib/test/test/lux/data/collection/sequence.lux | 34 +- stdlib/test/test/lux/data/collection/set.lux | 4 +- .../test/test/lux/data/collection/set/ordered.lux | 4 +- stdlib/test/test/lux/data/collection/stack.lux | 4 +- stdlib/test/test/lux/data/collection/tree/rose.lux | 8 +- .../test/lux/data/collection/tree/rose/zipper.lux | 4 +- stdlib/test/test/lux/data/color.lux | 6 +- stdlib/test/test/lux/data/format/json.lux | 10 +- stdlib/test/test/lux/data/format/xml.lux | 22 +- stdlib/test/test/lux/data/lazy.lux | 4 +- stdlib/test/test/lux/data/name.lux | 10 +- stdlib/test/test/lux/data/number.lux | 30 +- stdlib/test/test/lux/data/number/complex.lux | 20 +- stdlib/test/test/lux/data/number/i64.lux | 14 +- stdlib/test/test/lux/data/number/ratio.lux | 20 +- stdlib/test/test/lux/data/sum.lux | 14 +- stdlib/test/test/lux/data/text.lux | 24 +- stdlib/test/test/lux/data/text/format.lux | 2 +- stdlib/test/test/lux/data/text/lexer.lux | 4 +- stdlib/test/test/lux/data/text/regex.lux | 18 +- stdlib/test/test/lux/host.jvm.lux | 6 +- stdlib/test/test/lux/macro/poly/equivalence.lux | 4 +- stdlib/test/test/lux/macro/syntax.lux | 2 +- stdlib/test/test/lux/math.lux | 26 +- stdlib/test/test/lux/math/logic/continuous.lux | 2 +- stdlib/test/test/lux/math/logic/fuzzy.lux | 18 +- stdlib/test/test/lux/math/modular.lux | 2 +- stdlib/test/test/lux/math/random.lux | 4 +- stdlib/test/test/lux/time/date.lux | 20 +- stdlib/test/test/lux/time/duration.lux | 10 +- stdlib/test/test/lux/time/instant.lux | 14 +- stdlib/test/test/lux/type.lux | 16 +- stdlib/test/test/lux/type/check.lux | 12 +- stdlib/test/test/lux/type/implicit.lux | 14 +- stdlib/test/test/lux/type/resource.lux | 24 +- stdlib/test/test/lux/world/binary.lux | 26 +- stdlib/test/test/lux/world/file.lux | 34 +- stdlib/test/test/lux/world/net/tcp.lux | 14 +- stdlib/test/test/lux/world/net/udp.lux | 14 +- 152 files changed, 1677 insertions(+), 1676 deletions(-) diff --git a/luxc/src/lux/lexer.clj b/luxc/src/lux/lexer.clj index 354bf98e2..73bcb4f22 100644 --- a/luxc/src/lux/lexer.clj +++ b/luxc/src/lux/lexer.clj @@ -130,7 +130,7 @@ (|do [[meta _ token] (&reader/read-regex )] (return (&/T [meta ( token)])))) - lex-bit $Bit #"^(#0|#1)" + lex-bit $Bit #"^#(0|1)" ) (do-template [ ] @@ -138,10 +138,11 @@ (|do [[meta _ token] (&reader/read-regex )] (return (&/T [meta ( (string/replace token #"_" ""))])))) - lex-nat $Nat #"^\+[0-9][0-9_]*" + ;; (-|\+) + lex-nat $Nat #"^\|[0-9][0-9_]*" lex-int $Int #"^-?[0-9][0-9_]*" lex-rev $Rev #"^\.[0-9][0-9_]*" - lex-frac $Frac #"^-?[0-9][0-9_]*\.[0-9_]+((e|E)(-|\+)?[0-9][0-9_]*)?" + lex-frac $Frac #"^-?[0-9][0-9_]*\.[0-9][0-9_]*((e|E)(-|\+)[0-9][0-9_]*)?" ) (def +same-module-mark+ (str &/+name-separator+ &/+name-separator+)) diff --git a/luxc/src/lux/parser.clj b/luxc/src/lux/parser.clj index dd33129b8..5303327c8 100644 --- a/luxc/src/lux/parser.clj +++ b/luxc/src/lux/parser.clj @@ -68,7 +68,7 @@ (return (&/|list (&/T [meta (&/$Bit (.equals ^String ?value "#1"))]))) (&lexer/$Nat ?value) - (return (&/|list (&/T [meta (&/$Nat (Long/parseUnsignedLong ?value))]))) + (return (&/|list (&/T [meta (&/$Nat (Long/parseUnsignedLong (.substring ^String ?value 1)))]))) (&lexer/$Int ?value) (return (&/|list (&/T [meta (&/$Int (Long/parseLong ?value))]))) diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index a9c442462..a30c03a78 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -1,168 +1,168 @@ ("lux def" dummy-cursor - ("lux check" (+2 (+0 "#Text" (+0)) - (+2 (+0 "#I64" (+1 (+0 "#Nat" (+0)) (+0))) - (+0 "#I64" (+1 (+0 "#Nat" (+0)) (+0))))) - ["" +0 +0]) - [["" +0 +0] - (+10 (+1 [[["" +0 +0] (+7 ["lux" "export?"])] - [["" +0 +0] (+0 #1)]] - (+0)))]) + ("lux check" (|2 (|0 "#Text" (|0)) + (|2 (|0 "#I64" (|1 (|0 "#Nat" (|0)) (|0))) + (|0 "#I64" (|1 (|0 "#Nat" (|0)) (|0))))) + ["" |0 |0]) + [["" |0 |0] + (|10 (|1 [[["" |0 |0] (|7 ["lux" "export?"])] + [["" |0 |0] (|0 #1)]] + (|0)))]) ## (type: Any ## (Ex [a] a)) ("lux def" Any - (+10 ["lux" "Any"] - (+8 (+0) (+4 +1))) + (|10 ["lux" "Any"] + (|8 (|0) (|4 |1))) [dummy-cursor - (+10 (+1 [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (+1 [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] - (+1 [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "The type of things whose type does not matter. + (|10 (|1 [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (|1 [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] + (|1 [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "The type of things whose type does not matter. It can be used to write functions or data-structures that can take, or return, anything.")]] - (+0)))))]) + (|0)))))]) ## (type: Nothing ## (All [a] a)) ("lux def" Nothing - (+10 ["lux" "Nothing"] - (+7 (+0) (+4 +1))) + (|10 ["lux" "Nothing"] + (|7 (|0) (|4 |1))) [dummy-cursor - (+10 (+1 [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (+1 [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] - (+1 [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "The type of things whose type is unknown or undefined. + (|10 (|1 [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (|1 [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] + (|1 [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "The type of things whose type is unknown or undefined. Useful for expressions that cause errors or other \"extraordinary\" conditions.")]] - (+0)))))]) + (|0)))))]) ## (type: (List a) ## #Nil ## (#Cons a (List a))) ("lux def" List - (+10 ["lux" "List"] - (+7 (+0) - (+1 ## "lux.Nil" + (|10 ["lux" "List"] + (|7 (|0) + (|1 ## "lux.Nil" Any ## "lux.Cons" - (+2 (+4 +1) - (+9 (+4 +1) (+4 +0)))))) + (|2 (|4 |1) + (|9 (|4 |1) (|4 |0)))))) [dummy-cursor - (+10 (+1 [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (+1 [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] - (+1 [[dummy-cursor (+7 ["lux" "tags"])] - [dummy-cursor (+9 (+1 [dummy-cursor (+5 "Nil")] (+1 [dummy-cursor (+5 "Cons")] (+0))))]] - (+1 [[dummy-cursor (+7 ["lux" "type-args"])] - [dummy-cursor (+9 (+1 [dummy-cursor (+5 "a")] (+0)))]] - (+1 [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "A potentially empty list of values.")]] - (+0)))))))]) + (|10 (|1 [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (|1 [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] + (|1 [[dummy-cursor (|7 ["lux" "tags"])] + [dummy-cursor (|9 (|1 [dummy-cursor (|5 "Nil")] (|1 [dummy-cursor (|5 "Cons")] (|0))))]] + (|1 [[dummy-cursor (|7 ["lux" "type-args"])] + [dummy-cursor (|9 (|1 [dummy-cursor (|5 "a")] (|0)))]] + (|1 [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "A potentially empty list of values.")]] + (|0)))))))]) ("lux def" Bit - (+10 ["lux" "Bit"] - (+0 "#Bit" #Nil)) + (|10 ["lux" "Bit"] + (|0 "#Bit" #Nil)) [dummy-cursor - (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "Your standard, run-of-the-mill boolean values (as bits).")]] + (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "Your standard, run-of-the-mill boolean values (as bits).")]] #Nil))))]) ("lux def" I64 - (+10 ["lux" "I64"] - (+7 (+0) - (+0 "#I64" (#Cons (+4 +1) #Nil)))) + (|10 ["lux" "I64"] + (|7 (|0) + (|0 "#I64" (#Cons (|4 |1) #Nil)))) [dummy-cursor - (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "64-bit integers without any semantics.")]] + (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "64-bit integers without any semantics.")]] #Nil))))]) ("lux def" Nat - (+10 ["lux" "Nat"] - (+0 "#I64" (#Cons (+0 "#Nat" #Nil) #Nil))) + (|10 ["lux" "Nat"] + (|0 "#I64" (#Cons (|0 "#Nat" #Nil) #Nil))) [dummy-cursor - (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "Natural numbers (unsigned integers). - - They start at zero (+0) and extend in the positive direction.")]] + (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "Natural numbers (unsigned integers). + + They start at zero (|0) and extend in the positive direction.")]] #Nil))))]) ("lux def" Int - (+10 ["lux" "Int"] - (+0 "#I64" (#Cons (+0 "#Int" #Nil) #Nil))) + (|10 ["lux" "Int"] + (|0 "#I64" (#Cons (|0 "#Int" #Nil) #Nil))) [dummy-cursor - (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "Your standard, run-of-the-mill integer numbers.")]] + (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "Your standard, run-of-the-mill integer numbers.")]] #Nil))))]) ("lux def" Rev - (+10 ["lux" "Rev"] - (+0 "#I64" (#Cons (+0 "#Rev" #Nil) #Nil))) + (|10 ["lux" "Rev"] + (|0 "#I64" (#Cons (|0 "#Rev" #Nil) #Nil))) [dummy-cursor - (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "Fractional numbers that live in the interval [0,1). + (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "Fractional numbers that live in the interval [0,1). Useful for probability, and other domains that work within that interval.")]] #Nil))))]) ("lux def" Frac - (+10 ["lux" "Frac"] - (+0 "#Frac" #Nil)) + (|10 ["lux" "Frac"] + (|0 "#Frac" #Nil)) [dummy-cursor - (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "Your standard, run-of-the-mill floating-point (fractional) numbers.")]] + (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "Your standard, run-of-the-mill floating-point (fractional) numbers.")]] #Nil))))]) ("lux def" Text - (+10 ["lux" "Text"] - (+0 "#Text" #Nil)) + (|10 ["lux" "Text"] + (|0 "#Text" #Nil)) [dummy-cursor - (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "Your standard, run-of-the-mill string values.")]] + (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "Your standard, run-of-the-mill string values.")]] #Nil))))]) ("lux def" Name - (+10 ["lux" "Name"] - (+2 Text Text)) + (|10 ["lux" "Name"] + (|2 Text Text)) [dummy-cursor - (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "A name. + (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "A name. It is used as part of Lux syntax to represent identifiers and tags.")]] #Nil))))]) @@ -171,23 +171,23 @@ ## #None ## (#Some a)) ("lux def" Maybe - (+10 ["lux" "Maybe"] - (+7 #Nil - (+1 ## "lux.None" + (|10 ["lux" "Maybe"] + (|7 #Nil + (|1 ## "lux.None" Any ## "lux.Some" - (+4 +1)))) + (|4 |1)))) [dummy-cursor - (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "tags"])] - [dummy-cursor (+9 (#Cons [dummy-cursor (+5 "None")] (#Cons [dummy-cursor (+5 "Some")] #Nil)))]] - (#Cons [[dummy-cursor (+7 ["lux" "type-args"])] - [dummy-cursor (+9 (#Cons [dummy-cursor (+5 "a")] #Nil))]] - (#Cons [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "A potentially missing value.")]] + (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "tags"])] + [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "None")] (#Cons [dummy-cursor (|5 "Some")] #Nil)))]] + (#Cons [[dummy-cursor (|7 ["lux" "type-args"])] + [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "a")] #Nil))]] + (#Cons [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "A potentially missing value.")]] #Nil))))))]) ## (type: #rec Type @@ -204,59 +204,59 @@ ## (#Named Name Type) ## ) ("lux def" Type - (+10 ["lux" "Type"] + (|10 ["lux" "Type"] ({Type ({Type-List ({Type-Pair - (+9 Nothing - (+7 #Nil - (+1 ## "lux.Primitive" - (+2 Text Type-List) - (+1 ## "lux.Sum" + (|9 Nothing + (|7 #Nil + (|1 ## "lux.Primitive" + (|2 Text Type-List) + (|1 ## "lux.Sum" Type-Pair - (+1 ## "lux.Product" + (|1 ## "lux.Product" Type-Pair - (+1 ## "lux.Function" + (|1 ## "lux.Function" Type-Pair - (+1 ## "lux.Parameter" + (|1 ## "lux.Parameter" Nat - (+1 ## "lux.Var" + (|1 ## "lux.Var" Nat - (+1 ## "lux.Ex" + (|1 ## "lux.Ex" Nat - (+1 ## "lux.UnivQ" - (+2 Type-List Type) - (+1 ## "lux.ExQ" - (+2 Type-List Type) - (+1 ## "lux.Apply" + (|1 ## "lux.UnivQ" + (|2 Type-List Type) + (|1 ## "lux.ExQ" + (|2 Type-List Type) + (|1 ## "lux.Apply" Type-Pair ## "lux.Named" - (+2 Name Type)))))))))))))} - ("lux check type" (+2 Type Type)))} - ("lux check type" (+9 Type List)))} - ("lux check type" (+9 (+4 +1) (+4 +0))))) + (|2 Name Type)))))))))))))} + ("lux check type" (|2 Type Type)))} + ("lux check type" (|9 Type List)))} + ("lux check type" (|9 (|4 |1) (|4 |0))))) [dummy-cursor - (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "tags"])] - [dummy-cursor (+9 (#Cons [dummy-cursor (+5 "Primitive")] - (#Cons [dummy-cursor (+5 "Sum")] - (#Cons [dummy-cursor (+5 "Product")] - (#Cons [dummy-cursor (+5 "Function")] - (#Cons [dummy-cursor (+5 "Parameter")] - (#Cons [dummy-cursor (+5 "Var")] - (#Cons [dummy-cursor (+5 "Ex")] - (#Cons [dummy-cursor (+5 "UnivQ")] - (#Cons [dummy-cursor (+5 "ExQ")] - (#Cons [dummy-cursor (+5 "Apply")] - (#Cons [dummy-cursor (+5 "Named")] + (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "tags"])] + [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "Primitive")] + (#Cons [dummy-cursor (|5 "Sum")] + (#Cons [dummy-cursor (|5 "Product")] + (#Cons [dummy-cursor (|5 "Function")] + (#Cons [dummy-cursor (|5 "Parameter")] + (#Cons [dummy-cursor (|5 "Var")] + (#Cons [dummy-cursor (|5 "Ex")] + (#Cons [dummy-cursor (|5 "UnivQ")] + (#Cons [dummy-cursor (|5 "ExQ")] + (#Cons [dummy-cursor (|5 "Apply")] + (#Cons [dummy-cursor (|5 "Named")] #Nil))))))))))))]] - (#Cons [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "This type represents the data-structures that are used to specify types themselves.")]] - (#Cons [[dummy-cursor (+7 ["lux" "type-rec?"])] - [dummy-cursor (+0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "This type represents the data-structures that are used to specify types themselves.")]] + (#Cons [[dummy-cursor (|7 ["lux" "type-rec?"])] + [dummy-cursor (|0 #1)]] #Nil))))))]) ## (type: Cursor @@ -267,17 +267,17 @@ (#Named ["lux" "Cursor"] (#Product Text (#Product Nat Nat))) [dummy-cursor - (+10 (#Cons [[dummy-cursor (+7 ["lux" "tags"])] - [dummy-cursor (+9 (#Cons [dummy-cursor (+5 "module")] - (#Cons [dummy-cursor (+5 "line")] - (#Cons [dummy-cursor (+5 "column")] + (|10 (#Cons [[dummy-cursor (|7 ["lux" "tags"])] + [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "module")] + (#Cons [dummy-cursor (|5 "line")] + (#Cons [dummy-cursor (|5 "column")] #Nil))))]] - (#Cons [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "Cursors are for specifying the location of Code nodes in Lux files during compilation.")]] - (#Cons [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "Cursors are for specifying the location of Code nodes in Lux files during compilation.")]] + (#Cons [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] #Nil)))))]) ## (type: (Ann m v) @@ -287,21 +287,21 @@ (#Named ["lux" "Ann"] (#UnivQ #Nil (#UnivQ #Nil - (#Product (#Parameter +3) - (#Parameter +1))))) + (#Product (#Parameter |3) + (#Parameter |1))))) [dummy-cursor - (+10 (#Cons [[dummy-cursor (+7 ["lux" "tags"])] - [dummy-cursor (+9 (#Cons [dummy-cursor (+5 "meta")] - (#Cons [dummy-cursor (+5 "datum")] + (|10 (#Cons [[dummy-cursor (|7 ["lux" "tags"])] + [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "meta")] + (#Cons [dummy-cursor (|5 "datum")] #Nil)))]] - (#Cons [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "The type of things that can be annotated with meta-data of arbitrary types.")]] - (#Cons [[dummy-cursor (+7 ["lux" "type-args"])] - [dummy-cursor (+9 (#Cons [dummy-cursor (+5 "m")] (#Cons [dummy-cursor (+5 "v")] #Nil)))]] - (#Cons [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "doc"])] + [dummy-cursor (|5 "The type of things that can be annotated with meta-data of arbitrary types.")]] + (#Cons [[dummy-cursor (|7 ["lux" "type-args"])] + [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "m")] (#Cons [dummy-cursor (|5 "v")] #Nil)))]] + (#Cons [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] #Nil))))))]) ## (type: (Code' w) @@ -346,29 +346,29 @@ )))))))))) )} ("lux check type" (#Apply Code List)))} - ("lux check type" (#Apply (#Apply (#Parameter +1) - (#Parameter +0)) - (#Parameter +1))))) + ("lux check type" (#Apply (#Apply (#Parameter |1) + (#Parameter |0)) + (#Parameter |1))))) [dummy-cursor - (+10 (#Cons [[dummy-cursor (+7 ["lux" "tags"])] - [dummy-cursor (+9 (#Cons [dummy-cursor (+5 "Bit")] - (#Cons [dummy-cursor (+5 "Nat")] - (#Cons [dummy-cursor (+5 "Int")] - (#Cons [dummy-cursor (+5 "Rev")] - (#Cons [dummy-cursor (+5 "Frac")] - (#Cons [dummy-cursor (+5 "Text")] - (#Cons [dummy-cursor (+5 "Identifier")] - (#Cons [dummy-cursor (+5 "Tag")] - (#Cons [dummy-cursor (+5 "Form")] - (#Cons [dummy-cursor (+5 "Tuple")] - (#Cons [dummy-cursor (+5 "Record")] + (|10 (#Cons [[dummy-cursor (|7 ["lux" "tags"])] + [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "Bit")] + (#Cons [dummy-cursor (|5 "Nat")] + (#Cons [dummy-cursor (|5 "Int")] + (#Cons [dummy-cursor (|5 "Rev")] + (#Cons [dummy-cursor (|5 "Frac")] + (#Cons [dummy-cursor (|5 "Text")] + (#Cons [dummy-cursor (|5 "Identifier")] + (#Cons [dummy-cursor (|5 "Tag")] + (#Cons [dummy-cursor (|5 "Form")] + (#Cons [dummy-cursor (|5 "Tuple")] + (#Cons [dummy-cursor (|5 "Record")] #Nil))))))))))))]] - (#Cons [[dummy-cursor (+7 ["lux" "type-args"])] - [dummy-cursor (+9 (#Cons [dummy-cursor (+5 "w")] #Nil))]] - (#Cons [[dummy-cursor (+7 ["lux" "type?"])] - [dummy-cursor (+0 #1)]] - (#Cons [[dummy-cursor (+7 ["lux" "export?"])] - [dummy-cursor (+0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "type-args"])] + [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "w")] #Nil))]] + (#Cons [[dummy-cursor (|7 ["lux" "type?"])] + [dummy-cursor (|0 #1)]] + (#Cons [[dummy-cursor (|7 ["lux" "export?"])] + [dummy-cursor (|0 #1)]] #Nil)))))]) ## (type: Code @@ -490,8 +490,8 @@ (#Product ## "lux.counter" Nat ## "lux.mappings" - (#Apply (#Product (#Parameter +3) - (#Parameter +1)) + (#Apply (#Product (#Parameter |3) + (#Parameter |1)) List))))) (record$ (#Cons [(tag$ ["lux" "tags"]) (tuple$ (#Cons (text$ "counter") (#Cons (text$ "mappings") #Nil)))] @@ -543,9 +543,9 @@ (#UnivQ #Nil (#UnivQ #Nil (#Sum ## "lux.Left" - (#Parameter +3) + (#Parameter |3) ## "lux.Right" - (#Parameter +1))))) + (#Parameter |1))))) (record$ (#Cons [(tag$ ["lux" "tags"]) (tuple$ (#Cons (text$ "Left") (#Cons (text$ "Right") #Nil)))] (#Cons [(tag$ ["lux" "type-args"]) @@ -760,7 +760,7 @@ (#Named ["lux" "Meta"] (#UnivQ #Nil (#Function Lux - (#Apply (#Product Lux (#Parameter +1)) + (#Apply (#Product Lux (#Parameter |1)) (#Apply Text Either))))) (record$ (#Cons [(tag$ ["lux" "doc"]) (text$ "Computations that can have access to the state of the compiler. @@ -782,10 +782,10 @@ ## Base functions & macros ("lux def" return ("lux check" (#UnivQ #Nil - (#Function (#Parameter +1) + (#Function (#Parameter |1) (#Function Lux (#Apply (#Product Lux - (#Parameter +1)) + (#Parameter |1)) (#Apply Text Either))))) ([_ val] ([_ state] @@ -797,7 +797,7 @@ (#Function Text (#Function Lux (#Apply (#Product Lux - (#Parameter +1)) + (#Parameter |1)) (#Apply Text Either))))) ([_ msg] ([_ state] @@ -861,7 +861,7 @@ ("lux def" cursor-code ("lux check" Code - (tuple$ (#Cons (text$ "") (#Cons (nat$ +0) (#Cons (nat$ +0) #Nil))))) + (tuple$ (#Cons (text$ "") (#Cons (nat$ |0) (#Cons (nat$ |0) #Nil))))) (record$ #Nil)) ("lux def" meta-code @@ -1052,9 +1052,9 @@ #Nil (#UnivQ #Nil (#UnivQ #Nil - (#Function (#Function (#Parameter +3) (#Parameter +1)) - (#Function ($' List (#Parameter +3)) - ($' List (#Parameter +1)))))) + (#Function (#Function (#Parameter |3) (#Parameter |1)) + (#Function ($' List (#Parameter |3)) + ($' List (#Parameter |1)))))) ({#Nil #Nil @@ -1164,7 +1164,7 @@ pairs)) [_ (#Form (#Cons [_ (#Tag "lux" "Parameter")] (#Cons [_ (#Nat idx)] #Nil)))] - (form$ (#Cons (tag$ ["lux" "Parameter"]) (#Cons (nat$ (n/+ +2 idx)) #Nil))) + (form$ (#Cons (tag$ ["lux" "Parameter"]) (#Cons (nat$ (n/+ |2 idx)) #Nil))) [_ (#Form members)] (form$ (list/map update-parameters members)) @@ -1198,12 +1198,12 @@ (def:'' (list/fold f init xs) #Nil ## (All [a b] (-> (-> b a a) a (List b) a)) - (#UnivQ #Nil (#UnivQ #Nil (#Function (#Function (#Parameter +1) - (#Function (#Parameter +3) - (#Parameter +3))) - (#Function (#Parameter +3) - (#Function ($' List (#Parameter +1)) - (#Parameter +3)))))) + (#UnivQ #Nil (#UnivQ #Nil (#Function (#Function (#Parameter |1) + (#Function (#Parameter |3) + (#Parameter |3))) + (#Function (#Parameter |3) + (#Function ($' List (#Parameter |1)) + (#Parameter |3)))))) ({#Nil init @@ -1214,8 +1214,8 @@ (def:'' (list/size list) #Nil (#UnivQ #Nil - (#Function ($' List (#Parameter +1)) Nat)) - (list/fold (function'' [_ acc] (n/+ +1 acc)) +0 list)) + (#Function ($' List (#Parameter |1)) Nat)) + (list/fold (function'' [_ acc] (n/+ |1 acc)) |0 list)) (macro:' #export (All tokens) (#Cons [(tag$ ["lux" "doc"]) @@ -1241,7 +1241,7 @@ (function'' [name' body'] (form$ (#Cons (tag$ ["lux" "UnivQ"]) (#Cons (tag$ ["lux" "Nil"]) - (#Cons (replace-syntax (#Cons [name' (make-parameter +1)] #Nil) + (#Cons (replace-syntax (#Cons [name' (make-parameter |1)] #Nil) (update-parameters body')) #Nil)))))) body names) @@ -1252,7 +1252,7 @@ body' [#0 _] - (replace-syntax (#Cons [self-name (make-parameter (n/* +2 (n/- +1 (list/size names))))] + (replace-syntax (#Cons [self-name (make-parameter (n/* |2 (n/- |1 (list/size names))))] #Nil) body')} [(text/= "" self-name) names]) @@ -1288,7 +1288,7 @@ (function'' [name' body'] (form$ (#Cons (tag$ ["lux" "ExQ"]) (#Cons (tag$ ["lux" "Nil"]) - (#Cons (replace-syntax (#Cons [name' (make-parameter +1)] #Nil) + (#Cons (replace-syntax (#Cons [name' (make-parameter |1)] #Nil) (update-parameters body')) #Nil)))))) body names) @@ -1299,7 +1299,7 @@ body' [#0 _] - (replace-syntax (#Cons [self-name (make-parameter (n/* +2 (n/- +1 (list/size names))))] + (replace-syntax (#Cons [self-name (make-parameter (n/* |2 (n/- |1 (list/size names))))] #Nil) body')} [(text/= "" self-name) names]) @@ -1518,7 +1518,7 @@ (def:''' (wrap-meta content) #Nil (-> Code Code) - (tuple$ (list (tuple$ (list (text$ "") (nat$ +0) (nat$ +0))) + (tuple$ (list (tuple$ (list (text$ "") (nat$ |0) (nat$ |0))) content))) (def:''' (untemplate-list tokens) @@ -2199,14 +2199,14 @@ (def:''' (high-bits value) (list) (-> ($' I64 Any) I64) - ("lux i64 logical-right-shift" +32 value)) + ("lux i64 logical-right-shift" |32 value)) (def:''' low-mask (list) I64 - (|> +1 - ("lux i64 left-shift" +32) - ("lux i64 -" +1))) + (|> |1 + ("lux i64 left-shift" |32) + ("lux i64 -" |1))) (def:''' (low-bits value) (list) @@ -2366,12 +2366,12 @@ (-> Nat Nat Nat) (if ("lux int <" ("lux coerce" Int param) 0) (if (n/< param subject) - +0 - +1) + |0 + |1) (let' [quotient ("lux i64 left-shift" - +1 + |1 ("lux int /" - ("lux i64 logical-right-shift" +1 subject) + ("lux i64 logical-right-shift" |1 subject) ("lux coerce" Int param))) flat ("lux int *" ("lux coerce" Int quotient) @@ -2379,7 +2379,7 @@ remainder ("lux i64 -" flat subject)] (if (n/< param remainder) quotient - ("lux i64 +" +1 quotient))))) + ("lux i64 +" |1 quotient))))) (def:''' #export (n//% param subject) (list [(tag$ ["lux" "doc"]) @@ -2442,7 +2442,7 @@ paramL (low-bits param) bottom (|> subjectL ("lux int *" paramL) - ("lux i64 logical-right-shift" +32)) + ("lux i64 logical-right-shift" |32)) middle ("lux i64 +" ("lux int *" subjectH paramL) ("lux int *" subjectL paramH)) @@ -2452,17 +2452,17 @@ high-bits ("lux i64 +" top)))) -(def:''' least-significant-bit-mask (list) Nat +1) +(def:''' least-significant-bit-mask (list) Nat |1) (def:''' (without-trailing-zeroes count remaining) (list) (-> Nat Nat (#Product Nat Nat)) (if (|> remaining ("lux i64 and" least-significant-bit-mask) - ("lux i64 =" +0)) + ("lux i64 =" |0)) (without-trailing-zeroes - ("lux i64 +" +1 count) - ("lux i64 logical-right-shift" +1 remaining)) + ("lux i64 +" |1 count) + ("lux i64 logical-right-shift" |1 remaining)) [count remaining])) (def:''' #export (r// param subject) @@ -2471,13 +2471,13 @@ (-> Rev Rev Rev) (if ("lux i64 =" 0 param) ("lux io error" "Cannot divide Rev by zero!") - (let' [[trailing-zeroes remaining] (without-trailing-zeroes +0 ("lux coerce" Nat param)) + (let' [[trailing-zeroes remaining] (without-trailing-zeroes |0 ("lux coerce" Nat param)) [trailing-zeroes denominator] ("lux check" (#Product Nat Nat) (if ("lux i64 =" 0 trailing-zeroes) - [+1 ("lux i64 logical-right-shift" +1 remaining)] + [|1 ("lux i64 logical-right-shift" |1 remaining)] [trailing-zeroes remaining])) - shift ("lux i64 -" trailing-zeroes +64) - numerator ("lux i64 left-shift" shift +1)] + shift ("lux i64 -" trailing-zeroes |64) + numerator ("lux i64 left-shift" shift |1)] ("lux coerce" Rev ("lux int *" ("lux coerce" Int subject) @@ -2507,10 +2507,10 @@ (text$ "Rev(olution) reciprocal of a Nat(ural).")]) (-> Nat Rev) ("lux coerce" Rev - (let' [[trailing-zeroes remaining] (without-trailing-zeroes +0 numerator)] + (let' [[trailing-zeroes remaining] (without-trailing-zeroes |0 numerator)] (n// remaining - ({+0 ("lux coerce" Nat -1) - _ ("lux i64 left-shift" (n/- trailing-zeroes +64) +1)} + ({|0 ("lux coerce" Nat -1) + _ ("lux i64 left-shift" (n/- trailing-zeroes |64) |1)} trailing-zeroes))))) (do-template [ ] @@ -2543,26 +2543,26 @@ (def:''' (digit-to-text digit) #Nil (-> Nat Text) - ({+0 "0" - +1 "1" +2 "2" +3 "3" - +4 "4" +5 "5" +6 "6" - +7 "7" +8 "8" +9 "9" + ({|0 "0" + |1 "1" |2 "2" |3 "3" + |4 "4" |5 "5" |6 "6" + |7 "7" |8 "8" |9 "9" _ ("lux io error" "undefined")} digit)) (def:''' (nat/encode value) #Nil (-> Nat Text) - ({+0 - "+0" + ({|0 + "|0" _ (let' [loop ("lux check" (-> Nat Text Text) (function' recur [input output] - (if (n/= +0 input) + (if (n/= |0 input) (text/compose "+" output) - (recur (n// +10 input) - (text/compose (|> input (n/% +10) digit-to-text) + (recur (n// |10 input) + (text/compose (|> input (n/% |10) digit-to-text) output)))))] (loop value ""))} value)) @@ -2600,7 +2600,7 @@ (def:''' (multiple? div n) #Nil (-> Nat Nat Bit) - (|> n (n/% div) (n/= +0))) + (|> n (n/% div) (n/= |0))) (def:''' #export (not x) (list [(tag$ ["lux" "doc"]) @@ -2935,7 +2935,7 @@ #scope-type-vars scope-type-vars} (#Right {#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host - #seed (n/+ +1 seed) #expected expected + #seed (n/+ |1 seed) #expected expected #cursor cursor #extensions extensions #scope-type-vars scope-type-vars} (identifier$ ["" ($_ text/compose "__gensym__" prefix (nat/encode seed))]))} @@ -2948,7 +2948,7 @@ (Rec Self [Int (List Self)])")]) ({(#Cons [_ (#Identifier "" name)] (#Cons body #Nil)) - (let' [body' (replace-syntax (list [name (` (#.Apply (~ (make-parameter +1)) (~ (make-parameter +0))))]) + (let' [body' (replace-syntax (list [name (` (#.Apply (~ (make-parameter |1)) (~ (make-parameter |0))))]) (update-parameters body))] (return (list (` (#.Apply .Nothing (#.UnivQ #.Nil (~ body'))))))) @@ -3209,7 +3209,7 @@ (op x y))")]) (case tokens (^ (list [_ (#Tuple bindings)] body)) - (if (multiple? +2 (list/size bindings)) + (if (multiple? |2 (list/size bindings)) (|> bindings as-pairs list/reverse (list/fold (: (-> [Code Code] Code Code) (function' [lr body'] @@ -3573,7 +3573,7 @@ (def: (index-of part text) (-> Text Text (Maybe Nat)) - ("lux text index" text part +0)) + ("lux text index" text part |0)) (def: (last-index-of' part part-size since text) (-> Text Nat Nat Text (Maybe Nat)) @@ -3586,7 +3586,7 @@ (def: (last-index-of part text) (-> Text Text (Maybe Nat)) - (case ("lux text index" text part +0) + (case ("lux text index" text part |0) (#Some since) (last-index-of' part ("lux text size" part) since text) @@ -3635,10 +3635,10 @@ (#Some idx) (list& (default (error! "UNDEFINED") - (clip2 +0 idx input)) + (clip2 |0 idx input)) (text/split splitter (default (error! "UNDEFINED") - (clip1 (n/+ +1 idx) input)))))) + (clip1 (n/+ |1 idx) input)))))) (def: (nth idx xs) (All [a] @@ -3648,9 +3648,9 @@ #None (#Cons x xs') - (if (n/= +0 idx) + (if (n/= |0 idx) (#Some x) - (nth (n/- +1 idx) xs') + (nth (n/- |1 idx) xs') ))) (def: (beta-reduce env type) @@ -4132,7 +4132,7 @@ (def: (split at x) (-> Nat Text (Maybe [Text Text])) - (case [(..clip2 +0 at x) (..clip1 at x)] + (case [(..clip2 |0 at x) (..clip1 at x)] [(#.Some pre) (#.Some post)] (#.Some [pre post]) @@ -4170,38 +4170,38 @@ (#Some found) (if (n/= ups found) - (count-ups (n/+ +1 ups) input) + (count-ups (n/+ |1 ups) input) ups))) (def: (list/drop amount a+) (All [a] (-> Nat (List a) (List a))) (case [amount a+] - (^or [+0 _] [_ #Nil]) + (^or [|0 _] [_ #Nil]) a+ [_ (#Cons _ a+')] - (list/drop (n/- +1 amount) a+'))) + (list/drop (n/- |1 amount) a+'))) (def: (clean-module nested? relative-root module) (-> Bit Text Text (Meta Text)) - (case (count-ups +0 module) - +0 + (case (count-ups |0 module) + |0 (return (if nested? ($_ "lux text concat" relative-root "/" module) module)) ups (let [parts (text/split "/" relative-root)] - (if (n/< (list/size parts) (n/- +1 ups)) + (if (n/< (list/size parts) (n/- |1 ups)) (let [prefix (|> parts list/reverse - (list/drop (n/- +1 ups)) + (list/drop (n/- |1 ups)) list/reverse (interpose "/") text/join) clean (|> module (clip1 ups) (default (error! "UNDEFINED"))) output (case ("lux text size" clean) - +0 prefix + |0 prefix _ ($_ text/compose prefix "/" clean))] (return output)) (fail ($_ text/compose @@ -4545,7 +4545,7 @@ (n/odd? num) \"odd\" ## else-branch \"???\")"} - (if (n/= +0 (n/% +2 (list/size tokens))) + (if (n/= |0 (n/% |2 (list/size tokens))) (fail "cond requires an uneven number of arguments.") (case (list/reverse tokens) (^ (list& else branches')) @@ -4563,14 +4563,14 @@ (All [a] (-> Nat (List a) (List [Nat a]))) (case xs (#Cons x xs') - (#Cons [idx x] (enumerate' (n/+ +1 idx) xs')) + (#Cons [idx x] (enumerate' (n/+ |1 idx) xs')) #Nil #Nil)) (def: (enumerate xs) (All [a] (-> (List a) (List [Nat a]))) - (enumerate' +0 xs)) + (enumerate' |0 xs)) (macro: #export (get@ tokens) {#.doc "## Accesses the value of a record at a given tag. @@ -5176,7 +5176,7 @@ [(def: #export {#.doc } (All [s] (-> (I64 s) (I64 s))) - (|>> ( +1)))] + (|>> ( |1)))] [inc "lux i64 +" "Increment function."] [dec "lux i64 -" "Decrement function."] @@ -5715,7 +5715,7 @@ (-> Bit) (not ( n)))] - [Nat n/even? n/odd? n/% n/= +0 +2] + [Nat n/even? n/odd? n/% n/= |0 |2] [Int i/even? i/odd? i/% i/= 0 2]) (def: (get-scope-type-vars state) @@ -5735,17 +5735,17 @@ #None (#Cons x xs') - (if (n/= +0 idx) + (if (n/= |0 idx) (#Some x) (list-at (dec idx) xs')))) (macro: #export ($ tokens) {#.doc (doc "Allows you to refer to the type-variables in a polymorphic function's type, by their index." - "In the example below, +0 corresponds to the 'a' variable." + "In the example below, |0 corresponds to the 'a' variable." (def: #export (from-list list) (All [a] (-> (List a) (Row a))) (list/fold add - (: (Row ($ +0)) + (: (Row ($ |0)) empty) list)))} (case tokens @@ -5777,7 +5777,7 @@ {#.doc (doc "Allows you to simultaneously bind and de-structure a value." (def: (hash (^@ set [Hash _])) (list/fold (function (_ elem acc) (n/+ (:: Hash hash elem) acc)) - +0 + |0 (to-list set))))} (case tokens (^ (list& [_meta (#Form (list [_ (#Identifier ["" name])] pattern))] body branches)) @@ -5792,7 +5792,7 @@ (macro: #export (^|> tokens) {#.doc (doc "Pipes the value being pattern-matched against prior to binding it to a variable." (case input - (^|> value [inc (n/% +10) (n/max +1)]) + (^|> value [inc (n/% |10) (n/max |1)]) (foo value)))} (case tokens (^ (list& [_meta (#Form (list [_ (#Identifier ["" name])] [_ (#Tuple steps)]))] body branches)) @@ -5947,8 +5947,8 @@ (macro: #export (char tokens compiler) (case tokens (^multi (^ (list [_ (#Text input)])) - (n/= +1 ("lux text size" input))) - (|> ("lux text char" input +0) + (n/= |1 ("lux text size" input))) + (|> ("lux text char" input |0) (default (undefined)) nat$ list [compiler] #Right) @@ -6170,7 +6170,7 @@ (def: to-significand (-> (I64 Any) Frac) - (|>> ("lux i64 logical-right-shift" +11) + (|>> ("lux i64 logical-right-shift" |11) int-to-frac)) (def: rev-denominator Frac (to-significand -1)) @@ -6184,7 +6184,7 @@ (f/% 1.0) (f/* rev-denominator) frac-to-int - ("lux i64 left-shift" +11)))) + ("lux i64 left-shift" |11)))) (def: #export rev-to-frac (-> Rev Frac) diff --git a/stdlib/source/lux/compiler/default/cache.lux b/stdlib/source/lux/compiler/default/cache.lux index 1b5f595fd..1e264ec08 100644 --- a/stdlib/source/lux/compiler/default/cache.lux +++ b/stdlib/source/lux/compiler/default/cache.lux @@ -18,7 +18,7 @@ (Format Module) ($_ _.and ## #module-hash - (_.ignore +0) + (_.ignore |0) ## #module-aliases (_.list ..alias) ## #definitions diff --git a/stdlib/source/lux/compiler/default/init.lux b/stdlib/source/lux/compiler/default/init.lux index cac69ab89..4972e75c5 100644 --- a/stdlib/source/lux/compiler/default/init.lux +++ b/stdlib/source/lux/compiler/default/init.lux @@ -6,20 +6,20 @@ (def: #export (cursor file) (-> Text Cursor) - [file +1 +0]) + [file |1 |0]) (def: #export (source file code) (-> Text Text Source) - [(cursor file) +0 code]) + [(cursor file) |0 code]) (def: dummy-source Source - [.dummy-cursor +0 ""]) + [.dummy-cursor |0 ""]) (def: #export type-context Type-Context - {#.ex-counter +0 - #.var-counter +0 + {#.ex-counter |0 + #.var-counter |0 #.var-bindings (list)}) (`` (def: #export info @@ -46,7 +46,7 @@ #.scopes (list) #.type-context ..type-context #.expected #.None - #.seed +0 + #.seed |0 #.scope-type-vars (list) #.extensions [] #.host host}) diff --git a/stdlib/source/lux/compiler/default/name.lux b/stdlib/source/lux/compiler/default/name.lux index 50240a801..34bcf41eb 100644 --- a/stdlib/source/lux/compiler/default/name.lux +++ b/stdlib/source/lux/compiler/default/name.lux @@ -36,7 +36,7 @@ (def: #export (normalize name) (-> Text Text) (let [name/size (text.size name)] - (loop [idx +0 + (loop [idx |0 output ""] (if (n/< name/size idx) (recur (inc idx) diff --git a/stdlib/source/lux/compiler/default/phase/analysis.lux b/stdlib/source/lux/compiler/default/phase/analysis.lux index 182e3c321..ff540cded 100644 --- a/stdlib/source/lux/compiler/default/phase/analysis.lux +++ b/stdlib/source/lux/compiler/default/phase/analysis.lux @@ -107,7 +107,7 @@ (n/= (dec size) tag)) (template: #export (no-op value) - (|> +1 #reference.Local #reference.Variable #..Reference + (|> |1 #reference.Local #reference.Variable #..Reference (#..Function (list)) (#..Apply value))) @@ -117,11 +117,11 @@ (let [left (function.constant (|>> #.Left #Sum )) right (|>> #.Right #Sum )] (if (last? size tag) - (if (n/= +1 tag) + (if (n/= |1 tag) (right value) (list/fold left (right value) - (list.n/range +0 (n/- +2 tag)))) + (list.n/range |0 (n/- |2 tag)))) (list/fold left (case value ( (#Sum _)) @@ -129,7 +129,7 @@ _ value) - (list.n/range +0 tag)))))] + (list.n/range |0 tag)))))] [sum-analysis Analysis #Structure no-op] [sum-pattern Pattern #Complex id] @@ -174,7 +174,7 @@ (do-template [ ] [(def: #export ( value) (-> (Maybe (Variant ))) - (loop [lefts +0 + (loop [lefts |0 variantA value] (case variantA ( (#Sum (#.Left valueA))) @@ -238,13 +238,13 @@ (def: fresh-bindings (All [k v] (Bindings k v)) - {#.counter +0 + {#.counter |0 #.mappings (list)}) (def: fresh-scope Scope {#.name (list) - #.inner +0 + #.inner |0 #.locals fresh-bindings #.captured fresh-bindings}) diff --git a/stdlib/source/lux/compiler/default/phase/analysis/case/coverage.lux b/stdlib/source/lux/compiler/default/phase/analysis/case/coverage.lux index 24ded5476..716c11bf1 100644 --- a/stdlib/source/lux/compiler/default/phase/analysis/case/coverage.lux +++ b/stdlib/source/lux/compiler/default/phase/analysis/case/coverage.lux @@ -19,11 +19,11 @@ (def: cases (-> (Maybe Nat) Nat) - (|>> (maybe.default +0))) + (|>> (maybe.default |0))) (def: (variant sum-side) (-> (Either Pattern Pattern) (Variant Pattern)) - (loop [lefts +0 + (loop [lefts |0 variantP sum-side] (case variantP (#.Left valueP) diff --git a/stdlib/source/lux/compiler/default/phase/analysis/inference.lux b/stdlib/source/lux/compiler/default/phase/analysis/inference.lux index 91e28a4ca..1676c0cf7 100644 --- a/stdlib/source/lux/compiler/default/phase/analysis/inference.lux +++ b/stdlib/source/lux/compiler/default/phase/analysis/inference.lux @@ -70,7 +70,7 @@ (^template [] ( env quantified) ( (list/map (replace parameter-idx replacement) env) - (replace (n/+ +2 parameter-idx) replacement quantified))) + (replace (n/+ |2 parameter-idx) replacement quantified))) ([#.UnivQ] [#.ExQ]) @@ -199,7 +199,7 @@ ## Turns a variant type into the kind of function type suitable for inference. (def: #export (variant tag expected-size inferT) (-> Nat Nat Type (Operation Type)) - (loop [depth +0 + (loop [depth |0 currentT inferT] (case currentT (#.Named name unnamedT) @@ -224,9 +224,9 @@ (n/< boundary tag))) (case (list.nth tag cases) (#.Some caseT) - (operation/wrap (if (n/= +0 depth) + (operation/wrap (if (n/= |0 depth) (type.function (list caseT) currentT) - (let [replace' (replace (|> depth dec (n/* +2)) inferT)] + (let [replace' (replace (|> depth dec (n/* |2)) inferT)] (type.function (list (replace' caseT)) (replace' currentT))))) @@ -238,9 +238,9 @@ (n/= boundary tag) (let [caseT (type.variant (list.drop boundary cases))] - (operation/wrap (if (n/= +0 depth) + (operation/wrap (if (n/= |0 depth) (type.function (list caseT) currentT) - (let [replace' (replace (|> depth dec (n/* +2)) inferT)] + (let [replace' (replace (|> depth dec (n/* |2)) inferT)] (type.function (list (replace' caseT)) (replace' currentT)))))) diff --git a/stdlib/source/lux/compiler/default/phase/analysis/scope.lux b/stdlib/source/lux/compiler/default/phase/analysis/scope.lux index a3f7e926c..6b6896674 100644 --- a/stdlib/source/lux/compiler/default/phase/analysis/scope.lux +++ b/stdlib/source/lux/compiler/default/phase/analysis/scope.lux @@ -43,7 +43,7 @@ (def: (captured name scope) (-> Text Scope (Maybe [Type Variable])) - (loop [idx +0 + (loop [idx |0 mappings (get@ [#.captured #.mappings] scope)] (case mappings #.Nil @@ -133,7 +133,7 @@ (do-template [ ] [(def: (Bindings Text [Type ]) - {#.counter +0 + {#.counter |0 #.mappings (list)})] [init-locals Nat] @@ -143,7 +143,7 @@ (def: (scope parent-name child-name) (-> (List Text) Text Scope) {#.name (list& child-name parent-name) - #.inner +0 + #.inner |0 #.locals init-locals #.captured init-captured}) diff --git a/stdlib/source/lux/compiler/default/phase/analysis/structure.lux b/stdlib/source/lux/compiler/default/phase/analysis/structure.lux index e4d6159fc..26a91dff6 100644 --- a/stdlib/source/lux/compiler/default/phase/analysis/structure.lux +++ b/stdlib/source/lux/compiler/default/phase/analysis/structure.lux @@ -312,7 +312,7 @@ _ (if (n/= size-ts size-record) (wrap []) (///.throw record-size-mismatch [size-ts size-record recordT record])) - #let [tuple-range (list.n/range +0 (dec size-ts)) + #let [tuple-range (list.n/range |0 (dec size-ts)) tag->idx (dict.from-list name.Hash (list.zip2 tag-set tuple-range))] idx->val (monad.fold @ (function (_ [key val] idx->val) diff --git a/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux b/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux index 2817fd55d..d5ff4a085 100644 --- a/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux +++ b/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux @@ -82,7 +82,7 @@ (wrap (#analysis.Extension extension-name (list opA)))) _ - (////.throw bundle.incorrect-arity [extension-name +1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) (def: lux::in-module Handler @@ -108,7 +108,7 @@ ## (analyse valueC))) ## _ -## (////.throw bundle.incorrect-arity [extension-name +2 (list.size args)]))))] +## (////.throw bundle.incorrect-arity [extension-name |2 (list.size args)]))))] ## [lux::check (:coerce Type actualT)] ## [lux::coerce Any] @@ -126,7 +126,7 @@ (wrap valueA)) _ - (////.throw bundle.incorrect-arity [extension-name +1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) (def: bundle::lux Bundle @@ -275,7 +275,7 @@ (wrap (#analysis.Extension extension-name (list initA)))) _ - (////.throw bundle.incorrect-arity [extension-name +1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) (def: atom::read Handler @@ -315,7 +315,7 @@ (wrap (#analysis.Extension extension-name (list initA)))) _ - (////.throw bundle.incorrect-arity [extension-name +1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) (def: box::read Handler diff --git a/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux b/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux index 7f63118ea..9e4cd2e7e 100644 --- a/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux +++ b/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux @@ -231,7 +231,7 @@ (wrap (#analysis.Extension extension-name (list arrayA)))) _ - (////.throw bundle.incorrect-arity [extension-name +1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) (def: array::new Handler @@ -244,7 +244,7 @@ expectedT (///.lift macro.expected-type) [level elem-class] (: (Operation [Nat Text]) (loop [analysisT expectedT - level +0] + level |0] (case analysisT (#.Apply inputT funcT) (case (type.apply (list inputT) funcT) @@ -262,7 +262,7 @@ _ (////.throw non-array expectedT)))) - _ (if (n/> +0 level) + _ (if (n/> |0 level) (wrap []) (////.throw non-array expectedT))] (wrap (#analysis.Extension extension-name (list (analysis.nat (dec level)) @@ -270,7 +270,7 @@ lengthA)))) _ - (////.throw bundle.incorrect-arity [extension-name +1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) (def: (check-jvm objectT) (-> Type (Operation Text)) @@ -344,7 +344,7 @@ (wrap (#analysis.Extension extension-name (list (analysis.text elem-class) idxA arrayA)))) _ - (////.throw bundle.incorrect-arity [extension-name +2 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |2 (list.size args)])))) (def: array::write Handler @@ -366,7 +366,7 @@ (wrap (#analysis.Extension extension-name (list (analysis.text elem-class) idxA valueA arrayA)))) _ - (////.throw bundle.incorrect-arity [extension-name +3 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |3 (list.size args)])))) (def: bundle::array Bundle @@ -389,7 +389,7 @@ (wrap (#analysis.Extension extension-name (list)))) _ - (////.throw bundle.incorrect-arity [extension-name +0 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |0 (list.size args)])))) (def: object::null? Handler @@ -404,7 +404,7 @@ (wrap (#analysis.Extension extension-name (list objectA)))) _ - (////.throw bundle.incorrect-arity [extension-name +1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) (def: object::synchronized Handler @@ -419,7 +419,7 @@ (wrap (#analysis.Extension extension-name (list monitorA exprA)))) _ - (////.throw bundle.incorrect-arity [extension-name +2 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |2 (list.size args)])))) (host.import: java/lang/Object (equals [Object] boolean)) @@ -516,7 +516,7 @@ (wrap (#analysis.Extension extension-name (list exceptionA)))) _ - (////.throw bundle.incorrect-arity [extension-name +1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) (def: object::class Handler @@ -534,7 +534,7 @@ (////.throw bundle.invalid-syntax extension-name)) _ - (////.throw bundle.incorrect-arity [extension-name +1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) (def: object::instance? Handler @@ -557,7 +557,7 @@ (////.throw bundle.invalid-syntax extension-name)) _ - (////.throw bundle.incorrect-arity [extension-name +2 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |2 (list.size args)])))) (def: (java-type-to-class jvm-type) (-> java/lang/reflect/Type (Operation Text)) @@ -588,8 +588,8 @@ (host.instance? WildcardType java-type) (let [java-type (:coerce WildcardType java-type)] - (case [(array.read +0 (WildcardType::getUpperBounds [] java-type)) - (array.read +0 (WildcardType::getLowerBounds [] java-type))] + (case [(array.read |0 (WildcardType::getUpperBounds [] java-type)) + (array.read |0 (WildcardType::getLowerBounds [] java-type))] (^or [(#.Some bound) _] [_ (#.Some bound)]) (java-type-to-lux-type mappings bound) @@ -600,13 +600,13 @@ (let [java-type (:coerce (Class Object) java-type) class-name (Class::getName [] java-type)] (operation/wrap (case (array.size (Class::getTypeParameters [] java-type)) - +0 + |0 (#.Primitive class-name (list)) arity - (|> (list.n/range +0 (dec arity)) + (|> (list.n/range |0 (dec arity)) list.reverse - (list/map (|>> (n/* +2) inc #.Parameter)) + (list/map (|>> (n/* |2) inc #.Parameter)) (#.Primitive class-name) (type.univ-q arity))))) @@ -831,7 +831,7 @@ (////.throw bundle.invalid-syntax extension-name)) _ - (////.throw bundle.incorrect-arity [extension-name +2 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |2 (list.size args)])))) (def: static::put Handler @@ -853,7 +853,7 @@ (////.throw bundle.invalid-syntax extension-name)) _ - (////.throw bundle.incorrect-arity [extension-name +3 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |3 (list.size args)])))) (def: virtual::get Handler @@ -872,7 +872,7 @@ (////.throw bundle.invalid-syntax extension-name)) _ - (////.throw bundle.incorrect-arity [extension-name +3 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |3 (list.size args)])))) (def: virtual::put Handler @@ -896,7 +896,7 @@ (////.throw bundle.invalid-syntax extension-name)) _ - (////.throw bundle.incorrect-arity [extension-name +4 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name |4 (list.size args)])))) (def: (java-type-to-parameter type) (-> java/lang/reflect/Type (Operation Text)) @@ -970,11 +970,11 @@ (def: idx-to-parameter (-> Nat Type) - (|>> (n/* +2) inc #.Parameter)) + (|>> (n/* |2) inc #.Parameter)) (def: (type-vars amount offset) (-> Nat Nat (List Type)) - (if (n/= +0 amount) + (if (n/= |0 amount) (list) (|> (list.n/range offset (|> amount dec (n/+ offset))) (list/map idx-to-parameter)))) @@ -998,7 +998,7 @@ num-method-tvars (list.size method-tvars) all-tvars (list/compose owner-tvars method-tvars) num-all-tvars (list.size all-tvars) - owner-tvarsT (type-vars num-owner-tvars +0) + owner-tvarsT (type-vars num-owner-tvars |0) method-tvarsT (type-vars num-method-tvars num-owner-tvars) mappings (: Mappings (if (list.empty? all-tvars) @@ -1086,7 +1086,7 @@ num-owner-tvars (list.size owner-tvars) all-tvars (list/compose owner-tvars constructor-tvars) num-all-tvars (list.size all-tvars) - owner-tvarsT (type-vars num-owner-tvars +0) + owner-tvarsT (type-vars num-owner-tvars |0) constructor-tvarsT (type-vars num-all-tvars num-owner-tvars) mappings (: Mappings (if (list.empty? all-tvars) diff --git a/stdlib/source/lux/compiler/default/phase/synthesis.lux b/stdlib/source/lux/compiler/default/phase/synthesis.lux index 8deb48ba8..28392eafd 100644 --- a/stdlib/source/lux/compiler/default/phase/synthesis.lux +++ b/stdlib/source/lux/compiler/default/phase/synthesis.lux @@ -25,10 +25,10 @@ (def: #export init State - {#scope-arity +0 + {#scope-arity |0 #resolver fresh-resolver #direct? #0 - #locals +0}) + #locals |0}) (type: #export Primitive (#Bit Bit) diff --git a/stdlib/source/lux/compiler/default/phase/synthesis/expression.lux b/stdlib/source/lux/compiler/default/phase/synthesis/expression.lux index edb2cc034..0ab38afac 100644 --- a/stdlib/source/lux/compiler/default/phase/synthesis/expression.lux +++ b/stdlib/source/lux/compiler/default/phase/synthesis/expression.lux @@ -67,11 +67,11 @@ (do @ [arity //.scope-arity] (wrap (if (function.nested? arity) - (if (n/= +0 register) + (if (n/= |0 register) (|> (dec arity) - (list.n/range +1) + (list.n/range |1) (list/map (|>> //.variable/local)) - [(//.variable/local +0)] + [(//.variable/local |0)] //.function/apply) (#//.Reference (#reference.Variable (function.adjust arity #0 var)))) (#//.Reference (#reference.Variable var))))) diff --git a/stdlib/source/lux/compiler/default/phase/synthesis/function.lux b/stdlib/source/lux/compiler/default/phase/synthesis/function.lux index 397ca2449..b7dd22f70 100644 --- a/stdlib/source/lux/compiler/default/phase/synthesis/function.lux +++ b/stdlib/source/lux/compiler/default/phase/synthesis/function.lux @@ -20,7 +20,7 @@ (def: #export nested? (-> Arity Bit) - (n/> +1)) + (n/> |1)) (def: #export (adjust up-arity after? var) (-> Arity Bit Variable Variable) @@ -90,7 +90,7 @@ resolver //.resolver #let [function-arity (if direct? (inc arity) - +1) + |1) up-environment (if (nested? arity) (list/map (.function (_ closure) (case (dict.get closure resolver) @@ -107,7 +107,7 @@ (list) _ - (|> (list.size environment) dec (list.n/range +0) + (|> (list.size environment) dec (list.n/range |0) (list/map (|>> #reference.Foreign))))) resolver' (if (and (nested? function-arity) direct?) @@ -129,6 +129,6 @@ ..return)) _ - (|> (prepare function-arity +1 bodyS) - (maybe/map (|>> [up-environment +1] //.function/abstraction)) + (|> (prepare function-arity |1 bodyS) + (maybe/map (|>> [up-environment |1] //.function/abstraction)) ..return)))) diff --git a/stdlib/source/lux/compiler/default/phase/synthesis/loop.lux b/stdlib/source/lux/compiler/default/phase/synthesis/loop.lux index bfa69c7c6..4bae596c3 100644 --- a/stdlib/source/lux/compiler/default/phase/synthesis/loop.lux +++ b/stdlib/source/lux/compiler/default/phase/synthesis/loop.lux @@ -27,7 +27,7 @@ #.None #0)) (template: #export (self) - (#//.Reference (reference.local +0))) + (#//.Reference (reference.local |0))) (template: (recursive-apply args) (#//.Apply (self) args)) diff --git a/stdlib/source/lux/compiler/default/phase/translation.lux b/stdlib/source/lux/compiler/default/phase/translation.lux index f9b5dfbb4..ec67565d6 100644 --- a/stdlib/source/lux/compiler/default/phase/translation.lux +++ b/stdlib/source/lux/compiler/default/phase/translation.lux @@ -76,12 +76,12 @@ (-> (Host expression statement) (..State anchor expression statement))) {#context {#scope-name "" - #inner-functions +0} + #inner-functions |0} #anchor #.None #host host #buffer #.None #artifacts (dict.new text.Hash) - #counter +0}) + #counter |0}) (def: #export (with-context expr) (All [anchor expression statement output] @@ -90,7 +90,7 @@ (function (_ [bundle state]) (let [[old-scope old-inner] (get@ #context state) new-scope (format old-scope "c___" (%i (.int old-inner)))] - (case (expr [bundle (set@ #context [new-scope +0] state)]) + (case (expr [bundle (set@ #context [new-scope |0] state)]) (#error.Success [[bundle' state'] output]) (#error.Success [[bundle' (set@ #context [old-scope (inc old-inner)] state')] [new-scope output]]) diff --git a/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux b/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux index fb03f3788..10a893f09 100644 --- a/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux +++ b/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux @@ -30,10 +30,10 @@ (syntax: (Vector {size s.nat} elemT) (wrap (list (` [(~+ (list.repeat size elemT))])))) -(type: #export Nullary (-> (Vector +0 Expression) Computation)) -(type: #export Unary (-> (Vector +1 Expression) Computation)) -(type: #export Binary (-> (Vector +2 Expression) Computation)) -(type: #export Trinary (-> (Vector +3 Expression) Computation)) +(type: #export Nullary (-> (Vector |0 Expression) Computation)) +(type: #export Unary (-> (Vector |1 Expression) Computation)) +(type: #export Binary (-> (Vector |2 Expression) Computation)) +(type: #export Trinary (-> (Vector |3 Expression) Computation)) (type: #export Variadic (-> (List Expression) Computation)) ## [Utils] @@ -55,12 +55,12 @@ ((~' wrap) ((~ g!extension) [(~+ g!input+)]))) (~' _) - (/////.throw bundle.incorrect-arity [(~ g!name) +1 (list.size (~ g!inputs))])))))))))) + (/////.throw bundle.incorrect-arity [(~ g!name) |1 (list.size (~ g!inputs))])))))))))) -(arity: nullary +0) -(arity: unary +1) -(arity: binary +2) -(arity: trinary +3) +(arity: nullary |0) +(arity: unary |1) +(arity: binary |2) +(arity: trinary |3) (def: #export (variadic extension) (-> Variadic Handler) diff --git a/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux b/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux index 113f6b325..437c92520 100644 --- a/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux +++ b/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux @@ -70,8 +70,8 @@ (_.letrec (list [@function (_.lambda [(list) (#.Some @curried)] (_.let (list [@num-args (_.length/1 @curried)]) (<| (_.if (|> @num-args (_.=/2 arityO)) - (<| (_.let (list [(reference.local' +0) @function])) - (_.let-values (list [[(|> (list.n/range +0 (dec arity)) + (<| (_.let (list [(reference.local' |0) @function])) + (_.let-values (list [[(|> (list.n/range |0 (dec arity)) (list/map ..input)) #.None] (_.apply/2 (_.global "apply") (_.global "values") @curried)])) diff --git a/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux b/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux index 607d922e4..a2c9e31da 100644 --- a/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux +++ b/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux @@ -58,19 +58,19 @@ (def: #export none Computation - (variant [+0 #0 ..unit])) + (variant [|0 #0 ..unit])) (def: #export some (-> Expression Computation) - (|>> [+0 #1] ..variant)) + (|>> [|0 #1] ..variant)) (def: #export left (-> Expression Computation) - (|>> [+0 #0] ..variant)) + (|>> [|0 #0] ..variant)) (def: #export right (-> Expression Computation) - (|>> [+0 #1] ..variant)) + (|>> [|0 #1] ..variant)) (def: declaration (s.Syntax [Text (List Text)]) diff --git a/stdlib/source/lux/compiler/default/reference.lux b/stdlib/source/lux/compiler/default/reference.lux index 086c72810..1c94c0349 100644 --- a/stdlib/source/lux/compiler/default/reference.lux +++ b/stdlib/source/lux/compiler/default/reference.lux @@ -31,10 +31,10 @@ (def: (hash var) (case var (#Local register) - (n/* +1 register) + (n/* |1 register) (#Foreign register) - (n/* +2 register)))) + (n/* |2 register)))) (do-template [ ] [(template: #export ( content) @@ -55,12 +55,12 @@ [constant #..Constant] ) -(def: #export self Reference (..local +0)) +(def: #export self Reference (..local |0)) (def: #export self? (-> Variable Bit) (|>> ..variable - (case> (^ (..local +0)) + (case> (^ (..local |0)) #1 _ diff --git a/stdlib/source/lux/compiler/default/repl/type.lux b/stdlib/source/lux/compiler/default/repl/type.lux index b4a8735d8..e6d25a76a 100644 --- a/stdlib/source/lux/compiler/default/repl/type.lux +++ b/stdlib/source/lux/compiler/default/repl/type.lux @@ -110,7 +110,7 @@ (n/= num-tags (list.size casesR+)))] (wrap (function (_ variantV) (loop [cases-left (list.zip3 tags - (list.n/range +0 (dec num-tags)) + (list.n/range |0 (dec num-tags)) casesR+) variantV variantV] (case cases-left diff --git a/stdlib/source/lux/compiler/default/syntax.lux b/stdlib/source/lux/compiler/default/syntax.lux index e06590f2e..b5e9acb51 100644 --- a/stdlib/source/lux/compiler/default/syntax.lux +++ b/stdlib/source/lux/compiler/default/syntax.lux @@ -64,7 +64,7 @@ [content (l.many (l.one-of new-line))] (wrap [(|> where (update@ #.line (n/+ (text.size content))) - (set@ #.column +0)) + (set@ #.column |0)) content])) )) @@ -78,7 +78,7 @@ _ (l.this new-line)] (wrap [(|> where (update@ #.line inc) - (set@ #.column +0)) + (set@ #.column |0)) comment]))) ## This is just a helper parser to find text which doesn't run into @@ -100,7 +100,7 @@ (do p.Monad [_ (l.this "#(")] (loop [comment "" - where (update@ #.column (n/+ +2) where)] + where (update@ #.column (n/+ |2) where)] ($_ p.either ## These are normal chunks of commented text. (do @ @@ -115,7 +115,7 @@ (recur (format comment new-line) (|> where (update@ #.line inc) - (set@ #.column +0)))) + (set@ #.column |0)))) ## This is the rule for handling nested sub-comments. ## Ultimately, the whole comment is just treated as text ## (the comment must respect the syntax structure, but the @@ -129,7 +129,7 @@ ## Finally, this is the rule for closing the comment. (do @ [_ (l.this ")#")] - (wrap [(update@ #.column (n/+ +2) where) + (wrap [(update@ #.column (n/+ |2) where) comment])) )))) @@ -171,22 +171,22 @@ [code l.any] (case code ## Handle special cases. - "t" (wrap [+2 "\t"]) - "v" (wrap [+2 "\v"]) - "b" (wrap [+2 "\b"]) - "n" (wrap [+2 "\n"]) - "r" (wrap [+2 "\r"]) - "f" (wrap [+2 "\f"]) - "\"" (wrap [+2 "\""]) - "\\" (wrap [+2 "\\"]) + "t" (wrap [|2 "\t"]) + "v" (wrap [|2 "\v"]) + "b" (wrap [|2 "\b"]) + "n" (wrap [|2 "\n"]) + "r" (wrap [|2 "\r"]) + "f" (wrap [|2 "\f"]) + "\"" (wrap [|2 "\""]) + "\\" (wrap [|2 "\\"]) ## Handle unicode escapes. "u" (do p.Monad - [code (l.between +1 +4 l.hexadecimal)] + [code (l.between |1 |4 l.hexadecimal)] (wrap (case (|> code (format "+") (:: number.Hex@Codec decode)) (#.Right value) - [(n/+ +2 (text.size code)) (text.from-code value)] + [(n/+ |2 (text.size code)) (text.from-code value)] _ (undefined)))) @@ -251,7 +251,7 @@ (update@ #.column (n/+ chars-consumed))) char])))) _ (l.this "\"") - #let [char (maybe.assume (text.nth +0 char))]] + #let [char (maybe.assume (text.nth |0 char))]] (wrap [(|> where' (update@ #.column inc)) [where (#.Nat char)]]))) @@ -412,7 +412,7 @@ (recur (format text-read new-line) (|> where (update@ #.line inc) - (set@ #.column +0)) + (set@ #.column |0)) #1)))))] (wrap [where' [where (#.Text text-read)]]))) @@ -529,7 +529,7 @@ [_ (l.this current-module-mark) def-name name-part^] (wrap [[current-module def-name] - (n/+ +2 (text.size def-name))])) + (n/+ |2 (text.size def-name))])) ## If the name is prefixed by the mark, but no module ## part, the module is assumed to be "lux" (otherwise known as ## the 'prelude'). @@ -559,7 +559,7 @@ second-part] ($_ n/+ (text.size first-part) - +1 + |1 (text.size second-part))])) (wrap [["" first-part] (text.size first-part)]))))) @@ -569,7 +569,7 @@ (do p.Monad [[value length] (p.after (l.this "#") (name^ current-module aliases))] - (wrap [(update@ #.column (|>> ($_ n/+ +1 length)) where) + (wrap [(update@ #.column (|>> ($_ n/+ |1 length)) where) [where (#.Tag value)]]))) (def: #export (identifier current-module aliases where) diff --git a/stdlib/source/lux/compiler/meta/io/archive.lux b/stdlib/source/lux/compiler/meta/io/archive.lux index 1c5924df7..27c7416f0 100644 --- a/stdlib/source/lux/compiler/meta/io/archive.lux +++ b/stdlib/source/lux/compiler/meta/io/archive.lux @@ -67,7 +67,7 @@ (#.Some ["" post]) (let [raw (text.replace-all (:: System separator) "/" post)] (if (text.starts-with? "/" raw) - (text.clip' +1 raw) + (text.clip' |1 raw) (#.Some raw))) _ diff --git a/stdlib/source/lux/concurrency/actor.lux b/stdlib/source/lux/concurrency/actor.lux index 30924c86d..da76351c4 100644 --- a/stdlib/source/lux/concurrency/actor.lux +++ b/stdlib/source/lux/concurrency/actor.lux @@ -335,11 +335,11 @@ (if (list.empty? actor-vars) (list) (|> actor-vars list.size dec - (list.n/range +0) (list/map (|>> code.nat (~) ($) (`)))))) + (list.n/range |0) (list/map (|>> code.nat (~) ($) (`)))))) ref-replacements (|> (if (list.empty? actor-vars) (list) (|> actor-vars list.size dec - (list.n/range +0) (list/map (|>> code.nat (~) ($) (`))))) + (list.n/range |0) (list/map (|>> code.nat (~) ($) (`))))) (: (List Code)) (list.zip2 g!all-vars) (: (List [Code Code]))) diff --git a/stdlib/source/lux/concurrency/promise.lux b/stdlib/source/lux/concurrency/promise.lux index f84b659ff..6e2450068 100644 --- a/stdlib/source/lux/concurrency/promise.lux +++ b/stdlib/source/lux/concurrency/promise.lux @@ -155,7 +155,7 @@ (def: #export future {#.doc "Runs an I/O computation on its own process and returns a Promise that will eventually host its result."} (All [a] (-> (IO a) (Promise a))) - (schedule +0)) + (schedule |0)) (def: #export (delay time-millis value) {#.doc "Delivers a value after a certain period has passed."} diff --git a/stdlib/source/lux/concurrency/semaphore.lux b/stdlib/source/lux/concurrency/semaphore.lux index 3be7fb431..5b1688048 100644 --- a/stdlib/source/lux/concurrency/semaphore.lux +++ b/stdlib/source/lux/concurrency/semaphore.lux @@ -33,7 +33,7 @@ [state (atom.read semaphore) #let [[ready? state'] (: [Bit State] (case (get@ #open-positions state) - +0 [#0 (update@ #waiting-list (|>> (#.Cons signal)) + |0 [#0 (update@ #waiting-list (|>> (#.Cons signal)) state)] _ [#1 (update@ #open-positions dec state)]))] @@ -79,7 +79,7 @@ (def: #export (mutex _) (-> Any Mutex) - (:abstraction (semaphore +1))) + (:abstraction (semaphore |1))) (def: (acquire mutex) (-> Mutex (Promise Any)) @@ -98,7 +98,7 @@ (wrap output))) ) -(def: #export limit (refinement.refinement (n/> +0))) +(def: #export limit (refinement.refinement (n/> |0))) (`` (type: #export Limit (~~ (refinement.type limit)))) (abstract: #export Barrier @@ -112,13 +112,13 @@ (def: #export (barrier limit) (-> Limit Barrier) (:abstraction {#limit limit - #count (atom.atom +0) - #start-turnstile (semaphore +0) - #end-turnstile (semaphore +0)})) + #count (atom.atom |0) + #start-turnstile (semaphore |0) + #end-turnstile (semaphore |0)})) (def: (un-block times turnstile) (-> Nat Semaphore (Promise Any)) - (loop [step +0] + (loop [step |0] (if (n/< times step) (do promise.Monad [_ (signal turnstile)] @@ -138,7 +138,7 @@ (wait (get@ barrier))))] [start inc limit #start-turnstile] - [end dec +0 #end-turnstile] + [end dec |0 #end-turnstile] ) (def: #export (block barrier) diff --git a/stdlib/source/lux/control/comonad.lux b/stdlib/source/lux/control/comonad.lux index 211604dc7..ef262762f 100644 --- a/stdlib/source/lux/control/comonad.lux +++ b/stdlib/source/lux/control/comonad.lux @@ -26,7 +26,7 @@ [a (F (CoFree F a))]) ## [Syntax] -(def: _cursor Cursor ["" +0 +0]) +(def: _cursor Cursor ["" |0 |0]) (macro: #export (be tokens state) {#.doc (doc "A co-monadic parallel to the \"do\" macro." @@ -36,7 +36,7 @@ (square (head inputs)))))} (case tokens (#.Cons comonad (#.Cons [_ (#.Tuple bindings)] (#.Cons body #.Nil))) - (if (|> bindings list.size (n/% +2) (n/= +0)) + (if (|> bindings list.size (n/% |2) (n/= |0)) (let [g!_ (: Code [_cursor (#.Identifier ["" " _ "])]) g!map (: Code [_cursor (#.Identifier ["" " map "])]) g!split (: Code [_cursor (#.Identifier ["" " split "])]) diff --git a/stdlib/source/lux/control/concatenative.lux b/stdlib/source/lux/control/concatenative.lux index ee4a78e13..47c3ea4ca 100644 --- a/stdlib/source/lux/control/concatenative.lux +++ b/stdlib/source/lux/control/concatenative.lux @@ -129,7 +129,7 @@ (~ type) (|>> (~+ (list/map prepare commands)))))))) -(syntax: #export (apply {arity (|> s.nat (p.filter (.n/> +0)))}) +(syntax: #export (apply {arity (|> s.nat (p.filter (.n/> |0)))}) (with-gensyms [g! g!func g!stack g!output] (monad.do @ [g!inputs (|> (macro.gensym "input") (list.repeat arity) (monad.seq @))] @@ -141,14 +141,14 @@ [(~ g!stack) ((~ g!func) (~+ g!inputs))]))))))))) ## [Primitives] -(def: #export apply1 (apply +1)) -(def: #export apply2 (apply +2)) -(def: #export apply3 (apply +3)) -(def: #export apply4 (apply +4)) -(def: #export apply5 (apply +5)) -(def: #export apply6 (apply +6)) -(def: #export apply7 (apply +7)) -(def: #export apply8 (apply +8)) +(def: #export apply1 (apply |1)) +(def: #export apply2 (apply |2)) +(def: #export apply3 (apply |3)) +(def: #export apply4 (apply |4)) +(def: #export apply5 (apply |5)) +(def: #export apply6 (apply |6)) +(def: #export apply7 (apply |7)) +(def: #export apply8 (apply |8)) (def: #export (push x) (All [a] (-> a (=> [] [a]))) @@ -193,12 +193,12 @@ (def: #export ||L (All [a b] (=> [a] [(| a b)])) (function (_ [stack l]) - [stack (+0 l)])) + [stack (|0 l)])) (def: #export ||R (All [a b] (=> [b] [(| a b)])) (function (_ [stack r]) - [stack (+1 r)])) + [stack (|1 r)])) (do-template [ ] [(def: #export diff --git a/stdlib/source/lux/control/equivalence.lux b/stdlib/source/lux/control/equivalence.lux index dea0e3fa6..5f9ca37b6 100644 --- a/stdlib/source/lux/control/equivalence.lux +++ b/stdlib/source/lux/control/equivalence.lux @@ -15,10 +15,10 @@ (All [l r] (-> (Equivalence l) (Equivalence r) (Equivalence (| l r)))) (structure (def: (= a|b x|y) (case [a|b x|y] - [(+0 a) (+0 x)] + [(|0 a) (|0 x)] (:: left = a x) - [(+1 b) (+1 y)] + [(|1 b) (|1 y)] (:: right = b y) _ diff --git a/stdlib/source/lux/control/exception.lux b/stdlib/source/lux/control/exception.lux index 2a3cd92c0..66c7ebf7b 100644 --- a/stdlib/source/lux/control/exception.lux +++ b/stdlib/source/lux/control/exception.lux @@ -116,7 +116,7 @@ (-> (List [Text Text]) Text) (let [largest-header-size (|> entries (list/map (|>> product.left text.size)) - (list/fold n/max +0))] + (list/fold n/max |0))] (|> entries (list/map (function (_ [header message]) (let [padding (|> " " diff --git a/stdlib/source/lux/control/monad.lux b/stdlib/source/lux/control/monad.lux index 09dd14237..e3196faf5 100644 --- a/stdlib/source/lux/control/monad.lux +++ b/stdlib/source/lux/control/monad.lux @@ -16,7 +16,7 @@ (def: (list/size xs) (All [a] (-> (List a) Nat)) - (loop [counter +0 + (loop [counter |0 xs xs] (case xs #.Nil @@ -53,7 +53,7 @@ join)) ## [Syntax] -(def: _cursor Cursor ["" +0 +0]) +(def: _cursor Cursor ["" |0 |0]) (macro: #export (do tokens state) {#.doc (doc "Macro for easy concatenation of monadic operations." @@ -63,7 +63,7 @@ (wrap (f3 z))))} (case tokens (#.Cons monad (#.Cons [_ (#.Tuple bindings)] (#.Cons body #.Nil))) - (if (|> bindings list/size (n/% +2) (n/= +0)) + (if (|> bindings list/size (n/% |2) (n/= |0)) (let [g!_ (: Code [_cursor (#.Identifier ["" " _ "])]) g!map (: Code [_cursor (#.Identifier ["" " map "])]) g!join (: Code [_cursor (#.Identifier ["" " join "])]) diff --git a/stdlib/source/lux/control/parser.lux b/stdlib/source/lux/control/parser.lux index 32ef09784..48119eaa5 100644 --- a/stdlib/source/lux/control/parser.lux +++ b/stdlib/source/lux/control/parser.lux @@ -119,11 +119,11 @@ (-> (Parser s a) (Parser s b) (Parser s (| a b)))) (function (_ tokens) (case (p1 tokens) - (#e.Success [tokens' x1]) (#e.Success [tokens' (+0 x1)]) + (#e.Success [tokens' x1]) (#e.Success [tokens' (|0 x1)]) (#e.Error _) (run tokens (do Monad [x2 p2] - (wrap (+1 x2)))) + (wrap (|1 x2)))) ))) (def: #export (either pl pr) @@ -139,7 +139,7 @@ (def: #export (exactly n p) {#.doc "Parse exactly N times."} (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) - (if (n/> +0 n) + (if (n/> |0 n) (do Monad [x p xs (exactly (dec n) p)] @@ -157,7 +157,7 @@ (def: #export (at-most n p) {#.doc "Parse at most N times."} (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) - (if (n/> +0 n) + (if (n/> |0 n) (function (_ input) (case (p input) (#e.Error msg) diff --git a/stdlib/source/lux/control/pipe.lux b/stdlib/source/lux/control/pipe.lux index ffdb78575..716304479 100644 --- a/stdlib/source/lux/control/pipe.lux +++ b/stdlib/source/lux/control/pipe.lux @@ -16,7 +16,7 @@ (Syntax (List Code)) (s.tuple (p.some s.any))) -(syntax: #export (new> {tokens (p.at-least +2 s.any)}) +(syntax: #export (new> {tokens (p.at-least |2 s.any)}) {#.doc (doc "Ignores the piped argument, and begins a new pipe." (|> 20 (i/* 3) diff --git a/stdlib/source/lux/control/writer.lux b/stdlib/source/lux/control/writer.lux index a93242297..fc964537c 100644 --- a/stdlib/source/lux/control/writer.lux +++ b/stdlib/source/lux/control/writer.lux @@ -60,7 +60,7 @@ (def: (join MlMla) (do Monad [## TODO: Remove once new-luxc is the standard compiler. - [l1 Mla] (: (($ +1) (Writer ($ +0) (($ +1) (Writer ($ +0) ($ +2))))) + [l1 Mla] (: (($ |1) (Writer ($ |0) (($ |1) (Writer ($ |0) ($ |2))))) MlMla) ## [l1 Mla] MlMla [l2 a] Mla] diff --git a/stdlib/source/lux/data/bit.lux b/stdlib/source/lux/data/bit.lux index 65bfad034..8b61d8b32 100644 --- a/stdlib/source/lux/data/bit.lux +++ b/stdlib/source/lux/data/bit.lux @@ -18,8 +18,8 @@ (def: eq Equivalence) (def: (hash value) (case value - #1 +1 - #0 +0))) + #1 |1 + #0 |0))) (do-template [ ] [(structure: #export (Monoid Bit) diff --git a/stdlib/source/lux/data/collection/array.lux b/stdlib/source/lux/data/collection/array.lux index 1a9e191a8..588c5132b 100644 --- a/stdlib/source/lux/data/collection/array.lux +++ b/stdlib/source/lux/data/collection/array.lux @@ -38,7 +38,7 @@ (All [a] (-> Nat Nat (Array a) Nat (Array a) (Array a))) - (if (n/= +0 length) + (if (n/= |0 length) dest-array (list/fold (function (_ offset target) (case (read (n/+ offset src-start) src-array) @@ -48,7 +48,7 @@ (#.Some value) (write (n/+ offset dest-start) value target))) dest-array - (list.n/range +0 (dec length))))) + (list.n/range |0 (dec length))))) (def: #export (occupied array) {#.doc "Finds out how many cells in an array are occupied."} @@ -60,7 +60,7 @@ (#.Some _) (inc count))) - +0 + |0 (list.indices (size array)))) (def: #export (vacant array) @@ -87,7 +87,7 @@ (All [a] (-> (-> a Bit) (Array a) (Maybe a))) (let [arr-size (size xs)] - (loop [idx +0] + (loop [idx |0] (if (n/< arr-size idx) (case (read idx xs) #.None @@ -104,7 +104,7 @@ (All [a] (-> (-> Nat a Bit) (Array a) (Maybe [Nat a]))) (let [arr-size (size xs)] - (loop [idx +0] + (loop [idx |0] (if (n/< arr-size idx) (case (read idx xs) #.None @@ -133,10 +133,10 @@ (All [a] (-> (List a) (Array a))) (product.right (list/fold (function (_ x [idx arr]) [(inc idx) (write idx x arr)]) - [+0 (new (list.size xs))] + [|0 (new (list.size xs))] xs))) -(def: underflow Nat (dec +0)) +(def: underflow Nat (dec |0)) (def: #export (to-list array) (All [a] (-> (Array a) (List a))) @@ -170,23 +170,23 @@ _ #0))) #1 - (list.n/range +0 (dec sxs))))) + (list.n/range |0 (dec sxs))))) )) (structure: #export Monoid (All [a] (Monoid (Array a))) - (def: identity (new +0)) + (def: identity (new |0)) (def: (compose xs ys) (let [sxs (size xs) sxy (size ys)] (|> (new (n/+ sxy sxs)) - (copy sxs +0 xs +0) - (copy sxy +0 ys sxs))))) + (copy sxs |0 xs |0) + (copy sxy |0 ys sxs))))) (structure: #export _ (Functor Array) (def: (map f ma) (let [arr-size (size ma)] - (if (n/= +0 arr-size) + (if (n/= |0 arr-size) (new arr-size) (list/fold (function (_ idx mb) (case (read idx ma) @@ -196,14 +196,14 @@ (#.Some x) (write idx (f x) mb))) (new arr-size) - (list.n/range +0 (dec arr-size))) + (list.n/range |0 (dec arr-size))) )))) (structure: #export _ (Fold Array) (def: (fold f init xs) (let [arr-size (size xs)] (loop [so-far init - idx +0] + idx |0] (if (n/< arr-size idx) (case (read idx xs) #.None @@ -218,7 +218,7 @@ (All [a] (-> (Predicate a) (Array a) Bit)) (let [size (..size array)] - (loop [idx +0] + (loop [idx |0] (if (n/< size idx) (case (..read idx array) (#.Some value) diff --git a/stdlib/source/lux/data/collection/bits.lux b/stdlib/source/lux/data/collection/bits.lux index 988a5b1dc..5caec8eb7 100644 --- a/stdlib/source/lux/data/collection/bits.lux +++ b/stdlib/source/lux/data/collection/bits.lux @@ -19,17 +19,17 @@ (type: #export Bits (Array Chunk)) -(def: empty-chunk Chunk (.i64 +0)) +(def: empty-chunk Chunk (.i64 |0)) (def: #export empty Bits - (array.new +0)) + (array.new |0)) (def: #export (size bits) (-> Bits Nat) (array/fold (function (_ chunk total) (|> chunk i64.count (n/+ total))) - +0 + |0 bits)) (def: #export (capacity bits) @@ -38,7 +38,7 @@ (def: #export empty? (-> Bits Bit) - (|>> size (n/= +0))) + (|>> size (n/= |0))) (def: #export (get index bits) (-> Nat Bits Bit) @@ -62,7 +62,7 @@ (array.size input)) output ..empty] (let [idx|output (dec size|output)] - (if (n/> +0 size|output) + (if (n/> |0 size|output) (case (|> (..chunk idx|output input) (cond> [(new> (n/= chunk-index idx|output))] [( bit-index)] @@ -70,7 +70,7 @@ ## else []) .nat) - +0 + |0 ## TODO: Remove 'no-op' once new-luxc is the official compiler. (let [no-op (recur (dec size|output) output)] no-op) @@ -92,7 +92,7 @@ (-> Bits Bits Bit) (let [chunks (n/min (array.size reference) (array.size sample))] - (loop [idx +0] + (loop [idx |0] (if (n/< chunks idx) (.or (|> (..chunk idx sample) (i64.and (..chunk idx reference)) @@ -104,7 +104,7 @@ (def: #export (not input) (-> Bits Bits) (case (array.size input) - +0 + |0 ..empty size|output @@ -112,11 +112,11 @@ output ..empty] (let [idx (dec size|output)] (case (|> input (..chunk idx) i64.not .nat) - +0 + |0 (recur (dec size|output) output) chunk - (if (n/> +0 size|output) + (if (n/> |0 size|output) (|> (if (is? ..empty output) (: Bits (array.new size|output)) output) @@ -129,18 +129,18 @@ (-> Bits Bits Bits) (case (n/max (array.size param) (array.size subject)) - +0 + |0 ..empty size|output (loop [size|output size|output output ..empty] (let [idx (dec size|output)] - (if (n/> +0 size|output) + (if (n/> |0 size|output) (case (|> (..chunk idx subject) ( (..chunk idx param)) .nat) - +0 + |0 (recur (dec size|output) output) chunk @@ -160,7 +160,7 @@ (def: (= reference sample) (let [size (n/max (array.size reference) (array.size sample))] - (loop [idx +0] + (loop [idx |0] (if (n/< size idx) (.and ("lux i64 =" (..chunk idx reference) diff --git a/stdlib/source/lux/data/collection/dictionary.lux b/stdlib/source/lux/data/collection/dictionary.lux index 49465c123..64c577946 100644 --- a/stdlib/source/lux/data/collection/dictionary.lux +++ b/stdlib/source/lux/data/collection/dictionary.lux @@ -41,7 +41,7 @@ ## the appropriate multiple of the branching-exponent. ## A shift of 0 means root level. ## A shift of (* branching-exponent 1) means level 2. -## A shift of (* branching-exponent N) means level N+1. +## A shift of (* branching-exponent N) means level N|1. (type: Level Nat) ## Nodes for the tree data-structure that organizes the data inside @@ -75,7 +75,7 @@ ## Which is 32 zeroes, since the branching factor is 32. (def: clean-bitmap BitMap - +0) + |0) ## Bitmap position (while looking inside #Base nodes) is determined by ## getting 5 bits from a hash of the key being looked up and using @@ -88,35 +88,35 @@ ## shift in the shallowest node on the tree, which is the root node). (def: root-level Level - +0) + |0) ## The exponent to which 2 must be elevated, to reach the branching ## factor of the data-structure. (def: branching-exponent Nat - +5) + |5) ## The threshold on which #Hierarchy nodes are demoted to #Base nodes, ## which is 1/4 of the branching factor (or a left-shift 2). (def: demotion-threshold Nat - (i64.left-shift (n/- +2 branching-exponent) +1)) + (i64.left-shift (n/- |2 branching-exponent) |1)) ## The threshold on which #Base nodes are promoted to #Hierarchy nodes, ## which is 1/2 of the branching factor (or a left-shift 1). (def: promotion-threshold Nat - (i64.left-shift (n/- +1 branching-exponent) +1)) + (i64.left-shift (n/- |1 branching-exponent) |1)) ## The size of hierarchy-nodes, which is 2^(branching-exponent). (def: hierarchy-nodes-size Nat - (i64.left-shift branching-exponent +1)) + (i64.left-shift branching-exponent |1)) ## The cannonical empty node, which is just an empty #Base node. (def: empty Node - (#Base clean-bitmap (array.new +0))) + (#Base clean-bitmap (array.new |0))) ## Expands a copy of the array, to have 1 extra slot, which is used ## for storing the value. @@ -124,7 +124,7 @@ (All [a] (-> Index a (Array a) (Array a))) (let [old-size (array.size old-array)] (|> (array.new (inc old-size)) - (array.copy idx +0 old-array +0) + (array.copy idx |0 old-array |0) (array.write idx value) (array.copy (n/- idx old-size) idx old-array (inc idx))))) @@ -143,13 +143,13 @@ (All [a] (-> Index (Array a) (Array a))) (let [new-size (dec (array.size array))] (|> (array.new new-size) - (array.copy idx +0 array +0) + (array.copy idx |0 array |0) (array.copy (n/- idx new-size) (inc idx) array idx)))) ## Given a top-limit for indices, produces all indices in [0, R). (def: indices-for (-> Nat (List Index)) - (|>> dec (list.n/range +0))) + (|>> dec (list.n/range |0))) ## Increases the level-shift by the branching-exponent, to explore ## levels further down the tree. @@ -169,7 +169,7 @@ ## A mechanism to go from indices to bit-positions. (def: (->bit-position index) (-> Index BitPosition) - (i64.left-shift index +1)) + (i64.left-shift index |1)) ## The bit-position within a base that a given hash-code would have. (def: (bit-position level hash) @@ -234,7 +234,7 @@ [(set-bit-position (->bit-position idx) bitmap) (array.write insertion-idx (#.Left sub-node) base)]]) ))) - [+0 [clean-bitmap + [|0 [clean-bitmap (array.new (dec h-size))]] (list.indices (array.size h-array))))) @@ -264,7 +264,7 @@ #.None (undefined))] default)) - [+0 + [|0 (array.new hierarchy-nodes-size)] hierarchy-indices))) @@ -326,9 +326,9 @@ ## the same, a new ## #Collisions node ## is added. - (#Collisions hash (|> (array.new +2) - (array.write +0 [key' val']) - (array.write +1 [key val]))) + (#Collisions hash (|> (array.new |2) + (array.write |0 [key' val']) + (array.write |1 [key val]))) ## Otherwise, I can ## just keep using ## #Base nodes, so I @@ -371,8 +371,8 @@ ## If the hashes are not equal, I create a new #Base node that ## contains the old #Collisions node, plus the new KV-pair. (|> (#Base (bit-position level _hash) - (|> (array.new +1) - (array.write +0 (#.Left node)))) + (|> (array.new |1) + (array.write |0 (#.Left node)))) (put' level hash key val Hash))) )) @@ -460,7 +460,7 @@ ## But if so, then check the size of the collisions list. (#.Some idx) - (if (n/= +1 (array.size _colls)) + (if (n/= |1 (array.size _colls)) ## If there's only one left, then removing it leaves us with ## an empty node. empty @@ -505,13 +505,13 @@ (All [k v] (-> (Node k v) Nat)) (case node (#Hierarchy _size hierarchy) - (array/fold n/+ +0 (array/map size' hierarchy)) + (array/fold n/+ |0 (array/map size' hierarchy)) (#Base _ base) - (array/fold n/+ +0 (array/map (function (_ sub-node') + (array/fold n/+ |0 (array/map (function (_ sub-node') (case sub-node' (#.Left sub-node) (size' sub-node) - (#.Right _) +1)) + (#.Right _) |1)) base)) (#Collisions hash colls) @@ -605,7 +605,7 @@ (def: #export empty? (All [k v] (-> (Dictionary k v) Bit)) - (|>> size (n/= +0))) + (|>> size (n/= |0))) (def: #export (entries dict) (All [k v] (-> (Dictionary k v) (List [k v]))) diff --git a/stdlib/source/lux/data/collection/dictionary/ordered.lux b/stdlib/source/lux/data/collection/dictionary/ordered.lux index 9e9a2ea8d..38442f93d 100644 --- a/stdlib/source/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/lux/data/collection/dictionary/ordered.lux @@ -115,7 +115,7 @@ (loop [node (get@ #root dict)] (case node #.None - +0 + |0 (#.Some node) (inc ( (recur (get@ #left node)) diff --git a/stdlib/source/lux/data/collection/list.lux b/stdlib/source/lux/data/collection/list.lux index 2d74aad79..d7a2145c6 100644 --- a/stdlib/source/lux/data/collection/list.lux +++ b/stdlib/source/lux/data/collection/list.lux @@ -68,7 +68,7 @@ [(def: #export ( n xs) (All [a] (-> Nat (List a) (List a))) - (if (n/> +0 n) + (if (n/> |0 n) (case xs #.Nil #.Nil @@ -101,7 +101,7 @@ (def: #export (split n xs) (All [a] (-> Nat (List a) [(List a) (List a)])) - (if (n/> +0 n) + (if (n/> |0 n) (case xs #.Nil [#.Nil #.Nil] @@ -145,7 +145,7 @@ {#.doc "A list of the value x, repeated n times."} (All [a] (-> Nat a (List a))) - (if (n/> +0 n) + (if (n/> |0 n) (#.Cons [x (repeat (dec n) x)]) #.Nil)) @@ -229,7 +229,7 @@ (def: #export (size list) (All [a] (-> (List a) Nat)) - (fold (function (_ _ acc) (n/+ +1 acc)) +0 list)) + (fold (function (_ _ acc) (n/+ |1 acc)) |0 list)) (do-template [ ] [(def: #export ( p xs) @@ -261,7 +261,7 @@ #.None (#.Cons [x xs']) - (if (n/= +0 i) + (if (n/= |0 i) (#.Some x) (nth (dec i) xs')))) @@ -382,40 +382,40 @@ ## [Syntax] (def: (identifier$ name) (-> Text Code) - [["" +0 +0] (#.Identifier "" name)]) + [["" |0 |0] (#.Identifier "" name)]) (def: (nat/encode value) (-> Nat Text) (loop [input value output ""] - (let [digit (case (n/% +10 input) - +0 "0" - +1 "1" - +2 "2" - +3 "3" - +4 "4" - +5 "5" - +6 "6" - +7 "7" - +8 "8" - +9 "9" + (let [digit (case (n/% |10 input) + |0 "0" + |1 "1" + |2 "2" + |3 "3" + |4 "4" + |5 "5" + |6 "6" + |7 "7" + |8 "8" + |9 "9" _ (undefined)) output' ("lux text concat" digit output) - input' (n// +10 input)] - (if (n/= +0 input') + input' (n// |10 input)] + (if (n/= |0 input') ("lux text concat" "+" output') (recur input' output'))))) (macro: #export (zip tokens state) {#.doc (doc "Create list zippers with the specified number of input lists." - (def: #export zip2 (zip +2)) - (def: #export zip3 (zip +3)) - ((zip +3) xs ys zs))} + (def: #export zip2 (zip |2)) + (def: #export zip3 (zip |3)) + ((zip |3) xs ys zs))} (case tokens (^ (list [_ (#.Nat num-lists)])) - (if (n/> +0 num-lists) + (if (n/> |0 num-lists) (let [(^open ".") Functor - indices (n/range +0 (dec num-lists)) + indices (n/range |0 (dec num-lists)) type-vars (: (List Code) (map (|>> nat/encode identifier$) indices)) zip-type (` (All [(~+ type-vars)] (-> (~+ (map (: (-> Code Code) (function (_ var) (` (List (~ var))))) @@ -447,19 +447,19 @@ _ (#.Left "Wrong syntax for zip"))) -(def: #export zip2 (zip +2)) -(def: #export zip3 (zip +3)) +(def: #export zip2 (zip |2)) +(def: #export zip3 (zip |3)) (macro: #export (zip-with tokens state) {#.doc (doc "Create list zippers with the specified number of input lists." - (def: #export zip2-with (zip-with +2)) - (def: #export zip3-with (zip-with +3)) - ((zip-with +2) i/+ xs ys))} + (def: #export zip2-with (zip-with |2)) + (def: #export zip3-with (zip-with |3)) + ((zip-with |2) i/+ xs ys))} (case tokens (^ (list [_ (#.Nat num-lists)])) - (if (n/> +0 num-lists) + (if (n/> |0 num-lists) (let [(^open ".") Functor - indices (n/range +0 (dec num-lists)) + indices (n/range |0 (dec num-lists)) g!return-type (identifier$ "\treturn-type\t") g!func (identifier$ "\tfunc\t") type-vars (: (List Code) (map (|>> nat/encode identifier$) indices)) @@ -494,8 +494,8 @@ _ (#.Left "Wrong syntax for zip-with"))) -(def: #export zip2-with (zip-with +2)) -(def: #export zip3-with (zip-with +3)) +(def: #export zip2-with (zip-with |2)) +(def: #export zip3-with (zip-with |3)) (def: #export (last xs) (All [a] (-> (List a) (Maybe a))) @@ -545,7 +545,7 @@ (do Monad [lMla MlMla ## TODO: Remove this version ASAP and use one below. - lla (: (($ +0) (List (List ($ +1)))) + lla (: (($ |0) (List (List ($ |1)))) (monad.seq @ lMla)) ## lla (monad.seq @ lMla) ] @@ -567,11 +567,11 @@ (def: #export (enumerate xs) {#.doc "Pairs every element in the list with its index, starting at 0."} (All [a] (-> (List a) (List [Nat a]))) - (enumerate' +0 xs)) + (enumerate' |0 xs)) (def: #export (indices size) {#.doc "Produces all the valid indices for a given size."} (All [a] (-> Nat (List Nat))) - (if (n/= +0 size) + (if (n/= |0 size) (list) - (|> size dec (n/range +0)))) + (|> size dec (n/range |0)))) diff --git a/stdlib/source/lux/data/collection/queue/priority.lux b/stdlib/source/lux/data/collection/queue/priority.lux index ee1e5c1ca..a5aa7dd73 100644 --- a/stdlib/source/lux/data/collection/queue/priority.lux +++ b/stdlib/source/lux/data/collection/queue/priority.lux @@ -32,13 +32,13 @@ (All [a] (-> (Queue a) Nat)) (case queue #.None - +0 + |0 (#.Some fingers) (loop [node (get@ #finger.node fingers)] (case node (#finger.Leaf _ _) - +1 + |1 (#finger.Branch _ left right) (n/+ (recur left) (recur right)))))) diff --git a/stdlib/source/lux/data/collection/row.lux b/stdlib/source/lux/data/collection/row.lux index 1a12e3d9f..ddedad6c5 100644 --- a/stdlib/source/lux/data/collection/row.lux +++ b/stdlib/source/lux/data/collection/row.lux @@ -35,11 +35,11 @@ (def: branching-exponent Nat - +5) + |5) (def: root-level Level - +0) + |0) (do-template [ ] [(def: @@ -52,7 +52,7 @@ (def: full-node-size Nat - (i64.left-shift branching-exponent +1)) + (i64.left-shift branching-exponent |1)) (def: branch-idx-mask Nat @@ -69,23 +69,23 @@ (def: (tail-off vec-size) (-> Nat Nat) (if (n/< full-node-size vec-size) - +0 + |0 (|> (dec vec-size) (i64.logical-right-shift branching-exponent) (i64.left-shift branching-exponent)))) (def: (new-path level tail) (All [a] (-> Level (Base a) (Node a))) - (if (n/= +0 level) + (if (n/= |0 level) (#Base tail) (|> (new-hierarchy []) - (array.write +0 (new-path (level-down level) tail)) + (array.write |0 (new-path (level-down level) tail)) #Hierarchy))) (def: (new-tail singleton) (All [a] (-> a (Base a))) - (|> (array.new +1) - (array.write +0 singleton))) + (|> (array.new |1) + (array.write |0 singleton))) (def: (push-tail size level tail parent) (All [a] (-> Nat Level (Base a) (Hierarchy a) (Hierarchy a))) @@ -113,7 +113,7 @@ (All [a] (-> a (Base a) (Base a))) (let [tail-size (array.size tail)] (|> (array.new (inc tail-size)) - (array.copy tail-size +0 tail +0) + (array.copy tail-size |0 tail |0) (array.write tail-size val)))) (def: (put' level idx val hierarchy) @@ -125,7 +125,7 @@ (array.write sub-idx (#Hierarchy (put' (level-down level) idx val sub-node)))) (^multi (#.Some (#Base base)) - (n/= +0 (level-down level))) + (n/= |0 (level-down level))) (|> (array.clone hierarchy) (array.write sub-idx (|> (array.clone base) (array.write (branch-idx idx) val) @@ -136,8 +136,8 @@ (def: (pop-tail size level hierarchy) (All [a] (-> Nat Level (Hierarchy a) (Maybe (Hierarchy a)))) - (let [sub-idx (branch-idx (i64.logical-right-shift level (n/- +2 size)))] - (cond (n/= +0 sub-idx) + (let [sub-idx (branch-idx (i64.logical-right-shift level (n/- |2 size)))] + (cond (n/= |0 sub-idx) #.None (n/> branching-exponent level) @@ -183,9 +183,9 @@ (def: #export empty Row {#level (level-up root-level) - #size +0 + #size |0 #root (array.new full-node-size) - #tail (array.new +0)}) + #tail (array.new |0)}) (def: #export (size row) (All [a] (-> (Row a) Nat)) @@ -203,17 +203,17 @@ ## Otherwise, push tail into the tree ## -------------------------------------------------------- ## Will the root experience an overflow with this addition? - (|> (if (n/> (i64.left-shift (get@ #level vec) +1) + (|> (if (n/> (i64.left-shift (get@ #level vec) |1) (i64.logical-right-shift branching-exponent vec-size)) ## If so, a brand-new root must be established, that is ## 1-level taller. (|> vec - (set@ #root (|> (: (Hierarchy ($ +0)) + (set@ #root (|> (: (Hierarchy ($ |0)) (new-hierarchy [])) ## TODO: Remove version above once new-luxc becomes the standard compiler. ## (new-hierarchy []) - (array.write +0 (#Hierarchy (get@ #root vec))) - (array.write +1 (new-path (get@ #level vec) (get@ #tail vec))))) + (array.write |0 (#Hierarchy (get@ #root vec))) + (array.write |1 (new-path (get@ #level vec) (get@ #tail vec))))) (update@ #level level-up)) ## Otherwise, just push the current tail onto the root. (|> vec @@ -227,7 +227,7 @@ (def: (base-for idx vec) (All [a] (-> Index (Row a) (Maybe (Base a)))) (let [vec-size (get@ #size vec)] - (if (and (n/>= +0 idx) + (if (and (n/>= |0 idx) (n/< vec-size idx)) (if (n/>= (tail-off vec-size) idx) (#.Some (get@ #tail vec)) @@ -257,13 +257,13 @@ (def: #export (put idx val vec) (All [a] (-> Nat a (Row a) (Row a))) (let [vec-size (get@ #size vec)] - (if (and (n/>= +0 idx) + (if (and (n/>= |0 idx) (n/< vec-size idx)) (if (n/>= (tail-off vec-size) idx) (|> vec ## (update@ #tail (|>> array.clone (array.write (branch-idx idx) val))) ## TODO: Remove once new-luxc becomes the standard compiler. - (update@ #tail (: (-> (Base ($ +0)) (Base ($ +0))) + (update@ #tail (: (-> (Base ($ |0)) (Base ($ |0))) (|>> array.clone (array.write (branch-idx idx) val)))) ) (|> vec @@ -282,29 +282,29 @@ (def: #export (pop vec) (All [a] (-> (Row a) (Row a))) (case (get@ #size vec) - +0 + |0 empty - +1 + |1 empty vec-size - (if (|> vec-size (n/- (tail-off vec-size)) (n/> +1)) + (if (|> vec-size (n/- (tail-off vec-size)) (n/> |1)) (let [old-tail (get@ #tail vec) new-tail-size (dec (array.size old-tail))] (|> vec (update@ #size dec) (set@ #tail (|> (array.new new-tail-size) - (array.copy new-tail-size +0 old-tail +0))))) + (array.copy new-tail-size |0 old-tail |0))))) (maybe.assume (do maybe.Monad - [new-tail (base-for (n/- +2 vec-size) vec) + [new-tail (base-for (n/- |2 vec-size) vec) #let [[level' root'] (let [init-level (get@ #level vec)] (loop [level init-level root (maybe.default (new-hierarchy []) (pop-tail vec-size init-level (get@ #root vec)))] (if (n/> branching-exponent level) - (case [(array.read +1 root) (array.read +0 root)] + (case [(array.read |1 root) (array.read |0 root)] [#.None (#.Some (#Hierarchy sub-node))] (recur (level-down level) sub-node) @@ -338,7 +338,7 @@ (def: #export empty? (All [a] (-> (Row a) Bit)) - (|>> (get@ #size) (n/= +0))) + (|>> (get@ #size) (n/= |0))) ## [Syntax] (syntax: #export (row {elems (p.some s.any)}) diff --git a/stdlib/source/lux/data/collection/sequence.lux b/stdlib/source/lux/data/collection/sequence.lux index 2f9cf3722..95d60b555 100644 --- a/stdlib/source/lux/data/collection/sequence.lux +++ b/stdlib/source/lux/data/collection/sequence.lux @@ -62,7 +62,7 @@ (def: #export (nth idx s) (All [a] (-> Nat (Sequence a) a)) (let [[h t] (continuation.run s)] - (if (n/> +0 idx) + (if (n/> |0 idx) (nth (dec idx) t) h))) @@ -93,7 +93,7 @@ [(list) xs])))] [take-while drop-while split-while (-> a Bit) (pred x) pred] - [take drop split Nat (n/> +0 pred) (dec pred)] + [take drop split Nat (n/> |0 pred) (dec pred)] ) (def: #export (unfold step init) diff --git a/stdlib/source/lux/data/collection/set.lux b/stdlib/source/lux/data/collection/set.lux index ef39c98e0..cab4105b0 100644 --- a/stdlib/source/lux/data/collection/set.lux +++ b/stdlib/source/lux/data/collection/set.lux @@ -65,13 +65,13 @@ (def: (hash set) (let [[Hash _] (:representation set)] (list/fold (function (_ elem acc) (n/+ (:: Hash hash elem) acc)) - +0 + |0 (..to-list set))))) ) (def: #export empty? (All [a] (-> (Set a) Bit)) - (|>> ..size (n/= +0))) + (|>> ..size (n/= |0))) (def: #export (from-list Hash xs) (All [a] (-> (Hash a) (List a) (Set a))) diff --git a/stdlib/source/lux/data/collection/set/multi.lux b/stdlib/source/lux/data/collection/set/multi.lux index eb8e914e3..91fd7f675 100644 --- a/stdlib/source/lux/data/collection/set/multi.lux +++ b/stdlib/source/lux/data/collection/set/multi.lux @@ -25,15 +25,15 @@ (def: #export size (All [a] (-> (Set a) Nat)) - (|>> :representation dictionary.values (list/fold n/+ +0))) + (|>> :representation dictionary.values (list/fold n/+ |0))) (def: #export (add/* count elem set) (All [a] (-> Nat a (Set a) (Set a))) - (|> set :representation (dictionary.update~ elem +0 (n/+ count)) :abstraction)) + (|> set :representation (dictionary.update~ elem |0 (n/+ count)) :abstraction)) (def: #export add/1 (All [a] (-> a (Set a) (Set a))) - (add/* +1)) + (add/* |1)) (def: #export (remove/* count elem set) (All [a] (-> Nat a (Set a) (Set a))) @@ -53,18 +53,18 @@ (def: #export remove/1 (All [a] (-> a (Set a) (Set a))) - (remove/* +1)) + (remove/* |1)) (def: #export (multiplicity elem set) (All [a] (-> a (Set a) Nat)) - (|> set :representation (dictionary.get elem) (maybe.default +0))) + (|> set :representation (dictionary.get elem) (maybe.default |0))) (def: #export to-list (All [a] (-> (Set a) (List a))) (let [append (: (All [a] (-> a Nat (List a) (List a))) (function (append elem count output) (case count - +0 output + |0 output _ (|> output (#.Cons elem) (append elem (dec count))))))] (|>> :representation dictionary.entries @@ -105,7 +105,7 @@ (|> reference :representation (dictionary.get elem) - (maybe.default +0) + (maybe.default |0) (n/>= count)))))) (def: #export (support set) @@ -124,7 +124,7 @@ (list.every? (function (_ [elem count]) (|> sample (dictionary.get elem) - (maybe.default +0) + (maybe.default |0) (n/= count)))))))) (structure: #export Hash (All [a] (Hash (Set a))) @@ -134,17 +134,17 @@ (let [[Hash _] set] (list/fold (function (_ [elem count] acc) (|> elem (:: Hash hash) (n/* count) (n/+ acc))) - +0 + |0 (dictionary.entries set))))) ) (def: #export (member? set elem) (All [a] (-> (Set a) a Bit)) - (|> set (..multiplicity elem) (n/> +0))) + (|> set (..multiplicity elem) (n/> |0))) (def: #export empty? (All [a] (-> (Set a) Bit)) - (|>> ..size (n/= +0))) + (|>> ..size (n/= |0))) (def: #export (from-list Hash subject) (All [a] (-> (Hash a) (List a) (Set a))) diff --git a/stdlib/source/lux/data/collection/tree/rose/zipper.lux b/stdlib/source/lux/data/collection/tree/rose/zipper.lux index 4181bd406..b732f87b2 100644 --- a/stdlib/source/lux/data/collection/tree/rose/zipper.lux +++ b/stdlib/source/lux/data/collection/tree/rose/zipper.lux @@ -86,7 +86,7 @@ (#.Some parent) (|> parent ## TODO: Remove once new-luxc becomes the standard compiler. - (update@ #node (: (-> (Tree ($ +0)) (Tree ($ +0))) + (update@ #node (: (-> (Tree ($ |0)) (Tree ($ |0))) (function (_ node) (set@ #//.children (list/compose (list.reverse (get@ #lefts zipper)) (#.Cons (get@ #node zipper) @@ -155,7 +155,7 @@ (update@ [#node #//.children] (function (_ children) ## TODO: Remove once new-luxc becomes the standard compiler. - (list& (: (Tree ($ +0)) + (list& (: (Tree ($ |0)) (//.tree [value {}])) children) ## (list& (//.tree [value {}]) @@ -169,7 +169,7 @@ (function (_ children) (list/compose children ## TODO: Remove once new-luxc becomes the standard compiler. - (list (: (Tree ($ +0)) + (list (: (Tree ($ |0)) (//.tree [value {}]))) ## (list (//.tree [value {}])) )) @@ -203,7 +203,7 @@ (#.Some (|> zipper (update@ (function (_ side) ## TODO: Remove once new-luxc becomes the standard compiler. - (#.Cons (: (Tree ($ +0)) + (#.Cons (: (Tree ($ |0)) (//.tree [value {}])) side) ## (#.Cons (//.tree [value {}]) diff --git a/stdlib/source/lux/data/color.lux b/stdlib/source/lux/data/color.lux index 8ff70f96c..c708e8775 100644 --- a/stdlib/source/lux/data/color.lux +++ b/stdlib/source/lux/data/color.lux @@ -8,7 +8,7 @@ [type abstract]]) -(def: rgb Nat +256) +(def: rgb Nat |256) (def: top Nat (dec rgb)) (def: rgb-factor Frac (|> top .int int-to-frac)) @@ -155,9 +155,9 @@ t (|> 1.0 (f/- (|> 1.0 (f/- f) (f/* saturation))) (f/* brightness)) v brightness mod (|> i (f/% 6.0) frac-to-int .nat) - red (case mod +0 v +1 q +2 p +3 p +4 t +5 v _ (undefined)) - green (case mod +0 t +1 v +2 v +3 q +4 p +5 p _ (undefined)) - blue (case mod +0 p +1 p +2 t +3 v +4 v +5 q _ (undefined))] + red (case mod |0 v |1 q |2 p |3 p |4 t |5 v _ (undefined)) + green (case mod |0 t |1 v |2 v |3 q |4 p |5 p _ (undefined)) + blue (case mod |0 p |1 p |2 t |3 v |4 v |5 q _ (undefined))] (color [(scale-up red) (scale-up green) (scale-up blue)]))) @@ -180,7 +180,7 @@ (def: #export (from-cmyk [cyan magenta yellow key]) (-> [Frac Frac Frac Frac] Color) (if (f/= 1.0 key) - (color [+0 +0 +0]) + (color [|0 |0 |0]) (let [red (|> (|> 1.0 (f/- cyan)) (f/* (|> 1.0 (f/- key)))) green (|> (|> 1.0 (f/- magenta)) @@ -216,7 +216,7 @@ (interpolate' greenE greenS) (interpolate' blueE blueS)]))) -(def: black Color (color [+0 +0 +0])) +(def: black Color (color [|0 |0 |0])) (def: white Color (color [top top top])) (do-template [ ] @@ -283,7 +283,7 @@ (def: #export (analogous results slice color) (-> Nat Frac Color (List Color)) - (if (n/= +0 results) + (if (n/= |0 results) (list) (let [[hue saturation luminance] (to-hsl color) slice (normalize slice)] @@ -291,15 +291,15 @@ (from-hsl [(|> idx .int int-to-frac (f/* slice) (f/+ hue) normalize) saturation luminance])) - (list.n/range +0 (dec results)))))) + (list.n/range |0 (dec results)))))) (def: #export (monochromatic results color) (-> Nat Color (List Color)) - (if (n/= +0 results) + (if (n/= |0 results) (list) (let [[hue saturation brightness] (to-hsb color) slice (|> 1.0 (f// (|> results .int int-to-frac)))] - (|> (list.n/range +0 (dec results)) + (|> (list.n/range |0 (dec results)) (list/map (|>> .int int-to-frac (f/* slice) (f/+ brightness) diff --git a/stdlib/source/lux/data/format/binary.lux b/stdlib/source/lux/data/format/binary.lux index b2feda2c5..c5c7cbb89 100644 --- a/stdlib/source/lux/data/format/binary.lux +++ b/stdlib/source/lux/data/format/binary.lux @@ -28,10 +28,10 @@ (type: #export Size Nat) -(def: #export size/8 +1) -(def: #export size/16 +2) -(def: #export size/32 +4) -(def: #export size/64 +8) +(def: #export size/8 |1) +(def: #export size/16 |2) +(def: #export size/32 |4) +(def: #export size/64 |8) (type: #export Read (p.Parser [Offset Binary])) @@ -46,7 +46,7 @@ ## Operators (def: #export (read format input) (All [a] (-> (Format a) Binary (Error a))) - (case ((get@ #read format) [+0 input]) + (case ((get@ #read format) [|0 input]) (#error.Error msg) (#error.Error msg) @@ -59,7 +59,7 @@ (def: #export (write format value) (All [a] (-> (Format a) a Binary)) (let [[valueS valueT] ((get@ #write format) value)] - (|> valueS binary.create (valueT +0)))) + (|> valueS binary.create (valueT |0)))) ## Primitives (do-template [ ] @@ -91,9 +91,9 @@ {#read (do p.Monad [flag (get@ #read bits/8)] (case flag - +0 (:: @ map (|>> #.Left) (get@ #read leftB)) - +1 (:: @ map (|>> #.Right) (get@ #read rightB)) - _ (p.lift (ex.throw invalid-tag [+2 (.nat flag)])))) + |0 (:: @ map (|>> #.Left) (get@ #read leftB)) + |1 (:: @ map (|>> #.Right) (get@ #read rightB)) + _ (p.lift (ex.throw invalid-tag [|2 (.nat flag)])))) #write (function (_ altV) (case altV (#.Left leftV) @@ -101,7 +101,7 @@ [(.inc leftS) (function (_ offset binary) (|> binary - (binary.write/8 offset +0) + (binary.write/8 offset |0) error.assume (leftT (.inc offset))))]) @@ -110,7 +110,7 @@ [(.inc rightS) (function (_ offset binary) (|> binary - (binary.write/8 offset +1) + (binary.write/8 offset |1) error.assume (rightT (.inc offset))))]) ))}) @@ -141,7 +141,7 @@ {#read (function (_ input) (#error.Success [input default])) #write (function (_ value) - [+0 + [|0 (function (_ offset binary) binary)])}) @@ -157,19 +157,19 @@ (case (: Nat data) (^template [ ] (#error.Success [(inc offset) binary] )) - ([+0 #0] - [+1 #1]) + ([|0 #0] + [|1 #1]) _ - (ex.throw invalid-tag [+2 data])) + (ex.throw invalid-tag [|2 data])) (#error.Error error) (#error.Error error))) #write (function (_ value) - [+1 + [|1 (function (_ offset binary) (|> binary - (binary.write/8 offset (if value +1 +0)) + (binary.write/8 offset (if value |1 |0)) error.assume))])}) (def: #export nat (Format Nat) (:assume ..bits/64)) @@ -198,7 +198,7 @@ (error.assume (do error.Monad [_ (binary.write/64 offset size binary)] - (binary.copy size +0 value (n/+ size/64 offset) binary))))]))}) + (binary.copy size |0 value (n/+ size/64 offset) binary))))]))}) (def: #export text (Format Text) diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux index cb71b5b07..9934af3de 100644 --- a/stdlib/source/lux/data/number.lux +++ b/stdlib/source/lux/data/number.lux @@ -51,8 +51,8 @@ (def: abs id) (def: (signum x) (case x - +0 +0 - _ +1)) + |0 |0 + _ |1)) ) (do-template [ <+> <-> <*> <%> <=> <<> <0> <1> <-1>] @@ -107,10 +107,10 @@ (def: top ) (def: bottom ))] - [ Nat Enum (:coerce Nat -1) +0] + [ Nat Enum (:coerce Nat -1) |0] [ Int Enum 9_223_372_036_854_775_807 -9_223_372_036_854_775_808] [Frac Enum ("lux frac max") ("lux frac min")] - [ Rev Enum (:coerce Rev -1) (:coerce Rev +0)] + [ Rev Enum (:coerce Rev -1) (:coerce Rev |0)] ) (do-template [ ] @@ -118,8 +118,8 @@ (def: identity ) (def: compose ))] - [ Add@Monoid Nat +0 n/+] - [ Mul@Monoid Nat +1 n/*] + [ Add@Monoid Nat |0 n/+] + [ Mul@Monoid Nat |1 n/*] [ Max@Monoid Nat (:: Interval bottom) n/max] [ Min@Monoid Nat (:: Interval top) n/min] [ Add@Monoid Int 0 i/+] @@ -182,113 +182,113 @@ (def: (binary-character value) (-> Nat (Maybe Text)) (case value - +0 (#.Some "0") - +1 (#.Some "1") + |0 (#.Some "0") + |1 (#.Some "1") _ #.None)) (def: (binary-value digit) (-> Text (Maybe Nat)) (case digit - "0" (#.Some +0) - "1" (#.Some +1) + "0" (#.Some |0) + "1" (#.Some |1) _ #.None)) (def: (octal-character value) (-> Nat (Maybe Text)) (case value - +0 (#.Some "0") - +1 (#.Some "1") - +2 (#.Some "2") - +3 (#.Some "3") - +4 (#.Some "4") - +5 (#.Some "5") - +6 (#.Some "6") - +7 (#.Some "7") + |0 (#.Some "0") + |1 (#.Some "1") + |2 (#.Some "2") + |3 (#.Some "3") + |4 (#.Some "4") + |5 (#.Some "5") + |6 (#.Some "6") + |7 (#.Some "7") _ #.None)) (def: (octal-value digit) (-> Text (Maybe Nat)) (case digit - "0" (#.Some +0) - "1" (#.Some +1) - "2" (#.Some +2) - "3" (#.Some +3) - "4" (#.Some +4) - "5" (#.Some +5) - "6" (#.Some +6) - "7" (#.Some +7) + "0" (#.Some |0) + "1" (#.Some |1) + "2" (#.Some |2) + "3" (#.Some |3) + "4" (#.Some |4) + "5" (#.Some |5) + "6" (#.Some |6) + "7" (#.Some |7) _ #.None)) (def: (decimal-character value) (-> Nat (Maybe Text)) (case value - +0 (#.Some "0") - +1 (#.Some "1") - +2 (#.Some "2") - +3 (#.Some "3") - +4 (#.Some "4") - +5 (#.Some "5") - +6 (#.Some "6") - +7 (#.Some "7") - +8 (#.Some "8") - +9 (#.Some "9") + |0 (#.Some "0") + |1 (#.Some "1") + |2 (#.Some "2") + |3 (#.Some "3") + |4 (#.Some "4") + |5 (#.Some "5") + |6 (#.Some "6") + |7 (#.Some "7") + |8 (#.Some "8") + |9 (#.Some "9") _ #.None)) (def: (decimal-value digit) (-> Text (Maybe Nat)) (case digit - "0" (#.Some +0) - "1" (#.Some +1) - "2" (#.Some +2) - "3" (#.Some +3) - "4" (#.Some +4) - "5" (#.Some +5) - "6" (#.Some +6) - "7" (#.Some +7) - "8" (#.Some +8) - "9" (#.Some +9) + "0" (#.Some |0) + "1" (#.Some |1) + "2" (#.Some |2) + "3" (#.Some |3) + "4" (#.Some |4) + "5" (#.Some |5) + "6" (#.Some |6) + "7" (#.Some |7) + "8" (#.Some |8) + "9" (#.Some |9) _ #.None)) (def: (hexadecimal-character value) (-> Nat (Maybe Text)) (case value - +0 (#.Some "0") - +1 (#.Some "1") - +2 (#.Some "2") - +3 (#.Some "3") - +4 (#.Some "4") - +5 (#.Some "5") - +6 (#.Some "6") - +7 (#.Some "7") - +8 (#.Some "8") - +9 (#.Some "9") - +10 (#.Some "A") - +11 (#.Some "B") - +12 (#.Some "C") - +13 (#.Some "D") - +14 (#.Some "E") - +15 (#.Some "F") + |0 (#.Some "0") + |1 (#.Some "1") + |2 (#.Some "2") + |3 (#.Some "3") + |4 (#.Some "4") + |5 (#.Some "5") + |6 (#.Some "6") + |7 (#.Some "7") + |8 (#.Some "8") + |9 (#.Some "9") + |10 (#.Some "A") + |11 (#.Some "B") + |12 (#.Some "C") + |13 (#.Some "D") + |14 (#.Some "E") + |15 (#.Some "F") _ #.None)) (def: (hexadecimal-value digit) (-> Text (Maybe Nat)) (case digit - "0" (#.Some +0) - "1" (#.Some +1) - "2" (#.Some +2) - "3" (#.Some +3) - "4" (#.Some +4) - "5" (#.Some +5) - "6" (#.Some +6) - "7" (#.Some +7) - "8" (#.Some +8) - "9" (#.Some +9) - (^or "a" "A") (#.Some +10) - (^or "b" "B") (#.Some +11) - (^or "c" "C") (#.Some +12) - (^or "d" "D") (#.Some +13) - (^or "e" "E") (#.Some +14) - (^or "f" "F") (#.Some +15) + "0" (#.Some |0) + "1" (#.Some |1) + "2" (#.Some |2) + "3" (#.Some |3) + "4" (#.Some |4) + "5" (#.Some |5) + "6" (#.Some |6) + "7" (#.Some |7) + "8" (#.Some |8) + "9" (#.Some |9) + (^or "a" "A") (#.Some |10) + (^or "b" "B") (#.Some |11) + (^or "c" "C") (#.Some |12) + (^or "d" "D") (#.Some |13) + (^or "e" "E") (#.Some |14) + (^or "f" "F") (#.Some |15) _ #.None)) (do-template [ ] @@ -299,17 +299,17 @@ (let [digit (maybe.assume ( (n/% input))) output' ("lux text concat" digit output) input' (n// input)] - (if (n/= +0 input') - ("lux text concat" "+" output') + (if (n/= |0 input') + ("lux text concat" "|" output') (recur input' output'))))) (def: (decode repr) (let [input-size ("lux text size" repr)] - (if (n/>= +2 input-size) - (case ("lux text char" repr +0) - (^ (#.Some (char "+"))) - (loop [idx +1 - output +0] + (if (n/>= |2 input-size) + (case ("lux text char" repr |0) + (^ (#.Some (char "|"))) + (loop [idx |1 + output |0] (if (n/< input-size idx) (let [digit (maybe.assume (get-char repr idx))] (case ( digit) @@ -325,10 +325,10 @@ (#e.Error ("lux text concat" repr))) (#e.Error ("lux text concat" repr))))))] - [Binary@Codec +2 binary-character binary-value "Invalid binary syntax for Nat: "] - [Octal@Codec +8 octal-character octal-value "Invalid octal syntax for Nat: "] - [_ +10 decimal-character decimal-value "Invalid syntax for Nat: "] - [Hex@Codec +16 hexadecimal-character hexadecimal-value "Invalid hexadecimal syntax for Nat: "] + [Binary@Codec |2 binary-character binary-value "Invalid binary syntax for Nat: "] + [Octal@Codec |8 octal-character octal-value "Invalid octal syntax for Nat: "] + [_ |10 decimal-character decimal-value "Invalid syntax for Nat: "] + [Hex@Codec |16 hexadecimal-character hexadecimal-value "Invalid hexadecimal syntax for Nat: "] ) (do-template [ ] @@ -351,14 +351,14 @@ (def: (decode repr) (let [input-size ("lux text size" repr)] - (if (n/>= +1 input-size) - (let [sign (case (get-char repr +0) + (if (n/>= |1 input-size) + (let [sign (case (get-char repr |0) (^ (#.Some "-")) -1 _ 1)] - (loop [idx (if (i/= -1 sign) +1 +0) + (loop [idx (if (i/= -1 sign) |1 |0) output 0] (if (n/< input-size idx) (let [digit (maybe.assume (get-char repr idx))] @@ -380,17 +380,17 @@ (def: (de-prefix input) (-> Text Text) - (maybe.assume ("lux text clip" input +1 ("lux text size" input)))) + (maybe.assume ("lux text clip" input |1 ("lux text size" input)))) (do-template [ ] [(structure: #export (Codec Text Rev) (def: (encode value) (let [raw-output (de-prefix (:: encode (:coerce Nat value))) - max-num-chars (n// +64) + max-num-chars (n// |64) raw-size ("lux text size" raw-output) zero-padding (loop [zeroes-left (n/- raw-size max-num-chars) output ""] - (if (n/= +0 zeroes-left) + (if (n/= |0 zeroes-left) output (recur (dec zeroes-left) ("lux text concat" "0" output)))) @@ -399,10 +399,10 @@ (def: (decode repr) (let [repr-size ("lux text size" repr)] - (if (n/>= +2 repr-size) - (case ("lux text char" repr +0) + (if (n/>= |2 repr-size) + (case ("lux text char" repr |0) (^multi (^ (#.Some (char "."))) - [(:: decode ("lux text concat" "+" (de-prefix repr))) + [(:: decode ("lux text concat" "|" (de-prefix repr))) (#e.Success output)]) (#e.Success (:coerce Rev output)) @@ -410,9 +410,9 @@ (#e.Error ("lux text concat" repr))) (#e.Error ("lux text concat" repr))))))] - [Binary@Codec Binary@Codec +1 "Invalid binary syntax: "] - [Octal@Codec Octal@Codec +3 "Invalid octal syntax: "] - [Hex@Codec Hex@Codec +4 "Invalid hexadecimal syntax: "] + [Binary@Codec Binary@Codec |1 "Invalid binary syntax: "] + [Octal@Codec Octal@Codec |3 "Invalid octal syntax: "] + [Hex@Codec Hex@Codec |4 "Invalid hexadecimal syntax: "] ) (do-template [ ] @@ -435,9 +435,9 @@ ("lux text concat" whole-part decimal-part))) (def: (decode repr) - (case ("lux text index" repr "." +0) + (case ("lux text index" repr "." |0) (#.Some split-index) - (let [whole-part (maybe.assume ("lux text clip" repr +0 split-index)) + (let [whole-part (maybe.assume ("lux text clip" repr |0 split-index)) decimal-part (maybe.assume ("lux text clip" repr (inc split-index) ("lux text size" repr)))] (case [(:: decode whole-part) (:: decode decimal-part)] @@ -448,7 +448,7 @@ 1.0) div-power (loop [muls-left ("lux text size" decimal-part) output 1.0] - (if (n/= +0 muls-left) + (if (n/= |0 muls-left) output (recur (dec muls-left) (f/* output)))) @@ -483,7 +483,7 @@ (list digits) (let [boundary (n/- chunk-size num-digits) chunk (maybe.assume ("lux text clip" digits boundary num-digits)) - remaining (maybe.assume ("lux text clip" digits +0 boundary))] + remaining (maybe.assume ("lux text clip" digits |0 boundary))] (list& chunk (segment-digits chunk-size remaining))))))) (def: (bin-segment-to-hex input) @@ -575,15 +575,15 @@ (do-template [ ] [(def: ( on-left? input) (-> Bit Text Text) - (let [max-num-chars (n// +64) + (let [max-num-chars (n// |64) input-size ("lux text size" input) zero-padding (let [num-digits-that-need-padding (n/% input-size)] - (if (n/= +0 num-digits-that-need-padding) + (if (n/= |0 num-digits-that-need-padding) "" (loop [zeroes-left (n/- num-digits-that-need-padding ) output ""] - (if (n/= +0 zeroes-left) + (if (n/= |0 zeroes-left) output (recur (dec zeroes-left) ("lux text concat" "0" output)))))) @@ -597,12 +597,12 @@ (def: (-> Text Text) - (|>> (segment-digits +1) + (|>> (segment-digits |1) (map ) re-join-chunks))] - [binary-to-hex bin-segment-to-hex hex-to-binary hex-segment-to-bin +4] - [binary-to-octal bin-segment-to-octal octal-to-binary octal-segment-to-bin +3] + [binary-to-hex bin-segment-to-hex hex-to-binary hex-segment-to-bin |4] + [binary-to-octal bin-segment-to-octal octal-to-binary octal-segment-to-bin |3] ) (do-template [ ] @@ -610,9 +610,9 @@ (def: (encode value) (let [sign (:: Number signum value) raw-bin (:: Binary@Codec encode value) - dot-idx (maybe.assume ("lux text index" raw-bin "." +0)) + dot-idx (maybe.assume ("lux text index" raw-bin "." |0)) whole-part (maybe.assume ("lux text clip" raw-bin - (if (f/= -1.0 sign) +1 +0) + (if (f/= -1.0 sign) |1 |0) dot-idx)) decimal-part (maybe.assume ("lux text clip" raw-bin (inc dot-idx) ("lux text size" raw-bin))) hex-output (|> ( #0 decimal-part) @@ -622,15 +622,15 @@ hex-output)) (def: (decode repr) - (let [sign (case ("lux text index" repr "-" +0) - (#.Some +0) + (let [sign (case ("lux text index" repr "-" |0) + (#.Some |0) -1.0 _ 1.0)] - (case ("lux text index" repr "." +0) + (case ("lux text index" repr "." |0) (#.Some split-index) - (let [whole-part (maybe.assume ("lux text clip" repr (if (f/= -1.0 sign) +1 +0) split-index)) + (let [whole-part (maybe.assume ("lux text clip" repr (if (f/= -1.0 sign) |1 |0) split-index)) decimal-part (maybe.assume ("lux text clip" repr (inc split-index) ("lux text size" repr))) as-binary (|> ( decimal-part) ("lux text concat" ".") @@ -670,8 +670,8 @@ (def: (underscore-prefixed? number) (-> Text Bit) - (case ("lux text index" number "_" +0) - (#.Some +0) + (case ("lux text index" number "_" |0) + (#.Some |0) #1 _ @@ -740,7 +740,7 @@ (def: (digits-get idx digits) (-> Nat Digits Nat) - (maybe.default +0 ("lux array get" digits idx))) + (maybe.default |0 ("lux array get" digits idx))) (def: (digits-put idx digit digits) (-> Nat Nat Digits Digits) @@ -753,22 +753,22 @@ (def: (digits-times-5! idx output) (-> Nat Digits Digits) (loop [idx idx - carry +0 + carry |0 output output] (if (i/>= 0 (:coerce Int idx)) (let [raw (|> (digits-get idx output) - (n/* +5) + (n/* |5) (n/+ carry))] (recur (dec idx) - (n// +10 raw) - (digits-put idx (n/% +10 raw) output))) + (n// |10 raw) + (digits-put idx (n/% |10 raw) output))) output))) (def: (digits-power power) (-> Nat Digits) (loop [times power output (|> (make-digits []) - (digits-put power +1))] + (digits-put power |1))] (if (i/>= 0 (:coerce Int times)) (recur (dec times) (digits-times-5! power output)) @@ -781,7 +781,7 @@ output ""] (if (i/>= 0 (:coerce Int idx)) (let [digit (digits-get idx digits)] - (if (and (n/= +0 digit) + (if (and (n/= |0 digit) all-zeroes?) (recur (dec idx) #1 output) (recur (dec idx) @@ -796,7 +796,7 @@ (def: (digits-add param subject) (-> Digits Digits Digits) (loop [idx (dec i64.width) - carry +0 + carry |0 output (make-digits [])] (if (i/>= 0 (:coerce Int idx)) (let [raw ($_ n/+ @@ -804,19 +804,19 @@ (digits-get idx param) (digits-get idx subject))] (recur (dec idx) - (n// +10 raw) - (digits-put idx (n/% +10 raw) output))) + (n// |10 raw) + (digits-put idx (n/% |10 raw) output))) output))) (def: (text-to-digits input) (-> Text (Maybe Digits)) (let [length ("lux text size" input)] (if (n/<= i64.width length) - (loop [idx +0 + (loop [idx |0 output (make-digits [])] (if (n/< length idx) (let [char (maybe.assume (get-char input idx))] - (case ("lux text index" "0123456789" char +0) + (case ("lux text index" "0123456789" char |0) #.None #.None @@ -828,7 +828,7 @@ (def: (digits-lt param subject) (-> Digits Digits Bit) - (loop [idx +0] + (loop [idx |0] (and (n/< i64.width idx) (let [pd (digits-get idx param) sd (digits-get idx subject)] @@ -842,11 +842,11 @@ (if (n/>= param sd) (digits-put idx (n/- param sd) subject) (let [diff (|> sd - (n/+ +10) + (n/+ |10) (n/- param))] (|> subject (digits-put idx diff) - (digits-sub-once! (dec idx) +1)))))) + (digits-sub-once! (dec idx) |1)))))) (def: (digits-sub! param subject) (-> Digits Digits Digits) @@ -861,7 +861,7 @@ (def: (encode input) (let [input (:coerce Nat input) last-idx (dec i64.width)] - (if (n/= +0 input) + (if (n/= |0 input) ".0" (loop [idx last-idx digits (make-digits [])] @@ -878,21 +878,21 @@ (def: (decode input) (let [length ("lux text size" input) - dotted? (case ("lux text index" input "." +0) - (#.Some +0) + dotted? (case ("lux text index" input "." |0) + (#.Some |0) #1 _ #0)] (if (and dotted? (n/<= (inc i64.width) length)) - (case (|> ("lux text clip" input +1 length) + (case (|> ("lux text clip" input |1 length) maybe.assume text-to-digits) (#.Some digits) (loop [digits digits - idx +0 - output +0] + idx |0 + output |0] (if (n/< i64.width idx) (let [power (digits-power idx)] (if (digits-lt power digits) @@ -913,58 +913,58 @@ (f// ("lux math log" 2.0) ("lux math log" input))) -(def: double-bias Nat +1023) +(def: double-bias Nat |1023) -(def: mantissa-size Nat +52) -(def: exponent-size Nat +11) +(def: mantissa-size Nat |52) +(def: exponent-size Nat |11) (def: #export (frac-to-bits input) (-> Frac I64) (i64 (cond (not-a-number? input) - (hex "+7FF7FFFFFFFFFFFF") + (hex "|7FF7FFFFFFFFFFFF") (f/= positive-infinity input) - (hex "+7FF0000000000000") + (hex "|7FF0000000000000") (f/= negative-infinity input) - (hex "+FFF0000000000000") + (hex "|FFF0000000000000") (f/= 0.0 input) (let [reciprocal (f// input 1.0)] (if (f/= positive-infinity reciprocal) ## Positive zero - (hex "+0000000000000000") + (hex "|0000000000000000") ## Negative zero - (hex "+8000000000000000"))) + (hex "|8000000000000000"))) ## else (let [sign (:: Number signum input) input (:: Number abs input) exponent ("lux math floor" (log2 input)) - exponent-mask (|> +1 (i64.left-shift exponent-size) dec) + exponent-mask (|> |1 (i64.left-shift exponent-size) dec) mantissa (|> input ## Normalize (f// ("lux math pow" 2.0 exponent)) ## Make it int-equivalent (f/* ("lux math pow" 2.0 52.0))) - sign-bit (if (f/= -1.0 sign) +1 +0) + sign-bit (if (f/= -1.0 sign) |1 |0) exponent-bits (|> exponent frac-to-int .nat (n/+ double-bias) (i64.and exponent-mask)) mantissa-bits (|> mantissa frac-to-int .nat)] ($_ i64.or - (i64.left-shift +63 sign-bit) + (i64.left-shift |63 sign-bit) (i64.left-shift mantissa-size exponent-bits) (i64.clear mantissa-size mantissa-bits))) ))) (do-template [ ] - [(def: (|> +1 (i64.left-shift ) dec (i64.left-shift ))) + [(def: (|> |1 (i64.left-shift ) dec (i64.left-shift ))) (def: ( input) (-> (I64 Any) I64) (|> input (i64.and ) (i64.logical-right-shift ) i64))] - [mantissa mantissa-mask mantissa-size +0] + [mantissa mantissa-mask mantissa-size |0] [exponent exponent-mask exponent-size mantissa-size] - [sign sign-mask +1 (n/+ exponent-size mantissa-size)] + [sign sign-mask |1 (n/+ exponent-size mantissa-size)] ) (def: #export (bits-to-frac input) @@ -972,15 +972,15 @@ (let [S (sign input) E (exponent input) M (mantissa input)] - (cond (n/= (hex "+7FF") E) - (if (n/= +0 M) - (if (n/= +0 S) + (cond (n/= (hex "|7FF") E) + (if (n/= |0 M) + (if (n/= |0 S) positive-infinity negative-infinity) not-a-number) - (and (n/= +0 E) (n/= +0 M)) - (if (n/= +0 S) + (and (n/= |0 E) (n/= |0 M)) + (if (n/= |0 S) 0.0 (f/* -1.0 0.0)) @@ -993,7 +993,7 @@ ("lux math pow" 2.0)) shifted (f/* power normalized)] - (if (n/= +0 S) + (if (n/= |0 S) shifted (f/* -1.0 shifted)))))) diff --git a/stdlib/source/lux/data/number/complex.lux b/stdlib/source/lux/data/number/complex.lux index cc725925b..41e074be6 100644 --- a/stdlib/source/lux/data/number/complex.lux +++ b/stdlib/source/lux/data/number/complex.lux @@ -291,13 +291,13 @@ (def: #export (roots nth input) (-> Nat Complex (List Complex)) - (if (n/= +0 nth) + (if (n/= |0 nth) (list) (let [r-nth (|> nth .int int-to-frac) nth-root-of-abs (|> input abs (get@ #real) (math.pow (f// r-nth 1.0))) nth-phi (|> input argument (f// r-nth)) slice (|> math.pi (f/* 2.0) (f// r-nth))] - (|> (list.n/range +0 (dec nth)) + (|> (list.n/range |0 (dec nth)) (list/map (function (_ nth') (let [inner (|> nth' .int int-to-frac (f/* slice) diff --git a/stdlib/source/lux/data/number/i64.lux b/stdlib/source/lux/data/number/i64.lux index 32b9df2e3..9d1e8794b 100644 --- a/stdlib/source/lux/data/number/i64.lux +++ b/stdlib/source/lux/data/number/i64.lux @@ -1,6 +1,6 @@ (.module: [lux (#- and or not)]) -(def: #export width Nat +64) +(def: #export width Nat |64) ## [Values] (do-template [ ] @@ -32,15 +32,15 @@ (def: #export (count subject) {#.doc "Count the number of 1s in a bit-map."} (-> (I64 Any) Nat) - (let [count' (n/- (|> subject (logical-right-shift +1) (..and +6148914691236517205) i64) + (let [count' (n/- (|> subject (logical-right-shift |1) (..and |6148914691236517205) i64) (i64 subject))] (|> count' - (logical-right-shift +2) (..and +3689348814741910323) (n/+ (..and +3689348814741910323 count')) - (add-shift +4) (..and +1085102592571150095) - (add-shift +8) - (add-shift +16) - (add-shift +32) - (..and +127)))) + (logical-right-shift |2) (..and |3689348814741910323) (n/+ (..and |3689348814741910323 count')) + (add-shift |4) (..and |1085102592571150095) + (add-shift |8) + (add-shift |16) + (add-shift |32) + (..and |127)))) (def: #export not {#.doc "Bitwise negation."} @@ -49,7 +49,7 @@ (def: (flag idx) (-> Nat I64) - (|> +1 (:coerce I64) (left-shift idx))) + (|> |1 (:coerce I64) (left-shift idx))) (def: #export (clear idx input) {#.doc "Clear bit at given index."} @@ -68,7 +68,7 @@ (def: #export (set? idx input) (-> Nat (I64 Any) Bit) - (|> input (:coerce I64) (..and (flag idx)) (n/= +0) .not)) + (|> input (:coerce I64) (..and (flag idx)) (n/= |0) .not)) (do-template [
] [(def: #export ( distance input) @@ -84,4 +84,4 @@ (def: #export (region size offset) (-> Nat Nat I64) - (|> +1 (:coerce I64) (left-shift size) dec (left-shift offset))) + (|> |1 (:coerce I64) (left-shift size) dec (left-shift offset))) diff --git a/stdlib/source/lux/data/number/ratio.lux b/stdlib/source/lux/data/number/ratio.lux index 0562dec72..b072a808a 100644 --- a/stdlib/source/lux/data/number/ratio.lux +++ b/stdlib/source/lux/data/number/ratio.lux @@ -123,14 +123,14 @@ #denominator numerator}) (def: abs id) (def: (signum x) - {#numerator +1 - #denominator +1})) + {#numerator |1 + #denominator |1})) (def: separator Text ":") (def: part-encode (-> Nat Text) - (|>> nat/encode (text.split +1) maybe.assume product.right)) + (|>> nat/encode (text.split |1) maybe.assume product.right)) (def: part-decode (-> Text (E.Error Nat)) @@ -158,5 +158,5 @@ "The denominator can be omitted if it's 1." (ratio numerator))} (wrap (list (` ((~! normalize) {#..numerator (~ numerator) - #..denominator (~ (maybe.default (' +1) + #..denominator (~ (maybe.default (' |1) ?denominator))}))))) diff --git a/stdlib/source/lux/data/sum.lux b/stdlib/source/lux/data/sum.lux index 670951182..24704c3c0 100644 --- a/stdlib/source/lux/data/sum.lux +++ b/stdlib/source/lux/data/sum.lux @@ -7,8 +7,8 @@ (All [a b] (-> (| a b))) ( value))] - [left a +0] - [right b +1]) + [left a |0] + [right b |1]) (def: #export (either fl fr) (All [a b c] @@ -16,8 +16,8 @@ (-> (| a b) c))) (function (_ input) (case input - (+0 l) (fl l) - (+1 r) (fr r)))) + (|0 l) (fl l) + (|1 r) (fr r)))) (def: #export (each fl fr) (All [l l' r r'] @@ -25,8 +25,8 @@ (-> (| l r) (| l' r')))) (function (_ input) (case input - (+0 l) (+0 (fl l)) - (+1 r) (+1 (fr r))))) + (|0 l) (|0 (fl l)) + (|1 r) (|1 (fr r))))) (do-template [ ] [(def: #export ( es) @@ -36,8 +36,8 @@ (#.Cons ( x) es') (#.Cons [x ( es')]) (#.Cons _ es') ( es')))] - [lefts a +0] - [rights b +1] + [lefts a |0] + [rights b |1] ) (def: #export (partition xs) @@ -49,5 +49,5 @@ (#.Cons x xs') (let [[lefts rights] (partition xs')] (case x - (+0 x') [(#.Cons x' lefts) rights] - (+1 x') [lefts (#.Cons x' rights)])))) + (|0 x') [(#.Cons x' lefts) rights] + (|1 x') [lefts (#.Cons x' rights)])))) diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux index 28679b429..f5462e4e7 100644 --- a/stdlib/source/lux/data/text.lux +++ b/stdlib/source/lux/data/text.lux @@ -30,7 +30,7 @@ (def: #export (index-of pattern input) (-> Text Text (Maybe Nat)) - ("lux text index" input pattern +0)) + ("lux text index" input pattern |0)) (def: (last-index-of'' part since text) (-> Text Nat Text (Maybe Nat)) @@ -52,7 +52,7 @@ (def: #export (last-index-of part text) (-> Text Text (Maybe Nat)) - (case ("lux text index" text part +0) + (case ("lux text index" text part |0) (#.Some since) (last-index-of'' part since text) @@ -62,7 +62,7 @@ (def: #export (starts-with? prefix x) (-> Text Text Bit) (case (index-of prefix x) - (#.Some +0) + (#.Some |0) #1 _ @@ -80,7 +80,7 @@ (def: #export (contains? sub text) (-> Text Text Bit) - (case ("lux text index" text sub +0) + (case ("lux text index" text sub |0) (#.Some _) #1 @@ -97,7 +97,7 @@ (def: #export (split at x) (-> Nat Text (Maybe [Text Text])) - (case [(..clip +0 at x) (..clip' at x)] + (case [(..clip |0 at x) (..clip' at x)] [(#.Some pre) (#.Some post)] (#.Some [pre post]) @@ -179,13 +179,13 @@ (:coerce Nat))} ## Platform-independent default. (let [length ("lux text size" input)] - (loop [idx +0 - hash +0] + (loop [idx |0 + hash |0] (if (n/< length idx) - (let [char (|> idx ("lux text char" input) (maybe.default +0))] + (let [char (|> idx ("lux text char" input) (maybe.default |0))] (recur (inc idx) (|> hash - (i64.left-shift +5) + (i64.left-shift |5) (n/- hash) (n/+ char)))) hash))))))) diff --git a/stdlib/source/lux/data/text/buffer.lux b/stdlib/source/lux/data/text/buffer.lux index f8042abc0..af9d14efc 100644 --- a/stdlib/source/lux/data/text/buffer.lux +++ b/stdlib/source/lux/data/text/buffer.lux @@ -34,7 +34,7 @@ (def: #export empty Buffer (:abstraction (for {(~~ (static _.jvm)) - [+0 id]} + [|0 id]} ## default row.empty))) @@ -59,7 +59,7 @@ ## default (row/fold (function (_ chunk total) (n/+ (//.size chunk) total)) - +0 + |0 (:representation buffer)))) (def: #export (text buffer) diff --git a/stdlib/source/lux/data/text/lexer.lux b/stdlib/source/lux/data/text/lexer.lux index 6e16ee6ec..14afb4254 100644 --- a/stdlib/source/lux/data/text/lexer.lux +++ b/stdlib/source/lux/data/text/lexer.lux @@ -15,7 +15,7 @@ (type: Offset Nat) -(def: start-offset Offset +0) +(def: start-offset Offset |0) (type: #export Lexer (p.Parser [Offset Text])) @@ -126,7 +126,7 @@ (-> Nat Nat (Lexer Text)) (do p.Monad [char any - #let [char' (maybe.assume (text.nth +0 char))] + #let [char' (maybe.assume (text.nth |0 char))] _ (p.assert ($_ text/compose "Character is not within range: " (text.from-code bottom) "-" (text.from-code top)) (.and (n/>= bottom char') (n/<= top char')))] diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux index 2e4087b23..3cb65dd14 100644 --- a/stdlib/source/lux/data/text/regex.lux +++ b/stdlib/source/lux/data/text/regex.lux @@ -81,9 +81,9 @@ (def: re-range^ (l.Lexer Code) (do p.Monad - [from (|> regex-char^ (:: @ map (|>> (text.nth +0) maybe.assume))) + [from (|> regex-char^ (:: @ map (|>> (text.nth |0) maybe.assume))) _ (l.this "-") - to (|> regex-char^ (:: @ map (|>> (text.nth +0) maybe.assume)))] + to (|> regex-char^ (:: @ map (|>> (text.nth |0) maybe.assume)))] (wrap (` (l.range (~ (code.nat from)) (~ (code.nat to))))))) (def: re-char^ @@ -289,7 +289,7 @@ #.None [(inc idx) (code.identifier ["" (int/encode idx)])]) - access (if (n/> +0 num-captures) + access (if (n/> |0 num-captures) (` ((~! product.left) (~ name!))) name!)] [idx! @@ -304,7 +304,7 @@ parts)]] (wrap [(if capturing? (list.size names) - +0) + |0) (` (do p.Monad [(~ (' #let)) [(~ g!total) ""] (~+ (|> steps list.reverse list/join))] @@ -320,12 +320,12 @@ (function (_ input) (case (left input) (#e.Success [input' [lt lv]]) - (#e.Success [input' [lt (+0 lv)]]) + (#e.Success [input' [lt (|0 lv)]]) (#e.Error _) (case (right input) (#e.Success [input' [rt rv]]) - (#e.Success [input' [rt (+1 rv)]]) + (#e.Success [input' [rt (|1 rv)]]) (#e.Error error) (#e.Error error))))) @@ -347,7 +347,7 @@ (def: (prep-alternative [num-captures alt]) (-> [Nat Code] Code) - (if (n/> +0 num-captures) + (if (n/> |0 num-captures) alt (` ((~! unflatten^) (~ alt))))) diff --git a/stdlib/source/lux/data/text/unicode.lux b/stdlib/source/lux/data/text/unicode.lux index c9796158d..96f16052a 100644 --- a/stdlib/source/lux/data/text/unicode.lux +++ b/stdlib/source/lux/data/text/unicode.lux @@ -59,128 +59,128 @@ (do-template [ ] [(def: #export Segment (..segment (hex ) (hex )))] - [basic-latin "+0000" "+007F"] - [latin-1-supplement "+00A0" "+00FF"] - [latin-extended-a "+0100" "+017F"] - [latin-extended-b "+0180" "+024F"] - [ipa-extensions "+0250" "+02AF"] - [spacing-modifier-letters "+02B0" "+02FF"] - [combining-diacritical-marks "+0300" "+036F"] - [greek-and-coptic "+0370" "+03FF"] - [cyrillic "+0400" "+04FF"] - [cyrillic-supplementary "+0500" "+052F"] - [armenian "+0530" "+058F"] - [hebrew "+0590" "+05FF"] - [arabic "+0600" "+06FF"] - [syriac "+0700" "+074F"] - [thaana "+0780" "+07BF"] - [devanagari "+0900" "+097F"] - [bengali "+0980" "+09FF"] - [gurmukhi "+0A00" "+0A7F"] - [gujarati "+0A80" "+0AFF"] - [oriya "+0B00" "+0B7F"] - [tamil "+0B80" "+0BFF"] - [telugu "+0C00" "+0C7F"] - [kannada "+0C80" "+0CFF"] - [malayalam "+0D00" "+0D7F"] - [sinhala "+0D80" "+0DFF"] - [thai "+0E00" "+0E7F"] - [lao "+0E80" "+0EFF"] - [tibetan "+0F00" "+0FFF"] - [myanmar "+1000" "+109F"] - [georgian "+10A0" "+10FF"] - [hangul-jamo "+1100" "+11FF"] - [ethiopic "+1200" "+137F"] - [cherokee "+13A0" "+13FF"] - [unified-canadian-aboriginal-syllabics "+1400" "+167F"] - [ogham "+1680" "+169F"] - [runic "+16A0" "+16FF"] - [tagalog "+1700" "+171F"] - [hanunoo "+1720" "+173F"] - [buhid "+1740" "+175F"] - [tagbanwa "+1760" "+177F"] - [khmer "+1780" "+17FF"] - [mongolian "+1800" "+18AF"] - [limbu "+1900" "+194F"] - [tai-le "+1950" "+197F"] - [khmer-symbols "+19E0" "+19FF"] - [phonetic-extensions "+1D00" "+1D7F"] - [latin-extended-additional "+1E00" "+1EFF"] - [greek-extended "+1F00" "+1FFF"] - [general-punctuation "+2000" "+206F"] - [superscripts-and-subscripts "+2070" "+209F"] - [currency-symbols "+20A0" "+20CF"] - [combining-diacritical-marks-for-symbols "+20D0" "+20FF"] - [letterlike-symbols "+2100" "+214F"] - [number-forms "+2150" "+218F"] - [arrows "+2190" "+21FF"] - [mathematical-operators "+2200" "+22FF"] - [miscellaneous-technical "+2300" "+23FF"] - [control-pictures "+2400" "+243F"] - [optical-character-recognition "+2440" "+245F"] - [enclosed-alphanumerics "+2460" "+24FF"] - [box-drawing "+2500" "+257F"] - [block-elements "+2580" "+259F"] - [geometric-shapes "+25A0" "+25FF"] - [miscellaneous-symbols "+2600" "+26FF"] - [dingbats "+2700" "+27BF"] - [miscellaneous-mathematical-symbols-a "+27C0" "+27EF"] - [supplemental-arrows-a "+27F0" "+27FF"] - [braille-patterns "+2800" "+28FF"] - [supplemental-arrows-b "+2900" "+297F"] - [miscellaneous-mathematical-symbols-b "+2980" "+29FF"] - [supplemental-mathematical-operators "+2A00" "+2AFF"] - [miscellaneous-symbols-and-arrows "+2B00" "+2BFF"] - [cjk-radicals-supplement "+2E80" "+2EFF"] - [kangxi-radicals "+2F00" "+2FDF"] - [ideographic-description-characters "+2FF0" "+2FFF"] - [cjk-symbols-and-punctuation "+3000" "+303F"] - [hiragana "+3040" "+309F"] - [katakana "+30A0" "+30FF"] - [bopomofo "+3100" "+312F"] - [hangul-compatibility-jamo "+3130" "+318F"] - [kanbun "+3190" "+319F"] - [bopomofo-extended "+31A0" "+31BF"] - [katakana-phonetic-extensions "+31F0" "+31FF"] - [enclosed-cjk-letters-and-months "+3200" "+32FF"] - [cjk-compatibility "+3300" "+33FF"] - [cjk-unified-ideographs-extension-a "+3400" "+4DBF"] - [yijing-hexagram-symbols "+4DC0" "+4DFF"] - [cjk-unified-ideographs "+4E00" "+9FFF"] - [yi-syllables "+A000" "+A48F"] - [yi-radicals "+A490" "+A4CF"] - [hangul-syllables "+AC00" "+D7AF"] - [high-surrogates "+D800" "+DB7F"] - [high-private-use-surrogates "+DB80" "+DBFF"] - [low-surrogates "+DC00" "+DFFF"] - [private-use-area "+E000" "+F8FF"] - [cjk-compatibility-ideographs "+F900" "+FAFF"] - [alphabetic-presentation-forms "+FB00" "+FB4F"] - [arabic-presentation-forms-a "+FB50" "+FDFF"] - [variation-selectors "+FE00" "+FE0F"] - [combining-half-marks "+FE20" "+FE2F"] - [cjk-compatibility-forms "+FE30" "+FE4F"] - [small-form-variants "+FE50" "+FE6F"] - [arabic-presentation-forms-b "+FE70" "+FEFF"] - [halfwidth-and-fullwidth-forms "+FF00" "+FFEF"] - [specials "+FFF0" "+FFFF"] - [linear-b-syllabary "+10000" "+1007F"] - [linear-b-ideograms "+10080" "+100FF"] - [aegean-numbers "+10100" "+1013F"] - [old-italic "+10300" "+1032F"] - [gothic "+10330" "+1034F"] - [ugaritic "+10380" "+1039F"] - [deseret "+10400" "+1044F"] - [shavian "+10450" "+1047F"] - [osmanya "+10480" "+104AF"] - [cypriot-syllabary "+10800" "+1083F"] - [byzantine-musical-symbols "+1D000" "+1D0FF"] - [musical-symbols "+1D100" "+1D1FF"] - [tai-xuan-jing-symbols "+1D300" "+1D35F"] - [mathematical-alphanumeric-symbols "+1D400" "+1D7FF"] - [cjk-unified-ideographs-extension-b "+20000" "+2A6DF"] - [cjk-compatibility-ideographs-supplement "+2F800" "+2FA1F"] - [tags "+E0000" "+E007F"] + [basic-latin "|0000" "|007F"] + [latin-1-supplement "|00A0" "|00FF"] + [latin-extended-a "|0100" "|017F"] + [latin-extended-b "|0180" "|024F"] + [ipa-extensions "|0250" "|02AF"] + [spacing-modifier-letters "|02B0" "|02FF"] + [combining-diacritical-marks "|0300" "|036F"] + [greek-and-coptic "|0370" "|03FF"] + [cyrillic "|0400" "|04FF"] + [cyrillic-supplementary "|0500" "|052F"] + [armenian "|0530" "|058F"] + [hebrew "|0590" "|05FF"] + [arabic "|0600" "|06FF"] + [syriac "|0700" "|074F"] + [thaana "|0780" "|07BF"] + [devanagari "|0900" "|097F"] + [bengali "|0980" "|09FF"] + [gurmukhi "|0A00" "|0A7F"] + [gujarati "|0A80" "|0AFF"] + [oriya "|0B00" "|0B7F"] + [tamil "|0B80" "|0BFF"] + [telugu "|0C00" "|0C7F"] + [kannada "|0C80" "|0CFF"] + [malayalam "|0D00" "|0D7F"] + [sinhala "|0D80" "|0DFF"] + [thai "|0E00" "|0E7F"] + [lao "|0E80" "|0EFF"] + [tibetan "|0F00" "|0FFF"] + [myanmar "|1000" "|109F"] + [georgian "|10A0" "|10FF"] + [hangul-jamo "|1100" "|11FF"] + [ethiopic "|1200" "|137F"] + [cherokee "|13A0" "|13FF"] + [unified-canadian-aboriginal-syllabics "|1400" "|167F"] + [ogham "|1680" "|169F"] + [runic "|16A0" "|16FF"] + [tagalog "|1700" "|171F"] + [hanunoo "|1720" "|173F"] + [buhid "|1740" "|175F"] + [tagbanwa "|1760" "|177F"] + [khmer "|1780" "|17FF"] + [mongolian "|1800" "|18AF"] + [limbu "|1900" "|194F"] + [tai-le "|1950" "|197F"] + [khmer-symbols "|19E0" "|19FF"] + [phonetic-extensions "|1D00" "|1D7F"] + [latin-extended-additional "|1E00" "|1EFF"] + [greek-extended "|1F00" "|1FFF"] + [general-punctuation "|2000" "|206F"] + [superscripts-and-subscripts "|2070" "|209F"] + [currency-symbols "|20A0" "|20CF"] + [combining-diacritical-marks-for-symbols "|20D0" "|20FF"] + [letterlike-symbols "|2100" "|214F"] + [number-forms "|2150" "|218F"] + [arrows "|2190" "|21FF"] + [mathematical-operators "|2200" "|22FF"] + [miscellaneous-technical "|2300" "|23FF"] + [control-pictures "|2400" "|243F"] + [optical-character-recognition "|2440" "|245F"] + [enclosed-alphanumerics "|2460" "|24FF"] + [box-drawing "|2500" "|257F"] + [block-elements "|2580" "|259F"] + [geometric-shapes "|25A0" "|25FF"] + [miscellaneous-symbols "|2600" "|26FF"] + [dingbats "|2700" "|27BF"] + [miscellaneous-mathematical-symbols-a "|27C0" "|27EF"] + [supplemental-arrows-a "|27F0" "|27FF"] + [braille-patterns "|2800" "|28FF"] + [supplemental-arrows-b "|2900" "|297F"] + [miscellaneous-mathematical-symbols-b "|2980" "|29FF"] + [supplemental-mathematical-operators "|2A00" "|2AFF"] + [miscellaneous-symbols-and-arrows "|2B00" "|2BFF"] + [cjk-radicals-supplement "|2E80" "|2EFF"] + [kangxi-radicals "|2F00" "|2FDF"] + [ideographic-description-characters "|2FF0" "|2FFF"] + [cjk-symbols-and-punctuation "|3000" "|303F"] + [hiragana "|3040" "|309F"] + [katakana "|30A0" "|30FF"] + [bopomofo "|3100" "|312F"] + [hangul-compatibility-jamo "|3130" "|318F"] + [kanbun "|3190" "|319F"] + [bopomofo-extended "|31A0" "|31BF"] + [katakana-phonetic-extensions "|31F0" "|31FF"] + [enclosed-cjk-letters-and-months "|3200" "|32FF"] + [cjk-compatibility "|3300" "|33FF"] + [cjk-unified-ideographs-extension-a "|3400" "|4DBF"] + [yijing-hexagram-symbols "|4DC0" "|4DFF"] + [cjk-unified-ideographs "|4E00" "|9FFF"] + [yi-syllables "|A000" "|A48F"] + [yi-radicals "|A490" "|A4CF"] + [hangul-syllables "|AC00" "|D7AF"] + [high-surrogates "|D800" "|DB7F"] + [high-private-use-surrogates "|DB80" "|DBFF"] + [low-surrogates "|DC00" "|DFFF"] + [private-use-area "|E000" "|F8FF"] + [cjk-compatibility-ideographs "|F900" "|FAFF"] + [alphabetic-presentation-forms "|FB00" "|FB4F"] + [arabic-presentation-forms-a "|FB50" "|FDFF"] + [variation-selectors "|FE00" "|FE0F"] + [combining-half-marks "|FE20" "|FE2F"] + [cjk-compatibility-forms "|FE30" "|FE4F"] + [small-form-variants "|FE50" "|FE6F"] + [arabic-presentation-forms-b "|FE70" "|FEFF"] + [halfwidth-and-fullwidth-forms "|FF00" "|FFEF"] + [specials "|FFF0" "|FFFF"] + [linear-b-syllabary "|10000" "|1007F"] + [linear-b-ideograms "|10080" "|100FF"] + [aegean-numbers "|10100" "|1013F"] + [old-italic "|10300" "|1032F"] + [gothic "|10330" "|1034F"] + [ugaritic "|10380" "|1039F"] + [deseret "|10400" "|1044F"] + [shavian "|10450" "|1047F"] + [osmanya "|10480" "|104AF"] + [cypriot-syllabary "|10800" "|1083F"] + [byzantine-musical-symbols "|1D000" "|1D0FF"] + [musical-symbols "|1D100" "|1D1FF"] + [tai-xuan-jing-symbols "|1D300" "|1D35F"] + [mathematical-alphanumeric-symbols "|1D400" "|1D7FF"] + [cjk-unified-ideographs-extension-b "|20000" "|2A6DF"] + [cjk-compatibility-ideographs-supplement "|2F800" "|2FA1F"] + [tags "|E0000" "|E007F"] ) (type: #export Set (Tree Segment [])) @@ -203,7 +203,7 @@ (..singleton (:: Monoid compose left right)) _ - (let [[sides extra] (n//% +2 (list.size segments)) + (let [[sides extra] (n//% |2 (list.size segments)) [left+ right+] (list.split (n/+ sides extra) segments)] (finger.branch (set left+) (set right+))))) diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux index cd0eaafed..767a4976f 100644 --- a/stdlib/source/lux/host.jvm.lux +++ b/stdlib/source/lux/host.jvm.lux @@ -1921,7 +1921,7 @@ {type (generic-type^ imports (list))} size) {#.doc (doc "Create an array of the given type, with the given size." - (array Object +10))} + (array Object |10))} (case type (^template [ ] (^ (#GenericClass (list))) @@ -1967,7 +1967,7 @@ (syntax: #export (array-read idx array) {#.doc (doc "Loads an element from an array." - (array-read +10 my-array))} + (array-read |10 my-array))} (case array [_ (#.Identifier array-name)] (do Monad @@ -1996,7 +1996,7 @@ (syntax: #export (array-write idx value array) {#.doc (doc "Stores an element into an array." - (array-write +10 my-object my-array))} + (array-write |10 my-object my-array))} (case array [_ (#.Identifier array-name)] (do Monad diff --git a/stdlib/source/lux/io.lux b/stdlib/source/lux/io.lux index f772f60fa..ed277b4c3 100644 --- a/stdlib/source/lux/io.lux +++ b/stdlib/source/lux/io.lux @@ -21,7 +21,7 @@ "Some value...")))} (case tokens (^ (list value)) - (let [blank (: Code [["" +0 +0] (#.Identifier ["" ""])])] + (let [blank (: Code [["" |0 |0] (#.Identifier ["" ""])])] (#.Right [state (list (` ([(~ blank) (~ blank)] (~ value))))])) _ diff --git a/stdlib/source/lux/macro/code.lux b/stdlib/source/lux/macro/code.lux index f6896343c..0de1e5772 100644 --- a/stdlib/source/lux/macro/code.lux +++ b/stdlib/source/lux/macro/code.lux @@ -27,7 +27,7 @@ ## (Ann Cursor (Code' (Ann Cursor)))) ## [Utils] -(def: _cursor Cursor ["" +0 +0]) +(def: _cursor Cursor ["" |0 |0]) ## [Functions] (do-template [ ] diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux index 97ec08ff7..9be5a2ad4 100644 --- a/stdlib/source/lux/macro/poly.lux +++ b/stdlib/source/lux/macro/poly.lux @@ -153,7 +153,7 @@ (do p.Monad [headT any] (let [members ( (type.un-name headT))] - (if (n/> +1 (list.size members)) + (if (n/> |1 (list.size members)) (local members poly) (p.fail (ex.construct headT))))))] @@ -166,7 +166,7 @@ (do p.Monad [headT any #let [[num-arg bodyT] (type.flatten-univ-q (type.un-name headT))]] - (if (n/= +0 num-arg) + (if (n/= |0 num-arg) (p.fail (ex.construct not-polymorphic headT)) (wrap [num-arg bodyT])))) @@ -178,22 +178,22 @@ [num-args non-poly] (local (list headT) polymorphic') env ..env #let [funcL (label funcI) - [all-varsL env'] (loop [current-arg +0 + [all-varsL env'] (loop [current-arg |0 env' env all-varsL (: (List Code) (list))] (if (n/< num-args current-arg) - (if (n/= +0 current-arg) + (if (n/= |0 current-arg) (let [varL (label (inc funcI))] (recur (inc current-arg) (|> env' (dict.put funcI [headT funcL]) (dict.put (inc funcI) [(#.Parameter (inc funcI)) varL])) (#.Cons varL all-varsL))) - (let [partialI (|> current-arg (n/* +2) (n/+ funcI)) + (let [partialI (|> current-arg (n/* |2) (n/+ funcI)) partial-varI (inc partialI) partial-varL (label partial-varI) - partialC (` ((~ funcL) (~+ (|> (list.n/range +0 (dec num-args)) - (list/map (|>> (n/* +2) inc (n/+ funcI) label)) + partialC (` ((~ funcL) (~+ (|> (list.n/range |0 (dec num-args)) + (list/map (|>> (n/* |2) inc (n/+ funcI) label)) list.reverse))))] (recur (inc current-arg) (|> env' @@ -212,7 +212,7 @@ (do p.Monad [headT any #let [[inputsT outputT] (type.flatten-function (type.un-name headT))]] - (if (n/> +0 (list.size inputsT)) + (if (n/> |0 (list.size inputsT)) (p.and (local inputsT in-poly) (local (list outputT) out-poly)) (p.fail (ex.construct not-function headT))))) @@ -222,7 +222,7 @@ (do p.Monad [headT any #let [[funcT paramsT] (type.flatten-application (type.un-name headT))]] - (if (n/= +0 (list.size paramsT)) + (if (n/= |0 (list.size paramsT)) (p.fail (ex.construct not-application headT)) (local (#.Cons funcT paramsT) poly)))) @@ -242,10 +242,10 @@ (def: (adjusted-idx env idx) (-> Env Nat Nat) - (let [env-level (n// +2 (dict.size env)) - parameter-level (n// +2 idx) - parameter-idx (n/% +2 idx)] - (|> env-level dec (n/- parameter-level) (n/* +2) (n/+ parameter-idx)))) + (let [env-level (n// |2 (dict.size env)) + parameter-level (n// |2 idx) + parameter-idx (n/% |2 idx)] + (|> env-level dec (n/- parameter-level) (n/* |2) (n/+ parameter-idx)))) (def: #export parameter (Poly Code) @@ -323,8 +323,8 @@ headT any] (case (type.un-name headT) (^multi (#.Apply (#.Named ["lux" "Nothing"] _) (#.Parameter funcT-idx)) - (n/= +0 (adjusted-idx env funcT-idx)) - [(dict.get +0 env) (#.Some [self-type self-call])]) + (n/= |0 (adjusted-idx env funcT-idx)) + [(dict.get |0 env) (#.Some [self-type self-call])]) (wrap self-call) _ @@ -335,7 +335,7 @@ (do p.Monad [env ..env [funcT argsT] (apply (p.and any (p.many any))) - _ (local (list funcT) (..parameter! +0)) + _ (local (list funcT) (..parameter! |0)) allC (let [allT (list& funcT argsT)] (|> allT (monad.map @ (function.constant ..parameter)) @@ -425,13 +425,13 @@ (#.Parameter idx) (let [idx (adjusted-idx env idx)] - (if (n/= +0 idx) + (if (n/= |0 idx) (|> (dict.get idx env) maybe.assume product.left (to-code env)) (` (.$ (~ (code.nat (dec idx))))))) (#.Apply (#.Named ["lux" "Nothing"] _) (#.Parameter idx)) (let [idx (adjusted-idx env idx)] - (if (n/= +0 idx) + (if (n/= |0 idx) (|> (dict.get idx env) maybe.assume product.left (to-code env)) (undefined))) diff --git a/stdlib/source/lux/macro/poly/equivalence.lux b/stdlib/source/lux/macro/poly/equivalence.lux index cb9280506..6f356c060 100644 --- a/stdlib/source/lux/macro/poly/equivalence.lux +++ b/stdlib/source/lux/macro/poly/equivalence.lux @@ -116,7 +116,7 @@ (do @ [g!eqs (poly.tuple (p.many Equivalence)) #let [g!_ (code.local-identifier "_____________") - indices (|> (list.size g!eqs) dec (list.n/range +0)) + indices (|> (list.size g!eqs) dec (list.n/range |0)) g!lefts (list/map (|>> nat/encode (text/compose "left") code.local-identifier) indices) g!rights (list/map (|>> nat/encode (text/compose "right") code.local-identifier) indices)]] (wrap (` (: (~ (@Equivalence inputT)) diff --git a/stdlib/source/lux/macro/poly/functor.lux b/stdlib/source/lux/macro/poly/functor.lux index d28e98337..711179404 100644 --- a/stdlib/source/lux/macro/poly/functor.lux +++ b/stdlib/source/lux/macro/poly/functor.lux @@ -29,7 +29,7 @@ #let [num-vars (list.size varsC)] #let [@Functor (: (-> Type Code) (function (_ unwrappedT) - (if (n/= +1 num-vars) + (if (n/= |1 num-vars) (` ((~! functor.Functor) (~ (poly.to-code *env* unwrappedT)))) (let [paramsC (|> num-vars dec list.indices (list/map (|>> %n code.local-identifier)))] (` (All [(~+ paramsC)] @@ -39,7 +39,7 @@ ($_ p.either ## Type-var (do p.Monad - [#let [varI (|> num-vars (n/* +2) dec)] + [#let [varI (|> num-vars (n/* |2) dec)] _ (poly.parameter! varI)] (wrap (` ((~ funcC) (~ valueC))))) ## Variants @@ -54,7 +54,7 @@ ## Tuples (do p.Monad [pairsCC (: (poly.Poly (List [Code Code])) - (poly.tuple (loop [idx +0 + (poly.tuple (loop [idx |0 pairsCC (: (List [Code Code]) (list))] (p.either (let [slotC (|> idx %n (format "____________slot") code.local-identifier)] @@ -75,7 +75,7 @@ [inT+ outC] (poly.function (p.many poly.any) (Arg outL)) #let [inC+ (|> (list.size inT+) dec - (list.n/range +0) + (list.n/range |0) (list/map (|>> %n (format "____________inC") code.local-identifier)))]] (wrap (` (function ((~ g!) (~+ inC+)) (let [(~ outL) ((~ valueC) (~+ inC+))] diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/macro/poly/json.lux index 31ae2fdff..b9710773a 100644 --- a/stdlib/source/lux/macro/poly/json.lux +++ b/stdlib/source/lux/macro/poly/json.lux @@ -44,12 +44,12 @@ (function (_ input) (non-rec (rec-encode non-rec) input))) -(def: low-mask Nat (|> +1 (i64.left-shift +32) dec)) -(def: high-mask Nat (|> low-mask (i64.left-shift +32))) +(def: low-mask Nat (|> |1 (i64.left-shift |32) dec)) +(def: high-mask Nat (|> low-mask (i64.left-shift |32))) (structure: _ (Codec JSON Nat) (def: (encode input) - (let [high (|> input (i64.and high-mask) (i64.logical-right-shift +32)) + (let [high (|> input (i64.and high-mask) (i64.logical-right-shift |32)) low (i64.and low-mask input)] (#//.Array (row (|> high .int int-to-frac #//.Number) (|> low .int int-to-frac #//.Number))))) @@ -59,7 +59,7 @@ (do p.Monad [high //.number low //.number]) - (wrap (n/+ (|> high frac-to-int .nat (i64.left-shift +32)) + (wrap (n/+ (|> high frac-to-int .nat (i64.left-shift |32)) (|> low frac-to-int .nat)))))) (structure: _ (Codec JSON Int) @@ -164,7 +164,7 @@ [g!encoders (poly.tuple (p.many Codec//encode)) #let [g!_ (code.local-identifier "_______") g!members (|> (list.size g!encoders) dec - (list.n/range +0) + (list.n/range |0) (list/map (|>> nat/encode code.local-identifier)))]] (wrap (` (: (~ (@JSON//encode inputT)) (function ((~ g!_) [(~+ g!members)]) diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux index 499a83e3e..124320ce9 100644 --- a/stdlib/source/lux/math.lux +++ b/stdlib/source/lux/math.lux @@ -88,9 +88,9 @@ (def: #export (factorial n) (-> Nat Nat) - (loop [acc +1 + (loop [acc |1 n n] - (if (n/<= +1 n) + (if (n/<= |1 n) acc (recur (n/* n acc) (dec n))))) @@ -118,7 +118,7 @@ (|> a ( ( a b)) (<*> b)) ))] - [Nat n/mod n/gcd n/lcm +0 n/* n// n/-] + [Nat n/mod n/gcd n/lcm |0 n/* n// n/-] [Int i/mod i/gcd i/lcm 0 i/* i// i/-] ) @@ -251,7 +251,7 @@ (infix [sin [x i/+ y]]) (infix [[x n/< y] and [y n/< z]]) (infix [#and x n/< y n/< z]) - (infix [(n/* +3 +9) gcd +450]) + (infix [(n/* |3 |9) gcd |450]) "The rules for infix syntax are simple." "If you want your binary function to work well with it." diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux index 340cb1baa..1fc5c5476 100644 --- a/stdlib/source/lux/math/random.lux +++ b/stdlib/source/lux/math/random.lux @@ -88,7 +88,7 @@ (Random Bit) (function (_ prng) (let [[prng output] (prng [])] - [prng (|> output (i64.and +1) (n/= +1))]))) + [prng (|> output (i64.and |1) (n/= |1))]))) (def: #export i64 (Random I64) @@ -96,7 +96,7 @@ (let [[prng left] (prng []) [prng right] (prng [])] [prng (|> left - (i64.left-shift +32) + (i64.left-shift |32) ("lux i64 +" right))]))) (def: #export nat @@ -131,7 +131,7 @@ (def: #export (text char-gen size) (-> (Random Char) Nat (Random Text)) - (if (n/= +0 size) + (if (n/= |0 size) (:: Monad wrap "") (do Monad [x char-gen @@ -170,10 +170,10 @@ (if ? (do @ [=left left] - (wrap (+0 =left))) + (wrap (|0 =left))) (do @ [=right right] - (wrap (+1 =right)))))) + (wrap (|1 =right)))))) (def: #export (either left right) {#.doc "Homogeneous alternative combinator."} @@ -204,7 +204,7 @@ (do-template [ ] [(def: #export ( size value-gen) (All [a] (-> Nat (Random a) (Random ( a)))) - (if (n/> +0 size) + (if (n/> |0 size) (do Monad [x value-gen xs ( (dec size) value-gen)] @@ -229,7 +229,7 @@ (def: #export (set Hash size value-gen) (All [a] (-> (Hash a) Nat (Random a) (Random (Set a)))) - (if (n/> +0 size) + (if (n/> |0 size) (do Monad [xs (set Hash (dec size) value-gen)] (loop [_ []] @@ -243,7 +243,7 @@ (def: #export (dictionary Hash size key-gen value-gen) (All [k v] (-> (Hash k) Nat (Random k) (Random v) (Random (Dictionary k v)))) - (if (n/> +0 size) + (if (n/> |0 size) (do Monad [kv (dictionary Hash (dec size) key-gen value-gen)] (loop [_ []] @@ -260,7 +260,7 @@ (All [a] (-> PRNG (Random a) [PRNG a])) (calc prng)) -(def: pcg-32-magic-mult Nat +6364136223846793005) +(def: pcg-32-magic-mult Nat |6364136223846793005) (def: #export (pcg-32 [inc seed]) {#.doc "An implementation of the PCG32 algorithm. @@ -269,11 +269,11 @@ (-> [(I64 Any) (I64 Any)] PRNG) (function (_ _) [(|> seed .nat (n/* pcg-32-magic-mult) ("lux i64 +" inc) [inc] pcg-32) - (let [rot (|> seed .i64 (i64.logical-right-shift +59))] + (let [rot (|> seed .i64 (i64.logical-right-shift |59))] (|> seed - (i64.logical-right-shift +18) + (i64.logical-right-shift |18) (i64.xor seed) - (i64.logical-right-shift +27) + (i64.logical-right-shift |27) (i64.rotate-right rot) .i64))])) @@ -285,10 +285,10 @@ (function (_ _) [(let [s01 (i64.xor s0 s1)] (xoroshiro-128+ [(|> s0 - (i64.rotate-left +55) + (i64.rotate-left |55) (i64.xor s01) - (i64.xor (i64.left-shift +14 s01))) - (i64.rotate-left +36 s01)])) + (i64.xor (i64.left-shift |14 s01))) + (i64.rotate-left |36 s01)])) ("lux i64 +" s0 s1)])) (def: (swap from to vec) @@ -307,7 +307,7 @@ [rand nat] (wrap (swap idx (n/% _size rand) vec)))) row - (list.n/range +0 (dec _size)))] + (list.n/range |0 (dec _size)))] (|> _shuffle - (run (pcg-32 [+123 seed])) + (run (pcg-32 [|123 seed])) product.right))) diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux index 8bb0a71a3..f9ea42c2e 100644 --- a/stdlib/source/lux/test.lux +++ b/stdlib/source/lux/test.lux @@ -33,12 +33,12 @@ (type: #export Test (r.Random (Promise [Counters Text]))) -(def: pcg-32-magic-inc Nat +12345) +(def: pcg-32-magic-inc Nat |12345) ## [Values] -(def: success Counters [+1 +0]) -(def: failure Counters [+0 +1]) -(def: start Counters [+0 +0]) +(def: success Counters [|1 |0]) +(def: failure Counters [|0 |1]) +(def: start Counters [|0 |0]) (def: (add-counters [s f] [ts tf]) (-> Counters Counters Counters) @@ -87,7 +87,7 @@ (def: failed? (-> Counters Bit) - (|>> product.right (n/> +0))) + (|>> product.right (n/> |0))) (def: #export (seed value test) (-> Seed Test Test) @@ -103,10 +103,10 @@ (def: #export (times amount test) (-> Nat Test Test) - (cond (n/= +0 amount) + (cond (n/= |0 amount) (fail "Cannot try a test 0 times.") - (n/= +1 amount) + (n/= |1 amount) test ## else @@ -167,7 +167,7 @@ "By default, random tests will be tried 100 times, you can specify the amount you want:" (context: "Addition & Substraction" - (<| (times +1234) + (<| (times |1234) (do @ [x (:: @ map rand-gen) y (:: @ map rand-gen)] @@ -177,7 +177,7 @@ "If a test fails, you'll be shown a seed that you can then use to reproduce a failing scenario." (context: "Addition & Substraction" - (<| (seed +987654321) + (<| (seed |987654321) (do @ [x (:: @ map rand-gen) y (:: @ map rand-gen)] @@ -235,8 +235,8 @@ (:: @ map list/join)))] (wrap (list (` (: (~! (IO Any)) ((~! io) (exec ((~! do) (~! promise.Monad) - [(~' #let) [(~ g!total-successes) +0 - (~ g!total-failures) +0] + [(~' #let) [(~ g!total-successes) |0 + (~ g!total-failures) |0] (~+ (|> tests (list/map (function (_ [module-name test desc]) (` [(~ (code.text module-name)) (~ (code.identifier [module-name test])) (~ (code.text desc))]))) @@ -248,7 +248,7 @@ list/join))] (exec (log! ((~! success-message) (~ g!total-successes) (~ g!total-failures))) ((~! promise.future) - ((~! io.exit) (if (n/> +0 (~ g!total-failures)) + ((~! io.exit) (if (n/> |0 (~ g!total-failures)) 1 0))))) []))))))))) diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux index ca5ea55b4..d3306f826 100644 --- a/stdlib/source/lux/time/date.lux +++ b/stdlib/source/lux/time/date.lux @@ -57,18 +57,18 @@ (def: (month-to-nat month) (-> Month Nat) (case month - #January +0 - #February +1 - #March +2 - #April +3 - #May +4 - #June +5 - #July +6 - #August +7 - #September +8 - #October +9 - #November +10 - #December +11)) + #January |0 + #February |1 + #March |2 + #April |3 + #May |4 + #June |5 + #July |6 + #August |7 + #September |8 + #October |9 + #November |10 + #December |11)) (structure: #export _ (Order Month) (def: eq Equivalence) @@ -142,13 +142,13 @@ (def: (day-to-nat day) (-> Day Nat) (case day - #Sunday +0 - #Monday +1 - #Tuesday +2 - #Wednesday +3 - #Thursday +4 - #Friday +5 - #Saturday +6)) + #Sunday |0 + #Monday |1 + #Tuesday |2 + #Wednesday |3 + #Thursday |4 + #Friday |5 + #Saturday |6)) (structure: #export _ (Order Day) (def: eq Equivalence) @@ -246,7 +246,7 @@ (def: lex-section (l.Lexer Int) - (p.codec number.Codec (l.exactly +2 l.decimal))) + (p.codec number.Codec (l.exactly |2 l.decimal))) (def: (leap-years year) (-> Int Int) @@ -256,14 +256,14 @@ (def: normal-months (Row Nat) - (row +31 +28 +31 - +30 +31 +30 - +31 +31 +30 - +31 +30 +31)) + (row |31 |28 |31 + |30 |31 |30 + |31 |31 |30 + |31 |30 |31)) (def: leap-year-months (Row Nat) - (row.update [+1] inc normal-months)) + (row.update [|1] inc normal-months)) (def: (divisible? factor input) (-> Int Int Bit) diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux index ea834391e..427f4883e 100644 --- a/stdlib/source/lux/time/instant.lux +++ b/stdlib/source/lux/time/instant.lux @@ -108,14 +108,14 @@ (def: normal-months (Row Nat) - (row +31 +28 +31 - +30 +31 +30 - +31 +31 +30 - +31 +30 +31)) + (row |31 |28 |31 + |30 |31 |30 + |31 |31 |30 + |31 |30 |31)) (def: leap-year-months (Row Nat) - (row.update [+1] inc normal-months)) + (row.update [|1] inc normal-months)) (def: (find-month months time) (-> (Row Nat) duration.Duration [Nat duration.Duration]) @@ -125,14 +125,14 @@ (if (i/= 0 (duration.query month-duration time-left)) [current-month time-left] [(inc current-month) (duration.merge (duration.scale -1 month-duration) time-left)]))) - [+0 time] + [|0 time] months) (row/fold (function (_ month-days [current-month time-left]) (let [month-duration (duration.scale (.int month-days) duration.day)] (if (i/= 0 (duration.query month-duration time-left)) [current-month time-left] [(dec current-month) (duration.merge month-duration time-left)]))) - [+11 time] + [|11 time] (row.reverse months)))) (def: (pad value) @@ -227,11 +227,11 @@ (def: lex-section (l.Lexer Int) - (p.codec number.Codec (l.exactly +2 l.decimal))) + (p.codec number.Codec (l.exactly |2 l.decimal))) (def: lex-millis (l.Lexer Int) - (p.either (|> (l.at-most +3 l.decimal) + (p.either (|> (l.at-most |3 l.decimal) (p.codec number.Codec) (p.after (l.this "."))) (:: p.Monad wrap 0))) @@ -288,7 +288,7 @@ month-days-so-far (|> months row.to-list (list.take (.nat (dec utc-month))) - (list/fold n/+ +0)) + (list/fold n/+ |0)) total-days (|> year-days-so-far (i/+ (.int month-days-so-far)) (i/+ (dec utc-day)))]] diff --git a/stdlib/source/lux/type.lux b/stdlib/source/lux/type.lux index 376d40d67..851039728 100644 --- a/stdlib/source/lux/type.lux +++ b/stdlib/source/lux/type.lux @@ -93,7 +93,7 @@ (do-template [ ] [(def: #export ( type) (-> Type [Nat Type]) - (loop [num-args +0 + (loop [num-args |0 type type] (case type ( env sub-type) @@ -305,7 +305,7 @@ [(def: #export ( size body) (-> Nat Type Type) (case size - +0 body + |0 body _ (|> body ( (dec size)) ( (list)))))] [univ-q #.UnivQ] @@ -333,7 +333,7 @@ (def: #export (array level elem-type) (-> Nat Type Type) (case level - +0 elem-type + |0 elem-type _ (|> elem-type (array (dec level)) (list) (#.Primitive "#Array")))) (syntax: #export (:log! {input (p.or s.identifier diff --git a/stdlib/source/lux/type/check.lux b/stdlib/source/lux/type/check.lux index 7e77b0bb6..f09b8617b 100644 --- a/stdlib/source/lux/type/check.lux +++ b/stdlib/source/lux/type/check.lux @@ -298,8 +298,8 @@ (def: #export fresh-context Type-Context - {#.var-counter +0 - #.ex-counter +0 + {#.var-counter |0 + #.ex-counter |0 #.var-bindings (list) }) @@ -357,7 +357,7 @@ then) (do Monad [ring (ring id) - _ (assert "" (n/> +1 (set.size ring))) + _ (assert "" (n/> |1 (set.size ring))) _ (monad.map @ (update type) (set.to-list ring))] then) (do Monad diff --git a/stdlib/source/lux/type/implicit.lux b/stdlib/source/lux/type/implicit.lux index 91de1058e..fad0bfb5d 100644 --- a/stdlib/source/lux/type/implicit.lux +++ b/stdlib/source/lux/type/implicit.lux @@ -65,12 +65,12 @@ (find-member-type idx sig-type')) (#.Product left right) - (if (n/= +0 idx) + (if (n/= |0 idx) (:: check.Monad wrap left) (find-member-type (dec idx) right)) _ - (if (n/= +0 idx) + (if (n/= |0 idx) (:: check.Monad wrap sig-type) (check.fail (format "Cannot find member type " (%n idx) " for " (%type sig-type)))))) @@ -326,10 +326,10 @@ (::: eq.= x y) "(List Nat) equivalence" (::: = - (list.n/range +1 +10) - (list.n/range +1 +10)) + (list.n/range |1 |10) + (list.n/range |1 |10)) "(Functor List) map" - (::: map inc (list.n/range +0 +9)) + (::: map inc (list.n/range |0 |9)) "Caveat emptor: You need to make sure to import the module of any structure you want to use." "Otherwise, this macro will not find it.")} (case args diff --git a/stdlib/source/lux/type/resource.lux b/stdlib/source/lux/type/resource.lux index 68d0410dd..0912c2482 100644 --- a/stdlib/source/lux/type/resource.lux +++ b/stdlib/source/lux/type/resource.lux @@ -185,7 +185,7 @@ (do p.Monad [raw s.nat _ (p.assert (ex.construct amount-cannot-be-zero []) - (n/> +0 raw))] + (n/> |0 raw))] (wrap raw))) (do-template [ ] diff --git a/stdlib/source/lux/world/binary.lux b/stdlib/source/lux/world/binary.lux index d89b7ae3a..0b72af60b 100644 --- a/stdlib/source/lux/world/binary.lux +++ b/stdlib/source/lux/world/binary.lux @@ -30,7 +30,7 @@ (def: byte-mask I64 - (|> +1 (i64.left-shift +8) dec .i64)) + (|> |1 (i64.left-shift |8) dec .i64)) (def: i64 (-> (primitive "java.lang.Byte") I64) @@ -52,34 +52,34 @@ (def: #export (read/16 idx binary) (-> Nat Binary (Error I64)) - (if (n/< (host.array-length binary) (n/+ +1 idx)) + (if (n/< (host.array-length binary) (n/+ |1 idx)) (#error.Success ($_ i64.or - (i64.left-shift +8 (..i64 (host.array-read idx binary))) - (..i64 (host.array-read (n/+ +1 idx) binary)))) + (i64.left-shift |8 (..i64 (host.array-read idx binary))) + (..i64 (host.array-read (n/+ |1 idx) binary)))) (ex.throw index-out-of-bounds (%n idx)))) (def: #export (read/32 idx binary) (-> Nat Binary (Error I64)) - (if (n/< (host.array-length binary) (n/+ +3 idx)) + (if (n/< (host.array-length binary) (n/+ |3 idx)) (#error.Success ($_ i64.or - (i64.left-shift +24 (..i64 (host.array-read idx binary))) - (i64.left-shift +16 (..i64 (host.array-read (n/+ +1 idx) binary))) - (i64.left-shift +8 (..i64 (host.array-read (n/+ +2 idx) binary))) - (..i64 (host.array-read (n/+ +3 idx) binary)))) + (i64.left-shift |24 (..i64 (host.array-read idx binary))) + (i64.left-shift |16 (..i64 (host.array-read (n/+ |1 idx) binary))) + (i64.left-shift |8 (..i64 (host.array-read (n/+ |2 idx) binary))) + (..i64 (host.array-read (n/+ |3 idx) binary)))) (ex.throw index-out-of-bounds (%n idx)))) (def: #export (read/64 idx binary) (-> Nat Binary (Error I64)) - (if (n/< (host.array-length binary) (n/+ +7 idx)) + (if (n/< (host.array-length binary) (n/+ |7 idx)) (#error.Success ($_ i64.or - (i64.left-shift +56 (..i64 (host.array-read idx binary))) - (i64.left-shift +48 (..i64 (host.array-read (n/+ +1 idx) binary))) - (i64.left-shift +40 (..i64 (host.array-read (n/+ +2 idx) binary))) - (i64.left-shift +32 (..i64 (host.array-read (n/+ +3 idx) binary))) - (i64.left-shift +24 (..i64 (host.array-read (n/+ +4 idx) binary))) - (i64.left-shift +16 (..i64 (host.array-read (n/+ +5 idx) binary))) - (i64.left-shift +8 (..i64 (host.array-read (n/+ +6 idx) binary))) - (..i64 (host.array-read (n/+ +7 idx) binary)))) + (i64.left-shift |56 (..i64 (host.array-read idx binary))) + (i64.left-shift |48 (..i64 (host.array-read (n/+ |1 idx) binary))) + (i64.left-shift |40 (..i64 (host.array-read (n/+ |2 idx) binary))) + (i64.left-shift |32 (..i64 (host.array-read (n/+ |3 idx) binary))) + (i64.left-shift |24 (..i64 (host.array-read (n/+ |4 idx) binary))) + (i64.left-shift |16 (..i64 (host.array-read (n/+ |5 idx) binary))) + (i64.left-shift |8 (..i64 (host.array-read (n/+ |6 idx) binary))) + (..i64 (host.array-read (n/+ |7 idx) binary)))) (ex.throw index-out-of-bounds (%n idx)))) (def: #export (write/8 idx value binary) @@ -92,36 +92,36 @@ (def: #export (write/16 idx value binary) (-> Nat (I64 Any) Binary (Error Binary)) - (if (n/< (host.array-length binary) (n/+ +1 idx)) + (if (n/< (host.array-length binary) (n/+ |1 idx)) (exec (|> binary - (host.array-write idx (..byte (i64.logical-right-shift +8 value))) - (host.array-write (n/+ +1 idx) (..byte value))) + (host.array-write idx (..byte (i64.logical-right-shift |8 value))) + (host.array-write (n/+ |1 idx) (..byte value))) (#error.Success binary)) (ex.throw index-out-of-bounds (%n idx)))) (def: #export (write/32 idx value binary) (-> Nat (I64 Any) Binary (Error Binary)) - (if (n/< (host.array-length binary) (n/+ +3 idx)) + (if (n/< (host.array-length binary) (n/+ |3 idx)) (exec (|> binary - (host.array-write idx (..byte (i64.logical-right-shift +24 value))) - (host.array-write (n/+ +1 idx) (..byte (i64.logical-right-shift +16 value))) - (host.array-write (n/+ +2 idx) (..byte (i64.logical-right-shift +8 value))) - (host.array-write (n/+ +3 idx) (..byte value))) + (host.array-write idx (..byte (i64.logical-right-shift |24 value))) + (host.array-write (n/+ |1 idx) (..byte (i64.logical-right-shift |16 value))) + (host.array-write (n/+ |2 idx) (..byte (i64.logical-right-shift |8 value))) + (host.array-write (n/+ |3 idx) (..byte value))) (#error.Success binary)) (ex.throw index-out-of-bounds (%n idx)))) (def: #export (write/64 idx value binary) (-> Nat (I64 Any) Binary (Error Binary)) - (if (n/< (host.array-length binary) (n/+ +7 idx)) + (if (n/< (host.array-length binary) (n/+ |7 idx)) (exec (|> binary - (host.array-write idx (..byte (i64.logical-right-shift +56 value))) - (host.array-write (n/+ +1 idx) (..byte (i64.logical-right-shift +48 value))) - (host.array-write (n/+ +2 idx) (..byte (i64.logical-right-shift +40 value))) - (host.array-write (n/+ +3 idx) (..byte (i64.logical-right-shift +32 value))) - (host.array-write (n/+ +4 idx) (..byte (i64.logical-right-shift +24 value))) - (host.array-write (n/+ +5 idx) (..byte (i64.logical-right-shift +16 value))) - (host.array-write (n/+ +6 idx) (..byte (i64.logical-right-shift +8 value))) - (host.array-write (n/+ +7 idx) (..byte value))) + (host.array-write idx (..byte (i64.logical-right-shift |56 value))) + (host.array-write (n/+ |1 idx) (..byte (i64.logical-right-shift |48 value))) + (host.array-write (n/+ |2 idx) (..byte (i64.logical-right-shift |40 value))) + (host.array-write (n/+ |3 idx) (..byte (i64.logical-right-shift |32 value))) + (host.array-write (n/+ |4 idx) (..byte (i64.logical-right-shift |24 value))) + (host.array-write (n/+ |5 idx) (..byte (i64.logical-right-shift |16 value))) + (host.array-write (n/+ |6 idx) (..byte (i64.logical-right-shift |8 value))) + (host.array-write (n/+ |7 idx) (..byte value))) (#error.Success binary)) (ex.throw index-out-of-bounds (%n idx)))) diff --git a/stdlib/source/lux/world/net/udp.jvm.lux b/stdlib/source/lux/world/net/udp.jvm.lux index 6974af0ba..893538657 100644 --- a/stdlib/source/lux/world/net/udp.jvm.lux +++ b/stdlib/source/lux/world/net/udp.jvm.lux @@ -58,8 +58,8 @@ [addresses (InetAddress::getAllByName [address])] (: (io.IO (e.Error InetAddress)) (case (array.size addresses) - +0 (io.io (ex.throw cannot-resolve-address address)) - +1 (wrap (maybe.assume (array.read +0 addresses))) + |0 (io.io (ex.throw cannot-resolve-address address)) + |1 (wrap (maybe.assume (array.read |0 addresses))) _ (io.io (ex.throw multiple-candidate-addresses address)))))) (abstract: #export UDP {} diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux index 65f176b87..df0bb8278 100644 --- a/stdlib/test/test/lux.lux +++ b/stdlib/test/test/lux.lux @@ -15,9 +15,9 @@ test]) (context: "Value identity." - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% +100) (n/max +10)))) + [size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) x (r.unicode size) y (r.unicode size)] ($_ seq @@ -31,14 +31,14 @@ (do-template [category rand-gen even? odd? = < >] [(context: (format "[" category "] " "Simple operations.") - (<| (times +100) + (<| (times |100) (do @ [value rand-gen] ($_ seq (test (format "[" category "] " "Moving up-down or down-up should result in same value.") (and (|> value inc dec (= value)) (|> value dec inc (= value)))) - (test (format "[" category "] " "(x+1) > x && (x-1) < x") + (test (format "[" category "] " "(x|1) > x && (x-1) < x") (and (|> value inc (> value)) (|> value dec (< value)))) (test (format "[" category "] " "Every odd/even number is surrounded by two of the other kind.") @@ -54,7 +54,7 @@ (do-template [category rand-gen = < > <= >= min max] [(context: (format "[" category "] " "(More) simple operations.") - (<| (times +100) + (<| (times |100) (do @ [x rand-gen y rand-gen] @@ -77,7 +77,7 @@ (do-template [category rand-gen = + - * / <%> > <0> <1> ] [(context: (format "[" category "] " "Additive identity") - (<| (times +100) + (<| (times |100) (do @ [x rand-gen] (test "" @@ -85,7 +85,7 @@ (|> x (- <0>) (= x))))))) (context: (format "[" category "] " "Addition & Substraction") - (<| (times +100) + (<| (times |100) (do @ [x (:: @ map rand-gen) y (:: @ map rand-gen) @@ -96,7 +96,7 @@ (|> x (+ y) (- y) (= x))))))) (context: (format "[" category "] " "Multiplicative identity") - (<| (times +100) + (<| (times |100) (do @ [x rand-gen] (test "" @@ -108,7 +108,7 @@ (|> x (/ <1>) (= x)))))))) (context: (format "[" category "] " "Multiplication & Division") - (<| (times +100) + (<| (times |100) (do @ [x (:: @ map rand-gen) y (|> rand-gen @@ -125,7 +125,7 @@ (|> x' (/ y) (* y) (= x')))) ))))] - ["Nat" r.nat n/= n/+ n/- n/* n// n/% n/> +0 +1 +1_000_000 (n/% +1_000) id] + ["Nat" r.nat n/= n/+ n/- n/* n// n/% n/> |0 |1 |1_000_000 (n/% |1_000) id] ["Int" r.int i/= i/+ i/- i/* i// i/% i/> 0 1 1_000_000 (i/% 1_000) id] ["Frac" r.frac f/= f/+ f/- f/* f// f/% f/> 0.0 1.0 1_000_000.0 id math.floor] ["Rev" r.rev r/= r/+ r/- r/* r// r/% r/> .0 (.rev -1) (.rev -1) id id] @@ -134,11 +134,11 @@ (def: frac-rev (r.Random Rev) (|> r.rev - (:: r.Functor map (|>> (i64.left-shift +11) (i64.logical-right-shift +11))))) + (:: r.Functor map (|>> (i64.left-shift |11) (i64.logical-right-shift |11))))) (do-template [category rand-gen -> <- = ] [(context: (format "[" category "] " "Numeric conversions") - (<| (times +100) + (<| (times |100) (do @ [value rand-gen #let [value ( value)]] @@ -146,7 +146,7 @@ (|> value -> <- (= value))))))] ["Int->Nat" r.int .nat .int i/= (i/% 1_000_000)] - ["Nat->Int" r.nat .int .nat n/= (n/% +1_000_000)] + ["Nat->Int" r.nat .int .nat n/= (n/% |1_000_000)] ["Int->Frac" r.int int-to-frac frac-to-int i/= (i/% 1_000_000)] ["Frac->Int" r.frac frac-to-int int-to-frac f/= math.floor] ["Rev->Frac" frac-rev rev-to-frac frac-to-rev r/= id] @@ -189,7 +189,7 @@ (i/+ (i/* x x) (i/* y y))) (context: "Templates." - (<| (times +100) + (<| (times |100) (do @ [x r.int y r.int] diff --git a/stdlib/test/test/lux/cli.lux b/stdlib/test/test/lux/cli.lux index 6d156d3b2..c5b3a485c 100644 --- a/stdlib/test/test/lux/cli.lux +++ b/stdlib/test/test/lux/cli.lux @@ -17,16 +17,16 @@ lux/test) (context: "CLI" - (<| (times +100) + (<| (times |100) (do @ - [num-args (|> r.nat (:: @ map (n/% +10))) + [num-args (|> r.nat (:: @ map (n/% |10))) #let [(^open "Nat/.") number.Codec gen-arg (:: @ map Nat/encode r.nat)] yes gen-arg - #let [gen-ignore (|> (r.unicode +5) (r.filter (|>> (text/= yes) not)))] + #let [gen-ignore (|> (r.unicode |5) (r.filter (|>> (text/= yes) not)))] no gen-ignore - pre-ignore (r.list +5 gen-ignore) - post-ignore (r.list +5 gen-ignore)] + pre-ignore (r.list |5 gen-ignore) + post-ignore (r.list |5 gen-ignore)] ($_ seq (test "Can read any argument." (|> (/.run (list yes) /.any) diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/case.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/case.lux index fd516d048..4a1b1e28e 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/case.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/case.lux @@ -67,7 +67,7 @@ [#.Int r.int code.int] [#.Rev r.rev code.rev] [#.Frac r.frac code.frac] - [#.Text (r.unicode +5) code.text]) + [#.Text (r.unicode |5) code.text]) (^ [_ (#.Tuple (list))]) (random/wrap (list (' []))) @@ -118,7 +118,7 @@ choiceC (maybe.assume (list.nth choice primitivesC))]] (wrap (` ((~ choiceT) (~ choiceC))))) (do r.Monad - [size (|> r.nat (:: @ map (n/% +3))) + [size (|> r.nat (:: @ map (n/% |3))) elems (r.list size input)] (wrap (code.tuple elems))) (random/wrap (code.record (list.zip2 record-tags primitivesC))) @@ -129,17 +129,17 @@ [pattern body]) (context: "Pattern-matching." - ## #seed +9253409297339902486 - ## #seed +3793366152923578600 - (<| (seed +5004137551292836565) - ## (times +100) + ## #seed |9253409297339902486 + ## #seed |3793366152923578600 + (<| (seed |5004137551292836565) + ## (times |100) (do @ - [module-name (r.unicode +5) - variant-name (r.unicode +5) - record-name (|> (r.unicode +5) (r.filter (|>> (text/= variant-name) not))) - size (|> r.nat (:: @ map (|>> (n/% +10) (n/max +2)))) - variant-tags (|> (r.set text.Hash size (r.unicode +5)) (:: @ map set.to-list)) - record-tags (|> (r.set text.Hash size (r.unicode +5)) (:: @ map set.to-list)) + [module-name (r.unicode |5) + variant-name (r.unicode |5) + record-name (|> (r.unicode |5) (r.filter (|>> (text/= variant-name) not))) + size (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) + variant-tags (|> (r.set text.Hash size (r.unicode |5)) (:: @ map set.to-list)) + record-tags (|> (r.set text.Hash size (r.unicode |5)) (:: @ map set.to-list)) primitivesTC (r.list size _primitive.primitive) #let [primitivesT (list/map product.left primitivesTC) primitivesC (list/map product.right primitivesTC) @@ -178,7 +178,7 @@ _ (module.declare-tags record-tags #0 (#.Named [module-name record-name] (type.tuple primitivesT)))]) - (module.with-module +0 module-name))]] + (module.with-module |0 module-name))]] ($_ seq (test "Will reject empty pattern-matching (no branches)." (|> (analyse-pm (list)) diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/function.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/function.lux index 66c5f1a23..11220052f 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/function.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/function.lux @@ -47,10 +47,10 @@ #0))) (context: "Function definition." - (<| (times +100) + (<| (times |100) (do @ - [func-name (r.unicode +5) - arg-name (|> (r.unicode +5) (r.filter (|>> (text/= func-name) not))) + [func-name (r.unicode |5) + arg-name (|> (r.unicode |5) (r.filter (|>> (text/= func-name) not))) [outputT outputC] _primitive.primitive [inputT _] _primitive.primitive #let [g!arg (code.local-identifier arg-name)]] @@ -76,19 +76,19 @@ )))) (context: "Function application." - (<| (times +100) + (<| (times |100) (do @ - [full-args (|> r.nat (:: @ map (|>> (n/% +10) (n/max +2)))) + [full-args (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) partial-args (|> r.nat (:: @ map (n/% full-args))) - var-idx (|> r.nat (:: @ map (|>> (n/% full-args) (n/max +1)))) + var-idx (|> r.nat (:: @ map (|>> (n/% full-args) (n/max |1)))) inputsTC (r.list full-args _primitive.primitive) #let [inputsT (list/map product.left inputsTC) inputsC (list/map product.right inputsTC)] [outputT outputC] _primitive.primitive #let [funcT (type.function inputsT outputT) partialT (type.function (list.drop partial-args inputsT) outputT) - varT (#.Parameter +1) - polyT (<| (type.univ-q +1) + varT (#.Parameter |1) + polyT (<| (type.univ-q |1) (type.function (list.concat (list (list.take var-idx inputsT) (list varT) (list.drop (inc var-idx) inputsT)))) @@ -97,10 +97,10 @@ partial-poly-inputsT (list.drop (inc var-idx) inputsT) partial-polyT1 (<| (type.function partial-poly-inputsT) poly-inputT) - partial-polyT2 (<| (type.univ-q +1) + partial-polyT2 (<| (type.univ-q |1) (type.function (#.Cons varT partial-poly-inputsT)) varT) - dummy-function (#analysis.Function (list) (#analysis.Reference (reference.local +1)))]] + dummy-function (#analysis.Function (list) (#analysis.Reference (reference.local |1)))]] ($_ seq (test "Can analyse monomorphic type application." (|> (/.apply ..analyse funcT dummy-function inputsC) diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/primitive.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/primitive.lux index 9a5595f22..b6bec104f 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/primitive.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/primitive.lux @@ -36,13 +36,13 @@ (~~ (do-template [ ] [(r.and (random/wrap ) (random/map ))] - [Any code.tuple (r.list +0 ..unit)] + [Any code.tuple (r.list |0 ..unit)] [Bit code.bit r.bit] [Nat code.nat r.nat] [Int code.int r.int] [Rev code.rev r.rev] [Frac code.frac r.frac] - [Text code.text (r.unicode +5)] + [Text code.text (r.unicode |5)] ))))) (exception: (wrong-inference {expected Type} {inferred Type}) @@ -71,7 +71,7 @@ _ #0))) - (<| (times +100) + (<| (times |100) (`` ($_ seq (~~ (do-template [ ] [(do @ @@ -89,5 +89,5 @@ ["int" Int #analysis.Int r.int code.int] ["rev" Rev #analysis.Rev r.rev code.rev] ["frac" Frac #analysis.Frac r.frac code.frac] - ["text" Text #analysis.Text (r.unicode +5) code.text] + ["text" Text #analysis.Text (r.unicode |5) code.text] ))))))) diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux index 5c7296eff..f13db8218 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux @@ -47,7 +47,7 @@ ) (context: "Lux procedures" - (<| (times +100) + (<| (times |100) (do @ [[primT primC] _primitive.primitive [antiT antiC] (|> _primitive.primitive @@ -64,7 +64,7 @@ )))) (context: "Bit procedures" - (<| (times +100) + (<| (times |100) (do @ [subjectC (|> r.nat (:: @ map code.nat)) signedC (|> r.int (:: @ map code.int)) @@ -85,7 +85,7 @@ )))) (context: "Int procedures" - (<| (times +100) + (<| (times |100) (do @ [subjectC (|> r.int (:: @ map code.int)) paramC (|> r.int (:: @ map code.int))] @@ -111,11 +111,11 @@ )))) (context: "Frac procedures" - (<| (times +100) + (<| (times |100) (do @ [subjectC (|> r.frac (:: @ map code.frac)) paramC (|> r.frac (:: @ map code.frac)) - encodedC (|> (r.unicode +5) (:: @ map code.text))] + encodedC (|> (r.unicode |5) (:: @ map code.text))] ($_ seq (test "Can add frac numbers." (check-success+ "lux frac +" (list subjectC paramC) Frac)) @@ -146,11 +146,11 @@ )))) (context: "Text procedures" - (<| (times +100) + (<| (times |100) (do @ - [subjectC (|> (r.unicode +5) (:: @ map code.text)) - paramC (|> (r.unicode +5) (:: @ map code.text)) - replacementC (|> (r.unicode +5) (:: @ map code.text)) + [subjectC (|> (r.unicode |5) (:: @ map code.text)) + paramC (|> (r.unicode |5) (:: @ map code.text)) + replacementC (|> (r.unicode |5) (:: @ map code.text)) fromC (|> r.nat (:: @ map code.nat)) toC (|> r.nat (:: @ map code.nat))] ($_ seq @@ -171,12 +171,12 @@ )))) (context: "Array procedures" - (<| (times +100) + (<| (times |100) (do @ [[elemT elemC] _primitive.primitive sizeC (|> r.nat (:: @ map code.nat)) idxC (|> r.nat (:: @ map code.nat)) - var-name (r.unicode +5) + var-name (r.unicode |5) #let [arrayT (type (Array elemT)) g!array (code.local-identifier var-name) array-operation (function (_ output-type code) @@ -208,7 +208,7 @@ )))) (context: "Math procedures" - (<| (times +100) + (<| (times |100) (do @ [subjectC (|> r.frac (:: @ map code.frac)) paramC (|> r.frac (:: @ map code.frac))] @@ -239,12 +239,12 @@ ["lux math pow" "power"]))))))) (context: "Atom procedures" - (<| (times +100) + (<| (times |100) (do @ [[elemT elemC] _primitive.primitive sizeC (|> r.nat (:: @ map code.nat)) idxC (|> r.nat (:: @ map code.nat)) - var-name (r.unicode +5) + var-name (r.unicode |5) #let [atomT (type (atom.Atom elemT))]] ($_ seq (test "Can create atomic reference." @@ -277,7 +277,7 @@ )))) (context: "Process procedures" - (<| (times +100) + (<| (times |100) (do @ [[primT primC] _primitive.primitive timeC (|> r.nat (:: @ map code.nat))] @@ -292,9 +292,9 @@ )))) (context: "IO procedures" - (<| (times +100) + (<| (times |100) (do @ - [logC (|> (r.unicode +5) (:: @ map code.text)) + [logC (|> (r.unicode |5) (:: @ map code.text)) exitC (|> r.int (:: @ map code.int))] ($_ seq (test "Can log messages to standard output." diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/reference.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/reference.lux index 5c5ac9ee5..55a673935 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/reference.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/reference.lux @@ -48,13 +48,13 @@ (def: (reach-test var-name [export? def-module] [import? dependent-module] check!) (-> Text [Bit Text] [Bit Text] Check Bit) (|> (do phase.Monad - [_ (module.with-module +0 def-module + [_ (module.with-module |0 def-module (module.define var-name [Any (if export? (' {#.export? #1}) (' {})) []]))] - (module.with-module +0 dependent-module + (module.with-module |0 dependent-module (do @ [_ (if import? (module.import def-module) @@ -65,13 +65,13 @@ check!)) (context: "References" - (<| (times +100) + (<| (times |100) (do @ [[expectedT _] _primitive.primitive - def-module (r.unicode +5) - scope-name (r.unicode +5) - var-name (r.unicode +5) - dependent-module (|> (r.unicode +5) + def-module (r.unicode |5) + scope-name (r.unicode |5) + var-name (r.unicode |5) + dependent-module (|> (r.unicode |5) (r.filter (|>> (text/= def-module) not)))] ($_ seq (test "Can analyse variable." @@ -82,7 +82,7 @@ (phase.run [analysisE.bundle (init.compiler [])]) (case> (^ (#e.Success [inferredT (#analysis.Reference (reference.local var))])) (and (type/= expectedT inferredT) - (n/= +0 var)) + (n/= |0 var)) _ #0))) @@ -92,7 +92,7 @@ [_ (module.define var-name [expectedT (' {}) []])] (typeA.with-inference (..analyse (code.identifier def-name)))) - (module.with-module +0 def-module) + (module.with-module |0 def-module) (phase.run [analysisE.bundle (init.compiler [])]) (case> (^ (#e.Success [_ inferredT (#analysis.Reference (reference.constant constant-name))])) (and (type/= expectedT inferredT) diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/structure.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/structure.lux index eb517be72..1b23587f7 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/structure.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/structure.lux @@ -75,7 +75,7 @@ (All [a] (-> Text (List module.Tag) Type (Operation a) (Operation [Module a]))) (|>> (do phase.Monad [_ (module.declare-tags tags #0 type)]) - (module.with-module +0 module))) + (module.with-module |0 module))) (def: (check-variant module tags type size tag analysis) (-> Text (List module.Tag) Type Nat Tag (Operation Analysis) Bit) @@ -108,9 +108,9 @@ #0))) (context: "Sums" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% +10) (n/max +2)))) + [size (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) choice (|> r.nat (:: @ map (n/% size))) primitives (r.list size _primitive.primitive) +choice (|> r.nat (:: @ map (n/% (inc size)))) @@ -119,7 +119,7 @@ [valueT valueC] (maybe.assume (list.nth choice primitives)) +size (inc size) +primitives (list.concat (list (list.take choice primitives) - (list [(#.Parameter +1) +valueC]) + (list [(#.Parameter |1) +valueC]) (list.drop choice primitives))) [+valueT +valueC] (maybe.assume (list.nth +choice +primitives)) +variantT (type.variant (list/map product.left +primitives))]] @@ -149,29 +149,29 @@ (/.sum ..analyse choice valueC))) check-fails)) (test "Can analyse sum through existential quantification." - (|> (typeA.with-type (type.ex-q +1 +variantT) + (|> (typeA.with-type (type.ex-q |1 +variantT) (/.sum ..analyse +choice +valueC)) check-succeeds)) (test "Can analyse sum through universal quantification." (let [check-outcome (if (not (n/= choice +choice)) check-succeeds check-fails)] - (|> (typeA.with-type (type.univ-q +1 +variantT) + (|> (typeA.with-type (type.univ-q |1 +variantT) (/.sum ..analyse +choice +valueC)) check-outcome))) )))) (context: "Products" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% +10) (n/max +2)))) + [size (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) primitives (r.list size _primitive.primitive) choice (|> r.nat (:: @ map (n/% size))) [_ +valueC] _primitive.primitive #let [tupleT (type.tuple (list/map product.left primitives)) [singletonT singletonC] (|> primitives (list.nth choice) maybe.assume) +primitives (list.concat (list (list.take choice primitives) - (list [(#.Parameter +1) +valueC]) + (list [(#.Parameter |1) +valueC]) (list.drop choice primitives))) +tupleT (type.tuple (list/map product.left +primitives))]] ($_ seq @@ -212,26 +212,26 @@ _ #0))) (test "Can analyse product through existential quantification." - (|> (typeA.with-type (type.ex-q +1 +tupleT) + (|> (typeA.with-type (type.ex-q |1 +tupleT) (/.product ..analyse (list/map product.right +primitives))) check-succeeds)) (test "Cannot analyse product through universal quantification." - (|> (typeA.with-type (type.univ-q +1 +tupleT) + (|> (typeA.with-type (type.univ-q |1 +tupleT) (/.product ..analyse (list/map product.right +primitives))) check-fails)) )))) (context: "Tagged Sums" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% +10) (n/max +2)))) - tags (|> (r.set text.Hash size (r.unicode +5)) (:: @ map set.to-list)) + [size (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) + tags (|> (r.set text.Hash size (r.unicode |5)) (:: @ map set.to-list)) choice (|> r.nat (:: @ map (n/% size))) other-choice (|> r.nat (:: @ map (n/% size)) (r.filter (|>> (n/= choice) not))) primitives (r.list size _primitive.primitive) - module-name (r.unicode +5) - type-name (r.unicode +5) - #let [varT (#.Parameter +1) + module-name (r.unicode |5) + type-name (r.unicode |5) + #let [varT (#.Parameter |1) primitivesT (list/map product.left primitives) [choiceT choiceC] (maybe.assume (list.nth choice primitives)) [other-choiceT other-choiceC] (maybe.assume (list.nth other-choice primitives)) @@ -240,7 +240,7 @@ named-polyT (|> (type.variant (list.concat (list (list.take choice primitivesT) (list varT) (list.drop (inc choice) primitivesT)))) - (type.univ-q +1) + (type.univ-q |1) (#.Named [module-name type-name])) choice-tag (maybe.assume (list.nth choice tags)) other-choice-tag (maybe.assume (list.nth other-choice tags))]] @@ -261,15 +261,15 @@ )))) (context: "Records" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% +10) (n/max +2)))) - tags (|> (r.set text.Hash size (r.unicode +5)) (:: @ map set.to-list)) + [size (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) + tags (|> (r.set text.Hash size (r.unicode |5)) (:: @ map set.to-list)) primitives (r.list size _primitive.primitive) - module-name (r.unicode +5) - type-name (r.unicode +5) + module-name (r.unicode |5) + type-name (r.unicode |5) choice (|> r.nat (:: @ map (n/% size))) - #let [varT (#.Parameter +1) + #let [varT (#.Parameter |1) tagsC (list/map (|>> [module-name] code.tag) tags) primitivesT (list/map product.left primitives) primitivesC (list/map product.right primitives) @@ -279,7 +279,7 @@ named-polyT (|> (type.tuple (list.concat (list (list.take choice primitivesT) (list varT) (list.drop (inc choice) primitivesT)))) - (type.univ-q +1) + (type.univ-q |1) (#.Named [module-name type-name]))]] ($_ seq (test "Can infer record." diff --git a/stdlib/test/test/lux/compiler/default/phase/synthesis/case.lux b/stdlib/test/test/lux/compiler/default/phase/synthesis/case.lux index ad0d5c60a..43c58f446 100644 --- a/stdlib/test/test/lux/compiler/default/phase/synthesis/case.lux +++ b/stdlib/test/test/lux/compiler/default/phase/synthesis/case.lux @@ -20,10 +20,10 @@ ["." //primitive]) (context: "Dummy variables." - (<| (times +100) + (<| (times |100) (do @ [maskedA //primitive.primitive - temp (|> r.nat (:: @ map (n/% +100))) + temp (|> r.nat (:: @ map (n/% |100))) #let [maskA (analysis.control/case [maskedA [[(#analysis.Bind temp) @@ -37,7 +37,7 @@ (error.default #0)))))) (context: "Let expressions." - (<| (times +100) + (<| (times |100) (do @ [registerA r.nat inputA //primitive.primitive @@ -60,7 +60,7 @@ #0)))))) (context: "If expressions." - (<| (times +100) + (<| (times |100) (do @ [then|else r.bit inputA //primitive.primitive diff --git a/stdlib/test/test/lux/compiler/default/phase/synthesis/function.lux b/stdlib/test/test/lux/compiler/default/phase/synthesis/function.lux index 2249acca1..046eef852 100644 --- a/stdlib/test/test/lux/compiler/default/phase/synthesis/function.lux +++ b/stdlib/test/test/lux/compiler/default/phase/synthesis/function.lux @@ -42,7 +42,7 @@ predictionA])) (do @ [predictionA //primitive.primitive] - (wrap [+0 predictionA predictionA]))))))) + (wrap [|0 predictionA predictionA]))))))) (def: (pick scope-size) (-> Nat (r.Random Nat)) @@ -51,12 +51,12 @@ (def: function-with-environment (r.Random [Arity Analysis Variable]) (do r.Monad - [num-locals (|> r.nat (:: @ map (|>> (n/% +100) (n/max +10)))) - #let [indices (list.n/range +0 (dec num-locals)) + [num-locals (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) + #let [indices (list.n/range |0 (dec num-locals)) local-env (list/map (|>> #reference.Local) indices) foreign-env (list/map (|>> #reference.Foreign) indices)] [arity bodyA predictionA] (: (r.Random [Arity Analysis Variable]) - (loop [arity +1 + (loop [arity |1 current-env foreign-env] (let [current-env/size (list.size current-env) resolver (list/fold (function (_ [idx var] resolver) @@ -68,7 +68,7 @@ [nest? r.bit] (if nest? (do @ - [num-picks (:: @ map (n/max +1) (pick (inc current-env/size))) + [num-picks (:: @ map (n/max |1) (pick (inc current-env/size))) picks (|> (r.set number.Hash num-picks (pick current-env/size)) (:: @ map set.to-list)) [arity bodyA predictionA] (recur (inc arity) @@ -90,7 +90,7 @@ (def: local-function (r.Random [Arity Analysis Variable]) - (loop [arity +0 + (loop [arity |0 nest? #1] (if nest? (do r.Monad @@ -100,14 +100,14 @@ (#analysis.Function (list) bodyA) predictionA])) (do r.Monad - [chosen (|> r.nat (:: @ map (|>> (n/% +100) (n/max +2))))] + [chosen (|> r.nat (:: @ map (|>> (n/% |100) (n/max |2))))] (wrap [arity (#analysis.Reference (reference.local chosen)) (|> chosen (n/+ (dec arity)) #reference.Local)]))))) (context: "Function definition." - (<| (seed +13007429814532219492) - ## (times +100) + (<| (seed |13007429814532219492) + ## (times |100) (do @ [[arity//constant function//constant prediction//constant] constant-function [arity//environment function//environment prediction//environment] function-with-environment @@ -122,7 +122,7 @@ (//primitive.corresponds? prediction//constant output)) _ - (n/= +0 arity//constant)))) + (n/= |0 arity//constant)))) (test "Folded functions provide direct access to environment variables." (|> function//environment expression.synthesize @@ -146,9 +146,9 @@ )))) (context: "Function application." - (<| (times +100) + (<| (times |100) (do @ - [arity (|> r.nat (:: @ map (|>> (n/% +10) (n/max +1)))) + [arity (|> r.nat (:: @ map (|>> (n/% |10) (n/max |1)))) funcA //primitive.primitive argsA (r.list arity //primitive.primitive)] ($_ seq diff --git a/stdlib/test/test/lux/compiler/default/phase/synthesis/primitive.lux b/stdlib/test/test/lux/compiler/default/phase/synthesis/primitive.lux index cdeeea22b..e2fa45521 100644 --- a/stdlib/test/test/lux/compiler/default/phase/synthesis/primitive.lux +++ b/stdlib/test/test/lux/compiler/default/phase/synthesis/primitive.lux @@ -30,7 +30,7 @@ r.int r.rev r.frac - (r.unicode +5)))] + (r.unicode |5)))] (wrap (#analysis.Primitive primitive)))) (def: #export (corresponds? analysis synthesis) @@ -68,14 +68,14 @@ #0)) (context: "Primitives." - (<| (times +100) + (<| (times |100) (do @ [|bit| r.bit |nat| r.nat |int| r.int |rev| r.rev |frac| r.frac - |text| (r.unicode +5)] + |text| (r.unicode |5)] (`` ($_ seq (~~ (do-template [ ] [(test (format "Can synthesize " ".") diff --git a/stdlib/test/test/lux/compiler/default/phase/synthesis/structure.lux b/stdlib/test/test/lux/compiler/default/phase/synthesis/structure.lux index 924a4126d..b3363567a 100644 --- a/stdlib/test/test/lux/compiler/default/phase/synthesis/structure.lux +++ b/stdlib/test/test/lux/compiler/default/phase/synthesis/structure.lux @@ -23,9 +23,9 @@ ["." //primitive]) (context: "Variants" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% +10) (n/+ +2)))) + [size (|> r.nat (:: @ map (|>> (n/% |10) (n/+ |2)))) tagA (|> r.nat (:: @ map (n/% size))) memberA //primitive.primitive] ($_ seq @@ -44,9 +44,9 @@ )))) (context: "Tuples" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% +10) (n/max +2)))) + [size (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) membersA (r.list size //primitive.primitive)] ($_ seq (test "Can synthesize tuple." diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux index 07befa13c..76cc98717 100644 --- a/stdlib/test/test/lux/compiler/default/syntax.lux +++ b/stdlib/test/test/lux/compiler/default/syntax.lux @@ -23,8 +23,8 @@ (def: default-cursor Cursor {#.module "" - #.line +0 - #.column +0}) + #.line |0 + #.column |0}) (def: name-part^ (r.Random Text) @@ -34,11 +34,11 @@ space "\t\v \n\r\f" invalid-range (format digits delimiters space) char-gen (|> r.nat - (:: @ map (|>> (n/% +256) (n/max +1))) + (:: @ map (|>> (n/% |256) (n/max |1))) (r.filter (function (_ sample) (not (text.contains? (text.from-code sample) invalid-range)))))] - size (|> r.nat (:: @ map (|>> (n/% +20) (n/max +1))))] + size (|> r.nat (:: @ map (|>> (n/% |20) (n/max |1))))] (r.text char-gen size))) (def: name^ @@ -57,7 +57,7 @@ textual^ (: (r.Random Code) ($_ r.either (do r.Monad - [size (|> r.nat (r/map (n/% +20)))] + [size (|> r.nat (r/map (n/% |20)))] (|> (r.unicode size) (r/map code.text))) (|> name^ (r/map code.identifier)) (|> name^ (r/map code.tag)))) @@ -68,28 +68,28 @@ (r.rec (function (_ code^) (let [multi^ (do r.Monad - [size (|> r.nat (r/map (n/% +3)))] + [size (|> r.nat (r/map (n/% |3)))] (r.list size code^)) composite^ (: (r.Random Code) ($_ r.either (|> multi^ (r/map code.form)) (|> multi^ (r/map code.tuple)) (do r.Monad - [size (|> r.nat (r/map (n/% +3)))] + [size (|> r.nat (r/map (n/% |3)))] (|> (r.list size (r.and code^ code^)) (r/map code.record)))))] (r.either simple^ composite^)))))) (context: "Lux code syntax." - (<| (times +100) + (<| (times |100) (do @ [sample code^ other code^] ($_ seq (test "Can parse Lux code." (case (&.read "" (dict.new text.Hash) - [default-cursor +0 (code.to-text sample)]) + [default-cursor |0 (code.to-text sample)]) (#e.Error error) #0 @@ -97,7 +97,7 @@ (:: code.Equivalence = parsed sample))) (test "Can parse Lux multiple code nodes." (case (&.read "" (dict.new text.Hash) - [default-cursor +0 (format (code.to-text sample) " " + [default-cursor |0 (format (code.to-text sample) " " (code.to-text other))]) (#e.Error error) #0 @@ -114,15 +114,15 @@ )))) (context: "Frac special syntax." - (<| (times +100) + (<| (times |100) (do @ - [numerator (|> r.nat (:: @ map (|>> (n/% +100) .int int-to-frac))) - denominator (|> r.nat (:: @ map (|>> (n/% +100) (n/max +1) .int int-to-frac))) + [numerator (|> r.nat (:: @ map (|>> (n/% |100) .int int-to-frac))) + denominator (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1) .int int-to-frac))) signed? r.bit #let [expected (|> numerator (f// denominator) (f/* (if signed? -1.0 1.0)))]] (test "Can parse frac ratio syntax." (case (&.read "" (dict.new text.Hash) - [default-cursor +0 + [default-cursor |0 (format (if signed? "-" "") (%i (frac-to-int numerator)) "/" @@ -135,12 +135,12 @@ )))) (context: "Nat special syntax." - (<| (times +100) + (<| (times |100) (do @ - [expected (|> r.nat (:: @ map (n/% +1_000)))] + [expected (|> r.nat (:: @ map (n/% |1_000)))] (test "Can parse nat char syntax." (case (&.read "" (dict.new text.Hash) - [default-cursor +0 + [default-cursor |0 (format "#" (%t (text.from-code expected)) "")]) (#e.Success [_ [_ (#.Nat actual)]]) (n/= expected actual) @@ -157,7 +157,7 @@ (n/= (char "(") value) (n/= (char ")") value))))))] (do r.Monad - [size (|> r.nat (r/map (n/% +20)))] + [size (|> r.nat (r/map (n/% |20)))] (r.text char-gen size)))) (def: comment^ @@ -172,8 +172,8 @@ (wrap (format "#( " comment " )#"))))))) (context: "Multi-line text & comments." - (<| (seed +12137892244981970631) - ## (times +100) + (<| (seed |12137892244981970631) + ## (times |100) (do @ [#let [char-gen (|> r.nat (r.filter (function (_ value) (not (or (text.space? value) @@ -181,7 +181,7 @@ x char-gen y char-gen z char-gen - offset-size (|> r.nat (r/map (|>> (n/% +10) (n/max +1)))) + offset-size (|> r.nat (r/map (|>> (n/% |10) (n/max |1)))) #let [offset (text.join-with "" (list.repeat offset-size " "))] sample code^ comment comment^ @@ -192,7 +192,7 @@ (text.from-code y) "\n" (text.from-code z))] (case (&.read "" (dict.new text.Hash) - [default-cursor +0 + [default-cursor |0 (format "\"" bad-match "\"")]) (#e.Error error) #1 @@ -208,7 +208,7 @@ (text.from-code z))] (case (&.read "" (dict.new text.Hash) [(|> default-cursor (update@ #.column (n/+ (dec offset-size)))) - +0 + |0 (format "\"" good-input "\"")]) (#e.Error error) #0 @@ -219,7 +219,7 @@ (code.text good-output))))) (test "Can handle comments." (case (&.read "" (dict.new text.Hash) - [default-cursor +0 + [default-cursor |0 (format comment (code.to-text sample))]) (#e.Error error) #0 @@ -228,7 +228,7 @@ (:: code.Equivalence = parsed sample))) (test "Will reject unbalanced multi-line comments." (and (case (&.read "" (dict.new text.Hash) - [default-cursor +0 + [default-cursor |0 (format "#(" "#(" unbalanced-comment ")#" (code.to-text sample))]) (#e.Error error) @@ -237,7 +237,7 @@ (#e.Success [_ parsed]) #0) (case (&.read "" (dict.new text.Hash) - [default-cursor +0 + [default-cursor |0 (format "#(" unbalanced-comment ")#" ")#" (code.to-text sample))]) (#e.Error error) diff --git a/stdlib/test/test/lux/concurrency/actor.lux b/stdlib/test/test/lux/concurrency/actor.lux index a1e9ec549..42b2f5412 100644 --- a/stdlib/test/test/lux/concurrency/actor.lux +++ b/stdlib/test/test/lux/concurrency/actor.lux @@ -38,19 +38,19 @@ ($_ seq (test "Can check if an actor is alive." (io.run (do io.Monad - [counter (new@Counter +0)] + [counter (new@Counter |0)] (wrap (&.alive? counter))))) (test "Can poison actors." (io.run (do io.Monad - [counter (new@Counter +0) + [counter (new@Counter |0) poisoned? (&.poison counter)] (wrap (and poisoned? (not (&.alive? counter))))))) (test "Cannot poison an already dead actor." (io.run (do io.Monad - [counter (new@Counter +0) + [counter (new@Counter |0) first-time (&.poison counter) second-time (&.poison counter)] (wrap (and first-time @@ -58,13 +58,13 @@ (wrap (do P.Monad [result (do T.Monad - [#let [counter (io.run (new@Counter +0))] - output-1 (count! +1 counter) - output-2 (count! +1 counter) - output-3 (count! +1 counter)] - (wrap (and (n/= +1 output-1) - (n/= +2 output-2) - (n/= +3 output-3))))] + [#let [counter (io.run (new@Counter |0))] + output-1 (count! |1 counter) + output-2 (count! |1 counter) + output-3 (count! |1 counter)] + (wrap (and (n/= |1 output-1) + (n/= |2 output-2) + (n/= |3 output-3))))] (assert "Can send messages to actors." (case result (#e.Success outcome) diff --git a/stdlib/test/test/lux/concurrency/atom.lux b/stdlib/test/test/lux/concurrency/atom.lux index 03895bdeb..db480b27e 100644 --- a/stdlib/test/test/lux/concurrency/atom.lux +++ b/stdlib/test/test/lux/concurrency/atom.lux @@ -10,7 +10,7 @@ lux/test) (context: "Atoms" - (<| (times +100) + (<| (times |100) (do @ [value r.nat swap-value r.nat diff --git a/stdlib/test/test/lux/concurrency/frp.lux b/stdlib/test/test/lux/concurrency/frp.lux index c69ae6038..668882485 100644 --- a/stdlib/test/test/lux/concurrency/frp.lux +++ b/stdlib/test/test/lux/concurrency/frp.lux @@ -42,7 +42,7 @@ output (read! input) _ (write! values input)] (wrap output))) - _ (promise.wait +100) + _ (promise.wait |100) output (promise.future (atom.read output))] (assert "Can pipe one channel into another." (list/= values @@ -56,7 +56,7 @@ output (read! elems) _ (write! (list 0 1 2 3 4 5) input)] (wrap output))) - _ (promise.wait +100) + _ (promise.wait |100) output (promise.future (atom.read output))] (assert "Can filter a channel's elements." (list/= (list 0 2 4) @@ -72,7 +72,7 @@ _ (write! (list 0 1 2 3 4 5) left) _ (write! (list 0 -1 -2 -3 -4 -5) right)] (wrap output))) - _ (promise.wait +100) + _ (promise.wait |100) output (promise.future (atom.read output))] (assert "Can merge channels." (list/= (list 0 1 2 3 4 5 0 -1 -2 -3 -4 -5) @@ -86,7 +86,7 @@ output (read! mapped) _ (write! (list 0 1 2 3 4 5) inputs)] (wrap output))) - _ (promise.wait +100) + _ (promise.wait |100) output (promise.future (atom.read output))] (assert "Functor goes over every element in a channel." (list/= (list 1 2 3 4 5 6) @@ -102,7 +102,7 @@ _ (write! (list inc) >f<) _ (write! (list 12345) >a<)] (wrap output))) - _ (promise.wait +100) + _ (promise.wait |100) output (promise.future (atom.read output))] (assert "Apply works over all channel values." (list/= (list 12346) @@ -111,10 +111,10 @@ (wrap (do promise.Monad [output (promise.future (read! (do frp.Monad - [f (frp.from-promise (promise.delay +100 inc)) - a (frp.from-promise (promise.delay +200 12345))] - (frp.from-promise (promise.delay +300 (f a)))))) - _ (promise.wait +700) + [f (frp.from-promise (promise.delay |100 inc)) + a (frp.from-promise (promise.delay |200 12345))] + (frp.from-promise (promise.delay |300 (f a)))))) + _ (promise.wait |700) output (promise.future (atom.read output))] (assert "Valid monad." (list/= (list 12346) diff --git a/stdlib/test/test/lux/concurrency/promise.lux b/stdlib/test/test/lux/concurrency/promise.lux index 76c5df05c..749adf802 100644 --- a/stdlib/test/test/lux/concurrency/promise.lux +++ b/stdlib/test/test/lux/concurrency/promise.lux @@ -18,7 +18,7 @@ running?))) (wrap (do &.Monad - [_ (&.wait +500)] + [_ (&.wait |500)] (assert "Can wait for a specified amount of time." #1))) @@ -29,10 +29,10 @@ (and left (not right))))) (wrap (do &.Monad - [?left (&.or (&.delay +100 #1) - (&.delay +200 #0)) - ?right (&.or (&.delay +200 #1) - (&.delay +100 #0))] + [?left (&.or (&.delay |100 #1) + (&.delay |200 #0)) + ?right (&.or (&.delay |200 #1) + (&.delay |100 #0))] (assert "Can combine promises alternatively." (case [?left ?right] [(#.Left #1) (#.Right #0)] @@ -42,17 +42,17 @@ #0)))) (wrap (do &.Monad - [?left (&.either (&.delay +100 #1) - (&.delay +200 #0)) - ?right (&.either (&.delay +200 #1) - (&.delay +100 #0))] + [?left (&.either (&.delay |100 #1) + (&.delay |200 #0)) + ?right (&.either (&.delay |200 #1) + (&.delay |100 #0))] (assert "Can combine promises alternatively [Part 2]." (and ?left (not ?right))))) (test "Can poll a promise for its value." (and (|> (&.poll (&/wrap #1)) (case> (#.Some #1) #1 _ #0)) - (|> (&.poll (&.delay +200 #1)) + (|> (&.poll (&.delay |200 #1)) (case> #.None #1 _ #0)))) (test "Cannot re-resolve a resolved promise." @@ -60,8 +60,8 @@ (io.run (&.resolve #1 (: (&.Promise Bit) (&.promise #.None)))))) (wrap (do &.Monad - [?none (&.time-out +100 (&.delay +200 #1)) - ?some (&.time-out +200 (&.delay +100 #1))] + [?none (&.time-out |100 (&.delay |200 #1)) + ?some (&.time-out |200 (&.delay |100 #1))] (assert "Can establish maximum waiting times for promises to be fulfilled." (case [?none ?some] [#.None (#.Some #1)] diff --git a/stdlib/test/test/lux/concurrency/semaphore.lux b/stdlib/test/test/lux/concurrency/semaphore.lux index df145ff82..73ee3f8af 100644 --- a/stdlib/test/test/lux/concurrency/semaphore.lux +++ b/stdlib/test/test/lux/concurrency/semaphore.lux @@ -20,16 +20,16 @@ (def: (wait-many-times times semaphore) (-> Nat /.Semaphore (Promise Any)) (loop [steps times] - (if (n/> +0 steps) + (if (n/> |0 steps) (do promise.Monad [_ (/.wait semaphore)] (recur (dec steps))) (:: promise.Monad wrap [])))) (context: "Semaphore." - (<| (times +100) + (<| (times |100) (do @ - [open-positions (|> r.nat (:: @ map (|>> (n/% +10) (n/max +1))))] + [open-positions (|> r.nat (:: @ map (|>> (n/% |10) (n/max |1))))] ($_ seq (let [semaphore (/.semaphore open-positions)] (wrap (do promise.Monad @@ -38,7 +38,7 @@ #1)))) (let [semaphore (/.semaphore open-positions)] (wrap (do promise.Monad - [result (<| (promise.time-out +100) + [result (<| (promise.time-out |100) (wait-many-times (inc open-positions) semaphore))] (assert "Waiting on a semaphore more than the number of open positions blocks the process." (case result @@ -50,8 +50,8 @@ (let [semaphore (/.semaphore open-positions)] (wrap (do promise.Monad [_ (: (Promise Any) - (loop [steps (n/* +2 open-positions)] - (if (n/> +0 steps) + (loop [steps (n/* |2 open-positions)] + (if (n/> |0 steps) (do @ [_ (/.wait semaphore) _ (/.signal semaphore)] @@ -68,7 +68,7 @@ #let [_ (io.run (atom.update (|>> (format "B")) resource))]] (wrap []))] - _ (promise.wait +100) + _ (promise.wait |100) _ (exec (io.run (atom.update (|>> (format "A")) resource)) (/.signal semaphore)) @@ -79,9 +79,9 @@ )))) (context: "Mutex." - (<| (times +100) + (<| (times |100) (do @ - [repetitions (|> r.nat (:: @ map (|>> (n/% +100) (n/max +10))))] + [repetitions (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10))))] ($_ seq (let [mutex (/.mutex [])] (wrap (do promise.Monad @@ -122,12 +122,12 @@ (wrap []))) (context: "Barrier." - (let [limit +10 + (let [limit |10 barrier (/.barrier (maybe.assume (/.limit limit))) resource (atom.atom "")] ($_ seq (wrap (do promise.Monad - [#let [ids (list.n/range +0 (dec limit)) + [#let [ids (list.n/range |0 (dec limit)) waiters (list/map (function (_ id) (let [process (waiter resource barrier id)] (exec (io.run (atom.update (|>> (format "_")) resource)) diff --git a/stdlib/test/test/lux/concurrency/stm.lux b/stdlib/test/test/lux/concurrency/stm.lux index a1897b846..4105551bb 100644 --- a/stdlib/test/test/lux/concurrency/stm.lux +++ b/stdlib/test/test/lux/concurrency/stm.lux @@ -28,45 +28,45 @@ channel)] (wrap output))) -(def: iterations-per-process Nat +100) +(def: iterations-per-process Nat |100) (context: "STM" ($_ seq (wrap (do promise.Monad - [output (&.commit (&.read (&.var +0)))] + [output (&.commit (&.read (&.var |0)))] (assert "Can read STM vars." - (n/= +0 output)))) + (n/= |0 output)))) (wrap (do promise.Monad - [#let [_var (&.var +0)] + [#let [_var (&.var |0)] output (&.commit (do &.Monad - [_ (&.write +5 _var)] + [_ (&.write |5 _var)] (&.read _var)))] (assert "Can write STM vars." - (n/= +5 output)))) + (n/= |5 output)))) (wrap (do promise.Monad - [#let [_var (&.var +5)] + [#let [_var (&.var |5)] output (&.commit (do &.Monad - [_ (&.update (n/* +3) _var)] + [_ (&.update (n/* |3) _var)] (&.read _var)))] (assert "Can update STM vars." - (n/= +15 output)))) + (n/= |15 output)))) (wrap (do promise.Monad - [#let [_var (&.var +0) + [#let [_var (&.var |0) changes (io.run (read! (io.run (&.follow _var))))] - _ (&.commit (&.write +5 _var)) - _ (&.commit (&.update (n/* +3) _var)) + _ (&.commit (&.write |5 _var)) + _ (&.commit (&.update (n/* |3) _var)) changes (promise.future (atom.read changes))] (assert "Can follow all the changes to STM vars." (:: (list.Equivalence number.Equivalence) = - (list +5 +15) + (list |5 |15) (list.reverse changes))))) - (wrap (let [_concurrency-var (&.var +0)] + (wrap (let [_concurrency-var (&.var |0)] (do promise.Monad [_ (|> promise.parallelism - (list.n/range +1) + (list.n/range |1) (list/map (function (_ _) (|> iterations-per-process - (list.n/range +1) + (list.n/range |1) (M.map @ (function (_ _) (&.commit (&.update inc _concurrency-var))))))) (M.seq @)) last-val (&.commit (&.read _concurrency-var))] diff --git a/stdlib/test/test/lux/control/continuation.lux b/stdlib/test/test/lux/control/continuation.lux index be7ac920c..489742c04 100644 --- a/stdlib/test/test/lux/control/continuation.lux +++ b/stdlib/test/test/lux/control/continuation.lux @@ -11,12 +11,12 @@ lux/test) (context: "Continuations" - (<| (times +100) + (<| (times |100) (do @ [sample r.nat #let [(^open "&/.") &.Apply (^open "&/.") &.Monad] - elems (r.list +3 r.nat)] + elems (r.list |3 r.nat)] ($_ seq (test "Can run continuations to compute their values." (n/= sample (&.run (&/wrap sample)))) @@ -34,7 +34,7 @@ (wrap (func arg)))))) (test "Can use the current-continuation as a escape hatch." - (n/= (n/* +2 sample) + (n/= (n/* |2 sample) (&.run (do &.Monad [value (&.call/cc (function (_ k) @@ -42,16 +42,16 @@ [temp (k sample)] ## If this code where to run, ## the output would be - ## (n/* +4 sample) + ## (n/* |4 sample) (k temp))))] - (wrap (n/* +2 value)))))) + (wrap (n/* |2 value)))))) (test "Can use the current-continuation to build a time machine." - (n/= (n/+ +100 sample) + (n/= (n/+ |100 sample) (&.run (do &.Monad - [[restart [output idx]] (&.portal [sample +0])] - (if (n/< +10 idx) - (restart [(n/+ +10 output) (inc idx)]) + [[restart [output idx]] (&.portal [sample |0])] + (if (n/< |10 idx) + (restart [(n/+ |10 output) (inc idx)]) (wrap output)))))) (test "Can use delimited continuations with shifting." diff --git a/stdlib/test/test/lux/control/exception.lux b/stdlib/test/test/lux/control/exception.lux index c1aa9d08e..3cffa26c3 100644 --- a/stdlib/test/test/lux/control/exception.lux +++ b/stdlib/test/test/lux/control/exception.lux @@ -18,7 +18,7 @@ (exception: unknown-exception) (context: "Exceptions" - (<| (times +100) + (<| (times |100) (do @ [should-throw? r.bit which? r.bit diff --git a/stdlib/test/test/lux/control/interval.lux b/stdlib/test/test/lux/control/interval.lux index ba2e3c7b3..2c7192b59 100644 --- a/stdlib/test/test/lux/control/interval.lux +++ b/stdlib/test/test/lux/control/interval.lux @@ -14,7 +14,7 @@ ["L" list]]]]) (context: "Equivalence." - (<| (times +100) + (<| (times |100) (do @ [bottom r.int top r.int @@ -29,7 +29,7 @@ (&/= self self)))))))) (context: "Boundaries" - (<| (times +100) + (<| (times |100) (do @ [bottom r.int top r.int @@ -85,7 +85,7 @@ gen-singleton)) (context: "Unions" - (<| (times +100) + (<| (times |100) (do @ [some-interval gen-interval left-inner gen-inner @@ -107,7 +107,7 @@ )))) (context: "Intersections" - (<| (times +100) + (<| (times |100) (do @ [some-interval gen-interval left-inner gen-inner @@ -129,7 +129,7 @@ )))) (context: "Complement" - (<| (times +100) + (<| (times |100) (do @ [some-interval gen-interval #let [(^open "&/.") &.Equivalence]] @@ -141,9 +141,9 @@ )))) (context: "Positioning/location" - (<| (times +100) + (<| (times |100) (do @ - [[l m r] (|> (r.set number.Hash +3 r.int) + [[l m r] (|> (r.set number.Hash |3 r.int) (:: @ map (|>> S.to-list (L.sort i/<) (case> (^ (list b t1 t2)) @@ -163,9 +163,9 @@ )))) (context: "Touching intervals" - (<| (times +100) + (<| (times |100) (do @ - [[b t1 t2] (|> (r.set number.Hash +3 r.int) + [[b t1 t2] (|> (r.set number.Hash |3 r.int) (:: @ map (|>> S.to-list (L.sort i/<) (case> (^ (list b t1 t2)) @@ -189,10 +189,10 @@ )))) (context: "Nesting & overlap" - (<| (times +100) + (<| (times |100) (do @ [some-interval gen-interval - [x0 x1 x2 x3] (|> (r.set number.Hash +4 r.int) + [x0 x1 x2 x3] (|> (r.set number.Hash |4 r.int) (:: @ map (|>> S.to-list (L.sort i/<) (case> (^ (list x0 x1 x2 x3)) diff --git a/stdlib/test/test/lux/control/parser.lux b/stdlib/test/test/lux/control/parser.lux index 505ee4b55..c4f42a7b7 100644 --- a/stdlib/test/test/lux/control/parser.lux +++ b/stdlib/test/test/lux/control/parser.lux @@ -67,27 +67,27 @@ (context: "Combinators [Part 1]" ($_ seq (test "Can optionally succeed with some parser." - (and (match (#.Some +123) - (&.run (list (code.nat +123)) + (and (match (#.Some |123) + (&.run (list (code.nat |123)) (&.maybe s.nat))) (match #.None (&.run (list (code.int -123)) (&.maybe s.nat))))) (test "Can apply a parser 0 or more times." - (and (match (list +123 +456 +789) - (&.run (list (code.nat +123) (code.nat +456) (code.nat +789)) + (and (match (list |123 |456 |789) + (&.run (list (code.nat |123) (code.nat |456) (code.nat |789)) (&.some s.nat))) (match (list) (&.run (list (code.int -123)) (&.some s.nat))))) (test "Can apply a parser 1 or more times." - (and (match (list +123 +456 +789) - (&.run (list (code.nat +123) (code.nat +456) (code.nat +789)) + (and (match (list |123 |456 |789) + (&.run (list (code.nat |123) (code.nat |456) (code.nat |789)) (&.many s.nat))) - (match (list +123) - (&.run (list (code.nat +123)) + (match (list |123) + (&.run (list (code.nat |123)) (&.many s.nat))) (fails? (&.run (list (code.int -123)) (&.many s.nat))))) @@ -124,40 +124,40 @@ (test "Can apply a parser N times." (and (match (list 123 456 789) (&.run (list (code.int 123) (code.int 456) (code.int 789)) - (&.exactly +3 s.int))) + (&.exactly |3 s.int))) (match (list 123 456) (&.run (list (code.int 123) (code.int 456) (code.int 789)) - (&.exactly +2 s.int))) + (&.exactly |2 s.int))) (fails? (&.run (list (code.int 123) (code.int 456) (code.int 789)) - (&.exactly +4 s.int))))) + (&.exactly |4 s.int))))) (test "Can apply a parser at-least N times." (and (match (list 123 456 789) (&.run (list (code.int 123) (code.int 456) (code.int 789)) - (&.at-least +3 s.int))) + (&.at-least |3 s.int))) (match (list 123 456 789) (&.run (list (code.int 123) (code.int 456) (code.int 789)) - (&.at-least +2 s.int))) + (&.at-least |2 s.int))) (fails? (&.run (list (code.int 123) (code.int 456) (code.int 789)) - (&.at-least +4 s.int))))) + (&.at-least |4 s.int))))) (test "Can apply a parser at-most N times." (and (match (list 123 456 789) (&.run (list (code.int 123) (code.int 456) (code.int 789)) - (&.at-most +3 s.int))) + (&.at-most |3 s.int))) (match (list 123 456) (&.run (list (code.int 123) (code.int 456) (code.int 789)) - (&.at-most +2 s.int))) + (&.at-most |2 s.int))) (match (list 123 456 789) (&.run (list (code.int 123) (code.int 456) (code.int 789)) - (&.at-most +4 s.int))))) + (&.at-most |4 s.int))))) (test "Can apply a parser between N and M times." (and (match (list 123 456 789) (&.run (list (code.int 123) (code.int 456) (code.int 789)) - (&.between +3 +10 s.int))) + (&.between |3 |10 s.int))) (fails? (&.run (list (code.int 123) (code.int 456) (code.int 789)) - (&.between +4 +10 s.int))))) + (&.between |4 |10 s.int))))) (test "Can parse while taking separators into account." (and (match (list 123 456 789) diff --git a/stdlib/test/test/lux/control/region.lux b/stdlib/test/test/lux/control/region.lux index b6cd43ea7..59f523666 100644 --- a/stdlib/test/test/lux/control/region.lux +++ b/stdlib/test/test/lux/control/region.lux @@ -27,14 +27,14 @@ ) (context: "Regions." - (<| (times +100) + (<| (times |100) (do @ - [expected-clean-ups (|> r.nat (:: @ map (|>> (n/% +100) (n/max +1))))] + [expected-clean-ups (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1))))] ($_ seq (test "Clean-up functions are always run when region execution is done." (thread.run (do thread.Monad - [clean-up-counter (thread.box +0) + [clean-up-counter (thread.box |0) #let [@@ @ count-clean-up (function (_ value) (do @ @@ -43,7 +43,7 @@ outcome (/.run @ (do (/.Monad @) [_ (monad.map @ (/.acquire @@ count-clean-up) - (list.n/range +1 expected-clean-ups))] + (list.n/range |1 expected-clean-ups))] (wrap []))) actual-clean-ups (thread.read clean-up-counter)] (wrap (and (success? outcome) @@ -52,7 +52,7 @@ (test "Can clean-up despite errors." (thread.run (do thread.Monad - [clean-up-counter (thread.box +0) + [clean-up-counter (thread.box |0) #let [@@ @ count-clean-up (function (_ value) (do @ @@ -61,7 +61,7 @@ outcome (/.run @ (do (/.Monad @) [_ (monad.map @ (/.acquire @@ count-clean-up) - (list.n/range +1 expected-clean-ups)) + (list.n/range |1 expected-clean-ups)) _ (/.throw @@ oops [])] (wrap []))) actual-clean-ups (thread.read clean-up-counter)] @@ -71,7 +71,7 @@ (test "Errors can propagate from the cleaners." (thread.run (do thread.Monad - [clean-up-counter (thread.box +0) + [clean-up-counter (thread.box |0) #let [@@ @ count-clean-up (function (_ value) (do @ @@ -80,17 +80,17 @@ outcome (/.run @ (do (/.Monad @) [_ (monad.map @ (/.acquire @@ count-clean-up) - (list.n/range +1 expected-clean-ups))] + (list.n/range |1 expected-clean-ups))] (wrap []))) actual-clean-ups (thread.read clean-up-counter)] - (wrap (and (or (n/= +0 expected-clean-ups) + (wrap (and (or (n/= |0 expected-clean-ups) (error? outcome)) (n/= expected-clean-ups actual-clean-ups)))))) (test "Can lift operations." (thread.run (do thread.Monad - [clean-up-counter (thread.box +0) + [clean-up-counter (thread.box |0) #let [@@ @] outcome (/.run @ (do (/.Monad @) diff --git a/stdlib/test/test/lux/control/state.lux b/stdlib/test/test/lux/control/state.lux index e7f26bfe3..ba5fefb6d 100644 --- a/stdlib/test/test/lux/control/state.lux +++ b/stdlib/test/test/lux/control/state.lux @@ -19,7 +19,7 @@ (n/= output))) (context: "Basics" - (<| (times +100) + (<| (times |100) (do @ [state r.nat value r.nat] @@ -47,7 +47,7 @@ )))) (context: "Structures" - (<| (times +100) + (<| (times |100) (do @ [state r.nat value r.nat @@ -75,7 +75,7 @@ )))) (context: "Monad transformer" - (<| (times +100) + (<| (times |100) (do @ [state r.nat left r.nat @@ -95,23 +95,23 @@ )))) (context: "Loops" - (<| (times +100) + (<| (times |100) (do @ - [limit (|> r.nat (:: @ map (n/% +10))) + [limit (|> r.nat (:: @ map (n/% |10))) #let [condition (do &.Monad [state &.get] (wrap (n/< limit state)))]] ($_ seq (test "'while' will only execute if the condition is #1." (|> (&.while condition (&.update inc)) - (&.run +0) + (&.run |0) (case> [state' output'] (n/= limit state')))) (test "'do-while' will execute at least once." (|> (&.do-while condition (&.update inc)) - (&.run +0) + (&.run |0) (case> [state' output'] (or (n/= limit state') - (and (n/= +0 limit) - (n/= +1 state')))))) + (and (n/= |0 limit) + (n/= |1 state')))))) )))) diff --git a/stdlib/test/test/lux/control/thread.lux b/stdlib/test/test/lux/control/thread.lux index 8c7dcc592..5ac666c64 100644 --- a/stdlib/test/test/lux/control/thread.lux +++ b/stdlib/test/test/lux/control/thread.lux @@ -7,15 +7,15 @@ (def: _test0_ Nat (/.run (do /.Monad - [box (/.box +123) - old (/.update (n/* +2) box) + [box (/.box |123) + old (/.update (n/* |2) box) new (/.read box)] (wrap (n/+ old new))))) (def: _test1_ (All [!] (/.Thread ! Nat)) (do /.Monad - [box (/.box +123) - old (/.update (n/* +2) box) + [box (/.box |123) + old (/.update (n/* |2) box) new (/.read box)] (wrap (n/+ old new)))) diff --git a/stdlib/test/test/lux/data/bit.lux b/stdlib/test/test/lux/data/bit.lux index 7eea70f7a..deabfe265 100644 --- a/stdlib/test/test/lux/data/bit.lux +++ b/stdlib/test/test/lux/data/bit.lux @@ -9,7 +9,7 @@ lux/test) (context: "Bit operations." - (<| (times +100) + (<| (times |100) (do @ [value r.bit] (test "" (and (not (and value (not value))) diff --git a/stdlib/test/test/lux/data/collection/array.lux b/stdlib/test/test/lux/data/collection/array.lux index 0e42c7132..df43a3ef1 100644 --- a/stdlib/test/test/lux/data/collection/array.lux +++ b/stdlib/test/test/lux/data/collection/array.lux @@ -16,10 +16,10 @@ (def: bounded-size (r.Random Nat) (|> r.nat - (:: r.Monad map (|>> (n/% +100) (n/+ +1))))) + (:: r.Monad map (|>> (n/% |100) (n/+ |1))))) (context: "Arrays and their copies" - (<| (times +100) + (<| (times |100) (do @ [size bounded-size original (r.array size r.nat) @@ -35,7 +35,7 @@ (and (:: (@.Equivalence number.Equivalence) = original clone) (not (is? original clone)))) (test "Full-range manual copies should give the same result as cloning." - (exec (@.copy size +0 original +0 copy) + (exec (@.copy size |0 original |0 copy) (and (:: (@.Equivalence number.Equivalence) = original copy) (not (is? original copy))))) (test "Array folding should go over all values." @@ -43,7 +43,7 @@ (function (_ x idx) (exec (@.write idx x manual-copy) (inc idx))) - +0 + |0 original) (:: (@.Equivalence number.Equivalence) = original manual-copy))) (test "Transformations between (full) arrays and lists shouldn't cause lose or change any values." @@ -53,7 +53,7 @@ )))) (context: "Array mutation" - (<| (times +100) + (<| (times |100) (do @ [size bounded-size idx (:: @ map (n/% size) r.nat) @@ -71,17 +71,17 @@ #.None #0)) (test "All cells should be occupied on a full array." (and (n/= size (@.occupied array)) - (n/= +0 (@.vacant array)))) + (n/= |0 (@.vacant array)))) (test "Filtering mutates the array to remove invalid values." (exec (@.filter n/even? array) (and (n/< size (@.occupied array)) - (n/> +0 (@.vacant array)) + (n/> |0 (@.vacant array)) (n/= size (n/+ (@.occupied array) (@.vacant array)))))) )))) (context: "Finding values." - (<| (times +100) + (<| (times |100) (do @ [size bounded-size array (|> (r.array size r.nat) @@ -100,7 +100,7 @@ #.None #0))))))) (context: "Functor" - (<| (times +100) + (<| (times |100) (do @ [size bounded-size array (r.array size r.nat)] @@ -118,7 +118,7 @@ (= array back-again))))))))) (context: "Monoid" - (<| (times +100) + (<| (times |100) (do @ [sizeL bounded-size sizeR bounded-size @@ -133,11 +133,11 @@ (test "First elements of fused array should equal the first array." (|> (: (Array Nat) (@.new sizeL)) - (@.copy sizeL +0 fusion +0) + (@.copy sizeL |0 fusion |0) (= left))) (test "Last elements of fused array should equal the second array." (|> (: (Array Nat) (@.new sizeR)) - (@.copy sizeR sizeL fusion +0) + (@.copy sizeR sizeL fusion |0) (= right))) )))) diff --git a/stdlib/test/test/lux/data/collection/bits.lux b/stdlib/test/test/lux/data/collection/bits.lux index c9c1a1b85..bf6823386 100644 --- a/stdlib/test/test/lux/data/collection/bits.lux +++ b/stdlib/test/test/lux/data/collection/bits.lux @@ -22,14 +22,14 @@ (def: bits (r.Random /.Bits) (do r.Monad - [size (size +1 +1_000) + [size (size |1 |1_000) idx (|> r.nat (:: @ map (n/% size)))] (wrap (|> /.empty (/.set idx))))) (context: "Bits." - (<| (times +100) + (<| (times |100) (do @ - [size (size +1 +1_000) + [size (size |1 |1_000) idx (|> r.nat (:: @ map (n/% size))) sample bits] ($_ seq @@ -43,14 +43,14 @@ (|> /.empty (/.flip idx) (/.flip idx) (/.get idx) not))) (test "Bits (only) grow when (and as much as) necessary." - (and (n/= +0 (/.capacity /.empty)) + (and (n/= |0 (/.capacity /.empty)) (|> /.empty (/.set idx) /.capacity (n/- idx) - (predicate.union (n/>= +0) + (predicate.union (n/>= |0) (n/< /.chunk-size))))) (test "Bits (must) shrink when (and as much as) possible." (let [grown (/.flip idx /.empty)] - (and (n/> +0 (/.capacity grown)) + (and (n/> |0 (/.capacity grown)) (is? /.empty (/.flip idx grown))))) (test "Intersection can be detected when there are set bits in common." diff --git a/stdlib/test/test/lux/data/collection/dictionary.lux b/stdlib/test/test/lux/data/collection/dictionary.lux index aec463ec8..a30cdaef0 100644 --- a/stdlib/test/test/lux/data/collection/dictionary.lux +++ b/stdlib/test/test/lux/data/collection/dictionary.lux @@ -14,9 +14,9 @@ lux/test) (context: "Dictionaries." - (<| (times +100) + (<| (times |100) (do @ - [#let [capped-nat (:: r.Monad map (n/% +100) r.nat)] + [#let [capped-nat (:: r.Monad map (n/% |100) r.nat)] size capped-nat dict (r.dictionary number.Hash size r.nat capped-nat) non-key (|> r.nat (r.filter (function (_ key) (not (&.contains? key dict))))) @@ -26,7 +26,7 @@ (n/= size (&.size dict))) (test "Dictionaries of size 0 should be considered empty." - (if (n/= +0 size) + (if (n/= |0 size) (&.empty? dict) (not (&.empty? dict)))) @@ -62,7 +62,7 @@ _ #1)) (test "Shouldn't be able to put~ an existing key." - (or (n/= +0 size) + (or (n/= |0 size) (let [first-key (|> dict &.keys list.head maybe.assume)] (case (&.get first-key (&.put~ first-key test-val dict)) (#.Some v) (not (n/= test-val v)) @@ -106,7 +106,7 @@ (= dict' (&.merge dict' dict)))) (test "Can merge values in such a way that they become combined." - (list.every? (function (_ [x x*2]) (n/= (n/* +2 x) x*2)) + (list.every? (function (_ [x x*2]) (n/= (n/* |2 x) x*2)) (list.zip2 (&.values dict) (&.values (&.merge-with n/+ dict dict))))) @@ -115,10 +115,10 @@ (&.put non-key test-val) (&.select (list non-key)) &.size - (n/= +1))) + (n/= |1))) (test "Should be able to re-bind existing values to different keys." - (or (n/= +0 size) + (or (n/= |0 size) (let [first-key (|> dict &.keys list.head maybe.assume) rebound (&.re-bind first-key non-key dict)] (and (n/= (&.size dict) (&.size rebound)) diff --git a/stdlib/test/test/lux/data/collection/dictionary/ordered.lux b/stdlib/test/test/lux/data/collection/dictionary/ordered.lux index b3d917625..d6ec22ec1 100644 --- a/stdlib/test/test/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/test/test/lux/data/collection/dictionary/ordered.lux @@ -16,9 +16,9 @@ lux/test) (context: "Dictionary" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (n/% +100))) + [size (|> r.nat (:: @ map (n/% |100))) keys (r.set number.Hash size r.nat) values (r.set number.Hash size r.nat) extra-key (|> r.nat (r.filter (|>> (s.member? keys) not))) diff --git a/stdlib/test/test/lux/data/collection/list.lux b/stdlib/test/test/lux/data/collection/list.lux index 2afdcefe2..9a8b4a4cd 100644 --- a/stdlib/test/test/lux/data/collection/list.lux +++ b/stdlib/test/test/lux/data/collection/list.lux @@ -18,10 +18,10 @@ (def: bounded-size (r.Random Nat) (|> r.nat - (:: r.Monad map (|>> (n/% +100) (n/+ +10))))) + (:: r.Monad map (|>> (n/% |100) (n/+ |10))))) (context: "Lists: Part 1" - (<| (times +100) + (<| (times |100) (do @ [size bounded-size idx (:: @ map (n/% size) r.nat) @@ -67,7 +67,7 @@ )))) (context: "Lists: Part 2" - (<| (times +100) + (<| (times |100) (do @ [size bounded-size idx (:: @ map (n/% size) r.nat) @@ -115,7 +115,7 @@ ))) (test "Segmenting the list in pairs should yield as many elements as N/2." - (n/= (n// +2 size) + (n/= (n// |2 size) (&.size (&.as-pairs sample)))) (test "Sorting a list shouldn't change it's size." @@ -128,7 +128,7 @@ )))) (context: "Lists: Part 3" - (<| (times +100) + (<| (times |100) (do @ [size bounded-size idx (:: @ map (n/% size) r.nat) @@ -136,8 +136,8 @@ other-size bounded-size other-sample (r.list other-size r.nat) separator r.nat - from (|> r.nat (:: @ map (n/% +10))) - to (|> r.nat (:: @ map (n/% +10))) + from (|> r.nat (:: @ map (n/% |10))) + to (|> r.nat (:: @ map (n/% |10))) #let [(^open ".") (&.Equivalence number.Equivalence) (^open "&/.") &.Functor]] ($_ seq @@ -167,7 +167,7 @@ (test "The 'interpose' function places a value between every member of a list." (let [(^open ".") &.Functor sample+ (&.interpose separator sample)] - (and (n/= (|> size (n/* +2) dec) + (and (n/= (|> size (n/* |2) dec) (&.size sample+)) (|> sample+ &.as-pairs (map product.right) (&.every? (n/= separator)))))) @@ -204,9 +204,9 @@ (&.every? (bit.complement n/even?) sample)))) (test "You can iteratively construct a list, generating values until you're done." - (= (&.n/range +0 (dec size)) + (= (&.n/range |0 (dec size)) (&.iterate (function (_ n) (if (n/< size n) (#.Some (inc n)) #.None)) - +0))) + |0))) (test "Can enumerate all elements in a list." (let [enum-sample (&.enumerate sample)] diff --git a/stdlib/test/test/lux/data/collection/queue.lux b/stdlib/test/test/lux/data/collection/queue.lux index 935f8f22b..79c254341 100644 --- a/stdlib/test/test/lux/data/collection/queue.lux +++ b/stdlib/test/test/lux/data/collection/queue.lux @@ -11,15 +11,15 @@ lux/test) (context: "Queues" - (<| (times +100) + (<| (times |100) (do @ - [size (:: @ map (n/% +100) r.nat) + [size (:: @ map (n/% |100) r.nat) sample (r.queue size r.nat) non-member (|> r.nat (r.filter (|>> (&.member? number.Equivalence sample) not)))] ($_ seq (test "I can query the size of a queue (and empty queues have size 0)." - (if (n/= +0 size) + (if (n/= |0 size) (&.empty? sample) (n/= size (&.size sample)))) diff --git a/stdlib/test/test/lux/data/collection/queue/priority.lux b/stdlib/test/test/lux/data/collection/queue/priority.lux index b5f8a1d17..b0adafd5e 100644 --- a/stdlib/test/test/lux/data/collection/queue/priority.lux +++ b/stdlib/test/test/lux/data/collection/queue/priority.lux @@ -24,9 +24,9 @@ inputs))) (context: "Queues" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (n/% +100))) + [size (|> r.nat (:: @ map (n/% |100))) sample (gen-queue size) non-member-priority r.nat non-member (|> r.nat (r.filter (|>> (&.member? number.Equivalence sample) not)))] @@ -37,7 +37,7 @@ (test "Enqueueing and dequeing affects the size of queues." (and (n/= (inc size) (&.size (&.push non-member-priority non-member sample))) - (or (n/= +0 (&.size sample)) + (or (n/= |0 (&.size sample)) (n/= (dec size) (&.size (&.pop sample)))))) @@ -46,7 +46,7 @@ (&.member? number.Equivalence (&.push non-member-priority non-member sample) non-member)) - (or (n/= +0 (&.size sample)) + (or (n/= |0 (&.size sample)) (and (&.member? number.Equivalence sample (maybe.assume (&.peek sample))) diff --git a/stdlib/test/test/lux/data/collection/row.lux b/stdlib/test/test/lux/data/collection/row.lux index ec6d7659d..f33a369b7 100644 --- a/stdlib/test/test/lux/data/collection/row.lux +++ b/stdlib/test/test/lux/data/collection/row.lux @@ -12,9 +12,9 @@ lux/test) (context: "Rows" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% +100) (n/max +1)))) + [size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1)))) idx (|> r.nat (:: @ map (n/% size))) sample (r.row size r.nat) other-sample (r.row size r.nat) @@ -27,8 +27,8 @@ ($_ seq (test "Can query size of row." (if (&.empty? sample) - (and (n/= +0 size) - (n/= +0 (&.size sample))) + (and (n/= |0 size) + (n/= |0 (&.size sample))) (n/= size (&.size sample)))) (test "Can add and remove elements to rows." @@ -56,8 +56,8 @@ (&.member? number.Equivalence (&.add non-member sample) non-member))) (test "Can fold over elements of row." - (n/= (list/fold n/+ +0 (&.to-list sample)) - (&/fold n/+ +0 sample))) + (n/= (list/fold n/+ |0 (&.to-list sample)) + (&/fold n/+ |0 sample))) (test "Functor goes over every element." (let [there (&/map inc sample) diff --git a/stdlib/test/test/lux/data/collection/sequence.lux b/stdlib/test/test/lux/data/collection/sequence.lux index dd545e906..1f0298afd 100644 --- a/stdlib/test/test/lux/data/collection/sequence.lux +++ b/stdlib/test/test/lux/data/collection/sequence.lux @@ -15,38 +15,38 @@ lux/test) (context: "Sequences" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% +100) (n/max +2)))) - offset (|> r.nat (:: @ map (n/% +100))) - factor (|> r.nat (:: @ map (|>> (n/% +100) (n/max +2)))) + [size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |2)))) + offset (|> r.nat (:: @ map (n/% |100))) + factor (|> r.nat (:: @ map (|>> (n/% |100) (n/max |2)))) elem r.nat cycle-seed (r.list size r.nat) - cycle-sample-idx (|> r.nat (:: @ map (n/% +1000))) + cycle-sample-idx (|> r.nat (:: @ map (n/% |1000))) #let [(^open "List/.") (list.Equivalence number.Equivalence) - sample0 (&.iterate inc +0) + sample0 (&.iterate inc |0) sample1 (&.iterate inc offset)]] ($_ seq (test "Can move along a sequence and take slices off it." - (and (and (List/= (list.n/range +0 (dec size)) + (and (and (List/= (list.n/range |0 (dec size)) (&.take size sample0)) (List/= (list.n/range offset (dec (n/+ offset size))) (&.take size (&.drop offset sample0))) (let [[drops takes] (&.split size sample0)] - (and (List/= (list.n/range +0 (dec size)) + (and (List/= (list.n/range |0 (dec size)) drops) - (List/= (list.n/range size (dec (n/* +2 size))) + (List/= (list.n/range size (dec (n/* |2 size))) (&.take size takes))))) - (and (List/= (list.n/range +0 (dec size)) + (and (List/= (list.n/range |0 (dec size)) (&.take-while (n/< size) sample0)) (List/= (list.n/range offset (dec (n/+ offset size))) (&.take-while (n/< (n/+ offset size)) (&.drop-while (n/< offset) sample0))) (let [[drops takes] (&.split-while (n/< size) sample0)] - (and (List/= (list.n/range +0 (dec size)) + (and (List/= (list.n/range |0 (dec size)) drops) - (List/= (list.n/range size (dec (n/* +2 size))) - (&.take-while (n/< (n/* +2 size)) takes))))) + (List/= (list.n/range size (dec (n/* |2 size))) + (&.take-while (n/< (n/* |2 size)) takes))))) )) (test "Can repeat any element and infinite number of times." @@ -58,13 +58,13 @@ (&.take size (&.tail sample1))))) (test "Can filter sequences." - (and (n/= (n/* +2 offset) + (and (n/= (n/* |2 offset) (&.nth offset (&.filter n/even? sample0))) - (let [[evens odds] (&.partition n/even? (&.iterate inc +0))] - (and (n/= (n/* +2 offset) + (let [[evens odds] (&.partition n/even? (&.iterate inc |0))] + (and (n/= (n/* |2 offset) (&.nth offset evens)) - (n/= (inc (n/* +2 offset)) + (n/= (inc (n/* |2 offset)) (&.nth offset odds)))))) (test "Functor goes over 'all' elements in a sequence." diff --git a/stdlib/test/test/lux/data/collection/set.lux b/stdlib/test/test/lux/data/collection/set.lux index 78bb1bc42..d67503b53 100644 --- a/stdlib/test/test/lux/data/collection/set.lux +++ b/stdlib/test/test/lux/data/collection/set.lux @@ -14,10 +14,10 @@ (def: gen-nat (r.Random Nat) (|> r.nat - (:: r.Monad map (n/% +100)))) + (:: r.Monad map (n/% |100)))) (context: "Sets" - (<| (times +100) + (<| (times |100) (do @ [sizeL gen-nat sizeR gen-nat diff --git a/stdlib/test/test/lux/data/collection/set/ordered.lux b/stdlib/test/test/lux/data/collection/set/ordered.lux index fe7b3069c..16eca4081 100644 --- a/stdlib/test/test/lux/data/collection/set/ordered.lux +++ b/stdlib/test/test/lux/data/collection/set/ordered.lux @@ -17,10 +17,10 @@ (def: gen-nat (r.Random Nat) (|> r.nat - (:: r.Monad map (n/% +100)))) + (:: r.Monad map (n/% |100)))) (context: "Sets" - (<| (times +100) + (<| (times |100) (do @ [sizeL gen-nat sizeR gen-nat diff --git a/stdlib/test/test/lux/data/collection/stack.lux b/stdlib/test/test/lux/data/collection/stack.lux index 0be661232..b786193b0 100644 --- a/stdlib/test/test/lux/data/collection/stack.lux +++ b/stdlib/test/test/lux/data/collection/stack.lux @@ -13,10 +13,10 @@ (def: gen-nat (r.Random Nat) (|> r.nat - (:: r.Monad map (n/% +100)))) + (:: r.Monad map (n/% |100)))) (context: "Stacks" - (<| (times +100) + (<| (times |100) (do @ [size gen-nat sample (r.stack size gen-nat) diff --git a/stdlib/test/test/lux/data/collection/tree/rose.lux b/stdlib/test/test/lux/data/collection/tree/rose.lux index a891807b8..207c6aab9 100644 --- a/stdlib/test/test/lux/data/collection/tree/rose.lux +++ b/stdlib/test/test/lux/data/collection/tree/rose.lux @@ -19,19 +19,19 @@ (r.Random [Nat (&.Tree Nat)]) (r.rec (function (_ gen-tree) - (r.either (:: r.Monad map (|>> &.leaf [+1]) r.nat) + (r.either (:: r.Monad map (|>> &.leaf [|1]) r.nat) (do r.Monad [value r.nat - num-children (|> r.nat (:: @ map (n/% +3))) + num-children (|> r.nat (:: @ map (n/% |3))) children' (r.list num-children gen-tree) - #let [size' (list/fold n/+ +0 (list/map product.left children')) + #let [size' (list/fold n/+ |0 (list/map product.left children')) children (list/map product.right children')]] (wrap [(inc size') (&.branch value children)])) )))) (context: "Trees" - (<| (times +100) + (<| (times |100) (do @ [[size sample] gen-tree #let [(^open "&/.") (&.Equivalence number.Equivalence) diff --git a/stdlib/test/test/lux/data/collection/tree/rose/zipper.lux b/stdlib/test/test/lux/data/collection/tree/rose/zipper.lux index 8ac987570..d91b0065d 100644 --- a/stdlib/test/test/lux/data/collection/tree/rose/zipper.lux +++ b/stdlib/test/test/lux/data/collection/tree/rose/zipper.lux @@ -22,7 +22,7 @@ (r.rec (function (_ gen-tree) (do r.Monad ## Each branch can have, at most, 1 child. - [size (|> r.nat (:: @ map (n/% +2)))] + [size (|> r.nat (:: @ map (n/% |2)))] (r.and r.nat (r.list size gen-tree)))))) @@ -34,7 +34,7 @@ (recur (&.next zipper))))) (context: "Zippers." - (<| (times +100) + (<| (times |100) (do @ [sample gen-tree new-val r.nat diff --git a/stdlib/test/test/lux/data/color.lux b/stdlib/test/test/lux/data/color.lux index 42d48806a..d8e93aa5e 100644 --- a/stdlib/test/test/lux/data/color.lux +++ b/stdlib/test/test/lux/data/color.lux @@ -31,8 +31,8 @@ (def: error-margin Frac 1.8) -(def: black @.Color (@.color [+0 +0 +0])) -(def: white @.Color (@.color [+255 +255 +255])) +(def: black @.Color (@.color [|0 |0 |0])) +(def: white @.Color (@.color [|255 |255 |255])) (do-template [] [(def: ( color) @@ -45,7 +45,7 @@ ) (context: "Color." - (<| (times +100) + (<| (times |100) (do @ [any color colorful (|> color diff --git a/stdlib/test/test/lux/data/format/json.lux b/stdlib/test/test/lux/data/format/json.lux index 0f1f6ebce..5333cfb0e 100644 --- a/stdlib/test/test/lux/data/format/json.lux +++ b/stdlib/test/test/lux/data/format/json.lux @@ -44,7 +44,7 @@ (r.Random @.JSON) (r.rec (function (_ gen-json) (do r.Monad - [size (:: @ map (n/% +2) r.nat)] + [size (:: @ map (n/% |2) r.nat)] ($_ r.or (:: @ wrap []) r.bit @@ -55,7 +55,7 @@ ))))) (context: "JSON" - (<| (times +100) + (<| (times |100) (do @ [sample gen-json #let [(^open "@/.") @.Equivalence @@ -113,7 +113,7 @@ (def: gen-record (r.Random Record) (do r.Monad - [size (:: @ map (n/% +2) r.nat)] + [size (:: @ map (n/% |2) r.nat)] ($_ r.and r.bit r.frac @@ -167,8 +167,8 @@ )))) (context: "Polytypism" - (<| (seed +14562075782602945288) - ## (times +100) + (<| (seed |14562075782602945288) + ## (times |100) (do @ [sample gen-record #let [(^open "@/.") Equivalence diff --git a/stdlib/test/test/lux/data/format/xml.lux b/stdlib/test/test/lux/data/format/xml.lux index e1e773a96..6e6894f8b 100644 --- a/stdlib/test/test/lux/data/format/xml.lux +++ b/stdlib/test/test/lux/data/format/xml.lux @@ -44,22 +44,22 @@ (def: xml-identifier^ (r.Random Name) - (r.and (xml-text^ +0 +10) - (xml-text^ +1 +10))) + (r.and (xml-text^ |0 |10) + (xml-text^ |1 |10))) (def: gen-xml (r.Random &.XML) (r.rec (function (_ gen-xml) - (r.or (xml-text^ +1 +10) + (r.or (xml-text^ |1 |10) (do r.Monad - [size (size^ +0 +2)] + [size (size^ |0 |2)] ($_ r.and xml-identifier^ - (r.dictionary name.Hash size xml-identifier^ (xml-text^ +0 +10)) + (r.dictionary name.Hash size xml-identifier^ (xml-text^ |0 |10)) (r.list size gen-xml))))))) (context: "XML." - (<| (times +100) + (<| (times |100) (do @ [sample gen-xml #let [(^open "&/.") &.Equivalence @@ -78,14 +78,14 @@ )))) (context: "Parsing." - (<| (times +100) + (<| (times |100) (do @ - [text (xml-text^ +1 +10) - num-children (|> r.nat (:: @ map (n/% +5))) - children (r.list num-children (xml-text^ +1 +10)) + [text (xml-text^ |1 |10) + num-children (|> r.nat (:: @ map (n/% |5))) + children (r.list num-children (xml-text^ |1 |10)) tag xml-identifier^ attr xml-identifier^ - value (xml-text^ +1 +10) + value (xml-text^ |1 |10) #let [node (#&.Node tag (dict.put attr value &.attrs) (list/map (|>> #&.Text) children))]] diff --git a/stdlib/test/test/lux/data/lazy.lux b/stdlib/test/test/lux/data/lazy.lux index 094a1d164..416f3dd56 100644 --- a/stdlib/test/test/lux/data/lazy.lux +++ b/stdlib/test/test/lux/data/lazy.lux @@ -9,7 +9,7 @@ lux/test) (context: "Lazy." - (<| (times +100) + (<| (times |100) (do @ [left r.nat right r.nat @@ -27,7 +27,7 @@ )))) (context: "Functor, Apply, Monad." - (<| (times +100) + (<| (times |100) (do @ [sample r.nat] ($_ seq diff --git a/stdlib/test/test/lux/data/name.lux b/stdlib/test/test/lux/data/name.lux index 5c6311100..16ab67f59 100644 --- a/stdlib/test/test/lux/data/name.lux +++ b/stdlib/test/test/lux/data/name.lux @@ -16,17 +16,17 @@ (|> (r.unicode size) (r.filter (|>> (text.contains? ".") not)))) (context: "Names" - (<| (times +100) + (<| (times |100) (do @ [## First Name - sizeM1 (|> r.nat (:: @ map (n/% +100))) - sizeN1 (|> r.nat (:: @ map (|>> (n/% +100) (n/max +1)))) + sizeM1 (|> r.nat (:: @ map (n/% |100))) + sizeN1 (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1)))) module1 (gen-part sizeM1) short1 (gen-part sizeN1) #let [name1 [module1 short1]] ## Second Name - sizeM2 (|> r.nat (:: @ map (n/% +100))) - sizeN2 (|> r.nat (:: @ map (|>> (n/% +100) (n/max +1)))) + sizeM2 (|> r.nat (:: @ map (n/% |100))) + sizeN2 (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1)))) module2 (gen-part sizeM2) short2 (gen-part sizeN2) #let [name2 [module2 short2]] diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux index 93c0ac68d..8e9a867da 100644 --- a/stdlib/test/test/lux/data/number.lux +++ b/stdlib/test/test/lux/data/number.lux @@ -13,7 +13,7 @@ (do-template [category rand-gen ] [(context: (format "[" category "] " "Equivalence & Order") - (<| (times +100) + (<| (times |100) (do @ [x rand-gen y rand-gen] @@ -30,7 +30,7 @@ (do-template [category rand-gen ] [(context: (format "[" category "] " "Number") - (<| (times +100) + (<| (times |100) (do @ [x rand-gen #let [(^open ".") @@ -53,7 +53,7 @@ (do-template [category rand-gen ] [(context: (format "[" category "] " "Enum") - (<| (times +100) + (<| (times |100) (do @ [x rand-gen] (test "" (let [(^open ".") @@ -75,7 +75,7 @@ (do-template [category rand-gen ] [(context: (format "[" category "] " "Interval") - (<| (times +100) + (<| (times |100) (do @ [x (|> rand-gen (r.filter )) #let [(^open ".") @@ -92,7 +92,7 @@ (do-template [category rand-gen ] [(context: (format "[" category "] " "Monoid") - (<| (times +100) + (<| (times |100) (do @ [x (|> rand-gen (:: @ map (|>> (:: abs) )) (r.filter )) #let [(^open ".") @@ -103,10 +103,10 @@ (= x (compose x identity)) (= identity (compose identity identity)))))))] - ["Nat/Add" r.nat Number Order Add@Monoid (n/% +1000) (function (_ _) #1)] - ["Nat/Mul" r.nat Number Order Mul@Monoid (n/% +1000) (function (_ _) #1)] - ["Nat/Min" r.nat Number Order Min@Monoid (n/% +1000) (function (_ _) #1)] - ["Nat/Max" r.nat Number Order Max@Monoid (n/% +1000) (function (_ _) #1)] + ["Nat/Add" r.nat Number Order Add@Monoid (n/% |1000) (function (_ _) #1)] + ["Nat/Mul" r.nat Number Order Mul@Monoid (n/% |1000) (function (_ _) #1)] + ["Nat/Min" r.nat Number Order Min@Monoid (n/% |1000) (function (_ _) #1)] + ["Nat/Max" r.nat Number Order Max@Monoid (n/% |1000) (function (_ _) #1)] ["Int/Add" r.int Number Order Add@Monoid (i/% 1000) (function (_ _) #1)] ["Int/Mul" r.int Number Order Mul@Monoid (i/% 1000) (function (_ _) #1)] ["Int/Min" r.int Number Order Min@Monoid (i/% 1000) (function (_ _) #1)] @@ -123,7 +123,7 @@ (do-template [ ] [(context: (format "[" "] " "Alternative formats") - (<| (times +100) + (<| (times |100) (do @ [x ] (test "Can encode/decode values." @@ -158,10 +158,10 @@ ) (context: "Can convert frac values to/from their bit patterns." - (<| (times +100) + (<| (times |100) (do @ [raw r.frac - factor (|> r.nat (:: @ map (|>> (n/% +1000) (n/max +1)))) + factor (|> r.nat (:: @ map (|>> (n/% |1000) (n/max |1)))) #let [sample (|> factor .int int-to-frac (f/* raw))]] (test "Can convert frac values to/from their bit patterns." (|> sample frac-to-bits bits-to-frac (f/= sample)))))) @@ -169,17 +169,17 @@ (context: "Macros for alternative numeric encodings." ($_ seq (test "Binary." - (and (n/= (bin "+11001001") (bin "+11_00_10_01")) + (and (n/= (bin "|11001001") (bin "|11_00_10_01")) (i/= (bin "11001001") (bin "11_00_10_01")) (r/= (bin ".11001001") (bin ".11_00_10_01")) (f/= (bin "1100.1001") (bin "11_00.10_01")))) (test "Octal." - (and (n/= (oct "+615243") (oct "+615_243")) + (and (n/= (oct "|615243") (oct "|615_243")) (i/= (oct "615243") (oct "615_243")) (r/= (oct ".615243") (oct ".615_243")) (f/= (oct "6152.43") (oct "615_2.43")))) (test "Hexadecimal." - (and (n/= (hex "+deadBEEF") (hex "+dead_BEEF")) + (and (n/= (hex "|deadBEEF") (hex "|dead_BEEF")) (i/= (hex "deadBEEF") (hex "dead_BEEF")) (r/= (hex ".deadBEEF") (hex ".dead_BEEF")) (f/= (hex "deadBE.EF") (hex "dead_BE.EF")))))) diff --git a/stdlib/test/test/lux/data/number/complex.lux b/stdlib/test/test/lux/data/number/complex.lux index 9347b891c..0d66cf1af 100644 --- a/stdlib/test/test/lux/data/number/complex.lux +++ b/stdlib/test/test/lux/data/number/complex.lux @@ -26,7 +26,7 @@ (def: gen-dim (r.Random Frac) (do r.Monad - [factor (|> r.nat (:: @ map (|>> (n/% +1000) (n/max +1)))) + [factor (|> r.nat (:: @ map (|>> (n/% |1000) (n/max |1)))) measure (|> r.frac (r.filter (f/> 0.0)))] (wrap (f/* (|> factor .int int-to-frac) measure)))) @@ -39,7 +39,7 @@ (wrap (&.complex real imaginary)))) (context: "Construction" - (<| (times +100) + (<| (times |100) (do @ [real gen-dim imaginary gen-dim] @@ -55,7 +55,7 @@ )))) (context: "Absolute value" - (<| (times +100) + (<| (times |100) (do @ [real gen-dim imaginary gen-dim] @@ -78,7 +78,7 @@ )))) (context: "Addidion, substraction, multiplication and division" - (<| (times +100) + (<| (times |100) (do @ [x gen-complex y gen-complex @@ -122,7 +122,7 @@ )))) (context: "Conjugate, reciprocal, signum, negation" - (<| (times +100) + (<| (times |100) (do @ [x gen-complex] ($_ seq @@ -162,8 +162,8 @@ (|> normal forward backward (within? margin-of-error normal)))) (context: "Trigonometry" - (<| (seed +17274883666004960943) - ## (times +100) + (<| (seed |17274883666004960943) + ## (times |100) (do @ [angle (|> gen-complex (:: @ map (|>> (update@ #&.real (f/% 1.0)) (update@ #&.imaginary (f/% 1.0)))))] @@ -178,7 +178,7 @@ (trigonometric-symmetry &.tan &.atan angle)))))) (context: "Power 2 and exponential/logarithm" - (<| (times +100) + (<| (times |100) (do @ [x gen-complex] ($_ seq @@ -190,10 +190,10 @@ )))) (context: "Complex roots" - (<| (times +100) + (<| (times |100) (do @ [sample gen-complex - degree (|> r.nat (:: @ map (|>> (n/max +1) (n/% +5))))] + degree (|> r.nat (:: @ map (|>> (n/max |1) (n/% |5))))] (test "Can calculate the N roots for any complex number." (|> sample (&.roots degree) diff --git a/stdlib/test/test/lux/data/number/i64.lux b/stdlib/test/test/lux/data/number/i64.lux index d48d009e6..2868b91a6 100644 --- a/stdlib/test/test/lux/data/number/i64.lux +++ b/stdlib/test/test/lux/data/number/i64.lux @@ -10,7 +10,7 @@ lux/test) (context: "Bitwise operations." - (<| (times +100) + (<| (times |100) (do @ [pattern r.nat idx (:: @ map (n/% &.width) r.nat)] @@ -20,10 +20,10 @@ (&.count (&.clear idx pattern))) (|> (&.count pattern) (n/- (&.count (&.clear idx pattern))) - (n/<= +1)) + (n/<= |1)) (|> (&.count (&.set idx pattern)) (n/- (&.count pattern)) - (n/<= +1)))) + (n/<= |1)))) (test "Can query whether a bit is set." (and (or (and (&.set? idx pattern) (not (&.set? idx (&.clear idx pattern)))) @@ -39,16 +39,16 @@ (n/+ (&.count pattern) (&.count (&.not pattern))))) (test "Can do simple binary logic." - (and (n/= +0 + (and (n/= |0 (&.and pattern (&.not pattern))) - (n/= (&.not +0) + (n/= (&.not |0) (&.or pattern (&.not pattern))) - (n/= (&.not +0) + (n/= (&.not |0) (&.xor pattern (&.not pattern))) - (n/= +0 + (n/= |0 (&.xor pattern pattern)))) (test "rotate-left and rotate-right are inverses of one another." diff --git a/stdlib/test/test/lux/data/number/ratio.lux b/stdlib/test/test/lux/data/number/ratio.lux index 8a2f1640d..d30278cf5 100644 --- a/stdlib/test/test/lux/data/number/ratio.lux +++ b/stdlib/test/test/lux/data/number/ratio.lux @@ -12,27 +12,27 @@ (def: gen-part (r.Random Nat) - (|> r.nat (:: r.Monad map (|>> (n/% +1000) (n/max +1))))) + (|> r.nat (:: r.Monad map (|>> (n/% |1000) (n/max |1))))) (def: gen-ratio (r.Random &.Ratio) (do r.Monad [numerator gen-part denominator (|> gen-part - (r.filter (|>> (n/= +0) not)) + (r.filter (|>> (n/= |0) not)) (r.filter (|>> (n/= numerator) not)))] (wrap (&.ratio numerator denominator)))) (context: "Normalization" - (<| (times +100) + (<| (times |100) (do @ [denom1 gen-part denom2 gen-part sample gen-ratio] ($_ seq (test "All zeroes are the same." - (&.= (&.ratio +0 denom1) - (&.ratio +0 denom2))) + (&.= (&.ratio |0 denom1) + (&.ratio |0 denom2))) (test "All ratios are built normalized." (|> sample @@ -42,7 +42,7 @@ )))) (context: "Arithmetic" - (<| (times +100) + (<| (times |100) (do @ [x gen-ratio y gen-ratio @@ -67,12 +67,12 @@ (let [remainder (&.% min max) multiple (&.- remainder max) factor (&./ min multiple)] - (and (|> factor (get@ #&.denominator) (n/= +1)) + (and (|> factor (get@ #&.denominator) (n/= |1)) (|> factor (&.* min) (&.+ remainder) (&.= max))))) )))) (context: "Negation, absolute value and signum" - (<| (times +100) + (<| (times |100) (do @ [sample gen-ratio] ($_ seq @@ -90,7 +90,7 @@ )))) (context: "Order" - (<| (times +100) + (<| (times |100) (do @ [x gen-ratio y gen-ratio] @@ -103,7 +103,7 @@ )))) (context: "Codec" - (<| (times +100) + (<| (times |100) (do @ [sample gen-ratio #let [(^open "&/.") &.Codec]] diff --git a/stdlib/test/test/lux/data/sum.lux b/stdlib/test/test/lux/data/sum.lux index a771a23bb..23dfd6078 100644 --- a/stdlib/test/test/lux/data/sum.lux +++ b/stdlib/test/test/lux/data/sum.lux @@ -13,25 +13,25 @@ (let [(^open "List/.") (list.Equivalence text.Equivalence)] ($_ seq (test "Can inject values into Either." - (and (|> (left "Hello") (case> (+0 "Hello") #1 _ #0)) - (|> (right "World") (case> (+1 "World") #1 _ #0)))) + (and (|> (left "Hello") (case> (|0 "Hello") #1 _ #0)) + (|> (right "World") (case> (|1 "World") #1 _ #0)))) (test "Can discriminate eithers based on their cases." (let [[_lefts _rights] (partition (: (List (| Text Text)) - (list (+0 "0") (+1 "1") (+0 "2"))))] + (list (|0 "0") (|1 "1") (|0 "2"))))] (and (List/= _lefts (lefts (: (List (| Text Text)) - (list (+0 "0") (+1 "1") (+0 "2"))))) + (list (|0 "0") (|1 "1") (|0 "2"))))) (List/= _rights (rights (: (List (| Text Text)) - (list (+0 "0") (+1 "1") (+0 "2")))))))) + (list (|0 "0") (|1 "1") (|0 "2")))))))) (test "Can apply a function to an Either value depending on the case." (and (i/= 10 (either (function (_ _) 10) (function (_ _) 20) - (: (| Text Text) (+0 "")))) + (: (| Text Text) (|0 "")))) (i/= 20 (either (function (_ _) 10) (function (_ _) 20) - (: (| Text Text) (+1 "")))))) + (: (| Text Text) (|1 "")))))) ))) diff --git a/stdlib/test/test/lux/data/text.lux b/stdlib/test/test/lux/data/text.lux index e4982cab7..3d257cd75 100644 --- a/stdlib/test/test/lux/data/text.lux +++ b/stdlib/test/test/lux/data/text.lux @@ -13,21 +13,21 @@ lux/test) (context: "Size" - (<| (times +100) + (<| (times |100) (do @ - [size (:: @ map (n/% +100) r.nat) + [size (:: @ map (n/% |100) r.nat) sample (r.unicode size)] - (test "" (or (and (n/= +0 size) + (test "" (or (and (n/= |0 size) (&.empty? sample)) (n/= size (&.size sample))))))) (def: bounded-size (r.Random Nat) (|> r.nat - (:: r.Monad map (|>> (n/% +20) (n/+ +1))))) + (:: r.Monad map (|>> (n/% |20) (n/+ |1))))) (context: "Locations" - (<| (times +100) + (<| (times |100) (do @ [size bounded-size idx (:: @ map (n/% size) r.nat) @@ -56,7 +56,7 @@ )))) (context: "Text functions" - (<| (times +100) + (<| (times |100) (do @ [sizeL bounded-size sizeR bounded-size @@ -83,10 +83,10 @@ _ #0)) - (|> [(&.clip +0 sizeL sample) + (|> [(&.clip |0 sizeL sample) (&.clip sizeL (&.size sample) sample) (&.clip' sizeL sample) - (&.clip' +0 sample)] + (&.clip' |0 sample)] (case> [(#.Right _l) (#.Right _r) (#.Right _r') (#.Right _f)] (and (= sampleL _l) (= sampleR _r) @@ -99,16 +99,16 @@ )))) (context: "More text functions" - (<| (times +100) + (<| (times |100) (do @ [sizeP bounded-size sizeL bounded-size #let [## The wider unicode charset includes control characters that ## can make text replacement work improperly. ## Because of that, I restrict the charset. - normal-char-gen (|> r.nat (:: @ map (|>> (n/% +128) (n/max +1))))] - sep1 (r.text normal-char-gen +1) - sep2 (r.text normal-char-gen +1) + normal-char-gen (|> r.nat (:: @ map (|>> (n/% |128) (n/max |1))))] + sep1 (r.text normal-char-gen |1) + sep2 (r.text normal-char-gen |1) #let [part-gen (|> (r.text normal-char-gen sizeP) (r.filter (|>> (&.contains? sep1) not)))] parts (r.list sizeL part-gen) diff --git a/stdlib/test/test/lux/data/text/format.lux b/stdlib/test/test/lux/data/text/format.lux index a66a579b6..b66ee9f8e 100644 --- a/stdlib/test/test/lux/data/text/format.lux +++ b/stdlib/test/test/lux/data/text/format.lux @@ -12,7 +12,7 @@ ($_ seq (test "Can format common values simply." (and (&/= "#1" (%b #1)) - (&/= "+123" (%n +123)) + (&/= "|123" (%n |123)) (&/= "123" (%i 123)) (&/= "123.456" (%f 123.456)) (&/= ".5" (%r .5)) diff --git a/stdlib/test/test/lux/data/text/lexer.lux b/stdlib/test/test/lux/data/text/lexer.lux index 9654c29e6..d413504e0 100644 --- a/stdlib/test/test/lux/data/text/lexer.lux +++ b/stdlib/test/test/lux/data/text/lexer.lux @@ -73,9 +73,9 @@ )) (context: "Literals" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% +100) (n/max +10)))) + [size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) sample (r.unicode size) non-sample (|> (r.unicode size) (r.filter (|>> (text/= sample) not)))] diff --git a/stdlib/test/test/lux/data/text/regex.lux b/stdlib/test/test/lux/data/text/regex.lux index 2b9a5b9df..1135dbb0c 100644 --- a/stdlib/test/test/lux/data/text/regex.lux +++ b/stdlib/test/test/lux/data/text/regex.lux @@ -252,26 +252,26 @@ (context: "Regular Expressions [Alternation]" ($_ seq (test "Can specify alternative patterns." - (and (should-check ["a" (+0 [])] (&.regex "a|b") "a") - (should-check ["b" (+1 [])] (&.regex "a|b") "b") + (and (should-check ["a" (|0 [])] (&.regex "a|b") "a") + (should-check ["b" (|1 [])] (&.regex "a|b") "b") (should-fail (&.regex "a|b") "c"))) (test "Can have groups within alternations." - (and (should-check ["abc" (+0 ["b" "c"])] (&.regex "a(.)(.)|b(.)(.)") "abc") - (should-check ["bcd" (+1 ["c" "d"])] (&.regex "a(.)(.)|b(.)(.)") "bcd") + (and (should-check ["abc" (|0 ["b" "c"])] (&.regex "a(.)(.)|b(.)(.)") "abc") + (should-check ["bcd" (|1 ["c" "d"])] (&.regex "a(.)(.)|b(.)(.)") "bcd") (should-fail (&.regex "a(.)(.)|b(.)(.)") "cde") - (should-check ["809-345-6789" (+0 ["809" "345-6789" "345" "6789"])] + (should-check ["809-345-6789" (|0 ["809" "345-6789" "345" "6789"])] (&.regex "(\\d{3})-((\\d{3})-(\\d{4}))|b(.)d") "809-345-6789"))) )) (context: "Pattern-matching" - (<| (times +100) + (<| (times |100) (do @ - [sample1 (r.unicode +3) - sample2 (r.unicode +3) - sample3 (r.unicode +4)] + [sample1 (r.unicode |3) + sample2 (r.unicode |3) + sample3 (r.unicode |4)] (case (format sample1 "-" sample2 "-" sample3) (&.^regex "(.{3})-(.{3})-(.{4})" [_ match1 match2 match3]) diff --git a/stdlib/test/test/lux/host.jvm.lux b/stdlib/test/test/lux/host.jvm.lux index 400f786b0..d6b125657 100644 --- a/stdlib/test/test/lux/host.jvm.lux +++ b/stdlib/test/test/lux/host.jvm.lux @@ -59,7 +59,7 @@ ([] foo [boolean String] void #throws [Exception])) (context: "Conversions" - (<| (times +100) + (<| (times |100) (do @ [sample r.int] (with-expansions @@ -108,9 +108,9 @@ )) (context: "Arrays" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% +100) (n/max +1)))) + [size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1)))) idx (|> r.nat (:: @ map (n/% size))) value r.int] ($_ seq diff --git a/stdlib/test/test/lux/macro/poly/equivalence.lux b/stdlib/test/test/lux/macro/poly/equivalence.lux index 40dae030c..061b5714d 100644 --- a/stdlib/test/test/lux/macro/poly/equivalence.lux +++ b/stdlib/test/test/lux/macro/poly/equivalence.lux @@ -48,7 +48,7 @@ (def: gen-record (r.Random Record) (do r.Monad - [size (:: @ map (n/% +2) r.nat) + [size (:: @ map (n/% |2) r.nat) #let [gen-int (|> r.int (:: @ map (|>> int/abs (i/% 1_000_000))))]] ($_ r.and r.bit @@ -65,7 +65,7 @@ ## [Tests] (context: "Equivalence polytypism" - (<| (times +100) + (<| (times |100) (do @ [sample gen-record #let [(^open "&/.") Equivalence]] diff --git a/stdlib/test/test/lux/macro/syntax.lux b/stdlib/test/test/lux/macro/syntax.lux index 155f7985a..4f6a29a05 100644 --- a/stdlib/test/test/lux/macro/syntax.lux +++ b/stdlib/test/test/lux/macro/syntax.lux @@ -73,7 +73,7 @@ (enforced? (s.this ( )) (list ( )))))] ["Can parse Bit syntax." #1 code.bit bit.Equivalence s.bit] - ["Can parse Nat syntax." +123 code.nat number.Equivalence s.nat] + ["Can parse Nat syntax." |123 code.nat number.Equivalence s.nat] ["Can parse Int syntax." 123 code.int number.Equivalence s.int] ["Can parse Rev syntax." .123 code.rev number.Equivalence s.rev] ["Can parse Frac syntax." 123.0 code.frac number.Equivalence s.frac] diff --git a/stdlib/test/test/lux/math.lux b/stdlib/test/test/lux/math.lux index c20a89c60..eb086243f 100644 --- a/stdlib/test/test/lux/math.lux +++ b/stdlib/test/test/lux/math.lux @@ -22,7 +22,7 @@ (|> normal forward backward (within? margin normal)))) (context: "Trigonometry" - (<| (times +100) + (<| (times |100) (do @ [angle (|> r.frac (:: @ map (f/* &.tau)))] ($_ seq @@ -37,7 +37,7 @@ )))) (context: "Rounding" - (<| (times +100) + (<| (times |100) (do @ [sample (|> r.frac (:: @ map (f/* 1000.0)))] ($_ seq @@ -60,34 +60,34 @@ )))) (context: "Exponentials and logarithms" - (<| (times +100) + (<| (times |100) (do @ [sample (|> r.frac (:: @ map (f/* 10.0)))] (test "Logarithm is the inverse of exponential." (|> sample &.exp &.log (within? 1.0e-15 sample)))))) (context: "Greatest-Common-Divisor and Least-Common-Multiple" - (<| (times +100) + (<| (times |100) (do @ - [#let [gen-nat (|> r.nat (:: @ map (|>> (n/% +1000) (n/max +1))))] + [#let [gen-nat (|> r.nat (:: @ map (|>> (n/% |1000) (n/max |1))))] x gen-nat y gen-nat] ($_ seq (test "GCD" (let [gcd (&.n/gcd x y)] - (and (n/= +0 (n/% gcd x)) - (n/= +0 (n/% gcd y)) - (n/>= +1 gcd)))) + (and (n/= |0 (n/% gcd x)) + (n/= |0 (n/% gcd y)) + (n/>= |1 gcd)))) (test "LCM" (let [lcm (&.n/lcm x y)] - (and (n/= +0 (n/% x lcm)) - (n/= +0 (n/% y lcm)) + (and (n/= |0 (n/% x lcm)) + (n/= |0 (n/% y lcm)) (n/<= (n/* x y) lcm)))) )))) (context: "Infix syntax" - (<| (times +100) + (<| (times |100) (do @ [x r.nat y r.nat @@ -109,8 +109,8 @@ (&.infix [&.sin theta]))) (test "Can use regular syntax in the middle of infix code." - (n/= (&.n/gcd +450 (n/* +3 +9)) - (&.infix [(n/* +3 +9) &.n/gcd +450]))) + (n/= (&.n/gcd |450 (n/* |3 |9)) + (&.infix [(n/* |3 |9) &.n/gcd |450]))) (test "Can use non-numerical functions/macros as operators." (bit/= (and (n/< y x) (n/< z y)) diff --git a/stdlib/test/test/lux/math/logic/continuous.lux b/stdlib/test/test/lux/math/logic/continuous.lux index c53ad434b..02329d05d 100644 --- a/stdlib/test/test/lux/math/logic/continuous.lux +++ b/stdlib/test/test/lux/math/logic/continuous.lux @@ -9,7 +9,7 @@ lux/test) (context: "Operations" - (<| (times +100) + (<| (times |100) (do @ [left r.rev right r.rev] diff --git a/stdlib/test/test/lux/math/logic/fuzzy.lux b/stdlib/test/test/lux/math/logic/fuzzy.lux index 585857883..ad23d2eb9 100644 --- a/stdlib/test/test/lux/math/logic/fuzzy.lux +++ b/stdlib/test/test/lux/math/logic/fuzzy.lux @@ -19,9 +19,9 @@ (do-template [ ] [(context: (format "[" "] " "Triangles") - (<| (times +100) + (<| (times |100) (do @ - [values (r.set +3 ) + [values (r.set |3 ) #let [[x y z] (case (set.to-list values) (^ (list x y z)) [x y z] @@ -60,9 +60,9 @@ (do-template [ ] [(context: (format "[" "] " "Trapezoids") - (<| (times +100) + (<| (times |100) (do @ - [values (r.set +4 ) + [values (r.set |4 ) #let [[w x y z] (case (set.to-list values) (^ (list w x y z)) [w x y z] @@ -114,7 +114,7 @@ (wrap (&.triangle x y z)))) (context: "Combinators" - (<| (times +100) + (<| (times |100) (do @ [left gen-triangle right gen-triangle @@ -148,10 +148,10 @@ )))) (context: "From predicates and sets" - (<| (times +100) + (<| (times |100) (do @ - [#let [set-10 (set.from-list number.Hash (list.n/range +0 +10))] - sample (|> r.nat (:: @ map (n/% +20)))] + [#let [set-10 (set.from-list number.Hash (list.n/range |0 |10))] + sample (|> r.nat (:: @ map (n/% |20)))] ($_ seq (test "Values that satisfy a predicate have membership = 1. Values that don't have membership = 0." @@ -165,7 +165,7 @@ )))) (context: "Thresholds" - (<| (times +100) + (<| (times |100) (do @ [fuzzy gen-triangle sample r.rev diff --git a/stdlib/test/test/lux/math/modular.lux b/stdlib/test/test/lux/math/modular.lux index ad9fda295..4d4ae3d8d 100644 --- a/stdlib/test/test/lux/math/modular.lux +++ b/stdlib/test/test/lux/math/modular.lux @@ -60,7 +60,7 @@ (/.m/= (m/! param subject))))) (context: "Modular arithmetic." - (<| (times +100) + (<| (times |100) (do @ [_normalM modulusR _alternativeM (|> modulusR (r.filter (|>> (i/= _normalM) not))) diff --git a/stdlib/test/test/lux/math/random.lux b/stdlib/test/test/lux/math/random.lux index 24f95bd30..5085855e6 100644 --- a/stdlib/test/test/lux/math/random.lux +++ b/stdlib/test/test/lux/math/random.lux @@ -17,9 +17,9 @@ lux/test) (context: "Random." - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% +100) (n/max +10)))) + [size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) _list (r.list size r.nat) _row (r.row size r.nat) _array (r.array size r.nat) diff --git a/stdlib/test/test/lux/time/date.lux b/stdlib/test/test/lux/time/date.lux index ecccbc034..600f67b87 100644 --- a/stdlib/test/test/lux/time/date.lux +++ b/stdlib/test/test/lux/time/date.lux @@ -30,7 +30,7 @@ (random/wrap #@.December)))))) (context: "(Month) Equivalence." - (<| (times +100) + (<| (times |100) (do @ [sample month #let [(^open "@/.") @.Equivalence]] @@ -38,7 +38,7 @@ (@/= sample sample))))) (context: "(Month) Order." - (<| (times +100) + (<| (times |100) (do @ [reference month sample month @@ -50,7 +50,7 @@ (@/<= reference sample))))))) (context: "(Month) Enum." - (<| (times +100) + (<| (times |100) (do @ [sample month #let [(^open "@/.") @.Enum]] @@ -73,7 +73,7 @@ (random/wrap #@.Saturday)))) (context: "(Day) Equivalence." - (<| (times +100) + (<| (times |100) (do @ [sample day #let [(^open "@/.") @.Equivalence]] @@ -81,7 +81,7 @@ (@/= sample sample))))) (context: "(Day) Order." - (<| (times +100) + (<| (times |100) (do @ [reference day sample day @@ -93,7 +93,7 @@ (@/<= reference sample))))))) (context: "(Day) Enum." - (<| (times +100) + (<| (times |100) (do @ [sample day #let [(^open "@/.") @.Enum]] @@ -110,7 +110,7 @@ (|> _instant.instant (:: r.Monad map @instant.date))) (context: "(Date) Equivalence." - (<| (times +100) + (<| (times |100) (do @ [sample date #let [(^open "@/.") @.Equivalence]] @@ -118,7 +118,7 @@ (@/= sample sample))))) (context: "(Date) Order." - (<| (times +100) + (<| (times |100) (do @ [reference date sample date @@ -130,8 +130,8 @@ (@/<= reference sample))))))) (context: "(Date) Codec" - (<| (seed +6623983470548808292) - ## (times +100) + (<| (seed |6623983470548808292) + ## (times |100) (do @ [sample date #let [(^open "@/.") @.Equivalence diff --git a/stdlib/test/test/lux/time/duration.lux b/stdlib/test/test/lux/time/duration.lux index 199eabe24..01ca9c98e 100644 --- a/stdlib/test/test/lux/time/duration.lux +++ b/stdlib/test/test/lux/time/duration.lux @@ -16,14 +16,14 @@ (|> r.int (:: r.Monad map @.from-millis))) (context: "Conversion." - (<| (times +100) + (<| (times |100) (do @ [millis r.int] (test "Can convert from/to milliseconds." (|> millis @.from-millis @.to-millis (i/= millis)))))) (context: "Equivalence." - (<| (times +100) + (<| (times |100) (do @ [sample duration #let [(^open "@/.") @.Equivalence]] @@ -31,7 +31,7 @@ (@/= sample sample))))) (context: "Order." - (<| (times +100) + (<| (times |100) (do @ [reference duration sample duration @@ -43,7 +43,7 @@ (@/<= reference sample))))))) (context: "Arithmetic." - (<| (times +100) + (<| (times |100) (do @ [sample (|> duration (:: @ map (@.frame @.day))) frame duration @@ -74,7 +74,7 @@ frame)))))))))) (context: "Codec" - (<| (times +100) + (<| (times |100) (do @ [sample duration #let [(^open "@/.") @.Equivalence diff --git a/stdlib/test/test/lux/time/instant.lux b/stdlib/test/test/lux/time/instant.lux index 40902fa03..59c01019e 100644 --- a/stdlib/test/test/lux/time/instant.lux +++ b/stdlib/test/test/lux/time/instant.lux @@ -25,14 +25,14 @@ (|> r.int (:: r.Monad map (|>> (i/% boundary) @.from-millis)))) (context: "Conversion." - (<| (times +100) + (<| (times |100) (do @ [millis r.int] (test "Can convert from/to milliseconds." (|> millis @.from-millis @.to-millis (i/= millis)))))) (context: "Equivalence." - (<| (times +100) + (<| (times |100) (do @ [sample instant #let [(^open "@/.") @.Equivalence]] @@ -40,7 +40,7 @@ (@/= sample sample))))) (context: "Order" - (<| (times +100) + (<| (times |100) (do @ [reference instant sample instant @@ -52,7 +52,7 @@ (@/<= reference sample))))))) (context: "Enum" - (<| (times +100) + (<| (times |100) (do @ [sample instant #let [(^open "@/.") @.Enum]] @@ -65,7 +65,7 @@ (|> sample @/pred @/succ (@/= sample))))))) (context: "Arithmetic" - (<| (times +100) + (<| (times |100) (do @ [sample instant span _duration.duration @@ -82,8 +82,8 @@ (|> @.epoch (@.shift (@.relative sample)) (@/= sample))))))) ## (context: "Codec" -## (<| (seed +9863552679229274604) -## ## (times +100) +## (<| (seed |9863552679229274604) +## ## (times |100) ## (do @ ## [sample instant ## #let [(^open "@/.") @.Equivalence diff --git a/stdlib/test/test/lux/type.lux b/stdlib/test/test/lux/type.lux index 1c950eb40..cd335e420 100644 --- a/stdlib/test/test/lux/type.lux +++ b/stdlib/test/test/lux/type.lux @@ -18,7 +18,7 @@ (def: #export gen-short (r.Random Text) (do r.Monad - [size (|> r.nat (:: @ map (n/% +10)))] + [size (|> r.nat (:: @ map (n/% |10)))] (r.unicode size))) (def: #export gen-name @@ -48,7 +48,7 @@ ## [Tests] (context: "Types" - (<| (times +100) + (<| (times |100) (do @ [sample gen-type] (test "Every type is equal to itself." @@ -84,9 +84,9 @@ (&.un-name aliased))))))) (context: "Type construction [structs]" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (n/% +3))) + [size (|> r.nat (:: @ map (n/% |3))) members (|> gen-type (r.filter (function (_ type) (case type @@ -115,9 +115,9 @@ ))))) (context: "Type construction [parameterized]" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (n/% +3))) + [size (|> r.nat (:: @ map (n/% |3))) members (M.seq @ (list.repeat size gen-type)) extra (|> gen-type (r.filter (function (_ type) @@ -141,9 +141,9 @@ )))) (context: "Type construction [higher order]" - (<| (times +100) + (<| (times |100) (do @ - [size (|> r.nat (:: @ map (n/% +3))) + [size (|> r.nat (:: @ map (n/% |3))) extra (|> gen-type (r.filter (function (_ type) (case type diff --git a/stdlib/test/test/lux/type/check.lux b/stdlib/test/test/lux/type/check.lux index b801c1cd5..1ea83a10e 100644 --- a/stdlib/test/test/lux/type/check.lux +++ b/stdlib/test/test/lux/type/check.lux @@ -50,7 +50,7 @@ ## [Tests] (context: "Any and Nothing." - (<| (times +100) + (<| (times |100) (do @ [sample (|> //.gen-type (r.filter valid-type?))] ($_ seq @@ -98,7 +98,7 @@ )) (context: "Type application." - (<| (times +100) + (<| (times |100) (do @ [meta //.gen-type data //.gen-type] @@ -109,7 +109,7 @@ (|> Ann (#.Apply meta) (#.Apply data)))))))) (context: "Primitive types." - (<| (times +100) + (<| (times |100) (do @ [nameL //.gen-short nameR (|> //.gen-short (r.filter (|>> (text/= nameL) not))) @@ -177,9 +177,9 @@ (wrap [[head-id head-type] ids+types [tail-id tail-type]]))) (context: "Rings of type variables." - (<| (times +100) + (<| (times |100) (do @ - [num-connections (|> r.nat (:: @ map (n/% +100))) + [num-connections (|> r.nat (:: @ map (n/% |100))) boundT (|> //.gen-type (r.filter (|>> (case> (#.Var _) #0 _ #1)))) pick-pcg (r.and r.nat r.nat)] ($_ seq @@ -227,7 +227,7 @@ headRR-post (@.ring head-idR)] (@.assert "" (let [same-rings? (:: set.Equivalence = headRL-post headRR-post) - expected-size? (n/= (n/* +2 (inc num-connections)) + expected-size? (n/= (n/* |2 (inc num-connections)) (set.size headRL-post)) union? (:: set.Equivalence = headRL-post (set.union headRL-pre headRR-pre))] (and same-rings? diff --git a/stdlib/test/test/lux/type/implicit.lux b/stdlib/test/test/lux/type/implicit.lux index 8bb1d0d48..daf259609 100644 --- a/stdlib/test/test/lux/type/implicit.lux +++ b/stdlib/test/test/lux/type/implicit.lux @@ -15,7 +15,7 @@ lux/test) (context: "Automatic structure selection" - (<| (times +100) + (<| (times |100) (do @ [x r.nat y r.nat] @@ -24,17 +24,17 @@ (let [(^open "list/.") (list.Equivalence number.Equivalence)] (and (bit/= (:: number.Equivalence = x y) (::: = x y)) - (list/= (list.n/range +1 +10) - (::: map inc (list.n/range +0 +9))) + (list/= (list.n/range |1 |10) + (::: map inc (list.n/range |0 |9))) ))) (test "Can automatically select second-order structures." (::: = - (list.n/range +1 +10) - (list.n/range +1 +10))) + (list.n/range |1 |10) + (list.n/range |1 |10))) (test "Can automatically select third-order structures." - (let [lln (::: map (list.n/range +1) - (list.n/range +1 +10))] + (let [lln (::: map (list.n/range |1) + (list.n/range |1 |10))] (::: = lln lln))) )))) diff --git a/stdlib/test/test/lux/type/resource.lux b/stdlib/test/test/lux/type/resource.lux index 1457135a6..b3eabd995 100644 --- a/stdlib/test/test/lux/type/resource.lux +++ b/stdlib/test/test/lux/type/resource.lux @@ -11,37 +11,37 @@ (context: "Sub-structural typing." ($_ seq (test "Can produce and consume keys in an ordered manner." - (<| (n/= (n/+ +123 +456)) + (<| (n/= (n/+ |123 |456)) io.run resource.run-sync (do resource.IxMonad - [res|left (resource.ordered-sync +123) - res|right (resource.ordered-sync +456) + [res|left (resource.ordered-sync |123) + res|right (resource.ordered-sync |456) right (resource.read-sync res|right) left (resource.read-sync res|left)] (wrap (n/+ left right))))) (test "Can exchange commutative keys." - (<| (n/= (n/+ +123 +456)) + (<| (n/= (n/+ |123 |456)) io.run resource.run-sync (do resource.IxMonad - [res|left (resource.commutative-sync +123) - res|right (resource.commutative-sync +456) - _ (resource.exchange-sync [+1 +0]) + [res|left (resource.commutative-sync |123) + res|right (resource.commutative-sync |456) + _ (resource.exchange-sync [|1 |0]) left (resource.read-sync res|left) right (resource.read-sync res|right)] (wrap (n/+ left right))))) (test "Can group and un-group keys." - (<| (n/= (n/+ +123 +456)) + (<| (n/= (n/+ |123 |456)) io.run resource.run-sync (do resource.IxMonad - [res|left (resource.commutative-sync +123) - res|right (resource.commutative-sync +456) - _ (resource.group-sync +2) - _ (resource.un-group-sync +2) + [res|left (resource.commutative-sync |123) + res|right (resource.commutative-sync |456) + _ (resource.group-sync |2) + _ (resource.un-group-sync |2) right (resource.read-sync res|right) left (resource.read-sync res|left)] (wrap (n/+ left right))))) diff --git a/stdlib/test/test/lux/world/binary.lux b/stdlib/test/test/lux/world/binary.lux index acc3161c1..b5b625f50 100644 --- a/stdlib/test/test/lux/world/binary.lux +++ b/stdlib/test/test/lux/world/binary.lux @@ -30,7 +30,7 @@ (def: #export (binary size) (-> Nat (r.Random /.Binary)) (let [output (/.create size)] - (loop [idx +0] + (loop [idx |0] (if (n/< size idx) (do r.Monad [byte r.nat] @@ -40,19 +40,19 @@ (def: (bits-io bytes read write value) (-> Nat (-> Nat /.Binary (e.Error Nat)) (-> Nat Nat /.Binary (e.Error Any)) Nat Bit) - (let [binary (/.create +8) - bits (n/* +8 bytes) - capped-value (|> +1 (i64.left-shift bits) dec (i64.and value))] + (let [binary (/.create |8) + bits (n/* |8 bytes) + capped-value (|> |1 (i64.left-shift bits) dec (i64.and value))] (succeed (do e.Monad - [_ (write +0 value binary) - output (read +0 binary)] + [_ (write |0 value binary) + output (read |0 binary)] (wrap (n/= capped-value output)))))) (context: "Binary." - (<| (times +100) + (<| (times |100) (do @ - [#let [gen-size (|> r.nat (:: @ map (|>> (n/% +100) (n/max +8))))] + [#let [gen-size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |8))))] binary-size gen-size random-binary (binary binary-size) value r.nat @@ -65,17 +65,17 @@ (test "Can get size of binary." (|> random-binary /.size (n/= binary-size))) (test "Can read/write 8-bit values." - (bits-io +1 /.read/8 /.write/8 value)) + (bits-io |1 /.read/8 /.write/8 value)) (test "Can read/write 16-bit values." - (bits-io +2 /.read/16 /.write/16 value)) + (bits-io |2 /.read/16 /.write/16 value)) (test "Can read/write 32-bit values." - (bits-io +4 /.read/32 /.write/32 value)) + (bits-io |4 /.read/32 /.write/32 value)) (test "Can read/write 64-bit values." - (bits-io +8 /.read/64 /.write/64 value)) + (bits-io |8 /.read/64 /.write/64 value)) (test "Can slice binaries." (let [slice-size (|> to (n/- from) inc) random-slice (e.assume (/.slice from to random-binary)) - idxs (list.n/range +0 (dec slice-size)) + idxs (list.n/range |0 (dec slice-size)) reader (function (_ binary idx) (/.read/8 idx binary))] (and (n/= slice-size (/.size random-slice)) (case [(monad.map e.Monad (reader random-slice) idxs) diff --git a/stdlib/test/test/lux/world/file.lux b/stdlib/test/test/lux/world/file.lux index 54a5e0e2a..cadc242e6 100644 --- a/stdlib/test/test/lux/world/file.lux +++ b/stdlib/test/test/lux/world/file.lux @@ -27,7 +27,7 @@ (context: "File system." (do @ - [file-size (|> r.nat (:: @ map (|>> (n/% +100) (n/max +10)))) + [file-size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) dataL (_binary.binary file-size) dataR (_binary.binary file-size) code r.nat @@ -37,7 +37,7 @@ instant.absolute)))] ($_ seq (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ +0 code)))] + [#let [file (format "temp_file_" (%n (n/+ |0 code)))] result (promise.future (do (:: @.JVM@System &monad) [pre! (@.exists? @.JVM@System file) @@ -50,7 +50,7 @@ (assert "Can create/delete files." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ +1 code)))] + [#let [file (format "temp_file_" (%n (n/+ |1 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System write dataL file) @@ -60,7 +60,7 @@ (assert "Can write/read files." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ +2 code)))] + [#let [file (format "temp_file_" (%n (n/+ |2 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System write dataL file) @@ -70,7 +70,7 @@ (assert "Can read file size." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ +3 code)))] + [#let [file (format "temp_file_" (%n (n/+ |3 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System write dataL file) @@ -78,13 +78,13 @@ output (:: @.JVM@System read file) read-size (:: @.JVM@System size file) _ (:: @.JVM@System delete file)] - (wrap (and (n/= (n/* +2 file-size) read-size) - (:: binary.Equivalence = dataL (error.assume (binary.slice +0 (dec file-size) output))) + (wrap (and (n/= (n/* |2 file-size) read-size) + (:: binary.Equivalence = dataL (error.assume (binary.slice |0 (dec file-size) output))) (:: binary.Equivalence = dataR (error.assume (binary.slice file-size (dec read-size) output)))))))] (assert "Can append to files." (error.default #0 result)))) (wrap (do promise.Monad - [#let [dir (format "temp_dir_" (%n (n/+ +4 code)))] + [#let [dir (format "temp_dir_" (%n (n/+ |4 code)))] result (promise.future (do (:: @.JVM@System &monad) [pre! (@.exists? @.JVM@System dir) @@ -97,8 +97,8 @@ (assert "Can create/delete directories." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ +5 code))) - dir (format "temp_dir_" (%n (n/+ +5 code)))] + [#let [file (format "temp_file_" (%n (n/+ |5 code))) + dir (format "temp_dir_" (%n (n/+ |5 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System write dataL file) @@ -114,8 +114,8 @@ (assert "Can differentiate files from directories." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ +6 code))) - dir (format "temp_dir_" (%n (n/+ +6 code)))] + [#let [file (format "temp_file_" (%n (n/+ |6 code))) + dir (format "temp_dir_" (%n (n/+ |6 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System make-directory dir) @@ -128,8 +128,8 @@ (assert "Can create files inside of directories." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ +7 code))) - dir (format "temp_dir_" (%n (n/+ +7 code)))] + [#let [file (format "temp_file_" (%n (n/+ |7 code))) + dir (format "temp_dir_" (%n (n/+ |7 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System make-directory dir) @@ -147,7 +147,7 @@ (assert "Can list files inside a directory." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ +8 code)))] + [#let [file (format "temp_file_" (%n (n/+ |8 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System write dataL file) @@ -158,8 +158,8 @@ (assert "Can change the time of last modification." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file0 (format "temp_file_" (%n (n/+ +9 code)) "0") - file1 (format "temp_file_" (%n (n/+ +9 code)) "1")] + [#let [file0 (format "temp_file_" (%n (n/+ |9 code)) "0") + file1 (format "temp_file_" (%n (n/+ |9 code)) "1")] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System write dataL file0) diff --git a/stdlib/test/test/lux/world/net/tcp.lux b/stdlib/test/test/lux/world/net/tcp.lux index 1991e33cd..fb2ea3649 100644 --- a/stdlib/test/test/lux/world/net/tcp.lux +++ b/stdlib/test/test/lux/world/net/tcp.lux @@ -27,13 +27,13 @@ (r.Random net.Port) (|> r.nat (:: r.Monad map - (|>> (n/% +1000) - (n/+ +8000))))) + (|>> (n/% |1000) + (n/+ |8000))))) (context: "TCP networking." (do @ [port ..port - size (|> r.nat (:: @ map (|>> (n/% +100) (n/max +10)))) + size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) from (_binary.binary size) to (_binary.binary size) #let [temp-from (binary.create size) @@ -46,18 +46,18 @@ (P.promise #.Nil)) _ (frp/map (function (_ socket) (do @ - [bytes-from (@.read temp-from +0 size socket) + [bytes-from (@.read temp-from |0 size socket) #let [_ (io.run (P.resolve (#E.Success (and (n/= size bytes-from) (:: binary.Equivalence = from temp-from))) from-worked?))]] - (@.write to +0 size socket))) + (@.write to |0 size socket))) server)] client (@.client localhost port) - _ (@.write from +0 size client) + _ (@.write from |0 size client) from-worked? from-worked? #################### - bytes-to (@.read temp-to +0 size client) + bytes-to (@.read temp-to |0 size client) #let [to-worked? (and (n/= size bytes-to) (:: binary.Equivalence = to temp-to))] #################### diff --git a/stdlib/test/test/lux/world/net/udp.lux b/stdlib/test/test/lux/world/net/udp.lux index b3911aea3..8365452a1 100644 --- a/stdlib/test/test/lux/world/net/udp.lux +++ b/stdlib/test/test/lux/world/net/udp.lux @@ -24,13 +24,13 @@ (r.Random net.Port) (|> r.nat (:: r.Monad map - (|>> (n/% +1000) - (n/+ +8000))))) + (|>> (n/% |1000) + (n/+ |8000))))) (context: "UDP networking." (do @ [port ..port - size (|> r.nat (:: @ map (|>> (n/% +100) (n/max +10)))) + size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) from (_binary.binary size) to (_binary.binary size) #let [temp (binary.create size)]] @@ -40,13 +40,13 @@ [server (@.server port) client (@.client []) #################### - _ (@.write localhost port from +0 size client) - [bytes-from from-address from-port] (@.read temp +0 size server) + _ (@.write localhost port from |0 size client) + [bytes-from from-address from-port] (@.read temp |0 size server) #let [from-worked? (and (n/= size bytes-from) (:: binary.Equivalence = from temp))] #################### - _ (@.write from-address from-port to +0 size server) - [bytes-to to-address to-port] (@.read temp +0 size client) + _ (@.write from-address from-port to |0 size server) + [bytes-to to-address to-port] (@.read temp |0 size client) #let [to-worked? (and (n/= size bytes-to) (:: binary.Equivalence = to temp) (n/= port to-port))] -- cgit v1.2.3 From 15e71e57b688f5079fe606b2fee5e3efd2a5d5a7 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 28 Jul 2018 14:55:30 -0400 Subject: Added "+" sign to positive Int. --- luxc/src/lux/lexer.clj | 5 +- stdlib/source/lux.lux | 90 ++++---- .../compiler/default/phase/analysis/structure.lux | 2 +- .../translation/scheme/extension/common.jvm.lux | 12 +- .../phase/translation/scheme/function.jvm.lux | 2 +- .../phase/translation/scheme/runtime.jvm.lux | 28 +-- stdlib/source/lux/compiler/default/syntax.lux | 4 +- stdlib/source/lux/control/comonad.lux | 2 +- stdlib/source/lux/control/contract.lux | 6 +- stdlib/source/lux/control/pipe.lux | 60 ++--- stdlib/source/lux/data/collection/row.lux | 2 +- stdlib/source/lux/data/collection/sequence.lux | 2 +- stdlib/source/lux/data/collection/tree/rose.lux | 6 +- stdlib/source/lux/data/color.lux | 120 +++++----- stdlib/source/lux/data/error.lux | 8 +- stdlib/source/lux/data/format/json.lux | 2 +- stdlib/source/lux/data/maybe.lux | 4 +- stdlib/source/lux/data/number.lux | 256 +++++++++++---------- stdlib/source/lux/data/number/complex.lux | 46 ++-- stdlib/source/lux/data/text/regex.lux | 5 +- stdlib/source/lux/host.js.lux | 6 +- stdlib/source/lux/math.lux | 50 ++-- stdlib/source/lux/math/modular.lux | 10 +- stdlib/source/lux/test.lux | 26 +-- stdlib/source/lux/time/date.lux | 54 ++--- stdlib/source/lux/time/duration.lux | 56 +++-- stdlib/source/lux/time/instant.lux | 146 ++++++------ stdlib/source/lux/type/unit.lux | 16 +- stdlib/test/test/lux.lux | 26 +-- stdlib/test/test/lux/compiler/default/syntax.lux | 2 +- stdlib/test/test/lux/concurrency/frp.lux | 24 +- stdlib/test/test/lux/control/parser.lux | 68 +++--- stdlib/test/test/lux/control/pipe.lux | 70 +++--- stdlib/test/test/lux/control/reader.lux | 28 +-- stdlib/test/test/lux/control/writer.lux | 24 +- stdlib/test/test/lux/data/collection/list.lux | 8 +- stdlib/test/test/lux/data/color.lux | 24 +- stdlib/test/test/lux/data/error.lux | 28 +-- stdlib/test/test/lux/data/format/json.lux | 2 +- stdlib/test/test/lux/data/maybe.lux | 8 +- stdlib/test/test/lux/data/number.lux | 26 +-- stdlib/test/test/lux/data/number/complex.lux | 18 +- stdlib/test/test/lux/data/number/i64.lux | 6 +- stdlib/test/test/lux/data/product.lux | 10 +- stdlib/test/test/lux/data/sum.lux | 18 +- stdlib/test/test/lux/data/text/format.lux | 6 +- stdlib/test/test/lux/host.js.lux | 8 +- stdlib/test/test/lux/io.lux | 20 +- stdlib/test/test/lux/macro/code.lux | 24 +- stdlib/test/test/lux/macro/poly/equivalence.lux | 2 +- stdlib/test/test/lux/macro/syntax.lux | 22 +- stdlib/test/test/lux/math.lux | 14 +- stdlib/test/test/lux/math/modular.lux | 10 +- stdlib/test/test/lux/time/duration.lux | 4 +- stdlib/test/test/lux/time/instant.lux | 2 +- stdlib/test/test/lux/world/file.lux | 6 +- 56 files changed, 778 insertions(+), 756 deletions(-) diff --git a/luxc/src/lux/lexer.clj b/luxc/src/lux/lexer.clj index 73bcb4f22..dbbfc3d2e 100644 --- a/luxc/src/lux/lexer.clj +++ b/luxc/src/lux/lexer.clj @@ -138,11 +138,10 @@ (|do [[meta _ token] (&reader/read-regex )] (return (&/T [meta ( (string/replace token #"_" ""))])))) - ;; (-|\+) lex-nat $Nat #"^\|[0-9][0-9_]*" - lex-int $Int #"^-?[0-9][0-9_]*" + lex-int $Int #"^(-|\+)[0-9][0-9_]*" lex-rev $Rev #"^\.[0-9][0-9_]*" - lex-frac $Frac #"^-?[0-9][0-9_]*\.[0-9][0-9_]*((e|E)(-|\+)[0-9][0-9_]*)?" + lex-frac $Frac #"^(-|\+)[0-9][0-9_]*\.[0-9][0-9_]*((e|E)(-|\+)[0-9][0-9_]*)?" ) (def +same-module-mark+ (str &/+name-separator+ &/+name-separator+)) diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index a30c03a78..dd5a42064 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -1029,7 +1029,7 @@ (#Cons [(tag$ ["lux" "doc"]) (text$ "## Throws away any code given to it. ## Great for commenting-out code, while retaining syntax high-lighting and formatting in your text editor. - (comment 1 2 3 4)")] + (comment +1 +2 +3 +4)")] #Nil) (return #Nil)) @@ -1338,7 +1338,7 @@ (macro:' #export (list xs) (#Cons [(tag$ ["lux" "doc"]) (text$ "## List-construction macro. - (list 1 2 3)")] + (list +1 +2 +3)")] #Nil) (return (#Cons (list/fold (function'' [head tail] (form$ (#Cons (tag$ ["lux" "Cons"]) @@ -1352,7 +1352,7 @@ (#Cons [(tag$ ["lux" "doc"]) (text$ "## List-construction macro, with the last element being a tail-list. ## In other words, this macro prepends elements to another list. - (list& 1 2 3 (list 4 5 6))")] + (list& +1 +2 +3 (list +4 +5 +6))")] #Nil) ({(#Cons last init) (return (list (list/fold (function'' [head tail] @@ -2257,7 +2257,7 @@ (-> Int Int) (i/+ ))] - [inc 1] + [inc +1] [dec -1])")]) ({(#Cons [[_ (#Tuple bindings)] (#Cons [[_ (#Tuple templates)] data])]) ({[(#Some bindings') (#Some data')] @@ -2364,7 +2364,7 @@ (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) division.")]) (-> Nat Nat Nat) - (if ("lux int <" ("lux coerce" Int param) 0) + (if ("lux int <" ("lux coerce" Int param) +0) (if (n/< param subject) |0 |1) @@ -2469,11 +2469,11 @@ (list [(tag$ ["lux" "doc"]) (text$ "Rev(olution) division.")]) (-> Rev Rev Rev) - (if ("lux i64 =" 0 param) + (if ("lux i64 =" +0 param) ("lux io error" "Cannot divide Rev by zero!") (let' [[trailing-zeroes remaining] (without-trailing-zeroes |0 ("lux coerce" Nat param)) [trailing-zeroes denominator] ("lux check" (#Product Nat Nat) - (if ("lux i64 =" 0 trailing-zeroes) + (if ("lux i64 =" +0 trailing-zeroes) [|1 ("lux i64 logical-right-shift" |1 remaining)] [trailing-zeroes remaining])) shift ("lux i64 -" trailing-zeroes |64) @@ -2560,7 +2560,7 @@ (let' [loop ("lux check" (-> Nat Text Text) (function' recur [input output] (if (n/= |0 input) - (text/compose "+" output) + (text/compose "|" output) (recur (n// |10 input) (text/compose (|> input (n/% |10) digit-to-text) output)))))] @@ -2570,27 +2570,27 @@ (def:''' (int/abs value) #Nil (-> Int Int) - (if (i/< 0 value) + (if (i/< +0 value) (i/* -1 value) value)) (def:''' (int/encode value) #Nil (-> Int Text) - (if (i/= 0 value) + (if (i/= +0 value) "0" - (let' [sign (if (i/> 0 value) + (let' [sign (if (i/> +0 value) "" "-")] (("lux check" (-> Int Text Text) (function' recur [input output] - (if (i/= 0 input) + (if (i/= +0 input) (text/compose sign output) - (recur (i// 10 input) - (text/compose (|> input (i/% 10) ("lux coerce" Nat) digit-to-text) + (recur (i// +10 input) + (text/compose (|> input (i/% +10) ("lux coerce" Nat) digit-to-text) output))))) - (|> value (i// 10) int/abs) - (|> value (i/% 10) int/abs ("lux coerce" Nat) digit-to-text))))) + (|> value (i// +10) int/abs) + (|> value (i/% +10) int/abs ("lux coerce" Nat) digit-to-text))))) (def:''' (frac/encode x) #Nil @@ -2836,7 +2836,7 @@ (macro:' #export (: tokens) (list [(tag$ ["lux" "doc"]) (text$ "## The type-annotation macro. - (: (List Int) (list 1 2 3))")]) + (: (List Int) (list +1 +2 +3))")]) ({(#Cons type (#Cons value #Nil)) (return (list (` ("lux check" (type (~ type)) (~ value))))) @@ -2847,7 +2847,7 @@ (macro:' #export (:coerce tokens) (list [(tag$ ["lux" "doc"]) (text$ "## The type-coercion macro. - (:coerce Dinosaur (list 1 2 3))")]) + (:coerce Dinosaur (list +1 +2 +3))")]) ({(#Cons type (#Cons value #Nil)) (return (list (` ("lux coerce" (type (~ type)) (~ value))))) @@ -3117,7 +3117,7 @@ (list [(tag$ ["lux" "doc"]) (text$ "## The pattern-matching macro. ## Allows the usage of macros within the patterns to provide custom syntax. - (case (: (List Int) (list 1 2 3)) + (case (: (List Int) (list +1 +2 +3)) (#Cons x (#Cons y (#Cons z #Nil))) (#Some ($_ i/* x y z)) @@ -3136,7 +3136,7 @@ (list [(tag$ ["lux" "doc"]) (text$ "## Macro-expanding patterns. ## It's a special macro meant to be used with 'case'. - (case (: (List Int) (list 1 2 3)) + (case (: (List Int) (list +1 +2 +3)) (^ (list x y z)) (#Some ($_ i/* x y z)) @@ -3353,7 +3353,7 @@ (def: branching-exponent Int - 5)")]) + +5)")]) (let [[export? tokens'] (export^ tokens) parts (: (Maybe [Code (List Code) (Maybe Code) Code (List [Code Code])]) (case tokens' @@ -3610,9 +3610,9 @@ (macro: (default tokens state) {#.doc "## Allows you to provide a default value that will be used ## if a (Maybe x) value turns out to be #.None. - (default 20 (#.Some 10)) => 10 + (default +20 (#.Some +10)) => +10 - (default 20 #.None) => 20"} + (default +20 #.None) => +20"} (case tokens (^ (list else maybe)) (let [g!temp (: Code [dummy-cursor (#Identifier ["" ""])]) @@ -4872,7 +4872,7 @@ (:: Codec encode) ## Also allows using that value as a function. - (:: Codec encode 123)"} + (:: Codec encode +123)"} (case tokens (^ (list struct [_ (#Identifier member)])) (return (list (` (let [(^open ".") (~ struct)] (~ (identifier$ member)))))) @@ -5199,7 +5199,7 @@ (def: (repeat n x) (All [a] (-> Int a (List a))) - (if (i/> 0 n) + (if (i/> +0 n) (#Cons x (repeat (i/+ -1 n) x)) #Nil)) @@ -5289,9 +5289,9 @@ ## For Example: (doc \"Allows arbitrary looping, using the \\\"recur\\\" form to re-start the loop. Can be used in monadic code to create monadic loops.\" - (loop [count 0 + (loop [count +0 x init] - (if (< 10 count) + (if (< +10 count) (recur (inc count) (f x)) x)))"} (return (list (` [(~ cursor-code) @@ -5354,17 +5354,17 @@ (macro: #export (loop tokens) {#.doc (doc "Allows arbitrary looping, using the \"recur\" form to re-start the loop." "Can be used in monadic code to create monadic loops." - (loop [count 0 + (loop [count +0 x init] - (if (< 10 count) + (if (< +10 count) (recur (inc count) (f x)) x)) "Loops can also be given custom names." (loop my-loop - [count 0 + [count +0 x init] - (if (< 10 count) + (if (< +10 count) (my-loop (inc count) (f x)) x)))} (let [?params (case tokens @@ -5497,14 +5497,14 @@ [(bit #1) "#1" [_ (#.Bit #1)]] [(bit #0) "#0" [_ (#.Bit #0)]] - [(int 123) "123" [_ (#.Int 123)]] - [(frac 123.0) "123.0" [_ (#.Frac 123.0)]] + [(int +123) "+123" [_ (#.Int +123)]] + [(frac +123.0) "+123.0" [_ (#.Frac +123.0)]] [(text "\n") "\"\\n\"" [_ (#.Text "\n")]] [(tag ["yolo" "lol"]) "#yolo.lol" [_ (#.Tag ["yolo" "lol"])]] [(identifier ["yolo" "lol"]) "yolo.lol" [_ (#.Identifier ["yolo" "lol"])]] - [(form (list (bit #1) (int 123))) "(#1 123)" (^ [_ (#.Form (list [_ (#.Bit #1)] [_ (#.Int 123)]))])] - [(tuple (list (bit #1) (int 123))) "[#1 123]" (^ [_ (#.Tuple (list [_ (#.Bit #1)] [_ (#.Int 123)]))])] - [(record (list [(bit #1) (int 123)])) "{#1 123}" (^ [_ (#.Record (list [[_ (#.Bit #1)] [_ (#.Int 123)]]))])] + [(form (list (bit #1) (int +123))) "(#1 +123)" (^ [_ (#.Form (list [_ (#.Bit #1)] [_ (#.Int +123)]))])] + [(tuple (list (bit #1) (int +123))) "[#1 +123]" (^ [_ (#.Tuple (list [_ (#.Bit #1)] [_ (#.Int +123)]))])] + [(record (list [(bit #1) (int +123)])) "{#1 +123}" (^ [_ (#.Record (list [[_ (#.Bit #1)] [_ (#.Int +123)]]))])] [(local-tag "lol") "#lol" [_ (#.Tag ["" "lol"])]] [(local-identifier "lol") "lol" [_ (#.Identifier ["" "lol"])]] )] @@ -5716,7 +5716,7 @@ (not ( n)))] [Nat n/even? n/odd? n/% n/= |0 |2] - [Int i/even? i/odd? i/% i/= 0 2]) + [Int i/even? i/odd? i/% i/= +0 +2]) (def: (get-scope-type-vars state) (Meta (List Nat)) @@ -5765,11 +5765,11 @@ (def: #export (is? reference sample) {#.doc (doc "Tests whether the 2 values are identical (not just \"equal\")." "This one should succeed:" - (let [value 5] + (let [value +5] (is? value value)) "This one should fail:" - (is? 5 (i/+ 2 3)))} + (is? +5 (i/+ +2 +3)))} (All [a] (-> a a Bit)) ("lux is" reference sample)) @@ -5807,7 +5807,7 @@ (macro: #export (:assume tokens) {#.doc (doc "Coerces the given expression to the type of whatever is expected." - (: Dinosaur (:assume (list 1 2 3))))} + (: Dinosaur (:assume (list +1 +2 +3))))} (case tokens (^ (list expr)) (do Monad @@ -5833,7 +5833,7 @@ (macro: #export (:of tokens) {#.doc (doc "Generates the type corresponding to a given definition or variable." - (let [my-num (: Int 123)] + (let [my-num (: Int +123)] (:of my-num)) "==" Int)} @@ -6152,8 +6152,8 @@ (def: #export (i/mod param subject) (All [m] (-> Int Int Int)) (let [raw (i/% param subject)] - (if (i/< 0 raw) - (let [shift (if (i/< 0 param) i/- i/+)] + (if (i/< +0 raw) + (let [shift (if (i/< +0 param) i/- i/+)] (|> raw (shift param))) raw))) @@ -6177,11 +6177,11 @@ (def: #export (frac-to-rev input) (-> Frac Rev) - (let [abs (if (f/< 0.0 input) + (let [abs (if (f/< +0.0 input) (f/* -1.0 input) input)] (|> abs - (f/% 1.0) + (f/% +1.0) (f/* rev-denominator) frac-to-int ("lux i64 left-shift" |11)))) diff --git a/stdlib/source/lux/compiler/default/phase/analysis/structure.lux b/stdlib/source/lux/compiler/default/phase/analysis/structure.lux index 26a91dff6..29203290a 100644 --- a/stdlib/source/lux/compiler/default/phase/analysis/structure.lux +++ b/stdlib/source/lux/compiler/default/phase/analysis/structure.lux @@ -181,7 +181,7 @@ ## the tuple represents the expectations of the user. ## If the type is for a 3-tuple, but a 5-tuple is provided, it ## is assumed that the user intended the following layout: - ## [0, 1, [2, 3, 4]] + ## [+0, +1, [+2, +3, +4]] ## but that, for whatever reason, it was written in a flat ## way. [tailT tailC] diff --git a/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux b/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux index 10a893f09..b1dce6688 100644 --- a/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux +++ b/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux @@ -91,17 +91,17 @@ (def: (bit::left-shift [subjectO paramO]) Binary - (_.arithmetic-shift/2 (_.remainder/2 (_.int 64) paramO) + (_.arithmetic-shift/2 (_.remainder/2 (_.int +64) paramO) subjectO)) (def: (bit::arithmetic-right-shift [subjectO paramO]) Binary - (_.arithmetic-shift/2 (|> paramO (_.remainder/2 (_.int 64)) (_.*/2 (_.int -1))) + (_.arithmetic-shift/2 (|> paramO (_.remainder/2 (_.int +64)) (_.*/2 (_.int -1))) subjectO)) (def: (bit::logical-right-shift [subjectO paramO]) Binary - (runtime.bit//logical-right-shift (_.remainder/2 (_.int 64) paramO) subjectO)) + (runtime.bit//logical-right-shift (_.remainder/2 (_.int +64) paramO) subjectO)) (def: bundle::bit Bundle @@ -209,7 +209,7 @@ (bundle.install "%" (binary int::%)) (bundle.install "=" (binary int::=)) (bundle.install "<" (binary int::<)) - (bundle.install "to-frac" (unary (|>> (_.//2 (_.float 1.0))))) + (bundle.install "to-frac" (unary (|>> (_.//2 (_.float +1.0))))) (bundle.install "char" (unary int::char))))) (def: bundle::frac @@ -302,7 +302,7 @@ (def: (atom::read atom) Unary - (_.vector-ref/2 atom (_.int 0))) + (_.vector-ref/2 atom (_.int +0))) (def: (atom::compare-and-swap [atomO oldO newO]) Trinary @@ -332,7 +332,7 @@ ## [[Processes]] (def: (process::parallelism-level []) Nullary - (_.int 1)) + (_.int +1)) (def: bundle::process Bundle diff --git a/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux b/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux index 437c92520..bf65a7606 100644 --- a/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux +++ b/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux @@ -77,7 +77,7 @@ (_.apply/2 (_.global "apply") (_.global "values") @curried)])) bodyO)) (_.if (|> @num-args (_.>/2 arityO)) - (let [arity-args (runtime.slice (_.int 0) arityO @curried) + (let [arity-args (runtime.slice (_.int +0) arityO @curried) output-func-args (runtime.slice arityO (|> @num-args (_.-/2 arityO)) @curried)] diff --git a/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux b/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux index a2c9e31da..d72312693 100644 --- a/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux +++ b/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux @@ -114,14 +114,14 @@ (runtime: (slice offset length list) (<| (_.if (_.null?/1 list) list) - (_.if (|> offset (_.>/2 (_.int 0))) - (slice (|> offset (_.-/2 (_.int 1))) + (_.if (|> offset (_.>/2 (_.int +0))) + (slice (|> offset (_.-/2 (_.int +1))) length (_.cdr/1 list))) - (_.if (|> length (_.>/2 (_.int 0))) + (_.if (|> length (_.>/2 (_.int +0))) (_.cons/2 (_.car/1 list) (slice offset - (|> length (_.-/2 (_.int 1))) + (|> length (_.-/2 (_.int +1))) (_.cdr/1 list)))) _.nil)) @@ -157,7 +157,7 @@ (def: minimum-index-length (-> Expression Computation) - (|>> (_.+/2 (_.int 1)))) + (|>> (_.+/2 (_.int +1)))) (def: product-element (-> Expression Expression Computation) @@ -165,7 +165,7 @@ (def: (product-tail product) (-> Expression Computation) - (_.vector-ref/2 product (|> (_.length/1 product) (_.-/2 (_.int 1))))) + (_.vector-ref/2 product (|> (_.length/1 product) (_.-/2 (_.int +1))))) (def: (updated-index min-length product) (-> Expression Expression Computation) @@ -202,7 +202,7 @@ (_.begin (list (_.define @slice [(list) #.None] (_.make-vector/1 (|> @product_length (_.-/2 index)))) - (_.vector-copy!/5 @slice (_.int 0) product index @product_length) + (_.vector-copy!/5 @slice (_.int +0) product index @product_length) @slice))))))) (runtime: (sum//get sum last? wanted-tag) @@ -235,11 +235,11 @@ @@sum//get))) (runtime: (bit//logical-right-shift shift input) - (_.if (_.=/2 (_.int 0) shift) + (_.if (_.=/2 (_.int +0) shift) input (|> input (_.arithmetic-shift/2 (_.*/2 (_.int -1) shift)) - (_.bit-and/2 (_.int (hex "7FFFFFFFFFFFFFFF")))))) + (_.bit-and/2 (_.int (hex "+7FFFFFFFFFFFFFFF")))))) (def: runtime//bit Computation @@ -286,10 +286,10 @@ (runtime: (atom//compare-and-swap atom old new) (with-vars [@temp] - (_.let (list [@temp (_.vector-ref/2 atom (_.int 0))]) + (_.let (list [@temp (_.vector-ref/2 atom (_.int +0))]) (_.if (_.eq?/2 old @temp) (_.begin - (list (_.vector-set!/3 atom (_.int 0) new) + (list (_.vector-set!/3 atom (_.int +0) new) (_.bool #1))) (_.bool #0))))) @@ -300,7 +300,7 @@ (runtime: (box//write value box) (_.begin (list - (_.vector-set!/3 box (_.int 0) value) + (_.vector-set!/3 box (_.int +0) value) ..unit))) (def: runtime//box @@ -309,7 +309,7 @@ (runtime: (io//current-time _) (|> (_.apply/* (_.global "current-second") (list)) - (_.*/2 (_.int 1_000)) + (_.*/2 (_.int +1_000)) _.exact/1)) (def: runtime//io @@ -334,7 +334,7 @@ (_.set! process//incoming (_.cons/2 process process//incoming)))] (_.begin (list - (_.if (_.=/2 (_.int 0) milli-seconds) + (_.if (_.=/2 (_.int +0) milli-seconds) (process//future procedure) (with-vars [@start @process @now @ignored] (_.let (list [@start (io//current-time ..unit)]) diff --git a/stdlib/source/lux/compiler/default/syntax.lux b/stdlib/source/lux/compiler/default/syntax.lux index b5e9acb51..f88cedc9b 100644 --- a/stdlib/source/lux/compiler/default/syntax.lux +++ b/stdlib/source/lux/compiler/default/syntax.lux @@ -317,9 +317,9 @@ _ (l.this? "/") denominator frac-ratio-fragment _ (p.assert "Denominator cannot be 0." - (not (f/= 0.0 denominator)))] + (not (f/= +0.0 denominator)))] (wrap (|> numerator - (f/* (if signed? -1.0 1.0)) + (f/* (if signed? -1.0 +1.0)) (f// denominator)))))] (wrap [(update@ #.column (n/+ (text.size chunk)) where) [where (#.Frac value)]]))) diff --git a/stdlib/source/lux/control/comonad.lux b/stdlib/source/lux/control/comonad.lux index ef262762f..7efe24942 100644 --- a/stdlib/source/lux/control/comonad.lux +++ b/stdlib/source/lux/control/comonad.lux @@ -32,7 +32,7 @@ {#.doc (doc "A co-monadic parallel to the \"do\" macro." (let [square (function (_ n) (i/* n n))] (be CoMonad - [inputs (iterate inc 2)] + [inputs (iterate inc +2)] (square (head inputs)))))} (case tokens (#.Cons comonad (#.Cons [_ (#.Tuple bindings)] (#.Cons body #.Nil))) diff --git a/stdlib/source/lux/control/contract.lux b/stdlib/source/lux/control/contract.lux index 72aefd174..065829f44 100644 --- a/stdlib/source/lux/control/contract.lux +++ b/stdlib/source/lux/control/contract.lux @@ -19,8 +19,8 @@ {#.doc (doc "Pre-conditions." "Given a test and an expression to run, only runs the expression if the test passes." "Otherwise, an error is raised." - (pre (i/= 4 (i/+ 2 2)) - (foo 123 456 789)))} + (pre (i/= +4 (i/+ +2 +2)) + (foo +123 +456 +789)))} (wrap (list (` (exec (assert! (~ (code.text (format "Pre-condition failed: " (%code test)))) (~ test)) (~ expr)))))) @@ -31,7 +31,7 @@ "If the predicate returns #1, returns the value of the expression." "Otherwise, an error is raised." (post i/even? - (i/+ 2 2)))} + (i/+ +2 +2)))} (with-gensyms [g!output] (wrap (list (` (let [(~ g!output) (~ expr)] (exec (assert! (~ (code.text (format "Post-condition failed: " (%code test)))) diff --git a/stdlib/source/lux/control/pipe.lux b/stdlib/source/lux/control/pipe.lux index 716304479..a9a97b0c9 100644 --- a/stdlib/source/lux/control/pipe.lux +++ b/stdlib/source/lux/control/pipe.lux @@ -18,10 +18,10 @@ (syntax: #export (new> {tokens (p.at-least |2 s.any)}) {#.doc (doc "Ignores the piped argument, and begins a new pipe." - (|> 20 - (i/* 3) - (i/+ 4) - (new> 0 inc)))} + (|> +20 + (i/* +3) + (i/+ +4) + (new> +0 inc)))} (case (list.reverse tokens) (^ (list& _ r-body)) (wrap (list (` (|> (~+ (list.reverse r-body)))))) @@ -31,7 +31,7 @@ (syntax: #export (let> binding body prev) {#.doc (doc "Gives a name to the piped-argument, within the given expression." - (|> 5 + (|> +5 (let> X (i/+ X X))))} (wrap (list (` (let [(~ binding) (~ prev)] (~ body)))))) @@ -48,9 +48,9 @@ {branches (p.some (p.and body^ body^))}) {#.doc (doc "Branching for pipes." "Both the tests and the bodies are piped-code, and must be given inside a tuple." - (|> 5 - (cond> [i/even?] [(i/* 2)] - [i/odd?] [(i/* 3)] + (|> +5 + (cond> [i/even?] [(i/* +2)] + [i/odd?] [(i/* +3)] [(new> -1)])))} (with-gensyms [g!temp] (wrap (list (` (with-expansions @@ -71,8 +71,8 @@ prev) {#.doc (doc "Loops for pipes." "Both the testing and calculating steps are pipes and must be given inside tuples." - (|> 1 - (loop> [(i/< 10)] + (|> +1 + (loop> [(i/< +10)] [inc])))} (with-gensyms [g!temp] (wrap (list (` (loop [(~ g!temp) (~ prev)] @@ -85,10 +85,10 @@ prev) {#.doc (doc "Monadic pipes." "Each steps in the monadic computation is a pipe and must be given inside a tuple." - (|> 5 + (|> +5 (do> Monad - [(i/* 3)] - [(i/+ 4)] + [(i/* +3)] + [(i/+ +4)] [inc])))} (with-gensyms [g!temp] (case (list.reverse steps) @@ -108,9 +108,9 @@ prev) {#.doc (doc "Non-updating pipes." "Will generate piped computations, but their results will not be used in the larger scope." - (|> 5 + (|> +5 (exec> [.nat %n log!]) - (i/* 10)))} + (i/* +10)))} (with-gensyms [g!temp] (wrap (list (` (let [(~ g!temp) (~ prev)] (exec (|> (~ g!temp) (~+ body)) @@ -120,11 +120,11 @@ prev) {#.doc (doc "Parallel branching for pipes." "Allows to run multiple pipelines for a value and gives you a tuple of the outputs." - (|> 5 - (tuple> [(i/* 10)] - [dec (i// 2)] + (|> +5 + (tuple> [(i/* +10)] + [dec (i// +2)] [Int/encode])) - "Will become: [50 2 \"5\"]")} + "Will become: [+50 +2 \"+5\"]")} (with-gensyms [g!temp] (wrap (list (` (let [(~ g!temp) (~ prev)] [(~+ (list/map (function (_ body) (` (|> (~ g!temp) (~+ body)))) @@ -134,17 +134,17 @@ prev) {#.doc (doc "Pattern-matching for pipes." "The bodies of each branch are NOT pipes; just regular values." - (|> 5 - (case> 0 "zero" - 1 "one" - 2 "two" - 3 "three" - 4 "four" - 5 "five" - 6 "six" - 7 "seven" - 8 "eight" - 9 "nine" + (|> +5 + (case> +0 "zero" + +1 "one" + +2 "two" + +3 "three" + +4 "four" + +5 "five" + +6 "six" + +7 "seven" + +8 "eight" + +9 "nine" _ "???")))} (wrap (list (` (case (~ prev) (~+ (list/join (list/map (function (_ [pattern body]) (list pattern body)) diff --git a/stdlib/source/lux/data/collection/row.lux b/stdlib/source/lux/data/collection/row.lux index ddedad6c5..c9e2c6786 100644 --- a/stdlib/source/lux/data/collection/row.lux +++ b/stdlib/source/lux/data/collection/row.lux @@ -343,7 +343,7 @@ ## [Syntax] (syntax: #export (row {elems (p.some s.any)}) {#.doc (doc "Row literals." - (row 10 20 30 40))} + (row +10 +20 +30 +40))} (wrap (list (` (from-list (list (~+ elems))))))) ## [Structures] diff --git a/stdlib/source/lux/data/collection/sequence.lux b/stdlib/source/lux/data/collection/sequence.lux index 95d60b555..ed06547c2 100644 --- a/stdlib/source/lux/data/collection/sequence.lux +++ b/stdlib/source/lux/data/collection/sequence.lux @@ -138,7 +138,7 @@ {branches (p.some s.any)}) {#.doc (doc "Allows destructuring of sequences in pattern-matching expressions." "Caveat emptor: Only use it for destructuring, and not for testing values within the sequences." - (let [(^sequence& x y z _tail) (some-sequence-func 1 2 3)] + (let [(^sequence& x y z _tail) (some-sequence-func +1 +2 +3)] (func x y z)))} (with-gensyms [g!sequence] (let [body+ (` (let [(~+ (list/join (list/map (function (_ pattern) diff --git a/stdlib/source/lux/data/collection/tree/rose.lux b/stdlib/source/lux/data/collection/tree/rose.lux index 62b65422a..fc25f414f 100644 --- a/stdlib/source/lux/data/collection/tree/rose.lux +++ b/stdlib/source/lux/data/collection/tree/rose.lux @@ -49,9 +49,9 @@ (syntax: #export (tree {root tree^}) {#.doc (doc "Tree literals." - (tree Int [10 {20 {} - 30 {} - 40 {}}]))} + (tree Int [+10 {+20 {} + +30 {} + +40 {}}]))} (wrap (list (` (~ (loop [[value children] root] (` {#value (~ value) #children (list (~+ (list/map recur children)))}))))))) diff --git a/stdlib/source/lux/data/color.lux b/stdlib/source/lux/data/color.lux index c708e8775..2eb8bd35f 100644 --- a/stdlib/source/lux/data/color.lux +++ b/stdlib/source/lux/data/color.lux @@ -53,62 +53,62 @@ blue (scale-down blue) max ($_ f/max red green blue) min ($_ f/min red green blue) - luminance (|> (f/+ max min) (f// 2.0))] + luminance (|> (f/+ max min) (f// +2.0))] (if (f/= max min) ## Achromatic - [0.0 0.0 luminance] + [+0.0 +0.0 luminance] ## Chromatic (let [diff (|> max (f/- min)) saturation (|> diff - (f// (if (f/> 0.5 luminance) - (|> 2.0 (f/- max) (f/- min)) + (f// (if (f/> +0.5 luminance) + (|> +2.0 (f/- max) (f/- min)) (|> max (f/+ min))))) hue' (cond (f/= red max) (|> green (f/- blue) (f// diff) - (f/+ (if (f/< blue green) 6.0 0.0))) + (f/+ (if (f/< blue green) +6.0 +0.0))) (f/= green max) (|> blue (f/- red) (f// diff) - (f/+ 2.0)) + (f/+ +2.0)) ## (f/= blue max) (|> red (f/- green) (f// diff) - (f/+ 4.0)))] - [(|> hue' (f// 6.0)) + (f/+ +4.0)))] + [(|> hue' (f// +6.0)) saturation luminance])))) (def: (hue-to-rgb p q t) (-> Frac Frac Frac Frac) - (let [t (cond (f/< 0.0 t) (f/+ 1.0 t) - (f/> 1.0 t) (f/- 1.0 t) + (let [t (cond (f/< +0.0 t) (f/+ +1.0 t) + (f/> +1.0 t) (f/- +1.0 t) ## else t) - f2/3 (f// 3.0 2.0)] - (cond (f/< (f// 6.0 1.0) t) - (|> q (f/- p) (f/* 6.0) (f/* t) (f/+ p)) + f2/3 (f// +3.0 +2.0)] + (cond (f/< (f// +6.0 +1.0) t) + (|> q (f/- p) (f/* +6.0) (f/* t) (f/+ p)) - (f/< (f// 2.0 1.0) t) + (f/< (f// +2.0 +1.0) t) q (f/< f2/3 t) - (|> q (f/- p) (f/* (|> f2/3 (f/- t))) (f/* 6.0) (f/+ p)) + (|> q (f/- p) (f/* (|> f2/3 (f/- t))) (f/* +6.0) (f/+ p)) ## else p))) (def: #export (from-hsl [hue saturation luminance]) (-> [Frac Frac Frac] Color) - (if (f/= 0.0 saturation) + (if (f/= +0.0 saturation) ## Achromatic (let [intensity (scale-up luminance)] (color [intensity intensity intensity])) ## Chromatic - (let [q (if (f/< 0.5 luminance) - (|> saturation (f/+ 1.0) (f/* luminance)) + (let [q (if (f/< +0.5 luminance) + (|> saturation (f/+ +1.0) (f/* luminance)) (|> luminance (f/+ saturation) (f/- (f/* saturation luminance)))) - p (|> luminance (f/* 2.0) (f/- q)) - third (|> 1.0 (f// 3.0))] + p (|> luminance (f/* +2.0) (f/- q)) + third (|> +1.0 (f// +3.0))] (color [(scale-up (|> hue (f/+ third) (hue-to-rgb p q))) (scale-up (|> hue (hue-to-rgb p q))) (scale-up (|> hue (f/- third) (hue-to-rgb p q)))])))) @@ -123,38 +123,38 @@ min ($_ f/min red green blue) brightness max diff (|> max (f/- min)) - saturation (if (f/= 0.0 max) - 0.0 + saturation (if (f/= +0.0 max) + +0.0 (|> diff (f// max)))] (if (f/= max min) ## Achromatic - [0.0 saturation brightness] + [+0.0 saturation brightness] ## Chromatic (let [hue (cond (f/= red max) (|> green (f/- blue) (f// diff) - (f/+ (if (f/< blue green) 6.0 0.0))) + (f/+ (if (f/< blue green) +6.0 +0.0))) (f/= green max) (|> blue (f/- red) (f// diff) - (f/+ 2.0)) + (f/+ +2.0)) ## (f/= blue max) (|> red (f/- green) (f// diff) - (f/+ 4.0)))] - [(|> hue (f// 6.0)) + (f/+ +4.0)))] + [(|> hue (f// +6.0)) saturation brightness])))) (def: #export (from-hsb [hue saturation brightness]) (-> [Frac Frac Frac] Color) - (let [hue (|> hue (f/* 6.0)) + (let [hue (|> hue (f/* +6.0)) i (math.floor hue) f (|> hue (f/- i)) - p (|> 1.0 (f/- saturation) (f/* brightness)) - q (|> 1.0 (f/- (f/* f saturation)) (f/* brightness)) - t (|> 1.0 (f/- (|> 1.0 (f/- f) (f/* saturation))) (f/* brightness)) + p (|> +1.0 (f/- saturation) (f/* brightness)) + q (|> +1.0 (f/- (f/* f saturation)) (f/* brightness)) + t (|> +1.0 (f/- (|> +1.0 (f/- f) (f/* saturation))) (f/* brightness)) v brightness - mod (|> i (f/% 6.0) frac-to-int .nat) + mod (|> i (f/% +6.0) frac-to-int .nat) red (case mod |0 v |1 q |2 p |3 p |4 t |5 v _ (undefined)) green (case mod |0 t |1 v |2 v |3 q |4 p |5 p _ (undefined)) blue (case mod |0 p |1 p |2 t |3 v |4 v |5 q _ (undefined))] @@ -168,34 +168,34 @@ red (scale-down red) green (scale-down green) blue (scale-down blue) - key (|> 1.0 (f/- ($_ f/max red green blue))) - f (if (f/< 1.0 key) - (|> 1.0 (f// (|> 1.0 (f/- key)))) - 0.0) - cyan (|> 1.0 (f/- red) (f/- key) (f/* f)) - magenta (|> 1.0 (f/- green) (f/- key) (f/* f)) - yellow (|> 1.0 (f/- blue) (f/- key) (f/* f))] + key (|> +1.0 (f/- ($_ f/max red green blue))) + f (if (f/< +1.0 key) + (|> +1.0 (f// (|> +1.0 (f/- key)))) + +0.0) + cyan (|> +1.0 (f/- red) (f/- key) (f/* f)) + magenta (|> +1.0 (f/- green) (f/- key) (f/* f)) + yellow (|> +1.0 (f/- blue) (f/- key) (f/* f))] [cyan magenta yellow key])) (def: #export (from-cmyk [cyan magenta yellow key]) (-> [Frac Frac Frac Frac] Color) - (if (f/= 1.0 key) + (if (f/= +1.0 key) (color [|0 |0 |0]) - (let [red (|> (|> 1.0 (f/- cyan)) - (f/* (|> 1.0 (f/- key)))) - green (|> (|> 1.0 (f/- magenta)) - (f/* (|> 1.0 (f/- key)))) - blue (|> (|> 1.0 (f/- yellow)) - (f/* (|> 1.0 (f/- key))))] + (let [red (|> (|> +1.0 (f/- cyan)) + (f/* (|> +1.0 (f/- key)))) + green (|> (|> +1.0 (f/- magenta)) + (f/* (|> +1.0 (f/- key)))) + blue (|> (|> +1.0 (f/- yellow)) + (f/* (|> +1.0 (f/- key))))] (color [(scale-up red) (scale-up green) (scale-up blue)])))) (def: (normalize ratio) (-> Frac Frac) - (cond (f/> 1.0 ratio) - (f/% 1.0 ratio) + (cond (f/> +1.0 ratio) + (f/% +1.0 ratio) - (f/< 0.0 ratio) - (|> 1.0 (f/+ (f/% 1.0 ratio))) + (f/< +0.0 ratio) + (|> +1.0 (f/+ (f/% +1.0 ratio))) ## else ratio)) @@ -203,7 +203,7 @@ (def: #export (interpolate ratio end start) (-> Frac Color Color Color) (let [dS (normalize ratio) - dE (|> 1.0 (f/- dS)) + dE (|> +1.0 (f/- dS)) interpolate' (: (-> Nat Nat Nat) (function (_ end start) (|> (|> start .int int-to-frac (f/* dS)) @@ -242,8 +242,8 @@ (let [[hue saturation luminance] (to-hsl color)] (from-hsl [hue (|> saturation - (f/* (|> 1.0 ( (normalize ratio)))) - (f/min 1.0)) + (f/* (|> +1.0 ( (normalize ratio)))) + (f/min +1.0)) luminance])))] [saturate f/+] @@ -253,7 +253,7 @@ (def: #export (gray-scale color) (-> Color Color) (let [[_ _ luminance] (to-hsl color)] - (from-hsl [0.0 0.0 luminance]))) + (from-hsl [+0.0 +0.0 luminance]))) (do-template [ <1> <2>] [(def: #export ( color) @@ -263,9 +263,9 @@ (from-hsl [(|> hue (f/+ <1>) normalize) saturation luminance]) (from-hsl [(|> hue (f/+ <2>) normalize) saturation luminance])]))] - [triad (|> 1.0 (f// 3.0)) (|> 2.0 (f// 3.0))] - [clash (|> 1.0 (f// 4.0)) (|> 3.0 (f// 4.0))] - [split-complement (|> 1.0 (f// 5.0)) (|> 3.0 (f// 5.0))] + [triad (|> +1.0 (f// +3.0)) (|> +2.0 (f// +3.0))] + [clash (|> +1.0 (f// +4.0)) (|> +3.0 (f// +4.0))] + [split-complement (|> +1.0 (f// +5.0)) (|> +3.0 (f// +5.0))] ) (do-template [ <1> <2> <3>] @@ -277,8 +277,8 @@ (from-hsl [(|> hue (f/+ <2>) normalize) saturation luminance]) (from-hsl [(|> hue (f/+ <3>) normalize) saturation luminance])]))] - [square (|> 1.0 (f// 4.0)) (|> 2.0 (f// 4.0)) (|> 3.0 (f// 4.0))] - [tetradic (|> 2.0 (f// 12.0)) (|> 6.0 (f// 12.0)) (|> 8.0 (f// 12.0))] + [square (|> +1.0 (f// +4.0)) (|> +2.0 (f// +4.0)) (|> +3.0 (f// +4.0))] + [tetradic (|> +2.0 (f// +12.0)) (|> +6.0 (f// +12.0)) (|> +8.0 (f// +12.0))] ) (def: #export (analogous results slice color) @@ -298,7 +298,7 @@ (if (n/= |0 results) (list) (let [[hue saturation brightness] (to-hsb color) - slice (|> 1.0 (f// (|> results .int int-to-frac)))] + slice (|> +1.0 (f// (|> results .int int-to-frac)))] (|> (list.n/range |0 (dec results)) (list/map (|>> .int int-to-frac (f/* slice) diff --git a/stdlib/source/lux/data/error.lux b/stdlib/source/lux/data/error.lux index 8054736e9..17d88a5a0 100644 --- a/stdlib/source/lux/data/error.lux +++ b/stdlib/source/lux/data/error.lux @@ -86,10 +86,10 @@ (macro: #export (default tokens compiler) {#.doc (doc "Allows you to provide a default value that will be used" "if a (Error x) value turns out to be #Error." - (is? 10 - (default 20 (#Success 10))) - (is? 20 - (default 20 (#Error "KABOOM!"))))} + (is? +10 + (default +20 (#Success +10))) + (is? +20 + (default +20 (#Error "KABOOM!"))))} (case tokens (^ (list else error)) (#Success [compiler (list (` (case (~ error) diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux index 02c05f5dd..549631f2a 100644 --- a/stdlib/source/lux/data/format/json.lux +++ b/stdlib/source/lux/data/format/json.lux @@ -55,7 +55,7 @@ (syntax: #export (json token) {#.doc (doc "A simple way to produce JSON literals." (json #1) - (json 123.456) + (json +123.456) (json "Some text") (json #null) (json ["this" "is" "an" "array"]) diff --git a/stdlib/source/lux/data/maybe.lux b/stdlib/source/lux/data/maybe.lux index d6b44e02d..57ff95727 100644 --- a/stdlib/source/lux/data/maybe.lux +++ b/stdlib/source/lux/data/maybe.lux @@ -84,9 +84,9 @@ (macro: #export (default tokens state) {#.doc "## Allows you to provide a default value that will be used ## if a (Maybe x) value turns out to be #.None. - (default 20 (#.Some 10)) => 10 + (default +20 (#.Some +10)) => +10 - (default 20 #.None) => 20"} + (default +20 #.None) => +20"} (case tokens (^ (list else maybe)) (let [g!temp (: Code [dummy-cursor (#.Identifier ["" ""])]) diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux index 9934af3de..573e422d6 100644 --- a/stdlib/source/lux/data/number.lux +++ b/stdlib/source/lux/data/number.lux @@ -10,7 +10,7 @@ interval [codec (#+ Codec)]] [data - ["e" error] + ["." error (#+ Error)] ["." maybe] ["." text]]] [/ @@ -74,8 +74,8 @@ <1>)) )] - [ Int Order i/+ i/- i/* i// i/% i/= i/< 0 1 -1] - [Frac Order f/+ f/- f/* f// f/% f/= f/< 0.0 1.0 -1.0] + [ Int Order i/+ i/- i/* i// i/% i/= i/< +0 +1 -1] + [Frac Order f/+ f/- f/* f// f/% f/= f/< +0.0 +1.0 -1.0] ) (structure: #export _ (Number Rev) @@ -108,7 +108,7 @@ (def: bottom ))] [ Nat Enum (:coerce Nat -1) |0] - [ Int Enum 9_223_372_036_854_775_807 -9_223_372_036_854_775_808] + [ Int Enum +9_223_372_036_854_775_807 -9_223_372_036_854_775_808] [Frac Enum ("lux frac max") ("lux frac min")] [ Rev Enum (:coerce Rev -1) (:coerce Rev |0)] ) @@ -122,12 +122,12 @@ [ Mul@Monoid Nat |1 n/*] [ Max@Monoid Nat (:: Interval bottom) n/max] [ Min@Monoid Nat (:: Interval top) n/min] - [ Add@Monoid Int 0 i/+] - [ Mul@Monoid Int 1 i/*] + [ Add@Monoid Int +0 i/+] + [ Mul@Monoid Int +1 i/*] [ Max@Monoid Int (:: Interval bottom) i/max] [ Min@Monoid Int (:: Interval top) i/min] - [Add@Monoid Frac 0.0 f/+] - [Mul@Monoid Frac 1.0 f/*] + [Add@Monoid Frac +0.0 f/+] + [Mul@Monoid Frac +1.0 f/*] [Max@Monoid Frac (:: Interval bottom) f/max] [Min@Monoid Frac (:: Interval top) f/min] [ Add@Monoid Rev (:: Interval bottom) r/+] @@ -140,10 +140,10 @@ [(def: #export {#.doc } Frac - (f// 0.0 ))] + (f// +0.0 ))] - [not-a-number 0.0 "Not a number."] - [positive-infinity 1.0 "Positive infinity."] + [not-a-number +0.0 "Not a number."] + [positive-infinity +1.0 "Positive infinity."] [negative-infinity -1.0 "Negative infinity."] ) @@ -166,10 +166,10 @@ (def: (decode input) (case ( [input]) (#.Some value) - (#e.Success value) + (#error.Success value) #.None - (#e.Error ))))] + (#error.Error ))))] [Frac "lux frac encode" "lux frac decode" "Could not decode Frac"] ) @@ -314,16 +314,16 @@ (let [digit (maybe.assume (get-char repr idx))] (case ( digit) #.None - (#e.Error ("lux text concat" repr)) + (#error.Error ("lux text concat" repr)) (#.Some digit-value) (recur (inc idx) (|> output (n/* ) (n/+ digit-value))))) - (#e.Success output))) + (#error.Success output))) _ - (#e.Error ("lux text concat" repr))) - (#e.Error ("lux text concat" repr))))))] + (#error.Error ("lux text concat" repr))) + (#error.Error ("lux text concat" repr))))))] [Binary@Codec |2 binary-character binary-value "Invalid binary syntax for Nat: "] [Octal@Codec |8 octal-character octal-value "Invalid octal syntax for Nat: "] @@ -331,51 +331,69 @@ [Hex@Codec |16 hexadecimal-character hexadecimal-value "Invalid hexadecimal syntax for Nat: "] ) +(def: (int/sign!! value) + (-> Int Text) + (if (i/< +0 value) + "-" + "+")) + +(def: (int/sign?? representation) + (-> Text (Maybe Int)) + (case (get-char representation |0) + (^ (#.Some "-")) + (#.Some -1) + + (^ (#.Some "+")) + (#.Some +1) + + _ + #.None)) + +(def: (int-decode-loop input-size repr sign ) + (-> Nat Text Int Int (-> Text (Maybe Nat)) Text (Error Int)) + (loop [idx |1 + output +0] + (if (n/< input-size idx) + (let [digit (maybe.assume (get-char repr idx))] + (case ( digit) + #.None + (#error.Error ) + + (#.Some digit-value) + (recur (inc idx) + (|> output (i/* ) (i/+ (.int digit-value)))))) + (#error.Success (i/* sign output))))) + (do-template [ ] [(structure: #export (Codec Text Int) (def: (encode value) - (if (i/= 0 value) - "0" - (let [sign (if (i/< 0 value) - "-" - "")] - (loop [input (|> value (i// ) (:: Number abs)) - output (|> value (i/% ) (:: Number abs) .nat - - maybe.assume)] - (if (i/= 0 input) - ("lux text concat" sign output) - (let [digit (maybe.assume ( (.nat (i/% input))))] - (recur (i// input) - ("lux text concat" digit output)))))))) + (if (i/= +0 value) + "+0" + (loop [input (|> value (i// ) (:: Number abs)) + output (|> value (i/% ) (:: Number abs) .nat + + maybe.assume)] + (if (i/= +0 input) + ("lux text concat" (int/sign!! value) output) + (let [digit (maybe.assume ( (.nat (i/% input))))] + (recur (i// input) + ("lux text concat" digit output))))))) (def: (decode repr) (let [input-size ("lux text size" repr)] - (if (n/>= |1 input-size) - (let [sign (case (get-char repr |0) - (^ (#.Some "-")) - -1 - - _ - 1)] - (loop [idx (if (i/= -1 sign) |1 |0) - output 0] - (if (n/< input-size idx) - (let [digit (maybe.assume (get-char repr idx))] - (case ( digit) - #.None - (#e.Error ) - - (#.Some digit-value) - (recur (inc idx) - (|> output (i/* ) (i/+ (:coerce Int digit-value)))))) - (#e.Success (i/* sign output))))) - (#e.Error )))))] - - [Binary@Codec 2 binary-character binary-value "Invalid binary syntax for Int: "] - [Octal@Codec 8 octal-character octal-value "Invalid octal syntax for Int: "] - [_ 10 decimal-character decimal-value "Invalid syntax for Int: "] - [Hex@Codec 16 hexadecimal-character hexadecimal-value "Invalid hexadecimal syntax for Int: "] + (if (n/> |1 input-size) + (case (int/sign?? repr) + (#.Some sign) + (int-decode-loop input-size repr sign ) + + #.None + (#error.Error )) + (#error.Error )))))] + + [Binary@Codec +2 binary-character binary-value "Invalid binary syntax for Int: "] + [Octal@Codec +8 octal-character octal-value "Invalid octal syntax for Int: "] + [_ +10 decimal-character decimal-value "Invalid syntax for Int: "] + [Hex@Codec +16 hexadecimal-character hexadecimal-value "Invalid hexadecimal syntax for Int: "] ) (def: (de-prefix input) @@ -403,12 +421,12 @@ (case ("lux text char" repr |0) (^multi (^ (#.Some (char "."))) [(:: decode ("lux text concat" "|" (de-prefix repr))) - (#e.Success output)]) - (#e.Success (:coerce Rev output)) + (#error.Success output)]) + (#error.Success (:coerce Rev output)) _ - (#e.Error ("lux text concat" repr))) - (#e.Error ("lux text concat" repr))))))] + (#error.Error ("lux text concat" repr))) + (#error.Error ("lux text concat" repr))))))] [Binary@Codec Binary@Codec |1 "Invalid binary syntax: "] [Octal@Codec Octal@Codec |3 "Invalid octal syntax: "] @@ -420,17 +438,17 @@ (def: (encode value) (let [whole (frac-to-int value) whole-part (:: encode whole) - decimal (:: Number abs (f/% 1.0 value)) - decimal-part (if (f/= 0.0 decimal) + decimal (:: Number abs (f/% +1.0 value)) + decimal-part (if (f/= +0.0 decimal) ".0" (loop [dec-left decimal output ""] - (if (f/= 0.0 dec-left) + (if (f/= +0.0 dec-left) ("lux text concat" "." output) (let [shifted (f/* dec-left) digit (|> shifted (f/% ) frac-to-int .nat (get-char ) maybe.assume)] - (recur (f/% 1.0 shifted) + (recur (f/% +1.0 shifted) ("lux text concat" output digit))))))] ("lux text concat" whole-part decimal-part))) @@ -441,34 +459,34 @@ decimal-part (maybe.assume ("lux text clip" repr (inc split-index) ("lux text size" repr)))] (case [(:: decode whole-part) (:: decode decimal-part)] - (^multi [(#e.Success whole) (#e.Success decimal)] - (i/>= 0 decimal)) - (let [sign (if (i/< 0 whole) + (^multi [(#error.Success whole) (#error.Success decimal)] + (i/>= +0 decimal)) + (let [sign (if (i/< +0 whole) -1.0 - 1.0) + +1.0) div-power (loop [muls-left ("lux text size" decimal-part) - output 1.0] + output +1.0] (if (n/= |0 muls-left) output (recur (dec muls-left) (f/* output)))) adjusted-decimal (|> decimal int-to-frac (f// div-power)) dec-rev (case (:: Hex@Codec decode ("lux text concat" "." decimal-part)) - (#e.Success dec-rev) + (#error.Success dec-rev) dec-rev - (#e.Error error) + (#error.Error error) (error! error))] - (#e.Success (f/+ (int-to-frac whole) - (f/* sign adjusted-decimal)))) + (#error.Success (f/+ (int-to-frac whole) + (f/* sign adjusted-decimal)))) _ - (#e.Error ("lux text concat" repr)))) + (#error.Error ("lux text concat" repr)))) _ - (#e.Error ("lux text concat" repr)))))] + (#error.Error ("lux text concat" repr)))))] - [Binary@Codec Binary@Codec 2.0 "01" "Invalid binary syntax: "] + [Binary@Codec Binary@Codec +2.0 "01" "Invalid binary syntax: "] ) (def: (segment-digits chunk-size digits) @@ -627,7 +645,7 @@ -1.0 _ - 1.0)] + +1.0)] (case ("lux text index" repr "." |0) (#.Some split-index) (let [whole-part (maybe.assume ("lux text clip" repr (if (f/= -1.0 sign) |1 |0) split-index)) @@ -637,14 +655,14 @@ ("lux text concat" ( whole-part)) ("lux text concat" (if (f/= -1.0 sign) "-" "")))] (case (:: Binary@Codec decode as-binary) - (#e.Error _) - (#e.Error ("lux text concat" repr)) + (#error.Error _) + (#error.Error ("lux text concat" repr)) output output)) _ - (#e.Error ("lux text concat" repr))))))] + (#error.Error ("lux text concat" repr))))))] [Octal@Codec "Invalid octaladecimal syntax: " binary-to-octal octal-to-binary] [Hex@Codec "Invalid hexadecimal syntax: " binary-to-hex hex-to-binary] @@ -661,12 +679,12 @@ description [cursor (#.Text ($_ "lux text concat" encoding "\n" underscore))]] - (#e.Success [state (list (` (doc (~ description) - (~ example-1) - (~ example-2))))])) + (#error.Success [state (list (` (doc (~ description) + (~ example-1) + (~ example-2))))])) _ - (#e.Error "Wrong syntax for \"encoding-doc\"."))) + (#error.Error "Wrong syntax for \"encoding-doc\"."))) (def: (underscore-prefixed? number) (-> Text Bit) @@ -687,36 +705,36 @@ (case tokens (#.Cons [meta (#.Text repr')] #.Nil) (if (underscore-prefixed? repr') - (#e.Error ) + (#error.Error ) (let [repr (clean-underscores repr')] (case (:: decode repr) - (#e.Success value) - (#e.Success [state (list [meta (#.Nat value)])]) + (#error.Success value) + (#error.Success [state (list [meta (#.Nat value)])]) - (^multi (#e.Error _) - [(:: decode repr) (#e.Success value)]) - (#e.Success [state (list [meta (#.Int value)])]) + (^multi (#error.Error _) + [(:: decode repr) (#error.Success value)]) + (#error.Success [state (list [meta (#.Int value)])]) - (^multi (#e.Error _) - [(:: decode repr) (#e.Success value)]) - (#e.Success [state (list [meta (#.Rev value)])]) + (^multi (#error.Error _) + [(:: decode repr) (#error.Success value)]) + (#error.Success [state (list [meta (#.Rev value)])]) - (^multi (#e.Error _) - [(:: decode repr) (#e.Success value)]) - (#e.Success [state (list [meta (#.Frac value)])]) + (^multi (#error.Error _) + [(:: decode repr) (#error.Success value)]) + (#error.Success [state (list [meta (#.Frac value)])]) _ - (#e.Error )))) + (#error.Error )))) _ - (#e.Error )))] + (#error.Error )))] [bin Binary@Codec Binary@Codec Binary@Codec Binary@Codec "Invalid binary syntax." - (encoding-doc "binary" (bin "11001001") (bin "11_00_10_01"))] + (encoding-doc "binary" (bin "+11001001") (bin "+11_00_10_01"))] [oct Octal@Codec Octal@Codec Octal@Codec Octal@Codec "Invalid octal syntax." - (encoding-doc "octal" (oct "615243") (oct "615_243"))] + (encoding-doc "octal" (oct "+615243") (oct "+615_243"))] [hex Hex@Codec Hex@Codec Hex@Codec Hex@Codec "Invalid hexadecimal syntax." (encoding-doc "hexadecimal" (hex "deadBEEF") (hex "dead_BEEF"))] @@ -755,7 +773,7 @@ (loop [idx idx carry |0 output output] - (if (i/>= 0 (:coerce Int idx)) + (if (i/>= +0 (:coerce Int idx)) (let [raw (|> (digits-get idx output) (n/* |5) (n/+ carry))] @@ -769,7 +787,7 @@ (loop [times power output (|> (make-digits []) (digits-put power |1))] - (if (i/>= 0 (:coerce Int times)) + (if (i/>= +0 (:coerce Int times)) (recur (dec times) (digits-times-5! power output)) output))) @@ -779,7 +797,7 @@ (loop [idx (dec i64.width) all-zeroes? #1 output ""] - (if (i/>= 0 (:coerce Int idx)) + (if (i/>= +0 (:coerce Int idx)) (let [digit (digits-get idx digits)] (if (and (n/= |0 digit) all-zeroes?) @@ -798,7 +816,7 @@ (loop [idx (dec i64.width) carry |0 output (make-digits [])] - (if (i/>= 0 (:coerce Int idx)) + (if (i/>= +0 (:coerce Int idx)) (let [raw ($_ n/+ carry (digits-get idx param) @@ -816,7 +834,7 @@ output (make-digits [])] (if (n/< length idx) (let [char (maybe.assume (get-char input idx))] - (case ("lux text index" "0123456789" char |0) + (case ("lux text index" "+0123456789" char |0) #.None #.None @@ -852,7 +870,7 @@ (-> Digits Digits Digits) (loop [idx (dec i64.width) output subject] - (if (i/>= 0 (.int idx)) + (if (i/>= +0 (.int idx)) (recur (dec idx) (digits-sub-once! idx (digits-get idx param) output)) output))) @@ -865,7 +883,7 @@ ".0" (loop [idx last-idx digits (make-digits [])] - (if (i/>= 0 (:coerce Int idx)) + (if (i/>= +0 (:coerce Int idx)) (if (i64.set? idx input) (let [digits' (digits-add (digits-power (n/- idx last-idx)) digits)] @@ -901,16 +919,16 @@ (recur (digits-sub! power digits) (inc idx) (i64.set (n/- idx (dec i64.width)) output)))) - (#e.Success (:coerce Rev output)))) + (#error.Success (:coerce Rev output)))) #.None - (#e.Error ("lux text concat" "Wrong syntax for Rev: " input))) - (#e.Error ("lux text concat" "Wrong syntax for Rev: " input)))) + (#error.Error ("lux text concat" "Wrong syntax for Rev: " input))) + (#error.Error ("lux text concat" "Wrong syntax for Rev: " input)))) )) (def: (log2 input) (-> Frac Frac) - (f// ("lux math log" 2.0) + (f// ("lux math log" +2.0) ("lux math log" input))) (def: double-bias Nat |1023) @@ -929,8 +947,8 @@ (f/= negative-infinity input) (hex "|FFF0000000000000") - (f/= 0.0 input) - (let [reciprocal (f// input 1.0)] + (f/= +0.0 input) + (let [reciprocal (f// input +1.0)] (if (f/= positive-infinity reciprocal) ## Positive zero (hex "|0000000000000000") @@ -944,9 +962,9 @@ exponent-mask (|> |1 (i64.left-shift exponent-size) dec) mantissa (|> input ## Normalize - (f// ("lux math pow" 2.0 exponent)) + (f// ("lux math pow" +2.0 exponent)) ## Make it int-equivalent - (f/* ("lux math pow" 2.0 52.0))) + (f/* ("lux math pow" +2.0 +52.0))) sign-bit (if (f/= -1.0 sign) |1 |0) exponent-bits (|> exponent frac-to-int .nat (n/+ double-bias) (i64.and exponent-mask)) mantissa-bits (|> mantissa frac-to-int .nat)] @@ -981,16 +999,16 @@ (and (n/= |0 E) (n/= |0 M)) (if (n/= |0 S) - 0.0 - (f/* -1.0 0.0)) + +0.0 + (f/* -1.0 +0.0)) ## else (let [normalized (|> M (i64.set mantissa-size) .int int-to-frac - (f// ("lux math pow" 2.0 52.0))) + (f// ("lux math pow" +2.0 +52.0))) power (|> E (n/- double-bias) .int int-to-frac - ("lux math pow" 2.0)) + ("lux math pow" +2.0)) shifted (f/* power normalized)] (if (n/= |0 S) diff --git a/stdlib/source/lux/data/number/complex.lux b/stdlib/source/lux/data/number/complex.lux index 41e074be6..fb0401582 100644 --- a/stdlib/source/lux/data/number/complex.lux +++ b/stdlib/source/lux/data/number/complex.lux @@ -27,14 +27,14 @@ "The imaginary part can be omitted if it's 0." (complex real))} (wrap (list (` {#..real (~ real) - #..imaginary (~ (maybe.default (' 0.0) + #..imaginary (~ (maybe.default (' +0.0) ?imaginary))})))) -(def: #export i Complex (complex 0.0 1.0)) +(def: #export i Complex (complex +0.0 +1.0)) -(def: #export one Complex (complex 1.0 0.0)) +(def: #export one Complex (complex +1.0 +0.0)) -(def: #export zero Complex (complex 0.0 0.0)) +(def: #export zero Complex (complex +0.0 +0.0)) (def: #export (not-a-number? complex) (or (number.not-a-number? (get@ #real complex)) @@ -158,8 +158,8 @@ (def: #export (tan subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject - r2 (f/* 2.0 real) - i2 (f/* 2.0 imaginary) + r2 (f/* +2.0 real) + i2 (f/* +2.0 imaginary) d (f/+ (math.cos r2) (math.cosh i2))] {#real (f// d (math.sin r2)) #imaginary (f// d (math.sinh i2))})) @@ -167,8 +167,8 @@ (def: #export (tanh subject) (-> Complex Complex) (let [(^slots [#real #imaginary]) subject - r2 (f/* 2.0 real) - i2 (f/* 2.0 imaginary) + r2 (f/* +2.0 real) + i2 (f/* +2.0 imaginary) d (f/+ (math.cosh r2) (math.cos i2))] {#real (f// d (math.sinh r2)) #imaginary (f// d (math.sin i2))})) @@ -178,15 +178,15 @@ (let [(^slots [#real #imaginary]) subject] (complex (if (f/< (frac/abs imaginary) (frac/abs real)) - (if (f/= 0.0 imaginary) + (if (f/= +0.0 imaginary) (frac/abs real) (let [q (f// imaginary real)] - (f/* (math.pow 0.5 (f/+ 1.0 (f/* q q))) + (f/* (math.pow +0.5 (f/+ +1.0 (f/* q q))) (frac/abs imaginary)))) - (if (f/= 0.0 real) + (if (f/= +0.0 real) (frac/abs imaginary) (let [q (f// real imaginary)] - (f/* (math.pow 0.5 (f/+ 1.0 (f/* q q))) + (f/* (math.pow +0.5 (f/+ +1.0 (f/* q q))) (frac/abs real)))) )))) @@ -234,18 +234,18 @@ (def: #export (root2 (^@ input (^slots [#real #imaginary]))) (-> Complex Complex) - (let [t (|> input ..abs (get@ #real) (f/+ (frac/abs real)) (f// 2.0) (math.pow 0.5))] - (if (f/>= 0.0 real) + (let [t (|> input ..abs (get@ #real) (f/+ (frac/abs real)) (f// +2.0) (math.pow +0.5))] + (if (f/>= +0.0 real) {#real t - #imaginary (f// (f/* 2.0 t) + #imaginary (f// (f/* +2.0 t) imaginary)} - {#real (f// (f/* 2.0 t) + {#real (f// (f/* +2.0 t) (frac/abs imaginary)) - #imaginary (f/* t (copy-sign imaginary 1.0))}))) + #imaginary (f/* t (copy-sign imaginary +1.0))}))) (def: #export (root2-1z input) (-> Complex Complex) - (|> (complex 1.0) (- (* input input)) root2)) + (|> (complex +1.0) (- (* input input)) root2)) (def: #export (reciprocal (^slots [#real #imaginary])) (-> Complex Complex) @@ -253,12 +253,12 @@ (frac/abs real)) (let [q (f// imaginary real) scale (f// (|> real (f/* q) (f/+ imaginary)) - 1.0)] + +1.0)] {#real (f/* q scale) #imaginary (frac/negate scale)}) (let [q (f// real imaginary) scale (f// (|> imaginary (f/* q) (f/+ real)) - 1.0)] + +1.0)] {#real scale #imaginary (|> scale frac/negate (f/* q))}))) @@ -283,7 +283,7 @@ (+ i) (/ (- input i)) log - (* (/ (complex 2.0) i)))) + (* (/ (complex +2.0) i)))) (def: #export (argument (^slots [#real #imaginary])) (-> Complex Frac) @@ -294,9 +294,9 @@ (if (n/= |0 nth) (list) (let [r-nth (|> nth .int int-to-frac) - nth-root-of-abs (|> input abs (get@ #real) (math.pow (f// r-nth 1.0))) + nth-root-of-abs (|> input abs (get@ #real) (math.pow (f// r-nth +1.0))) nth-phi (|> input argument (f// r-nth)) - slice (|> math.pi (f/* 2.0) (f// r-nth))] + slice (|> math.pi (f/* +2.0) (f// r-nth))] (|> (list.n/range |0 (dec nth)) (list/map (function (_ nth') (let [inner (|> nth' .int int-to-frac diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux index 3cb65dd14..658d51ae2 100644 --- a/stdlib/source/lux/data/text/regex.lux +++ b/stdlib/source/lux/data/text/regex.lux @@ -183,8 +183,7 @@ (def: number^ (l.Lexer Nat) (|> (l.many l.decimal) - (p.codec number.Codec) - (parser/map .nat))) + (p.codec number.Codec))) (def: re-back-reference^ (l.Lexer Code) @@ -298,7 +297,7 @@ (' #let) (` [(~ g!total) (:: (~! text.Monoid) (~' compose) (~ g!total) (~ access))])) steps)]) ))) - [0 + [+0 (: (List Code) (list)) (: (List (List Code)) (list))] parts)]] diff --git a/stdlib/source/lux/host.js.lux b/stdlib/source/lux/host.js.lux index d074b1ff1..0302064b3 100644 --- a/stdlib/source/lux/host.js.lux +++ b/stdlib/source/lux/host.js.lux @@ -30,7 +30,7 @@ ## [Syntax] (syntax: #export (set! field-name field-value object) {#.doc (doc "A way to set fields from objects." - (set! "foo" 1234 some-object))} + (set! "foo" +1234 some-object))} (wrap (list (` ("js set-field" (~ object) (~ field-name) (~ field-value)))))) (syntax: #export (delete! field-name object) @@ -75,8 +75,8 @@ (syntax: #export (call! {shape (p.or ($_ p.and s.any (s.tuple (p.some s.any)) (p.maybe s.any)) ($_ p.and s.any s.text (s.tuple (p.some s.any)) (p.maybe s.any)))}) {#.doc (doc "A way to call JavaScript functions and methods." - (call! (ref "Math.ceil") [123.45]) - (call! (ref "Math") "ceil" [123.45]))} + (call! (ref "Math.ceil") [+123.45]) + (call! (ref "Math") "ceil" [+123.45]))} (case shape (#.Left [function args ?type]) (wrap (list (` (:coerce (~ (default (' ..Object) ?type)) diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux index 124320ce9..63eedfc9a 100644 --- a/stdlib/source/lux/math.lux +++ b/stdlib/source/lux/math.lux @@ -19,9 +19,9 @@ Frac )] - [e 2.7182818284590452354 "The base of the natural logarithm."] - [pi 3.14159265358979323846 "The ratio of a circle's circumference to its diameter."] - [tau 6.28318530717958647692 "The ratio of a circle's circumference to its radius."] + [e +2.7182818284590452354 "The base of the natural logarithm."] + [pi +3.14159265358979323846 "The ratio of a circle's circumference to its diameter."] + [tau +6.28318530717958647692 "The ratio of a circle's circumference to its radius."] ) (do-template [ ] @@ -48,8 +48,8 @@ (-> Frac Frac) (let [floored (floor input) diff (f/- floored input)] - (cond (f/> 0.5 diff) - (f/+ 1.0 floored) + (cond (f/> +0.5 diff) + (f/+ +1.0 floored) (f/< -0.5 diff) (f/+ -1.0 floored) @@ -63,22 +63,22 @@ (def: #export (atan2 param subject) (-> Frac Frac Frac) - (cond (f/> 0.0 param) + (cond (f/> +0.0 param) (atan (f// param subject)) - (f/< 0.0 param) - (if (f/>= 0.0 subject) + (f/< +0.0 param) + (if (f/>= +0.0 subject) (|> subject (f// param) atan (f/+ pi)) (|> subject (f// param) atan (f/- pi))) - ## (f/= 0.0 param) - (cond (f/> 0.0 subject) - (|> pi (f// 2.0)) + ## (f/= +0.0 param) + (cond (f/> +0.0 subject) + (|> pi (f// +2.0)) - (f/< 0.0 subject) + (f/< +0.0 subject) (|> pi (f// -2.0)) - ## (f/= 0.0 subject) + ## (f/= +0.0 subject) number.not-a-number))) (def: #export (log' base input) @@ -96,8 +96,8 @@ (def: #export (hypotenuse catA catB) (-> Frac Frac Frac) - (pow 0.5 (f/+ (pow 2.0 catA) - (pow 2.0 catB)))) + (pow +0.5 (f/+ (pow +2.0 catA) + (pow +2.0 catB)))) (do-template [ <*> <->] [(def: #export ( a b) @@ -119,7 +119,7 @@ ))] [Nat n/mod n/gcd n/lcm |0 n/* n// n/-] - [Int i/mod i/gcd i/lcm 0 i/* i// i/-] + [Int i/mod i/gcd i/lcm +0 i/* i// i/-] ) ## Hyperbolic functions @@ -127,11 +127,11 @@ (do-template [ ] [(def: #export ( x) (-> Frac Frac) - (|> (exp x) ( (exp (f/* -1.0 x))) (f// 2.0))) + (|> (exp x) ( (exp (f/* -1.0 x))) (f// +2.0))) (def: #export ( x) (-> Frac Frac) - (|> 2.0 (f// (|> (exp x) ( (exp (f/* -1.0 x)))))))] + (|> +2.0 (f// (|> (exp x) ( (exp (f/* -1.0 x)))))))] [sinh f/- csch] [cosh f/+ sech] @@ -154,7 +154,7 @@ (do-template [ ] [(def: #export ( x) (-> Frac Frac) - (|> x (pow 2.0) ( 1.0) (pow 0.5) (f/+ x) log))] + (|> x (pow +2.0) ( +1.0) (pow +0.5) (f/+ x) log))] [asinh f/+] [acosh f/-] @@ -165,17 +165,17 @@ (-> Frac Frac) (let [x+ (|> (f/+ )) x- (|> (f/- ))] - (|> x+ (f// x-) log (f// 2.0))))] + (|> x+ (f// x-) log (f// +2.0))))] - [atanh 1.0 x] - [acoth x 1.0] + [atanh +1.0 x] + [acoth x +1.0] ) (do-template [ ] [(def: #export ( x) (-> Frac Frac) - (let [x^2 (|> x (pow 2.0))] - (|> 1.0 ( x^2) (pow 0.5) (f/+ 1.0) (f// x) log)))] + (let [x^2 (|> x (pow +2.0))] + (|> +1.0 ( x^2) (pow +0.5) (f/+ +1.0) (f// x) log)))] [asech f/-] [acsch f/+] @@ -246,7 +246,7 @@ (syntax: #export (infix {expr infix^}) {#.doc (doc "Infix math syntax." - (infix [x i/* 10]) + (infix [x i/* +10]) (infix [[x i/+ y] i/* [x i/- y]]) (infix [sin [x i/+ y]]) (infix [[x n/< y] and [y n/< z]]) diff --git a/stdlib/source/lux/math/modular.lux b/stdlib/source/lux/math/modular.lux index 092b18944..ef0f36bb2 100644 --- a/stdlib/source/lux/math/modular.lux +++ b/stdlib/source/lux/math/modular.lux @@ -26,7 +26,7 @@ (def: #export (from-int value) (Ex [m] (-> Int (Error (Modulus m)))) - (if (i/= 0 value) + (if (i/= +0 value) (ex.throw zero-cannot-be-a-modulus []) (#e.Success (:abstraction value)))) @@ -52,7 +52,7 @@ (|> sample (i/- reference) (i/% (to-int modulus)) - (i/= 0))) + (i/= +0))) (syntax: #export (modulus {modulus s.int}) (case (from-int modulus) @@ -144,8 +144,8 @@ (def: (i/gcd+ a b) (-> Int Int [Int Int Int]) - (if (i/= 0 a) - [0 1 b] + (if (i/= +0 a) + [+0 +1 b] (let [[ak bk gcd] (i/gcd+ (i/% a b) a)] [(i/- (i/* ak (i// a b)) @@ -158,7 +158,7 @@ (let [[value modulus] (:representation modular) _modulus (to-int modulus) [vk mk gcd] (i/gcd+ value _modulus) - co-prime? (i/= 1 gcd)] + co-prime? (i/= +1 gcd)] (if co-prime? (#.Some (mod modulus vk)) #.None))) diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux index f9ea42c2e..3230ca27e 100644 --- a/stdlib/source/lux/test.lux +++ b/stdlib/source/lux/test.lux @@ -126,23 +126,23 @@ (context: "Simple macros and constructs" ($_ seq (test "Can write easy loops for iterative programming." - (i/= 1000 - (loop [counter 0 - value 1] - (if (i/< 3 counter) - (recur (inc counter) (i/* 10 value)) + (i/= +1000 + (loop [counter +0 + value +1] + (if (i/< +3 counter) + (recur (inc counter) (i/* +10 value)) value)))) (test "Can create lists easily through macros." - (and (case (list 1 2 3) - (#.Cons 1 (#.Cons 2 (#.Cons 3 #.Nil))) + (and (case (list +1 +2 +3) + (#.Cons +1 (#.Cons +2 (#.Cons +3 #.Nil))) #1 _ #0) - (case (list& 1 2 3 (list 4 5 6)) - (#.Cons 1 (#.Cons 2 (#.Cons 3 (#.Cons 4 (#.Cons 5 (#.Cons 6 #.Nil)))))) + (case (list& +1 +2 +3 (list +4 +5 +6)) + (#.Cons +1 (#.Cons +2 (#.Cons +3 (#.Cons +4 (#.Cons +5 (#.Cons +6 #.Nil)))))) #1 _ @@ -217,8 +217,8 @@ (def: (success-message successes failures) (-> Nat Nat Text) (format "Test-suite finished." "\n" - (%i (.int successes)) " out of " (%i (.int (n/+ failures successes))) " tests passed." "\n" - (%i (.int failures)) " tests failed." "\n")) + (%n successes) " out of " (%n (n/+ failures successes)) " tests passed." "\n" + (%n failures) " tests failed." "\n")) (syntax: #export (run) {#.doc (doc "Runs all the tests defined on the current module, and in all imported modules." @@ -249,8 +249,8 @@ (exec (log! ((~! success-message) (~ g!total-successes) (~ g!total-failures))) ((~! promise.future) ((~! io.exit) (if (n/> |0 (~ g!total-failures)) - 1 - 0))))) + +1 + +0))))) []))))))))) (def: #export (seq left right) diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux index d3306f826..688546698 100644 --- a/stdlib/source/lux/time/date.lux +++ b/stdlib/source/lux/time/date.lux @@ -223,7 +223,7 @@ ## Based on this: https://stackoverflow.com/a/42936293/6823464 (def: (pad value) (-> Int Text) - (if (i/< 10 value) + (if (i/< +10 value) (text/compose "0" (int/encode value)) (int/encode value))) @@ -237,11 +237,11 @@ (def: lex-year (l.Lexer Int) (do p.Monad - [sign? (p.maybe (l.this "-")) + [sign (p.or (l.this "-") (l.this "+")) raw-year (p.codec number.Codec (l.many l.decimal)) - #let [signum (case sign? - #.None 1 - (#.Some _) -1)]] + #let [signum (case sign + (#.Left _) -1 + (#.Right _) +1)]] (wrap (i/* signum raw-year)))) (def: lex-section @@ -250,9 +250,9 @@ (def: (leap-years year) (-> Int Int) - (|> (i// 4 year) - (i/- (i// 100 year)) - (i/+ (i// 400 year)))) + (|> (i// +4 year) + (i/- (i// +100 year)) + (i/+ (i// +400 year)))) (def: normal-months (Row Nat) @@ -267,13 +267,13 @@ (def: (divisible? factor input) (-> Int Int Bit) - (|> input (i/% factor) (i/= 0))) + (|> input (i/% factor) (i/= +0))) (def: (leap-year? year) (-> Int Bit) - (and (divisible? 4 year) - (or (not (divisible? 100 year)) - (divisible? 400 year)))) + (and (divisible? +4 year) + (or (not (divisible? +100 year)) + (divisible? +400 year)))) ## Based on: https://stackoverflow.com/a/3309340/6823464 (def: lex-date @@ -283,8 +283,8 @@ _ (l.this "-") utc-month lex-section _ (p.assert "Invalid month." - (and (i/>= 1 utc-month) - (i/<= 12 utc-month))) + (and (i/>= +1 utc-month) + (i/<= +12 utc-month))) #let [months (if (leap-year? utc-year) leap-year-months normal-months) @@ -294,22 +294,22 @@ _ (l.this "-") utc-day lex-section _ (p.assert "Invalid day." - (and (i/>= 1 utc-day) + (and (i/>= +1 utc-day) (i/<= (.int month-days) utc-day)))] (wrap {#year utc-year #month (case utc-month - 1 #January - 2 #February - 3 #March - 4 #April - 5 #May - 6 #June - 7 #July - 8 #August - 9 #September - 10 #October - 11 #November - 12 #December + +1 #January + +2 #February + +3 #March + +4 #April + +5 #May + +6 #June + +7 #July + +8 #August + +9 #September + +10 #October + +11 #November + +12 #December _ (undefined)) #day (.nat utc-day)}))) diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux index 0588d7ba2..1abac1cc0 100644 --- a/stdlib/source/lux/time/duration.lux +++ b/stdlib/source/lux/time/duration.lux @@ -63,21 +63,21 @@ (do-template [ ] [(def: #export ( duration) (-> Duration Bit) - ( 0 (:representation duration)))] + ( +0 (:representation duration)))] [positive? i/>] [negative? i/<] [neutral? i/=]) ) -(def: #export empty Duration (from-millis 0)) -(def: #export milli Duration (from-millis 1)) -(def: #export second Duration (scale 1_000 milli)) -(def: #export minute Duration (scale 60 second)) -(def: #export hour Duration (scale 60 minute)) -(def: #export day Duration (scale 24 hour)) -(def: #export week Duration (scale 7 day)) -(def: #export normal-year Duration (scale 365 day)) +(def: #export empty Duration (from-millis +0)) +(def: #export milli Duration (from-millis +1)) +(def: #export second Duration (scale +1_000 milli)) +(def: #export minute Duration (scale +60 second)) +(def: #export hour Duration (scale +60 minute)) +(def: #export day Duration (scale +24 hour)) +(def: #export week Duration (scale +7 day)) +(def: #export normal-year Duration (scale +365 day)) (def: #export leap-year Duration (merge day normal-year)) (structure: #export _ (Monoid Duration) @@ -87,7 +87,7 @@ (def: (encode duration) (-> Duration Text) (if (:: Equivalence = empty duration) - "0ms" + "+0ms" (let [signed? (negative? duration) [days time-left] [(query day duration) (frame day duration)] days (if signed? @@ -102,38 +102,44 @@ millis (to-millis time-left)] ($_ text/compose (if signed? "-" "") - (if (i/= 0 days) "" (text/compose (int/encode days) "D")) - (if (i/= 0 hours) "" (text/compose (int/encode hours) "h")) - (if (i/= 0 minutes) "" (text/compose (int/encode minutes) "m")) - (if (i/= 0 seconds) "" (text/compose (int/encode seconds) "s")) - (if (i/= 0 millis) "" (text/compose (int/encode millis) "ms")) + (if (i/= +0 days) "" (text/compose (int/encode days) "D")) + (if (i/= +0 hours) "" (text/compose (int/encode hours) "h")) + (if (i/= +0 minutes) "" (text/compose (int/encode minutes) "m")) + (if (i/= +0 seconds) "" (text/compose (int/encode seconds) "s")) + (if (i/= +0 millis) "" (text/compose (int/encode millis) "ms")) )))) (def: (lex-section suffix) (-> Text (l.Lexer Int)) (|> (p.codec number.Codec (l.many l.decimal)) (p.before (p.and (l.this suffix) (p.not l.alpha))) - (p.default 0))) + (p.default +0))) (def: lex-duration (l.Lexer Duration) (do p.Monad - [signed? (l.this? "-") - #let [sign (function (_ raw) (if signed? (i/* -1 raw) raw))] + [signed? (p.or (l.this? "-") (l.this? "+")) + #let [sign (function (_ raw) + (case signed? + (#.Left _) + (i/* -1 raw) + + (#.Right _) + raw))] utc-day (lex-section "D") utc-hour (lex-section "h") utc-minute (lex-section "m") _ (p.assert "Invalid minute." - (and (i/>= 0 utc-minute) - (i/<= 59 utc-minute))) + (and (i/>= +0 utc-minute) + (i/<= +59 utc-minute))) utc-second (lex-section "s") _ (p.assert "Invalid second." - (and (i/>= 0 utc-second) - (i/<= 59 utc-second))) + (and (i/>= +0 utc-second) + (i/<= +59 utc-second))) utc-millis (lex-section "ms") _ (p.assert "Invalid milli-seconds." - (and (i/>= 0 utc-millis) - (i/<= 999 utc-millis)))] + (and (i/>= +0 utc-millis) + (i/<= +999 utc-millis)))] (wrap (|> empty (merge (scale (sign utc-day) day)) (merge (scale (sign utc-hour) hour)) @@ -146,7 +152,7 @@ (l.run input lex-duration)) (structure: #export _ - {#.doc "For example: 15D21h14m51s827ms"} + {#.doc "For example: +15D21h14m51s827ms"} (Codec Text Duration) (def: encode encode) (def: decode decode)) diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux index 427f4883e..2119608e9 100644 --- a/stdlib/source/lux/time/instant.lux +++ b/stdlib/source/lux/time/instant.lux @@ -77,20 +77,20 @@ (def: #export epoch {#.doc "The instant corresponding to 1970-01-01T00:00:00Z"} Instant - (from-millis 0)) + (from-millis +0)) ## Codec::encode (def: (divisible? factor input) (-> Int Int Bit) - (|> input (i/% factor) (i/= 0))) + (|> input (i/% factor) (i/= +0))) (def: (leap-year? year) (-> Int Bit) - (and (divisible? 4 year) - (or (not (divisible? 100 year)) - (divisible? 400 year)))) + (and (divisible? +4 year) + (or (not (divisible? +100 year)) + (divisible? +400 year)))) -(def: epoch-year Int 1970) +(def: epoch-year Int +1970) (def: (find-year now) (-> Instant [Int duration.Duration]) @@ -99,7 +99,7 @@ (let [year (if (leap-year? reference) duration.leap-year duration.normal-year)] - (if (i/= 0 (duration.query year time-left)) + (if (i/= +0 (duration.query year time-left)) [reference time-left] (if (duration/>= duration.empty time-left) (recur (inc reference) (duration.merge (duration.scale -1 year) time-left)) @@ -122,14 +122,14 @@ (if (duration/>= duration.empty time) (row/fold (function (_ month-days [current-month time-left]) (let [month-duration (duration.scale (.int month-days) duration.day)] - (if (i/= 0 (duration.query month-duration time-left)) + (if (i/= +0 (duration.query month-duration time-left)) [current-month time-left] [(inc current-month) (duration.merge (duration.scale -1 month-duration) time-left)]))) [|0 time] months) (row/fold (function (_ month-days [current-month time-left]) (let [month-duration (duration.scale (.int month-days) duration.day)] - (if (i/= 0 (duration.query month-duration time-left)) + (if (i/= +0 (duration.query month-duration time-left)) [current-month time-left] [(dec current-month) (duration.merge month-duration time-left)]))) [|11 time] @@ -137,7 +137,7 @@ (def: (pad value) (-> Int Text) - (if (i/< 10 value) + (if (i/< +10 value) (text/compose "0" (int/encode value)) (int/encode value))) @@ -149,48 +149,48 @@ (def: (encode-millis millis) (-> Int Text) - (cond (i/= 0 millis) "" - (i/< 10 millis) ($_ text/compose ".00" (int/encode millis)) - (i/< 100 millis) ($_ text/compose ".0" (int/encode millis)) - ## (i/< 1_000 millis) + (cond (i/= +0 millis) "" + (i/< +10 millis) ($_ text/compose ".00" (int/encode millis)) + (i/< +100 millis) ($_ text/compose ".0" (int/encode millis)) + ## (i/< +1_000 millis) ($_ text/compose "." (int/encode millis)))) (def: seconds-per-day Int (duration.query duration.second duration.day)) -(def: days-up-to-epoch Int 719468) +(def: days-up-to-epoch Int +719468) (def: (extract-date instant) (-> Instant [[Int Int Int] duration.Duration]) (let [offset (relative instant) seconds (duration.query duration.second offset) z (|> seconds (i// seconds-per-day) (i/+ days-up-to-epoch)) - era (i// 146097 - (if (i/>= 0 z) + era (i// +146097 + (if (i/>= +0 z) z - (i/- 146096 z))) - days-of-era (|> z (i/- (i/* 146097 era))) + (i/- +146096 z))) + days-of-era (|> z (i/- (i/* +146097 era))) years-of-era (|> days-of-era - (i/- (i// 1460 days-of-era)) - (i/+ (i// 36524 days-of-era)) - (i/- (i// 146096 days-of-era)) - (i// 365)) - year (|> years-of-era (i/+ (i/* 400 era))) + (i/- (i// +1460 days-of-era)) + (i/+ (i// +36524 days-of-era)) + (i/- (i// +146096 days-of-era)) + (i// +365)) + year (|> years-of-era (i/+ (i/* +400 era))) days-of-year (|> days-of-era - (i/- (|> (i/* 365 years-of-era) - (i/+ (i// 4 years-of-era)) - (i/- (i// 100 years-of-era))))) + (i/- (|> (i/* +365 years-of-era) + (i/+ (i// +4 years-of-era)) + (i/- (i// +100 years-of-era))))) day-time (duration.frame duration.day offset) days-of-year (if (duration/>= duration.empty day-time) days-of-year (dec days-of-year)) - mp (|> days-of-year (i/* 5) (i/+ 2) (i// 153)) + mp (|> days-of-year (i/* +5) (i/+ +2) (i// +153)) day (|> days-of-year - (i/- (|> mp (i/* 153) (i/+ 2) (i// 5))) - (i/+ 1)) + (i/- (|> mp (i/* +153) (i/+ +2) (i// +5))) + (i/+ +1)) month (|> mp - (i/+ (if (i/< 10 mp) - 3 + (i/+ (if (i/< +10 mp) + +3 -9))) - year (if (i/<= 2 month) + year (if (i/<= +2 month) (inc year) year)] [[year month day] @@ -218,11 +218,11 @@ (def: lex-year (l.Lexer Int) (do p.Monad - [sign? (p.maybe (l.this "-")) + [sign (p.or (l.this "-") (l.this "+")) raw-year (p.codec number.Codec (l.many l.decimal)) - #let [signum (case sign? - #.None 1 - (#.Some _) -1)]] + #let [signum (case sign + (#.Left _) -1 + (#.Right _) +1)]] (wrap (i/* signum raw-year)))) (def: lex-section @@ -234,13 +234,13 @@ (p.either (|> (l.at-most |3 l.decimal) (p.codec number.Codec) (p.after (l.this "."))) - (:: p.Monad wrap 0))) + (:: p.Monad wrap +0))) (def: (leap-years year) (-> Int Int) - (|> (i// 4 year) - (i/- (i// 100 year)) - (i/+ (i// 400 year)))) + (|> (i// +4 year) + (i/- (i// +100 year)) + (i/+ (i// +400 year)))) ## Based on: https://stackoverflow.com/a/3309340/6823464 (def: lex-instant @@ -250,8 +250,8 @@ _ (l.this "-") utc-month lex-section _ (p.assert "Invalid month." - (and (i/>= 1 utc-month) - (i/<= 12 utc-month))) + (and (i/>= +1 utc-month) + (i/<= +12 utc-month))) #let [months (if (leap-year? utc-year) leap-year-months normal-months) @@ -261,29 +261,29 @@ _ (l.this "-") utc-day lex-section _ (p.assert "Invalid day." - (and (i/>= 1 utc-day) + (and (i/>= +1 utc-day) (i/<= (.int month-days) utc-day))) _ (l.this "T") utc-hour lex-section _ (p.assert "Invalid hour." - (and (i/>= 0 utc-hour) - (i/<= 23 utc-hour))) + (and (i/>= +0 utc-hour) + (i/<= +23 utc-hour))) _ (l.this ":") utc-minute lex-section _ (p.assert "Invalid minute." - (and (i/>= 0 utc-minute) - (i/<= 59 utc-minute))) + (and (i/>= +0 utc-minute) + (i/<= +59 utc-minute))) _ (l.this ":") utc-second lex-section _ (p.assert "Invalid second." - (and (i/>= 0 utc-second) - (i/<= 59 utc-second))) + (and (i/>= +0 utc-second) + (i/<= +59 utc-second))) utc-millis lex-millis _ (l.this "Z") #let [years-since-epoch (i/- epoch-year utc-year) previous-leap-days (i/- (leap-years epoch-year) (leap-years (dec utc-year))) - year-days-so-far (|> (i/* 365 years-since-epoch) + year-days-so-far (|> (i/* +365 years-since-epoch) (i/+ previous-leap-days)) month-days-so-far (|> months row.to-list @@ -320,18 +320,18 @@ (let [[[year month day] _] (extract-date instant)] {#date.year year #date.month (case (dec month) - 0 #date.January - 1 #date.February - 2 #date.March - 3 #date.April - 4 #date.May - 5 #date.June - 6 #date.July - 7 #date.August - 8 #date.September - 9 #date.October - 10 #date.November - 11 #date.December + +0 #date.January + +1 #date.February + +2 #date.March + +3 #date.April + +4 #date.May + +5 #date.June + +6 #date.July + +7 #date.August + +8 #date.September + +9 #date.October + +10 #date.November + +11 #date.December _ (undefined)) #date.day (.nat day)})) @@ -350,16 +350,16 @@ (dec days) days) ## 1970/01/01 was a Thursday - y1970m0d0 4] + y1970m0d0 +4] (case (|> y1970m0d0 - (i/+ days) (i/% 7) + (i/+ days) (i/% +7) ## This is done to turn negative days into positive days. - (i/+ 7) (i/% 7)) - 0 #date.Sunday - 1 #date.Monday - 2 #date.Tuesday - 3 #date.Wednesday - 4 #date.Thursday - 5 #date.Friday - 6 #date.Saturday + (i/+ +7) (i/% +7)) + +0 #date.Sunday + +1 #date.Monday + +2 #date.Tuesday + +3 #date.Wednesday + +4 #date.Thursday + +5 #date.Friday + +6 #date.Saturday _ (undefined)))) diff --git a/stdlib/source/lux/type/unit.lux b/stdlib/source/lux/type/unit.lux index df714a996..96584a989 100644 --- a/stdlib/source/lux/type/unit.lux +++ b/stdlib/source/lux/type/unit.lux @@ -85,10 +85,10 @@ (s.tuple (do p.Monad [numerator s.int _ (p.assert (format "Numerator must be positive: " (%i numerator)) - (i/> 0 numerator)) + (i/> +0 numerator)) denominator s.int _ (p.assert (format "Denominator must be positive: " (%i denominator)) - (i/> 0 denominator))] + (i/> +0 denominator))] (wrap [(.nat numerator) (.nat denominator)])))) (syntax: #export (scale: @@ -150,13 +150,13 @@ (i// (.int denominator)) in))) -(scale: #export Kilo [1 1_000]) -(scale: #export Mega [1 1_000_000]) -(scale: #export Giga [1 1_000_000_000]) +(scale: #export Kilo [+1 +1_000]) +(scale: #export Mega [+1 +1_000_000]) +(scale: #export Giga [+1 +1_000_000_000]) -(scale: #export Milli [ 1_000 1]) -(scale: #export Micro [ 1_000_000 1]) -(scale: #export Nano [1_000_000_000 1]) +(scale: #export Milli [ +1_000 +1]) +(scale: #export Micro [ +1_000_000 +1]) +(scale: #export Nano [+1_000_000_000 +1]) (unit: #export Gram) (unit: #export Meter) diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux index df0bb8278..f52b7764e 100644 --- a/stdlib/test/test/lux.lux +++ b/stdlib/test/test/lux.lux @@ -126,8 +126,8 @@ ))))] ["Nat" r.nat n/= n/+ n/- n/* n// n/% n/> |0 |1 |1_000_000 (n/% |1_000) id] - ["Int" r.int i/= i/+ i/- i/* i// i/% i/> 0 1 1_000_000 (i/% 1_000) id] - ["Frac" r.frac f/= f/+ f/- f/* f// f/% f/> 0.0 1.0 1_000_000.0 id math.floor] + ["Int" r.int i/= i/+ i/- i/* i// i/% i/> +0 +1 +1_000_000 (i/% +1_000) id] + ["Frac" r.frac f/= f/+ f/- f/* f// f/% f/> +0.0 +1.0 +1_000_000.0 id math.floor] ["Rev" r.rev r/= r/+ r/- r/* r// r/% r/> .0 (.rev -1) (.rev -1) id id] ) @@ -145,9 +145,9 @@ (test "" (|> value -> <- (= value))))))] - ["Int->Nat" r.int .nat .int i/= (i/% 1_000_000)] + ["Int->Nat" r.int .nat .int i/= (i/% +1_000_000)] ["Nat->Int" r.nat .int .nat n/= (n/% |1_000_000)] - ["Int->Frac" r.int int-to-frac frac-to-int i/= (i/% 1_000_000)] + ["Int->Frac" r.int int-to-frac frac-to-int i/= (i/% +1_000_000)] ["Frac->Int" r.frac frac-to-int int-to-frac f/= math.floor] ["Rev->Frac" frac-rev rev-to-frac frac-to-rev r/= id] ) @@ -155,23 +155,23 @@ (context: "Simple macros and constructs" ($_ seq (test "Can write easy loops for iterative programming." - (i/= 1000 - (loop [counter 0 - value 1] - (if (i/< 3 counter) - (recur (inc counter) (i/* 10 value)) + (i/= +1000 + (loop [counter +0 + value +1] + (if (i/< +3 counter) + (recur (inc counter) (i/* +10 value)) value)))) (test "Can create lists easily through macros." - (and (case (list 1 2 3) - (#.Cons 1 (#.Cons 2 (#.Cons 3 #.Nil))) + (and (case (list +1 +2 +3) + (#.Cons +1 (#.Cons +2 (#.Cons +3 #.Nil))) #1 _ #0) - (case (list& 1 2 3 (list 4 5 6)) - (#.Cons 1 (#.Cons 2 (#.Cons 3 (#.Cons 4 (#.Cons 5 (#.Cons 6 #.Nil)))))) + (case (list& +1 +2 +3 (list +4 +5 +6)) + (#.Cons +1 (#.Cons +2 (#.Cons +3 (#.Cons +4 (#.Cons +5 (#.Cons +6 #.Nil)))))) #1 _ diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux index 76cc98717..5bd7c09d8 100644 --- a/stdlib/test/test/lux/compiler/default/syntax.lux +++ b/stdlib/test/test/lux/compiler/default/syntax.lux @@ -119,7 +119,7 @@ [numerator (|> r.nat (:: @ map (|>> (n/% |100) .int int-to-frac))) denominator (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1) .int int-to-frac))) signed? r.bit - #let [expected (|> numerator (f// denominator) (f/* (if signed? -1.0 1.0)))]] + #let [expected (|> numerator (f// denominator) (f/* (if signed? -1.0 +1.0)))]] (test "Can parse frac ratio syntax." (case (&.read "" (dict.new text.Hash) [default-cursor |0 diff --git a/stdlib/test/test/lux/concurrency/frp.lux b/stdlib/test/test/lux/concurrency/frp.lux index 668882485..7ba1a80e9 100644 --- a/stdlib/test/test/lux/concurrency/frp.lux +++ b/stdlib/test/test/lux/concurrency/frp.lux @@ -35,7 +35,7 @@ (let [(^open "list/.") (list.Equivalence number.Equivalence)] ($_ seq (wrap (do promise.Monad - [#let [values (list 0 1 2 3 4 5)] + [#let [values (list +0 +1 +2 +3 +4 +5)] output (promise.future (do io.Monad [#let [input (: (Channel Int) (frp.channel []))] @@ -54,12 +54,12 @@ [#let [input (: (Channel Int) (frp.channel [])) elems (frp.filter i/even? input)] output (read! elems) - _ (write! (list 0 1 2 3 4 5) input)] + _ (write! (list +0 +1 +2 +3 +4 +5) input)] (wrap output))) _ (promise.wait |100) output (promise.future (atom.read output))] (assert "Can filter a channel's elements." - (list/= (list 0 2 4) + (list/= (list +0 +2 +4) (list.reverse output))))) (wrap (do promise.Monad @@ -69,13 +69,13 @@ right (: (Channel Int) (frp.channel []))] merged (frp.merge (list left right)) output (read! merged) - _ (write! (list 0 1 2 3 4 5) left) - _ (write! (list 0 -1 -2 -3 -4 -5) right)] + _ (write! (list +0 +1 +2 +3 +4 +5) left) + _ (write! (list +0 -1 -2 -3 -4 -5) right)] (wrap output))) _ (promise.wait |100) output (promise.future (atom.read output))] (assert "Can merge channels." - (list/= (list 0 1 2 3 4 5 0 -1 -2 -3 -4 -5) + (list/= (list +0 +1 +2 +3 +4 +5 +0 -1 -2 -3 -4 -5) (list.reverse output))))) (wrap (do promise.Monad @@ -84,12 +84,12 @@ [#let [inputs (: (Channel Int) (frp.channel [])) mapped (:: frp.Functor map inc inputs)] output (read! mapped) - _ (write! (list 0 1 2 3 4 5) inputs)] + _ (write! (list +0 +1 +2 +3 +4 +5) inputs)] (wrap output))) _ (promise.wait |100) output (promise.future (atom.read output))] (assert "Functor goes over every element in a channel." - (list/= (list 1 2 3 4 5 6) + (list/= (list +1 +2 +3 +4 +5 +6) (list.reverse output))))) (wrap (do promise.Monad @@ -100,23 +100,23 @@ output (read! (let [(^open ".") frp.Apply] (apply >f< >a<))) _ (write! (list inc) >f<) - _ (write! (list 12345) >a<)] + _ (write! (list +12345) >a<)] (wrap output))) _ (promise.wait |100) output (promise.future (atom.read output))] (assert "Apply works over all channel values." - (list/= (list 12346) + (list/= (list +12346) (list.reverse output))))) (wrap (do promise.Monad [output (promise.future (read! (do frp.Monad [f (frp.from-promise (promise.delay |100 inc)) - a (frp.from-promise (promise.delay |200 12345))] + a (frp.from-promise (promise.delay |200 +12345))] (frp.from-promise (promise.delay |300 (f a)))))) _ (promise.wait |700) output (promise.future (atom.read output))] (assert "Valid monad." - (list/= (list 12346) + (list/= (list +12346) (list.reverse output))))) ))) diff --git a/stdlib/test/test/lux/control/parser.lux b/stdlib/test/test/lux/control/parser.lux index c4f42a7b7..19ed2000d 100644 --- a/stdlib/test/test/lux/control/parser.lux +++ b/stdlib/test/test/lux/control/parser.lux @@ -59,9 +59,9 @@ (context: "Assertions" (test "Can make assertions while parsing." (and (match [] - (&.run (list (code.bit #1) (code.int 123)) + (&.run (list (code.bit #1) (code.int +123)) (&.assert "yolo" #1))) - (fails? (&.run (list (code.bit #1) (code.int 123)) + (fails? (&.run (list (code.bit #1) (code.int +123)) (&.assert "yolo" #0)))))) (context: "Combinators [Part 1]" @@ -96,22 +96,22 @@ (let [positive (: (s.Syntax Int) (do &.Monad [value s.int - _ (&.assert "" (i/> 0 value))] + _ (&.assert "" (i/> +0 value))] (wrap value)))] - (and (match 123 - (&.run (list (code.int 123) (code.int 456) (code.int 789)) + (and (match +123 + (&.run (list (code.int +123) (code.int +456) (code.int +789)) (&.either positive s.int))) (match -123 - (&.run (list (code.int -123) (code.int 456) (code.int 789)) + (&.run (list (code.int -123) (code.int +456) (code.int +789)) (&.either positive s.int))) - (fails? (&.run (list (code.bit #1) (code.int 456) (code.int 789)) + (fails? (&.run (list (code.bit #1) (code.int +456) (code.int +789)) (&.either positive s.int)))))) (test "Can create the opposite/negation of any parser." - (and (fails? (&.run (list (code.int 123) (code.int 456) (code.int 789)) + (and (fails? (&.run (list (code.int +123) (code.int +456) (code.int +789)) (&.not s.int))) (match [] - (&.run (list (code.bit #1) (code.int 456) (code.int 789)) + (&.run (list (code.bit #1) (code.int +456) (code.int +789)) (&.not s.int))))) )) @@ -122,53 +122,53 @@ (&.fail "Well, it really SHOULD fail...")))) (test "Can apply a parser N times." - (and (match (list 123 456 789) - (&.run (list (code.int 123) (code.int 456) (code.int 789)) + (and (match (list +123 +456 +789) + (&.run (list (code.int +123) (code.int +456) (code.int +789)) (&.exactly |3 s.int))) - (match (list 123 456) - (&.run (list (code.int 123) (code.int 456) (code.int 789)) + (match (list +123 +456) + (&.run (list (code.int +123) (code.int +456) (code.int +789)) (&.exactly |2 s.int))) - (fails? (&.run (list (code.int 123) (code.int 456) (code.int 789)) + (fails? (&.run (list (code.int +123) (code.int +456) (code.int +789)) (&.exactly |4 s.int))))) (test "Can apply a parser at-least N times." - (and (match (list 123 456 789) - (&.run (list (code.int 123) (code.int 456) (code.int 789)) + (and (match (list +123 +456 +789) + (&.run (list (code.int +123) (code.int +456) (code.int +789)) (&.at-least |3 s.int))) - (match (list 123 456 789) - (&.run (list (code.int 123) (code.int 456) (code.int 789)) + (match (list +123 +456 +789) + (&.run (list (code.int +123) (code.int +456) (code.int +789)) (&.at-least |2 s.int))) - (fails? (&.run (list (code.int 123) (code.int 456) (code.int 789)) + (fails? (&.run (list (code.int +123) (code.int +456) (code.int +789)) (&.at-least |4 s.int))))) (test "Can apply a parser at-most N times." - (and (match (list 123 456 789) - (&.run (list (code.int 123) (code.int 456) (code.int 789)) + (and (match (list +123 +456 +789) + (&.run (list (code.int +123) (code.int +456) (code.int +789)) (&.at-most |3 s.int))) - (match (list 123 456) - (&.run (list (code.int 123) (code.int 456) (code.int 789)) + (match (list +123 +456) + (&.run (list (code.int +123) (code.int +456) (code.int +789)) (&.at-most |2 s.int))) - (match (list 123 456 789) - (&.run (list (code.int 123) (code.int 456) (code.int 789)) + (match (list +123 +456 +789) + (&.run (list (code.int +123) (code.int +456) (code.int +789)) (&.at-most |4 s.int))))) (test "Can apply a parser between N and M times." - (and (match (list 123 456 789) - (&.run (list (code.int 123) (code.int 456) (code.int 789)) + (and (match (list +123 +456 +789) + (&.run (list (code.int +123) (code.int +456) (code.int +789)) (&.between |3 |10 s.int))) - (fails? (&.run (list (code.int 123) (code.int 456) (code.int 789)) + (fails? (&.run (list (code.int +123) (code.int +456) (code.int +789)) (&.between |4 |10 s.int))))) (test "Can parse while taking separators into account." - (and (match (list 123 456 789) - (&.run (list (code.int 123) (code.text "YOLO") (code.int 456) (code.text "YOLO") (code.int 789)) + (and (match (list +123 +456 +789) + (&.run (list (code.int +123) (code.text "YOLO") (code.int +456) (code.text "YOLO") (code.int +789)) (&.sep-by (s.this (' "YOLO")) s.int))) - (match (list 123 456) - (&.run (list (code.int 123) (code.text "YOLO") (code.int 456) (code.int 789)) + (match (list +123 +456) + (&.run (list (code.int +123) (code.text "YOLO") (code.int +456) (code.int +789)) (&.sep-by (s.this (' "YOLO")) s.int))))) (test "Can obtain the whole of the remaining input." (|> &.remaining - (&.run (list (code.int 123) (code.int 456) (code.int 789))) - (match (list [_ (#.Int 123)] [_ (#.Int 456)] [_ (#.Int 789)])))) + (&.run (list (code.int +123) (code.int +456) (code.int +789))) + (match (list [_ (#.Int +123)] [_ (#.Int +456)] [_ (#.Int +789)])))) )) diff --git a/stdlib/test/test/lux/control/pipe.lux b/stdlib/test/test/lux/control/pipe.lux index 2cc09fbf8..e5ceaeb19 100644 --- a/stdlib/test/test/lux/control/pipe.lux +++ b/stdlib/test/test/lux/control/pipe.lux @@ -14,59 +14,59 @@ (context: "Pipes" ($_ seq (test "Can dismiss previous pipeline results and begin a new line." - (|> 20 - (i/* 3) - (i/+ 4) - (new> 0 inc) - (i/= 1))) + (|> +20 + (i/* +3) + (i/+ +4) + (new> +0 inc) + (i/= +1))) (test "Can give names to piped values within a pipeline's scope." - (|> 5 + (|> +5 (let> X [(i/+ X X)]) - (i/= 10))) + (i/= +10))) (test "Can do branching in pipelines." - (and (|> 5 - (cond> [i/even?] [(i/* 2)] - [i/odd?] [(i/* 3)] + (and (|> +5 + (cond> [i/even?] [(i/* +2)] + [i/odd?] [(i/* +3)] [(new> -1)]) - (i/= 15)) - (|> 4 - (cond> [i/even?] [(i/* 2)] - [i/odd?] [(i/* 3)] + (i/= +15)) + (|> +4 + (cond> [i/even?] [(i/* +2)] + [i/odd?] [(i/* +3)] []) - (i/= 8)) - (|> 5 - (cond> [i/even?] [(i/* 2)] + (i/= +8)) + (|> +5 + (cond> [i/even?] [(i/* +2)] [(new> -1)]) (i/= -1)))) (test "Can loop within pipelines." - (|> 1 - (loop> [(i/< 10)] + (|> +1 + (loop> [(i/< +10)] [inc]) - (i/= 10))) + (i/= +10))) (test "Can use monads within pipelines." - (|> 5 + (|> +5 (do> Monad - [(i/* 3)] - [(i/+ 4)] + [(i/* +3)] + [(i/+ +4)] [inc]) - (i/= 20))) + (i/= +20))) (test "Can pattern-match against piped values." - (|> 5 - (case> 0 "zero" - 1 "one" - 2 "two" - 3 "three" - 4 "four" - 5 "five" - 6 "six" - 7 "seven" - 8 "eight" - 9 "nine" + (|> +5 + (case> +0 "zero" + +1 "one" + +2 "two" + +3 "three" + +4 "four" + +5 "five" + +6 "six" + +7 "seven" + +8 "eight" + +9 "nine" _ "???") (text/= "five"))) )) diff --git a/stdlib/test/test/lux/control/reader.lux b/stdlib/test/test/lux/control/reader.lux index 135cce4ee..57f487426 100644 --- a/stdlib/test/test/lux/control/reader.lux +++ b/stdlib/test/test/lux/control/reader.lux @@ -11,27 +11,27 @@ (let [(^open "&/.") &.Apply (^open "&/.") &.Monad] ($_ seq - (test "" (i/= 123 (&.run 123 &.ask))) - (test "" (i/= 246 (&.run 123 (&.local (i/* 2) &.ask)))) - (test "" (i/= 134 (&.run 123 (&/map inc (i/+ 10))))) - (test "" (i/= 10 (&.run 123 (&/wrap 10)))) - (test "" (i/= 30 (&.run 123 (&/apply (&/wrap (i/+ 10)) (&/wrap 20))))) - (test "" (i/= 30 (&.run 123 (do &.Monad - [f (wrap i/+) - x (wrap 10) - y (wrap 20)] - (wrap (f x y))))))))) + (test "" (i/= +123 (&.run +123 &.ask))) + (test "" (i/= +246 (&.run +123 (&.local (i/* +2) &.ask)))) + (test "" (i/= +134 (&.run +123 (&/map inc (i/+ +10))))) + (test "" (i/= +10 (&.run +123 (&/wrap +10)))) + (test "" (i/= +30 (&.run +123 (&/apply (&/wrap (i/+ +10)) (&/wrap +20))))) + (test "" (i/= +30 (&.run +123 (do &.Monad + [f (wrap i/+) + x (wrap +10) + y (wrap +20)] + (wrap (f x y))))))))) (context: "Monad transformer" (let [(^open "io/.") io.Monad] (test "Can add reader functionality to any monad." (|> (: (&.Reader Text (io.IO Int)) (do (&.ReaderT io.Monad) - [a (&.lift (io/wrap 123)) - b (wrap 456)] + [a (&.lift (io/wrap +123)) + b (wrap +456)] (wrap (i/+ a b)))) (&.run "") io.run - (case> 579 #1 - _ #0))) + (case> +579 #1 + _ #0))) )) diff --git a/stdlib/test/test/lux/control/writer.lux b/stdlib/test/test/lux/control/writer.lux index 6b31046ea..de8bdc599 100644 --- a/stdlib/test/test/lux/control/writer.lux +++ b/stdlib/test/test/lux/control/writer.lux @@ -15,18 +15,18 @@ (^open "&/.") (&.Apply text.Monoid)] ($_ seq (test "Functor respects Writer." - (i/= 11 (product.right (&/map inc ["" 10])))) + (i/= +11 (product.right (&/map inc ["" +10])))) (test "Apply respects Writer." - (and (i/= 20 (product.right (&/wrap 20))) - (i/= 30 (product.right (&/apply (&/wrap (i/+ 10)) (&/wrap 20)))))) + (and (i/= +20 (product.right (&/wrap +20))) + (i/= +30 (product.right (&/apply (&/wrap (i/+ +10)) (&/wrap +20)))))) (test "Monad respects Writer." - (i/= 30 (product.right (do (&.Monad text.Monoid) - [f (wrap i/+) - a (wrap 10) - b (wrap 20)] - (wrap (f a b)))))) + (i/= +30 (product.right (do (&.Monad text.Monoid) + [f (wrap i/+) + a (wrap +10) + b (wrap +20)] + (wrap (f a b)))))) (test "Can log any value." (text/= "YOLO" (product.left (&.log "YOLO")))) @@ -37,9 +37,9 @@ (^open "io/.") io.Monad] (test "Can add writer functionality to any monad." (|> (io.run (do (&.WriterT text.Monoid io.Monad) - [a (lift (io/wrap 123)) - b (wrap 456)] + [a (lift (io/wrap +123)) + b (wrap +456)] (wrap (i/+ a b)))) - (case> ["" 579] #1 - _ #0))) + (case> ["" +579] #1 + _ #0))) )) diff --git a/stdlib/test/test/lux/data/collection/list.lux b/stdlib/test/test/lux/data/collection/list.lux index 9a8b4a4cd..dbe92f70a 100644 --- a/stdlib/test/test/lux/data/collection/list.lux +++ b/stdlib/test/test/lux/data/collection/list.lux @@ -232,8 +232,8 @@ (^open "io/.") io.Monad] (test "Can add list functionality to any monad." (|> (io.run (do (&.ListT io.Monad) - [a (lift (io/wrap 123)) - b (wrap 456)] + [a (lift (io/wrap +123)) + b (wrap +456)] (wrap (i/+ a b)))) - (case> (^ (list 579)) #1 - _ #0))))) + (case> (^ (list +579)) #1 + _ #0))))) diff --git a/stdlib/test/test/lux/data/color.lux b/stdlib/test/test/lux/data/color.lux index d8e93aa5e..7d584ab4b 100644 --- a/stdlib/test/test/lux/data/color.lux +++ b/stdlib/test/test/lux/data/color.lux @@ -18,18 +18,18 @@ (-> Nat Frac) (|>> .int int-to-frac)) -(def: square (-> Frac Frac) (math.pow 2.0)) +(def: square (-> Frac Frac) (math.pow +2.0)) (def: (distance from to) (-> @.Color @.Color Frac) (let [[fr fg fb] (@.unpack from) [tr tg tb] (@.unpack to)] - (math.pow 0.5 ($_ f/+ - (|> (scale tr) (f/- (scale fr)) square) - (|> (scale tg) (f/- (scale fg)) square) - (|> (scale tb) (f/- (scale fb)) square))))) + (math.pow +0.5 ($_ f/+ + (|> (scale tr) (f/- (scale fr)) square) + (|> (scale tg) (f/- (scale fg)) square) + (|> (scale tb) (f/- (scale fb)) square))))) -(def: error-margin Frac 1.8) +(def: error-margin Frac +1.8) (def: black @.Color (@.color [|0 |0 |0])) (def: white @.Color (@.color [|255 |255 |255])) @@ -49,14 +49,14 @@ (do @ [any color colorful (|> color - (r.filter (function (_ color) (|> (distance color black) (f/>= 100.0)))) - (r.filter (function (_ color) (|> (distance color white) (f/>= 100.0))))) + (r.filter (function (_ color) (|> (distance color black) (f/>= +100.0)))) + (r.filter (function (_ color) (|> (distance color white) (f/>= +100.0))))) mediocre (|> color (r.filter (|>> saturation ((function (_ saturation) - (and (f/>= 0.25 saturation) - (f/<= 0.75 saturation))))))) - ratio (|> r.frac (r.filter (f/>= 0.5)))] + (and (f/>= +0.25 saturation) + (f/<= +0.75 saturation))))))) + ratio (|> r.frac (r.filter (f/>= +0.5)))] ($_ seq (test "Has equivalence." (:: @.Equivalence = any any)) @@ -90,7 +90,7 @@ (saturation (@.de-saturate ratio mediocre)))) (test "Can gray-scale color." (let [gray'ed (@.gray-scale mediocre)] - (and (f/= 0.0 + (and (f/= +0.0 (saturation gray'ed)) (|> (luminance gray'ed) (f/- (luminance mediocre)) diff --git a/stdlib/test/test/lux/data/error.lux b/stdlib/test/test/lux/data/error.lux index bea6146aa..30a12855d 100644 --- a/stdlib/test/test/lux/data/error.lux +++ b/stdlib/test/test/lux/data/error.lux @@ -13,9 +13,9 @@ (^open "&/.") &.Monad] ($_ seq (test "Functor correctly handles both cases." - (and (|> (: (&.Error Int) (#&.Success 10)) + (and (|> (: (&.Error Int) (#&.Success +10)) (&/map inc) - (case> (#&.Success 11) #1 _ #0)) + (case> (#&.Success +11) #1 _ #0)) (|> (: (&.Error Int) (#&.Error "YOLO")) (&/map inc) @@ -23,24 +23,24 @@ )) (test "Apply correctly handles both cases." - (and (|> (&/wrap 20) - (case> (#&.Success 20) #1 _ #0)) - (|> (&/apply (&/wrap inc) (&/wrap 10)) - (case> (#&.Success 11) #1 _ #0)) + (and (|> (&/wrap +20) + (case> (#&.Success +20) #1 _ #0)) + (|> (&/apply (&/wrap inc) (&/wrap +10)) + (case> (#&.Success +11) #1 _ #0)) (|> (&/apply (&/wrap inc) (#&.Error "YOLO")) (case> (#&.Error "YOLO") #1 _ #0)))) (test "Monad correctly handles both cases." (and (|> (do &.Monad [f (wrap i/+) - a (wrap 10) - b (wrap 20)] + a (wrap +10) + b (wrap +20)] (wrap (f a b))) - (case> (#&.Success 30) #1 _ #0)) + (case> (#&.Success +30) #1 _ #0)) (|> (do &.Monad [f (wrap i/+) a (#&.Error "YOLO") - b (wrap 20)] + b (wrap +20)] (wrap (f a b))) (case> (#&.Error "YOLO") #1 _ #0)) )) @@ -51,8 +51,8 @@ (^open "io/.") io.Monad] (test "Can add error functionality to any monad." (|> (io.run (do (&.ErrorT io.Monad) - [a (lift (io/wrap 123)) - b (wrap 456)] + [a (lift (io/wrap +123)) + b (wrap +456)] (wrap (i/+ a b)))) - (case> (#&.Success 579) #1 - _ #0))))) + (case> (#&.Success +579) #1 + _ #0))))) diff --git a/stdlib/test/test/lux/data/format/json.lux b/stdlib/test/test/lux/data/format/json.lux index 5333cfb0e..a898a2c97 100644 --- a/stdlib/test/test/lux/data/format/json.lux +++ b/stdlib/test/test/lux/data/format/json.lux @@ -48,7 +48,7 @@ ($_ r.or (:: @ wrap []) r.bit - (|> r.frac (:: @ map (f/* 1_000_000.0))) + (|> r.frac (:: @ map (f/* +1_000_000.0))) (r.unicode size) (r.row size gen-json) (r.dictionary text.Hash size (r.unicode size) gen-json) diff --git a/stdlib/test/test/lux/data/maybe.lux b/stdlib/test/test/lux/data/maybe.lux index 95ee39d91..4f135b68a 100644 --- a/stdlib/test/test/lux/data/maybe.lux +++ b/stdlib/test/test/lux/data/maybe.lux @@ -49,8 +49,8 @@ (let [lift (&.lift io.Monad)] (test "Can add maybe functionality to any monad." (|> (io.run (do (&.MaybeT io.Monad) - [a (lift (io/wrap 123)) - b (wrap 456)] + [a (lift (io/wrap +123)) + b (wrap +456)] (wrap (i/+ a b)))) - (case> (#.Some 579) #1 - _ #0))))) + (case> (#.Some +579) #1 + _ #0))))) diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux index 8e9a867da..c8e436d1d 100644 --- a/stdlib/test/test/lux/data/number.lux +++ b/stdlib/test/test/lux/data/number.lux @@ -87,7 +87,7 @@ ["Int" r.int Number Order Interval (function (_ _) #1)] ## Both min and max values will be positive (thus, greater than zero) ["Rev" r.rev Number Order Interval (function (_ _) #1)] - ["Frac" r.frac Number Order Interval (f/> 0.0)] + ["Frac" r.frac Number Order Interval (f/> +0.0)] ) (do-template [category rand-gen ] @@ -107,18 +107,18 @@ ["Nat/Mul" r.nat Number Order Mul@Monoid (n/% |1000) (function (_ _) #1)] ["Nat/Min" r.nat Number Order Min@Monoid (n/% |1000) (function (_ _) #1)] ["Nat/Max" r.nat Number Order Max@Monoid (n/% |1000) (function (_ _) #1)] - ["Int/Add" r.int Number Order Add@Monoid (i/% 1000) (function (_ _) #1)] - ["Int/Mul" r.int Number Order Mul@Monoid (i/% 1000) (function (_ _) #1)] - ["Int/Min" r.int Number Order Min@Monoid (i/% 1000) (function (_ _) #1)] - ["Int/Max" r.int Number Order Max@Monoid (i/% 1000) (function (_ _) #1)] + ["Int/Add" r.int Number Order Add@Monoid (i/% +1000) (function (_ _) #1)] + ["Int/Mul" r.int Number Order Mul@Monoid (i/% +1000) (function (_ _) #1)] + ["Int/Min" r.int Number Order Min@Monoid (i/% +1000) (function (_ _) #1)] + ["Int/Max" r.int Number Order Max@Monoid (i/% +1000) (function (_ _) #1)] ["Rev/Add" r.rev Number Order Add@Monoid (r/% .125) (function (_ _) #1)] ["Rev/Mul" r.rev Number Order Mul@Monoid (r/% .125) (function (_ _) #1)] ["Rev/Min" r.rev Number Order Min@Monoid (r/% .125) (function (_ _) #1)] ["Rev/Max" r.rev Number Order Max@Monoid (r/% .125) (function (_ _) #1)] - ["Frac/Add" r.frac Number Order Add@Monoid (f/% 1000.0) (f/> 0.0)] - ["Frac/Mul" r.frac Number Order Mul@Monoid (f/% 1000.0) (f/> 0.0)] - ["Frac/Min" r.frac Number Order Min@Monoid (f/% 1000.0) (f/> 0.0)] - ["Frac/Max" r.frac Number Order Max@Monoid (f/% 1000.0) (f/> 0.0)] + ["Frac/Add" r.frac Number Order Add@Monoid (f/% +1000.0) (f/> +0.0)] + ["Frac/Mul" r.frac Number Order Mul@Monoid (f/% +1000.0) (f/> +0.0)] + ["Frac/Min" r.frac Number Order Min@Monoid (f/% +1000.0) (f/> +0.0)] + ["Frac/Max" r.frac Number Order Max@Monoid (f/% +1000.0) (f/> +0.0)] ) (do-template [ ] @@ -170,14 +170,14 @@ ($_ seq (test "Binary." (and (n/= (bin "|11001001") (bin "|11_00_10_01")) - (i/= (bin "11001001") (bin "11_00_10_01")) + (i/= (bin "+11001001") (bin "+11_00_10_01")) (r/= (bin ".11001001") (bin ".11_00_10_01")) - (f/= (bin "1100.1001") (bin "11_00.10_01")))) + (f/= (bin "+1100.1001") (bin "+11_00.10_01")))) (test "Octal." (and (n/= (oct "|615243") (oct "|615_243")) - (i/= (oct "615243") (oct "615_243")) + (i/= (oct "+615243") (oct "+615_243")) (r/= (oct ".615243") (oct ".615_243")) - (f/= (oct "6152.43") (oct "615_2.43")))) + (f/= (oct "+6152.43") (oct "+615_2.43")))) (test "Hexadecimal." (and (n/= (hex "|deadBEEF") (hex "|dead_BEEF")) (i/= (hex "deadBEEF") (hex "dead_BEEF")) diff --git a/stdlib/test/test/lux/data/number/complex.lux b/stdlib/test/test/lux/data/number/complex.lux index 0d66cf1af..994e1cafb 100644 --- a/stdlib/test/test/lux/data/number/complex.lux +++ b/stdlib/test/test/lux/data/number/complex.lux @@ -12,7 +12,7 @@ ["r" random]]] lux/test) -(def: margin-of-error Frac 1.0e-9) +(def: margin-of-error Frac +1.0e-9) (def: (within? margin standard value) (-> Frac &.Complex &.Complex Bit) @@ -27,7 +27,7 @@ (r.Random Frac) (do r.Monad [factor (|> r.nat (:: @ map (|>> (n/% |1000) (n/max |1)))) - measure (|> r.frac (r.filter (f/> 0.0)))] + measure (|> r.frac (r.filter (f/> +0.0)))] (wrap (f/* (|> factor .int int-to-frac) measure)))) @@ -116,7 +116,7 @@ floored (|> quotient (update@ #&.real math.floor) (update@ #&.imaginary math.floor))] - (within? 0.000000000001 + (within? +0.000000000001 x (|> quotient (&.* y) (&.+ rem))))) )))) @@ -141,9 +141,9 @@ (test "Absolute value of signum is always root2(2), 1 or 0." (let [signum-abs (|> x &.signum &.abs (get@ #&.real))] - (or (f/= 0.0 signum-abs) - (f/= 1.0 signum-abs) - (f/= (math.pow 0.5 2.0) signum-abs)))) + (or (f/= +0.0 signum-abs) + (f/= +1.0 signum-abs) + (f/= (math.pow +0.5 +2.0) signum-abs)))) (test "Negation is its own inverse." (let [there (&.negate x) @@ -165,8 +165,8 @@ (<| (seed |17274883666004960943) ## (times |100) (do @ - [angle (|> gen-complex (:: @ map (|>> (update@ #&.real (f/% 1.0)) - (update@ #&.imaginary (f/% 1.0)))))] + [angle (|> gen-complex (:: @ map (|>> (update@ #&.real (f/% +1.0)) + (update@ #&.imaginary (f/% +1.0)))))] ($_ seq (test "Arc-sine is the inverse of sine." (trigonometric-symmetry &.sin &.asin angle)) @@ -183,7 +183,7 @@ [x gen-complex] ($_ seq (test "Root 2 is inverse of power 2." - (|> x (&.pow' 2.0) (&.pow' 0.5) (within? margin-of-error x))) + (|> x (&.pow' +2.0) (&.pow' +0.5) (within? margin-of-error x))) (test "Logarithm is inverse of exponentiation." (|> x &.log &.exp (within? margin-of-error x))) diff --git a/stdlib/test/test/lux/data/number/i64.lux b/stdlib/test/test/lux/data/number/i64.lux index 2868b91a6..96a174eaa 100644 --- a/stdlib/test/test/lux/data/number/i64.lux +++ b/stdlib/test/test/lux/data/number/i64.lux @@ -69,7 +69,7 @@ (n/= pattern)))) (test "Shift right respect the sign of ints." (let [value (.int pattern)] - (if (i/< 0 value) - (i/< 0 (&.arithmetic-right-shift idx value)) - (i/>= 0 (&.arithmetic-right-shift idx value))))) + (if (i/< +0 value) + (i/< +0 (&.arithmetic-right-shift idx value)) + (i/>= +0 (&.arithmetic-right-shift idx value))))) )))) diff --git a/stdlib/test/test/lux/data/product.lux b/stdlib/test/test/lux/data/product.lux index 440ccf62c..86db80d0e 100644 --- a/stdlib/test/test/lux/data/product.lux +++ b/stdlib/test/test/lux/data/product.lux @@ -7,11 +7,11 @@ (context: "Products" ($_ seq (test "Can access the sides of a pair." - (and (i/= 1 (@.left [1 2])) - (i/= 2 (@.right [1 2])))) + (and (i/= +1 (@.left [+1 +2])) + (i/= +2 (@.right [+1 +2])))) (test "Can swap the sides of a pair." - (let [[_left _right] (@.swap [1 2])] - (and (i/= 2 _left) - (i/= 1 _right)))) + (let [[_left _right] (@.swap [+1 +2])] + (and (i/= +2 _left) + (i/= +1 _right)))) )) diff --git a/stdlib/test/test/lux/data/sum.lux b/stdlib/test/test/lux/data/sum.lux index 23dfd6078..4023c1cc3 100644 --- a/stdlib/test/test/lux/data/sum.lux +++ b/stdlib/test/test/lux/data/sum.lux @@ -18,20 +18,20 @@ (test "Can discriminate eithers based on their cases." (let [[_lefts _rights] (partition (: (List (| Text Text)) - (list (|0 "0") (|1 "1") (|0 "2"))))] + (list (|0 "+0") (|1 "+1") (|0 "+2"))))] (and (List/= _lefts (lefts (: (List (| Text Text)) - (list (|0 "0") (|1 "1") (|0 "2"))))) + (list (|0 "+0") (|1 "+1") (|0 "+2"))))) (List/= _rights (rights (: (List (| Text Text)) - (list (|0 "0") (|1 "1") (|0 "2")))))))) + (list (|0 "+0") (|1 "+1") (|0 "+2")))))))) (test "Can apply a function to an Either value depending on the case." - (and (i/= 10 (either (function (_ _) 10) - (function (_ _) 20) - (: (| Text Text) (|0 "")))) - (i/= 20 (either (function (_ _) 10) - (function (_ _) 20) - (: (| Text Text) (|1 "")))))) + (and (i/= +10 (either (function (_ _) +10) + (function (_ _) +20) + (: (| Text Text) (|0 "")))) + (i/= +20 (either (function (_ _) +10) + (function (_ _) +20) + (: (| Text Text) (|1 "")))))) ))) diff --git a/stdlib/test/test/lux/data/text/format.lux b/stdlib/test/test/lux/data/text/format.lux index b66ee9f8e..adf4cdf7b 100644 --- a/stdlib/test/test/lux/data/text/format.lux +++ b/stdlib/test/test/lux/data/text/format.lux @@ -13,9 +13,9 @@ (test "Can format common values simply." (and (&/= "#1" (%b #1)) (&/= "|123" (%n |123)) - (&/= "123" (%i 123)) - (&/= "123.456" (%f 123.456)) + (&/= "+123" (%i +123)) + (&/= "+123.456" (%f +123.456)) (&/= ".5" (%r .5)) (&/= "\"YOLO\"" (%t "YOLO")) - (&/= "User-id: 123 -- Active: #1" (format "User-id: " (%i 123) " -- Active: " (%b #1))))) + (&/= "User-id: +123 -- Active: #1" (format "User-id: " (%i +123) " -- Active: " (%b #1))))) ))) diff --git a/stdlib/test/test/lux/host.js.lux b/stdlib/test/test/lux/host.js.lux index cba72d0ae..faf9f6b5f 100644 --- a/stdlib/test/test/lux/host.js.lux +++ b/stdlib/test/test/lux/host.js.lux @@ -21,8 +21,8 @@ (is? "BAR"))) (test "Can call JavaScript functions" - (and (is? 124.0 - (&.call! (&.ref "Math.ceil" &.Function) [123.45] Frac)) - (is? 124.0 - (&.call! (&.ref "Math") "ceil" [123.45] Frac)))) + (and (is? +124.0 + (&.call! (&.ref "Math.ceil" &.Function) [+123.45] Frac)) + (is? +124.0 + (&.call! (&.ref "Math") "ceil" [+123.45] Frac)))) )) diff --git a/stdlib/test/test/lux/io.lux b/stdlib/test/test/lux/io.lux index 1cef1097d..66cd4a730 100644 --- a/stdlib/test/test/lux/io.lux +++ b/stdlib/test/test/lux/io.lux @@ -12,13 +12,13 @@ (context: "I/O" ($_ seq (test "" (text/= "YOLO" (&.run (&.io "YOLO")))) - (test "" (i/= 11 (&.run (:: &.Functor map inc (&.io 10))))) - (test "" (i/= 10 (&.run (:: &.Monad wrap 10)))) - (test "" (i/= 30 (&.run (let [(^open "&/.") &.Apply - (^open "&/.") &.Monad] - (&/apply (&/wrap (i/+ 10)) (&/wrap 20)))))) - (test "" (i/= 30 (&.run (do &.Monad - [f (wrap i/+) - x (wrap 10) - y (wrap 20)] - (wrap (f x y)))))))) + (test "" (i/= +11 (&.run (:: &.Functor map inc (&.io +10))))) + (test "" (i/= +10 (&.run (:: &.Monad wrap +10)))) + (test "" (i/= +30 (&.run (let [(^open "&/.") &.Apply + (^open "&/.") &.Monad] + (&/apply (&/wrap (i/+ +10)) (&/wrap +20)))))) + (test "" (i/= +30 (&.run (do &.Monad + [f (wrap i/+) + x (wrap +10) + y (wrap +20)] + (wrap (f x y)))))))) diff --git a/stdlib/test/test/lux/macro/code.lux b/stdlib/test/test/lux/macro/code.lux index d4739c894..1e0d4a606 100644 --- a/stdlib/test/test/lux/macro/code.lux +++ b/stdlib/test/test/lux/macro/code.lux @@ -18,17 +18,17 @@ (and (text/= (&.to-text )) (:: &.Equivalence = )))] - [(&.bit #1) "#1"] - [(&.bit #0) "#0"] - [(&.int 123) "123"] - [(&.frac 123.0) "123.0"] - [(&.text "\n") "\"\\n\""] - [(&.tag ["yolo" "lol"]) "#yolo.lol"] - [(&.identifier ["yolo" "lol"]) "yolo.lol"] - [(&.form (list (&.bit #1) (&.int 123))) "(#1 123)"] - [(&.tuple (list (&.bit #1) (&.int 123))) "[#1 123]"] - [(&.record (list [(&.bit #1) (&.int 123)])) "{#1 123}"] - [(&.local-tag "lol") "#lol"] - [(&.local-identifier "lol") "lol"] + [(&.bit #1) "#1"] + [(&.bit #0) "#0"] + [(&.int +123) "+123"] + [(&.frac +123.0) "+123.0"] + [(&.text "\n") "\"\\n\""] + [(&.tag ["yolo" "lol"]) "#yolo.lol"] + [(&.identifier ["yolo" "lol"]) "yolo.lol"] + [(&.form (list (&.bit #1) (&.int +123))) "(#1 +123)"] + [(&.tuple (list (&.bit #1) (&.int +123))) "[#1 +123]"] + [(&.record (list [(&.bit #1) (&.int +123)])) "{#1 +123}"] + [(&.local-tag "lol") "#lol"] + [(&.local-identifier "lol") "lol"] )] ($_ seq ))) diff --git a/stdlib/test/test/lux/macro/poly/equivalence.lux b/stdlib/test/test/lux/macro/poly/equivalence.lux index 061b5714d..5d7cfee64 100644 --- a/stdlib/test/test/lux/macro/poly/equivalence.lux +++ b/stdlib/test/test/lux/macro/poly/equivalence.lux @@ -49,7 +49,7 @@ (r.Random Record) (do r.Monad [size (:: @ map (n/% |2) r.nat) - #let [gen-int (|> r.int (:: @ map (|>> int/abs (i/% 1_000_000))))]] + #let [gen-int (|> r.int (:: @ map (|>> int/abs (i/% +1_000_000))))]] ($_ r.and r.bit gen-int diff --git a/stdlib/test/test/lux/macro/syntax.lux b/stdlib/test/test/lux/macro/syntax.lux index 4f6a29a05..63d592251 100644 --- a/stdlib/test/test/lux/macro/syntax.lux +++ b/stdlib/test/test/lux/macro/syntax.lux @@ -74,9 +74,9 @@ ["Can parse Bit syntax." #1 code.bit bit.Equivalence s.bit] ["Can parse Nat syntax." |123 code.nat number.Equivalence s.nat] - ["Can parse Int syntax." 123 code.int number.Equivalence s.int] + ["Can parse Int syntax." +123 code.int number.Equivalence s.int] ["Can parse Rev syntax." .123 code.rev number.Equivalence s.rev] - ["Can parse Frac syntax." 123.0 code.frac number.Equivalence s.frac] + ["Can parse Frac syntax." +123.0 code.frac number.Equivalence s.frac] ["Can parse Text syntax." "\n" code.text text.Equivalence s.text] ["Can parse Identifier syntax." ["yolo" "lol"] code.identifier name.Equivalence s.identifier] ["Can parse Tag syntax." ["yolo" "lol"] code.tag name.Equivalence s.tag] @@ -103,21 +103,21 @@ (with-expansions [ (do-template [ ] [(test (format "Can parse " " syntax.") - (and (match [#1 123] - (p.run (list ( (list (code.bit #1) (code.int 123)))) + (and (match [#1 +123] + (p.run (list ( (list (code.bit #1) (code.int +123)))) ( (p.and s.bit s.int)))) (match #1 (p.run (list ( (list (code.bit #1)))) ( s.bit))) - (fails? (p.run (list ( (list (code.bit #1) (code.int 123)))) + (fails? (p.run (list ( (list (code.bit #1) (code.int +123)))) ( s.bit))) (match (#.Left #1) (p.run (list ( (list (code.bit #1)))) ( (p.or s.bit s.int)))) - (match (#.Right 123) - (p.run (list ( (list (code.int 123)))) + (match (#.Right +123) + (p.run (list ( (list (code.int +123)))) ( (p.or s.bit s.int)))) - (fails? (p.run (list ( (list (code.frac 123.0)))) + (fails? (p.run (list ( (list (code.frac +123.0)))) ( (p.or s.bit s.int))))))] ["form" s.form code.form] @@ -126,8 +126,8 @@ (test "Can parse record syntax." - (match [#1 123] - (p.run (list (code.record (list [(code.bit #1) (code.int 123)]))) + (match [#1 +123] + (p.run (list (code.record (list [(code.bit #1) (code.int +123)]))) (s.record (p.and s.bit s.int))))) ))) @@ -135,7 +135,7 @@ ($_ seq (test "Can parse any Code." (match [_ (#.Bit #1)] - (p.run (list (code.bit #1) (code.int 123)) + (p.run (list (code.bit #1) (code.int +123)) s.any))) (test "Can check whether the end has been reached." diff --git a/stdlib/test/test/lux/math.lux b/stdlib/test/test/lux/math.lux index eb086243f..83ed1f8b0 100644 --- a/stdlib/test/test/lux/math.lux +++ b/stdlib/test/test/lux/math.lux @@ -14,7 +14,7 @@ (f/< margin-of-error (frac/abs (f/- standard value)))) -(def: margin Frac 0.0000001) +(def: margin Frac +0.0000001) (def: (trigonometric-symmetry forward backward angle) (-> (-> Frac Frac) (-> Frac Frac) Frac Bit) @@ -39,32 +39,32 @@ (context: "Rounding" (<| (times |100) (do @ - [sample (|> r.frac (:: @ map (f/* 1000.0)))] + [sample (|> r.frac (:: @ map (f/* +1000.0)))] ($_ seq (test "The ceiling will be an integer value, and will be >= the original." (let [ceil'd (&.ceil sample)] (and (|> ceil'd frac-to-int int-to-frac (f/= ceil'd)) (f/>= sample ceil'd) - (f/<= 1.0 (f/- sample ceil'd))))) + (f/<= +1.0 (f/- sample ceil'd))))) (test "The floor will be an integer value, and will be <= the original." (let [floor'd (&.floor sample)] (and (|> floor'd frac-to-int int-to-frac (f/= floor'd)) (f/<= sample floor'd) - (f/<= 1.0 (f/- floor'd sample))))) + (f/<= +1.0 (f/- floor'd sample))))) (test "The round will be an integer value, and will be < or > or = the original." (let [round'd (&.round sample)] (and (|> round'd frac-to-int int-to-frac (f/= round'd)) - (f/<= 1.0 (frac/abs (f/- sample round'd)))))) + (f/<= +1.0 (frac/abs (f/- sample round'd)))))) )))) (context: "Exponentials and logarithms" (<| (times |100) (do @ - [sample (|> r.frac (:: @ map (f/* 10.0)))] + [sample (|> r.frac (:: @ map (f/* +10.0)))] (test "Logarithm is the inverse of exponential." - (|> sample &.exp &.log (within? 1.0e-15 sample)))))) + (|> sample &.exp &.log (within? +1.0e-15 sample)))))) (context: "Greatest-Common-Divisor and Least-Common-Multiple" (<| (times |100) diff --git a/stdlib/test/test/lux/math/modular.lux b/stdlib/test/test/lux/math/modular.lux index 4d4ae3d8d..43f7d178e 100644 --- a/stdlib/test/test/lux/math/modular.lux +++ b/stdlib/test/test/lux/math/modular.lux @@ -14,18 +14,18 @@ [type ("type/." Equivalence)]] lux/test) -(def: %3 (/.modulus 3)) +(def: %3 (/.modulus +3)) (`` (type: Mod3 (~~ (:of %3)))) (def: modulusR (r.Random Int) (|> r.int - (:: r.Monad map (i/% 1000)) - (r.filter (|>> (i/= 0) not)))) + (:: r.Monad map (i/% +1000)) + (r.filter (|>> (i/= +0) not)))) (def: valueR (r.Random Int) - (|> r.int (:: r.Monad map (i/% 1000)))) + (|> r.int (:: r.Monad map (i/% +1000)))) (def: (modR modulus) (All [m] (-> (/.Modulus m) (r.Random [Int (/.Mod m)]))) @@ -109,7 +109,7 @@ (#.Some subject^-1) (|> subject (/.m/* subject^-1) - (/.m/= (/.mod normalM 1))) + (/.m/= (/.mod normalM +1))) #.None #1)) diff --git a/stdlib/test/test/lux/time/duration.lux b/stdlib/test/test/lux/time/duration.lux index 01ca9c98e..0f8c9f553 100644 --- a/stdlib/test/test/lux/time/duration.lux +++ b/stdlib/test/test/lux/time/duration.lux @@ -47,13 +47,13 @@ (do @ [sample (|> duration (:: @ map (@.frame @.day))) frame duration - factor (|> r.int (:: @ map (|>> (i/% 10) (i/max 1)))) + factor (|> r.int (:: @ map (|>> (i/% +10) (i/max +1)))) #let [(^open "@/.") @.Order]] ($_ seq (test "Can scale a duration." (|> sample (@.scale factor) (@.query sample) (i/= factor))) (test "Scaling a duration by one does not change it." - (|> sample (@.scale 1) (@/= sample))) + (|> sample (@.scale +1) (@/= sample))) (test "Merging with the empty duration changes nothing." (|> sample (@.merge @.empty) (@/= sample))) (test "Merging a duration with it's opposite yields an empty duration." diff --git a/stdlib/test/test/lux/time/instant.lux b/stdlib/test/test/lux/time/instant.lux index 59c01019e..db4898e20 100644 --- a/stdlib/test/test/lux/time/instant.lux +++ b/stdlib/test/test/lux/time/instant.lux @@ -18,7 +18,7 @@ [// ["_." duration]]) -(def: boundary Int 99_999_999_999_999) +(def: boundary Int +99_999_999_999_999) (def: #export instant (r.Random @.Instant) diff --git a/stdlib/test/test/lux/world/file.lux b/stdlib/test/test/lux/world/file.lux index cadc242e6..857b6afb5 100644 --- a/stdlib/test/test/lux/world/file.lux +++ b/stdlib/test/test/lux/world/file.lux @@ -23,7 +23,7 @@ ["_." binary]]) (def: truncate-millis - (|>> (i// 1_000) (i/* 1_000))) + (|>> (i// +1_000) (i/* +1_000))) (context: "File system." (do @ @@ -158,8 +158,8 @@ (assert "Can change the time of last modification." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file0 (format "temp_file_" (%n (n/+ |9 code)) "0") - file1 (format "temp_file_" (%n (n/+ |9 code)) "1")] + [#let [file0 (format "temp_file_" (%n (n/+ |9 code)) "+0") + file1 (format "temp_file_" (%n (n/+ |9 code)) "+1")] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System write dataL file0) -- cgit v1.2.3 From e6db62dbd6529938dace0e1cf5743f4e985efb81 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 28 Jul 2018 15:39:06 -0400 Subject: Removed temporary "|" prefix on Nat. --- luxc/src/lux/lexer.clj | 2 +- luxc/src/lux/parser.clj | 2 +- stdlib/source/lux.lux | 654 ++++++++++----------- stdlib/source/lux/compiler/default/cache.lux | 2 +- stdlib/source/lux/compiler/default/init.lux | 12 +- stdlib/source/lux/compiler/default/name.lux | 2 +- .../source/lux/compiler/default/phase/analysis.lux | 14 +- .../default/phase/analysis/case/coverage.lux | 4 +- .../compiler/default/phase/analysis/inference.lux | 12 +- .../lux/compiler/default/phase/analysis/scope.lux | 6 +- .../compiler/default/phase/analysis/structure.lux | 2 +- .../default/phase/extension/analysis/common.lux | 10 +- .../default/phase/extension/analysis/host.jvm.lux | 50 +- .../lux/compiler/default/phase/synthesis.lux | 4 +- .../default/phase/synthesis/expression.lux | 6 +- .../compiler/default/phase/synthesis/function.lux | 10 +- .../lux/compiler/default/phase/synthesis/loop.lux | 2 +- .../lux/compiler/default/phase/translation.lux | 6 +- .../translation/scheme/extension/common.jvm.lux | 18 +- .../phase/translation/scheme/function.jvm.lux | 4 +- .../phase/translation/scheme/runtime.jvm.lux | 8 +- stdlib/source/lux/compiler/default/reference.lux | 8 +- stdlib/source/lux/compiler/default/repl/type.lux | 2 +- stdlib/source/lux/compiler/default/syntax.lux | 40 +- stdlib/source/lux/compiler/meta/io/archive.lux | 2 +- stdlib/source/lux/concurrency/actor.lux | 4 +- stdlib/source/lux/concurrency/promise.lux | 2 +- stdlib/source/lux/concurrency/semaphore.lux | 18 +- stdlib/source/lux/control/comonad.lux | 4 +- stdlib/source/lux/control/concatenative.lux | 22 +- stdlib/source/lux/control/equivalence.lux | 4 +- stdlib/source/lux/control/exception.lux | 2 +- stdlib/source/lux/control/monad.lux | 6 +- stdlib/source/lux/control/parser.lux | 8 +- stdlib/source/lux/control/pipe.lux | 2 +- stdlib/source/lux/control/writer.lux | 2 +- stdlib/source/lux/data/bit.lux | 4 +- stdlib/source/lux/data/collection/array.lux | 30 +- stdlib/source/lux/data/collection/bits.lux | 28 +- stdlib/source/lux/data/collection/dictionary.lux | 56 +- .../lux/data/collection/dictionary/ordered.lux | 2 +- stdlib/source/lux/data/collection/list.lux | 74 +-- .../source/lux/data/collection/queue/priority.lux | 4 +- stdlib/source/lux/data/collection/row.lux | 56 +- stdlib/source/lux/data/collection/sequence.lux | 4 +- stdlib/source/lux/data/collection/set.lux | 4 +- stdlib/source/lux/data/collection/set/multi.lux | 22 +- .../lux/data/collection/tree/rose/zipper.lux | 8 +- stdlib/source/lux/data/color.lux | 20 +- stdlib/source/lux/data/format/binary.lux | 36 +- stdlib/source/lux/data/number.lux | 341 ++++++----- stdlib/source/lux/data/number/complex.lux | 4 +- stdlib/source/lux/data/number/i64.lux | 22 +- stdlib/source/lux/data/number/ratio.lux | 16 +- stdlib/source/lux/data/sum.lux | 20 +- stdlib/source/lux/data/text.lux | 18 +- stdlib/source/lux/data/text/buffer.lux | 4 +- stdlib/source/lux/data/text/lexer.lux | 4 +- stdlib/source/lux/data/text/regex.lux | 14 +- stdlib/source/lux/data/text/unicode.lux | 246 ++++---- stdlib/source/lux/host.jvm.lux | 6 +- stdlib/source/lux/io.lux | 2 +- stdlib/source/lux/macro/code.lux | 2 +- stdlib/source/lux/macro/poly.lux | 36 +- stdlib/source/lux/macro/poly/equivalence.lux | 2 +- stdlib/source/lux/macro/poly/functor.lux | 8 +- stdlib/source/lux/macro/poly/json.lux | 10 +- stdlib/source/lux/math.lux | 8 +- stdlib/source/lux/math/random.lux | 34 +- stdlib/source/lux/test.lux | 24 +- stdlib/source/lux/time/date.lux | 50 +- stdlib/source/lux/time/instant.lux | 20 +- stdlib/source/lux/type.lux | 6 +- stdlib/source/lux/type/check.lux | 6 +- stdlib/source/lux/type/implicit.lux | 10 +- stdlib/source/lux/type/resource.lux | 2 +- stdlib/source/lux/world/binary.lux | 70 +-- stdlib/source/lux/world/net/udp.jvm.lux | 4 +- stdlib/test/test/lux.lux | 28 +- stdlib/test/test/lux/cli.lux | 10 +- .../lux/compiler/default/phase/analysis/case.lux | 26 +- .../compiler/default/phase/analysis/function.lux | 20 +- .../compiler/default/phase/analysis/primitive.lux | 8 +- .../default/phase/analysis/procedure/common.lux | 34 +- .../compiler/default/phase/analysis/reference.lux | 18 +- .../compiler/default/phase/analysis/structure.lux | 50 +- .../lux/compiler/default/phase/synthesis/case.lux | 8 +- .../compiler/default/phase/synthesis/function.lux | 24 +- .../compiler/default/phase/synthesis/primitive.lux | 6 +- .../compiler/default/phase/synthesis/structure.lux | 8 +- stdlib/test/test/lux/compiler/default/syntax.lux | 54 +- stdlib/test/test/lux/concurrency/actor.lux | 20 +- stdlib/test/test/lux/concurrency/atom.lux | 2 +- stdlib/test/test/lux/concurrency/frp.lux | 18 +- stdlib/test/test/lux/concurrency/promise.lux | 24 +- stdlib/test/test/lux/concurrency/semaphore.lux | 22 +- stdlib/test/test/lux/concurrency/stm.lux | 32 +- stdlib/test/test/lux/control/continuation.lux | 18 +- stdlib/test/test/lux/control/exception.lux | 2 +- stdlib/test/test/lux/control/interval.lux | 22 +- stdlib/test/test/lux/control/parser.lux | 38 +- stdlib/test/test/lux/control/region.lux | 20 +- stdlib/test/test/lux/control/state.lux | 18 +- stdlib/test/test/lux/control/thread.lux | 8 +- stdlib/test/test/lux/data/bit.lux | 2 +- stdlib/test/test/lux/data/collection/array.lux | 24 +- stdlib/test/test/lux/data/collection/bits.lux | 12 +- .../test/test/lux/data/collection/dictionary.lux | 14 +- .../lux/data/collection/dictionary/ordered.lux | 4 +- stdlib/test/test/lux/data/collection/list.lux | 20 +- stdlib/test/test/lux/data/collection/queue.lux | 6 +- .../test/lux/data/collection/queue/priority.lux | 8 +- stdlib/test/test/lux/data/collection/row.lux | 12 +- stdlib/test/test/lux/data/collection/sequence.lux | 34 +- stdlib/test/test/lux/data/collection/set.lux | 4 +- .../test/test/lux/data/collection/set/ordered.lux | 4 +- stdlib/test/test/lux/data/collection/stack.lux | 4 +- stdlib/test/test/lux/data/collection/tree/rose.lux | 8 +- .../test/lux/data/collection/tree/rose/zipper.lux | 4 +- stdlib/test/test/lux/data/color.lux | 6 +- stdlib/test/test/lux/data/format/json.lux | 10 +- stdlib/test/test/lux/data/format/xml.lux | 22 +- stdlib/test/test/lux/data/lazy.lux | 4 +- stdlib/test/test/lux/data/name.lux | 10 +- stdlib/test/test/lux/data/number.lux | 28 +- stdlib/test/test/lux/data/number/complex.lux | 20 +- stdlib/test/test/lux/data/number/i64.lux | 14 +- stdlib/test/test/lux/data/number/ratio.lux | 20 +- stdlib/test/test/lux/data/sum.lux | 14 +- stdlib/test/test/lux/data/text.lux | 24 +- stdlib/test/test/lux/data/text/format.lux | 2 +- stdlib/test/test/lux/data/text/lexer.lux | 4 +- stdlib/test/test/lux/data/text/regex.lux | 18 +- stdlib/test/test/lux/host.jvm.lux | 6 +- stdlib/test/test/lux/macro/poly/equivalence.lux | 4 +- stdlib/test/test/lux/macro/syntax.lux | 2 +- stdlib/test/test/lux/math.lux | 26 +- stdlib/test/test/lux/math/logic/continuous.lux | 2 +- stdlib/test/test/lux/math/logic/fuzzy.lux | 18 +- stdlib/test/test/lux/math/modular.lux | 2 +- stdlib/test/test/lux/math/random.lux | 4 +- stdlib/test/test/lux/time/date.lux | 20 +- stdlib/test/test/lux/time/duration.lux | 10 +- stdlib/test/test/lux/time/instant.lux | 14 +- stdlib/test/test/lux/type.lux | 16 +- stdlib/test/test/lux/type/check.lux | 12 +- stdlib/test/test/lux/type/implicit.lux | 14 +- stdlib/test/test/lux/type/resource.lux | 24 +- stdlib/test/test/lux/world/binary.lux | 26 +- stdlib/test/test/lux/world/file.lux | 34 +- stdlib/test/test/lux/world/net/tcp.lux | 14 +- stdlib/test/test/lux/world/net/udp.lux | 14 +- 152 files changed, 1720 insertions(+), 1729 deletions(-) diff --git a/luxc/src/lux/lexer.clj b/luxc/src/lux/lexer.clj index dbbfc3d2e..f74e14dfd 100644 --- a/luxc/src/lux/lexer.clj +++ b/luxc/src/lux/lexer.clj @@ -138,7 +138,7 @@ (|do [[meta _ token] (&reader/read-regex )] (return (&/T [meta ( (string/replace token #"_" ""))])))) - lex-nat $Nat #"^\|[0-9][0-9_]*" + lex-nat $Nat #"^[0-9][0-9_]*" lex-int $Int #"^(-|\+)[0-9][0-9_]*" lex-rev $Rev #"^\.[0-9][0-9_]*" lex-frac $Frac #"^(-|\+)[0-9][0-9_]*\.[0-9][0-9_]*((e|E)(-|\+)[0-9][0-9_]*)?" diff --git a/luxc/src/lux/parser.clj b/luxc/src/lux/parser.clj index 5303327c8..dd33129b8 100644 --- a/luxc/src/lux/parser.clj +++ b/luxc/src/lux/parser.clj @@ -68,7 +68,7 @@ (return (&/|list (&/T [meta (&/$Bit (.equals ^String ?value "#1"))]))) (&lexer/$Nat ?value) - (return (&/|list (&/T [meta (&/$Nat (Long/parseUnsignedLong (.substring ^String ?value 1)))]))) + (return (&/|list (&/T [meta (&/$Nat (Long/parseUnsignedLong ?value))]))) (&lexer/$Int ?value) (return (&/|list (&/T [meta (&/$Int (Long/parseLong ?value))]))) diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index dd5a42064..109a590e3 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -1,194 +1,194 @@ ("lux def" dummy-cursor - ("lux check" (|2 (|0 "#Text" (|0)) - (|2 (|0 "#I64" (|1 (|0 "#Nat" (|0)) (|0))) - (|0 "#I64" (|1 (|0 "#Nat" (|0)) (|0))))) - ["" |0 |0]) - [["" |0 |0] - (|10 (|1 [[["" |0 |0] (|7 ["lux" "export?"])] - [["" |0 |0] (|0 #1)]] - (|0)))]) + ("lux check" (2 (0 "#Text" (0)) + (2 (0 "#I64" (1 (0 "#Nat" (0)) (0))) + (0 "#I64" (1 (0 "#Nat" (0)) (0))))) + ["" 0 0]) + [["" 0 0] + (10 (1 [[["" 0 0] (7 ["lux" "export?"])] + [["" 0 0] (0 #1)]] + (0)))]) ## (type: Any ## (Ex [a] a)) ("lux def" Any - (|10 ["lux" "Any"] - (|8 (|0) (|4 |1))) + (10 ["lux" "Any"] + (8 (0) (4 1))) [dummy-cursor - (|10 (|1 [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (|1 [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - (|1 [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "The type of things whose type does not matter. + (10 (1 [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (1 [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + (1 [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "The type of things whose type does not matter. It can be used to write functions or data-structures that can take, or return, anything.")]] - (|0)))))]) + (0)))))]) ## (type: Nothing ## (All [a] a)) ("lux def" Nothing - (|10 ["lux" "Nothing"] - (|7 (|0) (|4 |1))) + (10 ["lux" "Nothing"] + (7 (0) (4 1))) [dummy-cursor - (|10 (|1 [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (|1 [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - (|1 [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "The type of things whose type is unknown or undefined. + (10 (1 [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (1 [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + (1 [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "The type of things whose type is unknown or undefined. Useful for expressions that cause errors or other \"extraordinary\" conditions.")]] - (|0)))))]) + (0)))))]) ## (type: (List a) ## #Nil ## (#Cons a (List a))) ("lux def" List - (|10 ["lux" "List"] - (|7 (|0) - (|1 ## "lux.Nil" - Any - ## "lux.Cons" - (|2 (|4 |1) - (|9 (|4 |1) (|4 |0)))))) + (10 ["lux" "List"] + (7 (0) + (1 ## "lux.Nil" + Any + ## "lux.Cons" + (2 (4 1) + (9 (4 1) (4 0)))))) [dummy-cursor - (|10 (|1 [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (|1 [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - (|1 [[dummy-cursor (|7 ["lux" "tags"])] - [dummy-cursor (|9 (|1 [dummy-cursor (|5 "Nil")] (|1 [dummy-cursor (|5 "Cons")] (|0))))]] - (|1 [[dummy-cursor (|7 ["lux" "type-args"])] - [dummy-cursor (|9 (|1 [dummy-cursor (|5 "a")] (|0)))]] - (|1 [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "A potentially empty list of values.")]] - (|0)))))))]) + (10 (1 [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (1 [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + (1 [[dummy-cursor (7 ["lux" "tags"])] + [dummy-cursor (9 (1 [dummy-cursor (5 "Nil")] (1 [dummy-cursor (5 "Cons")] (0))))]] + (1 [[dummy-cursor (7 ["lux" "type-args"])] + [dummy-cursor (9 (1 [dummy-cursor (5 "a")] (0)))]] + (1 [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "A potentially empty list of values.")]] + (0)))))))]) ("lux def" Bit - (|10 ["lux" "Bit"] - (|0 "#Bit" #Nil)) + (10 ["lux" "Bit"] + (0 "#Bit" #Nil)) [dummy-cursor - (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "Your standard, run-of-the-mill boolean values (as bits).")]] - #Nil))))]) + (10 (#Cons [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "Your standard, run-of-the-mill boolean values (as bits).")]] + #Nil))))]) ("lux def" I64 - (|10 ["lux" "I64"] - (|7 (|0) - (|0 "#I64" (#Cons (|4 |1) #Nil)))) + (10 ["lux" "I64"] + (7 (0) + (0 "#I64" (#Cons (4 1) #Nil)))) [dummy-cursor - (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "64-bit integers without any semantics.")]] - #Nil))))]) + (10 (#Cons [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "64-bit integers without any semantics.")]] + #Nil))))]) ("lux def" Nat - (|10 ["lux" "Nat"] - (|0 "#I64" (#Cons (|0 "#Nat" #Nil) #Nil))) + (10 ["lux" "Nat"] + (0 "#I64" (#Cons (0 "#Nat" #Nil) #Nil))) [dummy-cursor - (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "Natural numbers (unsigned integers). + (10 (#Cons [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "Natural numbers (unsigned integers). - They start at zero (|0) and extend in the positive direction.")]] - #Nil))))]) + They start at zero (0) and extend in the positive direction.")]] + #Nil))))]) ("lux def" Int - (|10 ["lux" "Int"] - (|0 "#I64" (#Cons (|0 "#Int" #Nil) #Nil))) + (10 ["lux" "Int"] + (0 "#I64" (#Cons (0 "#Int" #Nil) #Nil))) [dummy-cursor - (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "Your standard, run-of-the-mill integer numbers.")]] - #Nil))))]) + (10 (#Cons [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "Your standard, run-of-the-mill integer numbers.")]] + #Nil))))]) ("lux def" Rev - (|10 ["lux" "Rev"] - (|0 "#I64" (#Cons (|0 "#Rev" #Nil) #Nil))) + (10 ["lux" "Rev"] + (0 "#I64" (#Cons (0 "#Rev" #Nil) #Nil))) [dummy-cursor - (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "Fractional numbers that live in the interval [0,1). + (10 (#Cons [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "Fractional numbers that live in the interval [0,1). Useful for probability, and other domains that work within that interval.")]] - #Nil))))]) + #Nil))))]) ("lux def" Frac - (|10 ["lux" "Frac"] - (|0 "#Frac" #Nil)) + (10 ["lux" "Frac"] + (0 "#Frac" #Nil)) [dummy-cursor - (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "Your standard, run-of-the-mill floating-point (fractional) numbers.")]] - #Nil))))]) + (10 (#Cons [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "Your standard, run-of-the-mill floating-point (fractional) numbers.")]] + #Nil))))]) ("lux def" Text - (|10 ["lux" "Text"] - (|0 "#Text" #Nil)) + (10 ["lux" "Text"] + (0 "#Text" #Nil)) [dummy-cursor - (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "Your standard, run-of-the-mill string values.")]] - #Nil))))]) + (10 (#Cons [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "Your standard, run-of-the-mill string values.")]] + #Nil))))]) ("lux def" Name - (|10 ["lux" "Name"] - (|2 Text Text)) + (10 ["lux" "Name"] + (2 Text Text)) [dummy-cursor - (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "A name. + (10 (#Cons [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "A name. It is used as part of Lux syntax to represent identifiers and tags.")]] - #Nil))))]) + #Nil))))]) ## (type: (Maybe a) ## #None ## (#Some a)) ("lux def" Maybe - (|10 ["lux" "Maybe"] - (|7 #Nil - (|1 ## "lux.None" - Any - ## "lux.Some" - (|4 |1)))) + (10 ["lux" "Maybe"] + (7 #Nil + (1 ## "lux.None" + Any + ## "lux.Some" + (4 1)))) [dummy-cursor - (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "tags"])] - [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "None")] (#Cons [dummy-cursor (|5 "Some")] #Nil)))]] - (#Cons [[dummy-cursor (|7 ["lux" "type-args"])] - [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "a")] #Nil))]] - (#Cons [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "A potentially missing value.")]] - #Nil))))))]) + (10 (#Cons [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "tags"])] + [dummy-cursor (9 (#Cons [dummy-cursor (5 "None")] (#Cons [dummy-cursor (5 "Some")] #Nil)))]] + (#Cons [[dummy-cursor (7 ["lux" "type-args"])] + [dummy-cursor (9 (#Cons [dummy-cursor (5 "a")] #Nil))]] + (#Cons [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "A potentially missing value.")]] + #Nil))))))]) ## (type: #rec Type ## (#Primitive Text (List Type)) @@ -204,60 +204,60 @@ ## (#Named Name Type) ## ) ("lux def" Type - (|10 ["lux" "Type"] - ({Type - ({Type-List - ({Type-Pair - (|9 Nothing - (|7 #Nil - (|1 ## "lux.Primitive" - (|2 Text Type-List) - (|1 ## "lux.Sum" - Type-Pair - (|1 ## "lux.Product" - Type-Pair - (|1 ## "lux.Function" - Type-Pair - (|1 ## "lux.Parameter" - Nat - (|1 ## "lux.Var" - Nat - (|1 ## "lux.Ex" - Nat - (|1 ## "lux.UnivQ" - (|2 Type-List Type) - (|1 ## "lux.ExQ" - (|2 Type-List Type) - (|1 ## "lux.Apply" - Type-Pair - ## "lux.Named" - (|2 Name Type)))))))))))))} - ("lux check type" (|2 Type Type)))} - ("lux check type" (|9 Type List)))} - ("lux check type" (|9 (|4 |1) (|4 |0))))) + (10 ["lux" "Type"] + ({Type + ({Type-List + ({Type-Pair + (9 Nothing + (7 #Nil + (1 ## "lux.Primitive" + (2 Text Type-List) + (1 ## "lux.Sum" + Type-Pair + (1 ## "lux.Product" + Type-Pair + (1 ## "lux.Function" + Type-Pair + (1 ## "lux.Parameter" + Nat + (1 ## "lux.Var" + Nat + (1 ## "lux.Ex" + Nat + (1 ## "lux.UnivQ" + (2 Type-List Type) + (1 ## "lux.ExQ" + (2 Type-List Type) + (1 ## "lux.Apply" + Type-Pair + ## "lux.Named" + (2 Name Type)))))))))))))} + ("lux check type" (2 Type Type)))} + ("lux check type" (9 Type List)))} + ("lux check type" (9 (4 1) (4 0))))) [dummy-cursor - (|10 (#Cons [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "tags"])] - [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "Primitive")] - (#Cons [dummy-cursor (|5 "Sum")] - (#Cons [dummy-cursor (|5 "Product")] - (#Cons [dummy-cursor (|5 "Function")] - (#Cons [dummy-cursor (|5 "Parameter")] - (#Cons [dummy-cursor (|5 "Var")] - (#Cons [dummy-cursor (|5 "Ex")] - (#Cons [dummy-cursor (|5 "UnivQ")] - (#Cons [dummy-cursor (|5 "ExQ")] - (#Cons [dummy-cursor (|5 "Apply")] - (#Cons [dummy-cursor (|5 "Named")] - #Nil))))))))))))]] - (#Cons [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "This type represents the data-structures that are used to specify types themselves.")]] - (#Cons [[dummy-cursor (|7 ["lux" "type-rec?"])] - [dummy-cursor (|0 #1)]] - #Nil))))))]) + (10 (#Cons [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "tags"])] + [dummy-cursor (9 (#Cons [dummy-cursor (5 "Primitive")] + (#Cons [dummy-cursor (5 "Sum")] + (#Cons [dummy-cursor (5 "Product")] + (#Cons [dummy-cursor (5 "Function")] + (#Cons [dummy-cursor (5 "Parameter")] + (#Cons [dummy-cursor (5 "Var")] + (#Cons [dummy-cursor (5 "Ex")] + (#Cons [dummy-cursor (5 "UnivQ")] + (#Cons [dummy-cursor (5 "ExQ")] + (#Cons [dummy-cursor (5 "Apply")] + (#Cons [dummy-cursor (5 "Named")] + #Nil))))))))))))]] + (#Cons [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "This type represents the data-structures that are used to specify types themselves.")]] + (#Cons [[dummy-cursor (7 ["lux" "type-rec?"])] + [dummy-cursor (0 #1)]] + #Nil))))))]) ## (type: Cursor ## {#module Text @@ -267,18 +267,18 @@ (#Named ["lux" "Cursor"] (#Product Text (#Product Nat Nat))) [dummy-cursor - (|10 (#Cons [[dummy-cursor (|7 ["lux" "tags"])] - [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "module")] - (#Cons [dummy-cursor (|5 "line")] - (#Cons [dummy-cursor (|5 "column")] - #Nil))))]] - (#Cons [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "Cursors are for specifying the location of Code nodes in Lux files during compilation.")]] - (#Cons [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - #Nil)))))]) + (10 (#Cons [[dummy-cursor (7 ["lux" "tags"])] + [dummy-cursor (9 (#Cons [dummy-cursor (5 "module")] + (#Cons [dummy-cursor (5 "line")] + (#Cons [dummy-cursor (5 "column")] + #Nil))))]] + (#Cons [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "Cursors are for specifying the location of Code nodes in Lux files during compilation.")]] + (#Cons [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + #Nil)))))]) ## (type: (Ann m v) ## {#meta m @@ -287,22 +287,22 @@ (#Named ["lux" "Ann"] (#UnivQ #Nil (#UnivQ #Nil - (#Product (#Parameter |3) - (#Parameter |1))))) + (#Product (#Parameter 3) + (#Parameter 1))))) [dummy-cursor - (|10 (#Cons [[dummy-cursor (|7 ["lux" "tags"])] - [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "meta")] - (#Cons [dummy-cursor (|5 "datum")] - #Nil)))]] - (#Cons [[dummy-cursor (|7 ["lux" "doc"])] - [dummy-cursor (|5 "The type of things that can be annotated with meta-data of arbitrary types.")]] - (#Cons [[dummy-cursor (|7 ["lux" "type-args"])] - [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "m")] (#Cons [dummy-cursor (|5 "v")] #Nil)))]] - (#Cons [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - #Nil))))))]) + (10 (#Cons [[dummy-cursor (7 ["lux" "tags"])] + [dummy-cursor (9 (#Cons [dummy-cursor (5 "meta")] + (#Cons [dummy-cursor (5 "datum")] + #Nil)))]] + (#Cons [[dummy-cursor (7 ["lux" "doc"])] + [dummy-cursor (5 "The type of things that can be annotated with meta-data of arbitrary types.")]] + (#Cons [[dummy-cursor (7 ["lux" "type-args"])] + [dummy-cursor (9 (#Cons [dummy-cursor (5 "m")] (#Cons [dummy-cursor (5 "v")] #Nil)))]] + (#Cons [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + #Nil))))))]) ## (type: (Code' w) ## (#Bit Bit) @@ -346,30 +346,30 @@ )))))))))) )} ("lux check type" (#Apply Code List)))} - ("lux check type" (#Apply (#Apply (#Parameter |1) - (#Parameter |0)) - (#Parameter |1))))) + ("lux check type" (#Apply (#Apply (#Parameter 1) + (#Parameter 0)) + (#Parameter 1))))) [dummy-cursor - (|10 (#Cons [[dummy-cursor (|7 ["lux" "tags"])] - [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "Bit")] - (#Cons [dummy-cursor (|5 "Nat")] - (#Cons [dummy-cursor (|5 "Int")] - (#Cons [dummy-cursor (|5 "Rev")] - (#Cons [dummy-cursor (|5 "Frac")] - (#Cons [dummy-cursor (|5 "Text")] - (#Cons [dummy-cursor (|5 "Identifier")] - (#Cons [dummy-cursor (|5 "Tag")] - (#Cons [dummy-cursor (|5 "Form")] - (#Cons [dummy-cursor (|5 "Tuple")] - (#Cons [dummy-cursor (|5 "Record")] - #Nil))))))))))))]] - (#Cons [[dummy-cursor (|7 ["lux" "type-args"])] - [dummy-cursor (|9 (#Cons [dummy-cursor (|5 "w")] #Nil))]] - (#Cons [[dummy-cursor (|7 ["lux" "type?"])] - [dummy-cursor (|0 #1)]] - (#Cons [[dummy-cursor (|7 ["lux" "export?"])] - [dummy-cursor (|0 #1)]] - #Nil)))))]) + (10 (#Cons [[dummy-cursor (7 ["lux" "tags"])] + [dummy-cursor (9 (#Cons [dummy-cursor (5 "Bit")] + (#Cons [dummy-cursor (5 "Nat")] + (#Cons [dummy-cursor (5 "Int")] + (#Cons [dummy-cursor (5 "Rev")] + (#Cons [dummy-cursor (5 "Frac")] + (#Cons [dummy-cursor (5 "Text")] + (#Cons [dummy-cursor (5 "Identifier")] + (#Cons [dummy-cursor (5 "Tag")] + (#Cons [dummy-cursor (5 "Form")] + (#Cons [dummy-cursor (5 "Tuple")] + (#Cons [dummy-cursor (5 "Record")] + #Nil))))))))))))]] + (#Cons [[dummy-cursor (7 ["lux" "type-args"])] + [dummy-cursor (9 (#Cons [dummy-cursor (5 "w")] #Nil))]] + (#Cons [[dummy-cursor (7 ["lux" "type?"])] + [dummy-cursor (0 #1)]] + (#Cons [[dummy-cursor (7 ["lux" "export?"])] + [dummy-cursor (0 #1)]] + #Nil)))))]) ## (type: Code ## (Ann Cursor (Code' (Ann Cursor)))) @@ -490,8 +490,8 @@ (#Product ## "lux.counter" Nat ## "lux.mappings" - (#Apply (#Product (#Parameter |3) - (#Parameter |1)) + (#Apply (#Product (#Parameter 3) + (#Parameter 1)) List))))) (record$ (#Cons [(tag$ ["lux" "tags"]) (tuple$ (#Cons (text$ "counter") (#Cons (text$ "mappings") #Nil)))] @@ -543,9 +543,9 @@ (#UnivQ #Nil (#UnivQ #Nil (#Sum ## "lux.Left" - (#Parameter |3) + (#Parameter 3) ## "lux.Right" - (#Parameter |1))))) + (#Parameter 1))))) (record$ (#Cons [(tag$ ["lux" "tags"]) (tuple$ (#Cons (text$ "Left") (#Cons (text$ "Right") #Nil)))] (#Cons [(tag$ ["lux" "type-args"]) @@ -760,7 +760,7 @@ (#Named ["lux" "Meta"] (#UnivQ #Nil (#Function Lux - (#Apply (#Product Lux (#Parameter |1)) + (#Apply (#Product Lux (#Parameter 1)) (#Apply Text Either))))) (record$ (#Cons [(tag$ ["lux" "doc"]) (text$ "Computations that can have access to the state of the compiler. @@ -782,10 +782,10 @@ ## Base functions & macros ("lux def" return ("lux check" (#UnivQ #Nil - (#Function (#Parameter |1) + (#Function (#Parameter 1) (#Function Lux (#Apply (#Product Lux - (#Parameter |1)) + (#Parameter 1)) (#Apply Text Either))))) ([_ val] ([_ state] @@ -797,7 +797,7 @@ (#Function Text (#Function Lux (#Apply (#Product Lux - (#Parameter |1)) + (#Parameter 1)) (#Apply Text Either))))) ([_ msg] ([_ state] @@ -861,7 +861,7 @@ ("lux def" cursor-code ("lux check" Code - (tuple$ (#Cons (text$ "") (#Cons (nat$ |0) (#Cons (nat$ |0) #Nil))))) + (tuple$ (#Cons (text$ "") (#Cons (nat$ 0) (#Cons (nat$ 0) #Nil))))) (record$ #Nil)) ("lux def" meta-code @@ -1052,9 +1052,9 @@ #Nil (#UnivQ #Nil (#UnivQ #Nil - (#Function (#Function (#Parameter |3) (#Parameter |1)) - (#Function ($' List (#Parameter |3)) - ($' List (#Parameter |1)))))) + (#Function (#Function (#Parameter 3) (#Parameter 1)) + (#Function ($' List (#Parameter 3)) + ($' List (#Parameter 1)))))) ({#Nil #Nil @@ -1164,7 +1164,7 @@ pairs)) [_ (#Form (#Cons [_ (#Tag "lux" "Parameter")] (#Cons [_ (#Nat idx)] #Nil)))] - (form$ (#Cons (tag$ ["lux" "Parameter"]) (#Cons (nat$ (n/+ |2 idx)) #Nil))) + (form$ (#Cons (tag$ ["lux" "Parameter"]) (#Cons (nat$ (n/+ 2 idx)) #Nil))) [_ (#Form members)] (form$ (list/map update-parameters members)) @@ -1198,12 +1198,12 @@ (def:'' (list/fold f init xs) #Nil ## (All [a b] (-> (-> b a a) a (List b) a)) - (#UnivQ #Nil (#UnivQ #Nil (#Function (#Function (#Parameter |1) - (#Function (#Parameter |3) - (#Parameter |3))) - (#Function (#Parameter |3) - (#Function ($' List (#Parameter |1)) - (#Parameter |3)))))) + (#UnivQ #Nil (#UnivQ #Nil (#Function (#Function (#Parameter 1) + (#Function (#Parameter 3) + (#Parameter 3))) + (#Function (#Parameter 3) + (#Function ($' List (#Parameter 1)) + (#Parameter 3)))))) ({#Nil init @@ -1214,8 +1214,8 @@ (def:'' (list/size list) #Nil (#UnivQ #Nil - (#Function ($' List (#Parameter |1)) Nat)) - (list/fold (function'' [_ acc] (n/+ |1 acc)) |0 list)) + (#Function ($' List (#Parameter 1)) Nat)) + (list/fold (function'' [_ acc] (n/+ 1 acc)) 0 list)) (macro:' #export (All tokens) (#Cons [(tag$ ["lux" "doc"]) @@ -1241,7 +1241,7 @@ (function'' [name' body'] (form$ (#Cons (tag$ ["lux" "UnivQ"]) (#Cons (tag$ ["lux" "Nil"]) - (#Cons (replace-syntax (#Cons [name' (make-parameter |1)] #Nil) + (#Cons (replace-syntax (#Cons [name' (make-parameter 1)] #Nil) (update-parameters body')) #Nil)))))) body names) @@ -1252,7 +1252,7 @@ body' [#0 _] - (replace-syntax (#Cons [self-name (make-parameter (n/* |2 (n/- |1 (list/size names))))] + (replace-syntax (#Cons [self-name (make-parameter (n/* 2 (n/- 1 (list/size names))))] #Nil) body')} [(text/= "" self-name) names]) @@ -1288,7 +1288,7 @@ (function'' [name' body'] (form$ (#Cons (tag$ ["lux" "ExQ"]) (#Cons (tag$ ["lux" "Nil"]) - (#Cons (replace-syntax (#Cons [name' (make-parameter |1)] #Nil) + (#Cons (replace-syntax (#Cons [name' (make-parameter 1)] #Nil) (update-parameters body')) #Nil)))))) body names) @@ -1299,7 +1299,7 @@ body' [#0 _] - (replace-syntax (#Cons [self-name (make-parameter (n/* |2 (n/- |1 (list/size names))))] + (replace-syntax (#Cons [self-name (make-parameter (n/* 2 (n/- 1 (list/size names))))] #Nil) body')} [(text/= "" self-name) names]) @@ -1518,7 +1518,7 @@ (def:''' (wrap-meta content) #Nil (-> Code Code) - (tuple$ (list (tuple$ (list (text$ "") (nat$ |0) (nat$ |0))) + (tuple$ (list (tuple$ (list (text$ "") (nat$ 0) (nat$ 0))) content))) (def:''' (untemplate-list tokens) @@ -2199,14 +2199,14 @@ (def:''' (high-bits value) (list) (-> ($' I64 Any) I64) - ("lux i64 logical-right-shift" |32 value)) + ("lux i64 logical-right-shift" 32 value)) (def:''' low-mask (list) I64 - (|> |1 - ("lux i64 left-shift" |32) - ("lux i64 -" |1))) + (|> 1 + ("lux i64 left-shift" 32) + ("lux i64 -" 1))) (def:''' (low-bits value) (list) @@ -2366,12 +2366,12 @@ (-> Nat Nat Nat) (if ("lux int <" ("lux coerce" Int param) +0) (if (n/< param subject) - |0 - |1) + 0 + 1) (let' [quotient ("lux i64 left-shift" - |1 + 1 ("lux int /" - ("lux i64 logical-right-shift" |1 subject) + ("lux i64 logical-right-shift" 1 subject) ("lux coerce" Int param))) flat ("lux int *" ("lux coerce" Int quotient) @@ -2379,7 +2379,7 @@ remainder ("lux i64 -" flat subject)] (if (n/< param remainder) quotient - ("lux i64 +" |1 quotient))))) + ("lux i64 +" 1 quotient))))) (def:''' #export (n//% param subject) (list [(tag$ ["lux" "doc"]) @@ -2442,7 +2442,7 @@ paramL (low-bits param) bottom (|> subjectL ("lux int *" paramL) - ("lux i64 logical-right-shift" |32)) + ("lux i64 logical-right-shift" 32)) middle ("lux i64 +" ("lux int *" subjectH paramL) ("lux int *" subjectL paramH)) @@ -2452,17 +2452,17 @@ high-bits ("lux i64 +" top)))) -(def:''' least-significant-bit-mask (list) Nat |1) +(def:''' least-significant-bit-mask (list) Nat 1) (def:''' (without-trailing-zeroes count remaining) (list) (-> Nat Nat (#Product Nat Nat)) (if (|> remaining ("lux i64 and" least-significant-bit-mask) - ("lux i64 =" |0)) + ("lux i64 =" 0)) (without-trailing-zeroes - ("lux i64 +" |1 count) - ("lux i64 logical-right-shift" |1 remaining)) + ("lux i64 +" 1 count) + ("lux i64 logical-right-shift" 1 remaining)) [count remaining])) (def:''' #export (r// param subject) @@ -2471,13 +2471,13 @@ (-> Rev Rev Rev) (if ("lux i64 =" +0 param) ("lux io error" "Cannot divide Rev by zero!") - (let' [[trailing-zeroes remaining] (without-trailing-zeroes |0 ("lux coerce" Nat param)) + (let' [[trailing-zeroes remaining] (without-trailing-zeroes 0 ("lux coerce" Nat param)) [trailing-zeroes denominator] ("lux check" (#Product Nat Nat) (if ("lux i64 =" +0 trailing-zeroes) - [|1 ("lux i64 logical-right-shift" |1 remaining)] + [1 ("lux i64 logical-right-shift" 1 remaining)] [trailing-zeroes remaining])) - shift ("lux i64 -" trailing-zeroes |64) - numerator ("lux i64 left-shift" shift |1)] + shift ("lux i64 -" trailing-zeroes 64) + numerator ("lux i64 left-shift" shift 1)] ("lux coerce" Rev ("lux int *" ("lux coerce" Int subject) @@ -2507,10 +2507,10 @@ (text$ "Rev(olution) reciprocal of a Nat(ural).")]) (-> Nat Rev) ("lux coerce" Rev - (let' [[trailing-zeroes remaining] (without-trailing-zeroes |0 numerator)] + (let' [[trailing-zeroes remaining] (without-trailing-zeroes 0 numerator)] (n// remaining - ({|0 ("lux coerce" Nat -1) - _ ("lux i64 left-shift" (n/- trailing-zeroes |64) |1)} + ({0 ("lux coerce" Nat -1) + _ ("lux i64 left-shift" (n/- trailing-zeroes 64) 1)} trailing-zeroes))))) (do-template [ ] @@ -2543,26 +2543,26 @@ (def:''' (digit-to-text digit) #Nil (-> Nat Text) - ({|0 "0" - |1 "1" |2 "2" |3 "3" - |4 "4" |5 "5" |6 "6" - |7 "7" |8 "8" |9 "9" + ({0 "0" + 1 "1" 2 "2" 3 "3" + 4 "4" 5 "5" 6 "6" + 7 "7" 8 "8" 9 "9" _ ("lux io error" "undefined")} digit)) (def:''' (nat/encode value) #Nil (-> Nat Text) - ({|0 - "|0" + ({0 + "0" _ (let' [loop ("lux check" (-> Nat Text Text) (function' recur [input output] - (if (n/= |0 input) + (if (n/= 0 input) (text/compose "|" output) - (recur (n// |10 input) - (text/compose (|> input (n/% |10) digit-to-text) + (recur (n// 10 input) + (text/compose (|> input (n/% 10) digit-to-text) output)))))] (loop value ""))} value)) @@ -2600,7 +2600,7 @@ (def:''' (multiple? div n) #Nil (-> Nat Nat Bit) - (|> n (n/% div) (n/= |0))) + (|> n (n/% div) (n/= 0))) (def:''' #export (not x) (list [(tag$ ["lux" "doc"]) @@ -2935,7 +2935,7 @@ #scope-type-vars scope-type-vars} (#Right {#info info #source source #current-module _ #modules modules #scopes scopes #type-context types #host host - #seed (n/+ |1 seed) #expected expected + #seed (n/+ 1 seed) #expected expected #cursor cursor #extensions extensions #scope-type-vars scope-type-vars} (identifier$ ["" ($_ text/compose "__gensym__" prefix (nat/encode seed))]))} @@ -2948,7 +2948,7 @@ (Rec Self [Int (List Self)])")]) ({(#Cons [_ (#Identifier "" name)] (#Cons body #Nil)) - (let' [body' (replace-syntax (list [name (` (#.Apply (~ (make-parameter |1)) (~ (make-parameter |0))))]) + (let' [body' (replace-syntax (list [name (` (#.Apply (~ (make-parameter 1)) (~ (make-parameter 0))))]) (update-parameters body))] (return (list (` (#.Apply .Nothing (#.UnivQ #.Nil (~ body'))))))) @@ -3209,7 +3209,7 @@ (op x y))")]) (case tokens (^ (list [_ (#Tuple bindings)] body)) - (if (multiple? |2 (list/size bindings)) + (if (multiple? 2 (list/size bindings)) (|> bindings as-pairs list/reverse (list/fold (: (-> [Code Code] Code Code) (function' [lr body'] @@ -3573,7 +3573,7 @@ (def: (index-of part text) (-> Text Text (Maybe Nat)) - ("lux text index" text part |0)) + ("lux text index" text part 0)) (def: (last-index-of' part part-size since text) (-> Text Nat Nat Text (Maybe Nat)) @@ -3586,7 +3586,7 @@ (def: (last-index-of part text) (-> Text Text (Maybe Nat)) - (case ("lux text index" text part |0) + (case ("lux text index" text part 0) (#Some since) (last-index-of' part ("lux text size" part) since text) @@ -3635,10 +3635,10 @@ (#Some idx) (list& (default (error! "UNDEFINED") - (clip2 |0 idx input)) + (clip2 0 idx input)) (text/split splitter (default (error! "UNDEFINED") - (clip1 (n/+ |1 idx) input)))))) + (clip1 (n/+ 1 idx) input)))))) (def: (nth idx xs) (All [a] @@ -3648,9 +3648,9 @@ #None (#Cons x xs') - (if (n/= |0 idx) + (if (n/= 0 idx) (#Some x) - (nth (n/- |1 idx) xs') + (nth (n/- 1 idx) xs') ))) (def: (beta-reduce env type) @@ -4132,7 +4132,7 @@ (def: (split at x) (-> Nat Text (Maybe [Text Text])) - (case [(..clip2 |0 at x) (..clip1 at x)] + (case [(..clip2 0 at x) (..clip1 at x)] [(#.Some pre) (#.Some post)] (#.Some [pre post]) @@ -4170,38 +4170,38 @@ (#Some found) (if (n/= ups found) - (count-ups (n/+ |1 ups) input) + (count-ups (n/+ 1 ups) input) ups))) (def: (list/drop amount a+) (All [a] (-> Nat (List a) (List a))) (case [amount a+] - (^or [|0 _] [_ #Nil]) + (^or [0 _] [_ #Nil]) a+ [_ (#Cons _ a+')] - (list/drop (n/- |1 amount) a+'))) + (list/drop (n/- 1 amount) a+'))) (def: (clean-module nested? relative-root module) (-> Bit Text Text (Meta Text)) - (case (count-ups |0 module) - |0 + (case (count-ups 0 module) + 0 (return (if nested? ($_ "lux text concat" relative-root "/" module) module)) ups (let [parts (text/split "/" relative-root)] - (if (n/< (list/size parts) (n/- |1 ups)) + (if (n/< (list/size parts) (n/- 1 ups)) (let [prefix (|> parts list/reverse - (list/drop (n/- |1 ups)) + (list/drop (n/- 1 ups)) list/reverse (interpose "/") text/join) clean (|> module (clip1 ups) (default (error! "UNDEFINED"))) output (case ("lux text size" clean) - |0 prefix + 0 prefix _ ($_ text/compose prefix "/" clean))] (return output)) (fail ($_ text/compose @@ -4545,7 +4545,7 @@ (n/odd? num) \"odd\" ## else-branch \"???\")"} - (if (n/= |0 (n/% |2 (list/size tokens))) + (if (n/= 0 (n/% 2 (list/size tokens))) (fail "cond requires an uneven number of arguments.") (case (list/reverse tokens) (^ (list& else branches')) @@ -4563,14 +4563,14 @@ (All [a] (-> Nat (List a) (List [Nat a]))) (case xs (#Cons x xs') - (#Cons [idx x] (enumerate' (n/+ |1 idx) xs')) + (#Cons [idx x] (enumerate' (n/+ 1 idx) xs')) #Nil #Nil)) (def: (enumerate xs) (All [a] (-> (List a) (List [Nat a]))) - (enumerate' |0 xs)) + (enumerate' 0 xs)) (macro: #export (get@ tokens) {#.doc "## Accesses the value of a record at a given tag. @@ -5176,7 +5176,7 @@ [(def: #export {#.doc } (All [s] (-> (I64 s) (I64 s))) - (|>> ( |1)))] + (|>> ( 1)))] [inc "lux i64 +" "Increment function."] [dec "lux i64 -" "Decrement function."] @@ -5715,7 +5715,7 @@ (-> Bit) (not ( n)))] - [Nat n/even? n/odd? n/% n/= |0 |2] + [Nat n/even? n/odd? n/% n/= 0 2] [Int i/even? i/odd? i/% i/= +0 +2]) (def: (get-scope-type-vars state) @@ -5735,17 +5735,17 @@ #None (#Cons x xs') - (if (n/= |0 idx) + (if (n/= 0 idx) (#Some x) (list-at (dec idx) xs')))) (macro: #export ($ tokens) {#.doc (doc "Allows you to refer to the type-variables in a polymorphic function's type, by their index." - "In the example below, |0 corresponds to the 'a' variable." + "In the example below, 0 corresponds to the 'a' variable." (def: #export (from-list list) (All [a] (-> (List a) (Row a))) (list/fold add - (: (Row ($ |0)) + (: (Row ($ 0)) empty) list)))} (case tokens @@ -5777,7 +5777,7 @@ {#.doc (doc "Allows you to simultaneously bind and de-structure a value." (def: (hash (^@ set [Hash _])) (list/fold (function (_ elem acc) (n/+ (:: Hash hash elem) acc)) - |0 + 0 (to-list set))))} (case tokens (^ (list& [_meta (#Form (list [_ (#Identifier ["" name])] pattern))] body branches)) @@ -5792,7 +5792,7 @@ (macro: #export (^|> tokens) {#.doc (doc "Pipes the value being pattern-matched against prior to binding it to a variable." (case input - (^|> value [inc (n/% |10) (n/max |1)]) + (^|> value [inc (n/% 10) (n/max 1)]) (foo value)))} (case tokens (^ (list& [_meta (#Form (list [_ (#Identifier ["" name])] [_ (#Tuple steps)]))] body branches)) @@ -5947,8 +5947,8 @@ (macro: #export (char tokens compiler) (case tokens (^multi (^ (list [_ (#Text input)])) - (n/= |1 ("lux text size" input))) - (|> ("lux text char" input |0) + (n/= 1 ("lux text size" input))) + (|> ("lux text char" input 0) (default (undefined)) nat$ list [compiler] #Right) @@ -6170,7 +6170,7 @@ (def: to-significand (-> (I64 Any) Frac) - (|>> ("lux i64 logical-right-shift" |11) + (|>> ("lux i64 logical-right-shift" 11) int-to-frac)) (def: rev-denominator Frac (to-significand -1)) @@ -6184,7 +6184,7 @@ (f/% +1.0) (f/* rev-denominator) frac-to-int - ("lux i64 left-shift" |11)))) + ("lux i64 left-shift" 11)))) (def: #export rev-to-frac (-> Rev Frac) diff --git a/stdlib/source/lux/compiler/default/cache.lux b/stdlib/source/lux/compiler/default/cache.lux index 1e264ec08..1770b4a82 100644 --- a/stdlib/source/lux/compiler/default/cache.lux +++ b/stdlib/source/lux/compiler/default/cache.lux @@ -18,7 +18,7 @@ (Format Module) ($_ _.and ## #module-hash - (_.ignore |0) + (_.ignore 0) ## #module-aliases (_.list ..alias) ## #definitions diff --git a/stdlib/source/lux/compiler/default/init.lux b/stdlib/source/lux/compiler/default/init.lux index 4972e75c5..af31e03a4 100644 --- a/stdlib/source/lux/compiler/default/init.lux +++ b/stdlib/source/lux/compiler/default/init.lux @@ -6,20 +6,20 @@ (def: #export (cursor file) (-> Text Cursor) - [file |1 |0]) + [file 1 0]) (def: #export (source file code) (-> Text Text Source) - [(cursor file) |0 code]) + [(cursor file) 0 code]) (def: dummy-source Source - [.dummy-cursor |0 ""]) + [.dummy-cursor 0 ""]) (def: #export type-context Type-Context - {#.ex-counter |0 - #.var-counter |0 + {#.ex-counter 0 + #.var-counter 0 #.var-bindings (list)}) (`` (def: #export info @@ -46,7 +46,7 @@ #.scopes (list) #.type-context ..type-context #.expected #.None - #.seed |0 + #.seed 0 #.scope-type-vars (list) #.extensions [] #.host host}) diff --git a/stdlib/source/lux/compiler/default/name.lux b/stdlib/source/lux/compiler/default/name.lux index 34bcf41eb..ddbf9ee8f 100644 --- a/stdlib/source/lux/compiler/default/name.lux +++ b/stdlib/source/lux/compiler/default/name.lux @@ -36,7 +36,7 @@ (def: #export (normalize name) (-> Text Text) (let [name/size (text.size name)] - (loop [idx |0 + (loop [idx 0 output ""] (if (n/< name/size idx) (recur (inc idx) diff --git a/stdlib/source/lux/compiler/default/phase/analysis.lux b/stdlib/source/lux/compiler/default/phase/analysis.lux index ff540cded..cbd447d46 100644 --- a/stdlib/source/lux/compiler/default/phase/analysis.lux +++ b/stdlib/source/lux/compiler/default/phase/analysis.lux @@ -107,7 +107,7 @@ (n/= (dec size) tag)) (template: #export (no-op value) - (|> |1 #reference.Local #reference.Variable #..Reference + (|> 1 #reference.Local #reference.Variable #..Reference (#..Function (list)) (#..Apply value))) @@ -117,11 +117,11 @@ (let [left (function.constant (|>> #.Left #Sum )) right (|>> #.Right #Sum )] (if (last? size tag) - (if (n/= |1 tag) + (if (n/= 1 tag) (right value) (list/fold left (right value) - (list.n/range |0 (n/- |2 tag)))) + (list.n/range 0 (n/- 2 tag)))) (list/fold left (case value ( (#Sum _)) @@ -129,7 +129,7 @@ _ value) - (list.n/range |0 tag)))))] + (list.n/range 0 tag)))))] [sum-analysis Analysis #Structure no-op] [sum-pattern Pattern #Complex id] @@ -174,7 +174,7 @@ (do-template [ ] [(def: #export ( value) (-> (Maybe (Variant ))) - (loop [lefts |0 + (loop [lefts 0 variantA value] (case variantA ( (#Sum (#.Left valueA))) @@ -238,13 +238,13 @@ (def: fresh-bindings (All [k v] (Bindings k v)) - {#.counter |0 + {#.counter 0 #.mappings (list)}) (def: fresh-scope Scope {#.name (list) - #.inner |0 + #.inner 0 #.locals fresh-bindings #.captured fresh-bindings}) diff --git a/stdlib/source/lux/compiler/default/phase/analysis/case/coverage.lux b/stdlib/source/lux/compiler/default/phase/analysis/case/coverage.lux index 716c11bf1..df09bb0ec 100644 --- a/stdlib/source/lux/compiler/default/phase/analysis/case/coverage.lux +++ b/stdlib/source/lux/compiler/default/phase/analysis/case/coverage.lux @@ -19,11 +19,11 @@ (def: cases (-> (Maybe Nat) Nat) - (|>> (maybe.default |0))) + (|>> (maybe.default 0))) (def: (variant sum-side) (-> (Either Pattern Pattern) (Variant Pattern)) - (loop [lefts |0 + (loop [lefts 0 variantP sum-side] (case variantP (#.Left valueP) diff --git a/stdlib/source/lux/compiler/default/phase/analysis/inference.lux b/stdlib/source/lux/compiler/default/phase/analysis/inference.lux index 1676c0cf7..c96d0457c 100644 --- a/stdlib/source/lux/compiler/default/phase/analysis/inference.lux +++ b/stdlib/source/lux/compiler/default/phase/analysis/inference.lux @@ -70,7 +70,7 @@ (^template [] ( env quantified) ( (list/map (replace parameter-idx replacement) env) - (replace (n/+ |2 parameter-idx) replacement quantified))) + (replace (n/+ 2 parameter-idx) replacement quantified))) ([#.UnivQ] [#.ExQ]) @@ -199,7 +199,7 @@ ## Turns a variant type into the kind of function type suitable for inference. (def: #export (variant tag expected-size inferT) (-> Nat Nat Type (Operation Type)) - (loop [depth |0 + (loop [depth 0 currentT inferT] (case currentT (#.Named name unnamedT) @@ -224,9 +224,9 @@ (n/< boundary tag))) (case (list.nth tag cases) (#.Some caseT) - (operation/wrap (if (n/= |0 depth) + (operation/wrap (if (n/= 0 depth) (type.function (list caseT) currentT) - (let [replace' (replace (|> depth dec (n/* |2)) inferT)] + (let [replace' (replace (|> depth dec (n/* 2)) inferT)] (type.function (list (replace' caseT)) (replace' currentT))))) @@ -238,9 +238,9 @@ (n/= boundary tag) (let [caseT (type.variant (list.drop boundary cases))] - (operation/wrap (if (n/= |0 depth) + (operation/wrap (if (n/= 0 depth) (type.function (list caseT) currentT) - (let [replace' (replace (|> depth dec (n/* |2)) inferT)] + (let [replace' (replace (|> depth dec (n/* 2)) inferT)] (type.function (list (replace' caseT)) (replace' currentT)))))) diff --git a/stdlib/source/lux/compiler/default/phase/analysis/scope.lux b/stdlib/source/lux/compiler/default/phase/analysis/scope.lux index 6b6896674..2c34e7a44 100644 --- a/stdlib/source/lux/compiler/default/phase/analysis/scope.lux +++ b/stdlib/source/lux/compiler/default/phase/analysis/scope.lux @@ -43,7 +43,7 @@ (def: (captured name scope) (-> Text Scope (Maybe [Type Variable])) - (loop [idx |0 + (loop [idx 0 mappings (get@ [#.captured #.mappings] scope)] (case mappings #.Nil @@ -133,7 +133,7 @@ (do-template [ ] [(def: (Bindings Text [Type ]) - {#.counter |0 + {#.counter 0 #.mappings (list)})] [init-locals Nat] @@ -143,7 +143,7 @@ (def: (scope parent-name child-name) (-> (List Text) Text Scope) {#.name (list& child-name parent-name) - #.inner |0 + #.inner 0 #.locals init-locals #.captured init-captured}) diff --git a/stdlib/source/lux/compiler/default/phase/analysis/structure.lux b/stdlib/source/lux/compiler/default/phase/analysis/structure.lux index 29203290a..f894679ef 100644 --- a/stdlib/source/lux/compiler/default/phase/analysis/structure.lux +++ b/stdlib/source/lux/compiler/default/phase/analysis/structure.lux @@ -312,7 +312,7 @@ _ (if (n/= size-ts size-record) (wrap []) (///.throw record-size-mismatch [size-ts size-record recordT record])) - #let [tuple-range (list.n/range |0 (dec size-ts)) + #let [tuple-range (list.n/range 0 (dec size-ts)) tag->idx (dict.from-list name.Hash (list.zip2 tag-set tuple-range))] idx->val (monad.fold @ (function (_ [key val] idx->val) diff --git a/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux b/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux index d5ff4a085..d4e94a36f 100644 --- a/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux +++ b/stdlib/source/lux/compiler/default/phase/extension/analysis/common.lux @@ -82,7 +82,7 @@ (wrap (#analysis.Extension extension-name (list opA)))) _ - (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 1 (list.size args)])))) (def: lux::in-module Handler @@ -108,7 +108,7 @@ ## (analyse valueC))) ## _ -## (////.throw bundle.incorrect-arity [extension-name |2 (list.size args)]))))] +## (////.throw bundle.incorrect-arity [extension-name 2 (list.size args)]))))] ## [lux::check (:coerce Type actualT)] ## [lux::coerce Any] @@ -126,7 +126,7 @@ (wrap valueA)) _ - (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 1 (list.size args)])))) (def: bundle::lux Bundle @@ -275,7 +275,7 @@ (wrap (#analysis.Extension extension-name (list initA)))) _ - (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 1 (list.size args)])))) (def: atom::read Handler @@ -315,7 +315,7 @@ (wrap (#analysis.Extension extension-name (list initA)))) _ - (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 1 (list.size args)])))) (def: box::read Handler diff --git a/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux b/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux index 9e4cd2e7e..706d35e51 100644 --- a/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux +++ b/stdlib/source/lux/compiler/default/phase/extension/analysis/host.jvm.lux @@ -231,7 +231,7 @@ (wrap (#analysis.Extension extension-name (list arrayA)))) _ - (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 1 (list.size args)])))) (def: array::new Handler @@ -244,7 +244,7 @@ expectedT (///.lift macro.expected-type) [level elem-class] (: (Operation [Nat Text]) (loop [analysisT expectedT - level |0] + level 0] (case analysisT (#.Apply inputT funcT) (case (type.apply (list inputT) funcT) @@ -262,7 +262,7 @@ _ (////.throw non-array expectedT)))) - _ (if (n/> |0 level) + _ (if (n/> 0 level) (wrap []) (////.throw non-array expectedT))] (wrap (#analysis.Extension extension-name (list (analysis.nat (dec level)) @@ -270,7 +270,7 @@ lengthA)))) _ - (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 1 (list.size args)])))) (def: (check-jvm objectT) (-> Type (Operation Text)) @@ -344,7 +344,7 @@ (wrap (#analysis.Extension extension-name (list (analysis.text elem-class) idxA arrayA)))) _ - (////.throw bundle.incorrect-arity [extension-name |2 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 2 (list.size args)])))) (def: array::write Handler @@ -366,7 +366,7 @@ (wrap (#analysis.Extension extension-name (list (analysis.text elem-class) idxA valueA arrayA)))) _ - (////.throw bundle.incorrect-arity [extension-name |3 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 3 (list.size args)])))) (def: bundle::array Bundle @@ -389,7 +389,7 @@ (wrap (#analysis.Extension extension-name (list)))) _ - (////.throw bundle.incorrect-arity [extension-name |0 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 0 (list.size args)])))) (def: object::null? Handler @@ -404,7 +404,7 @@ (wrap (#analysis.Extension extension-name (list objectA)))) _ - (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 1 (list.size args)])))) (def: object::synchronized Handler @@ -419,7 +419,7 @@ (wrap (#analysis.Extension extension-name (list monitorA exprA)))) _ - (////.throw bundle.incorrect-arity [extension-name |2 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 2 (list.size args)])))) (host.import: java/lang/Object (equals [Object] boolean)) @@ -516,7 +516,7 @@ (wrap (#analysis.Extension extension-name (list exceptionA)))) _ - (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 1 (list.size args)])))) (def: object::class Handler @@ -534,7 +534,7 @@ (////.throw bundle.invalid-syntax extension-name)) _ - (////.throw bundle.incorrect-arity [extension-name |1 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 1 (list.size args)])))) (def: object::instance? Handler @@ -557,7 +557,7 @@ (////.throw bundle.invalid-syntax extension-name)) _ - (////.throw bundle.incorrect-arity [extension-name |2 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 2 (list.size args)])))) (def: (java-type-to-class jvm-type) (-> java/lang/reflect/Type (Operation Text)) @@ -588,8 +588,8 @@ (host.instance? WildcardType java-type) (let [java-type (:coerce WildcardType java-type)] - (case [(array.read |0 (WildcardType::getUpperBounds [] java-type)) - (array.read |0 (WildcardType::getLowerBounds [] java-type))] + (case [(array.read 0 (WildcardType::getUpperBounds [] java-type)) + (array.read 0 (WildcardType::getLowerBounds [] java-type))] (^or [(#.Some bound) _] [_ (#.Some bound)]) (java-type-to-lux-type mappings bound) @@ -600,13 +600,13 @@ (let [java-type (:coerce (Class Object) java-type) class-name (Class::getName [] java-type)] (operation/wrap (case (array.size (Class::getTypeParameters [] java-type)) - |0 + 0 (#.Primitive class-name (list)) arity - (|> (list.n/range |0 (dec arity)) + (|> (list.n/range 0 (dec arity)) list.reverse - (list/map (|>> (n/* |2) inc #.Parameter)) + (list/map (|>> (n/* 2) inc #.Parameter)) (#.Primitive class-name) (type.univ-q arity))))) @@ -831,7 +831,7 @@ (////.throw bundle.invalid-syntax extension-name)) _ - (////.throw bundle.incorrect-arity [extension-name |2 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 2 (list.size args)])))) (def: static::put Handler @@ -853,7 +853,7 @@ (////.throw bundle.invalid-syntax extension-name)) _ - (////.throw bundle.incorrect-arity [extension-name |3 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 3 (list.size args)])))) (def: virtual::get Handler @@ -872,7 +872,7 @@ (////.throw bundle.invalid-syntax extension-name)) _ - (////.throw bundle.incorrect-arity [extension-name |3 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 3 (list.size args)])))) (def: virtual::put Handler @@ -896,7 +896,7 @@ (////.throw bundle.invalid-syntax extension-name)) _ - (////.throw bundle.incorrect-arity [extension-name |4 (list.size args)])))) + (////.throw bundle.incorrect-arity [extension-name 4 (list.size args)])))) (def: (java-type-to-parameter type) (-> java/lang/reflect/Type (Operation Text)) @@ -970,11 +970,11 @@ (def: idx-to-parameter (-> Nat Type) - (|>> (n/* |2) inc #.Parameter)) + (|>> (n/* 2) inc #.Parameter)) (def: (type-vars amount offset) (-> Nat Nat (List Type)) - (if (n/= |0 amount) + (if (n/= 0 amount) (list) (|> (list.n/range offset (|> amount dec (n/+ offset))) (list/map idx-to-parameter)))) @@ -998,7 +998,7 @@ num-method-tvars (list.size method-tvars) all-tvars (list/compose owner-tvars method-tvars) num-all-tvars (list.size all-tvars) - owner-tvarsT (type-vars num-owner-tvars |0) + owner-tvarsT (type-vars num-owner-tvars 0) method-tvarsT (type-vars num-method-tvars num-owner-tvars) mappings (: Mappings (if (list.empty? all-tvars) @@ -1086,7 +1086,7 @@ num-owner-tvars (list.size owner-tvars) all-tvars (list/compose owner-tvars constructor-tvars) num-all-tvars (list.size all-tvars) - owner-tvarsT (type-vars num-owner-tvars |0) + owner-tvarsT (type-vars num-owner-tvars 0) constructor-tvarsT (type-vars num-all-tvars num-owner-tvars) mappings (: Mappings (if (list.empty? all-tvars) diff --git a/stdlib/source/lux/compiler/default/phase/synthesis.lux b/stdlib/source/lux/compiler/default/phase/synthesis.lux index 28392eafd..1dbbffd84 100644 --- a/stdlib/source/lux/compiler/default/phase/synthesis.lux +++ b/stdlib/source/lux/compiler/default/phase/synthesis.lux @@ -25,10 +25,10 @@ (def: #export init State - {#scope-arity |0 + {#scope-arity 0 #resolver fresh-resolver #direct? #0 - #locals |0}) + #locals 0}) (type: #export Primitive (#Bit Bit) diff --git a/stdlib/source/lux/compiler/default/phase/synthesis/expression.lux b/stdlib/source/lux/compiler/default/phase/synthesis/expression.lux index 0ab38afac..241896e58 100644 --- a/stdlib/source/lux/compiler/default/phase/synthesis/expression.lux +++ b/stdlib/source/lux/compiler/default/phase/synthesis/expression.lux @@ -67,11 +67,11 @@ (do @ [arity //.scope-arity] (wrap (if (function.nested? arity) - (if (n/= |0 register) + (if (n/= 0 register) (|> (dec arity) - (list.n/range |1) + (list.n/range 1) (list/map (|>> //.variable/local)) - [(//.variable/local |0)] + [(//.variable/local 0)] //.function/apply) (#//.Reference (#reference.Variable (function.adjust arity #0 var)))) (#//.Reference (#reference.Variable var))))) diff --git a/stdlib/source/lux/compiler/default/phase/synthesis/function.lux b/stdlib/source/lux/compiler/default/phase/synthesis/function.lux index b7dd22f70..eadcd52b0 100644 --- a/stdlib/source/lux/compiler/default/phase/synthesis/function.lux +++ b/stdlib/source/lux/compiler/default/phase/synthesis/function.lux @@ -20,7 +20,7 @@ (def: #export nested? (-> Arity Bit) - (n/> |1)) + (n/> 1)) (def: #export (adjust up-arity after? var) (-> Arity Bit Variable Variable) @@ -90,7 +90,7 @@ resolver //.resolver #let [function-arity (if direct? (inc arity) - |1) + 1) up-environment (if (nested? arity) (list/map (.function (_ closure) (case (dict.get closure resolver) @@ -107,7 +107,7 @@ (list) _ - (|> (list.size environment) dec (list.n/range |0) + (|> (list.size environment) dec (list.n/range 0) (list/map (|>> #reference.Foreign))))) resolver' (if (and (nested? function-arity) direct?) @@ -129,6 +129,6 @@ ..return)) _ - (|> (prepare function-arity |1 bodyS) - (maybe/map (|>> [up-environment |1] //.function/abstraction)) + (|> (prepare function-arity 1 bodyS) + (maybe/map (|>> [up-environment 1] //.function/abstraction)) ..return)))) diff --git a/stdlib/source/lux/compiler/default/phase/synthesis/loop.lux b/stdlib/source/lux/compiler/default/phase/synthesis/loop.lux index 4bae596c3..e7db982d8 100644 --- a/stdlib/source/lux/compiler/default/phase/synthesis/loop.lux +++ b/stdlib/source/lux/compiler/default/phase/synthesis/loop.lux @@ -27,7 +27,7 @@ #.None #0)) (template: #export (self) - (#//.Reference (reference.local |0))) + (#//.Reference (reference.local 0))) (template: (recursive-apply args) (#//.Apply (self) args)) diff --git a/stdlib/source/lux/compiler/default/phase/translation.lux b/stdlib/source/lux/compiler/default/phase/translation.lux index ec67565d6..f9d61c4af 100644 --- a/stdlib/source/lux/compiler/default/phase/translation.lux +++ b/stdlib/source/lux/compiler/default/phase/translation.lux @@ -76,12 +76,12 @@ (-> (Host expression statement) (..State anchor expression statement))) {#context {#scope-name "" - #inner-functions |0} + #inner-functions 0} #anchor #.None #host host #buffer #.None #artifacts (dict.new text.Hash) - #counter |0}) + #counter 0}) (def: #export (with-context expr) (All [anchor expression statement output] @@ -90,7 +90,7 @@ (function (_ [bundle state]) (let [[old-scope old-inner] (get@ #context state) new-scope (format old-scope "c___" (%i (.int old-inner)))] - (case (expr [bundle (set@ #context [new-scope |0] state)]) + (case (expr [bundle (set@ #context [new-scope 0] state)]) (#error.Success [[bundle' state'] output]) (#error.Success [[bundle' (set@ #context [old-scope (inc old-inner)] state')] [new-scope output]]) diff --git a/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux b/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux index b1dce6688..9952a754d 100644 --- a/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux +++ b/stdlib/source/lux/compiler/default/phase/translation/scheme/extension/common.jvm.lux @@ -30,10 +30,10 @@ (syntax: (Vector {size s.nat} elemT) (wrap (list (` [(~+ (list.repeat size elemT))])))) -(type: #export Nullary (-> (Vector |0 Expression) Computation)) -(type: #export Unary (-> (Vector |1 Expression) Computation)) -(type: #export Binary (-> (Vector |2 Expression) Computation)) -(type: #export Trinary (-> (Vector |3 Expression) Computation)) +(type: #export Nullary (-> (Vector 0 Expression) Computation)) +(type: #export Unary (-> (Vector 1 Expression) Computation)) +(type: #export Binary (-> (Vector 2 Expression) Computation)) +(type: #export Trinary (-> (Vector 3 Expression) Computation)) (type: #export Variadic (-> (List Expression) Computation)) ## [Utils] @@ -55,12 +55,12 @@ ((~' wrap) ((~ g!extension) [(~+ g!input+)]))) (~' _) - (/////.throw bundle.incorrect-arity [(~ g!name) |1 (list.size (~ g!inputs))])))))))))) + (/////.throw bundle.incorrect-arity [(~ g!name) 1 (list.size (~ g!inputs))])))))))))) -(arity: nullary |0) -(arity: unary |1) -(arity: binary |2) -(arity: trinary |3) +(arity: nullary 0) +(arity: unary 1) +(arity: binary 2) +(arity: trinary 3) (def: #export (variadic extension) (-> Variadic Handler) diff --git a/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux b/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux index bf65a7606..d4316a0b5 100644 --- a/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux +++ b/stdlib/source/lux/compiler/default/phase/translation/scheme/function.jvm.lux @@ -70,8 +70,8 @@ (_.letrec (list [@function (_.lambda [(list) (#.Some @curried)] (_.let (list [@num-args (_.length/1 @curried)]) (<| (_.if (|> @num-args (_.=/2 arityO)) - (<| (_.let (list [(reference.local' |0) @function])) - (_.let-values (list [[(|> (list.n/range |0 (dec arity)) + (<| (_.let (list [(reference.local' 0) @function])) + (_.let-values (list [[(|> (list.n/range 0 (dec arity)) (list/map ..input)) #.None] (_.apply/2 (_.global "apply") (_.global "values") @curried)])) diff --git a/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux b/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux index d72312693..2ec83227d 100644 --- a/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux +++ b/stdlib/source/lux/compiler/default/phase/translation/scheme/runtime.jvm.lux @@ -58,19 +58,19 @@ (def: #export none Computation - (variant [|0 #0 ..unit])) + (variant [0 #0 ..unit])) (def: #export some (-> Expression Computation) - (|>> [|0 #1] ..variant)) + (|>> [0 #1] ..variant)) (def: #export left (-> Expression Computation) - (|>> [|0 #0] ..variant)) + (|>> [0 #0] ..variant)) (def: #export right (-> Expression Computation) - (|>> [|0 #1] ..variant)) + (|>> [0 #1] ..variant)) (def: declaration (s.Syntax [Text (List Text)]) diff --git a/stdlib/source/lux/compiler/default/reference.lux b/stdlib/source/lux/compiler/default/reference.lux index 1c94c0349..0bbeb2db5 100644 --- a/stdlib/source/lux/compiler/default/reference.lux +++ b/stdlib/source/lux/compiler/default/reference.lux @@ -31,10 +31,10 @@ (def: (hash var) (case var (#Local register) - (n/* |1 register) + (n/* 1 register) (#Foreign register) - (n/* |2 register)))) + (n/* 2 register)))) (do-template [ ] [(template: #export ( content) @@ -55,12 +55,12 @@ [constant #..Constant] ) -(def: #export self Reference (..local |0)) +(def: #export self Reference (..local 0)) (def: #export self? (-> Variable Bit) (|>> ..variable - (case> (^ (..local |0)) + (case> (^ (..local 0)) #1 _ diff --git a/stdlib/source/lux/compiler/default/repl/type.lux b/stdlib/source/lux/compiler/default/repl/type.lux index e6d25a76a..212c5bcb9 100644 --- a/stdlib/source/lux/compiler/default/repl/type.lux +++ b/stdlib/source/lux/compiler/default/repl/type.lux @@ -110,7 +110,7 @@ (n/= num-tags (list.size casesR+)))] (wrap (function (_ variantV) (loop [cases-left (list.zip3 tags - (list.n/range |0 (dec num-tags)) + (list.n/range 0 (dec num-tags)) casesR+) variantV variantV] (case cases-left diff --git a/stdlib/source/lux/compiler/default/syntax.lux b/stdlib/source/lux/compiler/default/syntax.lux index f88cedc9b..0497f55a2 100644 --- a/stdlib/source/lux/compiler/default/syntax.lux +++ b/stdlib/source/lux/compiler/default/syntax.lux @@ -64,7 +64,7 @@ [content (l.many (l.one-of new-line))] (wrap [(|> where (update@ #.line (n/+ (text.size content))) - (set@ #.column |0)) + (set@ #.column 0)) content])) )) @@ -78,7 +78,7 @@ _ (l.this new-line)] (wrap [(|> where (update@ #.line inc) - (set@ #.column |0)) + (set@ #.column 0)) comment]))) ## This is just a helper parser to find text which doesn't run into @@ -100,7 +100,7 @@ (do p.Monad [_ (l.this "#(")] (loop [comment "" - where (update@ #.column (n/+ |2) where)] + where (update@ #.column (n/+ 2) where)] ($_ p.either ## These are normal chunks of commented text. (do @ @@ -115,7 +115,7 @@ (recur (format comment new-line) (|> where (update@ #.line inc) - (set@ #.column |0)))) + (set@ #.column 0)))) ## This is the rule for handling nested sub-comments. ## Ultimately, the whole comment is just treated as text ## (the comment must respect the syntax structure, but the @@ -129,7 +129,7 @@ ## Finally, this is the rule for closing the comment. (do @ [_ (l.this ")#")] - (wrap [(update@ #.column (n/+ |2) where) + (wrap [(update@ #.column (n/+ 2) where) comment])) )))) @@ -171,22 +171,22 @@ [code l.any] (case code ## Handle special cases. - "t" (wrap [|2 "\t"]) - "v" (wrap [|2 "\v"]) - "b" (wrap [|2 "\b"]) - "n" (wrap [|2 "\n"]) - "r" (wrap [|2 "\r"]) - "f" (wrap [|2 "\f"]) - "\"" (wrap [|2 "\""]) - "\\" (wrap [|2 "\\"]) + "t" (wrap [2 "\t"]) + "v" (wrap [2 "\v"]) + "b" (wrap [2 "\b"]) + "n" (wrap [2 "\n"]) + "r" (wrap [2 "\r"]) + "f" (wrap [2 "\f"]) + "\"" (wrap [2 "\""]) + "\\" (wrap [2 "\\"]) ## Handle unicode escapes. "u" (do p.Monad - [code (l.between |1 |4 l.hexadecimal)] + [code (l.between 1 4 l.hexadecimal)] (wrap (case (|> code (format "+") (:: number.Hex@Codec decode)) (#.Right value) - [(n/+ |2 (text.size code)) (text.from-code value)] + [(n/+ 2 (text.size code)) (text.from-code value)] _ (undefined)))) @@ -251,7 +251,7 @@ (update@ #.column (n/+ chars-consumed))) char])))) _ (l.this "\"") - #let [char (maybe.assume (text.nth |0 char))]] + #let [char (maybe.assume (text.nth 0 char))]] (wrap [(|> where' (update@ #.column inc)) [where (#.Nat char)]]))) @@ -412,7 +412,7 @@ (recur (format text-read new-line) (|> where (update@ #.line inc) - (set@ #.column |0)) + (set@ #.column 0)) #1)))))] (wrap [where' [where (#.Text text-read)]]))) @@ -529,7 +529,7 @@ [_ (l.this current-module-mark) def-name name-part^] (wrap [[current-module def-name] - (n/+ |2 (text.size def-name))])) + (n/+ 2 (text.size def-name))])) ## If the name is prefixed by the mark, but no module ## part, the module is assumed to be "lux" (otherwise known as ## the 'prelude'). @@ -559,7 +559,7 @@ second-part] ($_ n/+ (text.size first-part) - |1 + 1 (text.size second-part))])) (wrap [["" first-part] (text.size first-part)]))))) @@ -569,7 +569,7 @@ (do p.Monad [[value length] (p.after (l.this "#") (name^ current-module aliases))] - (wrap [(update@ #.column (|>> ($_ n/+ |1 length)) where) + (wrap [(update@ #.column (|>> ($_ n/+ 1 length)) where) [where (#.Tag value)]]))) (def: #export (identifier current-module aliases where) diff --git a/stdlib/source/lux/compiler/meta/io/archive.lux b/stdlib/source/lux/compiler/meta/io/archive.lux index 27c7416f0..1f0714b25 100644 --- a/stdlib/source/lux/compiler/meta/io/archive.lux +++ b/stdlib/source/lux/compiler/meta/io/archive.lux @@ -67,7 +67,7 @@ (#.Some ["" post]) (let [raw (text.replace-all (:: System separator) "/" post)] (if (text.starts-with? "/" raw) - (text.clip' |1 raw) + (text.clip' 1 raw) (#.Some raw))) _ diff --git a/stdlib/source/lux/concurrency/actor.lux b/stdlib/source/lux/concurrency/actor.lux index da76351c4..f6a6fbe0d 100644 --- a/stdlib/source/lux/concurrency/actor.lux +++ b/stdlib/source/lux/concurrency/actor.lux @@ -335,11 +335,11 @@ (if (list.empty? actor-vars) (list) (|> actor-vars list.size dec - (list.n/range |0) (list/map (|>> code.nat (~) ($) (`)))))) + (list.n/range 0) (list/map (|>> code.nat (~) ($) (`)))))) ref-replacements (|> (if (list.empty? actor-vars) (list) (|> actor-vars list.size dec - (list.n/range |0) (list/map (|>> code.nat (~) ($) (`))))) + (list.n/range 0) (list/map (|>> code.nat (~) ($) (`))))) (: (List Code)) (list.zip2 g!all-vars) (: (List [Code Code]))) diff --git a/stdlib/source/lux/concurrency/promise.lux b/stdlib/source/lux/concurrency/promise.lux index 6e2450068..7062c2082 100644 --- a/stdlib/source/lux/concurrency/promise.lux +++ b/stdlib/source/lux/concurrency/promise.lux @@ -155,7 +155,7 @@ (def: #export future {#.doc "Runs an I/O computation on its own process and returns a Promise that will eventually host its result."} (All [a] (-> (IO a) (Promise a))) - (schedule |0)) + (schedule 0)) (def: #export (delay time-millis value) {#.doc "Delivers a value after a certain period has passed."} diff --git a/stdlib/source/lux/concurrency/semaphore.lux b/stdlib/source/lux/concurrency/semaphore.lux index 5b1688048..7b749ea60 100644 --- a/stdlib/source/lux/concurrency/semaphore.lux +++ b/stdlib/source/lux/concurrency/semaphore.lux @@ -33,8 +33,8 @@ [state (atom.read semaphore) #let [[ready? state'] (: [Bit State] (case (get@ #open-positions state) - |0 [#0 (update@ #waiting-list (|>> (#.Cons signal)) - state)] + 0 [#0 (update@ #waiting-list (|>> (#.Cons signal)) + state)] _ [#1 (update@ #open-positions dec state)]))] success? (atom.compare-and-swap state state' semaphore) @@ -79,7 +79,7 @@ (def: #export (mutex _) (-> Any Mutex) - (:abstraction (semaphore |1))) + (:abstraction (semaphore 1))) (def: (acquire mutex) (-> Mutex (Promise Any)) @@ -98,7 +98,7 @@ (wrap output))) ) -(def: #export limit (refinement.refinement (n/> |0))) +(def: #export limit (refinement.refinement (n/> 0))) (`` (type: #export Limit (~~ (refinement.type limit)))) (abstract: #export Barrier @@ -112,13 +112,13 @@ (def: #export (barrier limit) (-> Limit Barrier) (:abstraction {#limit limit - #count (atom.atom |0) - #start-turnstile (semaphore |0) - #end-turnstile (semaphore |0)})) + #count (atom.atom 0) + #start-turnstile (semaphore 0) + #end-turnstile (semaphore 0)})) (def: (un-block times turnstile) (-> Nat Semaphore (Promise Any)) - (loop [step |0] + (loop [step 0] (if (n/< times step) (do promise.Monad [_ (signal turnstile)] @@ -138,7 +138,7 @@ (wait (get@ barrier))))] [start inc limit #start-turnstile] - [end dec |0 #end-turnstile] + [end dec 0 #end-turnstile] ) (def: #export (block barrier) diff --git a/stdlib/source/lux/control/comonad.lux b/stdlib/source/lux/control/comonad.lux index 7efe24942..23a059ae4 100644 --- a/stdlib/source/lux/control/comonad.lux +++ b/stdlib/source/lux/control/comonad.lux @@ -26,7 +26,7 @@ [a (F (CoFree F a))]) ## [Syntax] -(def: _cursor Cursor ["" |0 |0]) +(def: _cursor Cursor ["" 0 0]) (macro: #export (be tokens state) {#.doc (doc "A co-monadic parallel to the \"do\" macro." @@ -36,7 +36,7 @@ (square (head inputs)))))} (case tokens (#.Cons comonad (#.Cons [_ (#.Tuple bindings)] (#.Cons body #.Nil))) - (if (|> bindings list.size (n/% |2) (n/= |0)) + (if (|> bindings list.size (n/% 2) (n/= 0)) (let [g!_ (: Code [_cursor (#.Identifier ["" " _ "])]) g!map (: Code [_cursor (#.Identifier ["" " map "])]) g!split (: Code [_cursor (#.Identifier ["" " split "])]) diff --git a/stdlib/source/lux/control/concatenative.lux b/stdlib/source/lux/control/concatenative.lux index 47c3ea4ca..0011c8956 100644 --- a/stdlib/source/lux/control/concatenative.lux +++ b/stdlib/source/lux/control/concatenative.lux @@ -129,7 +129,7 @@ (~ type) (|>> (~+ (list/map prepare commands)))))))) -(syntax: #export (apply {arity (|> s.nat (p.filter (.n/> |0)))}) +(syntax: #export (apply {arity (|> s.nat (p.filter (.n/> 0)))}) (with-gensyms [g! g!func g!stack g!output] (monad.do @ [g!inputs (|> (macro.gensym "input") (list.repeat arity) (monad.seq @))] @@ -141,14 +141,14 @@ [(~ g!stack) ((~ g!func) (~+ g!inputs))]))))))))) ## [Primitives] -(def: #export apply1 (apply |1)) -(def: #export apply2 (apply |2)) -(def: #export apply3 (apply |3)) -(def: #export apply4 (apply |4)) -(def: #export apply5 (apply |5)) -(def: #export apply6 (apply |6)) -(def: #export apply7 (apply |7)) -(def: #export apply8 (apply |8)) +(def: #export apply1 (apply 1)) +(def: #export apply2 (apply 2)) +(def: #export apply3 (apply 3)) +(def: #export apply4 (apply 4)) +(def: #export apply5 (apply 5)) +(def: #export apply6 (apply 6)) +(def: #export apply7 (apply 7)) +(def: #export apply8 (apply 8)) (def: #export (push x) (All [a] (-> a (=> [] [a]))) @@ -193,12 +193,12 @@ (def: #export ||L (All [a b] (=> [a] [(| a b)])) (function (_ [stack l]) - [stack (|0 l)])) + [stack (0 l)])) (def: #export ||R (All [a b] (=> [b] [(| a b)])) (function (_ [stack r]) - [stack (|1 r)])) + [stack (1 r)])) (do-template [ ] [(def: #export diff --git a/stdlib/source/lux/control/equivalence.lux b/stdlib/source/lux/control/equivalence.lux index 5f9ca37b6..c10b0c295 100644 --- a/stdlib/source/lux/control/equivalence.lux +++ b/stdlib/source/lux/control/equivalence.lux @@ -15,10 +15,10 @@ (All [l r] (-> (Equivalence l) (Equivalence r) (Equivalence (| l r)))) (structure (def: (= a|b x|y) (case [a|b x|y] - [(|0 a) (|0 x)] + [(0 a) (0 x)] (:: left = a x) - [(|1 b) (|1 y)] + [(1 b) (1 y)] (:: right = b y) _ diff --git a/stdlib/source/lux/control/exception.lux b/stdlib/source/lux/control/exception.lux index 66c7ebf7b..d2e9c705d 100644 --- a/stdlib/source/lux/control/exception.lux +++ b/stdlib/source/lux/control/exception.lux @@ -116,7 +116,7 @@ (-> (List [Text Text]) Text) (let [largest-header-size (|> entries (list/map (|>> product.left text.size)) - (list/fold n/max |0))] + (list/fold n/max 0))] (|> entries (list/map (function (_ [header message]) (let [padding (|> " " diff --git a/stdlib/source/lux/control/monad.lux b/stdlib/source/lux/control/monad.lux index e3196faf5..36b2354fc 100644 --- a/stdlib/source/lux/control/monad.lux +++ b/stdlib/source/lux/control/monad.lux @@ -16,7 +16,7 @@ (def: (list/size xs) (All [a] (-> (List a) Nat)) - (loop [counter |0 + (loop [counter 0 xs xs] (case xs #.Nil @@ -53,7 +53,7 @@ join)) ## [Syntax] -(def: _cursor Cursor ["" |0 |0]) +(def: _cursor Cursor ["" 0 0]) (macro: #export (do tokens state) {#.doc (doc "Macro for easy concatenation of monadic operations." @@ -63,7 +63,7 @@ (wrap (f3 z))))} (case tokens (#.Cons monad (#.Cons [_ (#.Tuple bindings)] (#.Cons body #.Nil))) - (if (|> bindings list/size (n/% |2) (n/= |0)) + (if (|> bindings list/size (n/% 2) (n/= 0)) (let [g!_ (: Code [_cursor (#.Identifier ["" " _ "])]) g!map (: Code [_cursor (#.Identifier ["" " map "])]) g!join (: Code [_cursor (#.Identifier ["" " join "])]) diff --git a/stdlib/source/lux/control/parser.lux b/stdlib/source/lux/control/parser.lux index 48119eaa5..c40de3373 100644 --- a/stdlib/source/lux/control/parser.lux +++ b/stdlib/source/lux/control/parser.lux @@ -119,11 +119,11 @@ (-> (Parser s a) (Parser s b) (Parser s (| a b)))) (function (_ tokens) (case (p1 tokens) - (#e.Success [tokens' x1]) (#e.Success [tokens' (|0 x1)]) + (#e.Success [tokens' x1]) (#e.Success [tokens' (0 x1)]) (#e.Error _) (run tokens (do Monad [x2 p2] - (wrap (|1 x2)))) + (wrap (1 x2)))) ))) (def: #export (either pl pr) @@ -139,7 +139,7 @@ (def: #export (exactly n p) {#.doc "Parse exactly N times."} (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) - (if (n/> |0 n) + (if (n/> 0 n) (do Monad [x p xs (exactly (dec n) p)] @@ -157,7 +157,7 @@ (def: #export (at-most n p) {#.doc "Parse at most N times."} (All [s a] (-> Nat (Parser s a) (Parser s (List a)))) - (if (n/> |0 n) + (if (n/> 0 n) (function (_ input) (case (p input) (#e.Error msg) diff --git a/stdlib/source/lux/control/pipe.lux b/stdlib/source/lux/control/pipe.lux index a9a97b0c9..c23723f6d 100644 --- a/stdlib/source/lux/control/pipe.lux +++ b/stdlib/source/lux/control/pipe.lux @@ -16,7 +16,7 @@ (Syntax (List Code)) (s.tuple (p.some s.any))) -(syntax: #export (new> {tokens (p.at-least |2 s.any)}) +(syntax: #export (new> {tokens (p.at-least 2 s.any)}) {#.doc (doc "Ignores the piped argument, and begins a new pipe." (|> +20 (i/* +3) diff --git a/stdlib/source/lux/control/writer.lux b/stdlib/source/lux/control/writer.lux index fc964537c..4007cb6cb 100644 --- a/stdlib/source/lux/control/writer.lux +++ b/stdlib/source/lux/control/writer.lux @@ -60,7 +60,7 @@ (def: (join MlMla) (do Monad [## TODO: Remove once new-luxc is the standard compiler. - [l1 Mla] (: (($ |1) (Writer ($ |0) (($ |1) (Writer ($ |0) ($ |2))))) + [l1 Mla] (: (($ 1) (Writer ($ 0) (($ 1) (Writer ($ 0) ($ 2))))) MlMla) ## [l1 Mla] MlMla [l2 a] Mla] diff --git a/stdlib/source/lux/data/bit.lux b/stdlib/source/lux/data/bit.lux index 8b61d8b32..026f8bcab 100644 --- a/stdlib/source/lux/data/bit.lux +++ b/stdlib/source/lux/data/bit.lux @@ -18,8 +18,8 @@ (def: eq Equivalence) (def: (hash value) (case value - #1 |1 - #0 |0))) + #1 1 + #0 0))) (do-template [ ] [(structure: #export (Monoid Bit) diff --git a/stdlib/source/lux/data/collection/array.lux b/stdlib/source/lux/data/collection/array.lux index 588c5132b..1d64511a9 100644 --- a/stdlib/source/lux/data/collection/array.lux +++ b/stdlib/source/lux/data/collection/array.lux @@ -38,7 +38,7 @@ (All [a] (-> Nat Nat (Array a) Nat (Array a) (Array a))) - (if (n/= |0 length) + (if (n/= 0 length) dest-array (list/fold (function (_ offset target) (case (read (n/+ offset src-start) src-array) @@ -48,7 +48,7 @@ (#.Some value) (write (n/+ offset dest-start) value target))) dest-array - (list.n/range |0 (dec length))))) + (list.n/range 0 (dec length))))) (def: #export (occupied array) {#.doc "Finds out how many cells in an array are occupied."} @@ -60,7 +60,7 @@ (#.Some _) (inc count))) - |0 + 0 (list.indices (size array)))) (def: #export (vacant array) @@ -87,7 +87,7 @@ (All [a] (-> (-> a Bit) (Array a) (Maybe a))) (let [arr-size (size xs)] - (loop [idx |0] + (loop [idx 0] (if (n/< arr-size idx) (case (read idx xs) #.None @@ -104,7 +104,7 @@ (All [a] (-> (-> Nat a Bit) (Array a) (Maybe [Nat a]))) (let [arr-size (size xs)] - (loop [idx |0] + (loop [idx 0] (if (n/< arr-size idx) (case (read idx xs) #.None @@ -133,10 +133,10 @@ (All [a] (-> (List a) (Array a))) (product.right (list/fold (function (_ x [idx arr]) [(inc idx) (write idx x arr)]) - [|0 (new (list.size xs))] + [0 (new (list.size xs))] xs))) -(def: underflow Nat (dec |0)) +(def: underflow Nat (dec 0)) (def: #export (to-list array) (All [a] (-> (Array a) (List a))) @@ -170,23 +170,23 @@ _ #0))) #1 - (list.n/range |0 (dec sxs))))) + (list.n/range 0 (dec sxs))))) )) (structure: #export Monoid (All [a] (Monoid (Array a))) - (def: identity (new |0)) + (def: identity (new 0)) (def: (compose xs ys) (let [sxs (size xs) sxy (size ys)] (|> (new (n/+ sxy sxs)) - (copy sxs |0 xs |0) - (copy sxy |0 ys sxs))))) + (copy sxs 0 xs 0) + (copy sxy 0 ys sxs))))) (structure: #export _ (Functor Array) (def: (map f ma) (let [arr-size (size ma)] - (if (n/= |0 arr-size) + (if (n/= 0 arr-size) (new arr-size) (list/fold (function (_ idx mb) (case (read idx ma) @@ -196,14 +196,14 @@ (#.Some x) (write idx (f x) mb))) (new arr-size) - (list.n/range |0 (dec arr-size))) + (list.n/range 0 (dec arr-size))) )))) (structure: #export _ (Fold Array) (def: (fold f init xs) (let [arr-size (size xs)] (loop [so-far init - idx |0] + idx 0] (if (n/< arr-size idx) (case (read idx xs) #.None @@ -218,7 +218,7 @@ (All [a] (-> (Predicate a) (Array a) Bit)) (let [size (..size array)] - (loop [idx |0] + (loop [idx 0] (if (n/< size idx) (case (..read idx array) (#.Some value) diff --git a/stdlib/source/lux/data/collection/bits.lux b/stdlib/source/lux/data/collection/bits.lux index 5caec8eb7..66cb2dab7 100644 --- a/stdlib/source/lux/data/collection/bits.lux +++ b/stdlib/source/lux/data/collection/bits.lux @@ -19,17 +19,17 @@ (type: #export Bits (Array Chunk)) -(def: empty-chunk Chunk (.i64 |0)) +(def: empty-chunk Chunk (.i64 0)) (def: #export empty Bits - (array.new |0)) + (array.new 0)) (def: #export (size bits) (-> Bits Nat) (array/fold (function (_ chunk total) (|> chunk i64.count (n/+ total))) - |0 + 0 bits)) (def: #export (capacity bits) @@ -38,7 +38,7 @@ (def: #export empty? (-> Bits Bit) - (|>> size (n/= |0))) + (|>> size (n/= 0))) (def: #export (get index bits) (-> Nat Bits Bit) @@ -62,7 +62,7 @@ (array.size input)) output ..empty] (let [idx|output (dec size|output)] - (if (n/> |0 size|output) + (if (n/> 0 size|output) (case (|> (..chunk idx|output input) (cond> [(new> (n/= chunk-index idx|output))] [( bit-index)] @@ -70,7 +70,7 @@ ## else []) .nat) - |0 + 0 ## TODO: Remove 'no-op' once new-luxc is the official compiler. (let [no-op (recur (dec size|output) output)] no-op) @@ -92,7 +92,7 @@ (-> Bits Bits Bit) (let [chunks (n/min (array.size reference) (array.size sample))] - (loop [idx |0] + (loop [idx 0] (if (n/< chunks idx) (.or (|> (..chunk idx sample) (i64.and (..chunk idx reference)) @@ -104,7 +104,7 @@ (def: #export (not input) (-> Bits Bits) (case (array.size input) - |0 + 0 ..empty size|output @@ -112,11 +112,11 @@ output ..empty] (let [idx (dec size|output)] (case (|> input (..chunk idx) i64.not .nat) - |0 + 0 (recur (dec size|output) output) chunk - (if (n/> |0 size|output) + (if (n/> 0 size|output) (|> (if (is? ..empty output) (: Bits (array.new size|output)) output) @@ -129,18 +129,18 @@ (-> Bits Bits Bits) (case (n/max (array.size param) (array.size subject)) - |0 + 0 ..empty size|output (loop [size|output size|output output ..empty] (let [idx (dec size|output)] - (if (n/> |0 size|output) + (if (n/> 0 size|output) (case (|> (..chunk idx subject) ( (..chunk idx param)) .nat) - |0 + 0 (recur (dec size|output) output) chunk @@ -160,7 +160,7 @@ (def: (= reference sample) (let [size (n/max (array.size reference) (array.size sample))] - (loop [idx |0] + (loop [idx 0] (if (n/< size idx) (.and ("lux i64 =" (..chunk idx reference) diff --git a/stdlib/source/lux/data/collection/dictionary.lux b/stdlib/source/lux/data/collection/dictionary.lux index 64c577946..3d4e84207 100644 --- a/stdlib/source/lux/data/collection/dictionary.lux +++ b/stdlib/source/lux/data/collection/dictionary.lux @@ -41,7 +41,7 @@ ## the appropriate multiple of the branching-exponent. ## A shift of 0 means root level. ## A shift of (* branching-exponent 1) means level 2. -## A shift of (* branching-exponent N) means level N|1. +## A shift of (* branching-exponent N) means level N+1. (type: Level Nat) ## Nodes for the tree data-structure that organizes the data inside @@ -75,7 +75,7 @@ ## Which is 32 zeroes, since the branching factor is 32. (def: clean-bitmap BitMap - |0) + 0) ## Bitmap position (while looking inside #Base nodes) is determined by ## getting 5 bits from a hash of the key being looked up and using @@ -88,35 +88,35 @@ ## shift in the shallowest node on the tree, which is the root node). (def: root-level Level - |0) + 0) ## The exponent to which 2 must be elevated, to reach the branching ## factor of the data-structure. (def: branching-exponent Nat - |5) + 5) ## The threshold on which #Hierarchy nodes are demoted to #Base nodes, ## which is 1/4 of the branching factor (or a left-shift 2). (def: demotion-threshold Nat - (i64.left-shift (n/- |2 branching-exponent) |1)) + (i64.left-shift (n/- 2 branching-exponent) 1)) ## The threshold on which #Base nodes are promoted to #Hierarchy nodes, ## which is 1/2 of the branching factor (or a left-shift 1). (def: promotion-threshold Nat - (i64.left-shift (n/- |1 branching-exponent) |1)) + (i64.left-shift (n/- 1 branching-exponent) 1)) ## The size of hierarchy-nodes, which is 2^(branching-exponent). (def: hierarchy-nodes-size Nat - (i64.left-shift branching-exponent |1)) + (i64.left-shift branching-exponent 1)) ## The cannonical empty node, which is just an empty #Base node. (def: empty Node - (#Base clean-bitmap (array.new |0))) + (#Base clean-bitmap (array.new 0))) ## Expands a copy of the array, to have 1 extra slot, which is used ## for storing the value. @@ -124,7 +124,7 @@ (All [a] (-> Index a (Array a) (Array a))) (let [old-size (array.size old-array)] (|> (array.new (inc old-size)) - (array.copy idx |0 old-array |0) + (array.copy idx 0 old-array 0) (array.write idx value) (array.copy (n/- idx old-size) idx old-array (inc idx))))) @@ -143,13 +143,13 @@ (All [a] (-> Index (Array a) (Array a))) (let [new-size (dec (array.size array))] (|> (array.new new-size) - (array.copy idx |0 array |0) + (array.copy idx 0 array 0) (array.copy (n/- idx new-size) (inc idx) array idx)))) ## Given a top-limit for indices, produces all indices in [0, R). (def: indices-for (-> Nat (List Index)) - (|>> dec (list.n/range |0))) + (|>> dec (list.n/range 0))) ## Increases the level-shift by the branching-exponent, to explore ## levels further down the tree. @@ -169,7 +169,7 @@ ## A mechanism to go from indices to bit-positions. (def: (->bit-position index) (-> Index BitPosition) - (i64.left-shift index |1)) + (i64.left-shift index 1)) ## The bit-position within a base that a given hash-code would have. (def: (bit-position level hash) @@ -234,8 +234,8 @@ [(set-bit-position (->bit-position idx) bitmap) (array.write insertion-idx (#.Left sub-node) base)]]) ))) - [|0 [clean-bitmap - (array.new (dec h-size))]] + [0 [clean-bitmap + (array.new (dec h-size))]] (list.indices (array.size h-array))))) ## When #Base nodes grow too large, they're promoted to #Hierarchy to @@ -264,7 +264,7 @@ #.None (undefined))] default)) - [|0 + [0 (array.new hierarchy-nodes-size)] hierarchy-indices))) @@ -326,9 +326,9 @@ ## the same, a new ## #Collisions node ## is added. - (#Collisions hash (|> (array.new |2) - (array.write |0 [key' val']) - (array.write |1 [key val]))) + (#Collisions hash (|> (array.new 2) + (array.write 0 [key' val']) + (array.write 1 [key val]))) ## Otherwise, I can ## just keep using ## #Base nodes, so I @@ -371,8 +371,8 @@ ## If the hashes are not equal, I create a new #Base node that ## contains the old #Collisions node, plus the new KV-pair. (|> (#Base (bit-position level _hash) - (|> (array.new |1) - (array.write |0 (#.Left node)))) + (|> (array.new 1) + (array.write 0 (#.Left node)))) (put' level hash key val Hash))) )) @@ -460,7 +460,7 @@ ## But if so, then check the size of the collisions list. (#.Some idx) - (if (n/= |1 (array.size _colls)) + (if (n/= 1 (array.size _colls)) ## If there's only one left, then removing it leaves us with ## an empty node. empty @@ -505,14 +505,14 @@ (All [k v] (-> (Node k v) Nat)) (case node (#Hierarchy _size hierarchy) - (array/fold n/+ |0 (array/map size' hierarchy)) + (array/fold n/+ 0 (array/map size' hierarchy)) (#Base _ base) - (array/fold n/+ |0 (array/map (function (_ sub-node') - (case sub-node' - (#.Left sub-node) (size' sub-node) - (#.Right _) |1)) - base)) + (array/fold n/+ 0 (array/map (function (_ sub-node') + (case sub-node' + (#.Left sub-node) (size' sub-node) + (#.Right _) 1)) + base)) (#Collisions hash colls) (array.size colls) @@ -605,7 +605,7 @@ (def: #export empty? (All [k v] (-> (Dictionary k v) Bit)) - (|>> size (n/= |0))) + (|>> size (n/= 0))) (def: #export (entries dict) (All [k v] (-> (Dictionary k v) (List [k v]))) diff --git a/stdlib/source/lux/data/collection/dictionary/ordered.lux b/stdlib/source/lux/data/collection/dictionary/ordered.lux index 38442f93d..25c50367b 100644 --- a/stdlib/source/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/lux/data/collection/dictionary/ordered.lux @@ -115,7 +115,7 @@ (loop [node (get@ #root dict)] (case node #.None - |0 + 0 (#.Some node) (inc ( (recur (get@ #left node)) diff --git a/stdlib/source/lux/data/collection/list.lux b/stdlib/source/lux/data/collection/list.lux index d7a2145c6..09328def9 100644 --- a/stdlib/source/lux/data/collection/list.lux +++ b/stdlib/source/lux/data/collection/list.lux @@ -68,7 +68,7 @@ [(def: #export ( n xs) (All [a] (-> Nat (List a) (List a))) - (if (n/> |0 n) + (if (n/> 0 n) (case xs #.Nil #.Nil @@ -101,7 +101,7 @@ (def: #export (split n xs) (All [a] (-> Nat (List a) [(List a) (List a)])) - (if (n/> |0 n) + (if (n/> 0 n) (case xs #.Nil [#.Nil #.Nil] @@ -145,7 +145,7 @@ {#.doc "A list of the value x, repeated n times."} (All [a] (-> Nat a (List a))) - (if (n/> |0 n) + (if (n/> 0 n) (#.Cons [x (repeat (dec n) x)]) #.Nil)) @@ -229,7 +229,7 @@ (def: #export (size list) (All [a] (-> (List a) Nat)) - (fold (function (_ _ acc) (n/+ |1 acc)) |0 list)) + (fold (function (_ _ acc) (n/+ 1 acc)) 0 list)) (do-template [ ] [(def: #export ( p xs) @@ -261,7 +261,7 @@ #.None (#.Cons [x xs']) - (if (n/= |0 i) + (if (n/= 0 i) (#.Some x) (nth (dec i) xs')))) @@ -382,40 +382,40 @@ ## [Syntax] (def: (identifier$ name) (-> Text Code) - [["" |0 |0] (#.Identifier "" name)]) + [["" 0 0] (#.Identifier "" name)]) (def: (nat/encode value) (-> Nat Text) (loop [input value output ""] - (let [digit (case (n/% |10 input) - |0 "0" - |1 "1" - |2 "2" - |3 "3" - |4 "4" - |5 "5" - |6 "6" - |7 "7" - |8 "8" - |9 "9" + (let [digit (case (n/% 10 input) + 0 "0" + 1 "1" + 2 "2" + 3 "3" + 4 "4" + 5 "5" + 6 "6" + 7 "7" + 8 "8" + 9 "9" _ (undefined)) output' ("lux text concat" digit output) - input' (n// |10 input)] - (if (n/= |0 input') + input' (n// 10 input)] + (if (n/= 0 input') ("lux text concat" "+" output') (recur input' output'))))) (macro: #export (zip tokens state) {#.doc (doc "Create list zippers with the specified number of input lists." - (def: #export zip2 (zip |2)) - (def: #export zip3 (zip |3)) - ((zip |3) xs ys zs))} + (def: #export zip2 (zip 2)) + (def: #export zip3 (zip 3)) + ((zip 3) xs ys zs))} (case tokens (^ (list [_ (#.Nat num-lists)])) - (if (n/> |0 num-lists) + (if (n/> 0 num-lists) (let [(^open ".") Functor - indices (n/range |0 (dec num-lists)) + indices (n/range 0 (dec num-lists)) type-vars (: (List Code) (map (|>> nat/encode identifier$) indices)) zip-type (` (All [(~+ type-vars)] (-> (~+ (map (: (-> Code Code) (function (_ var) (` (List (~ var))))) @@ -447,19 +447,19 @@ _ (#.Left "Wrong syntax for zip"))) -(def: #export zip2 (zip |2)) -(def: #export zip3 (zip |3)) +(def: #export zip2 (zip 2)) +(def: #export zip3 (zip 3)) (macro: #export (zip-with tokens state) {#.doc (doc "Create list zippers with the specified number of input lists." - (def: #export zip2-with (zip-with |2)) - (def: #export zip3-with (zip-with |3)) - ((zip-with |2) i/+ xs ys))} + (def: #export zip2-with (zip-with 2)) + (def: #export zip3-with (zip-with 3)) + ((zip-with 2) i/+ xs ys))} (case tokens (^ (list [_ (#.Nat num-lists)])) - (if (n/> |0 num-lists) + (if (n/> 0 num-lists) (let [(^open ".") Functor - indices (n/range |0 (dec num-lists)) + indices (n/range 0 (dec num-lists)) g!return-type (identifier$ "\treturn-type\t") g!func (identifier$ "\tfunc\t") type-vars (: (List Code) (map (|>> nat/encode identifier$) indices)) @@ -494,8 +494,8 @@ _ (#.Left "Wrong syntax for zip-with"))) -(def: #export zip2-with (zip-with |2)) -(def: #export zip3-with (zip-with |3)) +(def: #export zip2-with (zip-with 2)) +(def: #export zip3-with (zip-with 3)) (def: #export (last xs) (All [a] (-> (List a) (Maybe a))) @@ -545,7 +545,7 @@ (do Monad [lMla MlMla ## TODO: Remove this version ASAP and use one below. - lla (: (($ |0) (List (List ($ |1)))) + lla (: (($ 0) (List (List ($ 1)))) (monad.seq @ lMla)) ## lla (monad.seq @ lMla) ] @@ -567,11 +567,11 @@ (def: #export (enumerate xs) {#.doc "Pairs every element in the list with its index, starting at 0."} (All [a] (-> (List a) (List [Nat a]))) - (enumerate' |0 xs)) + (enumerate' 0 xs)) (def: #export (indices size) {#.doc "Produces all the valid indices for a given size."} (All [a] (-> Nat (List Nat))) - (if (n/= |0 size) + (if (n/= 0 size) (list) - (|> size dec (n/range |0)))) + (|> size dec (n/range 0)))) diff --git a/stdlib/source/lux/data/collection/queue/priority.lux b/stdlib/source/lux/data/collection/queue/priority.lux index a5aa7dd73..1af9acaab 100644 --- a/stdlib/source/lux/data/collection/queue/priority.lux +++ b/stdlib/source/lux/data/collection/queue/priority.lux @@ -32,13 +32,13 @@ (All [a] (-> (Queue a) Nat)) (case queue #.None - |0 + 0 (#.Some fingers) (loop [node (get@ #finger.node fingers)] (case node (#finger.Leaf _ _) - |1 + 1 (#finger.Branch _ left right) (n/+ (recur left) (recur right)))))) diff --git a/stdlib/source/lux/data/collection/row.lux b/stdlib/source/lux/data/collection/row.lux index c9e2c6786..3951aadd1 100644 --- a/stdlib/source/lux/data/collection/row.lux +++ b/stdlib/source/lux/data/collection/row.lux @@ -35,11 +35,11 @@ (def: branching-exponent Nat - |5) + 5) (def: root-level Level - |0) + 0) (do-template [ ] [(def: @@ -52,7 +52,7 @@ (def: full-node-size Nat - (i64.left-shift branching-exponent |1)) + (i64.left-shift branching-exponent 1)) (def: branch-idx-mask Nat @@ -69,23 +69,23 @@ (def: (tail-off vec-size) (-> Nat Nat) (if (n/< full-node-size vec-size) - |0 + 0 (|> (dec vec-size) (i64.logical-right-shift branching-exponent) (i64.left-shift branching-exponent)))) (def: (new-path level tail) (All [a] (-> Level (Base a) (Node a))) - (if (n/= |0 level) + (if (n/= 0 level) (#Base tail) (|> (new-hierarchy []) - (array.write |0 (new-path (level-down level) tail)) + (array.write 0 (new-path (level-down level) tail)) #Hierarchy))) (def: (new-tail singleton) (All [a] (-> a (Base a))) - (|> (array.new |1) - (array.write |0 singleton))) + (|> (array.new 1) + (array.write 0 singleton))) (def: (push-tail size level tail parent) (All [a] (-> Nat Level (Base a) (Hierarchy a) (Hierarchy a))) @@ -113,7 +113,7 @@ (All [a] (-> a (Base a) (Base a))) (let [tail-size (array.size tail)] (|> (array.new (inc tail-size)) - (array.copy tail-size |0 tail |0) + (array.copy tail-size 0 tail 0) (array.write tail-size val)))) (def: (put' level idx val hierarchy) @@ -125,7 +125,7 @@ (array.write sub-idx (#Hierarchy (put' (level-down level) idx val sub-node)))) (^multi (#.Some (#Base base)) - (n/= |0 (level-down level))) + (n/= 0 (level-down level))) (|> (array.clone hierarchy) (array.write sub-idx (|> (array.clone base) (array.write (branch-idx idx) val) @@ -136,8 +136,8 @@ (def: (pop-tail size level hierarchy) (All [a] (-> Nat Level (Hierarchy a) (Maybe (Hierarchy a)))) - (let [sub-idx (branch-idx (i64.logical-right-shift level (n/- |2 size)))] - (cond (n/= |0 sub-idx) + (let [sub-idx (branch-idx (i64.logical-right-shift level (n/- 2 size)))] + (cond (n/= 0 sub-idx) #.None (n/> branching-exponent level) @@ -183,9 +183,9 @@ (def: #export empty Row {#level (level-up root-level) - #size |0 + #size 0 #root (array.new full-node-size) - #tail (array.new |0)}) + #tail (array.new 0)}) (def: #export (size row) (All [a] (-> (Row a) Nat)) @@ -203,17 +203,17 @@ ## Otherwise, push tail into the tree ## -------------------------------------------------------- ## Will the root experience an overflow with this addition? - (|> (if (n/> (i64.left-shift (get@ #level vec) |1) + (|> (if (n/> (i64.left-shift (get@ #level vec) 1) (i64.logical-right-shift branching-exponent vec-size)) ## If so, a brand-new root must be established, that is ## 1-level taller. (|> vec - (set@ #root (|> (: (Hierarchy ($ |0)) + (set@ #root (|> (: (Hierarchy ($ 0)) (new-hierarchy [])) ## TODO: Remove version above once new-luxc becomes the standard compiler. ## (new-hierarchy []) - (array.write |0 (#Hierarchy (get@ #root vec))) - (array.write |1 (new-path (get@ #level vec) (get@ #tail vec))))) + (array.write 0 (#Hierarchy (get@ #root vec))) + (array.write 1 (new-path (get@ #level vec) (get@ #tail vec))))) (update@ #level level-up)) ## Otherwise, just push the current tail onto the root. (|> vec @@ -227,7 +227,7 @@ (def: (base-for idx vec) (All [a] (-> Index (Row a) (Maybe (Base a)))) (let [vec-size (get@ #size vec)] - (if (and (n/>= |0 idx) + (if (and (n/>= 0 idx) (n/< vec-size idx)) (if (n/>= (tail-off vec-size) idx) (#.Some (get@ #tail vec)) @@ -257,13 +257,13 @@ (def: #export (put idx val vec) (All [a] (-> Nat a (Row a) (Row a))) (let [vec-size (get@ #size vec)] - (if (and (n/>= |0 idx) + (if (and (n/>= 0 idx) (n/< vec-size idx)) (if (n/>= (tail-off vec-size) idx) (|> vec ## (update@ #tail (|>> array.clone (array.write (branch-idx idx) val))) ## TODO: Remove once new-luxc becomes the standard compiler. - (update@ #tail (: (-> (Base ($ |0)) (Base ($ |0))) + (update@ #tail (: (-> (Base ($ 0)) (Base ($ 0))) (|>> array.clone (array.write (branch-idx idx) val)))) ) (|> vec @@ -282,29 +282,29 @@ (def: #export (pop vec) (All [a] (-> (Row a) (Row a))) (case (get@ #size vec) - |0 + 0 empty - |1 + 1 empty vec-size - (if (|> vec-size (n/- (tail-off vec-size)) (n/> |1)) + (if (|> vec-size (n/- (tail-off vec-size)) (n/> 1)) (let [old-tail (get@ #tail vec) new-tail-size (dec (array.size old-tail))] (|> vec (update@ #size dec) (set@ #tail (|> (array.new new-tail-size) - (array.copy new-tail-size |0 old-tail |0))))) + (array.copy new-tail-size 0 old-tail 0))))) (maybe.assume (do maybe.Monad - [new-tail (base-for (n/- |2 vec-size) vec) + [new-tail (base-for (n/- 2 vec-size) vec) #let [[level' root'] (let [init-level (get@ #level vec)] (loop [level init-level root (maybe.default (new-hierarchy []) (pop-tail vec-size init-level (get@ #root vec)))] (if (n/> branching-exponent level) - (case [(array.read |1 root) (array.read |0 root)] + (case [(array.read 1 root) (array.read 0 root)] [#.None (#.Some (#Hierarchy sub-node))] (recur (level-down level) sub-node) @@ -338,7 +338,7 @@ (def: #export empty? (All [a] (-> (Row a) Bit)) - (|>> (get@ #size) (n/= |0))) + (|>> (get@ #size) (n/= 0))) ## [Syntax] (syntax: #export (row {elems (p.some s.any)}) diff --git a/stdlib/source/lux/data/collection/sequence.lux b/stdlib/source/lux/data/collection/sequence.lux index ed06547c2..6529a1ced 100644 --- a/stdlib/source/lux/data/collection/sequence.lux +++ b/stdlib/source/lux/data/collection/sequence.lux @@ -62,7 +62,7 @@ (def: #export (nth idx s) (All [a] (-> Nat (Sequence a) a)) (let [[h t] (continuation.run s)] - (if (n/> |0 idx) + (if (n/> 0 idx) (nth (dec idx) t) h))) @@ -93,7 +93,7 @@ [(list) xs])))] [take-while drop-while split-while (-> a Bit) (pred x) pred] - [take drop split Nat (n/> |0 pred) (dec pred)] + [take drop split Nat (n/> 0 pred) (dec pred)] ) (def: #export (unfold step init) diff --git a/stdlib/source/lux/data/collection/set.lux b/stdlib/source/lux/data/collection/set.lux index cab4105b0..6de27eb24 100644 --- a/stdlib/source/lux/data/collection/set.lux +++ b/stdlib/source/lux/data/collection/set.lux @@ -65,13 +65,13 @@ (def: (hash set) (let [[Hash _] (:representation set)] (list/fold (function (_ elem acc) (n/+ (:: Hash hash elem) acc)) - |0 + 0 (..to-list set))))) ) (def: #export empty? (All [a] (-> (Set a) Bit)) - (|>> ..size (n/= |0))) + (|>> ..size (n/= 0))) (def: #export (from-list Hash xs) (All [a] (-> (Hash a) (List a) (Set a))) diff --git a/stdlib/source/lux/data/collection/set/multi.lux b/stdlib/source/lux/data/collection/set/multi.lux index 91fd7f675..d152c8506 100644 --- a/stdlib/source/lux/data/collection/set/multi.lux +++ b/stdlib/source/lux/data/collection/set/multi.lux @@ -25,15 +25,15 @@ (def: #export size (All [a] (-> (Set a) Nat)) - (|>> :representation dictionary.values (list/fold n/+ |0))) + (|>> :representation dictionary.values (list/fold n/+ 0))) (def: #export (add/* count elem set) (All [a] (-> Nat a (Set a) (Set a))) - (|> set :representation (dictionary.update~ elem |0 (n/+ count)) :abstraction)) + (|> set :representation (dictionary.update~ elem 0 (n/+ count)) :abstraction)) (def: #export add/1 (All [a] (-> a (Set a) (Set a))) - (add/* |1)) + (add/* 1)) (def: #export (remove/* count elem set) (All [a] (-> Nat a (Set a) (Set a))) @@ -53,18 +53,18 @@ (def: #export remove/1 (All [a] (-> a (Set a) (Set a))) - (remove/* |1)) + (remove/* 1)) (def: #export (multiplicity elem set) (All [a] (-> a (Set a) Nat)) - (|> set :representation (dictionary.get elem) (maybe.default |0))) + (|> set :representation (dictionary.get elem) (maybe.default 0))) (def: #export to-list (All [a] (-> (Set a) (List a))) (let [append (: (All [a] (-> a Nat (List a) (List a))) (function (append elem count output) (case count - |0 output + 0 output _ (|> output (#.Cons elem) (append elem (dec count))))))] (|>> :representation dictionary.entries @@ -105,7 +105,7 @@ (|> reference :representation (dictionary.get elem) - (maybe.default |0) + (maybe.default 0) (n/>= count)))))) (def: #export (support set) @@ -124,7 +124,7 @@ (list.every? (function (_ [elem count]) (|> sample (dictionary.get elem) - (maybe.default |0) + (maybe.default 0) (n/= count)))))))) (structure: #export Hash (All [a] (Hash (Set a))) @@ -134,17 +134,17 @@ (let [[Hash _] set] (list/fold (function (_ [elem count] acc) (|> elem (:: Hash hash) (n/* count) (n/+ acc))) - |0 + 0 (dictionary.entries set))))) ) (def: #export (member? set elem) (All [a] (-> (Set a) a Bit)) - (|> set (..multiplicity elem) (n/> |0))) + (|> set (..multiplicity elem) (n/> 0))) (def: #export empty? (All [a] (-> (Set a) Bit)) - (|>> ..size (n/= |0))) + (|>> ..size (n/= 0))) (def: #export (from-list Hash subject) (All [a] (-> (Hash a) (List a) (Set a))) diff --git a/stdlib/source/lux/data/collection/tree/rose/zipper.lux b/stdlib/source/lux/data/collection/tree/rose/zipper.lux index b732f87b2..f9380577b 100644 --- a/stdlib/source/lux/data/collection/tree/rose/zipper.lux +++ b/stdlib/source/lux/data/collection/tree/rose/zipper.lux @@ -86,7 +86,7 @@ (#.Some parent) (|> parent ## TODO: Remove once new-luxc becomes the standard compiler. - (update@ #node (: (-> (Tree ($ |0)) (Tree ($ |0))) + (update@ #node (: (-> (Tree ($ 0)) (Tree ($ 0))) (function (_ node) (set@ #//.children (list/compose (list.reverse (get@ #lefts zipper)) (#.Cons (get@ #node zipper) @@ -155,7 +155,7 @@ (update@ [#node #//.children] (function (_ children) ## TODO: Remove once new-luxc becomes the standard compiler. - (list& (: (Tree ($ |0)) + (list& (: (Tree ($ 0)) (//.tree [value {}])) children) ## (list& (//.tree [value {}]) @@ -169,7 +169,7 @@ (function (_ children) (list/compose children ## TODO: Remove once new-luxc becomes the standard compiler. - (list (: (Tree ($ |0)) + (list (: (Tree ($ 0)) (//.tree [value {}]))) ## (list (//.tree [value {}])) )) @@ -203,7 +203,7 @@ (#.Some (|> zipper (update@ (function (_ side) ## TODO: Remove once new-luxc becomes the standard compiler. - (#.Cons (: (Tree ($ |0)) + (#.Cons (: (Tree ($ 0)) (//.tree [value {}])) side) ## (#.Cons (//.tree [value {}]) diff --git a/stdlib/source/lux/data/color.lux b/stdlib/source/lux/data/color.lux index 2eb8bd35f..e070ced40 100644 --- a/stdlib/source/lux/data/color.lux +++ b/stdlib/source/lux/data/color.lux @@ -8,7 +8,7 @@ [type abstract]]) -(def: rgb Nat |256) +(def: rgb Nat 256) (def: top Nat (dec rgb)) (def: rgb-factor Frac (|> top .int int-to-frac)) @@ -155,9 +155,9 @@ t (|> +1.0 (f/- (|> +1.0 (f/- f) (f/* saturation))) (f/* brightness)) v brightness mod (|> i (f/% +6.0) frac-to-int .nat) - red (case mod |0 v |1 q |2 p |3 p |4 t |5 v _ (undefined)) - green (case mod |0 t |1 v |2 v |3 q |4 p |5 p _ (undefined)) - blue (case mod |0 p |1 p |2 t |3 v |4 v |5 q _ (undefined))] + red (case mod 0 v 1 q 2 p 3 p 4 t 5 v _ (undefined)) + green (case mod 0 t 1 v 2 v 3 q 4 p 5 p _ (undefined)) + blue (case mod 0 p 1 p 2 t 3 v 4 v 5 q _ (undefined))] (color [(scale-up red) (scale-up green) (scale-up blue)]))) @@ -180,7 +180,7 @@ (def: #export (from-cmyk [cyan magenta yellow key]) (-> [Frac Frac Frac Frac] Color) (if (f/= +1.0 key) - (color [|0 |0 |0]) + (color [0 0 0]) (let [red (|> (|> +1.0 (f/- cyan)) (f/* (|> +1.0 (f/- key)))) green (|> (|> +1.0 (f/- magenta)) @@ -216,7 +216,7 @@ (interpolate' greenE greenS) (interpolate' blueE blueS)]))) -(def: black Color (color [|0 |0 |0])) +(def: black Color (color [0 0 0])) (def: white Color (color [top top top])) (do-template [ ] @@ -283,7 +283,7 @@ (def: #export (analogous results slice color) (-> Nat Frac Color (List Color)) - (if (n/= |0 results) + (if (n/= 0 results) (list) (let [[hue saturation luminance] (to-hsl color) slice (normalize slice)] @@ -291,15 +291,15 @@ (from-hsl [(|> idx .int int-to-frac (f/* slice) (f/+ hue) normalize) saturation luminance])) - (list.n/range |0 (dec results)))))) + (list.n/range 0 (dec results)))))) (def: #export (monochromatic results color) (-> Nat Color (List Color)) - (if (n/= |0 results) + (if (n/= 0 results) (list) (let [[hue saturation brightness] (to-hsb color) slice (|> +1.0 (f// (|> results .int int-to-frac)))] - (|> (list.n/range |0 (dec results)) + (|> (list.n/range 0 (dec results)) (list/map (|>> .int int-to-frac (f/* slice) (f/+ brightness) diff --git a/stdlib/source/lux/data/format/binary.lux b/stdlib/source/lux/data/format/binary.lux index c5c7cbb89..4657b48d5 100644 --- a/stdlib/source/lux/data/format/binary.lux +++ b/stdlib/source/lux/data/format/binary.lux @@ -28,10 +28,10 @@ (type: #export Size Nat) -(def: #export size/8 |1) -(def: #export size/16 |2) -(def: #export size/32 |4) -(def: #export size/64 |8) +(def: #export size/8 1) +(def: #export size/16 2) +(def: #export size/32 4) +(def: #export size/64 8) (type: #export Read (p.Parser [Offset Binary])) @@ -46,7 +46,7 @@ ## Operators (def: #export (read format input) (All [a] (-> (Format a) Binary (Error a))) - (case ((get@ #read format) [|0 input]) + (case ((get@ #read format) [0 input]) (#error.Error msg) (#error.Error msg) @@ -59,7 +59,7 @@ (def: #export (write format value) (All [a] (-> (Format a) a Binary)) (let [[valueS valueT] ((get@ #write format) value)] - (|> valueS binary.create (valueT |0)))) + (|> valueS binary.create (valueT 0)))) ## Primitives (do-template [ ] @@ -91,9 +91,9 @@ {#read (do p.Monad [flag (get@ #read bits/8)] (case flag - |0 (:: @ map (|>> #.Left) (get@ #read leftB)) - |1 (:: @ map (|>> #.Right) (get@ #read rightB)) - _ (p.lift (ex.throw invalid-tag [|2 (.nat flag)])))) + 0 (:: @ map (|>> #.Left) (get@ #read leftB)) + 1 (:: @ map (|>> #.Right) (get@ #read rightB)) + _ (p.lift (ex.throw invalid-tag [2 (.nat flag)])))) #write (function (_ altV) (case altV (#.Left leftV) @@ -101,7 +101,7 @@ [(.inc leftS) (function (_ offset binary) (|> binary - (binary.write/8 offset |0) + (binary.write/8 offset 0) error.assume (leftT (.inc offset))))]) @@ -110,7 +110,7 @@ [(.inc rightS) (function (_ offset binary) (|> binary - (binary.write/8 offset |1) + (binary.write/8 offset 1) error.assume (rightT (.inc offset))))]) ))}) @@ -141,7 +141,7 @@ {#read (function (_ input) (#error.Success [input default])) #write (function (_ value) - [|0 + [0 (function (_ offset binary) binary)])}) @@ -157,19 +157,19 @@ (case (: Nat data) (^template [ ] (#error.Success [(inc offset) binary] )) - ([|0 #0] - [|1 #1]) + ([0 #0] + [1 #1]) _ - (ex.throw invalid-tag [|2 data])) + (ex.throw invalid-tag [2 data])) (#error.Error error) (#error.Error error))) #write (function (_ value) - [|1 + [1 (function (_ offset binary) (|> binary - (binary.write/8 offset (if value |1 |0)) + (binary.write/8 offset (if value 1 0)) error.assume))])}) (def: #export nat (Format Nat) (:assume ..bits/64)) @@ -198,7 +198,7 @@ (error.assume (do error.Monad [_ (binary.write/64 offset size binary)] - (binary.copy size |0 value (n/+ size/64 offset) binary))))]))}) + (binary.copy size 0 value (n/+ size/64 offset) binary))))]))}) (def: #export text (Format Text) diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux index 573e422d6..13ffe71da 100644 --- a/stdlib/source/lux/data/number.lux +++ b/stdlib/source/lux/data/number.lux @@ -51,8 +51,8 @@ (def: abs id) (def: (signum x) (case x - |0 |0 - _ |1)) + 0 0 + _ 1)) ) (do-template [ <+> <-> <*> <%> <=> <<> <0> <1> <-1>] @@ -107,10 +107,10 @@ (def: top ) (def: bottom ))] - [ Nat Enum (:coerce Nat -1) |0] + [ Nat Enum (:coerce Nat -1) 0] [ Int Enum +9_223_372_036_854_775_807 -9_223_372_036_854_775_808] [Frac Enum ("lux frac max") ("lux frac min")] - [ Rev Enum (:coerce Rev -1) (:coerce Rev |0)] + [ Rev Enum (:coerce Rev -1) (:coerce Rev 0)] ) (do-template [ ] @@ -118,8 +118,8 @@ (def: identity ) (def: compose ))] - [ Add@Monoid Nat |0 n/+] - [ Mul@Monoid Nat |1 n/*] + [ Add@Monoid Nat 0 n/+] + [ Mul@Monoid Nat 1 n/*] [ Max@Monoid Nat (:: Interval bottom) n/max] [ Min@Monoid Nat (:: Interval top) n/min] [ Add@Monoid Int +0 i/+] @@ -182,113 +182,113 @@ (def: (binary-character value) (-> Nat (Maybe Text)) (case value - |0 (#.Some "0") - |1 (#.Some "1") + 0 (#.Some "0") + 1 (#.Some "1") _ #.None)) (def: (binary-value digit) (-> Text (Maybe Nat)) (case digit - "0" (#.Some |0) - "1" (#.Some |1) + "0" (#.Some 0) + "1" (#.Some 1) _ #.None)) (def: (octal-character value) (-> Nat (Maybe Text)) (case value - |0 (#.Some "0") - |1 (#.Some "1") - |2 (#.Some "2") - |3 (#.Some "3") - |4 (#.Some "4") - |5 (#.Some "5") - |6 (#.Some "6") - |7 (#.Some "7") + 0 (#.Some "0") + 1 (#.Some "1") + 2 (#.Some "2") + 3 (#.Some "3") + 4 (#.Some "4") + 5 (#.Some "5") + 6 (#.Some "6") + 7 (#.Some "7") _ #.None)) (def: (octal-value digit) (-> Text (Maybe Nat)) (case digit - "0" (#.Some |0) - "1" (#.Some |1) - "2" (#.Some |2) - "3" (#.Some |3) - "4" (#.Some |4) - "5" (#.Some |5) - "6" (#.Some |6) - "7" (#.Some |7) + "0" (#.Some 0) + "1" (#.Some 1) + "2" (#.Some 2) + "3" (#.Some 3) + "4" (#.Some 4) + "5" (#.Some 5) + "6" (#.Some 6) + "7" (#.Some 7) _ #.None)) (def: (decimal-character value) (-> Nat (Maybe Text)) (case value - |0 (#.Some "0") - |1 (#.Some "1") - |2 (#.Some "2") - |3 (#.Some "3") - |4 (#.Some "4") - |5 (#.Some "5") - |6 (#.Some "6") - |7 (#.Some "7") - |8 (#.Some "8") - |9 (#.Some "9") + 0 (#.Some "0") + 1 (#.Some "1") + 2 (#.Some "2") + 3 (#.Some "3") + 4 (#.Some "4") + 5 (#.Some "5") + 6 (#.Some "6") + 7 (#.Some "7") + 8 (#.Some "8") + 9 (#.Some "9") _ #.None)) (def: (decimal-value digit) (-> Text (Maybe Nat)) (case digit - "0" (#.Some |0) - "1" (#.Some |1) - "2" (#.Some |2) - "3" (#.Some |3) - "4" (#.Some |4) - "5" (#.Some |5) - "6" (#.Some |6) - "7" (#.Some |7) - "8" (#.Some |8) - "9" (#.Some |9) + "0" (#.Some 0) + "1" (#.Some 1) + "2" (#.Some 2) + "3" (#.Some 3) + "4" (#.Some 4) + "5" (#.Some 5) + "6" (#.Some 6) + "7" (#.Some 7) + "8" (#.Some 8) + "9" (#.Some 9) _ #.None)) (def: (hexadecimal-character value) (-> Nat (Maybe Text)) (case value - |0 (#.Some "0") - |1 (#.Some "1") - |2 (#.Some "2") - |3 (#.Some "3") - |4 (#.Some "4") - |5 (#.Some "5") - |6 (#.Some "6") - |7 (#.Some "7") - |8 (#.Some "8") - |9 (#.Some "9") - |10 (#.Some "A") - |11 (#.Some "B") - |12 (#.Some "C") - |13 (#.Some "D") - |14 (#.Some "E") - |15 (#.Some "F") + 0 (#.Some "0") + 1 (#.Some "1") + 2 (#.Some "2") + 3 (#.Some "3") + 4 (#.Some "4") + 5 (#.Some "5") + 6 (#.Some "6") + 7 (#.Some "7") + 8 (#.Some "8") + 9 (#.Some "9") + 10 (#.Some "A") + 11 (#.Some "B") + 12 (#.Some "C") + 13 (#.Some "D") + 14 (#.Some "E") + 15 (#.Some "F") _ #.None)) (def: (hexadecimal-value digit) (-> Text (Maybe Nat)) (case digit - "0" (#.Some |0) - "1" (#.Some |1) - "2" (#.Some |2) - "3" (#.Some |3) - "4" (#.Some |4) - "5" (#.Some |5) - "6" (#.Some |6) - "7" (#.Some |7) - "8" (#.Some |8) - "9" (#.Some |9) - (^or "a" "A") (#.Some |10) - (^or "b" "B") (#.Some |11) - (^or "c" "C") (#.Some |12) - (^or "d" "D") (#.Some |13) - (^or "e" "E") (#.Some |14) - (^or "f" "F") (#.Some |15) + "0" (#.Some 0) + "1" (#.Some 1) + "2" (#.Some 2) + "3" (#.Some 3) + "4" (#.Some 4) + "5" (#.Some 5) + "6" (#.Some 6) + "7" (#.Some 7) + "8" (#.Some 8) + "9" (#.Some 9) + (^or "a" "A") (#.Some 10) + (^or "b" "B") (#.Some 11) + (^or "c" "C") (#.Some 12) + (^or "d" "D") (#.Some 13) + (^or "e" "E") (#.Some 14) + (^or "f" "F") (#.Some 15) _ #.None)) (do-template [ ] @@ -299,36 +299,31 @@ (let [digit (maybe.assume ( (n/% input))) output' ("lux text concat" digit output) input' (n// input)] - (if (n/= |0 input') - ("lux text concat" "|" output') + (if (n/= 0 input') + output' (recur input' output'))))) (def: (decode repr) (let [input-size ("lux text size" repr)] - (if (n/>= |2 input-size) - (case ("lux text char" repr |0) - (^ (#.Some (char "|"))) - (loop [idx |1 - output |0] - (if (n/< input-size idx) - (let [digit (maybe.assume (get-char repr idx))] - (case ( digit) - #.None - (#error.Error ("lux text concat" repr)) - - (#.Some digit-value) - (recur (inc idx) - (|> output (n/* ) (n/+ digit-value))))) - (#error.Success output))) - - _ - (#error.Error ("lux text concat" repr))) + (if (n/> 0 input-size) + (loop [idx 0 + output 0] + (if (n/< input-size idx) + (let [digit (maybe.assume (get-char repr idx))] + (case ( digit) + #.None + (#error.Error ("lux text concat" repr)) + + (#.Some digit-value) + (recur (inc idx) + (|> output (n/* ) (n/+ digit-value))))) + (#error.Success output))) (#error.Error ("lux text concat" repr))))))] - [Binary@Codec |2 binary-character binary-value "Invalid binary syntax for Nat: "] - [Octal@Codec |8 octal-character octal-value "Invalid octal syntax for Nat: "] - [_ |10 decimal-character decimal-value "Invalid syntax for Nat: "] - [Hex@Codec |16 hexadecimal-character hexadecimal-value "Invalid hexadecimal syntax for Nat: "] + [Binary@Codec 2 binary-character binary-value "Invalid binary syntax for Nat: "] + [Octal@Codec 8 octal-character octal-value "Invalid octal syntax for Nat: "] + [_ 10 decimal-character decimal-value "Invalid syntax for Nat: "] + [Hex@Codec 16 hexadecimal-character hexadecimal-value "Invalid hexadecimal syntax for Nat: "] ) (def: (int/sign!! value) @@ -339,7 +334,7 @@ (def: (int/sign?? representation) (-> Text (Maybe Int)) - (case (get-char representation |0) + (case (get-char representation 0) (^ (#.Some "-")) (#.Some -1) @@ -351,7 +346,7 @@ (def: (int-decode-loop input-size repr sign ) (-> Nat Text Int Int (-> Text (Maybe Nat)) Text (Error Int)) - (loop [idx |1 + (loop [idx 1 output +0] (if (n/< input-size idx) (let [digit (maybe.assume (get-char repr idx))] @@ -381,7 +376,7 @@ (def: (decode repr) (let [input-size ("lux text size" repr)] - (if (n/> |1 input-size) + (if (n/> 1 input-size) (case (int/sign?? repr) (#.Some sign) (int-decode-loop input-size repr sign ) @@ -398,17 +393,17 @@ (def: (de-prefix input) (-> Text Text) - (maybe.assume ("lux text clip" input |1 ("lux text size" input)))) + (maybe.assume ("lux text clip" input 1 ("lux text size" input)))) (do-template [ ] [(structure: #export (Codec Text Rev) (def: (encode value) (let [raw-output (de-prefix (:: encode (:coerce Nat value))) - max-num-chars (n// |64) + max-num-chars (n// 64) raw-size ("lux text size" raw-output) zero-padding (loop [zeroes-left (n/- raw-size max-num-chars) output ""] - (if (n/= |0 zeroes-left) + (if (n/= 0 zeroes-left) output (recur (dec zeroes-left) ("lux text concat" "0" output)))) @@ -417,10 +412,10 @@ (def: (decode repr) (let [repr-size ("lux text size" repr)] - (if (n/>= |2 repr-size) - (case ("lux text char" repr |0) + (if (n/>= 2 repr-size) + (case ("lux text char" repr 0) (^multi (^ (#.Some (char "."))) - [(:: decode ("lux text concat" "|" (de-prefix repr))) + [(:: decode (de-prefix repr)) (#error.Success output)]) (#error.Success (:coerce Rev output)) @@ -428,9 +423,9 @@ (#error.Error ("lux text concat" repr))) (#error.Error ("lux text concat" repr))))))] - [Binary@Codec Binary@Codec |1 "Invalid binary syntax: "] - [Octal@Codec Octal@Codec |3 "Invalid octal syntax: "] - [Hex@Codec Hex@Codec |4 "Invalid hexadecimal syntax: "] + [Binary@Codec Binary@Codec 1 "Invalid binary syntax: "] + [Octal@Codec Octal@Codec 3 "Invalid octal syntax: "] + [Hex@Codec Hex@Codec 4 "Invalid hexadecimal syntax: "] ) (do-template [ ] @@ -453,9 +448,9 @@ ("lux text concat" whole-part decimal-part))) (def: (decode repr) - (case ("lux text index" repr "." |0) + (case ("lux text index" repr "." 0) (#.Some split-index) - (let [whole-part (maybe.assume ("lux text clip" repr |0 split-index)) + (let [whole-part (maybe.assume ("lux text clip" repr 0 split-index)) decimal-part (maybe.assume ("lux text clip" repr (inc split-index) ("lux text size" repr)))] (case [(:: decode whole-part) (:: decode decimal-part)] @@ -466,7 +461,7 @@ +1.0) div-power (loop [muls-left ("lux text size" decimal-part) output +1.0] - (if (n/= |0 muls-left) + (if (n/= 0 muls-left) output (recur (dec muls-left) (f/* output)))) @@ -501,7 +496,7 @@ (list digits) (let [boundary (n/- chunk-size num-digits) chunk (maybe.assume ("lux text clip" digits boundary num-digits)) - remaining (maybe.assume ("lux text clip" digits |0 boundary))] + remaining (maybe.assume ("lux text clip" digits 0 boundary))] (list& chunk (segment-digits chunk-size remaining))))))) (def: (bin-segment-to-hex input) @@ -593,15 +588,15 @@ (do-template [ ] [(def: ( on-left? input) (-> Bit Text Text) - (let [max-num-chars (n// |64) + (let [max-num-chars (n// 64) input-size ("lux text size" input) zero-padding (let [num-digits-that-need-padding (n/% input-size)] - (if (n/= |0 num-digits-that-need-padding) + (if (n/= 0 num-digits-that-need-padding) "" (loop [zeroes-left (n/- num-digits-that-need-padding ) output ""] - (if (n/= |0 zeroes-left) + (if (n/= 0 zeroes-left) output (recur (dec zeroes-left) ("lux text concat" "0" output)))))) @@ -615,12 +610,12 @@ (def: (-> Text Text) - (|>> (segment-digits |1) + (|>> (segment-digits 1) (map ) re-join-chunks))] - [binary-to-hex bin-segment-to-hex hex-to-binary hex-segment-to-bin |4] - [binary-to-octal bin-segment-to-octal octal-to-binary octal-segment-to-bin |3] + [binary-to-hex bin-segment-to-hex hex-to-binary hex-segment-to-bin 4] + [binary-to-octal bin-segment-to-octal octal-to-binary octal-segment-to-bin 3] ) (do-template [ ] @@ -628,9 +623,9 @@ (def: (encode value) (let [sign (:: Number signum value) raw-bin (:: Binary@Codec encode value) - dot-idx (maybe.assume ("lux text index" raw-bin "." |0)) + dot-idx (maybe.assume ("lux text index" raw-bin "." 0)) whole-part (maybe.assume ("lux text clip" raw-bin - (if (f/= -1.0 sign) |1 |0) + (if (f/= -1.0 sign) 1 0) dot-idx)) decimal-part (maybe.assume ("lux text clip" raw-bin (inc dot-idx) ("lux text size" raw-bin))) hex-output (|> ( #0 decimal-part) @@ -640,15 +635,15 @@ hex-output)) (def: (decode repr) - (let [sign (case ("lux text index" repr "-" |0) - (#.Some |0) + (let [sign (case ("lux text index" repr "-" 0) + (#.Some 0) -1.0 _ +1.0)] - (case ("lux text index" repr "." |0) + (case ("lux text index" repr "." 0) (#.Some split-index) - (let [whole-part (maybe.assume ("lux text clip" repr (if (f/= -1.0 sign) |1 |0) split-index)) + (let [whole-part (maybe.assume ("lux text clip" repr (if (f/= -1.0 sign) 1 0) split-index)) decimal-part (maybe.assume ("lux text clip" repr (inc split-index) ("lux text size" repr))) as-binary (|> ( decimal-part) ("lux text concat" ".") @@ -688,8 +683,8 @@ (def: (underscore-prefixed? number) (-> Text Bit) - (case ("lux text index" number "_" |0) - (#.Some |0) + (case ("lux text index" number "_" 0) + (#.Some 0) #1 _ @@ -758,7 +753,7 @@ (def: (digits-get idx digits) (-> Nat Digits Nat) - (maybe.default |0 ("lux array get" digits idx))) + (maybe.default 0 ("lux array get" digits idx))) (def: (digits-put idx digit digits) (-> Nat Nat Digits Digits) @@ -771,22 +766,22 @@ (def: (digits-times-5! idx output) (-> Nat Digits Digits) (loop [idx idx - carry |0 + carry 0 output output] (if (i/>= +0 (:coerce Int idx)) (let [raw (|> (digits-get idx output) - (n/* |5) + (n/* 5) (n/+ carry))] (recur (dec idx) - (n// |10 raw) - (digits-put idx (n/% |10 raw) output))) + (n// 10 raw) + (digits-put idx (n/% 10 raw) output))) output))) (def: (digits-power power) (-> Nat Digits) (loop [times power output (|> (make-digits []) - (digits-put power |1))] + (digits-put power 1))] (if (i/>= +0 (:coerce Int times)) (recur (dec times) (digits-times-5! power output)) @@ -799,7 +794,7 @@ output ""] (if (i/>= +0 (:coerce Int idx)) (let [digit (digits-get idx digits)] - (if (and (n/= |0 digit) + (if (and (n/= 0 digit) all-zeroes?) (recur (dec idx) #1 output) (recur (dec idx) @@ -814,7 +809,7 @@ (def: (digits-add param subject) (-> Digits Digits Digits) (loop [idx (dec i64.width) - carry |0 + carry 0 output (make-digits [])] (if (i/>= +0 (:coerce Int idx)) (let [raw ($_ n/+ @@ -822,19 +817,19 @@ (digits-get idx param) (digits-get idx subject))] (recur (dec idx) - (n// |10 raw) - (digits-put idx (n/% |10 raw) output))) + (n// 10 raw) + (digits-put idx (n/% 10 raw) output))) output))) (def: (text-to-digits input) (-> Text (Maybe Digits)) (let [length ("lux text size" input)] (if (n/<= i64.width length) - (loop [idx |0 + (loop [idx 0 output (make-digits [])] (if (n/< length idx) (let [char (maybe.assume (get-char input idx))] - (case ("lux text index" "+0123456789" char |0) + (case ("lux text index" "+0123456789" char 0) #.None #.None @@ -846,7 +841,7 @@ (def: (digits-lt param subject) (-> Digits Digits Bit) - (loop [idx |0] + (loop [idx 0] (and (n/< i64.width idx) (let [pd (digits-get idx param) sd (digits-get idx subject)] @@ -860,11 +855,11 @@ (if (n/>= param sd) (digits-put idx (n/- param sd) subject) (let [diff (|> sd - (n/+ |10) + (n/+ 10) (n/- param))] (|> subject (digits-put idx diff) - (digits-sub-once! (dec idx) |1)))))) + (digits-sub-once! (dec idx) 1)))))) (def: (digits-sub! param subject) (-> Digits Digits Digits) @@ -879,7 +874,7 @@ (def: (encode input) (let [input (:coerce Nat input) last-idx (dec i64.width)] - (if (n/= |0 input) + (if (n/= 0 input) ".0" (loop [idx last-idx digits (make-digits [])] @@ -896,21 +891,21 @@ (def: (decode input) (let [length ("lux text size" input) - dotted? (case ("lux text index" input "." |0) - (#.Some |0) + dotted? (case ("lux text index" input "." 0) + (#.Some 0) #1 _ #0)] (if (and dotted? (n/<= (inc i64.width) length)) - (case (|> ("lux text clip" input |1 length) + (case (|> ("lux text clip" input 1 length) maybe.assume text-to-digits) (#.Some digits) (loop [digits digits - idx |0 - output |0] + idx 0 + output 0] (if (n/< i64.width idx) (let [power (digits-power idx)] (if (digits-lt power digits) @@ -931,58 +926,58 @@ (f// ("lux math log" +2.0) ("lux math log" input))) -(def: double-bias Nat |1023) +(def: double-bias Nat 1023) -(def: mantissa-size Nat |52) -(def: exponent-size Nat |11) +(def: mantissa-size Nat 52) +(def: exponent-size Nat 11) (def: #export (frac-to-bits input) (-> Frac I64) (i64 (cond (not-a-number? input) - (hex "|7FF7FFFFFFFFFFFF") + (hex "7FF7FFFFFFFFFFFF") (f/= positive-infinity input) - (hex "|7FF0000000000000") + (hex "7FF0000000000000") (f/= negative-infinity input) - (hex "|FFF0000000000000") + (hex "FFF0000000000000") (f/= +0.0 input) (let [reciprocal (f// input +1.0)] (if (f/= positive-infinity reciprocal) ## Positive zero - (hex "|0000000000000000") + (hex "0000000000000000") ## Negative zero - (hex "|8000000000000000"))) + (hex "8000000000000000"))) ## else (let [sign (:: Number signum input) input (:: Number abs input) exponent ("lux math floor" (log2 input)) - exponent-mask (|> |1 (i64.left-shift exponent-size) dec) + exponent-mask (|> 1 (i64.left-shift exponent-size) dec) mantissa (|> input ## Normalize (f// ("lux math pow" +2.0 exponent)) ## Make it int-equivalent (f/* ("lux math pow" +2.0 +52.0))) - sign-bit (if (f/= -1.0 sign) |1 |0) + sign-bit (if (f/= -1.0 sign) 1 0) exponent-bits (|> exponent frac-to-int .nat (n/+ double-bias) (i64.and exponent-mask)) mantissa-bits (|> mantissa frac-to-int .nat)] ($_ i64.or - (i64.left-shift |63 sign-bit) + (i64.left-shift 63 sign-bit) (i64.left-shift mantissa-size exponent-bits) (i64.clear mantissa-size mantissa-bits))) ))) (do-template [ ] - [(def: (|> |1 (i64.left-shift ) dec (i64.left-shift ))) + [(def: (|> 1 (i64.left-shift ) dec (i64.left-shift ))) (def: ( input) (-> (I64 Any) I64) (|> input (i64.and ) (i64.logical-right-shift ) i64))] - [mantissa mantissa-mask mantissa-size |0] + [mantissa mantissa-mask mantissa-size 0] [exponent exponent-mask exponent-size mantissa-size] - [sign sign-mask |1 (n/+ exponent-size mantissa-size)] + [sign sign-mask 1 (n/+ exponent-size mantissa-size)] ) (def: #export (bits-to-frac input) @@ -990,15 +985,15 @@ (let [S (sign input) E (exponent input) M (mantissa input)] - (cond (n/= (hex "|7FF") E) - (if (n/= |0 M) - (if (n/= |0 S) + (cond (n/= (hex "7FF") E) + (if (n/= 0 M) + (if (n/= 0 S) positive-infinity negative-infinity) not-a-number) - (and (n/= |0 E) (n/= |0 M)) - (if (n/= |0 S) + (and (n/= 0 E) (n/= 0 M)) + (if (n/= 0 S) +0.0 (f/* -1.0 +0.0)) @@ -1011,7 +1006,7 @@ ("lux math pow" +2.0)) shifted (f/* power normalized)] - (if (n/= |0 S) + (if (n/= 0 S) shifted (f/* -1.0 shifted)))))) diff --git a/stdlib/source/lux/data/number/complex.lux b/stdlib/source/lux/data/number/complex.lux index fb0401582..cd785fb31 100644 --- a/stdlib/source/lux/data/number/complex.lux +++ b/stdlib/source/lux/data/number/complex.lux @@ -291,13 +291,13 @@ (def: #export (roots nth input) (-> Nat Complex (List Complex)) - (if (n/= |0 nth) + (if (n/= 0 nth) (list) (let [r-nth (|> nth .int int-to-frac) nth-root-of-abs (|> input abs (get@ #real) (math.pow (f// r-nth +1.0))) nth-phi (|> input argument (f// r-nth)) slice (|> math.pi (f/* +2.0) (f// r-nth))] - (|> (list.n/range |0 (dec nth)) + (|> (list.n/range 0 (dec nth)) (list/map (function (_ nth') (let [inner (|> nth' .int int-to-frac (f/* slice) diff --git a/stdlib/source/lux/data/number/i64.lux b/stdlib/source/lux/data/number/i64.lux index 9d1e8794b..aba61ad3e 100644 --- a/stdlib/source/lux/data/number/i64.lux +++ b/stdlib/source/lux/data/number/i64.lux @@ -1,6 +1,6 @@ (.module: [lux (#- and or not)]) -(def: #export width Nat |64) +(def: #export width Nat 64) ## [Values] (do-template [ ] @@ -32,15 +32,15 @@ (def: #export (count subject) {#.doc "Count the number of 1s in a bit-map."} (-> (I64 Any) Nat) - (let [count' (n/- (|> subject (logical-right-shift |1) (..and |6148914691236517205) i64) + (let [count' (n/- (|> subject (logical-right-shift 1) (..and 6148914691236517205) i64) (i64 subject))] (|> count' - (logical-right-shift |2) (..and |3689348814741910323) (n/+ (..and |3689348814741910323 count')) - (add-shift |4) (..and |1085102592571150095) - (add-shift |8) - (add-shift |16) - (add-shift |32) - (..and |127)))) + (logical-right-shift 2) (..and 3689348814741910323) (n/+ (..and 3689348814741910323 count')) + (add-shift 4) (..and 1085102592571150095) + (add-shift 8) + (add-shift 16) + (add-shift 32) + (..and 127)))) (def: #export not {#.doc "Bitwise negation."} @@ -49,7 +49,7 @@ (def: (flag idx) (-> Nat I64) - (|> |1 (:coerce I64) (left-shift idx))) + (|> 1 (:coerce I64) (left-shift idx))) (def: #export (clear idx input) {#.doc "Clear bit at given index."} @@ -68,7 +68,7 @@ (def: #export (set? idx input) (-> Nat (I64 Any) Bit) - (|> input (:coerce I64) (..and (flag idx)) (n/= |0) .not)) + (|> input (:coerce I64) (..and (flag idx)) (n/= 0) .not)) (do-template [
] [(def: #export ( distance input) @@ -84,4 +84,4 @@ (def: #export (region size offset) (-> Nat Nat I64) - (|> |1 (:coerce I64) (left-shift size) dec (left-shift offset))) + (|> 1 (:coerce I64) (left-shift size) dec (left-shift offset))) diff --git a/stdlib/source/lux/data/number/ratio.lux b/stdlib/source/lux/data/number/ratio.lux index b072a808a..647eaf4b5 100644 --- a/stdlib/source/lux/data/number/ratio.lux +++ b/stdlib/source/lux/data/number/ratio.lux @@ -123,18 +123,14 @@ #denominator numerator}) (def: abs id) (def: (signum x) - {#numerator |1 - #denominator |1})) + {#numerator 1 + #denominator 1})) (def: separator Text ":") (def: part-encode (-> Nat Text) - (|>> nat/encode (text.split |1) maybe.assume product.right)) - -(def: part-decode - (-> Text (E.Error Nat)) - (|>> (format "+") nat/decode)) + (|>> nat/encode (text.split 1) maybe.assume product.right)) (structure: #export _ (Codec Text Ratio) (def: (encode (^slots [#numerator #denominator])) @@ -144,8 +140,8 @@ (case (text.split-with separator input) (#.Some [num denom]) (do E.Monad - [numerator (part-decode num) - denominator (part-decode denom)] + [numerator (nat/decode num) + denominator (nat/decode denom)] (wrap (normalize {#numerator numerator #denominator denominator}))) @@ -158,5 +154,5 @@ "The denominator can be omitted if it's 1." (ratio numerator))} (wrap (list (` ((~! normalize) {#..numerator (~ numerator) - #..denominator (~ (maybe.default (' |1) + #..denominator (~ (maybe.default (' 1) ?denominator))}))))) diff --git a/stdlib/source/lux/data/sum.lux b/stdlib/source/lux/data/sum.lux index 24704c3c0..edb9d19fd 100644 --- a/stdlib/source/lux/data/sum.lux +++ b/stdlib/source/lux/data/sum.lux @@ -7,8 +7,8 @@ (All [a b] (-> (| a b))) ( value))] - [left a |0] - [right b |1]) + [left a 0] + [right b 1]) (def: #export (either fl fr) (All [a b c] @@ -16,8 +16,8 @@ (-> (| a b) c))) (function (_ input) (case input - (|0 l) (fl l) - (|1 r) (fr r)))) + (0 l) (fl l) + (1 r) (fr r)))) (def: #export (each fl fr) (All [l l' r r'] @@ -25,8 +25,8 @@ (-> (| l r) (| l' r')))) (function (_ input) (case input - (|0 l) (|0 (fl l)) - (|1 r) (|1 (fr r))))) + (0 l) (0 (fl l)) + (1 r) (1 (fr r))))) (do-template [ ] [(def: #export ( es) @@ -36,8 +36,8 @@ (#.Cons ( x) es') (#.Cons [x ( es')]) (#.Cons _ es') ( es')))] - [lefts a |0] - [rights b |1] + [lefts a 0] + [rights b 1] ) (def: #export (partition xs) @@ -49,5 +49,5 @@ (#.Cons x xs') (let [[lefts rights] (partition xs')] (case x - (|0 x') [(#.Cons x' lefts) rights] - (|1 x') [lefts (#.Cons x' rights)])))) + (0 x') [(#.Cons x' lefts) rights] + (1 x') [lefts (#.Cons x' rights)])))) diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux index f5462e4e7..48f35febe 100644 --- a/stdlib/source/lux/data/text.lux +++ b/stdlib/source/lux/data/text.lux @@ -30,7 +30,7 @@ (def: #export (index-of pattern input) (-> Text Text (Maybe Nat)) - ("lux text index" input pattern |0)) + ("lux text index" input pattern 0)) (def: (last-index-of'' part since text) (-> Text Nat Text (Maybe Nat)) @@ -52,7 +52,7 @@ (def: #export (last-index-of part text) (-> Text Text (Maybe Nat)) - (case ("lux text index" text part |0) + (case ("lux text index" text part 0) (#.Some since) (last-index-of'' part since text) @@ -62,7 +62,7 @@ (def: #export (starts-with? prefix x) (-> Text Text Bit) (case (index-of prefix x) - (#.Some |0) + (#.Some 0) #1 _ @@ -80,7 +80,7 @@ (def: #export (contains? sub text) (-> Text Text Bit) - (case ("lux text index" text sub |0) + (case ("lux text index" text sub 0) (#.Some _) #1 @@ -97,7 +97,7 @@ (def: #export (split at x) (-> Nat Text (Maybe [Text Text])) - (case [(..clip |0 at x) (..clip' at x)] + (case [(..clip 0 at x) (..clip' at x)] [(#.Some pre) (#.Some post)] (#.Some [pre post]) @@ -179,13 +179,13 @@ (:coerce Nat))} ## Platform-independent default. (let [length ("lux text size" input)] - (loop [idx |0 - hash |0] + (loop [idx 0 + hash 0] (if (n/< length idx) - (let [char (|> idx ("lux text char" input) (maybe.default |0))] + (let [char (|> idx ("lux text char" input) (maybe.default 0))] (recur (inc idx) (|> hash - (i64.left-shift |5) + (i64.left-shift 5) (n/- hash) (n/+ char)))) hash))))))) diff --git a/stdlib/source/lux/data/text/buffer.lux b/stdlib/source/lux/data/text/buffer.lux index af9d14efc..38b47e875 100644 --- a/stdlib/source/lux/data/text/buffer.lux +++ b/stdlib/source/lux/data/text/buffer.lux @@ -34,7 +34,7 @@ (def: #export empty Buffer (:abstraction (for {(~~ (static _.jvm)) - [|0 id]} + [0 id]} ## default row.empty))) @@ -59,7 +59,7 @@ ## default (row/fold (function (_ chunk total) (n/+ (//.size chunk) total)) - |0 + 0 (:representation buffer)))) (def: #export (text buffer) diff --git a/stdlib/source/lux/data/text/lexer.lux b/stdlib/source/lux/data/text/lexer.lux index 14afb4254..481d17b0a 100644 --- a/stdlib/source/lux/data/text/lexer.lux +++ b/stdlib/source/lux/data/text/lexer.lux @@ -15,7 +15,7 @@ (type: Offset Nat) -(def: start-offset Offset |0) +(def: start-offset Offset 0) (type: #export Lexer (p.Parser [Offset Text])) @@ -126,7 +126,7 @@ (-> Nat Nat (Lexer Text)) (do p.Monad [char any - #let [char' (maybe.assume (text.nth |0 char))] + #let [char' (maybe.assume (text.nth 0 char))] _ (p.assert ($_ text/compose "Character is not within range: " (text.from-code bottom) "-" (text.from-code top)) (.and (n/>= bottom char') (n/<= top char')))] diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux index 658d51ae2..ffd937d8e 100644 --- a/stdlib/source/lux/data/text/regex.lux +++ b/stdlib/source/lux/data/text/regex.lux @@ -81,9 +81,9 @@ (def: re-range^ (l.Lexer Code) (do p.Monad - [from (|> regex-char^ (:: @ map (|>> (text.nth |0) maybe.assume))) + [from (|> regex-char^ (:: @ map (|>> (text.nth 0) maybe.assume))) _ (l.this "-") - to (|> regex-char^ (:: @ map (|>> (text.nth |0) maybe.assume)))] + to (|> regex-char^ (:: @ map (|>> (text.nth 0) maybe.assume)))] (wrap (` (l.range (~ (code.nat from)) (~ (code.nat to))))))) (def: re-char^ @@ -288,7 +288,7 @@ #.None [(inc idx) (code.identifier ["" (int/encode idx)])]) - access (if (n/> |0 num-captures) + access (if (n/> 0 num-captures) (` ((~! product.left) (~ name!))) name!)] [idx! @@ -303,7 +303,7 @@ parts)]] (wrap [(if capturing? (list.size names) - |0) + 0) (` (do p.Monad [(~ (' #let)) [(~ g!total) ""] (~+ (|> steps list.reverse list/join))] @@ -319,12 +319,12 @@ (function (_ input) (case (left input) (#e.Success [input' [lt lv]]) - (#e.Success [input' [lt (|0 lv)]]) + (#e.Success [input' [lt (0 lv)]]) (#e.Error _) (case (right input) (#e.Success [input' [rt rv]]) - (#e.Success [input' [rt (|1 rv)]]) + (#e.Success [input' [rt (1 rv)]]) (#e.Error error) (#e.Error error))))) @@ -346,7 +346,7 @@ (def: (prep-alternative [num-captures alt]) (-> [Nat Code] Code) - (if (n/> |0 num-captures) + (if (n/> 0 num-captures) alt (` ((~! unflatten^) (~ alt))))) diff --git a/stdlib/source/lux/data/text/unicode.lux b/stdlib/source/lux/data/text/unicode.lux index 96f16052a..011af390e 100644 --- a/stdlib/source/lux/data/text/unicode.lux +++ b/stdlib/source/lux/data/text/unicode.lux @@ -59,128 +59,128 @@ (do-template [ ] [(def: #export Segment (..segment (hex ) (hex )))] - [basic-latin "|0000" "|007F"] - [latin-1-supplement "|00A0" "|00FF"] - [latin-extended-a "|0100" "|017F"] - [latin-extended-b "|0180" "|024F"] - [ipa-extensions "|0250" "|02AF"] - [spacing-modifier-letters "|02B0" "|02FF"] - [combining-diacritical-marks "|0300" "|036F"] - [greek-and-coptic "|0370" "|03FF"] - [cyrillic "|0400" "|04FF"] - [cyrillic-supplementary "|0500" "|052F"] - [armenian "|0530" "|058F"] - [hebrew "|0590" "|05FF"] - [arabic "|0600" "|06FF"] - [syriac "|0700" "|074F"] - [thaana "|0780" "|07BF"] - [devanagari "|0900" "|097F"] - [bengali "|0980" "|09FF"] - [gurmukhi "|0A00" "|0A7F"] - [gujarati "|0A80" "|0AFF"] - [oriya "|0B00" "|0B7F"] - [tamil "|0B80" "|0BFF"] - [telugu "|0C00" "|0C7F"] - [kannada "|0C80" "|0CFF"] - [malayalam "|0D00" "|0D7F"] - [sinhala "|0D80" "|0DFF"] - [thai "|0E00" "|0E7F"] - [lao "|0E80" "|0EFF"] - [tibetan "|0F00" "|0FFF"] - [myanmar "|1000" "|109F"] - [georgian "|10A0" "|10FF"] - [hangul-jamo "|1100" "|11FF"] - [ethiopic "|1200" "|137F"] - [cherokee "|13A0" "|13FF"] - [unified-canadian-aboriginal-syllabics "|1400" "|167F"] - [ogham "|1680" "|169F"] - [runic "|16A0" "|16FF"] - [tagalog "|1700" "|171F"] - [hanunoo "|1720" "|173F"] - [buhid "|1740" "|175F"] - [tagbanwa "|1760" "|177F"] - [khmer "|1780" "|17FF"] - [mongolian "|1800" "|18AF"] - [limbu "|1900" "|194F"] - [tai-le "|1950" "|197F"] - [khmer-symbols "|19E0" "|19FF"] - [phonetic-extensions "|1D00" "|1D7F"] - [latin-extended-additional "|1E00" "|1EFF"] - [greek-extended "|1F00" "|1FFF"] - [general-punctuation "|2000" "|206F"] - [superscripts-and-subscripts "|2070" "|209F"] - [currency-symbols "|20A0" "|20CF"] - [combining-diacritical-marks-for-symbols "|20D0" "|20FF"] - [letterlike-symbols "|2100" "|214F"] - [number-forms "|2150" "|218F"] - [arrows "|2190" "|21FF"] - [mathematical-operators "|2200" "|22FF"] - [miscellaneous-technical "|2300" "|23FF"] - [control-pictures "|2400" "|243F"] - [optical-character-recognition "|2440" "|245F"] - [enclosed-alphanumerics "|2460" "|24FF"] - [box-drawing "|2500" "|257F"] - [block-elements "|2580" "|259F"] - [geometric-shapes "|25A0" "|25FF"] - [miscellaneous-symbols "|2600" "|26FF"] - [dingbats "|2700" "|27BF"] - [miscellaneous-mathematical-symbols-a "|27C0" "|27EF"] - [supplemental-arrows-a "|27F0" "|27FF"] - [braille-patterns "|2800" "|28FF"] - [supplemental-arrows-b "|2900" "|297F"] - [miscellaneous-mathematical-symbols-b "|2980" "|29FF"] - [supplemental-mathematical-operators "|2A00" "|2AFF"] - [miscellaneous-symbols-and-arrows "|2B00" "|2BFF"] - [cjk-radicals-supplement "|2E80" "|2EFF"] - [kangxi-radicals "|2F00" "|2FDF"] - [ideographic-description-characters "|2FF0" "|2FFF"] - [cjk-symbols-and-punctuation "|3000" "|303F"] - [hiragana "|3040" "|309F"] - [katakana "|30A0" "|30FF"] - [bopomofo "|3100" "|312F"] - [hangul-compatibility-jamo "|3130" "|318F"] - [kanbun "|3190" "|319F"] - [bopomofo-extended "|31A0" "|31BF"] - [katakana-phonetic-extensions "|31F0" "|31FF"] - [enclosed-cjk-letters-and-months "|3200" "|32FF"] - [cjk-compatibility "|3300" "|33FF"] - [cjk-unified-ideographs-extension-a "|3400" "|4DBF"] - [yijing-hexagram-symbols "|4DC0" "|4DFF"] - [cjk-unified-ideographs "|4E00" "|9FFF"] - [yi-syllables "|A000" "|A48F"] - [yi-radicals "|A490" "|A4CF"] - [hangul-syllables "|AC00" "|D7AF"] - [high-surrogates "|D800" "|DB7F"] - [high-private-use-surrogates "|DB80" "|DBFF"] - [low-surrogates "|DC00" "|DFFF"] - [private-use-area "|E000" "|F8FF"] - [cjk-compatibility-ideographs "|F900" "|FAFF"] - [alphabetic-presentation-forms "|FB00" "|FB4F"] - [arabic-presentation-forms-a "|FB50" "|FDFF"] - [variation-selectors "|FE00" "|FE0F"] - [combining-half-marks "|FE20" "|FE2F"] - [cjk-compatibility-forms "|FE30" "|FE4F"] - [small-form-variants "|FE50" "|FE6F"] - [arabic-presentation-forms-b "|FE70" "|FEFF"] - [halfwidth-and-fullwidth-forms "|FF00" "|FFEF"] - [specials "|FFF0" "|FFFF"] - [linear-b-syllabary "|10000" "|1007F"] - [linear-b-ideograms "|10080" "|100FF"] - [aegean-numbers "|10100" "|1013F"] - [old-italic "|10300" "|1032F"] - [gothic "|10330" "|1034F"] - [ugaritic "|10380" "|1039F"] - [deseret "|10400" "|1044F"] - [shavian "|10450" "|1047F"] - [osmanya "|10480" "|104AF"] - [cypriot-syllabary "|10800" "|1083F"] - [byzantine-musical-symbols "|1D000" "|1D0FF"] - [musical-symbols "|1D100" "|1D1FF"] - [tai-xuan-jing-symbols "|1D300" "|1D35F"] - [mathematical-alphanumeric-symbols "|1D400" "|1D7FF"] - [cjk-unified-ideographs-extension-b "|20000" "|2A6DF"] - [cjk-compatibility-ideographs-supplement "|2F800" "|2FA1F"] - [tags "|E0000" "|E007F"] + [basic-latin "0000" "007F"] + [latin-1-supplement "00A0" "00FF"] + [latin-extended-a "0100" "017F"] + [latin-extended-b "0180" "024F"] + [ipa-extensions "0250" "02AF"] + [spacing-modifier-letters "02B0" "02FF"] + [combining-diacritical-marks "0300" "036F"] + [greek-and-coptic "0370" "03FF"] + [cyrillic "0400" "04FF"] + [cyrillic-supplementary "0500" "052F"] + [armenian "0530" "058F"] + [hebrew "0590" "05FF"] + [arabic "0600" "06FF"] + [syriac "0700" "074F"] + [thaana "0780" "07BF"] + [devanagari "0900" "097F"] + [bengali "0980" "09FF"] + [gurmukhi "0A00" "0A7F"] + [gujarati "0A80" "0AFF"] + [oriya "0B00" "0B7F"] + [tamil "0B80" "0BFF"] + [telugu "0C00" "0C7F"] + [kannada "0C80" "0CFF"] + [malayalam "0D00" "0D7F"] + [sinhala "0D80" "0DFF"] + [thai "0E00" "0E7F"] + [lao "0E80" "0EFF"] + [tibetan "0F00" "0FFF"] + [myanmar "1000" "109F"] + [georgian "10A0" "10FF"] + [hangul-jamo "1100" "11FF"] + [ethiopic "1200" "137F"] + [cherokee "13A0" "13FF"] + [unified-canadian-aboriginal-syllabics "1400" "167F"] + [ogham "1680" "169F"] + [runic "16A0" "16FF"] + [tagalog "1700" "171F"] + [hanunoo "1720" "173F"] + [buhid "1740" "175F"] + [tagbanwa "1760" "177F"] + [khmer "1780" "17FF"] + [mongolian "1800" "18AF"] + [limbu "1900" "194F"] + [tai-le "1950" "197F"] + [khmer-symbols "19E0" "19FF"] + [phonetic-extensions "1D00" "1D7F"] + [latin-extended-additional "1E00" "1EFF"] + [greek-extended "1F00" "1FFF"] + [general-punctuation "2000" "206F"] + [superscripts-and-subscripts "2070" "209F"] + [currency-symbols "20A0" "20CF"] + [combining-diacritical-marks-for-symbols "20D0" "20FF"] + [letterlike-symbols "2100" "214F"] + [number-forms "2150" "218F"] + [arrows "2190" "21FF"] + [mathematical-operators "2200" "22FF"] + [miscellaneous-technical "2300" "23FF"] + [control-pictures "2400" "243F"] + [optical-character-recognition "2440" "245F"] + [enclosed-alphanumerics "2460" "24FF"] + [box-drawing "2500" "257F"] + [block-elements "2580" "259F"] + [geometric-shapes "25A0" "25FF"] + [miscellaneous-symbols "2600" "26FF"] + [dingbats "2700" "27BF"] + [miscellaneous-mathematical-symbols-a "27C0" "27EF"] + [supplemental-arrows-a "27F0" "27FF"] + [braille-patterns "2800" "28FF"] + [supplemental-arrows-b "2900" "297F"] + [miscellaneous-mathematical-symbols-b "2980" "29FF"] + [supplemental-mathematical-operators "2A00" "2AFF"] + [miscellaneous-symbols-and-arrows "2B00" "2BFF"] + [cjk-radicals-supplement "2E80" "2EFF"] + [kangxi-radicals "2F00" "2FDF"] + [ideographic-description-characters "2FF0" "2FFF"] + [cjk-symbols-and-punctuation "3000" "303F"] + [hiragana "3040" "309F"] + [katakana "30A0" "30FF"] + [bopomofo "3100" "312F"] + [hangul-compatibility-jamo "3130" "318F"] + [kanbun "3190" "319F"] + [bopomofo-extended "31A0" "31BF"] + [katakana-phonetic-extensions "31F0" "31FF"] + [enclosed-cjk-letters-and-months "3200" "32FF"] + [cjk-compatibility "3300" "33FF"] + [cjk-unified-ideographs-extension-a "3400" "4DBF"] + [yijing-hexagram-symbols "4DC0" "4DFF"] + [cjk-unified-ideographs "4E00" "9FFF"] + [yi-syllables "A000" "A48F"] + [yi-radicals "A490" "A4CF"] + [hangul-syllables "AC00" "D7AF"] + [high-surrogates "D800" "DB7F"] + [high-private-use-surrogates "DB80" "DBFF"] + [low-surrogates "DC00" "DFFF"] + [private-use-area "E000" "F8FF"] + [cjk-compatibility-ideographs "F900" "FAFF"] + [alphabetic-presentation-forms "FB00" "FB4F"] + [arabic-presentation-forms-a "FB50" "FDFF"] + [variation-selectors "FE00" "FE0F"] + [combining-half-marks "FE20" "FE2F"] + [cjk-compatibility-forms "FE30" "FE4F"] + [small-form-variants "FE50" "FE6F"] + [arabic-presentation-forms-b "FE70" "FEFF"] + [halfwidth-and-fullwidth-forms "FF00" "FFEF"] + [specials "FFF0" "FFFF"] + [linear-b-syllabary "10000" "1007F"] + [linear-b-ideograms "10080" "100FF"] + [aegean-numbers "10100" "1013F"] + [old-italic "10300" "1032F"] + [gothic "10330" "1034F"] + [ugaritic "10380" "1039F"] + [deseret "10400" "1044F"] + [shavian "10450" "1047F"] + [osmanya "10480" "104AF"] + [cypriot-syllabary "10800" "1083F"] + [byzantine-musical-symbols "1D000" "1D0FF"] + [musical-symbols "1D100" "1D1FF"] + [tai-xuan-jing-symbols "1D300" "1D35F"] + [mathematical-alphanumeric-symbols "1D400" "1D7FF"] + [cjk-unified-ideographs-extension-b "20000" "2A6DF"] + [cjk-compatibility-ideographs-supplement "2F800" "2FA1F"] + [tags "E0000" "E007F"] ) (type: #export Set (Tree Segment [])) @@ -203,7 +203,7 @@ (..singleton (:: Monoid compose left right)) _ - (let [[sides extra] (n//% |2 (list.size segments)) + (let [[sides extra] (n//% 2 (list.size segments)) [left+ right+] (list.split (n/+ sides extra) segments)] (finger.branch (set left+) (set right+))))) diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux index 767a4976f..5b91fc526 100644 --- a/stdlib/source/lux/host.jvm.lux +++ b/stdlib/source/lux/host.jvm.lux @@ -1921,7 +1921,7 @@ {type (generic-type^ imports (list))} size) {#.doc (doc "Create an array of the given type, with the given size." - (array Object |10))} + (array Object 10))} (case type (^template [ ] (^ (#GenericClass (list))) @@ -1967,7 +1967,7 @@ (syntax: #export (array-read idx array) {#.doc (doc "Loads an element from an array." - (array-read |10 my-array))} + (array-read 10 my-array))} (case array [_ (#.Identifier array-name)] (do Monad @@ -1996,7 +1996,7 @@ (syntax: #export (array-write idx value array) {#.doc (doc "Stores an element into an array." - (array-write |10 my-object my-array))} + (array-write 10 my-object my-array))} (case array [_ (#.Identifier array-name)] (do Monad diff --git a/stdlib/source/lux/io.lux b/stdlib/source/lux/io.lux index ed277b4c3..9295795be 100644 --- a/stdlib/source/lux/io.lux +++ b/stdlib/source/lux/io.lux @@ -21,7 +21,7 @@ "Some value...")))} (case tokens (^ (list value)) - (let [blank (: Code [["" |0 |0] (#.Identifier ["" ""])])] + (let [blank (: Code [["" 0 0] (#.Identifier ["" ""])])] (#.Right [state (list (` ([(~ blank) (~ blank)] (~ value))))])) _ diff --git a/stdlib/source/lux/macro/code.lux b/stdlib/source/lux/macro/code.lux index 0de1e5772..f04503e2f 100644 --- a/stdlib/source/lux/macro/code.lux +++ b/stdlib/source/lux/macro/code.lux @@ -27,7 +27,7 @@ ## (Ann Cursor (Code' (Ann Cursor)))) ## [Utils] -(def: _cursor Cursor ["" |0 |0]) +(def: _cursor Cursor ["" 0 0]) ## [Functions] (do-template [ ] diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux index 9be5a2ad4..135cad97e 100644 --- a/stdlib/source/lux/macro/poly.lux +++ b/stdlib/source/lux/macro/poly.lux @@ -153,7 +153,7 @@ (do p.Monad [headT any] (let [members ( (type.un-name headT))] - (if (n/> |1 (list.size members)) + (if (n/> 1 (list.size members)) (local members poly) (p.fail (ex.construct headT))))))] @@ -166,7 +166,7 @@ (do p.Monad [headT any #let [[num-arg bodyT] (type.flatten-univ-q (type.un-name headT))]] - (if (n/= |0 num-arg) + (if (n/= 0 num-arg) (p.fail (ex.construct not-polymorphic headT)) (wrap [num-arg bodyT])))) @@ -178,22 +178,22 @@ [num-args non-poly] (local (list headT) polymorphic') env ..env #let [funcL (label funcI) - [all-varsL env'] (loop [current-arg |0 + [all-varsL env'] (loop [current-arg 0 env' env all-varsL (: (List Code) (list))] (if (n/< num-args current-arg) - (if (n/= |0 current-arg) + (if (n/= 0 current-arg) (let [varL (label (inc funcI))] (recur (inc current-arg) (|> env' (dict.put funcI [headT funcL]) (dict.put (inc funcI) [(#.Parameter (inc funcI)) varL])) (#.Cons varL all-varsL))) - (let [partialI (|> current-arg (n/* |2) (n/+ funcI)) + (let [partialI (|> current-arg (n/* 2) (n/+ funcI)) partial-varI (inc partialI) partial-varL (label partial-varI) - partialC (` ((~ funcL) (~+ (|> (list.n/range |0 (dec num-args)) - (list/map (|>> (n/* |2) inc (n/+ funcI) label)) + partialC (` ((~ funcL) (~+ (|> (list.n/range 0 (dec num-args)) + (list/map (|>> (n/* 2) inc (n/+ funcI) label)) list.reverse))))] (recur (inc current-arg) (|> env' @@ -212,7 +212,7 @@ (do p.Monad [headT any #let [[inputsT outputT] (type.flatten-function (type.un-name headT))]] - (if (n/> |0 (list.size inputsT)) + (if (n/> 0 (list.size inputsT)) (p.and (local inputsT in-poly) (local (list outputT) out-poly)) (p.fail (ex.construct not-function headT))))) @@ -222,7 +222,7 @@ (do p.Monad [headT any #let [[funcT paramsT] (type.flatten-application (type.un-name headT))]] - (if (n/= |0 (list.size paramsT)) + (if (n/= 0 (list.size paramsT)) (p.fail (ex.construct not-application headT)) (local (#.Cons funcT paramsT) poly)))) @@ -242,10 +242,10 @@ (def: (adjusted-idx env idx) (-> Env Nat Nat) - (let [env-level (n// |2 (dict.size env)) - parameter-level (n// |2 idx) - parameter-idx (n/% |2 idx)] - (|> env-level dec (n/- parameter-level) (n/* |2) (n/+ parameter-idx)))) + (let [env-level (n// 2 (dict.size env)) + parameter-level (n// 2 idx) + parameter-idx (n/% 2 idx)] + (|> env-level dec (n/- parameter-level) (n/* 2) (n/+ parameter-idx)))) (def: #export parameter (Poly Code) @@ -323,8 +323,8 @@ headT any] (case (type.un-name headT) (^multi (#.Apply (#.Named ["lux" "Nothing"] _) (#.Parameter funcT-idx)) - (n/= |0 (adjusted-idx env funcT-idx)) - [(dict.get |0 env) (#.Some [self-type self-call])]) + (n/= 0 (adjusted-idx env funcT-idx)) + [(dict.get 0 env) (#.Some [self-type self-call])]) (wrap self-call) _ @@ -335,7 +335,7 @@ (do p.Monad [env ..env [funcT argsT] (apply (p.and any (p.many any))) - _ (local (list funcT) (..parameter! |0)) + _ (local (list funcT) (..parameter! 0)) allC (let [allT (list& funcT argsT)] (|> allT (monad.map @ (function.constant ..parameter)) @@ -425,13 +425,13 @@ (#.Parameter idx) (let [idx (adjusted-idx env idx)] - (if (n/= |0 idx) + (if (n/= 0 idx) (|> (dict.get idx env) maybe.assume product.left (to-code env)) (` (.$ (~ (code.nat (dec idx))))))) (#.Apply (#.Named ["lux" "Nothing"] _) (#.Parameter idx)) (let [idx (adjusted-idx env idx)] - (if (n/= |0 idx) + (if (n/= 0 idx) (|> (dict.get idx env) maybe.assume product.left (to-code env)) (undefined))) diff --git a/stdlib/source/lux/macro/poly/equivalence.lux b/stdlib/source/lux/macro/poly/equivalence.lux index 6f356c060..af714ed51 100644 --- a/stdlib/source/lux/macro/poly/equivalence.lux +++ b/stdlib/source/lux/macro/poly/equivalence.lux @@ -116,7 +116,7 @@ (do @ [g!eqs (poly.tuple (p.many Equivalence)) #let [g!_ (code.local-identifier "_____________") - indices (|> (list.size g!eqs) dec (list.n/range |0)) + indices (|> (list.size g!eqs) dec (list.n/range 0)) g!lefts (list/map (|>> nat/encode (text/compose "left") code.local-identifier) indices) g!rights (list/map (|>> nat/encode (text/compose "right") code.local-identifier) indices)]] (wrap (` (: (~ (@Equivalence inputT)) diff --git a/stdlib/source/lux/macro/poly/functor.lux b/stdlib/source/lux/macro/poly/functor.lux index 711179404..205e78566 100644 --- a/stdlib/source/lux/macro/poly/functor.lux +++ b/stdlib/source/lux/macro/poly/functor.lux @@ -29,7 +29,7 @@ #let [num-vars (list.size varsC)] #let [@Functor (: (-> Type Code) (function (_ unwrappedT) - (if (n/= |1 num-vars) + (if (n/= 1 num-vars) (` ((~! functor.Functor) (~ (poly.to-code *env* unwrappedT)))) (let [paramsC (|> num-vars dec list.indices (list/map (|>> %n code.local-identifier)))] (` (All [(~+ paramsC)] @@ -39,7 +39,7 @@ ($_ p.either ## Type-var (do p.Monad - [#let [varI (|> num-vars (n/* |2) dec)] + [#let [varI (|> num-vars (n/* 2) dec)] _ (poly.parameter! varI)] (wrap (` ((~ funcC) (~ valueC))))) ## Variants @@ -54,7 +54,7 @@ ## Tuples (do p.Monad [pairsCC (: (poly.Poly (List [Code Code])) - (poly.tuple (loop [idx |0 + (poly.tuple (loop [idx 0 pairsCC (: (List [Code Code]) (list))] (p.either (let [slotC (|> idx %n (format "____________slot") code.local-identifier)] @@ -75,7 +75,7 @@ [inT+ outC] (poly.function (p.many poly.any) (Arg outL)) #let [inC+ (|> (list.size inT+) dec - (list.n/range |0) + (list.n/range 0) (list/map (|>> %n (format "____________inC") code.local-identifier)))]] (wrap (` (function ((~ g!) (~+ inC+)) (let [(~ outL) ((~ valueC) (~+ inC+))] diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/macro/poly/json.lux index b9710773a..9eabdc816 100644 --- a/stdlib/source/lux/macro/poly/json.lux +++ b/stdlib/source/lux/macro/poly/json.lux @@ -44,12 +44,12 @@ (function (_ input) (non-rec (rec-encode non-rec) input))) -(def: low-mask Nat (|> |1 (i64.left-shift |32) dec)) -(def: high-mask Nat (|> low-mask (i64.left-shift |32))) +(def: low-mask Nat (|> 1 (i64.left-shift 32) dec)) +(def: high-mask Nat (|> low-mask (i64.left-shift 32))) (structure: _ (Codec JSON Nat) (def: (encode input) - (let [high (|> input (i64.and high-mask) (i64.logical-right-shift |32)) + (let [high (|> input (i64.and high-mask) (i64.logical-right-shift 32)) low (i64.and low-mask input)] (#//.Array (row (|> high .int int-to-frac #//.Number) (|> low .int int-to-frac #//.Number))))) @@ -59,7 +59,7 @@ (do p.Monad [high //.number low //.number]) - (wrap (n/+ (|> high frac-to-int .nat (i64.left-shift |32)) + (wrap (n/+ (|> high frac-to-int .nat (i64.left-shift 32)) (|> low frac-to-int .nat)))))) (structure: _ (Codec JSON Int) @@ -164,7 +164,7 @@ [g!encoders (poly.tuple (p.many Codec//encode)) #let [g!_ (code.local-identifier "_______") g!members (|> (list.size g!encoders) dec - (list.n/range |0) + (list.n/range 0) (list/map (|>> nat/encode code.local-identifier)))]] (wrap (` (: (~ (@JSON//encode inputT)) (function ((~ g!_) [(~+ g!members)]) diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux index 63eedfc9a..cdaf54461 100644 --- a/stdlib/source/lux/math.lux +++ b/stdlib/source/lux/math.lux @@ -88,9 +88,9 @@ (def: #export (factorial n) (-> Nat Nat) - (loop [acc |1 + (loop [acc 1 n n] - (if (n/<= |1 n) + (if (n/<= 1 n) acc (recur (n/* n acc) (dec n))))) @@ -118,7 +118,7 @@ (|> a ( ( a b)) (<*> b)) ))] - [Nat n/mod n/gcd n/lcm |0 n/* n// n/-] + [Nat n/mod n/gcd n/lcm 0 n/* n// n/-] [Int i/mod i/gcd i/lcm +0 i/* i// i/-] ) @@ -251,7 +251,7 @@ (infix [sin [x i/+ y]]) (infix [[x n/< y] and [y n/< z]]) (infix [#and x n/< y n/< z]) - (infix [(n/* |3 |9) gcd |450]) + (infix [(n/* 3 9) gcd 450]) "The rules for infix syntax are simple." "If you want your binary function to work well with it." diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux index 1fc5c5476..fdbf202cf 100644 --- a/stdlib/source/lux/math/random.lux +++ b/stdlib/source/lux/math/random.lux @@ -88,7 +88,7 @@ (Random Bit) (function (_ prng) (let [[prng output] (prng [])] - [prng (|> output (i64.and |1) (n/= |1))]))) + [prng (|> output (i64.and 1) (n/= 1))]))) (def: #export i64 (Random I64) @@ -96,7 +96,7 @@ (let [[prng left] (prng []) [prng right] (prng [])] [prng (|> left - (i64.left-shift |32) + (i64.left-shift 32) ("lux i64 +" right))]))) (def: #export nat @@ -131,7 +131,7 @@ (def: #export (text char-gen size) (-> (Random Char) Nat (Random Text)) - (if (n/= |0 size) + (if (n/= 0 size) (:: Monad wrap "") (do Monad [x char-gen @@ -170,10 +170,10 @@ (if ? (do @ [=left left] - (wrap (|0 =left))) + (wrap (0 =left))) (do @ [=right right] - (wrap (|1 =right)))))) + (wrap (1 =right)))))) (def: #export (either left right) {#.doc "Homogeneous alternative combinator."} @@ -204,7 +204,7 @@ (do-template [ ] [(def: #export ( size value-gen) (All [a] (-> Nat (Random a) (Random ( a)))) - (if (n/> |0 size) + (if (n/> 0 size) (do Monad [x value-gen xs ( (dec size) value-gen)] @@ -229,7 +229,7 @@ (def: #export (set Hash size value-gen) (All [a] (-> (Hash a) Nat (Random a) (Random (Set a)))) - (if (n/> |0 size) + (if (n/> 0 size) (do Monad [xs (set Hash (dec size) value-gen)] (loop [_ []] @@ -243,7 +243,7 @@ (def: #export (dictionary Hash size key-gen value-gen) (All [k v] (-> (Hash k) Nat (Random k) (Random v) (Random (Dictionary k v)))) - (if (n/> |0 size) + (if (n/> 0 size) (do Monad [kv (dictionary Hash (dec size) key-gen value-gen)] (loop [_ []] @@ -260,7 +260,7 @@ (All [a] (-> PRNG (Random a) [PRNG a])) (calc prng)) -(def: pcg-32-magic-mult Nat |6364136223846793005) +(def: pcg-32-magic-mult Nat 6364136223846793005) (def: #export (pcg-32 [inc seed]) {#.doc "An implementation of the PCG32 algorithm. @@ -269,11 +269,11 @@ (-> [(I64 Any) (I64 Any)] PRNG) (function (_ _) [(|> seed .nat (n/* pcg-32-magic-mult) ("lux i64 +" inc) [inc] pcg-32) - (let [rot (|> seed .i64 (i64.logical-right-shift |59))] + (let [rot (|> seed .i64 (i64.logical-right-shift 59))] (|> seed - (i64.logical-right-shift |18) + (i64.logical-right-shift 18) (i64.xor seed) - (i64.logical-right-shift |27) + (i64.logical-right-shift 27) (i64.rotate-right rot) .i64))])) @@ -285,10 +285,10 @@ (function (_ _) [(let [s01 (i64.xor s0 s1)] (xoroshiro-128+ [(|> s0 - (i64.rotate-left |55) + (i64.rotate-left 55) (i64.xor s01) - (i64.xor (i64.left-shift |14 s01))) - (i64.rotate-left |36 s01)])) + (i64.xor (i64.left-shift 14 s01))) + (i64.rotate-left 36 s01)])) ("lux i64 +" s0 s1)])) (def: (swap from to vec) @@ -307,7 +307,7 @@ [rand nat] (wrap (swap idx (n/% _size rand) vec)))) row - (list.n/range |0 (dec _size)))] + (list.n/range 0 (dec _size)))] (|> _shuffle - (run (pcg-32 [|123 seed])) + (run (pcg-32 [123 seed])) product.right))) diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux index 3230ca27e..26e99fbce 100644 --- a/stdlib/source/lux/test.lux +++ b/stdlib/source/lux/test.lux @@ -33,12 +33,12 @@ (type: #export Test (r.Random (Promise [Counters Text]))) -(def: pcg-32-magic-inc Nat |12345) +(def: pcg-32-magic-inc Nat 12345) ## [Values] -(def: success Counters [|1 |0]) -(def: failure Counters [|0 |1]) -(def: start Counters [|0 |0]) +(def: success Counters [1 0]) +(def: failure Counters [0 1]) +(def: start Counters [0 0]) (def: (add-counters [s f] [ts tf]) (-> Counters Counters Counters) @@ -87,7 +87,7 @@ (def: failed? (-> Counters Bit) - (|>> product.right (n/> |0))) + (|>> product.right (n/> 0))) (def: #export (seed value test) (-> Seed Test Test) @@ -103,10 +103,10 @@ (def: #export (times amount test) (-> Nat Test Test) - (cond (n/= |0 amount) + (cond (n/= 0 amount) (fail "Cannot try a test 0 times.") - (n/= |1 amount) + (n/= 1 amount) test ## else @@ -167,7 +167,7 @@ "By default, random tests will be tried 100 times, you can specify the amount you want:" (context: "Addition & Substraction" - (<| (times |1234) + (<| (times 1234) (do @ [x (:: @ map rand-gen) y (:: @ map rand-gen)] @@ -177,7 +177,7 @@ "If a test fails, you'll be shown a seed that you can then use to reproduce a failing scenario." (context: "Addition & Substraction" - (<| (seed |987654321) + (<| (seed 987654321) (do @ [x (:: @ map rand-gen) y (:: @ map rand-gen)] @@ -235,8 +235,8 @@ (:: @ map list/join)))] (wrap (list (` (: (~! (IO Any)) ((~! io) (exec ((~! do) (~! promise.Monad) - [(~' #let) [(~ g!total-successes) |0 - (~ g!total-failures) |0] + [(~' #let) [(~ g!total-successes) 0 + (~ g!total-failures) 0] (~+ (|> tests (list/map (function (_ [module-name test desc]) (` [(~ (code.text module-name)) (~ (code.identifier [module-name test])) (~ (code.text desc))]))) @@ -248,7 +248,7 @@ list/join))] (exec (log! ((~! success-message) (~ g!total-successes) (~ g!total-failures))) ((~! promise.future) - ((~! io.exit) (if (n/> |0 (~ g!total-failures)) + ((~! io.exit) (if (n/> 0 (~ g!total-failures)) +1 +0))))) []))))))))) diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux index 688546698..b902b631f 100644 --- a/stdlib/source/lux/time/date.lux +++ b/stdlib/source/lux/time/date.lux @@ -57,18 +57,18 @@ (def: (month-to-nat month) (-> Month Nat) (case month - #January |0 - #February |1 - #March |2 - #April |3 - #May |4 - #June |5 - #July |6 - #August |7 - #September |8 - #October |9 - #November |10 - #December |11)) + #January 0 + #February 1 + #March 2 + #April 3 + #May 4 + #June 5 + #July 6 + #August 7 + #September 8 + #October 9 + #November 10 + #December 11)) (structure: #export _ (Order Month) (def: eq Equivalence) @@ -142,13 +142,13 @@ (def: (day-to-nat day) (-> Day Nat) (case day - #Sunday |0 - #Monday |1 - #Tuesday |2 - #Wednesday |3 - #Thursday |4 - #Friday |5 - #Saturday |6)) + #Sunday 0 + #Monday 1 + #Tuesday 2 + #Wednesday 3 + #Thursday 4 + #Friday 5 + #Saturday 6)) (structure: #export _ (Order Day) (def: eq Equivalence) @@ -246,7 +246,7 @@ (def: lex-section (l.Lexer Int) - (p.codec number.Codec (l.exactly |2 l.decimal))) + (p.codec number.Codec (l.exactly 2 l.decimal))) (def: (leap-years year) (-> Int Int) @@ -256,14 +256,14 @@ (def: normal-months (Row Nat) - (row |31 |28 |31 - |30 |31 |30 - |31 |31 |30 - |31 |30 |31)) + (row 31 28 31 + 30 31 30 + 31 31 30 + 31 30 31)) (def: leap-year-months (Row Nat) - (row.update [|1] inc normal-months)) + (row.update [1] inc normal-months)) (def: (divisible? factor input) (-> Int Int Bit) diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux index 2119608e9..d6c506218 100644 --- a/stdlib/source/lux/time/instant.lux +++ b/stdlib/source/lux/time/instant.lux @@ -108,14 +108,14 @@ (def: normal-months (Row Nat) - (row |31 |28 |31 - |30 |31 |30 - |31 |31 |30 - |31 |30 |31)) + (row 31 28 31 + 30 31 30 + 31 31 30 + 31 30 31)) (def: leap-year-months (Row Nat) - (row.update [|1] inc normal-months)) + (row.update [1] inc normal-months)) (def: (find-month months time) (-> (Row Nat) duration.Duration [Nat duration.Duration]) @@ -125,14 +125,14 @@ (if (i/= +0 (duration.query month-duration time-left)) [current-month time-left] [(inc current-month) (duration.merge (duration.scale -1 month-duration) time-left)]))) - [|0 time] + [0 time] months) (row/fold (function (_ month-days [current-month time-left]) (let [month-duration (duration.scale (.int month-days) duration.day)] (if (i/= +0 (duration.query month-duration time-left)) [current-month time-left] [(dec current-month) (duration.merge month-duration time-left)]))) - [|11 time] + [11 time] (row.reverse months)))) (def: (pad value) @@ -227,11 +227,11 @@ (def: lex-section (l.Lexer Int) - (p.codec number.Codec (l.exactly |2 l.decimal))) + (p.codec number.Codec (l.exactly 2 l.decimal))) (def: lex-millis (l.Lexer Int) - (p.either (|> (l.at-most |3 l.decimal) + (p.either (|> (l.at-most 3 l.decimal) (p.codec number.Codec) (p.after (l.this "."))) (:: p.Monad wrap +0))) @@ -288,7 +288,7 @@ month-days-so-far (|> months row.to-list (list.take (.nat (dec utc-month))) - (list/fold n/+ |0)) + (list/fold n/+ 0)) total-days (|> year-days-so-far (i/+ (.int month-days-so-far)) (i/+ (dec utc-day)))]] diff --git a/stdlib/source/lux/type.lux b/stdlib/source/lux/type.lux index 851039728..5dd1e905f 100644 --- a/stdlib/source/lux/type.lux +++ b/stdlib/source/lux/type.lux @@ -93,7 +93,7 @@ (do-template [ ] [(def: #export ( type) (-> Type [Nat Type]) - (loop [num-args |0 + (loop [num-args 0 type type] (case type ( env sub-type) @@ -305,7 +305,7 @@ [(def: #export ( size body) (-> Nat Type Type) (case size - |0 body + 0 body _ (|> body ( (dec size)) ( (list)))))] [univ-q #.UnivQ] @@ -333,7 +333,7 @@ (def: #export (array level elem-type) (-> Nat Type Type) (case level - |0 elem-type + 0 elem-type _ (|> elem-type (array (dec level)) (list) (#.Primitive "#Array")))) (syntax: #export (:log! {input (p.or s.identifier diff --git a/stdlib/source/lux/type/check.lux b/stdlib/source/lux/type/check.lux index f09b8617b..ce5ce652a 100644 --- a/stdlib/source/lux/type/check.lux +++ b/stdlib/source/lux/type/check.lux @@ -298,8 +298,8 @@ (def: #export fresh-context Type-Context - {#.var-counter |0 - #.ex-counter |0 + {#.var-counter 0 + #.ex-counter 0 #.var-bindings (list) }) @@ -357,7 +357,7 @@ then) (do Monad [ring (ring id) - _ (assert "" (n/> |1 (set.size ring))) + _ (assert "" (n/> 1 (set.size ring))) _ (monad.map @ (update type) (set.to-list ring))] then) (do Monad diff --git a/stdlib/source/lux/type/implicit.lux b/stdlib/source/lux/type/implicit.lux index fad0bfb5d..6f26a01f8 100644 --- a/stdlib/source/lux/type/implicit.lux +++ b/stdlib/source/lux/type/implicit.lux @@ -65,12 +65,12 @@ (find-member-type idx sig-type')) (#.Product left right) - (if (n/= |0 idx) + (if (n/= 0 idx) (:: check.Monad wrap left) (find-member-type (dec idx) right)) _ - (if (n/= |0 idx) + (if (n/= 0 idx) (:: check.Monad wrap sig-type) (check.fail (format "Cannot find member type " (%n idx) " for " (%type sig-type)))))) @@ -326,10 +326,10 @@ (::: eq.= x y) "(List Nat) equivalence" (::: = - (list.n/range |1 |10) - (list.n/range |1 |10)) + (list.n/range 1 10) + (list.n/range 1 10)) "(Functor List) map" - (::: map inc (list.n/range |0 |9)) + (::: map inc (list.n/range 0 9)) "Caveat emptor: You need to make sure to import the module of any structure you want to use." "Otherwise, this macro will not find it.")} (case args diff --git a/stdlib/source/lux/type/resource.lux b/stdlib/source/lux/type/resource.lux index 0912c2482..d3f7b7ab0 100644 --- a/stdlib/source/lux/type/resource.lux +++ b/stdlib/source/lux/type/resource.lux @@ -185,7 +185,7 @@ (do p.Monad [raw s.nat _ (p.assert (ex.construct amount-cannot-be-zero []) - (n/> |0 raw))] + (n/> 0 raw))] (wrap raw))) (do-template [ ] diff --git a/stdlib/source/lux/world/binary.lux b/stdlib/source/lux/world/binary.lux index 0b72af60b..a125b8067 100644 --- a/stdlib/source/lux/world/binary.lux +++ b/stdlib/source/lux/world/binary.lux @@ -30,7 +30,7 @@ (def: byte-mask I64 - (|> |1 (i64.left-shift |8) dec .i64)) + (|> 1 (i64.left-shift 8) dec .i64)) (def: i64 (-> (primitive "java.lang.Byte") I64) @@ -52,34 +52,34 @@ (def: #export (read/16 idx binary) (-> Nat Binary (Error I64)) - (if (n/< (host.array-length binary) (n/+ |1 idx)) + (if (n/< (host.array-length binary) (n/+ 1 idx)) (#error.Success ($_ i64.or - (i64.left-shift |8 (..i64 (host.array-read idx binary))) - (..i64 (host.array-read (n/+ |1 idx) binary)))) + (i64.left-shift 8 (..i64 (host.array-read idx binary))) + (..i64 (host.array-read (n/+ 1 idx) binary)))) (ex.throw index-out-of-bounds (%n idx)))) (def: #export (read/32 idx binary) (-> Nat Binary (Error I64)) - (if (n/< (host.array-length binary) (n/+ |3 idx)) + (if (n/< (host.array-length binary) (n/+ 3 idx)) (#error.Success ($_ i64.or - (i64.left-shift |24 (..i64 (host.array-read idx binary))) - (i64.left-shift |16 (..i64 (host.array-read (n/+ |1 idx) binary))) - (i64.left-shift |8 (..i64 (host.array-read (n/+ |2 idx) binary))) - (..i64 (host.array-read (n/+ |3 idx) binary)))) + (i64.left-shift 24 (..i64 (host.array-read idx binary))) + (i64.left-shift 16 (..i64 (host.array-read (n/+ 1 idx) binary))) + (i64.left-shift 8 (..i64 (host.array-read (n/+ 2 idx) binary))) + (..i64 (host.array-read (n/+ 3 idx) binary)))) (ex.throw index-out-of-bounds (%n idx)))) (def: #export (read/64 idx binary) (-> Nat Binary (Error I64)) - (if (n/< (host.array-length binary) (n/+ |7 idx)) + (if (n/< (host.array-length binary) (n/+ 7 idx)) (#error.Success ($_ i64.or - (i64.left-shift |56 (..i64 (host.array-read idx binary))) - (i64.left-shift |48 (..i64 (host.array-read (n/+ |1 idx) binary))) - (i64.left-shift |40 (..i64 (host.array-read (n/+ |2 idx) binary))) - (i64.left-shift |32 (..i64 (host.array-read (n/+ |3 idx) binary))) - (i64.left-shift |24 (..i64 (host.array-read (n/+ |4 idx) binary))) - (i64.left-shift |16 (..i64 (host.array-read (n/+ |5 idx) binary))) - (i64.left-shift |8 (..i64 (host.array-read (n/+ |6 idx) binary))) - (..i64 (host.array-read (n/+ |7 idx) binary)))) + (i64.left-shift 56 (..i64 (host.array-read idx binary))) + (i64.left-shift 48 (..i64 (host.array-read (n/+ 1 idx) binary))) + (i64.left-shift 40 (..i64 (host.array-read (n/+ 2 idx) binary))) + (i64.left-shift 32 (..i64 (host.array-read (n/+ 3 idx) binary))) + (i64.left-shift 24 (..i64 (host.array-read (n/+ 4 idx) binary))) + (i64.left-shift 16 (..i64 (host.array-read (n/+ 5 idx) binary))) + (i64.left-shift 8 (..i64 (host.array-read (n/+ 6 idx) binary))) + (..i64 (host.array-read (n/+ 7 idx) binary)))) (ex.throw index-out-of-bounds (%n idx)))) (def: #export (write/8 idx value binary) @@ -92,36 +92,36 @@ (def: #export (write/16 idx value binary) (-> Nat (I64 Any) Binary (Error Binary)) - (if (n/< (host.array-length binary) (n/+ |1 idx)) + (if (n/< (host.array-length binary) (n/+ 1 idx)) (exec (|> binary - (host.array-write idx (..byte (i64.logical-right-shift |8 value))) - (host.array-write (n/+ |1 idx) (..byte value))) + (host.array-write idx (..byte (i64.logical-right-shift 8 value))) + (host.array-write (n/+ 1 idx) (..byte value))) (#error.Success binary)) (ex.throw index-out-of-bounds (%n idx)))) (def: #export (write/32 idx value binary) (-> Nat (I64 Any) Binary (Error Binary)) - (if (n/< (host.array-length binary) (n/+ |3 idx)) + (if (n/< (host.array-length binary) (n/+ 3 idx)) (exec (|> binary - (host.array-write idx (..byte (i64.logical-right-shift |24 value))) - (host.array-write (n/+ |1 idx) (..byte (i64.logical-right-shift |16 value))) - (host.array-write (n/+ |2 idx) (..byte (i64.logical-right-shift |8 value))) - (host.array-write (n/+ |3 idx) (..byte value))) + (host.array-write idx (..byte (i64.logical-right-shift 24 value))) + (host.array-write (n/+ 1 idx) (..byte (i64.logical-right-shift 16 value))) + (host.array-write (n/+ 2 idx) (..byte (i64.logical-right-shift 8 value))) + (host.array-write (n/+ 3 idx) (..byte value))) (#error.Success binary)) (ex.throw index-out-of-bounds (%n idx)))) (def: #export (write/64 idx value binary) (-> Nat (I64 Any) Binary (Error Binary)) - (if (n/< (host.array-length binary) (n/+ |7 idx)) + (if (n/< (host.array-length binary) (n/+ 7 idx)) (exec (|> binary - (host.array-write idx (..byte (i64.logical-right-shift |56 value))) - (host.array-write (n/+ |1 idx) (..byte (i64.logical-right-shift |48 value))) - (host.array-write (n/+ |2 idx) (..byte (i64.logical-right-shift |40 value))) - (host.array-write (n/+ |3 idx) (..byte (i64.logical-right-shift |32 value))) - (host.array-write (n/+ |4 idx) (..byte (i64.logical-right-shift |24 value))) - (host.array-write (n/+ |5 idx) (..byte (i64.logical-right-shift |16 value))) - (host.array-write (n/+ |6 idx) (..byte (i64.logical-right-shift |8 value))) - (host.array-write (n/+ |7 idx) (..byte value))) + (host.array-write idx (..byte (i64.logical-right-shift 56 value))) + (host.array-write (n/+ 1 idx) (..byte (i64.logical-right-shift 48 value))) + (host.array-write (n/+ 2 idx) (..byte (i64.logical-right-shift 40 value))) + (host.array-write (n/+ 3 idx) (..byte (i64.logical-right-shift 32 value))) + (host.array-write (n/+ 4 idx) (..byte (i64.logical-right-shift 24 value))) + (host.array-write (n/+ 5 idx) (..byte (i64.logical-right-shift 16 value))) + (host.array-write (n/+ 6 idx) (..byte (i64.logical-right-shift 8 value))) + (host.array-write (n/+ 7 idx) (..byte value))) (#error.Success binary)) (ex.throw index-out-of-bounds (%n idx)))) diff --git a/stdlib/source/lux/world/net/udp.jvm.lux b/stdlib/source/lux/world/net/udp.jvm.lux index 893538657..e8eeb1b1b 100644 --- a/stdlib/source/lux/world/net/udp.jvm.lux +++ b/stdlib/source/lux/world/net/udp.jvm.lux @@ -58,8 +58,8 @@ [addresses (InetAddress::getAllByName [address])] (: (io.IO (e.Error InetAddress)) (case (array.size addresses) - |0 (io.io (ex.throw cannot-resolve-address address)) - |1 (wrap (maybe.assume (array.read |0 addresses))) + 0 (io.io (ex.throw cannot-resolve-address address)) + 1 (wrap (maybe.assume (array.read 0 addresses))) _ (io.io (ex.throw multiple-candidate-addresses address)))))) (abstract: #export UDP {} diff --git a/stdlib/test/test/lux.lux b/stdlib/test/test/lux.lux index f52b7764e..61a0299ea 100644 --- a/stdlib/test/test/lux.lux +++ b/stdlib/test/test/lux.lux @@ -15,9 +15,9 @@ test]) (context: "Value identity." - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) + [size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10)))) x (r.unicode size) y (r.unicode size)] ($_ seq @@ -31,14 +31,14 @@ (do-template [category rand-gen even? odd? = < >] [(context: (format "[" category "] " "Simple operations.") - (<| (times |100) + (<| (times 100) (do @ [value rand-gen] ($_ seq (test (format "[" category "] " "Moving up-down or down-up should result in same value.") (and (|> value inc dec (= value)) (|> value dec inc (= value)))) - (test (format "[" category "] " "(x|1) > x && (x-1) < x") + (test (format "[" category "] " "(x1) > x && (x-1) < x") (and (|> value inc (> value)) (|> value dec (< value)))) (test (format "[" category "] " "Every odd/even number is surrounded by two of the other kind.") @@ -54,7 +54,7 @@ (do-template [category rand-gen = < > <= >= min max] [(context: (format "[" category "] " "(More) simple operations.") - (<| (times |100) + (<| (times 100) (do @ [x rand-gen y rand-gen] @@ -77,7 +77,7 @@ (do-template [category rand-gen = + - * / <%> > <0> <1> ] [(context: (format "[" category "] " "Additive identity") - (<| (times |100) + (<| (times 100) (do @ [x rand-gen] (test "" @@ -85,7 +85,7 @@ (|> x (- <0>) (= x))))))) (context: (format "[" category "] " "Addition & Substraction") - (<| (times |100) + (<| (times 100) (do @ [x (:: @ map rand-gen) y (:: @ map rand-gen) @@ -96,7 +96,7 @@ (|> x (+ y) (- y) (= x))))))) (context: (format "[" category "] " "Multiplicative identity") - (<| (times |100) + (<| (times 100) (do @ [x rand-gen] (test "" @@ -108,7 +108,7 @@ (|> x (/ <1>) (= x)))))))) (context: (format "[" category "] " "Multiplication & Division") - (<| (times |100) + (<| (times 100) (do @ [x (:: @ map rand-gen) y (|> rand-gen @@ -125,7 +125,7 @@ (|> x' (/ y) (* y) (= x')))) ))))] - ["Nat" r.nat n/= n/+ n/- n/* n// n/% n/> |0 |1 |1_000_000 (n/% |1_000) id] + ["Nat" r.nat n/= n/+ n/- n/* n// n/% n/> 0 1 1_000_000 (n/% 1_000) id] ["Int" r.int i/= i/+ i/- i/* i// i/% i/> +0 +1 +1_000_000 (i/% +1_000) id] ["Frac" r.frac f/= f/+ f/- f/* f// f/% f/> +0.0 +1.0 +1_000_000.0 id math.floor] ["Rev" r.rev r/= r/+ r/- r/* r// r/% r/> .0 (.rev -1) (.rev -1) id id] @@ -134,11 +134,11 @@ (def: frac-rev (r.Random Rev) (|> r.rev - (:: r.Functor map (|>> (i64.left-shift |11) (i64.logical-right-shift |11))))) + (:: r.Functor map (|>> (i64.left-shift 11) (i64.logical-right-shift 11))))) (do-template [category rand-gen -> <- = ] [(context: (format "[" category "] " "Numeric conversions") - (<| (times |100) + (<| (times 100) (do @ [value rand-gen #let [value ( value)]] @@ -146,7 +146,7 @@ (|> value -> <- (= value))))))] ["Int->Nat" r.int .nat .int i/= (i/% +1_000_000)] - ["Nat->Int" r.nat .int .nat n/= (n/% |1_000_000)] + ["Nat->Int" r.nat .int .nat n/= (n/% 1_000_000)] ["Int->Frac" r.int int-to-frac frac-to-int i/= (i/% +1_000_000)] ["Frac->Int" r.frac frac-to-int int-to-frac f/= math.floor] ["Rev->Frac" frac-rev rev-to-frac frac-to-rev r/= id] @@ -189,7 +189,7 @@ (i/+ (i/* x x) (i/* y y))) (context: "Templates." - (<| (times |100) + (<| (times 100) (do @ [x r.int y r.int] diff --git a/stdlib/test/test/lux/cli.lux b/stdlib/test/test/lux/cli.lux index c5b3a485c..501c62df4 100644 --- a/stdlib/test/test/lux/cli.lux +++ b/stdlib/test/test/lux/cli.lux @@ -17,16 +17,16 @@ lux/test) (context: "CLI" - (<| (times |100) + (<| (times 100) (do @ - [num-args (|> r.nat (:: @ map (n/% |10))) + [num-args (|> r.nat (:: @ map (n/% 10))) #let [(^open "Nat/.") number.Codec gen-arg (:: @ map Nat/encode r.nat)] yes gen-arg - #let [gen-ignore (|> (r.unicode |5) (r.filter (|>> (text/= yes) not)))] + #let [gen-ignore (|> (r.unicode 5) (r.filter (|>> (text/= yes) not)))] no gen-ignore - pre-ignore (r.list |5 gen-ignore) - post-ignore (r.list |5 gen-ignore)] + pre-ignore (r.list 5 gen-ignore) + post-ignore (r.list 5 gen-ignore)] ($_ seq (test "Can read any argument." (|> (/.run (list yes) /.any) diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/case.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/case.lux index 4a1b1e28e..abe199241 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/case.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/case.lux @@ -67,7 +67,7 @@ [#.Int r.int code.int] [#.Rev r.rev code.rev] [#.Frac r.frac code.frac] - [#.Text (r.unicode |5) code.text]) + [#.Text (r.unicode 5) code.text]) (^ [_ (#.Tuple (list))]) (random/wrap (list (' []))) @@ -118,7 +118,7 @@ choiceC (maybe.assume (list.nth choice primitivesC))]] (wrap (` ((~ choiceT) (~ choiceC))))) (do r.Monad - [size (|> r.nat (:: @ map (n/% |3))) + [size (|> r.nat (:: @ map (n/% 3))) elems (r.list size input)] (wrap (code.tuple elems))) (random/wrap (code.record (list.zip2 record-tags primitivesC))) @@ -129,17 +129,17 @@ [pattern body]) (context: "Pattern-matching." - ## #seed |9253409297339902486 - ## #seed |3793366152923578600 - (<| (seed |5004137551292836565) - ## (times |100) + ## #seed 9253409297339902486 + ## #seed 3793366152923578600 + (<| (seed 5004137551292836565) + ## (times 100) (do @ - [module-name (r.unicode |5) - variant-name (r.unicode |5) - record-name (|> (r.unicode |5) (r.filter (|>> (text/= variant-name) not))) - size (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) - variant-tags (|> (r.set text.Hash size (r.unicode |5)) (:: @ map set.to-list)) - record-tags (|> (r.set text.Hash size (r.unicode |5)) (:: @ map set.to-list)) + [module-name (r.unicode 5) + variant-name (r.unicode 5) + record-name (|> (r.unicode 5) (r.filter (|>> (text/= variant-name) not))) + size (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2)))) + variant-tags (|> (r.set text.Hash size (r.unicode 5)) (:: @ map set.to-list)) + record-tags (|> (r.set text.Hash size (r.unicode 5)) (:: @ map set.to-list)) primitivesTC (r.list size _primitive.primitive) #let [primitivesT (list/map product.left primitivesTC) primitivesC (list/map product.right primitivesTC) @@ -178,7 +178,7 @@ _ (module.declare-tags record-tags #0 (#.Named [module-name record-name] (type.tuple primitivesT)))]) - (module.with-module |0 module-name))]] + (module.with-module 0 module-name))]] ($_ seq (test "Will reject empty pattern-matching (no branches)." (|> (analyse-pm (list)) diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/function.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/function.lux index 11220052f..ba84d926f 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/function.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/function.lux @@ -47,10 +47,10 @@ #0))) (context: "Function definition." - (<| (times |100) + (<| (times 100) (do @ - [func-name (r.unicode |5) - arg-name (|> (r.unicode |5) (r.filter (|>> (text/= func-name) not))) + [func-name (r.unicode 5) + arg-name (|> (r.unicode 5) (r.filter (|>> (text/= func-name) not))) [outputT outputC] _primitive.primitive [inputT _] _primitive.primitive #let [g!arg (code.local-identifier arg-name)]] @@ -76,19 +76,19 @@ )))) (context: "Function application." - (<| (times |100) + (<| (times 100) (do @ - [full-args (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) + [full-args (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2)))) partial-args (|> r.nat (:: @ map (n/% full-args))) - var-idx (|> r.nat (:: @ map (|>> (n/% full-args) (n/max |1)))) + var-idx (|> r.nat (:: @ map (|>> (n/% full-args) (n/max 1)))) inputsTC (r.list full-args _primitive.primitive) #let [inputsT (list/map product.left inputsTC) inputsC (list/map product.right inputsTC)] [outputT outputC] _primitive.primitive #let [funcT (type.function inputsT outputT) partialT (type.function (list.drop partial-args inputsT) outputT) - varT (#.Parameter |1) - polyT (<| (type.univ-q |1) + varT (#.Parameter 1) + polyT (<| (type.univ-q 1) (type.function (list.concat (list (list.take var-idx inputsT) (list varT) (list.drop (inc var-idx) inputsT)))) @@ -97,10 +97,10 @@ partial-poly-inputsT (list.drop (inc var-idx) inputsT) partial-polyT1 (<| (type.function partial-poly-inputsT) poly-inputT) - partial-polyT2 (<| (type.univ-q |1) + partial-polyT2 (<| (type.univ-q 1) (type.function (#.Cons varT partial-poly-inputsT)) varT) - dummy-function (#analysis.Function (list) (#analysis.Reference (reference.local |1)))]] + dummy-function (#analysis.Function (list) (#analysis.Reference (reference.local 1)))]] ($_ seq (test "Can analyse monomorphic type application." (|> (/.apply ..analyse funcT dummy-function inputsC) diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/primitive.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/primitive.lux index b6bec104f..1d807e519 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/primitive.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/primitive.lux @@ -36,13 +36,13 @@ (~~ (do-template [ ] [(r.and (random/wrap ) (random/map ))] - [Any code.tuple (r.list |0 ..unit)] + [Any code.tuple (r.list 0 ..unit)] [Bit code.bit r.bit] [Nat code.nat r.nat] [Int code.int r.int] [Rev code.rev r.rev] [Frac code.frac r.frac] - [Text code.text (r.unicode |5)] + [Text code.text (r.unicode 5)] ))))) (exception: (wrong-inference {expected Type} {inferred Type}) @@ -71,7 +71,7 @@ _ #0))) - (<| (times |100) + (<| (times 100) (`` ($_ seq (~~ (do-template [ ] [(do @ @@ -89,5 +89,5 @@ ["int" Int #analysis.Int r.int code.int] ["rev" Rev #analysis.Rev r.rev code.rev] ["frac" Frac #analysis.Frac r.frac code.frac] - ["text" Text #analysis.Text (r.unicode |5) code.text] + ["text" Text #analysis.Text (r.unicode 5) code.text] ))))))) diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux index f13db8218..5fc04278b 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/procedure/common.lux @@ -47,7 +47,7 @@ ) (context: "Lux procedures" - (<| (times |100) + (<| (times 100) (do @ [[primT primC] _primitive.primitive [antiT antiC] (|> _primitive.primitive @@ -64,7 +64,7 @@ )))) (context: "Bit procedures" - (<| (times |100) + (<| (times 100) (do @ [subjectC (|> r.nat (:: @ map code.nat)) signedC (|> r.int (:: @ map code.int)) @@ -85,7 +85,7 @@ )))) (context: "Int procedures" - (<| (times |100) + (<| (times 100) (do @ [subjectC (|> r.int (:: @ map code.int)) paramC (|> r.int (:: @ map code.int))] @@ -111,11 +111,11 @@ )))) (context: "Frac procedures" - (<| (times |100) + (<| (times 100) (do @ [subjectC (|> r.frac (:: @ map code.frac)) paramC (|> r.frac (:: @ map code.frac)) - encodedC (|> (r.unicode |5) (:: @ map code.text))] + encodedC (|> (r.unicode 5) (:: @ map code.text))] ($_ seq (test "Can add frac numbers." (check-success+ "lux frac +" (list subjectC paramC) Frac)) @@ -146,11 +146,11 @@ )))) (context: "Text procedures" - (<| (times |100) + (<| (times 100) (do @ - [subjectC (|> (r.unicode |5) (:: @ map code.text)) - paramC (|> (r.unicode |5) (:: @ map code.text)) - replacementC (|> (r.unicode |5) (:: @ map code.text)) + [subjectC (|> (r.unicode 5) (:: @ map code.text)) + paramC (|> (r.unicode 5) (:: @ map code.text)) + replacementC (|> (r.unicode 5) (:: @ map code.text)) fromC (|> r.nat (:: @ map code.nat)) toC (|> r.nat (:: @ map code.nat))] ($_ seq @@ -171,12 +171,12 @@ )))) (context: "Array procedures" - (<| (times |100) + (<| (times 100) (do @ [[elemT elemC] _primitive.primitive sizeC (|> r.nat (:: @ map code.nat)) idxC (|> r.nat (:: @ map code.nat)) - var-name (r.unicode |5) + var-name (r.unicode 5) #let [arrayT (type (Array elemT)) g!array (code.local-identifier var-name) array-operation (function (_ output-type code) @@ -208,7 +208,7 @@ )))) (context: "Math procedures" - (<| (times |100) + (<| (times 100) (do @ [subjectC (|> r.frac (:: @ map code.frac)) paramC (|> r.frac (:: @ map code.frac))] @@ -239,12 +239,12 @@ ["lux math pow" "power"]))))))) (context: "Atom procedures" - (<| (times |100) + (<| (times 100) (do @ [[elemT elemC] _primitive.primitive sizeC (|> r.nat (:: @ map code.nat)) idxC (|> r.nat (:: @ map code.nat)) - var-name (r.unicode |5) + var-name (r.unicode 5) #let [atomT (type (atom.Atom elemT))]] ($_ seq (test "Can create atomic reference." @@ -277,7 +277,7 @@ )))) (context: "Process procedures" - (<| (times |100) + (<| (times 100) (do @ [[primT primC] _primitive.primitive timeC (|> r.nat (:: @ map code.nat))] @@ -292,9 +292,9 @@ )))) (context: "IO procedures" - (<| (times |100) + (<| (times 100) (do @ - [logC (|> (r.unicode |5) (:: @ map code.text)) + [logC (|> (r.unicode 5) (:: @ map code.text)) exitC (|> r.int (:: @ map code.int))] ($_ seq (test "Can log messages to standard output." diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/reference.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/reference.lux index 55a673935..dae6d916b 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/reference.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/reference.lux @@ -48,13 +48,13 @@ (def: (reach-test var-name [export? def-module] [import? dependent-module] check!) (-> Text [Bit Text] [Bit Text] Check Bit) (|> (do phase.Monad - [_ (module.with-module |0 def-module + [_ (module.with-module 0 def-module (module.define var-name [Any (if export? (' {#.export? #1}) (' {})) []]))] - (module.with-module |0 dependent-module + (module.with-module 0 dependent-module (do @ [_ (if import? (module.import def-module) @@ -65,13 +65,13 @@ check!)) (context: "References" - (<| (times |100) + (<| (times 100) (do @ [[expectedT _] _primitive.primitive - def-module (r.unicode |5) - scope-name (r.unicode |5) - var-name (r.unicode |5) - dependent-module (|> (r.unicode |5) + def-module (r.unicode 5) + scope-name (r.unicode 5) + var-name (r.unicode 5) + dependent-module (|> (r.unicode 5) (r.filter (|>> (text/= def-module) not)))] ($_ seq (test "Can analyse variable." @@ -82,7 +82,7 @@ (phase.run [analysisE.bundle (init.compiler [])]) (case> (^ (#e.Success [inferredT (#analysis.Reference (reference.local var))])) (and (type/= expectedT inferredT) - (n/= |0 var)) + (n/= 0 var)) _ #0))) @@ -92,7 +92,7 @@ [_ (module.define var-name [expectedT (' {}) []])] (typeA.with-inference (..analyse (code.identifier def-name)))) - (module.with-module |0 def-module) + (module.with-module 0 def-module) (phase.run [analysisE.bundle (init.compiler [])]) (case> (^ (#e.Success [_ inferredT (#analysis.Reference (reference.constant constant-name))])) (and (type/= expectedT inferredT) diff --git a/stdlib/test/test/lux/compiler/default/phase/analysis/structure.lux b/stdlib/test/test/lux/compiler/default/phase/analysis/structure.lux index 1b23587f7..d36bffe20 100644 --- a/stdlib/test/test/lux/compiler/default/phase/analysis/structure.lux +++ b/stdlib/test/test/lux/compiler/default/phase/analysis/structure.lux @@ -75,7 +75,7 @@ (All [a] (-> Text (List module.Tag) Type (Operation a) (Operation [Module a]))) (|>> (do phase.Monad [_ (module.declare-tags tags #0 type)]) - (module.with-module |0 module))) + (module.with-module 0 module))) (def: (check-variant module tags type size tag analysis) (-> Text (List module.Tag) Type Nat Tag (Operation Analysis) Bit) @@ -108,9 +108,9 @@ #0))) (context: "Sums" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) + [size (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2)))) choice (|> r.nat (:: @ map (n/% size))) primitives (r.list size _primitive.primitive) +choice (|> r.nat (:: @ map (n/% (inc size)))) @@ -119,7 +119,7 @@ [valueT valueC] (maybe.assume (list.nth choice primitives)) +size (inc size) +primitives (list.concat (list (list.take choice primitives) - (list [(#.Parameter |1) +valueC]) + (list [(#.Parameter 1) +valueC]) (list.drop choice primitives))) [+valueT +valueC] (maybe.assume (list.nth +choice +primitives)) +variantT (type.variant (list/map product.left +primitives))]] @@ -149,29 +149,29 @@ (/.sum ..analyse choice valueC))) check-fails)) (test "Can analyse sum through existential quantification." - (|> (typeA.with-type (type.ex-q |1 +variantT) + (|> (typeA.with-type (type.ex-q 1 +variantT) (/.sum ..analyse +choice +valueC)) check-succeeds)) (test "Can analyse sum through universal quantification." (let [check-outcome (if (not (n/= choice +choice)) check-succeeds check-fails)] - (|> (typeA.with-type (type.univ-q |1 +variantT) + (|> (typeA.with-type (type.univ-q 1 +variantT) (/.sum ..analyse +choice +valueC)) check-outcome))) )))) (context: "Products" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) + [size (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2)))) primitives (r.list size _primitive.primitive) choice (|> r.nat (:: @ map (n/% size))) [_ +valueC] _primitive.primitive #let [tupleT (type.tuple (list/map product.left primitives)) [singletonT singletonC] (|> primitives (list.nth choice) maybe.assume) +primitives (list.concat (list (list.take choice primitives) - (list [(#.Parameter |1) +valueC]) + (list [(#.Parameter 1) +valueC]) (list.drop choice primitives))) +tupleT (type.tuple (list/map product.left +primitives))]] ($_ seq @@ -212,26 +212,26 @@ _ #0))) (test "Can analyse product through existential quantification." - (|> (typeA.with-type (type.ex-q |1 +tupleT) + (|> (typeA.with-type (type.ex-q 1 +tupleT) (/.product ..analyse (list/map product.right +primitives))) check-succeeds)) (test "Cannot analyse product through universal quantification." - (|> (typeA.with-type (type.univ-q |1 +tupleT) + (|> (typeA.with-type (type.univ-q 1 +tupleT) (/.product ..analyse (list/map product.right +primitives))) check-fails)) )))) (context: "Tagged Sums" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) - tags (|> (r.set text.Hash size (r.unicode |5)) (:: @ map set.to-list)) + [size (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2)))) + tags (|> (r.set text.Hash size (r.unicode 5)) (:: @ map set.to-list)) choice (|> r.nat (:: @ map (n/% size))) other-choice (|> r.nat (:: @ map (n/% size)) (r.filter (|>> (n/= choice) not))) primitives (r.list size _primitive.primitive) - module-name (r.unicode |5) - type-name (r.unicode |5) - #let [varT (#.Parameter |1) + module-name (r.unicode 5) + type-name (r.unicode 5) + #let [varT (#.Parameter 1) primitivesT (list/map product.left primitives) [choiceT choiceC] (maybe.assume (list.nth choice primitives)) [other-choiceT other-choiceC] (maybe.assume (list.nth other-choice primitives)) @@ -240,7 +240,7 @@ named-polyT (|> (type.variant (list.concat (list (list.take choice primitivesT) (list varT) (list.drop (inc choice) primitivesT)))) - (type.univ-q |1) + (type.univ-q 1) (#.Named [module-name type-name])) choice-tag (maybe.assume (list.nth choice tags)) other-choice-tag (maybe.assume (list.nth other-choice tags))]] @@ -261,15 +261,15 @@ )))) (context: "Records" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) - tags (|> (r.set text.Hash size (r.unicode |5)) (:: @ map set.to-list)) + [size (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2)))) + tags (|> (r.set text.Hash size (r.unicode 5)) (:: @ map set.to-list)) primitives (r.list size _primitive.primitive) - module-name (r.unicode |5) - type-name (r.unicode |5) + module-name (r.unicode 5) + type-name (r.unicode 5) choice (|> r.nat (:: @ map (n/% size))) - #let [varT (#.Parameter |1) + #let [varT (#.Parameter 1) tagsC (list/map (|>> [module-name] code.tag) tags) primitivesT (list/map product.left primitives) primitivesC (list/map product.right primitives) @@ -279,7 +279,7 @@ named-polyT (|> (type.tuple (list.concat (list (list.take choice primitivesT) (list varT) (list.drop (inc choice) primitivesT)))) - (type.univ-q |1) + (type.univ-q 1) (#.Named [module-name type-name]))]] ($_ seq (test "Can infer record." diff --git a/stdlib/test/test/lux/compiler/default/phase/synthesis/case.lux b/stdlib/test/test/lux/compiler/default/phase/synthesis/case.lux index 43c58f446..f3c3b9d2e 100644 --- a/stdlib/test/test/lux/compiler/default/phase/synthesis/case.lux +++ b/stdlib/test/test/lux/compiler/default/phase/synthesis/case.lux @@ -20,10 +20,10 @@ ["." //primitive]) (context: "Dummy variables." - (<| (times |100) + (<| (times 100) (do @ [maskedA //primitive.primitive - temp (|> r.nat (:: @ map (n/% |100))) + temp (|> r.nat (:: @ map (n/% 100))) #let [maskA (analysis.control/case [maskedA [[(#analysis.Bind temp) @@ -37,7 +37,7 @@ (error.default #0)))))) (context: "Let expressions." - (<| (times |100) + (<| (times 100) (do @ [registerA r.nat inputA //primitive.primitive @@ -60,7 +60,7 @@ #0)))))) (context: "If expressions." - (<| (times |100) + (<| (times 100) (do @ [then|else r.bit inputA //primitive.primitive diff --git a/stdlib/test/test/lux/compiler/default/phase/synthesis/function.lux b/stdlib/test/test/lux/compiler/default/phase/synthesis/function.lux index 046eef852..fae0e0fdf 100644 --- a/stdlib/test/test/lux/compiler/default/phase/synthesis/function.lux +++ b/stdlib/test/test/lux/compiler/default/phase/synthesis/function.lux @@ -42,7 +42,7 @@ predictionA])) (do @ [predictionA //primitive.primitive] - (wrap [|0 predictionA predictionA]))))))) + (wrap [0 predictionA predictionA]))))))) (def: (pick scope-size) (-> Nat (r.Random Nat)) @@ -51,12 +51,12 @@ (def: function-with-environment (r.Random [Arity Analysis Variable]) (do r.Monad - [num-locals (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) - #let [indices (list.n/range |0 (dec num-locals)) + [num-locals (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10)))) + #let [indices (list.n/range 0 (dec num-locals)) local-env (list/map (|>> #reference.Local) indices) foreign-env (list/map (|>> #reference.Foreign) indices)] [arity bodyA predictionA] (: (r.Random [Arity Analysis Variable]) - (loop [arity |1 + (loop [arity 1 current-env foreign-env] (let [current-env/size (list.size current-env) resolver (list/fold (function (_ [idx var] resolver) @@ -68,7 +68,7 @@ [nest? r.bit] (if nest? (do @ - [num-picks (:: @ map (n/max |1) (pick (inc current-env/size))) + [num-picks (:: @ map (n/max 1) (pick (inc current-env/size))) picks (|> (r.set number.Hash num-picks (pick current-env/size)) (:: @ map set.to-list)) [arity bodyA predictionA] (recur (inc arity) @@ -90,7 +90,7 @@ (def: local-function (r.Random [Arity Analysis Variable]) - (loop [arity |0 + (loop [arity 0 nest? #1] (if nest? (do r.Monad @@ -100,14 +100,14 @@ (#analysis.Function (list) bodyA) predictionA])) (do r.Monad - [chosen (|> r.nat (:: @ map (|>> (n/% |100) (n/max |2))))] + [chosen (|> r.nat (:: @ map (|>> (n/% 100) (n/max 2))))] (wrap [arity (#analysis.Reference (reference.local chosen)) (|> chosen (n/+ (dec arity)) #reference.Local)]))))) (context: "Function definition." - (<| (seed |13007429814532219492) - ## (times |100) + (<| (seed 13007429814532219492) + ## (times 100) (do @ [[arity//constant function//constant prediction//constant] constant-function [arity//environment function//environment prediction//environment] function-with-environment @@ -122,7 +122,7 @@ (//primitive.corresponds? prediction//constant output)) _ - (n/= |0 arity//constant)))) + (n/= 0 arity//constant)))) (test "Folded functions provide direct access to environment variables." (|> function//environment expression.synthesize @@ -146,9 +146,9 @@ )))) (context: "Function application." - (<| (times |100) + (<| (times 100) (do @ - [arity (|> r.nat (:: @ map (|>> (n/% |10) (n/max |1)))) + [arity (|> r.nat (:: @ map (|>> (n/% 10) (n/max 1)))) funcA //primitive.primitive argsA (r.list arity //primitive.primitive)] ($_ seq diff --git a/stdlib/test/test/lux/compiler/default/phase/synthesis/primitive.lux b/stdlib/test/test/lux/compiler/default/phase/synthesis/primitive.lux index e2fa45521..9587919a2 100644 --- a/stdlib/test/test/lux/compiler/default/phase/synthesis/primitive.lux +++ b/stdlib/test/test/lux/compiler/default/phase/synthesis/primitive.lux @@ -30,7 +30,7 @@ r.int r.rev r.frac - (r.unicode |5)))] + (r.unicode 5)))] (wrap (#analysis.Primitive primitive)))) (def: #export (corresponds? analysis synthesis) @@ -68,14 +68,14 @@ #0)) (context: "Primitives." - (<| (times |100) + (<| (times 100) (do @ [|bit| r.bit |nat| r.nat |int| r.int |rev| r.rev |frac| r.frac - |text| (r.unicode |5)] + |text| (r.unicode 5)] (`` ($_ seq (~~ (do-template [ ] [(test (format "Can synthesize " ".") diff --git a/stdlib/test/test/lux/compiler/default/phase/synthesis/structure.lux b/stdlib/test/test/lux/compiler/default/phase/synthesis/structure.lux index b3363567a..90fd155b0 100644 --- a/stdlib/test/test/lux/compiler/default/phase/synthesis/structure.lux +++ b/stdlib/test/test/lux/compiler/default/phase/synthesis/structure.lux @@ -23,9 +23,9 @@ ["." //primitive]) (context: "Variants" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% |10) (n/+ |2)))) + [size (|> r.nat (:: @ map (|>> (n/% 10) (n/+ 2)))) tagA (|> r.nat (:: @ map (n/% size))) memberA //primitive.primitive] ($_ seq @@ -44,9 +44,9 @@ )))) (context: "Tuples" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% |10) (n/max |2)))) + [size (|> r.nat (:: @ map (|>> (n/% 10) (n/max 2)))) membersA (r.list size //primitive.primitive)] ($_ seq (test "Can synthesize tuple." diff --git a/stdlib/test/test/lux/compiler/default/syntax.lux b/stdlib/test/test/lux/compiler/default/syntax.lux index 5bd7c09d8..e52a6ea02 100644 --- a/stdlib/test/test/lux/compiler/default/syntax.lux +++ b/stdlib/test/test/lux/compiler/default/syntax.lux @@ -23,8 +23,8 @@ (def: default-cursor Cursor {#.module "" - #.line |0 - #.column |0}) + #.line 0 + #.column 0}) (def: name-part^ (r.Random Text) @@ -34,11 +34,11 @@ space "\t\v \n\r\f" invalid-range (format digits delimiters space) char-gen (|> r.nat - (:: @ map (|>> (n/% |256) (n/max |1))) + (:: @ map (|>> (n/% 256) (n/max 1))) (r.filter (function (_ sample) (not (text.contains? (text.from-code sample) invalid-range)))))] - size (|> r.nat (:: @ map (|>> (n/% |20) (n/max |1))))] + size (|> r.nat (:: @ map (|>> (n/% 20) (n/max 1))))] (r.text char-gen size))) (def: name^ @@ -57,7 +57,7 @@ textual^ (: (r.Random Code) ($_ r.either (do r.Monad - [size (|> r.nat (r/map (n/% |20)))] + [size (|> r.nat (r/map (n/% 20)))] (|> (r.unicode size) (r/map code.text))) (|> name^ (r/map code.identifier)) (|> name^ (r/map code.tag)))) @@ -68,28 +68,28 @@ (r.rec (function (_ code^) (let [multi^ (do r.Monad - [size (|> r.nat (r/map (n/% |3)))] + [size (|> r.nat (r/map (n/% 3)))] (r.list size code^)) composite^ (: (r.Random Code) ($_ r.either (|> multi^ (r/map code.form)) (|> multi^ (r/map code.tuple)) (do r.Monad - [size (|> r.nat (r/map (n/% |3)))] + [size (|> r.nat (r/map (n/% 3)))] (|> (r.list size (r.and code^ code^)) (r/map code.record)))))] (r.either simple^ composite^)))))) (context: "Lux code syntax." - (<| (times |100) + (<| (times 100) (do @ [sample code^ other code^] ($_ seq (test "Can parse Lux code." (case (&.read "" (dict.new text.Hash) - [default-cursor |0 (code.to-text sample)]) + [default-cursor 0 (code.to-text sample)]) (#e.Error error) #0 @@ -97,8 +97,8 @@ (:: code.Equivalence = parsed sample))) (test "Can parse Lux multiple code nodes." (case (&.read "" (dict.new text.Hash) - [default-cursor |0 (format (code.to-text sample) " " - (code.to-text other))]) + [default-cursor 0 (format (code.to-text sample) " " + (code.to-text other))]) (#e.Error error) #0 @@ -114,15 +114,15 @@ )))) (context: "Frac special syntax." - (<| (times |100) + (<| (times 100) (do @ - [numerator (|> r.nat (:: @ map (|>> (n/% |100) .int int-to-frac))) - denominator (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1) .int int-to-frac))) + [numerator (|> r.nat (:: @ map (|>> (n/% 100) .int int-to-frac))) + denominator (|> r.nat (:: @ map (|>> (n/% 100) (n/max 1) .int int-to-frac))) signed? r.bit #let [expected (|> numerator (f// denominator) (f/* (if signed? -1.0 +1.0)))]] (test "Can parse frac ratio syntax." (case (&.read "" (dict.new text.Hash) - [default-cursor |0 + [default-cursor 0 (format (if signed? "-" "") (%i (frac-to-int numerator)) "/" @@ -135,12 +135,12 @@ )))) (context: "Nat special syntax." - (<| (times |100) + (<| (times 100) (do @ - [expected (|> r.nat (:: @ map (n/% |1_000)))] + [expected (|> r.nat (:: @ map (n/% 1_000)))] (test "Can parse nat char syntax." (case (&.read "" (dict.new text.Hash) - [default-cursor |0 + [default-cursor 0 (format "#" (%t (text.from-code expected)) "")]) (#e.Success [_ [_ (#.Nat actual)]]) (n/= expected actual) @@ -157,7 +157,7 @@ (n/= (char "(") value) (n/= (char ")") value))))))] (do r.Monad - [size (|> r.nat (r/map (n/% |20)))] + [size (|> r.nat (r/map (n/% 20)))] (r.text char-gen size)))) (def: comment^ @@ -172,8 +172,8 @@ (wrap (format "#( " comment " )#"))))))) (context: "Multi-line text & comments." - (<| (seed |12137892244981970631) - ## (times |100) + (<| (seed 12137892244981970631) + ## (times 100) (do @ [#let [char-gen (|> r.nat (r.filter (function (_ value) (not (or (text.space? value) @@ -181,7 +181,7 @@ x char-gen y char-gen z char-gen - offset-size (|> r.nat (r/map (|>> (n/% |10) (n/max |1)))) + offset-size (|> r.nat (r/map (|>> (n/% 10) (n/max 1)))) #let [offset (text.join-with "" (list.repeat offset-size " "))] sample code^ comment comment^ @@ -192,7 +192,7 @@ (text.from-code y) "\n" (text.from-code z))] (case (&.read "" (dict.new text.Hash) - [default-cursor |0 + [default-cursor 0 (format "\"" bad-match "\"")]) (#e.Error error) #1 @@ -208,7 +208,7 @@ (text.from-code z))] (case (&.read "" (dict.new text.Hash) [(|> default-cursor (update@ #.column (n/+ (dec offset-size)))) - |0 + 0 (format "\"" good-input "\"")]) (#e.Error error) #0 @@ -219,7 +219,7 @@ (code.text good-output))))) (test "Can handle comments." (case (&.read "" (dict.new text.Hash) - [default-cursor |0 + [default-cursor 0 (format comment (code.to-text sample))]) (#e.Error error) #0 @@ -228,7 +228,7 @@ (:: code.Equivalence = parsed sample))) (test "Will reject unbalanced multi-line comments." (and (case (&.read "" (dict.new text.Hash) - [default-cursor |0 + [default-cursor 0 (format "#(" "#(" unbalanced-comment ")#" (code.to-text sample))]) (#e.Error error) @@ -237,7 +237,7 @@ (#e.Success [_ parsed]) #0) (case (&.read "" (dict.new text.Hash) - [default-cursor |0 + [default-cursor 0 (format "#(" unbalanced-comment ")#" ")#" (code.to-text sample))]) (#e.Error error) diff --git a/stdlib/test/test/lux/concurrency/actor.lux b/stdlib/test/test/lux/concurrency/actor.lux index 42b2f5412..a43845380 100644 --- a/stdlib/test/test/lux/concurrency/actor.lux +++ b/stdlib/test/test/lux/concurrency/actor.lux @@ -38,19 +38,19 @@ ($_ seq (test "Can check if an actor is alive." (io.run (do io.Monad - [counter (new@Counter |0)] + [counter (new@Counter 0)] (wrap (&.alive? counter))))) (test "Can poison actors." (io.run (do io.Monad - [counter (new@Counter |0) + [counter (new@Counter 0) poisoned? (&.poison counter)] (wrap (and poisoned? (not (&.alive? counter))))))) (test "Cannot poison an already dead actor." (io.run (do io.Monad - [counter (new@Counter |0) + [counter (new@Counter 0) first-time (&.poison counter) second-time (&.poison counter)] (wrap (and first-time @@ -58,13 +58,13 @@ (wrap (do P.Monad [result (do T.Monad - [#let [counter (io.run (new@Counter |0))] - output-1 (count! |1 counter) - output-2 (count! |1 counter) - output-3 (count! |1 counter)] - (wrap (and (n/= |1 output-1) - (n/= |2 output-2) - (n/= |3 output-3))))] + [#let [counter (io.run (new@Counter 0))] + output-1 (count! 1 counter) + output-2 (count! 1 counter) + output-3 (count! 1 counter)] + (wrap (and (n/= 1 output-1) + (n/= 2 output-2) + (n/= 3 output-3))))] (assert "Can send messages to actors." (case result (#e.Success outcome) diff --git a/stdlib/test/test/lux/concurrency/atom.lux b/stdlib/test/test/lux/concurrency/atom.lux index db480b27e..a10edcae7 100644 --- a/stdlib/test/test/lux/concurrency/atom.lux +++ b/stdlib/test/test/lux/concurrency/atom.lux @@ -10,7 +10,7 @@ lux/test) (context: "Atoms" - (<| (times |100) + (<| (times 100) (do @ [value r.nat swap-value r.nat diff --git a/stdlib/test/test/lux/concurrency/frp.lux b/stdlib/test/test/lux/concurrency/frp.lux index 7ba1a80e9..46db40889 100644 --- a/stdlib/test/test/lux/concurrency/frp.lux +++ b/stdlib/test/test/lux/concurrency/frp.lux @@ -42,7 +42,7 @@ output (read! input) _ (write! values input)] (wrap output))) - _ (promise.wait |100) + _ (promise.wait 100) output (promise.future (atom.read output))] (assert "Can pipe one channel into another." (list/= values @@ -56,7 +56,7 @@ output (read! elems) _ (write! (list +0 +1 +2 +3 +4 +5) input)] (wrap output))) - _ (promise.wait |100) + _ (promise.wait 100) output (promise.future (atom.read output))] (assert "Can filter a channel's elements." (list/= (list +0 +2 +4) @@ -72,7 +72,7 @@ _ (write! (list +0 +1 +2 +3 +4 +5) left) _ (write! (list +0 -1 -2 -3 -4 -5) right)] (wrap output))) - _ (promise.wait |100) + _ (promise.wait 100) output (promise.future (atom.read output))] (assert "Can merge channels." (list/= (list +0 +1 +2 +3 +4 +5 +0 -1 -2 -3 -4 -5) @@ -86,7 +86,7 @@ output (read! mapped) _ (write! (list +0 +1 +2 +3 +4 +5) inputs)] (wrap output))) - _ (promise.wait |100) + _ (promise.wait 100) output (promise.future (atom.read output))] (assert "Functor goes over every element in a channel." (list/= (list +1 +2 +3 +4 +5 +6) @@ -102,7 +102,7 @@ _ (write! (list inc) >f<) _ (write! (list +12345) >a<)] (wrap output))) - _ (promise.wait |100) + _ (promise.wait 100) output (promise.future (atom.read output))] (assert "Apply works over all channel values." (list/= (list +12346) @@ -111,10 +111,10 @@ (wrap (do promise.Monad [output (promise.future (read! (do frp.Monad - [f (frp.from-promise (promise.delay |100 inc)) - a (frp.from-promise (promise.delay |200 +12345))] - (frp.from-promise (promise.delay |300 (f a)))))) - _ (promise.wait |700) + [f (frp.from-promise (promise.delay 100 inc)) + a (frp.from-promise (promise.delay 200 +12345))] + (frp.from-promise (promise.delay 300 (f a)))))) + _ (promise.wait 700) output (promise.future (atom.read output))] (assert "Valid monad." (list/= (list +12346) diff --git a/stdlib/test/test/lux/concurrency/promise.lux b/stdlib/test/test/lux/concurrency/promise.lux index 749adf802..e857d0708 100644 --- a/stdlib/test/test/lux/concurrency/promise.lux +++ b/stdlib/test/test/lux/concurrency/promise.lux @@ -18,7 +18,7 @@ running?))) (wrap (do &.Monad - [_ (&.wait |500)] + [_ (&.wait 500)] (assert "Can wait for a specified amount of time." #1))) @@ -29,10 +29,10 @@ (and left (not right))))) (wrap (do &.Monad - [?left (&.or (&.delay |100 #1) - (&.delay |200 #0)) - ?right (&.or (&.delay |200 #1) - (&.delay |100 #0))] + [?left (&.or (&.delay 100 #1) + (&.delay 200 #0)) + ?right (&.or (&.delay 200 #1) + (&.delay 100 #0))] (assert "Can combine promises alternatively." (case [?left ?right] [(#.Left #1) (#.Right #0)] @@ -42,17 +42,17 @@ #0)))) (wrap (do &.Monad - [?left (&.either (&.delay |100 #1) - (&.delay |200 #0)) - ?right (&.either (&.delay |200 #1) - (&.delay |100 #0))] + [?left (&.either (&.delay 100 #1) + (&.delay 200 #0)) + ?right (&.either (&.delay 200 #1) + (&.delay 100 #0))] (assert "Can combine promises alternatively [Part 2]." (and ?left (not ?right))))) (test "Can poll a promise for its value." (and (|> (&.poll (&/wrap #1)) (case> (#.Some #1) #1 _ #0)) - (|> (&.poll (&.delay |200 #1)) + (|> (&.poll (&.delay 200 #1)) (case> #.None #1 _ #0)))) (test "Cannot re-resolve a resolved promise." @@ -60,8 +60,8 @@ (io.run (&.resolve #1 (: (&.Promise Bit) (&.promise #.None)))))) (wrap (do &.Monad - [?none (&.time-out |100 (&.delay |200 #1)) - ?some (&.time-out |200 (&.delay |100 #1))] + [?none (&.time-out 100 (&.delay 200 #1)) + ?some (&.time-out 200 (&.delay 100 #1))] (assert "Can establish maximum waiting times for promises to be fulfilled." (case [?none ?some] [#.None (#.Some #1)] diff --git a/stdlib/test/test/lux/concurrency/semaphore.lux b/stdlib/test/test/lux/concurrency/semaphore.lux index 73ee3f8af..f309fcd0c 100644 --- a/stdlib/test/test/lux/concurrency/semaphore.lux +++ b/stdlib/test/test/lux/concurrency/semaphore.lux @@ -20,16 +20,16 @@ (def: (wait-many-times times semaphore) (-> Nat /.Semaphore (Promise Any)) (loop [steps times] - (if (n/> |0 steps) + (if (n/> 0 steps) (do promise.Monad [_ (/.wait semaphore)] (recur (dec steps))) (:: promise.Monad wrap [])))) (context: "Semaphore." - (<| (times |100) + (<| (times 100) (do @ - [open-positions (|> r.nat (:: @ map (|>> (n/% |10) (n/max |1))))] + [open-positions (|> r.nat (:: @ map (|>> (n/% 10) (n/max 1))))] ($_ seq (let [semaphore (/.semaphore open-positions)] (wrap (do promise.Monad @@ -38,7 +38,7 @@ #1)))) (let [semaphore (/.semaphore open-positions)] (wrap (do promise.Monad - [result (<| (promise.time-out |100) + [result (<| (promise.time-out 100) (wait-many-times (inc open-positions) semaphore))] (assert "Waiting on a semaphore more than the number of open positions blocks the process." (case result @@ -50,8 +50,8 @@ (let [semaphore (/.semaphore open-positions)] (wrap (do promise.Monad [_ (: (Promise Any) - (loop [steps (n/* |2 open-positions)] - (if (n/> |0 steps) + (loop [steps (n/* 2 open-positions)] + (if (n/> 0 steps) (do @ [_ (/.wait semaphore) _ (/.signal semaphore)] @@ -68,7 +68,7 @@ #let [_ (io.run (atom.update (|>> (format "B")) resource))]] (wrap []))] - _ (promise.wait |100) + _ (promise.wait 100) _ (exec (io.run (atom.update (|>> (format "A")) resource)) (/.signal semaphore)) @@ -79,9 +79,9 @@ )))) (context: "Mutex." - (<| (times |100) + (<| (times 100) (do @ - [repetitions (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10))))] + [repetitions (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10))))] ($_ seq (let [mutex (/.mutex [])] (wrap (do promise.Monad @@ -122,12 +122,12 @@ (wrap []))) (context: "Barrier." - (let [limit |10 + (let [limit 10 barrier (/.barrier (maybe.assume (/.limit limit))) resource (atom.atom "")] ($_ seq (wrap (do promise.Monad - [#let [ids (list.n/range |0 (dec limit)) + [#let [ids (list.n/range 0 (dec limit)) waiters (list/map (function (_ id) (let [process (waiter resource barrier id)] (exec (io.run (atom.update (|>> (format "_")) resource)) diff --git a/stdlib/test/test/lux/concurrency/stm.lux b/stdlib/test/test/lux/concurrency/stm.lux index 4105551bb..3506146f4 100644 --- a/stdlib/test/test/lux/concurrency/stm.lux +++ b/stdlib/test/test/lux/concurrency/stm.lux @@ -28,45 +28,45 @@ channel)] (wrap output))) -(def: iterations-per-process Nat |100) +(def: iterations-per-process Nat 100) (context: "STM" ($_ seq (wrap (do promise.Monad - [output (&.commit (&.read (&.var |0)))] + [output (&.commit (&.read (&.var 0)))] (assert "Can read STM vars." - (n/= |0 output)))) + (n/= 0 output)))) (wrap (do promise.Monad - [#let [_var (&.var |0)] + [#let [_var (&.var 0)] output (&.commit (do &.Monad - [_ (&.write |5 _var)] + [_ (&.write 5 _var)] (&.read _var)))] (assert "Can write STM vars." - (n/= |5 output)))) + (n/= 5 output)))) (wrap (do promise.Monad - [#let [_var (&.var |5)] + [#let [_var (&.var 5)] output (&.commit (do &.Monad - [_ (&.update (n/* |3) _var)] + [_ (&.update (n/* 3) _var)] (&.read _var)))] (assert "Can update STM vars." - (n/= |15 output)))) + (n/= 15 output)))) (wrap (do promise.Monad - [#let [_var (&.var |0) + [#let [_var (&.var 0) changes (io.run (read! (io.run (&.follow _var))))] - _ (&.commit (&.write |5 _var)) - _ (&.commit (&.update (n/* |3) _var)) + _ (&.commit (&.write 5 _var)) + _ (&.commit (&.update (n/* 3) _var)) changes (promise.future (atom.read changes))] (assert "Can follow all the changes to STM vars." (:: (list.Equivalence number.Equivalence) = - (list |5 |15) + (list 5 15) (list.reverse changes))))) - (wrap (let [_concurrency-var (&.var |0)] + (wrap (let [_concurrency-var (&.var 0)] (do promise.Monad [_ (|> promise.parallelism - (list.n/range |1) + (list.n/range 1) (list/map (function (_ _) (|> iterations-per-process - (list.n/range |1) + (list.n/range 1) (M.map @ (function (_ _) (&.commit (&.update inc _concurrency-var))))))) (M.seq @)) last-val (&.commit (&.read _concurrency-var))] diff --git a/stdlib/test/test/lux/control/continuation.lux b/stdlib/test/test/lux/control/continuation.lux index 489742c04..dfe93023a 100644 --- a/stdlib/test/test/lux/control/continuation.lux +++ b/stdlib/test/test/lux/control/continuation.lux @@ -11,12 +11,12 @@ lux/test) (context: "Continuations" - (<| (times |100) + (<| (times 100) (do @ [sample r.nat #let [(^open "&/.") &.Apply (^open "&/.") &.Monad] - elems (r.list |3 r.nat)] + elems (r.list 3 r.nat)] ($_ seq (test "Can run continuations to compute their values." (n/= sample (&.run (&/wrap sample)))) @@ -34,7 +34,7 @@ (wrap (func arg)))))) (test "Can use the current-continuation as a escape hatch." - (n/= (n/* |2 sample) + (n/= (n/* 2 sample) (&.run (do &.Monad [value (&.call/cc (function (_ k) @@ -42,16 +42,16 @@ [temp (k sample)] ## If this code where to run, ## the output would be - ## (n/* |4 sample) + ## (n/* 4 sample) (k temp))))] - (wrap (n/* |2 value)))))) + (wrap (n/* 2 value)))))) (test "Can use the current-continuation to build a time machine." - (n/= (n/+ |100 sample) + (n/= (n/+ 100 sample) (&.run (do &.Monad - [[restart [output idx]] (&.portal [sample |0])] - (if (n/< |10 idx) - (restart [(n/+ |10 output) (inc idx)]) + [[restart [output idx]] (&.portal [sample 0])] + (if (n/< 10 idx) + (restart [(n/+ 10 output) (inc idx)]) (wrap output)))))) (test "Can use delimited continuations with shifting." diff --git a/stdlib/test/test/lux/control/exception.lux b/stdlib/test/test/lux/control/exception.lux index 3cffa26c3..36555f490 100644 --- a/stdlib/test/test/lux/control/exception.lux +++ b/stdlib/test/test/lux/control/exception.lux @@ -18,7 +18,7 @@ (exception: unknown-exception) (context: "Exceptions" - (<| (times |100) + (<| (times 100) (do @ [should-throw? r.bit which? r.bit diff --git a/stdlib/test/test/lux/control/interval.lux b/stdlib/test/test/lux/control/interval.lux index 2c7192b59..9fe01a0a1 100644 --- a/stdlib/test/test/lux/control/interval.lux +++ b/stdlib/test/test/lux/control/interval.lux @@ -14,7 +14,7 @@ ["L" list]]]]) (context: "Equivalence." - (<| (times |100) + (<| (times 100) (do @ [bottom r.int top r.int @@ -29,7 +29,7 @@ (&/= self self)))))))) (context: "Boundaries" - (<| (times |100) + (<| (times 100) (do @ [bottom r.int top r.int @@ -85,7 +85,7 @@ gen-singleton)) (context: "Unions" - (<| (times |100) + (<| (times 100) (do @ [some-interval gen-interval left-inner gen-inner @@ -107,7 +107,7 @@ )))) (context: "Intersections" - (<| (times |100) + (<| (times 100) (do @ [some-interval gen-interval left-inner gen-inner @@ -129,7 +129,7 @@ )))) (context: "Complement" - (<| (times |100) + (<| (times 100) (do @ [some-interval gen-interval #let [(^open "&/.") &.Equivalence]] @@ -141,9 +141,9 @@ )))) (context: "Positioning/location" - (<| (times |100) + (<| (times 100) (do @ - [[l m r] (|> (r.set number.Hash |3 r.int) + [[l m r] (|> (r.set number.Hash 3 r.int) (:: @ map (|>> S.to-list (L.sort i/<) (case> (^ (list b t1 t2)) @@ -163,9 +163,9 @@ )))) (context: "Touching intervals" - (<| (times |100) + (<| (times 100) (do @ - [[b t1 t2] (|> (r.set number.Hash |3 r.int) + [[b t1 t2] (|> (r.set number.Hash 3 r.int) (:: @ map (|>> S.to-list (L.sort i/<) (case> (^ (list b t1 t2)) @@ -189,10 +189,10 @@ )))) (context: "Nesting & overlap" - (<| (times |100) + (<| (times 100) (do @ [some-interval gen-interval - [x0 x1 x2 x3] (|> (r.set number.Hash |4 r.int) + [x0 x1 x2 x3] (|> (r.set number.Hash 4 r.int) (:: @ map (|>> S.to-list (L.sort i/<) (case> (^ (list x0 x1 x2 x3)) diff --git a/stdlib/test/test/lux/control/parser.lux b/stdlib/test/test/lux/control/parser.lux index 19ed2000d..378cbccd4 100644 --- a/stdlib/test/test/lux/control/parser.lux +++ b/stdlib/test/test/lux/control/parser.lux @@ -67,27 +67,27 @@ (context: "Combinators [Part 1]" ($_ seq (test "Can optionally succeed with some parser." - (and (match (#.Some |123) - (&.run (list (code.nat |123)) + (and (match (#.Some 123) + (&.run (list (code.nat 123)) (&.maybe s.nat))) (match #.None (&.run (list (code.int -123)) (&.maybe s.nat))))) (test "Can apply a parser 0 or more times." - (and (match (list |123 |456 |789) - (&.run (list (code.nat |123) (code.nat |456) (code.nat |789)) + (and (match (list 123 456 789) + (&.run (list (code.nat 123) (code.nat 456) (code.nat 789)) (&.some s.nat))) (match (list) (&.run (list (code.int -123)) (&.some s.nat))))) (test "Can apply a parser 1 or more times." - (and (match (list |123 |456 |789) - (&.run (list (code.nat |123) (code.nat |456) (code.nat |789)) + (and (match (list 123 456 789) + (&.run (list (code.nat 123) (code.nat 456) (code.nat 789)) (&.many s.nat))) - (match (list |123) - (&.run (list (code.nat |123)) + (match (list 123) + (&.run (list (code.nat 123)) (&.many s.nat))) (fails? (&.run (list (code.int -123)) (&.many s.nat))))) @@ -124,40 +124,40 @@ (test "Can apply a parser N times." (and (match (list +123 +456 +789) (&.run (list (code.int +123) (code.int +456) (code.int +789)) - (&.exactly |3 s.int))) + (&.exactly 3 s.int))) (match (list +123 +456) (&.run (list (code.int +123) (code.int +456) (code.int +789)) - (&.exactly |2 s.int))) + (&.exactly 2 s.int))) (fails? (&.run (list (code.int +123) (code.int +456) (code.int +789)) - (&.exactly |4 s.int))))) + (&.exactly 4 s.int))))) (test "Can apply a parser at-least N times." (and (match (list +123 +456 +789) (&.run (list (code.int +123) (code.int +456) (code.int +789)) - (&.at-least |3 s.int))) + (&.at-least 3 s.int))) (match (list +123 +456 +789) (&.run (list (code.int +123) (code.int +456) (code.int +789)) - (&.at-least |2 s.int))) + (&.at-least 2 s.int))) (fails? (&.run (list (code.int +123) (code.int +456) (code.int +789)) - (&.at-least |4 s.int))))) + (&.at-least 4 s.int))))) (test "Can apply a parser at-most N times." (and (match (list +123 +456 +789) (&.run (list (code.int +123) (code.int +456) (code.int +789)) - (&.at-most |3 s.int))) + (&.at-most 3 s.int))) (match (list +123 +456) (&.run (list (code.int +123) (code.int +456) (code.int +789)) - (&.at-most |2 s.int))) + (&.at-most 2 s.int))) (match (list +123 +456 +789) (&.run (list (code.int +123) (code.int +456) (code.int +789)) - (&.at-most |4 s.int))))) + (&.at-most 4 s.int))))) (test "Can apply a parser between N and M times." (and (match (list +123 +456 +789) (&.run (list (code.int +123) (code.int +456) (code.int +789)) - (&.between |3 |10 s.int))) + (&.between 3 10 s.int))) (fails? (&.run (list (code.int +123) (code.int +456) (code.int +789)) - (&.between |4 |10 s.int))))) + (&.between 4 10 s.int))))) (test "Can parse while taking separators into account." (and (match (list +123 +456 +789) diff --git a/stdlib/test/test/lux/control/region.lux b/stdlib/test/test/lux/control/region.lux index 59f523666..8a419bb0a 100644 --- a/stdlib/test/test/lux/control/region.lux +++ b/stdlib/test/test/lux/control/region.lux @@ -27,14 +27,14 @@ ) (context: "Regions." - (<| (times |100) + (<| (times 100) (do @ - [expected-clean-ups (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1))))] + [expected-clean-ups (|> r.nat (:: @ map (|>> (n/% 100) (n/max 1))))] ($_ seq (test "Clean-up functions are always run when region execution is done." (thread.run (do thread.Monad - [clean-up-counter (thread.box |0) + [clean-up-counter (thread.box 0) #let [@@ @ count-clean-up (function (_ value) (do @ @@ -43,7 +43,7 @@ outcome (/.run @ (do (/.Monad @) [_ (monad.map @ (/.acquire @@ count-clean-up) - (list.n/range |1 expected-clean-ups))] + (list.n/range 1 expected-clean-ups))] (wrap []))) actual-clean-ups (thread.read clean-up-counter)] (wrap (and (success? outcome) @@ -52,7 +52,7 @@ (test "Can clean-up despite errors." (thread.run (do thread.Monad - [clean-up-counter (thread.box |0) + [clean-up-counter (thread.box 0) #let [@@ @ count-clean-up (function (_ value) (do @ @@ -61,7 +61,7 @@ outcome (/.run @ (do (/.Monad @) [_ (monad.map @ (/.acquire @@ count-clean-up) - (list.n/range |1 expected-clean-ups)) + (list.n/range 1 expected-clean-ups)) _ (/.throw @@ oops [])] (wrap []))) actual-clean-ups (thread.read clean-up-counter)] @@ -71,7 +71,7 @@ (test "Errors can propagate from the cleaners." (thread.run (do thread.Monad - [clean-up-counter (thread.box |0) + [clean-up-counter (thread.box 0) #let [@@ @ count-clean-up (function (_ value) (do @ @@ -80,17 +80,17 @@ outcome (/.run @ (do (/.Monad @) [_ (monad.map @ (/.acquire @@ count-clean-up) - (list.n/range |1 expected-clean-ups))] + (list.n/range 1 expected-clean-ups))] (wrap []))) actual-clean-ups (thread.read clean-up-counter)] - (wrap (and (or (n/= |0 expected-clean-ups) + (wrap (and (or (n/= 0 expected-clean-ups) (error? outcome)) (n/= expected-clean-ups actual-clean-ups)))))) (test "Can lift operations." (thread.run (do thread.Monad - [clean-up-counter (thread.box |0) + [clean-up-counter (thread.box 0) #let [@@ @] outcome (/.run @ (do (/.Monad @) diff --git a/stdlib/test/test/lux/control/state.lux b/stdlib/test/test/lux/control/state.lux index ba5fefb6d..45f8675d8 100644 --- a/stdlib/test/test/lux/control/state.lux +++ b/stdlib/test/test/lux/control/state.lux @@ -19,7 +19,7 @@ (n/= output))) (context: "Basics" - (<| (times |100) + (<| (times 100) (do @ [state r.nat value r.nat] @@ -47,7 +47,7 @@ )))) (context: "Structures" - (<| (times |100) + (<| (times 100) (do @ [state r.nat value r.nat @@ -75,7 +75,7 @@ )))) (context: "Monad transformer" - (<| (times |100) + (<| (times 100) (do @ [state r.nat left r.nat @@ -95,23 +95,23 @@ )))) (context: "Loops" - (<| (times |100) + (<| (times 100) (do @ - [limit (|> r.nat (:: @ map (n/% |10))) + [limit (|> r.nat (:: @ map (n/% 10))) #let [condition (do &.Monad [state &.get] (wrap (n/< limit state)))]] ($_ seq (test "'while' will only execute if the condition is #1." (|> (&.while condition (&.update inc)) - (&.run |0) + (&.run 0) (case> [state' output'] (n/= limit state')))) (test "'do-while' will execute at least once." (|> (&.do-while condition (&.update inc)) - (&.run |0) + (&.run 0) (case> [state' output'] (or (n/= limit state') - (and (n/= |0 limit) - (n/= |1 state')))))) + (and (n/= 0 limit) + (n/= 1 state')))))) )))) diff --git a/stdlib/test/test/lux/control/thread.lux b/stdlib/test/test/lux/control/thread.lux index 5ac666c64..d9867f4bc 100644 --- a/stdlib/test/test/lux/control/thread.lux +++ b/stdlib/test/test/lux/control/thread.lux @@ -7,15 +7,15 @@ (def: _test0_ Nat (/.run (do /.Monad - [box (/.box |123) - old (/.update (n/* |2) box) + [box (/.box 123) + old (/.update (n/* 2) box) new (/.read box)] (wrap (n/+ old new))))) (def: _test1_ (All [!] (/.Thread ! Nat)) (do /.Monad - [box (/.box |123) - old (/.update (n/* |2) box) + [box (/.box 123) + old (/.update (n/* 2) box) new (/.read box)] (wrap (n/+ old new)))) diff --git a/stdlib/test/test/lux/data/bit.lux b/stdlib/test/test/lux/data/bit.lux index deabfe265..ecb0c90ad 100644 --- a/stdlib/test/test/lux/data/bit.lux +++ b/stdlib/test/test/lux/data/bit.lux @@ -9,7 +9,7 @@ lux/test) (context: "Bit operations." - (<| (times |100) + (<| (times 100) (do @ [value r.bit] (test "" (and (not (and value (not value))) diff --git a/stdlib/test/test/lux/data/collection/array.lux b/stdlib/test/test/lux/data/collection/array.lux index df43a3ef1..ac3061464 100644 --- a/stdlib/test/test/lux/data/collection/array.lux +++ b/stdlib/test/test/lux/data/collection/array.lux @@ -16,10 +16,10 @@ (def: bounded-size (r.Random Nat) (|> r.nat - (:: r.Monad map (|>> (n/% |100) (n/+ |1))))) + (:: r.Monad map (|>> (n/% 100) (n/+ 1))))) (context: "Arrays and their copies" - (<| (times |100) + (<| (times 100) (do @ [size bounded-size original (r.array size r.nat) @@ -35,7 +35,7 @@ (and (:: (@.Equivalence number.Equivalence) = original clone) (not (is? original clone)))) (test "Full-range manual copies should give the same result as cloning." - (exec (@.copy size |0 original |0 copy) + (exec (@.copy size 0 original 0 copy) (and (:: (@.Equivalence number.Equivalence) = original copy) (not (is? original copy))))) (test "Array folding should go over all values." @@ -43,7 +43,7 @@ (function (_ x idx) (exec (@.write idx x manual-copy) (inc idx))) - |0 + 0 original) (:: (@.Equivalence number.Equivalence) = original manual-copy))) (test "Transformations between (full) arrays and lists shouldn't cause lose or change any values." @@ -53,7 +53,7 @@ )))) (context: "Array mutation" - (<| (times |100) + (<| (times 100) (do @ [size bounded-size idx (:: @ map (n/% size) r.nat) @@ -71,17 +71,17 @@ #.None #0)) (test "All cells should be occupied on a full array." (and (n/= size (@.occupied array)) - (n/= |0 (@.vacant array)))) + (n/= 0 (@.vacant array)))) (test "Filtering mutates the array to remove invalid values." (exec (@.filter n/even? array) (and (n/< size (@.occupied array)) - (n/> |0 (@.vacant array)) + (n/> 0 (@.vacant array)) (n/= size (n/+ (@.occupied array) (@.vacant array)))))) )))) (context: "Finding values." - (<| (times |100) + (<| (times 100) (do @ [size bounded-size array (|> (r.array size r.nat) @@ -100,7 +100,7 @@ #.None #0))))))) (context: "Functor" - (<| (times |100) + (<| (times 100) (do @ [size bounded-size array (r.array size r.nat)] @@ -118,7 +118,7 @@ (= array back-again))))))))) (context: "Monoid" - (<| (times |100) + (<| (times 100) (do @ [sizeL bounded-size sizeR bounded-size @@ -133,11 +133,11 @@ (test "First elements of fused array should equal the first array." (|> (: (Array Nat) (@.new sizeL)) - (@.copy sizeL |0 fusion |0) + (@.copy sizeL 0 fusion 0) (= left))) (test "Last elements of fused array should equal the second array." (|> (: (Array Nat) (@.new sizeR)) - (@.copy sizeR sizeL fusion |0) + (@.copy sizeR sizeL fusion 0) (= right))) )))) diff --git a/stdlib/test/test/lux/data/collection/bits.lux b/stdlib/test/test/lux/data/collection/bits.lux index bf6823386..91ab7b828 100644 --- a/stdlib/test/test/lux/data/collection/bits.lux +++ b/stdlib/test/test/lux/data/collection/bits.lux @@ -22,14 +22,14 @@ (def: bits (r.Random /.Bits) (do r.Monad - [size (size |1 |1_000) + [size (size 1 1_000) idx (|> r.nat (:: @ map (n/% size)))] (wrap (|> /.empty (/.set idx))))) (context: "Bits." - (<| (times |100) + (<| (times 100) (do @ - [size (size |1 |1_000) + [size (size 1 1_000) idx (|> r.nat (:: @ map (n/% size))) sample bits] ($_ seq @@ -43,14 +43,14 @@ (|> /.empty (/.flip idx) (/.flip idx) (/.get idx) not))) (test "Bits (only) grow when (and as much as) necessary." - (and (n/= |0 (/.capacity /.empty)) + (and (n/= 0 (/.capacity /.empty)) (|> /.empty (/.set idx) /.capacity (n/- idx) - (predicate.union (n/>= |0) + (predicate.union (n/>= 0) (n/< /.chunk-size))))) (test "Bits (must) shrink when (and as much as) possible." (let [grown (/.flip idx /.empty)] - (and (n/> |0 (/.capacity grown)) + (and (n/> 0 (/.capacity grown)) (is? /.empty (/.flip idx grown))))) (test "Intersection can be detected when there are set bits in common." diff --git a/stdlib/test/test/lux/data/collection/dictionary.lux b/stdlib/test/test/lux/data/collection/dictionary.lux index a30cdaef0..466cb2872 100644 --- a/stdlib/test/test/lux/data/collection/dictionary.lux +++ b/stdlib/test/test/lux/data/collection/dictionary.lux @@ -14,9 +14,9 @@ lux/test) (context: "Dictionaries." - (<| (times |100) + (<| (times 100) (do @ - [#let [capped-nat (:: r.Monad map (n/% |100) r.nat)] + [#let [capped-nat (:: r.Monad map (n/% 100) r.nat)] size capped-nat dict (r.dictionary number.Hash size r.nat capped-nat) non-key (|> r.nat (r.filter (function (_ key) (not (&.contains? key dict))))) @@ -26,7 +26,7 @@ (n/= size (&.size dict))) (test "Dictionaries of size 0 should be considered empty." - (if (n/= |0 size) + (if (n/= 0 size) (&.empty? dict) (not (&.empty? dict)))) @@ -62,7 +62,7 @@ _ #1)) (test "Shouldn't be able to put~ an existing key." - (or (n/= |0 size) + (or (n/= 0 size) (let [first-key (|> dict &.keys list.head maybe.assume)] (case (&.get first-key (&.put~ first-key test-val dict)) (#.Some v) (not (n/= test-val v)) @@ -106,7 +106,7 @@ (= dict' (&.merge dict' dict)))) (test "Can merge values in such a way that they become combined." - (list.every? (function (_ [x x*2]) (n/= (n/* |2 x) x*2)) + (list.every? (function (_ [x x*2]) (n/= (n/* 2 x) x*2)) (list.zip2 (&.values dict) (&.values (&.merge-with n/+ dict dict))))) @@ -115,10 +115,10 @@ (&.put non-key test-val) (&.select (list non-key)) &.size - (n/= |1))) + (n/= 1))) (test "Should be able to re-bind existing values to different keys." - (or (n/= |0 size) + (or (n/= 0 size) (let [first-key (|> dict &.keys list.head maybe.assume) rebound (&.re-bind first-key non-key dict)] (and (n/= (&.size dict) (&.size rebound)) diff --git a/stdlib/test/test/lux/data/collection/dictionary/ordered.lux b/stdlib/test/test/lux/data/collection/dictionary/ordered.lux index d6ec22ec1..a8246887e 100644 --- a/stdlib/test/test/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/test/test/lux/data/collection/dictionary/ordered.lux @@ -16,9 +16,9 @@ lux/test) (context: "Dictionary" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (n/% |100))) + [size (|> r.nat (:: @ map (n/% 100))) keys (r.set number.Hash size r.nat) values (r.set number.Hash size r.nat) extra-key (|> r.nat (r.filter (|>> (s.member? keys) not))) diff --git a/stdlib/test/test/lux/data/collection/list.lux b/stdlib/test/test/lux/data/collection/list.lux index dbe92f70a..31d5d6155 100644 --- a/stdlib/test/test/lux/data/collection/list.lux +++ b/stdlib/test/test/lux/data/collection/list.lux @@ -18,10 +18,10 @@ (def: bounded-size (r.Random Nat) (|> r.nat - (:: r.Monad map (|>> (n/% |100) (n/+ |10))))) + (:: r.Monad map (|>> (n/% 100) (n/+ 10))))) (context: "Lists: Part 1" - (<| (times |100) + (<| (times 100) (do @ [size bounded-size idx (:: @ map (n/% size) r.nat) @@ -67,7 +67,7 @@ )))) (context: "Lists: Part 2" - (<| (times |100) + (<| (times 100) (do @ [size bounded-size idx (:: @ map (n/% size) r.nat) @@ -115,7 +115,7 @@ ))) (test "Segmenting the list in pairs should yield as many elements as N/2." - (n/= (n// |2 size) + (n/= (n// 2 size) (&.size (&.as-pairs sample)))) (test "Sorting a list shouldn't change it's size." @@ -128,7 +128,7 @@ )))) (context: "Lists: Part 3" - (<| (times |100) + (<| (times 100) (do @ [size bounded-size idx (:: @ map (n/% size) r.nat) @@ -136,8 +136,8 @@ other-size bounded-size other-sample (r.list other-size r.nat) separator r.nat - from (|> r.nat (:: @ map (n/% |10))) - to (|> r.nat (:: @ map (n/% |10))) + from (|> r.nat (:: @ map (n/% 10))) + to (|> r.nat (:: @ map (n/% 10))) #let [(^open ".") (&.Equivalence number.Equivalence) (^open "&/.") &.Functor]] ($_ seq @@ -167,7 +167,7 @@ (test "The 'interpose' function places a value between every member of a list." (let [(^open ".") &.Functor sample+ (&.interpose separator sample)] - (and (n/= (|> size (n/* |2) dec) + (and (n/= (|> size (n/* 2) dec) (&.size sample+)) (|> sample+ &.as-pairs (map product.right) (&.every? (n/= separator)))))) @@ -204,9 +204,9 @@ (&.every? (bit.complement n/even?) sample)))) (test "You can iteratively construct a list, generating values until you're done." - (= (&.n/range |0 (dec size)) + (= (&.n/range 0 (dec size)) (&.iterate (function (_ n) (if (n/< size n) (#.Some (inc n)) #.None)) - |0))) + 0))) (test "Can enumerate all elements in a list." (let [enum-sample (&.enumerate sample)] diff --git a/stdlib/test/test/lux/data/collection/queue.lux b/stdlib/test/test/lux/data/collection/queue.lux index 79c254341..9b21411fa 100644 --- a/stdlib/test/test/lux/data/collection/queue.lux +++ b/stdlib/test/test/lux/data/collection/queue.lux @@ -11,15 +11,15 @@ lux/test) (context: "Queues" - (<| (times |100) + (<| (times 100) (do @ - [size (:: @ map (n/% |100) r.nat) + [size (:: @ map (n/% 100) r.nat) sample (r.queue size r.nat) non-member (|> r.nat (r.filter (|>> (&.member? number.Equivalence sample) not)))] ($_ seq (test "I can query the size of a queue (and empty queues have size 0)." - (if (n/= |0 size) + (if (n/= 0 size) (&.empty? sample) (n/= size (&.size sample)))) diff --git a/stdlib/test/test/lux/data/collection/queue/priority.lux b/stdlib/test/test/lux/data/collection/queue/priority.lux index b0adafd5e..5450b8ad9 100644 --- a/stdlib/test/test/lux/data/collection/queue/priority.lux +++ b/stdlib/test/test/lux/data/collection/queue/priority.lux @@ -24,9 +24,9 @@ inputs))) (context: "Queues" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (n/% |100))) + [size (|> r.nat (:: @ map (n/% 100))) sample (gen-queue size) non-member-priority r.nat non-member (|> r.nat (r.filter (|>> (&.member? number.Equivalence sample) not)))] @@ -37,7 +37,7 @@ (test "Enqueueing and dequeing affects the size of queues." (and (n/= (inc size) (&.size (&.push non-member-priority non-member sample))) - (or (n/= |0 (&.size sample)) + (or (n/= 0 (&.size sample)) (n/= (dec size) (&.size (&.pop sample)))))) @@ -46,7 +46,7 @@ (&.member? number.Equivalence (&.push non-member-priority non-member sample) non-member)) - (or (n/= |0 (&.size sample)) + (or (n/= 0 (&.size sample)) (and (&.member? number.Equivalence sample (maybe.assume (&.peek sample))) diff --git a/stdlib/test/test/lux/data/collection/row.lux b/stdlib/test/test/lux/data/collection/row.lux index f33a369b7..09b443219 100644 --- a/stdlib/test/test/lux/data/collection/row.lux +++ b/stdlib/test/test/lux/data/collection/row.lux @@ -12,9 +12,9 @@ lux/test) (context: "Rows" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1)))) + [size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 1)))) idx (|> r.nat (:: @ map (n/% size))) sample (r.row size r.nat) other-sample (r.row size r.nat) @@ -27,8 +27,8 @@ ($_ seq (test "Can query size of row." (if (&.empty? sample) - (and (n/= |0 size) - (n/= |0 (&.size sample))) + (and (n/= 0 size) + (n/= 0 (&.size sample))) (n/= size (&.size sample)))) (test "Can add and remove elements to rows." @@ -56,8 +56,8 @@ (&.member? number.Equivalence (&.add non-member sample) non-member))) (test "Can fold over elements of row." - (n/= (list/fold n/+ |0 (&.to-list sample)) - (&/fold n/+ |0 sample))) + (n/= (list/fold n/+ 0 (&.to-list sample)) + (&/fold n/+ 0 sample))) (test "Functor goes over every element." (let [there (&/map inc sample) diff --git a/stdlib/test/test/lux/data/collection/sequence.lux b/stdlib/test/test/lux/data/collection/sequence.lux index 1f0298afd..ce8ef1b4f 100644 --- a/stdlib/test/test/lux/data/collection/sequence.lux +++ b/stdlib/test/test/lux/data/collection/sequence.lux @@ -15,38 +15,38 @@ lux/test) (context: "Sequences" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |2)))) - offset (|> r.nat (:: @ map (n/% |100))) - factor (|> r.nat (:: @ map (|>> (n/% |100) (n/max |2)))) + [size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 2)))) + offset (|> r.nat (:: @ map (n/% 100))) + factor (|> r.nat (:: @ map (|>> (n/% 100) (n/max 2)))) elem r.nat cycle-seed (r.list size r.nat) - cycle-sample-idx (|> r.nat (:: @ map (n/% |1000))) + cycle-sample-idx (|> r.nat (:: @ map (n/% 1000))) #let [(^open "List/.") (list.Equivalence number.Equivalence) - sample0 (&.iterate inc |0) + sample0 (&.iterate inc 0) sample1 (&.iterate inc offset)]] ($_ seq (test "Can move along a sequence and take slices off it." - (and (and (List/= (list.n/range |0 (dec size)) + (and (and (List/= (list.n/range 0 (dec size)) (&.take size sample0)) (List/= (list.n/range offset (dec (n/+ offset size))) (&.take size (&.drop offset sample0))) (let [[drops takes] (&.split size sample0)] - (and (List/= (list.n/range |0 (dec size)) + (and (List/= (list.n/range 0 (dec size)) drops) - (List/= (list.n/range size (dec (n/* |2 size))) + (List/= (list.n/range size (dec (n/* 2 size))) (&.take size takes))))) - (and (List/= (list.n/range |0 (dec size)) + (and (List/= (list.n/range 0 (dec size)) (&.take-while (n/< size) sample0)) (List/= (list.n/range offset (dec (n/+ offset size))) (&.take-while (n/< (n/+ offset size)) (&.drop-while (n/< offset) sample0))) (let [[drops takes] (&.split-while (n/< size) sample0)] - (and (List/= (list.n/range |0 (dec size)) + (and (List/= (list.n/range 0 (dec size)) drops) - (List/= (list.n/range size (dec (n/* |2 size))) - (&.take-while (n/< (n/* |2 size)) takes))))) + (List/= (list.n/range size (dec (n/* 2 size))) + (&.take-while (n/< (n/* 2 size)) takes))))) )) (test "Can repeat any element and infinite number of times." @@ -58,13 +58,13 @@ (&.take size (&.tail sample1))))) (test "Can filter sequences." - (and (n/= (n/* |2 offset) + (and (n/= (n/* 2 offset) (&.nth offset (&.filter n/even? sample0))) - (let [[evens odds] (&.partition n/even? (&.iterate inc |0))] - (and (n/= (n/* |2 offset) + (let [[evens odds] (&.partition n/even? (&.iterate inc 0))] + (and (n/= (n/* 2 offset) (&.nth offset evens)) - (n/= (inc (n/* |2 offset)) + (n/= (inc (n/* 2 offset)) (&.nth offset odds)))))) (test "Functor goes over 'all' elements in a sequence." diff --git a/stdlib/test/test/lux/data/collection/set.lux b/stdlib/test/test/lux/data/collection/set.lux index d67503b53..1b94aed8c 100644 --- a/stdlib/test/test/lux/data/collection/set.lux +++ b/stdlib/test/test/lux/data/collection/set.lux @@ -14,10 +14,10 @@ (def: gen-nat (r.Random Nat) (|> r.nat - (:: r.Monad map (n/% |100)))) + (:: r.Monad map (n/% 100)))) (context: "Sets" - (<| (times |100) + (<| (times 100) (do @ [sizeL gen-nat sizeR gen-nat diff --git a/stdlib/test/test/lux/data/collection/set/ordered.lux b/stdlib/test/test/lux/data/collection/set/ordered.lux index 16eca4081..7eb313c0f 100644 --- a/stdlib/test/test/lux/data/collection/set/ordered.lux +++ b/stdlib/test/test/lux/data/collection/set/ordered.lux @@ -17,10 +17,10 @@ (def: gen-nat (r.Random Nat) (|> r.nat - (:: r.Monad map (n/% |100)))) + (:: r.Monad map (n/% 100)))) (context: "Sets" - (<| (times |100) + (<| (times 100) (do @ [sizeL gen-nat sizeR gen-nat diff --git a/stdlib/test/test/lux/data/collection/stack.lux b/stdlib/test/test/lux/data/collection/stack.lux index b786193b0..954e72e78 100644 --- a/stdlib/test/test/lux/data/collection/stack.lux +++ b/stdlib/test/test/lux/data/collection/stack.lux @@ -13,10 +13,10 @@ (def: gen-nat (r.Random Nat) (|> r.nat - (:: r.Monad map (n/% |100)))) + (:: r.Monad map (n/% 100)))) (context: "Stacks" - (<| (times |100) + (<| (times 100) (do @ [size gen-nat sample (r.stack size gen-nat) diff --git a/stdlib/test/test/lux/data/collection/tree/rose.lux b/stdlib/test/test/lux/data/collection/tree/rose.lux index 207c6aab9..674ac1d47 100644 --- a/stdlib/test/test/lux/data/collection/tree/rose.lux +++ b/stdlib/test/test/lux/data/collection/tree/rose.lux @@ -19,19 +19,19 @@ (r.Random [Nat (&.Tree Nat)]) (r.rec (function (_ gen-tree) - (r.either (:: r.Monad map (|>> &.leaf [|1]) r.nat) + (r.either (:: r.Monad map (|>> &.leaf [1]) r.nat) (do r.Monad [value r.nat - num-children (|> r.nat (:: @ map (n/% |3))) + num-children (|> r.nat (:: @ map (n/% 3))) children' (r.list num-children gen-tree) - #let [size' (list/fold n/+ |0 (list/map product.left children')) + #let [size' (list/fold n/+ 0 (list/map product.left children')) children (list/map product.right children')]] (wrap [(inc size') (&.branch value children)])) )))) (context: "Trees" - (<| (times |100) + (<| (times 100) (do @ [[size sample] gen-tree #let [(^open "&/.") (&.Equivalence number.Equivalence) diff --git a/stdlib/test/test/lux/data/collection/tree/rose/zipper.lux b/stdlib/test/test/lux/data/collection/tree/rose/zipper.lux index d91b0065d..b1481518b 100644 --- a/stdlib/test/test/lux/data/collection/tree/rose/zipper.lux +++ b/stdlib/test/test/lux/data/collection/tree/rose/zipper.lux @@ -22,7 +22,7 @@ (r.rec (function (_ gen-tree) (do r.Monad ## Each branch can have, at most, 1 child. - [size (|> r.nat (:: @ map (n/% |2)))] + [size (|> r.nat (:: @ map (n/% 2)))] (r.and r.nat (r.list size gen-tree)))))) @@ -34,7 +34,7 @@ (recur (&.next zipper))))) (context: "Zippers." - (<| (times |100) + (<| (times 100) (do @ [sample gen-tree new-val r.nat diff --git a/stdlib/test/test/lux/data/color.lux b/stdlib/test/test/lux/data/color.lux index 7d584ab4b..8932fad79 100644 --- a/stdlib/test/test/lux/data/color.lux +++ b/stdlib/test/test/lux/data/color.lux @@ -31,8 +31,8 @@ (def: error-margin Frac +1.8) -(def: black @.Color (@.color [|0 |0 |0])) -(def: white @.Color (@.color [|255 |255 |255])) +(def: black @.Color (@.color [0 0 0])) +(def: white @.Color (@.color [255 255 255])) (do-template [] [(def: ( color) @@ -45,7 +45,7 @@ ) (context: "Color." - (<| (times |100) + (<| (times 100) (do @ [any color colorful (|> color diff --git a/stdlib/test/test/lux/data/format/json.lux b/stdlib/test/test/lux/data/format/json.lux index a898a2c97..dc30d54d7 100644 --- a/stdlib/test/test/lux/data/format/json.lux +++ b/stdlib/test/test/lux/data/format/json.lux @@ -44,7 +44,7 @@ (r.Random @.JSON) (r.rec (function (_ gen-json) (do r.Monad - [size (:: @ map (n/% |2) r.nat)] + [size (:: @ map (n/% 2) r.nat)] ($_ r.or (:: @ wrap []) r.bit @@ -55,7 +55,7 @@ ))))) (context: "JSON" - (<| (times |100) + (<| (times 100) (do @ [sample gen-json #let [(^open "@/.") @.Equivalence @@ -113,7 +113,7 @@ (def: gen-record (r.Random Record) (do r.Monad - [size (:: @ map (n/% |2) r.nat)] + [size (:: @ map (n/% 2) r.nat)] ($_ r.and r.bit r.frac @@ -167,8 +167,8 @@ )))) (context: "Polytypism" - (<| (seed |14562075782602945288) - ## (times |100) + (<| (seed 14562075782602945288) + ## (times 100) (do @ [sample gen-record #let [(^open "@/.") Equivalence diff --git a/stdlib/test/test/lux/data/format/xml.lux b/stdlib/test/test/lux/data/format/xml.lux index 6e6894f8b..b61ad1a5d 100644 --- a/stdlib/test/test/lux/data/format/xml.lux +++ b/stdlib/test/test/lux/data/format/xml.lux @@ -44,22 +44,22 @@ (def: xml-identifier^ (r.Random Name) - (r.and (xml-text^ |0 |10) - (xml-text^ |1 |10))) + (r.and (xml-text^ 0 10) + (xml-text^ 1 10))) (def: gen-xml (r.Random &.XML) (r.rec (function (_ gen-xml) - (r.or (xml-text^ |1 |10) + (r.or (xml-text^ 1 10) (do r.Monad - [size (size^ |0 |2)] + [size (size^ 0 2)] ($_ r.and xml-identifier^ - (r.dictionary name.Hash size xml-identifier^ (xml-text^ |0 |10)) + (r.dictionary name.Hash size xml-identifier^ (xml-text^ 0 10)) (r.list size gen-xml))))))) (context: "XML." - (<| (times |100) + (<| (times 100) (do @ [sample gen-xml #let [(^open "&/.") &.Equivalence @@ -78,14 +78,14 @@ )))) (context: "Parsing." - (<| (times |100) + (<| (times 100) (do @ - [text (xml-text^ |1 |10) - num-children (|> r.nat (:: @ map (n/% |5))) - children (r.list num-children (xml-text^ |1 |10)) + [text (xml-text^ 1 10) + num-children (|> r.nat (:: @ map (n/% 5))) + children (r.list num-children (xml-text^ 1 10)) tag xml-identifier^ attr xml-identifier^ - value (xml-text^ |1 |10) + value (xml-text^ 1 10) #let [node (#&.Node tag (dict.put attr value &.attrs) (list/map (|>> #&.Text) children))]] diff --git a/stdlib/test/test/lux/data/lazy.lux b/stdlib/test/test/lux/data/lazy.lux index 416f3dd56..b5918c281 100644 --- a/stdlib/test/test/lux/data/lazy.lux +++ b/stdlib/test/test/lux/data/lazy.lux @@ -9,7 +9,7 @@ lux/test) (context: "Lazy." - (<| (times |100) + (<| (times 100) (do @ [left r.nat right r.nat @@ -27,7 +27,7 @@ )))) (context: "Functor, Apply, Monad." - (<| (times |100) + (<| (times 100) (do @ [sample r.nat] ($_ seq diff --git a/stdlib/test/test/lux/data/name.lux b/stdlib/test/test/lux/data/name.lux index 16ab67f59..53751066d 100644 --- a/stdlib/test/test/lux/data/name.lux +++ b/stdlib/test/test/lux/data/name.lux @@ -16,17 +16,17 @@ (|> (r.unicode size) (r.filter (|>> (text.contains? ".") not)))) (context: "Names" - (<| (times |100) + (<| (times 100) (do @ [## First Name - sizeM1 (|> r.nat (:: @ map (n/% |100))) - sizeN1 (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1)))) + sizeM1 (|> r.nat (:: @ map (n/% 100))) + sizeN1 (|> r.nat (:: @ map (|>> (n/% 100) (n/max 1)))) module1 (gen-part sizeM1) short1 (gen-part sizeN1) #let [name1 [module1 short1]] ## Second Name - sizeM2 (|> r.nat (:: @ map (n/% |100))) - sizeN2 (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1)))) + sizeM2 (|> r.nat (:: @ map (n/% 100))) + sizeN2 (|> r.nat (:: @ map (|>> (n/% 100) (n/max 1)))) module2 (gen-part sizeM2) short2 (gen-part sizeN2) #let [name2 [module2 short2]] diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux index c8e436d1d..36bc9a3f9 100644 --- a/stdlib/test/test/lux/data/number.lux +++ b/stdlib/test/test/lux/data/number.lux @@ -13,7 +13,7 @@ (do-template [category rand-gen ] [(context: (format "[" category "] " "Equivalence & Order") - (<| (times |100) + (<| (times 100) (do @ [x rand-gen y rand-gen] @@ -30,7 +30,7 @@ (do-template [category rand-gen ] [(context: (format "[" category "] " "Number") - (<| (times |100) + (<| (times 100) (do @ [x rand-gen #let [(^open ".") @@ -53,7 +53,7 @@ (do-template [category rand-gen ] [(context: (format "[" category "] " "Enum") - (<| (times |100) + (<| (times 100) (do @ [x rand-gen] (test "" (let [(^open ".") @@ -75,7 +75,7 @@ (do-template [category rand-gen ] [(context: (format "[" category "] " "Interval") - (<| (times |100) + (<| (times 100) (do @ [x (|> rand-gen (r.filter )) #let [(^open ".") @@ -92,7 +92,7 @@ (do-template [category rand-gen ] [(context: (format "[" category "] " "Monoid") - (<| (times |100) + (<| (times 100) (do @ [x (|> rand-gen (:: @ map (|>> (:: abs) )) (r.filter )) #let [(^open ".") @@ -103,10 +103,10 @@ (= x (compose x identity)) (= identity (compose identity identity)))))))] - ["Nat/Add" r.nat Number Order Add@Monoid (n/% |1000) (function (_ _) #1)] - ["Nat/Mul" r.nat Number Order Mul@Monoid (n/% |1000) (function (_ _) #1)] - ["Nat/Min" r.nat Number Order Min@Monoid (n/% |1000) (function (_ _) #1)] - ["Nat/Max" r.nat Number Order Max@Monoid (n/% |1000) (function (_ _) #1)] + ["Nat/Add" r.nat Number Order Add@Monoid (n/% 1000) (function (_ _) #1)] + ["Nat/Mul" r.nat Number Order Mul@Monoid (n/% 1000) (function (_ _) #1)] + ["Nat/Min" r.nat Number Order Min@Monoid (n/% 1000) (function (_ _) #1)] + ["Nat/Max" r.nat Number Order Max@Monoid (n/% 1000) (function (_ _) #1)] ["Int/Add" r.int Number Order Add@Monoid (i/% +1000) (function (_ _) #1)] ["Int/Mul" r.int Number Order Mul@Monoid (i/% +1000) (function (_ _) #1)] ["Int/Min" r.int Number Order Min@Monoid (i/% +1000) (function (_ _) #1)] @@ -123,7 +123,7 @@ (do-template [ ] [(context: (format "[" "] " "Alternative formats") - (<| (times |100) + (<| (times 100) (do @ [x ] (test "Can encode/decode values." @@ -158,10 +158,10 @@ ) (context: "Can convert frac values to/from their bit patterns." - (<| (times |100) + (<| (times 100) (do @ [raw r.frac - factor (|> r.nat (:: @ map (|>> (n/% |1000) (n/max |1)))) + factor (|> r.nat (:: @ map (|>> (n/% 1000) (n/max 1)))) #let [sample (|> factor .int int-to-frac (f/* raw))]] (test "Can convert frac values to/from their bit patterns." (|> sample frac-to-bits bits-to-frac (f/= sample)))))) @@ -169,12 +169,12 @@ (context: "Macros for alternative numeric encodings." ($_ seq (test "Binary." - (and (n/= (bin "|11001001") (bin "|11_00_10_01")) + (and (n/= (bin "11001001") (bin "11_00_10_01")) (i/= (bin "+11001001") (bin "+11_00_10_01")) (r/= (bin ".11001001") (bin ".11_00_10_01")) (f/= (bin "+1100.1001") (bin "+11_00.10_01")))) (test "Octal." - (and (n/= (oct "|615243") (oct "|615_243")) + (and (n/= (oct "615243") (oct "615_243")) (i/= (oct "+615243") (oct "+615_243")) (r/= (oct ".615243") (oct ".615_243")) (f/= (oct "+6152.43") (oct "+615_2.43")))) diff --git a/stdlib/test/test/lux/data/number/complex.lux b/stdlib/test/test/lux/data/number/complex.lux index 994e1cafb..537027710 100644 --- a/stdlib/test/test/lux/data/number/complex.lux +++ b/stdlib/test/test/lux/data/number/complex.lux @@ -26,7 +26,7 @@ (def: gen-dim (r.Random Frac) (do r.Monad - [factor (|> r.nat (:: @ map (|>> (n/% |1000) (n/max |1)))) + [factor (|> r.nat (:: @ map (|>> (n/% 1000) (n/max 1)))) measure (|> r.frac (r.filter (f/> +0.0)))] (wrap (f/* (|> factor .int int-to-frac) measure)))) @@ -39,7 +39,7 @@ (wrap (&.complex real imaginary)))) (context: "Construction" - (<| (times |100) + (<| (times 100) (do @ [real gen-dim imaginary gen-dim] @@ -55,7 +55,7 @@ )))) (context: "Absolute value" - (<| (times |100) + (<| (times 100) (do @ [real gen-dim imaginary gen-dim] @@ -78,7 +78,7 @@ )))) (context: "Addidion, substraction, multiplication and division" - (<| (times |100) + (<| (times 100) (do @ [x gen-complex y gen-complex @@ -122,7 +122,7 @@ )))) (context: "Conjugate, reciprocal, signum, negation" - (<| (times |100) + (<| (times 100) (do @ [x gen-complex] ($_ seq @@ -162,8 +162,8 @@ (|> normal forward backward (within? margin-of-error normal)))) (context: "Trigonometry" - (<| (seed |17274883666004960943) - ## (times |100) + (<| (seed 17274883666004960943) + ## (times 100) (do @ [angle (|> gen-complex (:: @ map (|>> (update@ #&.real (f/% +1.0)) (update@ #&.imaginary (f/% +1.0)))))] @@ -178,7 +178,7 @@ (trigonometric-symmetry &.tan &.atan angle)))))) (context: "Power 2 and exponential/logarithm" - (<| (times |100) + (<| (times 100) (do @ [x gen-complex] ($_ seq @@ -190,10 +190,10 @@ )))) (context: "Complex roots" - (<| (times |100) + (<| (times 100) (do @ [sample gen-complex - degree (|> r.nat (:: @ map (|>> (n/max |1) (n/% |5))))] + degree (|> r.nat (:: @ map (|>> (n/max 1) (n/% 5))))] (test "Can calculate the N roots for any complex number." (|> sample (&.roots degree) diff --git a/stdlib/test/test/lux/data/number/i64.lux b/stdlib/test/test/lux/data/number/i64.lux index 96a174eaa..62de5e56e 100644 --- a/stdlib/test/test/lux/data/number/i64.lux +++ b/stdlib/test/test/lux/data/number/i64.lux @@ -10,7 +10,7 @@ lux/test) (context: "Bitwise operations." - (<| (times |100) + (<| (times 100) (do @ [pattern r.nat idx (:: @ map (n/% &.width) r.nat)] @@ -20,10 +20,10 @@ (&.count (&.clear idx pattern))) (|> (&.count pattern) (n/- (&.count (&.clear idx pattern))) - (n/<= |1)) + (n/<= 1)) (|> (&.count (&.set idx pattern)) (n/- (&.count pattern)) - (n/<= |1)))) + (n/<= 1)))) (test "Can query whether a bit is set." (and (or (and (&.set? idx pattern) (not (&.set? idx (&.clear idx pattern)))) @@ -39,16 +39,16 @@ (n/+ (&.count pattern) (&.count (&.not pattern))))) (test "Can do simple binary logic." - (and (n/= |0 + (and (n/= 0 (&.and pattern (&.not pattern))) - (n/= (&.not |0) + (n/= (&.not 0) (&.or pattern (&.not pattern))) - (n/= (&.not |0) + (n/= (&.not 0) (&.xor pattern (&.not pattern))) - (n/= |0 + (n/= 0 (&.xor pattern pattern)))) (test "rotate-left and rotate-right are inverses of one another." diff --git a/stdlib/test/test/lux/data/number/ratio.lux b/stdlib/test/test/lux/data/number/ratio.lux index d30278cf5..aa931d688 100644 --- a/stdlib/test/test/lux/data/number/ratio.lux +++ b/stdlib/test/test/lux/data/number/ratio.lux @@ -12,27 +12,27 @@ (def: gen-part (r.Random Nat) - (|> r.nat (:: r.Monad map (|>> (n/% |1000) (n/max |1))))) + (|> r.nat (:: r.Monad map (|>> (n/% 1000) (n/max 1))))) (def: gen-ratio (r.Random &.Ratio) (do r.Monad [numerator gen-part denominator (|> gen-part - (r.filter (|>> (n/= |0) not)) + (r.filter (|>> (n/= 0) not)) (r.filter (|>> (n/= numerator) not)))] (wrap (&.ratio numerator denominator)))) (context: "Normalization" - (<| (times |100) + (<| (times 100) (do @ [denom1 gen-part denom2 gen-part sample gen-ratio] ($_ seq (test "All zeroes are the same." - (&.= (&.ratio |0 denom1) - (&.ratio |0 denom2))) + (&.= (&.ratio 0 denom1) + (&.ratio 0 denom2))) (test "All ratios are built normalized." (|> sample @@ -42,7 +42,7 @@ )))) (context: "Arithmetic" - (<| (times |100) + (<| (times 100) (do @ [x gen-ratio y gen-ratio @@ -67,12 +67,12 @@ (let [remainder (&.% min max) multiple (&.- remainder max) factor (&./ min multiple)] - (and (|> factor (get@ #&.denominator) (n/= |1)) + (and (|> factor (get@ #&.denominator) (n/= 1)) (|> factor (&.* min) (&.+ remainder) (&.= max))))) )))) (context: "Negation, absolute value and signum" - (<| (times |100) + (<| (times 100) (do @ [sample gen-ratio] ($_ seq @@ -90,7 +90,7 @@ )))) (context: "Order" - (<| (times |100) + (<| (times 100) (do @ [x gen-ratio y gen-ratio] @@ -103,7 +103,7 @@ )))) (context: "Codec" - (<| (times |100) + (<| (times 100) (do @ [sample gen-ratio #let [(^open "&/.") &.Codec]] diff --git a/stdlib/test/test/lux/data/sum.lux b/stdlib/test/test/lux/data/sum.lux index 4023c1cc3..96c0518c0 100644 --- a/stdlib/test/test/lux/data/sum.lux +++ b/stdlib/test/test/lux/data/sum.lux @@ -13,25 +13,25 @@ (let [(^open "List/.") (list.Equivalence text.Equivalence)] ($_ seq (test "Can inject values into Either." - (and (|> (left "Hello") (case> (|0 "Hello") #1 _ #0)) - (|> (right "World") (case> (|1 "World") #1 _ #0)))) + (and (|> (left "Hello") (case> (0 "Hello") #1 _ #0)) + (|> (right "World") (case> (1 "World") #1 _ #0)))) (test "Can discriminate eithers based on their cases." (let [[_lefts _rights] (partition (: (List (| Text Text)) - (list (|0 "+0") (|1 "+1") (|0 "+2"))))] + (list (0 "+0") (1 "+1") (0 "+2"))))] (and (List/= _lefts (lefts (: (List (| Text Text)) - (list (|0 "+0") (|1 "+1") (|0 "+2"))))) + (list (0 "+0") (1 "+1") (0 "+2"))))) (List/= _rights (rights (: (List (| Text Text)) - (list (|0 "+0") (|1 "+1") (|0 "+2")))))))) + (list (0 "+0") (1 "+1") (0 "+2")))))))) (test "Can apply a function to an Either value depending on the case." (and (i/= +10 (either (function (_ _) +10) (function (_ _) +20) - (: (| Text Text) (|0 "")))) + (: (| Text Text) (0 "")))) (i/= +20 (either (function (_ _) +10) (function (_ _) +20) - (: (| Text Text) (|1 "")))))) + (: (| Text Text) (1 "")))))) ))) diff --git a/stdlib/test/test/lux/data/text.lux b/stdlib/test/test/lux/data/text.lux index 3d257cd75..a98eb92e6 100644 --- a/stdlib/test/test/lux/data/text.lux +++ b/stdlib/test/test/lux/data/text.lux @@ -13,21 +13,21 @@ lux/test) (context: "Size" - (<| (times |100) + (<| (times 100) (do @ - [size (:: @ map (n/% |100) r.nat) + [size (:: @ map (n/% 100) r.nat) sample (r.unicode size)] - (test "" (or (and (n/= |0 size) + (test "" (or (and (n/= 0 size) (&.empty? sample)) (n/= size (&.size sample))))))) (def: bounded-size (r.Random Nat) (|> r.nat - (:: r.Monad map (|>> (n/% |20) (n/+ |1))))) + (:: r.Monad map (|>> (n/% 20) (n/+ 1))))) (context: "Locations" - (<| (times |100) + (<| (times 100) (do @ [size bounded-size idx (:: @ map (n/% size) r.nat) @@ -56,7 +56,7 @@ )))) (context: "Text functions" - (<| (times |100) + (<| (times 100) (do @ [sizeL bounded-size sizeR bounded-size @@ -83,10 +83,10 @@ _ #0)) - (|> [(&.clip |0 sizeL sample) + (|> [(&.clip 0 sizeL sample) (&.clip sizeL (&.size sample) sample) (&.clip' sizeL sample) - (&.clip' |0 sample)] + (&.clip' 0 sample)] (case> [(#.Right _l) (#.Right _r) (#.Right _r') (#.Right _f)] (and (= sampleL _l) (= sampleR _r) @@ -99,16 +99,16 @@ )))) (context: "More text functions" - (<| (times |100) + (<| (times 100) (do @ [sizeP bounded-size sizeL bounded-size #let [## The wider unicode charset includes control characters that ## can make text replacement work improperly. ## Because of that, I restrict the charset. - normal-char-gen (|> r.nat (:: @ map (|>> (n/% |128) (n/max |1))))] - sep1 (r.text normal-char-gen |1) - sep2 (r.text normal-char-gen |1) + normal-char-gen (|> r.nat (:: @ map (|>> (n/% 128) (n/max 1))))] + sep1 (r.text normal-char-gen 1) + sep2 (r.text normal-char-gen 1) #let [part-gen (|> (r.text normal-char-gen sizeP) (r.filter (|>> (&.contains? sep1) not)))] parts (r.list sizeL part-gen) diff --git a/stdlib/test/test/lux/data/text/format.lux b/stdlib/test/test/lux/data/text/format.lux index adf4cdf7b..bd66712a8 100644 --- a/stdlib/test/test/lux/data/text/format.lux +++ b/stdlib/test/test/lux/data/text/format.lux @@ -12,7 +12,7 @@ ($_ seq (test "Can format common values simply." (and (&/= "#1" (%b #1)) - (&/= "|123" (%n |123)) + (&/= "123" (%n 123)) (&/= "+123" (%i +123)) (&/= "+123.456" (%f +123.456)) (&/= ".5" (%r .5)) diff --git a/stdlib/test/test/lux/data/text/lexer.lux b/stdlib/test/test/lux/data/text/lexer.lux index d413504e0..d87f91eb4 100644 --- a/stdlib/test/test/lux/data/text/lexer.lux +++ b/stdlib/test/test/lux/data/text/lexer.lux @@ -73,9 +73,9 @@ )) (context: "Literals" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) + [size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10)))) sample (r.unicode size) non-sample (|> (r.unicode size) (r.filter (|>> (text/= sample) not)))] diff --git a/stdlib/test/test/lux/data/text/regex.lux b/stdlib/test/test/lux/data/text/regex.lux index 1135dbb0c..96f56c3d9 100644 --- a/stdlib/test/test/lux/data/text/regex.lux +++ b/stdlib/test/test/lux/data/text/regex.lux @@ -252,26 +252,26 @@ (context: "Regular Expressions [Alternation]" ($_ seq (test "Can specify alternative patterns." - (and (should-check ["a" (|0 [])] (&.regex "a|b") "a") - (should-check ["b" (|1 [])] (&.regex "a|b") "b") + (and (should-check ["a" (0 [])] (&.regex "a|b") "a") + (should-check ["b" (1 [])] (&.regex "a|b") "b") (should-fail (&.regex "a|b") "c"))) (test "Can have groups within alternations." - (and (should-check ["abc" (|0 ["b" "c"])] (&.regex "a(.)(.)|b(.)(.)") "abc") - (should-check ["bcd" (|1 ["c" "d"])] (&.regex "a(.)(.)|b(.)(.)") "bcd") + (and (should-check ["abc" (0 ["b" "c"])] (&.regex "a(.)(.)|b(.)(.)") "abc") + (should-check ["bcd" (1 ["c" "d"])] (&.regex "a(.)(.)|b(.)(.)") "bcd") (should-fail (&.regex "a(.)(.)|b(.)(.)") "cde") - (should-check ["809-345-6789" (|0 ["809" "345-6789" "345" "6789"])] + (should-check ["809-345-6789" (0 ["809" "345-6789" "345" "6789"])] (&.regex "(\\d{3})-((\\d{3})-(\\d{4}))|b(.)d") "809-345-6789"))) )) (context: "Pattern-matching" - (<| (times |100) + (<| (times 100) (do @ - [sample1 (r.unicode |3) - sample2 (r.unicode |3) - sample3 (r.unicode |4)] + [sample1 (r.unicode 3) + sample2 (r.unicode 3) + sample3 (r.unicode 4)] (case (format sample1 "-" sample2 "-" sample3) (&.^regex "(.{3})-(.{3})-(.{4})" [_ match1 match2 match3]) diff --git a/stdlib/test/test/lux/host.jvm.lux b/stdlib/test/test/lux/host.jvm.lux index d6b125657..49a229d11 100644 --- a/stdlib/test/test/lux/host.jvm.lux +++ b/stdlib/test/test/lux/host.jvm.lux @@ -59,7 +59,7 @@ ([] foo [boolean String] void #throws [Exception])) (context: "Conversions" - (<| (times |100) + (<| (times 100) (do @ [sample r.int] (with-expansions @@ -108,9 +108,9 @@ )) (context: "Arrays" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |1)))) + [size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 1)))) idx (|> r.nat (:: @ map (n/% size))) value r.int] ($_ seq diff --git a/stdlib/test/test/lux/macro/poly/equivalence.lux b/stdlib/test/test/lux/macro/poly/equivalence.lux index 5d7cfee64..8b10dc738 100644 --- a/stdlib/test/test/lux/macro/poly/equivalence.lux +++ b/stdlib/test/test/lux/macro/poly/equivalence.lux @@ -48,7 +48,7 @@ (def: gen-record (r.Random Record) (do r.Monad - [size (:: @ map (n/% |2) r.nat) + [size (:: @ map (n/% 2) r.nat) #let [gen-int (|> r.int (:: @ map (|>> int/abs (i/% +1_000_000))))]] ($_ r.and r.bit @@ -65,7 +65,7 @@ ## [Tests] (context: "Equivalence polytypism" - (<| (times |100) + (<| (times 100) (do @ [sample gen-record #let [(^open "&/.") Equivalence]] diff --git a/stdlib/test/test/lux/macro/syntax.lux b/stdlib/test/test/lux/macro/syntax.lux index 63d592251..b1e2f445b 100644 --- a/stdlib/test/test/lux/macro/syntax.lux +++ b/stdlib/test/test/lux/macro/syntax.lux @@ -73,7 +73,7 @@ (enforced? (s.this ( )) (list ( )))))] ["Can parse Bit syntax." #1 code.bit bit.Equivalence s.bit] - ["Can parse Nat syntax." |123 code.nat number.Equivalence s.nat] + ["Can parse Nat syntax." 123 code.nat number.Equivalence s.nat] ["Can parse Int syntax." +123 code.int number.Equivalence s.int] ["Can parse Rev syntax." .123 code.rev number.Equivalence s.rev] ["Can parse Frac syntax." +123.0 code.frac number.Equivalence s.frac] diff --git a/stdlib/test/test/lux/math.lux b/stdlib/test/test/lux/math.lux index 83ed1f8b0..4cdb8eed5 100644 --- a/stdlib/test/test/lux/math.lux +++ b/stdlib/test/test/lux/math.lux @@ -22,7 +22,7 @@ (|> normal forward backward (within? margin normal)))) (context: "Trigonometry" - (<| (times |100) + (<| (times 100) (do @ [angle (|> r.frac (:: @ map (f/* &.tau)))] ($_ seq @@ -37,7 +37,7 @@ )))) (context: "Rounding" - (<| (times |100) + (<| (times 100) (do @ [sample (|> r.frac (:: @ map (f/* +1000.0)))] ($_ seq @@ -60,34 +60,34 @@ )))) (context: "Exponentials and logarithms" - (<| (times |100) + (<| (times 100) (do @ [sample (|> r.frac (:: @ map (f/* +10.0)))] (test "Logarithm is the inverse of exponential." (|> sample &.exp &.log (within? +1.0e-15 sample)))))) (context: "Greatest-Common-Divisor and Least-Common-Multiple" - (<| (times |100) + (<| (times 100) (do @ - [#let [gen-nat (|> r.nat (:: @ map (|>> (n/% |1000) (n/max |1))))] + [#let [gen-nat (|> r.nat (:: @ map (|>> (n/% 1000) (n/max 1))))] x gen-nat y gen-nat] ($_ seq (test "GCD" (let [gcd (&.n/gcd x y)] - (and (n/= |0 (n/% gcd x)) - (n/= |0 (n/% gcd y)) - (n/>= |1 gcd)))) + (and (n/= 0 (n/% gcd x)) + (n/= 0 (n/% gcd y)) + (n/>= 1 gcd)))) (test "LCM" (let [lcm (&.n/lcm x y)] - (and (n/= |0 (n/% x lcm)) - (n/= |0 (n/% y lcm)) + (and (n/= 0 (n/% x lcm)) + (n/= 0 (n/% y lcm)) (n/<= (n/* x y) lcm)))) )))) (context: "Infix syntax" - (<| (times |100) + (<| (times 100) (do @ [x r.nat y r.nat @@ -109,8 +109,8 @@ (&.infix [&.sin theta]))) (test "Can use regular syntax in the middle of infix code." - (n/= (&.n/gcd |450 (n/* |3 |9)) - (&.infix [(n/* |3 |9) &.n/gcd |450]))) + (n/= (&.n/gcd 450 (n/* 3 9)) + (&.infix [(n/* 3 9) &.n/gcd 450]))) (test "Can use non-numerical functions/macros as operators." (bit/= (and (n/< y x) (n/< z y)) diff --git a/stdlib/test/test/lux/math/logic/continuous.lux b/stdlib/test/test/lux/math/logic/continuous.lux index 02329d05d..b9db253f6 100644 --- a/stdlib/test/test/lux/math/logic/continuous.lux +++ b/stdlib/test/test/lux/math/logic/continuous.lux @@ -9,7 +9,7 @@ lux/test) (context: "Operations" - (<| (times |100) + (<| (times 100) (do @ [left r.rev right r.rev] diff --git a/stdlib/test/test/lux/math/logic/fuzzy.lux b/stdlib/test/test/lux/math/logic/fuzzy.lux index ad23d2eb9..fe36a58c5 100644 --- a/stdlib/test/test/lux/math/logic/fuzzy.lux +++ b/stdlib/test/test/lux/math/logic/fuzzy.lux @@ -19,9 +19,9 @@ (do-template [ ] [(context: (format "[" "] " "Triangles") - (<| (times |100) + (<| (times 100) (do @ - [values (r.set |3 ) + [values (r.set 3 ) #let [[x y z] (case (set.to-list values) (^ (list x y z)) [x y z] @@ -60,9 +60,9 @@ (do-template [ ] [(context: (format "[" "] " "Trapezoids") - (<| (times |100) + (<| (times 100) (do @ - [values (r.set |4 ) + [values (r.set 4 ) #let [[w x y z] (case (set.to-list values) (^ (list w x y z)) [w x y z] @@ -114,7 +114,7 @@ (wrap (&.triangle x y z)))) (context: "Combinators" - (<| (times |100) + (<| (times 100) (do @ [left gen-triangle right gen-triangle @@ -148,10 +148,10 @@ )))) (context: "From predicates and sets" - (<| (times |100) + (<| (times 100) (do @ - [#let [set-10 (set.from-list number.Hash (list.n/range |0 |10))] - sample (|> r.nat (:: @ map (n/% |20)))] + [#let [set-10 (set.from-list number.Hash (list.n/range 0 10))] + sample (|> r.nat (:: @ map (n/% 20)))] ($_ seq (test "Values that satisfy a predicate have membership = 1. Values that don't have membership = 0." @@ -165,7 +165,7 @@ )))) (context: "Thresholds" - (<| (times |100) + (<| (times 100) (do @ [fuzzy gen-triangle sample r.rev diff --git a/stdlib/test/test/lux/math/modular.lux b/stdlib/test/test/lux/math/modular.lux index 43f7d178e..559928304 100644 --- a/stdlib/test/test/lux/math/modular.lux +++ b/stdlib/test/test/lux/math/modular.lux @@ -60,7 +60,7 @@ (/.m/= (m/! param subject))))) (context: "Modular arithmetic." - (<| (times |100) + (<| (times 100) (do @ [_normalM modulusR _alternativeM (|> modulusR (r.filter (|>> (i/= _normalM) not))) diff --git a/stdlib/test/test/lux/math/random.lux b/stdlib/test/test/lux/math/random.lux index 5085855e6..f3f118c90 100644 --- a/stdlib/test/test/lux/math/random.lux +++ b/stdlib/test/test/lux/math/random.lux @@ -17,9 +17,9 @@ lux/test) (context: "Random." - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) + [size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10)))) _list (r.list size r.nat) _row (r.row size r.nat) _array (r.array size r.nat) diff --git a/stdlib/test/test/lux/time/date.lux b/stdlib/test/test/lux/time/date.lux index 600f67b87..602ecc78f 100644 --- a/stdlib/test/test/lux/time/date.lux +++ b/stdlib/test/test/lux/time/date.lux @@ -30,7 +30,7 @@ (random/wrap #@.December)))))) (context: "(Month) Equivalence." - (<| (times |100) + (<| (times 100) (do @ [sample month #let [(^open "@/.") @.Equivalence]] @@ -38,7 +38,7 @@ (@/= sample sample))))) (context: "(Month) Order." - (<| (times |100) + (<| (times 100) (do @ [reference month sample month @@ -50,7 +50,7 @@ (@/<= reference sample))))))) (context: "(Month) Enum." - (<| (times |100) + (<| (times 100) (do @ [sample month #let [(^open "@/.") @.Enum]] @@ -73,7 +73,7 @@ (random/wrap #@.Saturday)))) (context: "(Day) Equivalence." - (<| (times |100) + (<| (times 100) (do @ [sample day #let [(^open "@/.") @.Equivalence]] @@ -81,7 +81,7 @@ (@/= sample sample))))) (context: "(Day) Order." - (<| (times |100) + (<| (times 100) (do @ [reference day sample day @@ -93,7 +93,7 @@ (@/<= reference sample))))))) (context: "(Day) Enum." - (<| (times |100) + (<| (times 100) (do @ [sample day #let [(^open "@/.") @.Enum]] @@ -110,7 +110,7 @@ (|> _instant.instant (:: r.Monad map @instant.date))) (context: "(Date) Equivalence." - (<| (times |100) + (<| (times 100) (do @ [sample date #let [(^open "@/.") @.Equivalence]] @@ -118,7 +118,7 @@ (@/= sample sample))))) (context: "(Date) Order." - (<| (times |100) + (<| (times 100) (do @ [reference date sample date @@ -130,8 +130,8 @@ (@/<= reference sample))))))) (context: "(Date) Codec" - (<| (seed |6623983470548808292) - ## (times |100) + (<| (seed 6623983470548808292) + ## (times 100) (do @ [sample date #let [(^open "@/.") @.Equivalence diff --git a/stdlib/test/test/lux/time/duration.lux b/stdlib/test/test/lux/time/duration.lux index 0f8c9f553..1231fb563 100644 --- a/stdlib/test/test/lux/time/duration.lux +++ b/stdlib/test/test/lux/time/duration.lux @@ -16,14 +16,14 @@ (|> r.int (:: r.Monad map @.from-millis))) (context: "Conversion." - (<| (times |100) + (<| (times 100) (do @ [millis r.int] (test "Can convert from/to milliseconds." (|> millis @.from-millis @.to-millis (i/= millis)))))) (context: "Equivalence." - (<| (times |100) + (<| (times 100) (do @ [sample duration #let [(^open "@/.") @.Equivalence]] @@ -31,7 +31,7 @@ (@/= sample sample))))) (context: "Order." - (<| (times |100) + (<| (times 100) (do @ [reference duration sample duration @@ -43,7 +43,7 @@ (@/<= reference sample))))))) (context: "Arithmetic." - (<| (times |100) + (<| (times 100) (do @ [sample (|> duration (:: @ map (@.frame @.day))) frame duration @@ -74,7 +74,7 @@ frame)))))))))) (context: "Codec" - (<| (times |100) + (<| (times 100) (do @ [sample duration #let [(^open "@/.") @.Equivalence diff --git a/stdlib/test/test/lux/time/instant.lux b/stdlib/test/test/lux/time/instant.lux index db4898e20..734456765 100644 --- a/stdlib/test/test/lux/time/instant.lux +++ b/stdlib/test/test/lux/time/instant.lux @@ -25,14 +25,14 @@ (|> r.int (:: r.Monad map (|>> (i/% boundary) @.from-millis)))) (context: "Conversion." - (<| (times |100) + (<| (times 100) (do @ [millis r.int] (test "Can convert from/to milliseconds." (|> millis @.from-millis @.to-millis (i/= millis)))))) (context: "Equivalence." - (<| (times |100) + (<| (times 100) (do @ [sample instant #let [(^open "@/.") @.Equivalence]] @@ -40,7 +40,7 @@ (@/= sample sample))))) (context: "Order" - (<| (times |100) + (<| (times 100) (do @ [reference instant sample instant @@ -52,7 +52,7 @@ (@/<= reference sample))))))) (context: "Enum" - (<| (times |100) + (<| (times 100) (do @ [sample instant #let [(^open "@/.") @.Enum]] @@ -65,7 +65,7 @@ (|> sample @/pred @/succ (@/= sample))))))) (context: "Arithmetic" - (<| (times |100) + (<| (times 100) (do @ [sample instant span _duration.duration @@ -82,8 +82,8 @@ (|> @.epoch (@.shift (@.relative sample)) (@/= sample))))))) ## (context: "Codec" -## (<| (seed |9863552679229274604) -## ## (times |100) +## (<| (seed 9863552679229274604) +## ## (times 100) ## (do @ ## [sample instant ## #let [(^open "@/.") @.Equivalence diff --git a/stdlib/test/test/lux/type.lux b/stdlib/test/test/lux/type.lux index cd335e420..e8de83c56 100644 --- a/stdlib/test/test/lux/type.lux +++ b/stdlib/test/test/lux/type.lux @@ -18,7 +18,7 @@ (def: #export gen-short (r.Random Text) (do r.Monad - [size (|> r.nat (:: @ map (n/% |10)))] + [size (|> r.nat (:: @ map (n/% 10)))] (r.unicode size))) (def: #export gen-name @@ -48,7 +48,7 @@ ## [Tests] (context: "Types" - (<| (times |100) + (<| (times 100) (do @ [sample gen-type] (test "Every type is equal to itself." @@ -84,9 +84,9 @@ (&.un-name aliased))))))) (context: "Type construction [structs]" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (n/% |3))) + [size (|> r.nat (:: @ map (n/% 3))) members (|> gen-type (r.filter (function (_ type) (case type @@ -115,9 +115,9 @@ ))))) (context: "Type construction [parameterized]" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (n/% |3))) + [size (|> r.nat (:: @ map (n/% 3))) members (M.seq @ (list.repeat size gen-type)) extra (|> gen-type (r.filter (function (_ type) @@ -141,9 +141,9 @@ )))) (context: "Type construction [higher order]" - (<| (times |100) + (<| (times 100) (do @ - [size (|> r.nat (:: @ map (n/% |3))) + [size (|> r.nat (:: @ map (n/% 3))) extra (|> gen-type (r.filter (function (_ type) (case type diff --git a/stdlib/test/test/lux/type/check.lux b/stdlib/test/test/lux/type/check.lux index 1ea83a10e..c5700f8cb 100644 --- a/stdlib/test/test/lux/type/check.lux +++ b/stdlib/test/test/lux/type/check.lux @@ -50,7 +50,7 @@ ## [Tests] (context: "Any and Nothing." - (<| (times |100) + (<| (times 100) (do @ [sample (|> //.gen-type (r.filter valid-type?))] ($_ seq @@ -98,7 +98,7 @@ )) (context: "Type application." - (<| (times |100) + (<| (times 100) (do @ [meta //.gen-type data //.gen-type] @@ -109,7 +109,7 @@ (|> Ann (#.Apply meta) (#.Apply data)))))))) (context: "Primitive types." - (<| (times |100) + (<| (times 100) (do @ [nameL //.gen-short nameR (|> //.gen-short (r.filter (|>> (text/= nameL) not))) @@ -177,9 +177,9 @@ (wrap [[head-id head-type] ids+types [tail-id tail-type]]))) (context: "Rings of type variables." - (<| (times |100) + (<| (times 100) (do @ - [num-connections (|> r.nat (:: @ map (n/% |100))) + [num-connections (|> r.nat (:: @ map (n/% 100))) boundT (|> //.gen-type (r.filter (|>> (case> (#.Var _) #0 _ #1)))) pick-pcg (r.and r.nat r.nat)] ($_ seq @@ -227,7 +227,7 @@ headRR-post (@.ring head-idR)] (@.assert "" (let [same-rings? (:: set.Equivalence = headRL-post headRR-post) - expected-size? (n/= (n/* |2 (inc num-connections)) + expected-size? (n/= (n/* 2 (inc num-connections)) (set.size headRL-post)) union? (:: set.Equivalence = headRL-post (set.union headRL-pre headRR-pre))] (and same-rings? diff --git a/stdlib/test/test/lux/type/implicit.lux b/stdlib/test/test/lux/type/implicit.lux index daf259609..669d720c2 100644 --- a/stdlib/test/test/lux/type/implicit.lux +++ b/stdlib/test/test/lux/type/implicit.lux @@ -15,7 +15,7 @@ lux/test) (context: "Automatic structure selection" - (<| (times |100) + (<| (times 100) (do @ [x r.nat y r.nat] @@ -24,17 +24,17 @@ (let [(^open "list/.") (list.Equivalence number.Equivalence)] (and (bit/= (:: number.Equivalence = x y) (::: = x y)) - (list/= (list.n/range |1 |10) - (::: map inc (list.n/range |0 |9))) + (list/= (list.n/range 1 10) + (::: map inc (list.n/range 0 9))) ))) (test "Can automatically select second-order structures." (::: = - (list.n/range |1 |10) - (list.n/range |1 |10))) + (list.n/range 1 10) + (list.n/range 1 10))) (test "Can automatically select third-order structures." - (let [lln (::: map (list.n/range |1) - (list.n/range |1 |10))] + (let [lln (::: map (list.n/range 1) + (list.n/range 1 10))] (::: = lln lln))) )))) diff --git a/stdlib/test/test/lux/type/resource.lux b/stdlib/test/test/lux/type/resource.lux index b3eabd995..cf6d49b17 100644 --- a/stdlib/test/test/lux/type/resource.lux +++ b/stdlib/test/test/lux/type/resource.lux @@ -11,37 +11,37 @@ (context: "Sub-structural typing." ($_ seq (test "Can produce and consume keys in an ordered manner." - (<| (n/= (n/+ |123 |456)) + (<| (n/= (n/+ 123 456)) io.run resource.run-sync (do resource.IxMonad - [res|left (resource.ordered-sync |123) - res|right (resource.ordered-sync |456) + [res|left (resource.ordered-sync 123) + res|right (resource.ordered-sync 456) right (resource.read-sync res|right) left (resource.read-sync res|left)] (wrap (n/+ left right))))) (test "Can exchange commutative keys." - (<| (n/= (n/+ |123 |456)) + (<| (n/= (n/+ 123 456)) io.run resource.run-sync (do resource.IxMonad - [res|left (resource.commutative-sync |123) - res|right (resource.commutative-sync |456) - _ (resource.exchange-sync [|1 |0]) + [res|left (resource.commutative-sync 123) + res|right (resource.commutative-sync 456) + _ (resource.exchange-sync [1 0]) left (resource.read-sync res|left) right (resource.read-sync res|right)] (wrap (n/+ left right))))) (test "Can group and un-group keys." - (<| (n/= (n/+ |123 |456)) + (<| (n/= (n/+ 123 456)) io.run resource.run-sync (do resource.IxMonad - [res|left (resource.commutative-sync |123) - res|right (resource.commutative-sync |456) - _ (resource.group-sync |2) - _ (resource.un-group-sync |2) + [res|left (resource.commutative-sync 123) + res|right (resource.commutative-sync 456) + _ (resource.group-sync 2) + _ (resource.un-group-sync 2) right (resource.read-sync res|right) left (resource.read-sync res|left)] (wrap (n/+ left right))))) diff --git a/stdlib/test/test/lux/world/binary.lux b/stdlib/test/test/lux/world/binary.lux index b5b625f50..a6a6df9d6 100644 --- a/stdlib/test/test/lux/world/binary.lux +++ b/stdlib/test/test/lux/world/binary.lux @@ -30,7 +30,7 @@ (def: #export (binary size) (-> Nat (r.Random /.Binary)) (let [output (/.create size)] - (loop [idx |0] + (loop [idx 0] (if (n/< size idx) (do r.Monad [byte r.nat] @@ -40,19 +40,19 @@ (def: (bits-io bytes read write value) (-> Nat (-> Nat /.Binary (e.Error Nat)) (-> Nat Nat /.Binary (e.Error Any)) Nat Bit) - (let [binary (/.create |8) - bits (n/* |8 bytes) - capped-value (|> |1 (i64.left-shift bits) dec (i64.and value))] + (let [binary (/.create 8) + bits (n/* 8 bytes) + capped-value (|> 1 (i64.left-shift bits) dec (i64.and value))] (succeed (do e.Monad - [_ (write |0 value binary) - output (read |0 binary)] + [_ (write 0 value binary) + output (read 0 binary)] (wrap (n/= capped-value output)))))) (context: "Binary." - (<| (times |100) + (<| (times 100) (do @ - [#let [gen-size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |8))))] + [#let [gen-size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 8))))] binary-size gen-size random-binary (binary binary-size) value r.nat @@ -65,17 +65,17 @@ (test "Can get size of binary." (|> random-binary /.size (n/= binary-size))) (test "Can read/write 8-bit values." - (bits-io |1 /.read/8 /.write/8 value)) + (bits-io 1 /.read/8 /.write/8 value)) (test "Can read/write 16-bit values." - (bits-io |2 /.read/16 /.write/16 value)) + (bits-io 2 /.read/16 /.write/16 value)) (test "Can read/write 32-bit values." - (bits-io |4 /.read/32 /.write/32 value)) + (bits-io 4 /.read/32 /.write/32 value)) (test "Can read/write 64-bit values." - (bits-io |8 /.read/64 /.write/64 value)) + (bits-io 8 /.read/64 /.write/64 value)) (test "Can slice binaries." (let [slice-size (|> to (n/- from) inc) random-slice (e.assume (/.slice from to random-binary)) - idxs (list.n/range |0 (dec slice-size)) + idxs (list.n/range 0 (dec slice-size)) reader (function (_ binary idx) (/.read/8 idx binary))] (and (n/= slice-size (/.size random-slice)) (case [(monad.map e.Monad (reader random-slice) idxs) diff --git a/stdlib/test/test/lux/world/file.lux b/stdlib/test/test/lux/world/file.lux index 857b6afb5..b9bd2457a 100644 --- a/stdlib/test/test/lux/world/file.lux +++ b/stdlib/test/test/lux/world/file.lux @@ -27,7 +27,7 @@ (context: "File system." (do @ - [file-size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) + [file-size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10)))) dataL (_binary.binary file-size) dataR (_binary.binary file-size) code r.nat @@ -37,7 +37,7 @@ instant.absolute)))] ($_ seq (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ |0 code)))] + [#let [file (format "temp_file_" (%n (n/+ 0 code)))] result (promise.future (do (:: @.JVM@System &monad) [pre! (@.exists? @.JVM@System file) @@ -50,7 +50,7 @@ (assert "Can create/delete files." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ |1 code)))] + [#let [file (format "temp_file_" (%n (n/+ 1 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System write dataL file) @@ -60,7 +60,7 @@ (assert "Can write/read files." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ |2 code)))] + [#let [file (format "temp_file_" (%n (n/+ 2 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System write dataL file) @@ -70,7 +70,7 @@ (assert "Can read file size." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ |3 code)))] + [#let [file (format "temp_file_" (%n (n/+ 3 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System write dataL file) @@ -78,13 +78,13 @@ output (:: @.JVM@System read file) read-size (:: @.JVM@System size file) _ (:: @.JVM@System delete file)] - (wrap (and (n/= (n/* |2 file-size) read-size) - (:: binary.Equivalence = dataL (error.assume (binary.slice |0 (dec file-size) output))) + (wrap (and (n/= (n/* 2 file-size) read-size) + (:: binary.Equivalence = dataL (error.assume (binary.slice 0 (dec file-size) output))) (:: binary.Equivalence = dataR (error.assume (binary.slice file-size (dec read-size) output)))))))] (assert "Can append to files." (error.default #0 result)))) (wrap (do promise.Monad - [#let [dir (format "temp_dir_" (%n (n/+ |4 code)))] + [#let [dir (format "temp_dir_" (%n (n/+ 4 code)))] result (promise.future (do (:: @.JVM@System &monad) [pre! (@.exists? @.JVM@System dir) @@ -97,8 +97,8 @@ (assert "Can create/delete directories." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ |5 code))) - dir (format "temp_dir_" (%n (n/+ |5 code)))] + [#let [file (format "temp_file_" (%n (n/+ 5 code))) + dir (format "temp_dir_" (%n (n/+ 5 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System write dataL file) @@ -114,8 +114,8 @@ (assert "Can differentiate files from directories." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ |6 code))) - dir (format "temp_dir_" (%n (n/+ |6 code)))] + [#let [file (format "temp_file_" (%n (n/+ 6 code))) + dir (format "temp_dir_" (%n (n/+ 6 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System make-directory dir) @@ -128,8 +128,8 @@ (assert "Can create files inside of directories." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ |7 code))) - dir (format "temp_dir_" (%n (n/+ |7 code)))] + [#let [file (format "temp_file_" (%n (n/+ 7 code))) + dir (format "temp_dir_" (%n (n/+ 7 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System make-directory dir) @@ -147,7 +147,7 @@ (assert "Can list files inside a directory." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file (format "temp_file_" (%n (n/+ |8 code)))] + [#let [file (format "temp_file_" (%n (n/+ 8 code)))] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System write dataL file) @@ -158,8 +158,8 @@ (assert "Can change the time of last modification." (error.default #0 result)))) (wrap (do promise.Monad - [#let [file0 (format "temp_file_" (%n (n/+ |9 code)) "+0") - file1 (format "temp_file_" (%n (n/+ |9 code)) "+1")] + [#let [file0 (format "temp_file_" (%n (n/+ 9 code)) "+0") + file1 (format "temp_file_" (%n (n/+ 9 code)) "+1")] result (promise.future (do (:: @.JVM@System &monad) [_ (:: @.JVM@System write dataL file0) diff --git a/stdlib/test/test/lux/world/net/tcp.lux b/stdlib/test/test/lux/world/net/tcp.lux index fb2ea3649..7520a2fbc 100644 --- a/stdlib/test/test/lux/world/net/tcp.lux +++ b/stdlib/test/test/lux/world/net/tcp.lux @@ -27,13 +27,13 @@ (r.Random net.Port) (|> r.nat (:: r.Monad map - (|>> (n/% |1000) - (n/+ |8000))))) + (|>> (n/% 1000) + (n/+ 8000))))) (context: "TCP networking." (do @ [port ..port - size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) + size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10)))) from (_binary.binary size) to (_binary.binary size) #let [temp-from (binary.create size) @@ -46,18 +46,18 @@ (P.promise #.Nil)) _ (frp/map (function (_ socket) (do @ - [bytes-from (@.read temp-from |0 size socket) + [bytes-from (@.read temp-from 0 size socket) #let [_ (io.run (P.resolve (#E.Success (and (n/= size bytes-from) (:: binary.Equivalence = from temp-from))) from-worked?))]] - (@.write to |0 size socket))) + (@.write to 0 size socket))) server)] client (@.client localhost port) - _ (@.write from |0 size client) + _ (@.write from 0 size client) from-worked? from-worked? #################### - bytes-to (@.read temp-to |0 size client) + bytes-to (@.read temp-to 0 size client) #let [to-worked? (and (n/= size bytes-to) (:: binary.Equivalence = to temp-to))] #################### diff --git a/stdlib/test/test/lux/world/net/udp.lux b/stdlib/test/test/lux/world/net/udp.lux index 8365452a1..497cef8f3 100644 --- a/stdlib/test/test/lux/world/net/udp.lux +++ b/stdlib/test/test/lux/world/net/udp.lux @@ -24,13 +24,13 @@ (r.Random net.Port) (|> r.nat (:: r.Monad map - (|>> (n/% |1000) - (n/+ |8000))))) + (|>> (n/% 1000) + (n/+ 8000))))) (context: "UDP networking." (do @ [port ..port - size (|> r.nat (:: @ map (|>> (n/% |100) (n/max |10)))) + size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10)))) from (_binary.binary size) to (_binary.binary size) #let [temp (binary.create size)]] @@ -40,13 +40,13 @@ [server (@.server port) client (@.client []) #################### - _ (@.write localhost port from |0 size client) - [bytes-from from-address from-port] (@.read temp |0 size server) + _ (@.write localhost port from 0 size client) + [bytes-from from-address from-port] (@.read temp 0 size server) #let [from-worked? (and (n/= size bytes-from) (:: binary.Equivalence = from temp))] #################### - _ (@.write from-address from-port to |0 size server) - [bytes-to to-address to-port] (@.read temp |0 size client) + _ (@.write from-address from-port to 0 size server) + [bytes-to to-address to-port] (@.read temp 0 size client) #let [to-worked? (and (n/= size bytes-to) (:: binary.Equivalence = to temp) (n/= port to-port))] -- cgit v1.2.3 From 395f3bf37ab370c985bd253ee32ea242d2ebedad Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 28 Jul 2018 15:39:32 -0400 Subject: Adjusted lux-mode to the latest syntactic changes. --- lux-mode/lux-mode.el | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/lux-mode/lux-mode.el b/lux-mode/lux-mode.el index 7d717d5b2..3b97d4718 100644 --- a/lux-mode/lux-mode.el +++ b/lux-mode/lux-mode.el @@ -211,23 +211,30 @@ Called by `imenu--generic-function'." (defun altRE (&rest alternatives) (concat "\\(" (mapconcat 'identity alternatives "\\|") "\\)")) +(defun literal (content) + (concat "\\<" content "\\>")) + +(defun special (normal) + (concat "#" normal)) + (defconst lux-font-lock-keywords - (let ((digits "[0-9][0-9_]*") - (digits+ "[0-9_]+") + (let ((natural "[0-9][0-9_]*") (identifier_h "[a-zA-Z-\\+_=!@\\$%\\^&\\*<>;,/\\\\\\|':~\\?]") - (identifier_t "[a-zA-Z0-9-\\+_=!@\\$%\\^&\\*<>;,/\\\\\\|':~\\?]")) - (let ((identifier (concat identifier_h identifier_t "*"))) - (let ((bitRE (concat "\\<" (regexp-opt '("#0" "#1") t) "\\>")) - (natRE (concat "\\<\\+" digits "\\>")) - (int&fracRE (concat "\\<-?" digits "\\(\\." digits+ "\\(\\(e\\|E\\)\\(-\\|\\+\\)?" digits "\\)?\\)?\\>")) - (frac-ratioRE (concat "\\<-?" digits "/" digits "\\>")) - (revRE (concat "\\<\\." digits "\\>")) + (identifier_t "[a-zA-Z0-9-\\+_=!@\\$%\\^&\\*<>;,/\\\\\\|':~\\?]") + (sign (altRE "-" "\\+"))) + (let ((identifier (concat identifier_h identifier_t "*")) + (integer (concat sign natural))) + (let ((bitRE (literal (special (altRE "0" "1")))) + (natRE (literal natural)) + (int&fracRE (literal (concat integer "\\(\\." natural "\\(\\(e\\|E\\)" integer "\\)?\\)?"))) + (frac-ratioRE (literal (concat integer "/" natural))) + (revRE (literal (concat "\\." natural))) (tagRE (let ((separator "\\.")) (let ((in-prelude separator) (in-current-module (concat separator separator)) (in-module (concat identifier separator)) (in-local "")) - (concat "#" (altRE in-prelude in-current-module in-module in-local) identifier))))) + (special (concat (altRE in-prelude in-current-module in-module in-local) identifier)))))) (eval-when-compile `(;; Special forms (,(let (;; Control -- cgit v1.2.3 From 168d36d07b48d2d936de24aa69b8464e68992075 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 28 Jul 2018 15:51:48 -0400 Subject: Covered some missing bits. --- stdlib/source/lux.lux | 2 +- stdlib/source/lux/compiler/default/syntax.lux | 14 +++++++------- stdlib/source/lux/data/collection/list.lux | 2 +- stdlib/test/test/lux/data/number.lux | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 109a590e3..34ceb43ba 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -2560,7 +2560,7 @@ (let' [loop ("lux check" (-> Nat Text Text) (function' recur [input output] (if (n/= 0 input) - (text/compose "|" output) + output (recur (n// 10 input) (text/compose (|> input (n/% 10) digit-to-text) output)))))] diff --git a/stdlib/source/lux/compiler/default/syntax.lux b/stdlib/source/lux/compiler/default/syntax.lux index 0497f55a2..5b20dcff5 100644 --- a/stdlib/source/lux/compiler/default/syntax.lux +++ b/stdlib/source/lux/compiler/default/syntax.lux @@ -184,7 +184,7 @@ "u" (do p.Monad [code (l.between 1 4 l.hexadecimal)] - (wrap (case (|> code (format "+") (:: number.Hex@Codec decode)) + (wrap (case (:: number.Hex@Codec decode code) (#.Right value) [(n/+ 2 (text.size code)) (text.from-code value)] @@ -207,6 +207,8 @@ (l.and l.decimal (l.some rich-digit))) +(def: sign^ (l.one-of "+-")) + (do-template [ ] [(def: #export ( where) (-> Cursor (l.Lexer [Cursor Code])) @@ -221,8 +223,7 @@ [where ( value)]]))))] [int #.Int - (l.and (p.default "" (l.one-of "-")) - rich-digits^) + (l.and sign^ rich-digits^) number.Codec] [rev #.Rev @@ -259,8 +260,7 @@ (def: (normal-nat where) (-> Cursor (l.Lexer [Cursor Code])) (do p.Monad - [chunk (l.and (l.one-of "+") - rich-digits^)] + [chunk rich-digits^] (case (:: number.Codec decode chunk) (#.Left error) (p.fail error) @@ -278,14 +278,14 @@ (-> Cursor (l.Lexer [Cursor Code])) (do p.Monad [chunk ($_ l.and - (p.default "" (l.one-of "-")) + sign^ rich-digits^ (l.one-of ".") rich-digits^ (p.default "" ($_ l.and (l.one-of "eE") - (p.default "" (l.one-of "+-")) + sign^ rich-digits^)))] (case (:: number.Codec decode chunk) (#.Left error) diff --git a/stdlib/source/lux/data/collection/list.lux b/stdlib/source/lux/data/collection/list.lux index 09328def9..bbc649fb9 100644 --- a/stdlib/source/lux/data/collection/list.lux +++ b/stdlib/source/lux/data/collection/list.lux @@ -403,7 +403,7 @@ output' ("lux text concat" digit output) input' (n// 10 input)] (if (n/= 0 input') - ("lux text concat" "+" output') + output' (recur input' output'))))) (macro: #export (zip tokens state) diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux index 36bc9a3f9..b5cf8e414 100644 --- a/stdlib/test/test/lux/data/number.lux +++ b/stdlib/test/test/lux/data/number.lux @@ -179,7 +179,7 @@ (r/= (oct ".615243") (oct ".615_243")) (f/= (oct "+6152.43") (oct "+615_2.43")))) (test "Hexadecimal." - (and (n/= (hex "|deadBEEF") (hex "|dead_BEEF")) - (i/= (hex "deadBEEF") (hex "dead_BEEF")) + (and (n/= (hex "deadBEEF") (hex "dead_BEEF")) + (i/= (hex "+deadBEEF") (hex "+dead_BEEF")) (r/= (hex ".deadBEEF") (hex ".dead_BEEF")) - (f/= (hex "deadBE.EF") (hex "dead_BE.EF")))))) + (f/= (hex "+deadBE.EF") (hex "+dead_BE.EF")))))) -- cgit v1.2.3