From 69fefab57c40f323d759dc444dbcebad15071585 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Fri, 13 Jul 2018 22:01:32 -0400 Subject: Re-named "Bool" type to "Bit". --- stdlib/source/lux.lux | 188 ++++++++++----------- stdlib/source/lux/concurrency/actor.lux | 6 +- stdlib/source/lux/concurrency/atom.lux | 2 +- stdlib/source/lux/concurrency/frp.lux | 2 +- stdlib/source/lux/concurrency/promise.lux | 4 +- stdlib/source/lux/concurrency/semaphore.lux | 2 +- stdlib/source/lux/concurrency/stm.lux | 4 +- stdlib/source/lux/control/concatenative.lux | 54 +++--- stdlib/source/lux/control/contract.lux | 2 +- stdlib/source/lux/control/enum.lux | 2 +- stdlib/source/lux/control/equivalence.lux | 2 +- stdlib/source/lux/control/exception.lux | 4 +- stdlib/source/lux/control/interval.lux | 24 +-- stdlib/source/lux/control/order.lux | 4 +- stdlib/source/lux/control/parser.lux | 4 +- stdlib/source/lux/control/predicate.lux | 2 +- stdlib/source/lux/control/state.lux | 4 +- stdlib/source/lux/data/bit.lux | 51 ++++++ stdlib/source/lux/data/bool.lux | 51 ------ stdlib/source/lux/data/collection/array.lux | 6 +- stdlib/source/lux/data/collection/bits.lux | 6 +- stdlib/source/lux/data/collection/dictionary.lux | 10 +- .../lux/data/collection/dictionary/ordered.lux | 2 +- .../lux/data/collection/dictionary/plist.lux | 2 +- stdlib/source/lux/data/collection/list.lux | 22 +-- stdlib/source/lux/data/collection/queue.lux | 4 +- .../source/lux/data/collection/queue/priority.lux | 2 +- stdlib/source/lux/data/collection/row.lux | 4 +- stdlib/source/lux/data/collection/sequence.lux | 10 +- stdlib/source/lux/data/collection/set.lux | 8 +- stdlib/source/lux/data/collection/set/multi.lux | 8 +- stdlib/source/lux/data/collection/set/ordered.lux | 6 +- stdlib/source/lux/data/collection/stack.lux | 2 +- stdlib/source/lux/data/collection/tree/finger.lux | 4 +- .../lux/data/collection/tree/rose/zipper.lux | 8 +- stdlib/source/lux/data/format/binary.lux | 12 +- stdlib/source/lux/data/format/json.lux | 28 +-- stdlib/source/lux/data/number.lux | 10 +- stdlib/source/lux/data/number/complex.lux | 2 +- stdlib/source/lux/data/number/i64.lux | 2 +- stdlib/source/lux/data/number/ratio.lux | 4 +- stdlib/source/lux/data/tainted.lux | 2 +- stdlib/source/lux/data/text.lux | 10 +- stdlib/source/lux/data/text/format.lux | 4 +- stdlib/source/lux/data/text/lexer.lux | 6 +- stdlib/source/lux/data/text/regex.lux | 4 +- stdlib/source/lux/data/text/unicode.lux | 2 +- stdlib/source/lux/host.js.lux | 2 +- stdlib/source/lux/host.jvm.lux | 66 ++++---- stdlib/source/lux/language/compiler/analysis.lux | 10 +- .../source/lux/language/compiler/analysis/case.lux | 2 +- .../language/compiler/analysis/case/coverage.lux | 26 +-- .../lux/language/compiler/analysis/expression.lux | 2 +- .../lux/language/compiler/analysis/module.lux | 10 +- .../lux/language/compiler/analysis/primitive.lux | 2 +- .../lux/language/compiler/analysis/scope.lux | 6 +- .../lux/language/compiler/default/repl/type.lux | 2 +- .../compiler/extension/analysis/common.lux | 16 +- .../compiler/extension/analysis/host.jvm.lux | 28 +-- stdlib/source/lux/language/compiler/meta/cache.lux | 6 +- stdlib/source/lux/language/compiler/synthesis.lux | 10 +- .../lux/language/compiler/synthesis/case.lux | 14 +- .../lux/language/compiler/synthesis/expression.lux | 2 +- .../lux/language/compiler/synthesis/function.lux | 4 +- .../lux/language/compiler/synthesis/loop.lux | 8 +- .../compiler/translation/scheme/case.jvm.lux | 4 +- .../compiler/translation/scheme/expression.jvm.lux | 2 +- .../compiler/translation/scheme/primitive.jvm.lux | 4 +- .../compiler/translation/scheme/runtime.jvm.lux | 2 +- stdlib/source/lux/language/host/scheme.lux | 2 +- stdlib/source/lux/language/reference.lux | 2 +- stdlib/source/lux/language/syntax.lux | 8 +- stdlib/source/lux/language/type.lux | 2 +- stdlib/source/lux/language/type/check.lux | 12 +- stdlib/source/lux/macro.lux | 22 +-- stdlib/source/lux/macro/code.lux | 39 ++--- stdlib/source/lux/macro/poly.lux | 4 +- stdlib/source/lux/macro/poly/equivalence.lux | 4 +- stdlib/source/lux/macro/poly/json.lux | 14 +- stdlib/source/lux/macro/syntax.lux | 10 +- stdlib/source/lux/macro/syntax/common/reader.lux | 2 +- stdlib/source/lux/macro/syntax/common/writer.lux | 2 +- stdlib/source/lux/math.lux | 2 +- stdlib/source/lux/math/modular.lux | 4 +- stdlib/source/lux/math/random.lux | 12 +- stdlib/source/lux/test.lux | 6 +- stdlib/source/lux/time/date.lux | 6 +- stdlib/source/lux/time/duration.lux | 2 +- stdlib/source/lux/time/instant.lux | 4 +- stdlib/source/lux/type/implicit.lux | 3 +- stdlib/source/lux/type/object/interface.lux | 10 +- stdlib/source/lux/type/object/protocol.lux | 6 +- stdlib/source/lux/world/file.lux | 6 +- stdlib/test/test/lux/concurrency/promise.lux | 2 +- stdlib/test/test/lux/control/exception.lux | 6 +- stdlib/test/test/lux/control/parser.lux | 16 +- stdlib/test/test/lux/control/region.lux | 2 +- stdlib/test/test/lux/control/state.lux | 2 +- stdlib/test/test/lux/data/bit.lux | 38 +++++ stdlib/test/test/lux/data/bool.lux | 38 ----- stdlib/test/test/lux/data/collection/list.lux | 14 +- stdlib/test/test/lux/data/format/json.lux | 22 +-- stdlib/test/test/lux/data/number/complex.lux | 4 +- stdlib/test/test/lux/data/number/i64.lux | 2 +- stdlib/test/test/lux/data/text/lexer.lux | 8 +- stdlib/test/test/lux/data/text/regex.lux | 6 +- .../test/lux/language/compiler/analysis/case.lux | 4 +- .../lux/language/compiler/analysis/function.lux | 2 +- .../lux/language/compiler/analysis/primitive.lux | 4 +- .../compiler/analysis/procedure/common.lux | 20 +-- .../lux/language/compiler/analysis/reference.lux | 4 +- .../lux/language/compiler/analysis/structure.lux | 16 +- .../test/lux/language/compiler/synthesis/case.lux | 6 +- .../lux/language/compiler/synthesis/function.lux | 6 +- .../lux/language/compiler/synthesis/primitive.lux | 12 +- .../lux/language/compiler/synthesis/structure.lux | 4 +- stdlib/test/test/lux/language/syntax.lux | 4 +- stdlib/test/test/lux/language/type.lux | 8 +- stdlib/test/test/lux/language/type/check.lux | 10 +- stdlib/test/test/lux/macro/code.lux | 24 +-- stdlib/test/test/lux/macro/poly/equivalence.lux | 10 +- stdlib/test/test/lux/macro/syntax.lux | 44 ++--- stdlib/test/test/lux/math.lux | 22 +-- stdlib/test/test/lux/math/logic/fuzzy.lux | 56 +++--- stdlib/test/test/lux/math/modular.lux | 34 ++-- stdlib/test/test/lux/type/implicit.lux | 6 +- stdlib/test/test/lux/type/object/protocol.lux | 6 +- stdlib/test/test/lux/world/blob.lux | 4 +- stdlib/test/test/lux/world/net/tcp.lux | 2 +- 129 files changed, 744 insertions(+), 738 deletions(-) create mode 100644 stdlib/source/lux/data/bit.lux delete mode 100644 stdlib/source/lux/data/bool.lux create mode 100644 stdlib/test/test/lux/data/bit.lux delete mode 100644 stdlib/test/test/lux/data/bool.lux (limited to 'stdlib') diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index ecf5584d6..2f2649758 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -65,16 +65,16 @@ [dummy-cursor (+5 "A potentially empty list of values.")]] (+0)))))))]) -("lux def" Bool - (+10 ["lux" "Bool"] - (+0 "#Bool" #Nil)) +("lux def" Bit + (+10 ["lux" "Bit"] + (+0 "#Bit" #Nil)) [dummy-cursor (+10 (#Cons [[dummy-cursor (+7 ["lux" "type?"])] [dummy-cursor (+0 true)]] (#Cons [[dummy-cursor (+7 ["lux" "export?"])] [dummy-cursor (+0 true)]] (#Cons [[dummy-cursor (+7 ["lux" "doc"])] - [dummy-cursor (+5 "Your standard, run-of-the-mill boolean values.")]] + [dummy-cursor (+5 "Your standard, run-of-the-mill boolean values (as bits).")]] #Nil))))]) ("lux def" I64 @@ -306,7 +306,7 @@ #Nil))))))]) ## (type: (Code' w) -## (#Bool Bool) +## (#Bit Bit) ## (#Nat Nat) ## (#Int Int) ## (#Rev Rev) @@ -322,8 +322,8 @@ ({Code ({Code-List (#UnivQ #Nil - (#Sum ## "lux.Bool" - Bool + (#Sum ## "lux.Bit" + Bit (#Sum ## "lux.Nat" Nat (#Sum ## "lux.Int" @@ -352,7 +352,7 @@ (#Parameter +1))))) [dummy-cursor (+10 (#Cons [[dummy-cursor (+7 ["lux" "tags"])] - [dummy-cursor (+9 (#Cons [dummy-cursor (+5 "Bool")] + [dummy-cursor (+9 (#Cons [dummy-cursor (+5 "Bit")] (#Cons [dummy-cursor (+5 "Nat")] (#Cons [dummy-cursor (+5 "Int")] (#Cons [dummy-cursor (+5 "Rev")] @@ -383,9 +383,9 @@ (#Record (#Cons [[dummy-cursor (#Tag ["lux" "doc"])] [dummy-cursor (#Text "The type of Code nodes for Lux syntax.")]] (#Cons [[dummy-cursor (#Tag ["lux" "type?"])] - [dummy-cursor (#Bool true)]] + [dummy-cursor (#Bit true)]] (#Cons [[dummy-cursor (#Tag ["lux" "export?"])] - [dummy-cursor (#Bool true)]] + [dummy-cursor (#Bit true)]] #Nil))))]) ("lux def" _ann @@ -396,9 +396,9 @@ [dummy-cursor data])) [dummy-cursor (#Record #Nil)]) -("lux def" bool$ - ("lux check" (#Function Bool Code) - ([_ value] (_ann (#Bool value)))) +("lux def" bit$ + ("lux check" (#Function Bit Code) + ([_ value] (_ann (#Bit value)))) [dummy-cursor (#Record #Nil)]) ("lux def" nat$ @@ -459,16 +459,16 @@ ("lux def" default-def-meta-exported ("lux check" (#Apply (#Product Code Code) List) (#Cons [(tag$ ["lux" "type?"]) - (bool$ true)] + (bit$ true)] (#Cons [(tag$ ["lux" "export?"]) - (bool$ true)] + (bit$ true)] #Nil))) (record$ #Nil)) ("lux def" default-def-meta-unexported ("lux check" (#Apply (#Product Code Code) List) (#Cons [(tag$ ["lux" "type?"]) - (bool$ true)] + (bit$ true)] #Nil)) (record$ #Nil)) @@ -585,8 +585,8 @@ ## #module-aliases (List [Text Text]) ## #definitions (List [Text Definition]) ## #imports (List Text) -## #tags (List [Text [Nat (List Ident) Bool Type]]) -## #types (List [Text [(List Ident) Bool Type]]) +## #tags (List [Text [Nat (List Ident) Bit Type]]) +## #types (List [Text [(List Ident) Bit Type]]) ## #module-annotations (Maybe Code) ## #module-state Module-State}) ("lux def" Module @@ -603,13 +603,13 @@ (#Apply (#Product Text (#Product Nat (#Product (#Apply Ident List) - (#Product Bool + (#Product Bit Type)))) List) (#Product ## "lux.types" (#Apply (#Product Text (#Product (#Apply Ident List) - (#Product Bool + (#Product Bit Type))) List) (#Product ## "lux.module-annotations" @@ -808,7 +808,7 @@ ("lux def" default-macro-meta ("lux check" (#Apply (#Product Code Code) List) (#Cons [(tag$ ["lux" "macro?"]) - (bool$ true)] + (bit$ true)] #Nil)) (record$ #Nil)) @@ -878,13 +878,13 @@ ("lux check" (#Function Text Code) ([_ tag] (tuple$ (#Cons [(meta-code ["lux" "Tag"] (tuple$ (#Cons (text$ "lux") (#Cons (text$ tag) #Nil)))) - (#Cons [(meta-code ["lux" "Bool"] (bool$ true)) + (#Cons [(meta-code ["lux" "Bit"] (bit$ true)) #Nil])])))) (record$ #Nil)) ("lux def" export-meta ("lux check" (#Product Code Code) - [(tag$ ["lux" "export?"]) (bool$ true)]) + [(tag$ ["lux" "export?"]) (bit$ true)]) (record$ #Nil)) ("lux def" export?-meta @@ -1080,7 +1080,7 @@ (def:'' (text/= x y) #Nil - (#Function Text (#Function Text Bool)) + (#Function Text (#Function Text Bit)) ("lux text =" x y)) (def:'' (get-rep key env) @@ -1369,7 +1369,7 @@ (macro:' #export (& tokens) (#Cons [(tag$ ["lux" "doc"]) (text$ "## Tuple types: - (& Text Int Bool) + (& Text Int Bit) ## Any. (&)")] @@ -1386,7 +1386,7 @@ (macro:' #export (| tokens) (#Cons [(tag$ ["lux" "doc"]) (text$ "## Variant types: - (| Text Int Bool) + (| Text Int Bit) ## Nothing. (|)")] @@ -1506,7 +1506,7 @@ (def:''' (any? p xs) #Nil (All [a] - (-> (-> a Bool) ($' List a) Bool)) + (-> (-> a Bit) ($' List a) Bit)) ({#Nil false @@ -1716,7 +1716,7 @@ (macro:' #export (if tokens) (list [(tag$ ["lux" "doc"]) - (text$ "Picks which expression to evaluate based on a boolean test value. + (text$ "Picks which expression to evaluate based on a bit test value. (if true \"Oh, yeah!\" @@ -1724,8 +1724,8 @@ => \"Oh, yeah!\"")]) ({(#Cons test (#Cons then (#Cons else #Nil))) - (return (list (form$ (list (record$ (list [(bool$ true) then] - [(bool$ false) else])) + (return (list (form$ (list (record$ (list [(bit$ true) then] + [(bit$ false) else])) test)))) _ @@ -1833,7 +1833,7 @@ (def:''' (splice replace? untemplate elems) #Nil - (-> Bool (-> Code ($' Meta Code)) ($' List Code) ($' Meta Code)) + (-> Bit (-> Code ($' Meta Code)) ($' List Code) ($' Meta Code)) ({true ({#Nil (return (tag$ ["lux" "Nil"])) @@ -1878,9 +1878,9 @@ (def:''' (untemplate replace? subst token) #Nil - (-> Bool Text Code ($' Meta Code)) - ({[_ [_ (#Bool value)]] - (return (wrap-meta (form$ (list (tag$ ["lux" "Bool"]) (bool$ value))))) + (-> Bit Text Code ($' Meta Code)) + ({[_ [_ (#Bit value)]] + (return (wrap-meta (form$ (list (tag$ ["lux" "Bit"]) (bit$ value))))) [_ [_ (#Nat value)]] (return (wrap-meta (form$ (list (tag$ ["lux" "Nat"]) (nat$ value))))) @@ -2188,13 +2188,13 @@ (def:''' (every? p xs) #Nil (All [a] - (-> (-> a Bool) ($' List a) Bool)) + (-> (-> a Bit) ($' List a) Bit)) (list/fold (function' [_2 _1] (if _1 (p _2) false)) true xs)) (def:''' #export (n/= test subject) (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) equivalence.")]) - (-> Nat Nat Bool) + (-> Nat Nat Bit) ("lux i64 =" test subject)) (def:''' (high-bits value) @@ -2217,7 +2217,7 @@ (def:''' #export (n/< test subject) (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) less-than.")]) - (-> Nat Nat Bool) + (-> Nat Nat Bit) (let' [testH (high-bits test) subjectH (high-bits subject)] (if ("lux int <" subjectH testH) @@ -2231,7 +2231,7 @@ (def:''' #export (n/<= test subject) (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) less-than-equal.")]) - (-> Nat Nat Bool) + (-> Nat Nat Bit) (if (n/< test subject) true ("lux i64 =" test subject))) @@ -2239,13 +2239,13 @@ (def:''' #export (n/> test subject) (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) greater-than.")]) - (-> Nat Nat Bool) + (-> Nat Nat Bit) (n/< subject test)) (def:''' #export (n/>= test subject) (list [(tag$ ["lux" "doc"]) (text$ "Nat(ural) greater-than-equal.")]) - (-> Nat Nat Bool) + (-> Nat Nat Bit) (if (n/< subject test) true ("lux i64 =" test subject))) @@ -2284,20 +2284,20 @@ (def:''' #export (r/= test subject) (list [(tag$ ["lux" "doc"]) (text$ "Rev(olution) equivalence.")]) - (-> Rev Rev Bool) + (-> Rev Rev Bit) ("lux i64 =" test subject)) (def:''' #export (r/< test subject) (list [(tag$ ["lux" "doc"]) (text$ "Rev(olution) less-than.")]) - (-> Rev Rev Bool) + (-> Rev Rev Bit) (n/< ("lux coerce" Nat test) ("lux coerce" Nat subject))) (def:''' #export (r/<= test subject) (list [(tag$ ["lux" "doc"]) (text$ "Rev(olution) less-than-equal.")]) - (-> Rev Rev Bool) + (-> Rev Rev Bit) (if (n/< ("lux coerce" Nat test) ("lux coerce" Nat subject)) true @@ -2306,13 +2306,13 @@ (def:''' #export (r/> test subject) (list [(tag$ ["lux" "doc"]) (text$ "Rev(olution) greater-than.")]) - (-> Rev Rev Bool) + (-> Rev Rev Bit) (r/< subject test)) (def:''' #export (r/>= test subject) (list [(tag$ ["lux" "doc"]) (text$ "Rev(olution) greater-than-equal.")]) - (-> Rev Rev Bool) + (-> Rev Rev Bit) (if (r/< subject test) true ("lux i64 =" test subject))) @@ -2323,19 +2323,19 @@ [(def:''' #export ( test subject) (list [(tag$ ["lux" "doc"]) (text$ )]) - (-> Bool) + (-> Bit) ( subject test)) (def:''' #export ( test subject) (list [(tag$ ["lux" "doc"]) (text$ <<-doc>)]) - (-> Bool) + (-> Bit) ( subject test)) (def:''' #export ( test subject) (list [(tag$ ["lux" "doc"]) (text$ <<=-doc>)]) - (-> Bool) + (-> Bit) (if ( subject test) true ( subject test))) @@ -2343,13 +2343,13 @@ (def:''' #export ( test subject) (list [(tag$ ["lux" "doc"]) (text$ <>-doc>)]) - (-> Bool) + (-> Bit) ( test subject)) (def:''' #export ( test subject) (list [(tag$ ["lux" "doc"]) (text$ <>=-doc>)]) - (-> Bool) + (-> Bit) (if ( test subject) true ( subject test)))] @@ -2536,9 +2536,9 @@ [f/max Frac f/> "Frac(tion) minimum."] ) -(def:''' (bool/encode x) +(def:''' (bit/encode x) #Nil - (-> Bool Text) + (-> Bit Text) (if x "true" "false")) (def:''' (digit-to-text digit) @@ -2600,17 +2600,17 @@ (def:''' (multiple? div n) #Nil - (-> Nat Nat Bool) + (-> Nat Nat Bit) (|> n (n/% div) (n/= +0))) (def:''' #export (not x) (list [(tag$ ["lux" "doc"]) - (text$ "## Boolean negation. + (text$ "## Bit negation. (not true) => false (not false) => true")]) - (-> Bool Bool) + (-> Bit Bit) (if x false true)) (def:''' (find-macro' modules current-module module name) @@ -2623,8 +2623,8 @@ gdef (let' [{#module-hash _ #module-aliases _ #definitions bindings #imports _ #tags tags #types types #module-annotations _ #module-state _} ("lux check" Module $module)] (get name bindings))] (let' [[def-type def-meta def-value] ("lux check" Definition gdef)] - ({(#Some [_ (#Bool true)]) - ({(#Some [_ (#Bool true)]) + ({(#Some [_ (#Bit true)]) + ({(#Some [_ (#Bit true)]) (#Some ("lux coerce" Macro def-value)) _ @@ -2672,7 +2672,7 @@ (def:''' (macro? ident) #Nil - (-> Ident ($' Meta Bool)) + (-> Ident ($' Meta Bit)) (do Monad [ident (normalize ident) output (find-macro ident)] @@ -2858,7 +2858,7 @@ (def:''' (empty? xs) #Nil - (All [a] (-> ($' List a) Bool)) + (All [a] (-> ($' List a) Bit)) ({#Nil true _ false} xs)) @@ -3030,8 +3030,8 @@ (def:' (code-to-text code) (-> Code Text) - ({[_ (#Bool value)] - (bool/encode value) + ({[_ (#Bit value)] + (bit/encode value) [_ (#Nat value)] (nat/encode value) @@ -3171,7 +3171,7 @@ #Sunday) (def: (weekend? day) - (-> Weekday Bool) + (-> Weekday Bit) (case day (^or #Saturday #Sunday) true @@ -3193,7 +3193,7 @@ (fail "Wrong syntax for ^or"))) (def:' (symbol? code) - (-> Code Bool) + (-> Code Bit) (case code [_ (#Symbol _)] true @@ -3263,8 +3263,8 @@ (def:' (process-def-meta-value code) (-> Code Code) (case code - [_ (#Bool value)] - (meta-code ["lux" "Bool"] (bool$ value)) + [_ (#Bit value)] + (meta-code ["lux" "Bit"] (bit$ value)) [_ (#Nat value)] (meta-code ["lux" "Nat"] (nat$ value)) @@ -3330,7 +3330,7 @@ args))]})) (def:' (export^ tokens) - (-> (List Code) [Bool (List Code)]) + (-> (List Code) [Bit (List Code)]) (case tokens (#Cons [_ (#Tag [_ "export"])] tokens') [true tokens'] @@ -3339,7 +3339,7 @@ [false tokens])) (def:' (export ?) - (-> Bool (List Code)) + (-> Bit (List Code)) (if ? (list (' #export)) (list))) @@ -3481,13 +3481,13 @@ (signature: #export (Ord a) (: (Equivalence a) eq) - (: (-> a a Bool) + (: (-> a a Bit) <) - (: (-> a a Bool) + (: (-> a a Bit) <=) - (: (-> a a Bool) + (: (-> a a Bit) >) - (: (-> a a Bool) + (: (-> a a Bit) >=))"} (let [[exported? tokens'] (export^ tokens) ?parts (: (Maybe [Ident (List Code) Code (List Code)]) @@ -3792,7 +3792,7 @@ (find-module module-name))) (def: (resolve-tag [module name]) - (-> Ident (Meta [Nat (List Ident) Bool Type])) + (-> Ident (Meta [Nat (List Ident) Bit Type])) (do Monad [=module (find-module module) #let [{#module-hash _ #module-aliases _ #definitions bindings #imports _ #tags tags-table #types types #module-annotations _ #module-state _} =module]] @@ -4180,7 +4180,7 @@ (list/drop (n/- +1 amount) a+'))) (def: (clean-module nested? relative-root module) - (-> Bool Text Text (Meta Text)) + (-> Bit Text Text (Meta Text)) (case (count-ups +0 module) +0 (return (if nested? @@ -4207,7 +4207,7 @@ " Relative Root: " relative-root "\n")))))) (def: (parse-imports nested? relative-root imports) - (-> Bool Text (List Code) (Meta (List Importation))) + (-> Bit Text (List Code) (Meta (List Importation))) (do Monad [imports' (monad/map Monad (: (-> Code (Meta (List Importation))) @@ -4280,7 +4280,7 @@ (List Text)) (function (_ [name [def-type def-meta def-value]]) (case (get-meta ["lux" "export?"] def-meta) - (#Some [_ (#Bool true)]) + (#Some [_ (#Bit true)]) (list name) _ @@ -4294,7 +4294,7 @@ )) (def: (filter p xs) - (All [a] (-> (-> a Bool) (List a) (List a))) + (All [a] (-> (-> a Bit) (List a) (List a))) (case xs #Nil (list) @@ -4305,7 +4305,7 @@ (filter p xs')))) (def: (is-member? cases name) - (-> (List Text) Text Bool) + (-> (List Text) Text Bit) (let [output (list/fold (function (_ case prev) (or prev (text/= case name))) @@ -4730,7 +4730,7 @@ (return (list (` (function ((~ g!_) (~ g!arg)) (<| (~+ tokens) (~ g!arg)))))))) (def: (imported-by? import-name module-name) - (-> Text Text (Meta Bool)) + (-> Text Text (Meta Bit)) (do Monad [module (find-module module-name) #let [{#module-hash _ #module-aliases _ #definitions _ #imports imports #tags _ #types _ #module-annotations _ #module-state _} module]] @@ -5154,7 +5154,7 @@ (^template [] [[_ _ column] ( _)] column) - ([#Bool] + ([#Bit] [#Nat] [#Int] [#Rev] @@ -5266,7 +5266,7 @@ [(update-cursor new-cursor as-text) (text/compose (cursor-padding baseline prev-cursor new-cursor) as-text)])) - ([#Bool bool/encode] + ([#Bit bit/encode] [#Nat nat/encode] [#Int int/encode] [#Frac frac/encode] @@ -5479,7 +5479,7 @@ (def: (place-tokens label tokens target) (-> Text (List Code) Code (Maybe (List Code))) (case target - (^or [_ (#Bool _)] [_ (#Nat _)] [_ (#Int _)] [_ (#Rev _)] [_ (#Frac _)] [_ (#Text _)] [_ (#Tag _)]) + (^or [_ (#Bit _)] [_ (#Nat _)] [_ (#Int _)] [_ (#Rev _)] [_ (#Frac _)] [_ (#Text _)] [_ (#Tag _)]) (#Some (list target)) [_ (#Symbol [prefix name])] @@ -5525,16 +5525,16 @@ (compare (:: Code/encode show )) (compare true (:: Equivalence = ))] - [(bool true) "true" [_ (#.Bool true)]] - [(bool false) "false" [_ (#.Bool false)]] + [(bit true) "true" [_ (#.Bit true)]] + [(bit false) "false" [_ (#.Bit false)]] [(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"])]] [(symbol ["yolo" "lol"]) "yolo.lol" [_ (#.Symbol ["yolo" "lol"])]] - [(form (list (bool true) (int 123))) "(true 123)" (^ [_ (#.Form (list [_ (#.Bool true)] [_ (#.Int 123)]))])] - [(tuple (list (bool true) (int 123))) "[true 123]" (^ [_ (#.Tuple (list [_ (#.Bool true)] [_ (#.Int 123)]))])] - [(record (list [(bool true) (int 123)])) "{true 123}" (^ [_ (#.Record (list [[_ (#.Bool true)] [_ (#.Int 123)]]))])] + [(form (list (bit true) (int 123))) "(true 123)" (^ [_ (#.Form (list [_ (#.Bit true)] [_ (#.Int 123)]))])] + [(tuple (list (bit true) (int 123))) "[true 123]" (^ [_ (#.Tuple (list [_ (#.Bit true)] [_ (#.Int 123)]))])] + [(record (list [(bit true) (int 123)])) "{true 123}" (^ [_ (#.Record (list [[_ (#.Bit true)] [_ (#.Int 123)]]))])] [(local-tag "lol") "#lol" [_ (#.Tag ["" "lol"])]] [(local-symbol "lol") "lol" [_ (#.Symbol ["" "lol"])]] )] @@ -5569,7 +5569,7 @@ (^template [] (#Named ["lux" ] _) type) - (["Bool"] + (["Bit"] ["Nat"] ["Int"] ["Rev"] @@ -5591,7 +5591,7 @@ (^template [ ] (#Named ["lux" ] _) (wrap ( (:coerce value)))) - (["Bool" Bool bool$] + (["Bit" Bit bit$] ["Nat" Nat nat$] ["Int" Int int$] ["Rev" Rev rev$] @@ -5690,7 +5690,7 @@ _ (#.Left (format "Static part " (%t static) " does not match URI: " uri))) - "Short-cuts can be taken when using boolean tests." + "Short-cuts can be taken when using bit tests." "The example above can be rewritten as..." (case (split (size static) uri) (^multi (#.Some [chunk uri']) (text/= static chunk)) @@ -5738,11 +5738,11 @@ (do-template [ <%> <=> <0> <2>] [(def: #export ( n) - (-> Bool) + (-> Bit) (<=> <0> (<%> <2> n))) (def: #export ( n) - (-> Bool) + (-> Bit) (not ( n)))] [Nat n/even? n/odd? n/% n/= +0 +2] @@ -5800,7 +5800,7 @@ "This one should fail:" (is? 5 (i/+ 2 3)))} - (All [a] (-> a a Bool)) + (All [a] (-> a a Bit)) ("lux is" reference sample)) (macro: #export (^@ tokens) @@ -5987,7 +5987,7 @@ (#Left "Wrong syntax for char"))) (def: #export (when test f) - (All [a] (-> Bool (-> a a) (-> a a))) + (All [a] (-> Bit (-> a a) (-> a a))) (function (_ value) (if test (f value) @@ -6114,7 +6114,7 @@ (do Monad [g!meta (gensym "g!meta")] (wrap (` [(~ g!meta) ( (~ ( value)))])))) - ([#Bool "Bool" bool$] + ([#Bit "Bit" bit$] [#Nat "Nat" nat$] [#Int "Int" int$] [#Rev "Rev" rev$] diff --git a/stdlib/source/lux/concurrency/actor.lux b/stdlib/source/lux/concurrency/actor.lux index 81e873def..570316334 100644 --- a/stdlib/source/lux/concurrency/actor.lux +++ b/stdlib/source/lux/concurrency/actor.lux @@ -92,7 +92,7 @@ self))) (def: #export (alive? actor) - (All [s] (-> (Actor s) Bool)) + (All [s] (-> (Actor s) Bit)) (case (promise.poll (get@ #obituary (:representation actor))) #.None true @@ -102,7 +102,7 @@ (def: #export (send message actor) {#.doc "Communicate with an actor through message passing."} - (All [s] (-> (Message s) (Actor s) (IO Bool))) + (All [s] (-> (Message s) (Actor s) (IO Bit))) (if (alive? actor) (let [entry [message (promise #.None)]] (do Monad @@ -140,7 +140,7 @@ (def: #export (poison actor) {#.doc "Kills the actor by sending a message that will kill it upon processing, but allows the actor to handle previous messages."} - (All [s] (-> (Actor s) (IO Bool))) + (All [s] (-> (Actor s) (IO Bit))) (send (function (_ state self) (task.throw poisoned [])) actor)) diff --git a/stdlib/source/lux/concurrency/atom.lux b/stdlib/source/lux/concurrency/atom.lux index 8cfc117e4..a06a93b4e 100644 --- a/stdlib/source/lux/concurrency/atom.lux +++ b/stdlib/source/lux/concurrency/atom.lux @@ -19,7 +19,7 @@ {#.doc "Only mutates an atom if you can present it's current value. That guarantees that atom was not updated since you last read from it."} - (All [a] (-> a a (Atom a) (IO Bool))) + (All [a] (-> a a (Atom a) (IO Bit))) (io ("lux atom compare-and-swap" atom current new))) (def: #export (update f atom) diff --git a/stdlib/source/lux/concurrency/frp.lux b/stdlib/source/lux/concurrency/frp.lux index b75e85939..2e1e10d87 100644 --- a/stdlib/source/lux/concurrency/frp.lux +++ b/stdlib/source/lux/concurrency/frp.lux @@ -37,7 +37,7 @@ ## [Values] (def: #export (filter predicate input) - (All [a] (-> (-> a Bool) (Channel a) (Channel a))) + (All [a] (-> (-> a Bit) (Channel a) (Channel a))) (let [output (channel [])] (exec (io.run (listen (function (_ value) (if (predicate value) diff --git a/stdlib/source/lux/concurrency/promise.lux b/stdlib/source/lux/concurrency/promise.lux index c76c4c013..0a03b2c9e 100644 --- a/stdlib/source/lux/concurrency/promise.lux +++ b/stdlib/source/lux/concurrency/promise.lux @@ -31,7 +31,7 @@ (def: #export (resolve value (^:representation promise)) {#.doc "Sets an promise's value if it has not been done yet."} - (All [a] (-> a (Promise a) (IO Bool))) + (All [a] (-> a (Promise a) (IO Bit))) (do io.Monad [(^@ old [_value _observers]) (atom.read promise)] (case _value @@ -65,7 +65,7 @@ (def: #export (resolved? promise) {#.doc "Checks whether a promise's value has already been resolved."} - (All [a] (-> (Promise a) Bool)) + (All [a] (-> (Promise a) Bit)) (case (poll promise) #.None false diff --git a/stdlib/source/lux/concurrency/semaphore.lux b/stdlib/source/lux/concurrency/semaphore.lux index 0c01e9389..774acf5fa 100644 --- a/stdlib/source/lux/concurrency/semaphore.lux +++ b/stdlib/source/lux/concurrency/semaphore.lux @@ -31,7 +31,7 @@ (promise.promise #.None))] (do io.Monad [state (atom.read semaphore) - #let [[ready? state'] (: [Bool State] + #let [[ready? state'] (: [Bit State] (case (get@ #open-positions state) +0 [false (update@ #waiting-list (|>> (#.Cons signal)) state)] diff --git a/stdlib/source/lux/concurrency/stm.lux b/stdlib/source/lux/concurrency/stm.lux index e3c797b2d..7af73b68d 100644 --- a/stdlib/source/lux/concurrency/stm.lux +++ b/stdlib/source/lux/concurrency/stm.lux @@ -166,7 +166,7 @@ (wrap [a a']))) (def: (can-commit? tx) - (-> Tx Bool) + (-> Tx Bit) (list.every? (function (_ [_var _original _current]) (is? _original (read!! _var))) tx)) @@ -186,7 +186,7 @@ (atom (promise #.None))) (def: commit-processor-flag - (Atom Bool) + (Atom Bit) (atom false)) (def: (issue-commit commit) diff --git a/stdlib/source/lux/control/concatenative.lux b/stdlib/source/lux/control/concatenative.lux index af86fc527..bed6e9dd5 100644 --- a/stdlib/source/lux/control/concatenative.lux +++ b/stdlib/source/lux/control/concatenative.lux @@ -101,7 +101,7 @@ (def: (prepare command) (-> Code Code) (case command - (^or [_ (#.Bool _)] + (^or [_ (#.Bit _)] [_ (#.Nat _)] [_ (#.Int _)] [_ (#.Rev _)] [_ (#.Frac _)] [_ (#.Text _)] @@ -210,51 +210,51 @@ [Nat Nat n/* .n/*] [Nat Nat n// .n//] [Nat Nat n/% .n/%] - [Nat Bool n/= .n/=] - [Nat Bool n/< .n/<] - [Nat Bool n/<= .n/<=] - [Nat Bool n/> .n/>] - [Nat Bool n/>= .n/>=] + [Nat Bit n/= .n/=] + [Nat Bit n/< .n/<] + [Nat Bit n/<= .n/<=] + [Nat Bit n/> .n/>] + [Nat Bit n/>= .n/>=] [Int Int i/+ .i/+] [Int Int i/- .i/-] [Int Int i/* .i/*] [Int Int i// .i//] [Int Int i/% .i/%] - [Int Bool i/= .i/=] - [Int Bool i/< .i/<] - [Int Bool i/<= .i/<=] - [Int Bool i/> .i/>] - [Int Bool i/>= .i/>=] + [Int Bit i/= .i/=] + [Int Bit i/< .i/<] + [Int Bit i/<= .i/<=] + [Int Bit i/> .i/>] + [Int Bit i/>= .i/>=] [Rev Rev r/+ .r/+] [Rev Rev r/- .r/-] [Rev Rev r/* .r/*] [Rev Rev r// .r//] [Rev Rev r/% .r/%] - [Rev Bool r/= .r/=] - [Rev Bool r/< .r/<] - [Rev Bool r/<= .r/<=] - [Rev Bool r/> .r/>] - [Rev Bool r/>= .r/>=] + [Rev Bit r/= .r/=] + [Rev Bit r/< .r/<] + [Rev Bit r/<= .r/<=] + [Rev Bit r/> .r/>] + [Rev Bit r/>= .r/>=] [Frac Frac f/+ .f/+] [Frac Frac f/- .f/-] [Frac Frac f/* .f/*] [Frac Frac f// .f//] [Frac Frac f/% .f/%] - [Frac Bool f/= .f/=] - [Frac Bool f/< .f/<] - [Frac Bool f/<= .f/<=] - [Frac Bool f/> .f/>] - [Frac Bool f/>= .f/>=] + [Frac Bit f/= .f/=] + [Frac Bit f/< .f/<] + [Frac Bit f/<= .f/<=] + [Frac Bit f/> .f/>] + [Frac Bit f/>= .f/>=] ) (def: #export if (All [__a __b] (=> {then (=> __a __b) else (=> __a __b)} - __a [Bool then else] __b)) + __a [Bit then else] __b)) (function (_ [[[stack test] then] else]) (.if test (then stack) @@ -269,7 +269,7 @@ (def: #export loop (All [___] - (=> {test (=> ___ ___ [Bool])} + (=> {test (=> ___ ___ [Bit])} ___ [test] ___)) (function (loop [stack pred]) (let [[stack' verdict] (pred stack)] @@ -293,7 +293,7 @@ (def: #export do (All [__a __b] - (=> {pred (=> __a __b [Bool]) + (=> {pred (=> __a __b [Bit]) body (=> __b __a)} __b [pred body] __a [pred body])) @@ -302,7 +302,7 @@ (def: #export while (All [__a __b] - (=> {pred (=> __a __b [Bool]) + (=> {pred (=> __a __b [Bit]) body (=> __b __a)} __a [pred body] __b)) @@ -330,11 +330,11 @@ (word: #export when (All [___] (=> {body (=> ___ ___)} - ___ [Bool body] + ___ [Bit body] ___)) swap [call] [drop] if) (word: #export ? (All [a] - (=> [Bool a a] [a])) + (=> [Bit a a] [a])) rotL [drop] [nip] if) diff --git a/stdlib/source/lux/control/contract.lux b/stdlib/source/lux/control/contract.lux index 1b4939cb6..9b7427190 100644 --- a/stdlib/source/lux/control/contract.lux +++ b/stdlib/source/lux/control/contract.lux @@ -8,7 +8,7 @@ ["s" syntax (#+ syntax:)]]]) (def: #export (assert! message test) - (-> Text Bool []) + (-> Text Bit []) (if test [] (error! message))) diff --git a/stdlib/source/lux/control/enum.lux b/stdlib/source/lux/control/enum.lux index b153beede..4dc825508 100644 --- a/stdlib/source/lux/control/enum.lux +++ b/stdlib/source/lux/control/enum.lux @@ -12,7 +12,7 @@ ## [Functions] (def: (range' <= succ from to) - (All [a] (-> (-> a a Bool) (-> a a) a a (List a))) + (All [a] (-> (-> a a Bit) (-> a a) a a (List a))) (if (<= to from) (#.Cons from (range' <= succ (succ from) to)) #.Nil)) diff --git a/stdlib/source/lux/control/equivalence.lux b/stdlib/source/lux/control/equivalence.lux index cddf72542..eb869a81c 100644 --- a/stdlib/source/lux/control/equivalence.lux +++ b/stdlib/source/lux/control/equivalence.lux @@ -2,7 +2,7 @@ (signature: #export (Equivalence a) {#.doc "Equivalence for a type's instances."} - (: (-> a a Bool) + (: (-> a a Bit) =)) (def: #export (product left right) diff --git a/stdlib/source/lux/control/exception.lux b/stdlib/source/lux/control/exception.lux index 41dd22b88..296513718 100644 --- a/stdlib/source/lux/control/exception.lux +++ b/stdlib/source/lux/control/exception.lux @@ -26,7 +26,7 @@ ## [Values] (def: #export (match? exception error) - (All [e] (-> (Exception e) Text Bool)) + (All [e] (-> (Exception e) Text Bit)) (text.starts-with? (get@ #label exception) error)) (def: #export (catch exception then try) @@ -76,7 +76,7 @@ (#/.Error (construct exception message))) (def: #export (assert exception message test) - (All [e] (-> (Exception e) e Bool (Error Any))) + (All [e] (-> (Exception e) e Bit (Error Any))) (if test (#/.Success []) (..throw exception message))) diff --git a/stdlib/source/lux/control/interval.lux b/stdlib/source/lux/control/interval.lux index ae8c6ce30..a1084290a 100644 --- a/stdlib/source/lux/control/interval.lux +++ b/stdlib/source/lux/control/interval.lux @@ -31,7 +31,7 @@ (do-template [ ] [(def: #export ( interval) - (All [a] (-> (Interval a) Bool)) + (All [a] (-> (Interval a) Bit)) (let [(^open) interval] ( bottom top)))] @@ -41,7 +41,7 @@ ) (def: #export (within? interval elem) - (All [a] (-> (Interval a) a Bool)) + (All [a] (-> (Interval a) a Bit)) (let [(^open) interval] (cond (inner? interval) (and (>= bottom elem) @@ -57,7 +57,7 @@ (do-template [ ] [(def: #export ( elem interval) - (All [a] (-> a (Interval a) Bool)) + (All [a] (-> a (Interval a) Bit)) (let [(^open) interval] (= elem)))] @@ -66,7 +66,7 @@ ) (def: #export (borders? interval elem) - (All [a] (-> (Interval a) a Bool)) + (All [a] (-> (Interval a) a Bit)) (or (starts-with? elem interval) (ends-with? elem interval))) @@ -90,31 +90,31 @@ (def: top (pred bottom))))) (def: #export (precedes? reference sample) - (All [a] (-> (Interval a) (Interval a) Bool)) + (All [a] (-> (Interval a) (Interval a) Bit)) (let [(^open) reference limit (:: reference bottom)] (and (< limit (:: sample bottom)) (< limit (:: sample top))))) (def: #export (succeeds? reference sample) - (All [a] (-> (Interval a) (Interval a) Bool)) + (All [a] (-> (Interval a) (Interval a) Bit)) (precedes? sample reference)) (def: #export (meets? reference sample) - (All [a] (-> (Interval a) (Interval a) Bool)) + (All [a] (-> (Interval a) (Interval a) Bit)) (let [(^open) reference limit (:: reference bottom)] (and (<= limit (:: sample bottom)) (= limit (:: sample top))))) (def: #export (touches? reference sample) - (All [a] (-> (Interval a) (Interval a) Bool)) + (All [a] (-> (Interval a) (Interval a) Bit)) (or (meets? reference sample) (meets? sample reference))) (do-template [ ] [(def: #export ( reference sample) - (All [a] (-> (Interval a) (Interval a) Bool)) + (All [a] (-> (Interval a) (Interval a) Bit)) (let [(^open) reference] (and (= (:: reference ) (:: sample )) ( (:: reference ) (:: sample )))))] @@ -125,7 +125,7 @@ (do-template [ ] [(def: #export ( reference sample) - (All [a] (-> a (Interval a) Bool)) + (All [a] (-> a (Interval a) Bit)) (let [(^open) sample] (and ( reference bottom) ( reference top))))] @@ -141,7 +141,7 @@ (= top (:: sample top)))))) (def: #export (nested? reference sample) - (All [a] (-> (Interval a) (Interval a) Bool)) + (All [a] (-> (Interval a) (Interval a) Bit)) (cond (or (singleton? sample) (and (inner? reference) (inner? sample)) (and (outer? reference) (outer? sample))) @@ -162,7 +162,7 @@ )) (def: #export (overlaps? reference sample) - (All [a] (-> (Interval a) (Interval a) Bool)) + (All [a] (-> (Interval a) (Interval a) Bit)) (let [(^open) reference] (and (not (:: Equivalence = reference sample)) (cond (singleton? sample) diff --git a/stdlib/source/lux/control/order.lux b/stdlib/source/lux/control/order.lux index 6a801392d..7b07325a1 100644 --- a/stdlib/source/lux/control/order.lux +++ b/stdlib/source/lux/control/order.lux @@ -11,7 +11,7 @@ eq) (do-template [] - [(: (-> a a Bool) )] + [(: (-> a a Bit) )] [<] [<=] [>] [>=] ) @@ -20,7 +20,7 @@ ## [Values] (def: #export (order eq <) (All [a] - (-> (Equivalence a) (-> a a Bool) (Order a))) + (-> (Equivalence a) (-> a a Bit) (Order a))) (let [> (flip <)] (structure (def: eq eq) (def: < <) diff --git a/stdlib/source/lux/control/parser.lux b/stdlib/source/lux/control/parser.lux index 4c5e827f9..7ad46dba8 100644 --- a/stdlib/source/lux/control/parser.lux +++ b/stdlib/source/lux/control/parser.lux @@ -61,7 +61,7 @@ ## [Parsers] (def: #export (assert message test) {#.doc "Fails with the given message if the test is false."} - (All [s] (-> Text Bool (Parser s Any))) + (All [s] (-> Text Bit (Parser s Any))) (function (_ input) (if test (#e.Success [input []]) @@ -254,7 +254,7 @@ (wrap output))) (def: #export (filter test parser) - (All [s a] (-> (-> a Bool) (Parser s a) (Parser s a))) + (All [s a] (-> (-> a Bit) (Parser s a) (Parser s a))) (do Monad [output parser _ (assert "Constraint failed." (test output))] diff --git a/stdlib/source/lux/control/predicate.lux b/stdlib/source/lux/control/predicate.lux index 9af533a8f..383d1b907 100644 --- a/stdlib/source/lux/control/predicate.lux +++ b/stdlib/source/lux/control/predicate.lux @@ -5,7 +5,7 @@ [function]]) (type: #export (Predicate a) - (-> a Bool)) + (-> a Bit)) (do-template [ ] [(def: #export diff --git a/stdlib/source/lux/control/state.lux b/stdlib/source/lux/control/state.lux index 03965f498..94330ff96 100644 --- a/stdlib/source/lux/control/state.lux +++ b/stdlib/source/lux/control/state.lux @@ -135,7 +135,7 @@ (wrap [state a])))) (def: #export (while condition body) - (All [s] (-> (State s Bool) (State s Any) (State s Any))) + (All [s] (-> (State s Bit) (State s Any) (State s Any))) (do Monad [execute? condition] (if execute? @@ -145,7 +145,7 @@ (wrap [])))) (def: #export (do-while condition body) - (All [s] (-> (State s Bool) (State s Any) (State s Any))) + (All [s] (-> (State s Bit) (State s Any) (State s Any))) (do Monad [_ body] (while condition body))) diff --git a/stdlib/source/lux/data/bit.lux b/stdlib/source/lux/data/bit.lux new file mode 100644 index 000000000..60cef178b --- /dev/null +++ b/stdlib/source/lux/data/bit.lux @@ -0,0 +1,51 @@ +(.module: + [lux #* + [control + [monoid (#+ Monoid)] + [equivalence (#+ Equivalence)] + hash + [codec (#+ Codec)]] + function]) + +## [Structures] +(structure: #export _ (Equivalence Bit) + (def: (= x y) + (if x + y + (not y)))) + +(structure: #export _ (Hash Bit) + (def: eq Equivalence) + (def: (hash value) + (case value + true +1 + false +0))) + +(do-template [ ] + [(structure: #export (Monoid Bit) + (def: identity ) + (def: (compose x y) + ( x y)))] + + [ Or@Monoid false or] + [And@Monoid true and] + ) + +(structure: #export _ (Codec Text Bit) + (def: (encode x) + (if x + "true" + "false")) + + (def: (decode input) + (case input + "true" (#.Right true) + "false" (#.Right false) + _ (#.Left "Wrong syntax for Bit.")))) + +## [Values] +(def: #export complement + {#.doc "Generates the complement of a predicate. + That is a predicate that returns the oposite of the original predicate."} + (All [a] (-> (-> a Bit) (-> a Bit))) + (compose not)) diff --git a/stdlib/source/lux/data/bool.lux b/stdlib/source/lux/data/bool.lux deleted file mode 100644 index b75663ad5..000000000 --- a/stdlib/source/lux/data/bool.lux +++ /dev/null @@ -1,51 +0,0 @@ -(.module: - [lux #* - [control - [monoid (#+ Monoid)] - [equivalence (#+ Equivalence)] - hash - [codec (#+ Codec)]] - function]) - -## [Structures] -(structure: #export _ (Equivalence Bool) - (def: (= x y) - (if x - y - (not y)))) - -(structure: #export _ (Hash Bool) - (def: eq Equivalence) - (def: (hash value) - (case value - true +1 - false +0))) - -(do-template [ ] - [(structure: #export (Monoid Bool) - (def: identity ) - (def: (compose x y) - ( x y)))] - - [ Or@Monoid false or] - [And@Monoid true and] - ) - -(structure: #export _ (Codec Text Bool) - (def: (encode x) - (if x - "true" - "false")) - - (def: (decode input) - (case input - "true" (#.Right true) - "false" (#.Right false) - _ (#.Left "Wrong syntax for Bool.")))) - -## [Values] -(def: #export complement - {#.doc "Generates the complement of a predicate. - That is a predicate that returns the oposite of the original predicate."} - (All [a] (-> (-> a Bool) (-> a Bool))) - (compose not)) diff --git a/stdlib/source/lux/data/collection/array.lux b/stdlib/source/lux/data/collection/array.lux index 684988954..d8d4ce5fa 100644 --- a/stdlib/source/lux/data/collection/array.lux +++ b/stdlib/source/lux/data/collection/array.lux @@ -69,7 +69,7 @@ (def: #export (filter p xs) (All [a] - (-> (-> a Bool) (Array a) (Array a))) + (-> (-> a Bit) (Array a) (Array a))) (list/fold (function (_ idx xs') (case (read idx xs) #.None @@ -84,7 +84,7 @@ (def: #export (find p xs) (All [a] - (-> (-> a Bool) (Array a) (Maybe a))) + (-> (-> a Bit) (Array a) (Maybe a))) (let [arr-size (size xs)] (loop [idx +0] (if (n/< arr-size idx) @@ -101,7 +101,7 @@ (def: #export (find+ p xs) {#.doc "Just like 'find', but with access to the index of each value."} (All [a] - (-> (-> Nat a Bool) (Array a) (Maybe [Nat a]))) + (-> (-> Nat a Bit) (Array a) (Maybe [Nat a]))) (let [arr-size (size xs)] (loop [idx +0] (if (n/< arr-size idx) diff --git a/stdlib/source/lux/data/collection/bits.lux b/stdlib/source/lux/data/collection/bits.lux index b0e506cde..24eaa44a6 100644 --- a/stdlib/source/lux/data/collection/bits.lux +++ b/stdlib/source/lux/data/collection/bits.lux @@ -36,11 +36,11 @@ (|> bits array.size (n/* chunk-size))) (def: #export empty? - (-> Bits Bool) + (-> Bits Bit) (|>> size (n/= +0))) (def: #export (get index bits) - (-> Nat Bits Bool) + (-> Nat Bits Bit) (let [[chunk-index bit-index] (n//% chunk-size index)] (.and (n/< (array.size bits) chunk-index) (|> (array.read chunk-index bits) @@ -88,7 +88,7 @@ ) (def: #export (intersects? reference sample) - (-> Bits Bits Bool) + (-> Bits Bits Bit) (let [chunks (n/min (array.size reference) (array.size sample))] (loop [idx +0] diff --git a/stdlib/source/lux/data/collection/dictionary.lux b/stdlib/source/lux/data/collection/dictionary.lux index 8e967b768..5add5c74a 100644 --- a/stdlib/source/lux/data/collection/dictionary.lux +++ b/stdlib/source/lux/data/collection/dictionary.lux @@ -177,12 +177,12 @@ (->bit-position (level-index level hash))) (def: (bit-position-is-set? bit bitmap) - (-> BitPosition BitMap Bool) + (-> BitPosition BitMap Bit) (not (n/= clean-bitmap (i64.and bit bitmap)))) ## Figures out whether a bitmap only contains a single bit-position. (def: only-bit-position? - (-> BitPosition BitMap Bool) + (-> BitPosition BitMap Bit) n/=) (def: (set-bit-position bit bitmap) @@ -272,7 +272,7 @@ ## used). ## So, this test is introduced to detect them. (def: (empty?' node) - (All [k v] (-> (Node k v) Bool)) + (All [k v] (-> (Node k v) Bit)) (`` (case node (#Base (~~ (static ..clean-bitmap)) _) true @@ -569,7 +569,7 @@ (get' root-level (:: Hash hash key) key Hash node))) (def: #export (contains? key dict) - (All [k v] (-> k (Dictionary k v) Bool)) + (All [k v] (-> k (Dictionary k v) Bit)) (case (get key dict) #.None false (#.Some _) true)) @@ -604,7 +604,7 @@ (|>> product.right size')) (def: #export empty? - (All [k v] (-> (Dictionary k v) Bool)) + (All [k v] (-> (Dictionary k v) Bit)) (|>> size (n/= +0))) (def: #export (entries dict) diff --git a/stdlib/source/lux/data/collection/dictionary/ordered.lux b/stdlib/source/lux/data/collection/dictionary/ordered.lux index 963f178b3..153c17a69 100644 --- a/stdlib/source/lux/data/collection/dictionary/ordered.lux +++ b/stdlib/source/lux/data/collection/dictionary/ordered.lux @@ -71,7 +71,7 @@ )))) (def: #export (contains? key dict) - (All [k v] (-> k (Dictionary k v) Bool)) + (All [k v] (-> k (Dictionary k v) Bit)) (let [## (^open "T/") (get@ #order dict) ] (loop [node (get@ #root dict)] diff --git a/stdlib/source/lux/data/collection/dictionary/plist.lux b/stdlib/source/lux/data/collection/dictionary/plist.lux index f1a6dff7e..050185307 100644 --- a/stdlib/source/lux/data/collection/dictionary/plist.lux +++ b/stdlib/source/lux/data/collection/dictionary/plist.lux @@ -18,7 +18,7 @@ (get key properties')))) (def: #export (contains? key properties) - (All [a] (-> Text (PList a) Bool)) + (All [a] (-> Text (PList a) Bit)) (case (get key properties) (#.Some _) true diff --git a/stdlib/source/lux/data/collection/list.lux b/stdlib/source/lux/data/collection/list.lux index b3089a01e..c734c140b 100644 --- a/stdlib/source/lux/data/collection/list.lux +++ b/stdlib/source/lux/data/collection/list.lux @@ -8,7 +8,7 @@ [equivalence (#+ Equivalence)] [fold]] [data - bool + bit [product]]]) ## [Types] @@ -37,7 +37,7 @@ (def: #export (filter p xs) (All [a] - (-> (-> a Bool) (List a) (List a))) + (-> (-> a Bit) (List a) (List a))) (case xs #.Nil #.Nil @@ -49,7 +49,7 @@ (def: #export (partition p xs) {#.doc "Divide the list into all elements that satisfy a predicate, and all elements that do not."} - (All [a] (-> (-> a Bool) (List a) [(List a) (List a)])) + (All [a] (-> (-> a Bit) (List a) [(List a) (List a)])) [(filter p xs) (filter (complement p) xs)]) (def: #export (as-pairs xs) @@ -84,7 +84,7 @@ (do-template [ ] [(def: #export ( p xs) (All [a] - (-> (-> a Bool) (List a) (List a))) + (-> (-> a Bit) (List a) (List a))) (case xs #.Nil #.Nil @@ -113,7 +113,7 @@ (def: (split-with' p ys xs) (All [a] - (-> (-> a Bool) (List a) (List a) [(List a) (List a)])) + (-> (-> a Bit) (List a) (List a) [(List a) (List a)])) (case xs #.Nil [ys xs] @@ -126,7 +126,7 @@ (def: #export (split-with p xs) {#.doc "Segment the list by using a predicate to tell when to cut."} (All [a] - (-> (-> a Bool) (List a) [(List a) (List a)])) + (-> (-> a Bit) (List a) [(List a) (List a)])) (let [[ys' xs'] (split-with' p #.Nil xs)] [(reverse ys') xs'])) @@ -173,7 +173,7 @@ (def: #export (find p xs) {#.doc "Returns the first value in the list for which the predicate is true."} (All [a] - (-> (-> a Bool) (List a) (Maybe a))) + (-> (-> a Bit) (List a) (Maybe a))) (case xs #.Nil #.None @@ -234,7 +234,7 @@ (do-template [ ] [(def: #export ( p xs) (All [a] - (-> (-> a Bool) (List a) Bool)) + (-> (-> a Bit) (List a) Bit)) (loop [xs xs] (case xs #.Nil @@ -320,7 +320,7 @@ ## [Functions] (def: #export (sort < xs) - (All [a] (-> (-> a a Bool) (List a) (List a))) + (All [a] (-> (-> a a Bit) (List a) (List a))) (case xs #.Nil (list) @@ -352,13 +352,13 @@ ) (def: #export (empty? xs) - (All [a] (-> (List a) Bool)) + (All [a] (-> (List a) Bit)) (case xs #.Nil true _ false)) (def: #export (member? eq xs x) - (All [a] (-> (Equivalence a) (List a) a Bool)) + (All [a] (-> (Equivalence a) (List a) a Bit)) (case xs #.Nil false (#.Cons x' xs') (or (:: eq = x x') diff --git a/stdlib/source/lux/data/collection/queue.lux b/stdlib/source/lux/data/collection/queue.lux index cf3587ece..864dfb67d 100644 --- a/stdlib/source/lux/data/collection/queue.lux +++ b/stdlib/source/lux/data/collection/queue.lux @@ -35,11 +35,11 @@ (list.size rear)))) (def: #export empty? - (All [a] (-> (Queue a) Bool)) + (All [a] (-> (Queue a) Bit)) (|>> (get@ #front) list.empty?)) (def: #export (member? Equivalence queue member) - (All [a] (-> (Equivalence a) (Queue a) a Bool)) + (All [a] (-> (Equivalence a) (Queue a) a Bit)) (let [(^slots [#front #rear]) queue] (or (list.member? Equivalence front member) (list.member? Equivalence rear member)))) diff --git a/stdlib/source/lux/data/collection/queue/priority.lux b/stdlib/source/lux/data/collection/queue/priority.lux index 6765c6708..dbf6dec75 100644 --- a/stdlib/source/lux/data/collection/queue/priority.lux +++ b/stdlib/source/lux/data/collection/queue/priority.lux @@ -42,7 +42,7 @@ (n/+ (recur left) (recur right)))))) (def: #export (member? Equivalence queue member) - (All [a] (-> (Equivalence a) (Queue a) a Bool)) + (All [a] (-> (Equivalence a) (Queue a) a Bit)) (case queue #.None false diff --git a/stdlib/source/lux/data/collection/row.lux b/stdlib/source/lux/data/collection/row.lux index 3b3b080eb..197e596e6 100644 --- a/stdlib/source/lux/data/collection/row.lux +++ b/stdlib/source/lux/data/collection/row.lux @@ -333,11 +333,11 @@ list)) (def: #export (member? a/Equivalence vec val) - (All [a] (-> (Equivalence a) (Row a) a Bool)) + (All [a] (-> (Equivalence a) (Row a) a Bit)) (list.member? a/Equivalence (to-list vec) val)) (def: #export empty? - (All [a] (-> (Row a) Bool)) + (All [a] (-> (Row a) Bit)) (|>> (get@ #size) (n/= +0))) ## [Syntax] diff --git a/stdlib/source/lux/data/collection/sequence.lux b/stdlib/source/lux/data/collection/sequence.lux index dc8f4a802..0a2350324 100644 --- a/stdlib/source/lux/data/collection/sequence.lux +++ b/stdlib/source/lux/data/collection/sequence.lux @@ -10,7 +10,7 @@ [code] ["s" syntax (#+ syntax: Syntax)]] [data - bool + bit [collection [list ("list/" Monad)]]]]) ## [Types] @@ -91,8 +91,8 @@ [(#.Cons [x tail]) next]) [(list) xs])))] - [take-while drop-while split-while (-> a Bool) (pred x) pred] - [take drop split Nat (n/> +0 pred) (dec pred)] + [take-while drop-while split-while (-> a Bit) (pred x) pred] + [take drop split Nat (n/> +0 pred) (dec pred)] ) (def: #export (unfold step init) @@ -103,7 +103,7 @@ (pending [x (unfold step next)]))) (def: #export (filter p xs) - (All [a] (-> (-> a Bool) (Sequence a) (Sequence a))) + (All [a] (-> (-> a Bit) (Sequence a) (Sequence a))) (let [[x xs'] (continuation.run xs)] (if (p x) (pending [x (filter p xs')]) @@ -115,7 +115,7 @@ The left side contains all entries for which the predicate is true. The right side contains all entries for which the predicate is false."} - (All [a] (-> (-> a Bool) (Sequence a) [(Sequence a) (Sequence a)])) + (All [a] (-> (-> a Bit) (Sequence a) [(Sequence a) (Sequence a)])) [(filter p xs) (filter (complement p) xs)]) ## [Structures] diff --git a/stdlib/source/lux/data/collection/set.lux b/stdlib/source/lux/data/collection/set.lux index 5fa774e9e..11381c683 100644 --- a/stdlib/source/lux/data/collection/set.lux +++ b/stdlib/source/lux/data/collection/set.lux @@ -31,7 +31,7 @@ (|> set :representation (dict.remove elem) :abstraction)) (def: #export (member? set elem) - (All [a] (-> (Set a) a Bool)) + (All [a] (-> (Set a) a Bit)) (|> set :representation (dict.contains? elem))) (def: #export to-list @@ -68,7 +68,7 @@ ) (def: #export empty? - (All [a] (-> (Set a) Bool)) + (All [a] (-> (Set a) Bit)) (|>> ..size (n/= +0))) (def: #export (from-list Hash xs) @@ -76,9 +76,9 @@ (list/fold ..add (..new Hash) xs)) (def: #export (sub? super sub) - (All [a] (-> (Set a) (Set a) Bool)) + (All [a] (-> (Set a) (Set a) Bit)) (list.every? (..member? super) (..to-list sub))) (def: #export (super? sub super) - (All [a] (-> (Set a) (Set a) Bool)) + (All [a] (-> (Set a) (Set a) Bit)) (sub? super sub)) diff --git a/stdlib/source/lux/data/collection/set/multi.lux b/stdlib/source/lux/data/collection/set/multi.lux index 5aff87021..314c0423c 100644 --- a/stdlib/source/lux/data/collection/set/multi.lux +++ b/stdlib/source/lux/data/collection/set/multi.lux @@ -96,7 +96,7 @@ subject))) (def: #export (sub? reference subject) - (All [a] (-> (Set a) (Set a) Bool)) + (All [a] (-> (Set a) (Set a) Bit)) (|> subject :representation dictionary.entries @@ -138,11 +138,11 @@ ) (def: #export (member? set elem) - (All [a] (-> (Set a) a Bool)) + (All [a] (-> (Set a) a Bit)) (|> set (..multiplicity elem) (n/> +0))) (def: #export empty? - (All [a] (-> (Set a) Bool)) + (All [a] (-> (Set a) Bit)) (|>> ..size (n/= +0))) (def: #export (from-list Hash subject) @@ -150,5 +150,5 @@ (list/fold ..add/1 (..new Hash) subject)) (def: #export super? - (All [a] (-> (Set a) (Set a) Bool)) + (All [a] (-> (Set a) (Set a) Bit)) (function.flip sub?)) diff --git a/stdlib/source/lux/data/collection/set/ordered.lux b/stdlib/source/lux/data/collection/set/ordered.lux index 7e43d2a4e..b9fff0680 100644 --- a/stdlib/source/lux/data/collection/set/ordered.lux +++ b/stdlib/source/lux/data/collection/set/ordered.lux @@ -19,7 +19,7 @@ (|>> //.new :abstraction)) (def: #export (member? set elem) - (All [a] (-> (Set a) a Bool)) + (All [a] (-> (Set a) a Bit)) (|> set :representation (//.contains? elem))) (do-template [ ] @@ -79,11 +79,11 @@ ) (def: #export (sub? super sub) - (All [a] (-> (Set a) (Set a) Bool)) + (All [a] (-> (Set a) (Set a) Bit)) (|> sub ..to-list (list.every? (..member? super)))) (def: #export (super? sub super) - (All [a] (-> (Set a) (Set a) Bool)) + (All [a] (-> (Set a) (Set a) Bit)) (sub? super sub)) diff --git a/stdlib/source/lux/data/collection/stack.lux b/stdlib/source/lux/data/collection/stack.lux index 409993ef1..8a24010e7 100644 --- a/stdlib/source/lux/data/collection/stack.lux +++ b/stdlib/source/lux/data/collection/stack.lux @@ -18,7 +18,7 @@ (list.size stack)) (def: #export (empty? stack) - (All [a] (-> (Stack a) Bool)) + (All [a] (-> (Stack a) Bit)) (list.empty? stack)) (def: #export (peek stack) diff --git a/stdlib/source/lux/data/collection/tree/finger.lux b/stdlib/source/lux/data/collection/tree/finger.lux index 1ce6d63fc..b77fca2ec 100644 --- a/stdlib/source/lux/data/collection/tree/finger.lux +++ b/stdlib/source/lux/data/collection/tree/finger.lux @@ -35,7 +35,7 @@ (get@ #node right))})) (def: #export (search pred tree) - (All [m a] (-> (-> m Bool) (Tree m a) (Maybe a))) + (All [m a] (-> (-> m Bit) (Tree m a) (Maybe a))) (let [tag/compose (get@ [#monoid #m.compose] tree)] (if (pred (tag tree)) (loop [_tag (get@ [#monoid #m.identity] tree) @@ -52,7 +52,7 @@ #.None))) (def: #export (found? pred tree) - (All [m a] (-> (-> m Bool) (Tree m a) Bool)) + (All [m a] (-> (-> m Bit) (Tree m a) Bit)) (case (search pred tree) (#.Some _) true diff --git a/stdlib/source/lux/data/collection/tree/rose/zipper.lux b/stdlib/source/lux/data/collection/tree/rose/zipper.lux index f9a33ce0e..cdaba29fc 100644 --- a/stdlib/source/lux/data/collection/tree/rose/zipper.lux +++ b/stdlib/source/lux/data/collection/tree/rose/zipper.lux @@ -44,20 +44,20 @@ (|> zipper (get@ [#node #rose.children]))) (def: #export (branch? zipper) - (All [a] (-> (Zipper a) Bool)) + (All [a] (-> (Zipper a) Bit)) (|> zipper children list.empty? not)) (def: #export (leaf? zipper) - (All [a] (-> (Zipper a) Bool)) + (All [a] (-> (Zipper a) Bit)) (|> zipper branch? not)) (def: #export (end? zipper) - (All [a] (-> (Zipper a) Bool)) + (All [a] (-> (Zipper a) Bit)) (and (list.empty? (get@ #rights zipper)) (list.empty? (children zipper)))) (def: #export (root? zipper) - (All [a] (-> (Zipper a) Bool)) + (All [a] (-> (Zipper a) Bit)) (case (get@ #parent zipper) #.None true diff --git a/stdlib/source/lux/data/format/binary.lux b/stdlib/source/lux/data/format/binary.lux index 4503f21dd..a5dcde900 100644 --- a/stdlib/source/lux/data/format/binary.lux +++ b/stdlib/source/lux/data/format/binary.lux @@ -148,14 +148,14 @@ (Binary Any) (ignore [])) -(def: #export bool - (Binary Bool) +(def: #export bit + (Binary Bit) {#read (function (_ [offset blob]) (case (blob.read/8 offset blob) (#error.Success data) (case (: Nat data) - (^template [ ] - (#error.Success [(inc offset) blob] )) + (^template [ ] + (#error.Success [(inc offset) blob] )) ([+0 false] [+1 true]) @@ -264,8 +264,8 @@ (function (_ code) (let [sequence (..list code) code' ($_ ..alt - ## #Bool - ..bool + ## #Bit + ..bit ## #Nat ..nat ## #Int diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux index 0316b5a9b..4dfa6cb7d 100644 --- a/stdlib/source/lux/data/format/json.lux +++ b/stdlib/source/lux/data/format/json.lux @@ -8,7 +8,7 @@ codec ["p" parser ("parser/" Monad)]] [data - [bool] + [bit] [text ("text/" Equivalence Monoid) ["l" lexer]] [number ("frac/" Codec) ("nat/" Codec)] @@ -28,7 +28,7 @@ [(type: #export )] [Null Any] - [Boolean Bool] + [Boolean Bit] [Number Frac] [String Text] ) @@ -67,9 +67,9 @@ (^template [ ] [_ ( value)] (wrap (list (` (: JSON ( (~ ( value)))))))) - ([#.Bool code.bool #Boolean] - [#.Frac code.frac #Number] - [#.Text code.text #String]) + ([#.Bit code.bit #Boolean] + [#.Frac code.frac #Number] + [#.Text code.text #String]) [_ (#.Tag ["" "null"])] (wrap (list (` (: JSON #Null)))) @@ -159,7 +159,7 @@ (^template [ ] [( x') ( y')] (:: = x' y')) - ([#Boolean bool.Equivalence] + ([#Boolean bit.Equivalence] [#Number number.Equivalence] [#String text.Equivalence]) @@ -237,16 +237,22 @@ _ (fail ($_ text/compose "JSON value is not " ".")))))] - [null Any #Null "null"] - [boolean Bool #Boolean "boolean"] + [null Any #Null "null"] + [boolean Bit #Boolean "boolean"] [number Frac #Number "number"] [string Text #String "string"] ) +(def: (encode-boolean value) + (-> Bit Text) + (if value + "true" + "false")) + (do-template [
]
   [(def: #export ( test)
      {#.doc (code.text ($_ text/compose "Asks whether a JSON value is a "  "."))}
-     (->  (Reader Bool))
+     (->  (Reader Bit))
      (do p.Monad
        [head any]
        (case head
@@ -271,7 +277,7 @@
          _
          (fail ($_ text/compose "JSON value is not a "  ".")))))]
 
-  [boolean? boolean! Bool bool.Equivalence   (:: bool.Codec encode)   #Boolean "boolean" id]
+  [boolean? boolean! Bit  bit.Equivalence     encode-boolean                      #Boolean "boolean" id]
   [number?  number!  Frac number.Equivalence (:: number.Codec encode) #Number  "number"  id]
   [string?  string!  Text text.Equivalence   text.encode                         #String  "string"  id]
   )
@@ -360,7 +366,7 @@
 (do-template [  ]
   [(def:  (->  Text) )]
 
-  [show-boolean Boolean (:: bool.Codec encode)]
+  [show-boolean Boolean encode-boolean]
   [show-number  Number (:: number.Codec encode)]
   [show-string  String text.encode])
 
diff --git a/stdlib/source/lux/data/number.lux b/stdlib/source/lux/data/number.lux
index 773300f31..cb322299c 100644
--- a/stdlib/source/lux/data/number.lux
+++ b/stdlib/source/lux/data/number.lux
@@ -149,11 +149,11 @@
 
 (def: #export (not-a-number? number)
   {#.doc "Tests whether a frac is actually not-a-number."}
-  (-> Frac Bool)
+  (-> Frac Bit)
   (not (f/= number number)))
 
 (def: #export (frac? value)
-  (-> Frac Bool)
+  (-> Frac Bit)
   (not (or (not-a-number? value)
            (f/= positive-infinity value)
            (f/= negative-infinity value))))
@@ -574,7 +574,7 @@
 
 (do-template [    ]
   [(def: ( on-left? input)
-     (-> Bool Text Text)
+     (-> Bit Text Text)
      (let [max-num-chars (n//  +64)
            input-size ("lux text size" input)
            zero-padding (let [num-digits-that-need-padding (n/%  input-size)]
@@ -669,7 +669,7 @@
     (#e.Error "Wrong syntax for \"encoding-doc\".")))
 
 (def: (underscore-prefixed? number)
-  (-> Text Bool)
+  (-> Text Bit)
   (case ("lux text index" number "_" +0)
     (#.Some +0)
     true
@@ -827,7 +827,7 @@
       #.None)))
 
 (def: (digits-lt param subject)
-  (-> Digits Digits Bool)
+  (-> Digits Digits Bit)
   (loop [idx +0]
     (and (n/< i64.width idx)
          (let [pd (digits-get idx param)
diff --git a/stdlib/source/lux/data/number/complex.lux b/stdlib/source/lux/data/number/complex.lux
index 134801015..5c9c97d46 100644
--- a/stdlib/source/lux/data/number/complex.lux
+++ b/stdlib/source/lux/data/number/complex.lux
@@ -40,7 +40,7 @@
       (number.not-a-number? (get@ #imaginary complex))))
 
 (def: #export (= param input)
-  (-> Complex Complex Bool)
+  (-> Complex Complex Bit)
   (and (f/= (get@ #real param)
             (get@ #real input))
        (f/= (get@ #imaginary param)
diff --git a/stdlib/source/lux/data/number/i64.lux b/stdlib/source/lux/data/number/i64.lux
index 353a1237a..32b9df2e3 100644
--- a/stdlib/source/lux/data/number/i64.lux
+++ b/stdlib/source/lux/data/number/i64.lux
@@ -67,7 +67,7 @@
   )
 
 (def: #export (set? idx input)
-  (-> Nat (I64 Any) Bool)
+  (-> Nat (I64 Any) Bit)
   (|> input (:coerce I64) (..and (flag idx)) (n/= +0) .not))
 
 (do-template [ 
] diff --git a/stdlib/source/lux/data/number/ratio.lux b/stdlib/source/lux/data/number/ratio.lux index b1aed0cba..2aa332dc6 100644 --- a/stdlib/source/lux/data/number/ratio.lux +++ b/stdlib/source/lux/data/number/ratio.lux @@ -71,7 +71,7 @@ input))) (def: #export (= param input) - (-> Ratio Ratio Bool) + (-> Ratio Ratio Bit) (and (n/= (get@ #numerator param) (get@ #numerator input)) (n/= (get@ #denominator param) @@ -79,7 +79,7 @@ (do-template [ ] [(def: #export ( param input) - (-> Ratio Ratio Bool) + (-> Ratio Ratio Bit) (and ( (n/* (get@ #denominator input) (get@ #numerator param)) (n/* (get@ #denominator param) diff --git a/stdlib/source/lux/data/tainted.lux b/stdlib/source/lux/data/tainted.lux index 903b777d6..7ff754081 100644 --- a/stdlib/source/lux/data/tainted.lux +++ b/stdlib/source/lux/data/tainted.lux @@ -17,7 +17,7 @@ (|>> :representation))) (def: #export (validate pred tainted) - (All [a] (-> (-> a Bool) (Tainted a) (Maybe a))) + (All [a] (-> (-> a Bit) (Tainted a) (Maybe a))) (let [value (trust tainted)] (if (pred value) (#.Some value) diff --git a/stdlib/source/lux/data/text.lux b/stdlib/source/lux/data/text.lux index 3a9e6ab3b..8120f19d5 100644 --- a/stdlib/source/lux/data/text.lux +++ b/stdlib/source/lux/data/text.lux @@ -60,7 +60,7 @@ #.None)) (def: #export (starts-with? prefix x) - (-> Text Text Bool) + (-> Text Text Bit) (case (index-of prefix x) (#.Some +0) true @@ -69,7 +69,7 @@ false)) (def: #export (ends-with? postfix x) - (-> Text Text Bool) + (-> Text Text Bit) (case (last-index-of postfix x) (#.Some n) (n/= (size x) @@ -79,7 +79,7 @@ false)) (def: #export (contains? sub text) - (-> Text Text Bool) + (-> Text Text Bit) (case ("lux text index" text sub +0) (#.Some _) true @@ -200,7 +200,7 @@ (|> texts (list.interpose sep) concat)) (def: #export (empty? text) - (-> Text Bool) + (-> Text Bit) (case text "" true _ false)) @@ -234,7 +234,7 @@ (def: #export (space? char) {#.doc "Checks whether the character is white-space."} - (-> Nat Bool) + (-> Nat Bit) (case char (^or (^ (char "\t")) (^ (char "\v")) (^ (char " ")) (^ (char "\n")) diff --git a/stdlib/source/lux/data/text/format.lux b/stdlib/source/lux/data/text/format.lux index d32862024..4b9717fab 100644 --- a/stdlib/source/lux/data/text/format.lux +++ b/stdlib/source/lux/data/text/format.lux @@ -4,7 +4,7 @@ [monad (#+ do Monad)] ["p" parser]] [data - [bool] + [bit] [number] [text] [ident] @@ -39,7 +39,7 @@ (Format ) )] - [%b Bool (:: bool.Codec encode)] + [%b Bit (:: bit.Codec encode)] [%n Nat (:: number.Codec encode)] [%i Int (:: number.Codec encode)] [%r Rev (:: number.Codec encode)] diff --git a/stdlib/source/lux/data/text/lexer.lux b/stdlib/source/lux/data/text/lexer.lux index 13c49ef8f..d9b07db1e 100644 --- a/stdlib/source/lux/data/text/lexer.lux +++ b/stdlib/source/lux/data/text/lexer.lux @@ -78,7 +78,7 @@ (def: #export (this? reference) {#.doc "Lex a text if it matches the given sample."} - (-> Text (Lexer Bool)) + (-> Text (Lexer Bit)) (function (_ (^@ input [offset tape])) (case (text.index-of' reference offset tape) (^multi (#.Some where) (n/= offset where)) @@ -97,7 +97,7 @@ (def: #export end? {#.doc "Ask if the lexer's input is empty."} - (Lexer Bool) + (Lexer Bit) (function (_ (^@ input [offset tape])) (#e.Success [input (n/= offset (text.size tape))]))) @@ -190,7 +190,7 @@ (def: #export (satisfies p) {#.doc "Only lex characters that satisfy a predicate."} - (-> (-> Nat Bool) (Lexer Text)) + (-> (-> Nat Bit) (Lexer Text)) (function (_ [offset tape]) (case (text.nth offset tape) (#.Some output) diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux index 8b35b770c..107270225 100644 --- a/stdlib/source/lux/data/text/regex.lux +++ b/stdlib/source/lux/data/text/regex.lux @@ -260,7 +260,7 @@ (#Capturing [(Maybe Text) Nat])) (def: (re-sequential^ capturing? re-scoped^ current-module) - (-> Bool + (-> Bit (-> Text (l.Lexer [Re-Group Code])) Text (l.Lexer [Nat Code])) @@ -351,7 +351,7 @@ (` ((~! unflatten^) (~ alt))))) (def: (re-alternative^ capturing? re-scoped^ current-module) - (-> Bool + (-> Bit (-> Text (l.Lexer [Re-Group Code])) Text (l.Lexer [Nat Code])) diff --git a/stdlib/source/lux/data/text/unicode.lux b/stdlib/source/lux/data/text/unicode.lux index 10b9692ee..11c69be84 100644 --- a/stdlib/source/lux/data/text/unicode.lux +++ b/stdlib/source/lux/data/text/unicode.lux @@ -50,7 +50,7 @@ (|> end (n/- start) inc))) (def: #export (within? segment char) - (All [a] (-> Segment Char Bool)) + (All [a] (-> Segment Char Bit)) (interval.within? (:representation segment) char)) ) diff --git a/stdlib/source/lux/host.js.lux b/stdlib/source/lux/host.js.lux index b3758e3b5..022394f21 100644 --- a/stdlib/source/lux/host.js.lux +++ b/stdlib/source/lux/host.js.lux @@ -23,7 +23,7 @@ [String Text] [Number Frac] - [Boolean Bool] + [Boolean Bit] ) ## [Syntax] diff --git a/stdlib/source/lux/host.jvm.lux b/stdlib/source/lux/host.jvm.lux index 8639ea2c5..927f16c7d 100644 --- a/stdlib/source/lux/host.jvm.lux +++ b/stdlib/source/lux/host.jvm.lux @@ -13,7 +13,7 @@ [product] [text ("text/" Equivalence Monoid) format] - [bool ("bool/" Codec)]] + [bit ("bit/" Codec)]] [macro (#+ with-gensyms Functor Monad) [code] ["s" syntax (#+ syntax: Syntax)]] @@ -147,27 +147,27 @@ [GenericType Code]) (type: Method-Definition - (#ConstructorMethod [Bool + (#ConstructorMethod [Bit (List Type-Paramameter) (List ArgDecl) (List ConstructorArg) Code (List GenericType)]) - (#VirtualMethod [Bool - Bool + (#VirtualMethod [Bit + Bit (List Type-Paramameter) (List ArgDecl) GenericType Code (List GenericType)]) - (#OverridenMethod [Bool + (#OverridenMethod [Bit Class-Declaration (List Type-Paramameter) (List ArgDecl) GenericType Code (List GenericType)]) - (#StaticMethod [Bool + (#StaticMethod [Bit (List Type-Paramameter) (List ArgDecl) GenericType @@ -195,10 +195,10 @@ #import-member-alias Text #import-member-kind ImportMethodKind #import-member-tvars (List Type-Paramameter) - #import-member-args (List [Bool GenericType]) - #import-member-maybe? Bool - #import-member-try? Bool - #import-member-io? Bool}) + #import-member-args (List [Bit GenericType]) + #import-member-maybe? Bit + #import-member-try? Bit + #import-member-io? Bit}) (type: ImportConstructorDecl {}) @@ -210,9 +210,9 @@ (type: ImportFieldDecl {#import-field-mode Primitive-Mode #import-field-name Text - #import-field-static? Bool - #import-field-maybe? Bool - #import-field-setter? Bool + #import-field-static? Bit + #import-field-maybe? Bit + #import-field-setter? Bit #import-field-type GenericType}) (type: Import-Member-Declaration @@ -259,7 +259,7 @@ (^template [ ] (#.Some (' ))) - (["boolean" .Bool] + (["boolean" .Bit] ["byte" .Int] ["short" .Int] ["int" .Int] @@ -277,8 +277,8 @@ (def: (generic-class->type' mode type-params in-array? name+params class->type') - (-> Primitive-Mode (List Type-Paramameter) Bool [Text (List GenericType)] - (-> Primitive-Mode (List Type-Paramameter) Bool GenericType Code) + (-> Primitive-Mode (List Type-Paramameter) Bit [Text (List GenericType)] + (-> Primitive-Mode (List Type-Paramameter) Bit GenericType Code) Code) (case [name+params mode in-array?] (^multi [[prim #.Nil] #ManualPrM false] @@ -295,7 +295,7 @@ (` (primitive (~ (code.text name)) [(~+ =params)]))))) (def: (class->type' mode type-params in-array? class) - (-> Primitive-Mode (List Type-Paramameter) Bool GenericType Code) + (-> Primitive-Mode (List Type-Paramameter) Bit GenericType Code) (case class (#GenericTypeVar name) (case (list.find (function (_ [pname pbounds]) @@ -977,11 +977,11 @@ s.local-symbol))) (def: (import-member-args^ imports type-vars) - (-> Class-Imports (List Type-Paramameter) (Syntax (List [Bool GenericType]))) + (-> Class-Imports (List Type-Paramameter) (Syntax (List [Bit GenericType]))) (s.tuple (p.some (p.seq (s.this? (' #?)) (generic-type^ imports type-vars))))) (def: import-member-return-flags^ - (Syntax [Bool Bool Bool]) + (Syntax [Bit Bit Bit]) ($_ p.seq (s.this? (' #io)) (s.this? (' #try)) (s.this? (' #?)))) (def: primitive-mode^ @@ -1181,7 +1181,7 @@ (with-parens (spaced (list "init" (privacy-modifier$ pm) - (bool/encode strict-fp?) + (bit/encode strict-fp?) (with-brackets (spaced (list/map annotation$ anns))) (with-brackets (spaced (list/map type-param$ type-vars))) (with-brackets (spaced (list/map generic-type$ exs))) @@ -1195,8 +1195,8 @@ (spaced (list "virtual" name (privacy-modifier$ pm) - (bool/encode final?) - (bool/encode strict-fp?) + (bit/encode final?) + (bit/encode strict-fp?) (with-brackets (spaced (list/map annotation$ anns))) (with-brackets (spaced (list/map type-param$ type-vars))) (with-brackets (spaced (list/map generic-type$ exs))) @@ -1216,7 +1216,7 @@ (spaced (list "override" (class-decl$ class-decl) name - (bool/encode strict-fp?) + (bit/encode strict-fp?) (with-brackets (spaced (list/map annotation$ anns))) (with-brackets (spaced (list/map type-param$ type-vars))) (with-brackets (spaced (list/map generic-type$ exs))) @@ -1233,7 +1233,7 @@ (spaced (list "static" name (privacy-modifier$ pm) - (bool/encode strict-fp?) + (bit/encode strict-fp?) (with-brackets (spaced (list/map annotation$ anns))) (with-brackets (spaced (list/map type-param$ type-vars))) (with-brackets (spaced (list/map generic-type$ exs))) @@ -1398,7 +1398,7 @@ (null? "YOLO") "=>" false)} - (-> (primitive "java.lang.Object") Bool) + (-> (primitive "java.lang.Object") Bit) ("jvm object null?" obj)) (syntax: #export (??? expr) @@ -1454,7 +1454,7 @@ (do @ [g!_ (macro.gensym "_") g!obj (macro.gensym "obj")] - (wrap (list (` (: (-> (primitive "java.lang.Object") Bool) + (wrap (list (` (: (-> (primitive "java.lang.Object") Bit) (function ((~ g!_) (~ g!obj)) ((~ (code.text (format "jvm instanceof" ":" (simple-class$ (list) class)))) (~ g!obj)))))))) )) @@ -1480,7 +1480,7 @@ (~ g!obj)))))))) (def: (class-import$ long-name? [full-name params]) - (-> Bool Class-Declaration Code) + (-> Bit Class-Declaration Code) (let [def-name (if long-name? full-name (short-class-name full-name)) @@ -1517,7 +1517,7 @@ (let [(^slots [#import-member-tvars #import-member-args]) commons] (do Monad [arg-inputs (monad.map @ - (: (-> [Bool GenericType] (Meta [Code Code])) + (: (-> [Bit GenericType] (Meta [Code Code])) (function (_ [maybe? _]) (with-gensyms [arg-name] (wrap [arg-name (if maybe? @@ -1527,7 +1527,7 @@ #let [arg-classes (: (List Text) (list/map (|>> product.right (simple-class$ (list/compose type-params import-member-tvars))) import-member-args)) - arg-types (list/map (: (-> [Bool GenericType] Code) + arg-types (list/map (: (-> [Bit GenericType] Code) (function (_ [maybe? arg]) (let [arg-type (class->type (get@ #import-member-mode commons) type-params arg)] (if maybe? @@ -1588,7 +1588,7 @@ ) (def: (free-type-param? [name bounds]) - (-> Type-Paramameter Bool) + (-> Type-Paramameter Bit) (case bounds #.Nil true _ false)) @@ -1621,7 +1621,7 @@ body))) (def: (auto-conv-class? class) - (-> Text Bool) + (-> Text Bit) (case class (^or "byte" "short" "int" "float") true @@ -1828,7 +1828,7 @@ ))) (def: (member-import$ type-params long-name? kind class member) - (-> (List Type-Paramameter) Bool Class-Kind Class-Declaration Import-Member-Declaration (Meta (List Code))) + (-> (List Type-Paramameter) Bit Class-Kind Class-Declaration Import-Member-Declaration (Meta (List Code))) (let [[full-name _] class method-prefix (if long-name? full-name @@ -1838,7 +1838,7 @@ (member-def-interop type-params kind class =args member method-prefix)))) (def: (interface? class) - (All [a] (-> (primitive "java.lang.Class" [a]) Bool)) + (All [a] (-> (primitive "java.lang.Class" [a]) Bit)) ("jvm invokevirtual:java.lang.Class:isInterface:" class)) (def: (load-class class-name) diff --git a/stdlib/source/lux/language/compiler/analysis.lux b/stdlib/source/lux/language/compiler/analysis.lux index 0ca620e42..e9eb3b921 100644 --- a/stdlib/source/lux/language/compiler/analysis.lux +++ b/stdlib/source/lux/language/compiler/analysis.lux @@ -13,7 +13,7 @@ (type: #export #rec Primitive #Unit - (#Bool Bool) + (#Bit Bit) (#Nat Nat) (#Int Int) (#Rev Rev) @@ -80,7 +80,7 @@ (-> Analysis) (|>> #Primitive))] - [bool Bool #Bool] + [bit Bit #Bit] [nat Nat #Nat] [int Int #Int] [rev Rev #Rev] @@ -90,7 +90,7 @@ (type: #export (Variant a) {#lefts Nat - #right? Bool + #right? Bit #value a}) (type: #export (Tuple a) (List a)) @@ -102,7 +102,7 @@ (type: #export (Application c) [c (List c)]) (def: (last? size tag) - (-> Nat Tag Bool) + (-> Nat Tag Bit) (n/= (dec size) tag)) (template: #export (no-op value) @@ -215,7 +215,7 @@ [(template: #export ( content) (#..Simple ( content)))] - [pattern/bool #..Bool] + [pattern/bit #..Bit] [pattern/nat #..Nat] [pattern/int #..Int] [pattern/rev #..Rev] diff --git a/stdlib/source/lux/language/compiler/analysis/case.lux b/stdlib/source/lux/language/compiler/analysis/case.lux index 760ea3b03..2f5162fbd 100644 --- a/stdlib/source/lux/language/compiler/analysis/case.lux +++ b/stdlib/source/lux/language/compiler/analysis/case.lux @@ -163,7 +163,7 @@ (^template [ ] [cursor ] (analyse-primitive inputT cursor (#//.Simple ) next)) - ([Bool (#.Bool pattern-value) (#//.Bool pattern-value)] + ([Bit (#.Bit pattern-value) (#//.Bit pattern-value)] [Nat (#.Nat pattern-value) (#//.Nat pattern-value)] [Int (#.Int pattern-value) (#//.Int pattern-value)] [Rev (#.Rev pattern-value) (#//.Rev pattern-value)] diff --git a/stdlib/source/lux/language/compiler/analysis/case/coverage.lux b/stdlib/source/lux/language/compiler/analysis/case/coverage.lux index bce8512e5..b718c382d 100644 --- a/stdlib/source/lux/language/compiler/analysis/case/coverage.lux +++ b/stdlib/source/lux/language/compiler/analysis/case/coverage.lux @@ -5,7 +5,7 @@ ["ex" exception (#+ exception:)] equivalence] [data - [bool ("bool/" Equivalence)] + [bit ("bit/" Equivalence)] [number] ["e" error ("error/" Monad)] [maybe] @@ -50,18 +50,18 @@ ## as insuficient (since it could lead to runtime errors due to values ## not being handled by any pattern). ## The #Partial tag covers arbitrary partial coverages in a general -## way, while the other tags cover more specific cases for booleans +## way, while the other tags cover more specific cases for bits ## and variants. (type: #export #rec Coverage #Partial - (#Bool Bool) + (#Bit Bit) (#Variant (Maybe Nat) (Dictionary Nat Coverage)) (#Seq Coverage Coverage) (#Alt Coverage Coverage) #Exhaustive) (def: #export (exhaustive? coverage) - (-> Coverage Bool) + (-> Coverage Bit) (case coverage (#Exhaustive _) true @@ -87,11 +87,11 @@ [#///.Frac] [#///.Text]) - ## Bools are the exception, since there is only "true" and - ## "false", which means it is possible for boolean + ## Bits are the exception, since there is only "true" and + ## "false", which means it is possible for bit ## pattern-matching to become exhaustive if complementary parts meet. - (#///.Simple (#///.Bool value)) - (operation/wrap (#Bool value)) + (#///.Simple (#///.Bit value)) + (operation/wrap (#Bit value)) ## Tuple patterns can be exhaustive if there is exhaustiveness for all of ## their sub-patterns. @@ -122,7 +122,7 @@ (dict.put variant-idx value-coverage)))))))) (def: (xor left right) - (-> Bool Bool Bool) + (-> Bit Bit Bit) (or (and left (not right)) (and (not left) right))) @@ -151,8 +151,8 @@ [#Exhaustive #Exhaustive] true - [(#Bool sideR) (#Bool sideS)] - (bool/= sideR sideS) + [(#Bit sideR) (#Bit sideS)] + (bit/= sideR sideS) [(#Variant allR casesR) (#Variant allS casesS)] (and (n/= (cases allR) @@ -194,8 +194,8 @@ [#Partial #Partial] (error/wrap #Partial) - ## 2 boolean coverages are exhaustive if they compliment one another. - (^multi [(#Bool sideA) (#Bool sideSF)] + ## 2 bit coverages are exhaustive if they complement one another. + (^multi [(#Bit sideA) (#Bit sideSF)] (xor sideA sideSF)) (error/wrap #Exhaustive) diff --git a/stdlib/source/lux/language/compiler/analysis/expression.lux b/stdlib/source/lux/language/compiler/analysis/expression.lux index 1c5c8794c..f413b8077 100644 --- a/stdlib/source/lux/language/compiler/analysis/expression.lux +++ b/stdlib/source/lux/language/compiler/analysis/expression.lux @@ -44,7 +44,7 @@ (^template [ ] ( value) ( value)) - ([#.Bool primitive.bool] + ([#.Bit primitive.bit] [#.Nat primitive.nat] [#.Int primitive.int] [#.Rev primitive.rev] diff --git a/stdlib/source/lux/language/compiler/analysis/module.lux b/stdlib/source/lux/language/compiler/analysis/module.lux index 2a2aef5c3..bdc4abf05 100644 --- a/stdlib/source/lux/language/compiler/analysis/module.lux +++ b/stdlib/source/lux/language/compiler/analysis/module.lux @@ -102,7 +102,7 @@ []]))))) (def: #export (exists? module) - (-> Text (Operation Bool)) + (-> Text (Operation Bit)) (extension.lift (function (_ state) (|> state @@ -173,7 +173,7 @@ ((///.throw unknown-module module-name) state))))) (def: #export ( module-name) - (-> Text (Operation Bool)) + (-> Text (Operation Bit)) (extension.lift (function (_ state) (case (|> state (get@ #.modules) (plist.get module-name)) @@ -203,8 +203,8 @@ #.None ((///.throw unknown-module module-name) state)))))] - [tags #.tags (List [Text [Nat (List Ident) Bool Type]])] - [types #.types (List [Text [(List Ident) Bool Type]])] + [tags #.tags (List [Text [Nat (List Ident) Bit Type]])] + [types #.types (List [Text [(List Ident) Bit Type]])] [hash #.module-hash Nat] ) @@ -224,7 +224,7 @@ (wrap []))) (def: #export (declare-tags tags exported? type) - (-> (List Tag) Bool Type (Operation Any)) + (-> (List Tag) Bit Type (Operation Any)) (do ///.Monad [self-name (extension.lift macro.current-module-name) [type-module type-name] (case type diff --git a/stdlib/source/lux/language/compiler/analysis/primitive.lux b/stdlib/source/lux/language/compiler/analysis/primitive.lux index eabbcb7d8..346906909 100644 --- a/stdlib/source/lux/language/compiler/analysis/primitive.lux +++ b/stdlib/source/lux/language/compiler/analysis/primitive.lux @@ -14,7 +14,7 @@ [_ (typeA.infer )] (wrap (#//.Primitive ( value)))))] - [bool Bool #//.Bool] + [bit Bit #//.Bit] [nat Nat #//.Nat] [int Int #//.Int] [rev Rev #//.Rev] diff --git a/stdlib/source/lux/language/compiler/analysis/scope.lux b/stdlib/source/lux/language/compiler/analysis/scope.lux index 2468ede27..3ee0499e8 100644 --- a/stdlib/source/lux/language/compiler/analysis/scope.lux +++ b/stdlib/source/lux/language/compiler/analysis/scope.lux @@ -21,7 +21,7 @@ (type: Foreign (Bindings Text [Type Variable])) (def: (local? name scope) - (-> Text Scope Bool) + (-> Text Scope Bit) (|> scope (get@ [#.locals #.mappings]) (plist.contains? name))) @@ -35,7 +35,7 @@ [type (#reference.Local value)])))) (def: (captured? name scope) - (-> Text Scope Bool) + (-> Text Scope Bit) (|> scope (get@ [#.captured #.mappings]) (plist.contains? name))) @@ -54,7 +54,7 @@ (recur (inc idx) mappings'))))) (def: (reference? name scope) - (-> Text Scope Bool) + (-> Text Scope Bit) (or (local? name scope) (captured? name scope))) diff --git a/stdlib/source/lux/language/compiler/default/repl/type.lux b/stdlib/source/lux/language/compiler/default/repl/type.lux index 84f063e0c..c9b68c06e 100644 --- a/stdlib/source/lux/language/compiler/default/repl/type.lux +++ b/stdlib/source/lux/language/compiler/default/repl/type.lux @@ -40,7 +40,7 @@ [_ (poly.similar )] (wrap (|>> (:coerce ) )))] - [Bool %b] + [Bit %b] [Nat %n] [Int %i] [Rev %r] diff --git a/stdlib/source/lux/language/compiler/extension/analysis/common.lux b/stdlib/source/lux/language/compiler/extension/analysis/common.lux index 55d479052..9616f2533 100644 --- a/stdlib/source/lux/language/compiler/extension/analysis/common.lux +++ b/stdlib/source/lux/language/compiler/extension/analysis/common.lux @@ -63,7 +63,7 @@ (function (_ extension-name analyse args) (do ////.Monad [[var-id varT] (typeA.with-env tc.var)] - ((binary varT varT Bool extension-name) + ((binary varT varT Bit extension-name) analyse args)))) ## "lux try" provides a simple way to interact with the host platform's @@ -167,8 +167,8 @@ (bundle.install "*" (binary Int Int Int)) (bundle.install "/" (binary Int Int Int)) (bundle.install "%" (binary Int Int Int)) - (bundle.install "=" (binary Int Int Bool)) - (bundle.install "<" (binary Int Int Bool)) + (bundle.install "=" (binary Int Int Bit)) + (bundle.install "<" (binary Int Int Bit)) (bundle.install "to-frac" (unary Int Frac)) (bundle.install "char" (unary Int Text))))) @@ -181,8 +181,8 @@ (bundle.install "*" (binary Frac Frac Frac)) (bundle.install "/" (binary Frac Frac Frac)) (bundle.install "%" (binary Frac Frac Frac)) - (bundle.install "=" (binary Frac Frac Bool)) - (bundle.install "<" (binary Frac Frac Bool)) + (bundle.install "=" (binary Frac Frac Bit)) + (bundle.install "<" (binary Frac Frac Bit)) (bundle.install "smallest" (nullary Frac)) (bundle.install "min" (nullary Frac)) (bundle.install "max" (nullary Frac)) @@ -195,8 +195,8 @@ Bundle (<| (bundle.prefix "text") (|> bundle.empty - (bundle.install "=" (binary Text Text Bool)) - (bundle.install "<" (binary Text Text Bool)) + (bundle.install "=" (binary Text Text Bit)) + (bundle.install "<" (binary Text Text Bit)) (bundle.install "concat" (binary Text Text Text)) (bundle.install "index" (trinary Text Text Nat (type (Maybe Nat)))) (bundle.install "size" (unary Text Nat)) @@ -289,7 +289,7 @@ (function (_ extension-name analyse args) (do ////.Monad [[var-id varT] (typeA.with-env tc.var)] - ((trinary (type (Atom varT)) varT varT Bool extension-name) + ((trinary (type (Atom varT)) varT varT Bit extension-name) analyse args)))) (def: bundle::atom diff --git a/stdlib/source/lux/language/compiler/extension/analysis/host.jvm.lux b/stdlib/source/lux/language/compiler/extension/analysis/host.jvm.lux index d25be6e40..876448b5b 100644 --- a/stdlib/source/lux/language/compiler/extension/analysis/host.jvm.lux +++ b/stdlib/source/lux/language/compiler/extension/analysis/host.jvm.lux @@ -167,8 +167,8 @@ (bundle.install "*" (common.binary )) (bundle.install "/" (common.binary )) (bundle.install "%" (common.binary )) - (bundle.install "=" (common.binary Boolean)) - (bundle.install "<" (common.binary Boolean)) + (bundle.install "=" (common.binary Bit)) + (bundle.install "<" (common.binary Bit)) (bundle.install "and" (common.binary )) (bundle.install "or" (common.binary )) (bundle.install "xor" (common.binary )) @@ -191,8 +191,8 @@ (bundle.install "*" (common.binary )) (bundle.install "/" (common.binary )) (bundle.install "%" (common.binary )) - (bundle.install "=" (common.binary Boolean)) - (bundle.install "<" (common.binary Boolean)) + (bundle.install "=" (common.binary Bit)) + (bundle.install "<" (common.binary Bit)) )))] [bundle::float "float" Float] @@ -203,8 +203,8 @@ Bundle (<| (bundle.prefix "char") (|> bundle.empty - (bundle.install "=" (common.binary Character Character Boolean)) - (bundle.install "<" (common.binary Character Character Boolean)) + (bundle.install "=" (common.binary Character Character Bit)) + (bundle.install "<" (common.binary Character Character Bit)) ))) (def: #export boxes @@ -398,7 +398,7 @@ (case args (^ (list objectC)) (do ////.Monad - [_ (typeA.infer Bool) + [_ (typeA.infer Bit) [objectT objectA] (typeA.with-inference (analyse objectC)) _ (check-object objectT)] @@ -493,7 +493,7 @@ (////.throw unknown-class name)))) (def: (sub-class? super sub) - (-> Text Text (Operation Bool)) + (-> Text Text (Operation Bit)) (do ////.Monad [super (load-class super) sub (load-class sub)] @@ -545,7 +545,7 @@ (case classC [_ (#.Text class)] (do ////.Monad - [_ (typeA.infer Bool) + [_ (typeA.infer Bit) [objectT objectA] (typeA.with-inference (analyse objectC)) object-class (check-object objectT) @@ -674,7 +674,7 @@ [valueT valueA] (typeA.with-inference (analyse valueC)) from-name (check-jvm valueT) - can-cast? (: (Operation Bool) + can-cast? (: (Operation Bit) (case [from-name to-name] (^template [ ] (^or [ ] @@ -773,7 +773,7 @@ (////.throw unknown-field (format class-name "#" field-name))))) (def: (static-field class-name field-name) - (-> Text Text (Operation [Type Bool])) + (-> Text Text (Operation [Type Bit])) (do ////.Monad [[class fieldJ] (find-field class-name field-name) #let [modifiers (Field::getModifiers [] fieldJ)]] @@ -785,7 +785,7 @@ (////.throw not-a-static-field (format class-name "#" field-name))))) (def: (virtual-field class-name field-name objectT) - (-> Text Text Type (Operation [Type Bool])) + (-> Text Text Type (Operation [Type Bit])) (do ////.Monad [[class fieldJ] (find-field class-name field-name) #let [modifiers (Field::getModifiers [] fieldJ)]] @@ -927,7 +927,7 @@ #Interface) (def: (check-method class method-name method-style arg-classes method) - (-> (Class Object) Text Method-Style (List Text) Method (Operation Bool)) + (-> (Class Object) Text Method-Style (List Text) Method (Operation Bit)) (do ////.Monad [parameters (|> (Method::getGenericParameterTypes [] method) array.to-list @@ -956,7 +956,7 @@ (list.zip2 arg-classes parameters)))))) (def: (check-constructor class arg-classes constructor) - (-> (Class Object) (List Text) (Constructor Object) (Operation Bool)) + (-> (Class Object) (List Text) (Constructor Object) (Operation Bit)) (do ////.Monad [parameters (|> (Constructor::getGenericParameterTypes [] constructor) array.to-list diff --git a/stdlib/source/lux/language/compiler/meta/cache.lux b/stdlib/source/lux/language/compiler/meta/cache.lux index 753a66e89..4a35d81d4 100644 --- a/stdlib/source/lux/language/compiler/meta/cache.lux +++ b/stdlib/source/lux/language/compiler/meta/cache.lux @@ -5,7 +5,7 @@ ["ex" exception (#+ exception:)] pipe] [data - [bool ("bool/" Equivalence)] + [bit ("bit/" Equivalence)] [maybe] [error] [product] @@ -82,7 +82,7 @@ (do @ [_ (..delete System file)] (wrap true))))))] - [(list.every? (bool/= true)) + [(list.every? (bit/= true)) (if> [(..delete System document)] [(wrap [])])])))) @@ -91,7 +91,7 @@ (|> root (do> (:: System &monad) [(..cached System)] - [(list.filter (bool.complement (set.member? wanted-modules))) + [(list.filter (bit.complement (set.member? wanted-modules))) (monad.map @ (un-install System root))]))) ## Load diff --git a/stdlib/source/lux/language/compiler/synthesis.lux b/stdlib/source/lux/language/compiler/synthesis.lux index 05be98f3c..202260fa2 100644 --- a/stdlib/source/lux/language/compiler/synthesis.lux +++ b/stdlib/source/lux/language/compiler/synthesis.lux @@ -15,7 +15,7 @@ (type: #export State {#scope-arity Arity #resolver Resolver - #direct? Bool + #direct? Bit #locals Nat}) (def: #export fresh-resolver @@ -30,7 +30,7 @@ #locals +0}) (type: #export Primitive - (#Bool Bool) + (#Bit Bit) (#I64 I64) (#F64 Frac) (#Text Text)) @@ -110,7 +110,7 @@ [(template: #export ( content) (#..Test ( content)))] - [path/bool #..Bool] + [path/bit #..Bit] [path/i64 #..I64] [path/f64 #..F64] [path/text #..Text] @@ -187,7 +187,7 @@ [scope-arity #scope-arity Arity] [resolver #resolver Resolver] - [direct? #direct? Bool] + [direct? #direct? Bit] [locals #locals Nat] ) @@ -201,7 +201,7 @@ [(template: #export ( content) (#..Primitive ( content)))] - [bool #..Bool] + [bit #..Bit] [i64 #..I64] [f64 #..F64] [text #..Text] diff --git a/stdlib/source/lux/language/compiler/synthesis/case.lux b/stdlib/source/lux/language/compiler/synthesis/case.lux index de7a4f9fd..0c23d1f52 100644 --- a/stdlib/source/lux/language/compiler/synthesis/case.lux +++ b/stdlib/source/lux/language/compiler/synthesis/case.lux @@ -6,7 +6,7 @@ [monad (#+ do)]] [data [product] - [bool ("bool/" Equivalence)] + [bit ("bit/" Equivalence)] [text ("text/" Equivalence) format] [number ("frac/" Equivalence)] @@ -30,7 +30,7 @@ ( value) (operation/map (|>> (#//.Seq (#//.Test (|> value )))) bodyC)) - ([#analysis.Bool #//.Bool] + ([#analysis.Bit #//.Bit] [#analysis.Nat (<| #//.I64 .i64)] [#analysis.Int (<| #//.I64 .i64)] [#analysis.Rev (<| #//.I64 .i64)] @@ -101,7 +101,7 @@ (if ( leftV rightV) rightP )) - ([#//.Bool bool/=] + ([#//.Bit bit/=] [#//.I64 (:coerce (Equivalence I64) i/=)] [#//.F64 frac/=] [#//.Text text/=]) @@ -152,10 +152,10 @@ headB/bodyS]))))) - (as-is (^or (^ [[(analysis.pattern/bool true) thenA] - (list [(analysis.pattern/bool false) elseA])]) - (^ [[(analysis.pattern/bool false) elseA] - (list [(analysis.pattern/bool true) thenA])])) + (as-is (^or (^ [[(analysis.pattern/bit true) thenA] + (list [(analysis.pattern/bit false) elseA])]) + (^ [[(analysis.pattern/bit false) elseA] + (list [(analysis.pattern/bit true) thenA])])) (do @ [thenS (synthesize^ thenA) elseS (synthesize^ elseA)] diff --git a/stdlib/source/lux/language/compiler/synthesis/expression.lux b/stdlib/source/lux/language/compiler/synthesis/expression.lux index 80480de68..0d780d444 100644 --- a/stdlib/source/lux/language/compiler/synthesis/expression.lux +++ b/stdlib/source/lux/language/compiler/synthesis/expression.lux @@ -29,7 +29,7 @@ (^template [ ] ( value) ( value)) - ([#analysis.Bool #//.Bool] + ([#analysis.Bit #//.Bit] [#analysis.Frac #//.F64] [#analysis.Text #//.Text]) diff --git a/stdlib/source/lux/language/compiler/synthesis/function.lux b/stdlib/source/lux/language/compiler/synthesis/function.lux index 92e75dc94..67f0dda46 100644 --- a/stdlib/source/lux/language/compiler/synthesis/function.lux +++ b/stdlib/source/lux/language/compiler/synthesis/function.lux @@ -19,11 +19,11 @@ [analysis (#+ Environment Arity Analysis)]]]]) (def: #export nested? - (-> Arity Bool) + (-> Arity Bit) (n/> +1)) (def: #export (adjust up-arity after? var) - (-> Arity Bool Variable Variable) + (-> Arity Bit Variable Variable) (case var (#reference.Local register) (if (and after? (n/>= up-arity register)) diff --git a/stdlib/source/lux/language/compiler/synthesis/loop.lux b/stdlib/source/lux/language/compiler/synthesis/loop.lux index 564fe5421..eeb1adcc7 100644 --- a/stdlib/source/lux/language/compiler/synthesis/loop.lux +++ b/stdlib/source/lux/language/compiler/synthesis/loop.lux @@ -19,7 +19,7 @@ (-> a (Maybe a))) (def: (some? maybe) - (All [a] (-> (Maybe a) Bool)) + (All [a] (-> (Maybe a) Bit)) (case maybe (#.Some _) true #.None false)) @@ -30,11 +30,11 @@ (template: (recursive-apply args) (#//.Apply (self) args)) -(def: proper Bool true) -(def: improper Bool false) +(def: proper Bit true) +(def: improper Bit false) (def: (proper? exprS) - (-> Synthesis Bool) + (-> Synthesis Bit) (case exprS (^ (self)) improper diff --git a/stdlib/source/lux/language/compiler/translation/scheme/case.jvm.lux b/stdlib/source/lux/language/compiler/translation/scheme/case.jvm.lux index 3ef368c18..f7b1adb7a 100644 --- a/stdlib/source/lux/language/compiler/translation/scheme/case.jvm.lux +++ b/stdlib/source/lux/language/compiler/translation/scheme/case.jvm.lux @@ -28,7 +28,7 @@ bodyO)))) (def: #export (record-get translate valueS pathP) - (-> Compiler Synthesis (List [Nat Bool]) + (-> Compiler Synthesis (List [Nat Bit]) (Operation Expression)) (do compiler.Monad [valueO (translate valueS)] @@ -118,7 +118,7 @@ (^ ( value)) (operation/wrap (_.when (|> value (<=> cursor-top) _.not/1) fail-pm!))) - ([synthesis.path/bool _.bool _.eqv?/2] + ([synthesis.path/bit _.bool _.eqv?/2] [synthesis.path/i64 _.int _.=/2] [synthesis.path/f64 _.float _.=/2] [synthesis.path/text _.string _.eqv?/2]) diff --git a/stdlib/source/lux/language/compiler/translation/scheme/expression.jvm.lux b/stdlib/source/lux/language/compiler/translation/scheme/expression.jvm.lux index d7ef01e61..3cbefbf69 100644 --- a/stdlib/source/lux/language/compiler/translation/scheme/expression.jvm.lux +++ b/stdlib/source/lux/language/compiler/translation/scheme/expression.jvm.lux @@ -19,7 +19,7 @@ (^template [ ] (^ ( value)) ( value)) - ([synthesis.bool primitive.bool] + ([synthesis.bit primitive.bit] [synthesis.i64 primitive.i64] [synthesis.f64 primitive.f64] [synthesis.text primitive.text]) diff --git a/stdlib/source/lux/language/compiler/translation/scheme/primitive.jvm.lux b/stdlib/source/lux/language/compiler/translation/scheme/primitive.jvm.lux index fea12c6c3..6ff146393 100644 --- a/stdlib/source/lux/language/compiler/translation/scheme/primitive.jvm.lux +++ b/stdlib/source/lux/language/compiler/translation/scheme/primitive.jvm.lux @@ -6,8 +6,8 @@ [host ["_" scheme (#+ Expression)]]] [//runtime (#+ Operation)]) -(def: #export bool - (-> Bool (Operation Expression)) +(def: #export bit + (-> Bit (Operation Expression)) (|>> _.bool operation/wrap)) (def: #export i64 diff --git a/stdlib/source/lux/language/compiler/translation/scheme/runtime.jvm.lux b/stdlib/source/lux/language/compiler/translation/scheme/runtime.jvm.lux index a1ce941d2..a84677144 100644 --- a/stdlib/source/lux/language/compiler/translation/scheme/runtime.jvm.lux +++ b/stdlib/source/lux/language/compiler/translation/scheme/runtime.jvm.lux @@ -33,7 +33,7 @@ (def: #export variant-tag "lux-variant") (def: (flag value) - (-> Bool Computation) + (-> Bit Computation) (if value (_.string "") _.nil)) diff --git a/stdlib/source/lux/language/host/scheme.lux b/stdlib/source/lux/language/host/scheme.lux index f93f3b671..d2edd6fac 100644 --- a/stdlib/source/lux/language/host/scheme.lux +++ b/stdlib/source/lux/language/host/scheme.lux @@ -62,7 +62,7 @@ (:abstraction "'()")) (def: #export bool - (-> Bool Computation) + (-> Bit Computation) (|>> (case> true "#t" false "#f") :abstraction)) diff --git a/stdlib/source/lux/language/reference.lux b/stdlib/source/lux/language/reference.lux index 0e66497a1..0f4ee03a5 100644 --- a/stdlib/source/lux/language/reference.lux +++ b/stdlib/source/lux/language/reference.lux @@ -58,7 +58,7 @@ (def: #export self Reference (..local +0)) (def: #export self? - (-> Variable Bool) + (-> Variable Bit) (|>> ..variable (case> (^ (..local +0)) true diff --git a/stdlib/source/lux/language/syntax.lux b/stdlib/source/lux/language/syntax.lux index e924694c3..e31356dcb 100644 --- a/stdlib/source/lux/language/syntax.lux +++ b/stdlib/source/lux/language/syntax.lux @@ -580,7 +580,7 @@ [where (case value (^template [ ] ["" ] - (#.Bool )) + (#.Bit )) (["true" true] ["false" false]) @@ -591,9 +591,9 @@ module) (exception: #export (unrecognized-input {[file line column] Cursor}) - (format " File: " file "\n" - " Line: " (%n line) "\n" - "Column: " (%n column) "\n")) + (ex.report ["File" file] + ["Line" (%n line)] + ["Column" (%n column)])) (def: (ast current-module aliases) (-> Text Aliases Cursor (l.Lexer [Cursor Code])) diff --git a/stdlib/source/lux/language/type.lux b/stdlib/source/lux/language/type.lux index 09c30fd03..cdb43422d 100644 --- a/stdlib/source/lux/language/type.lux +++ b/stdlib/source/lux/language/type.lux @@ -313,7 +313,7 @@ ) (def: #export (quantified? type) - (-> Type Bool) + (-> Type Bit) (case type (#.Named [module name] _type) (quantified? _type) diff --git a/stdlib/source/lux/language/type/check.lux b/stdlib/source/lux/language/type/check.lux index 60864008f..3308c497b 100644 --- a/stdlib/source/lux/language/type/check.lux +++ b/stdlib/source/lux/language/type/check.lux @@ -39,7 +39,7 @@ (type: #export Assumption {#subsumption [Type Type] - #verdict Bool}) + #verdict Bit}) (type: #export (Check a) (-> Type-Context (e.Error [Type-Context a]))) @@ -186,7 +186,7 @@ #.None (ex.throw unknown-type-var id))))] - [bound? Bool false true] + [bound? Bit false true] [read (Maybe Type) #.None (#.Some bound)] ) @@ -320,7 +320,7 @@ (#e.Error message))) (def: #export (assert message test) - (-> Text Bool (Check Any)) + (-> Text Bit (Check Any)) (function (_ context) (if test (#e.Success [context []]) @@ -337,7 +337,7 @@ (right context)))) (def: (assumed? [e a] assumptions) - (-> [Type Type] (List Assumption) (Maybe Bool)) + (-> [Type Type] (List Assumption) (Maybe Bit)) (:: maybe.Monad map product.right (list.find (function (_ [[fe fa] status]) (and (type/= e fe) @@ -345,7 +345,7 @@ assumptions))) (def: (assume! ea status assumptions) - (-> [Type Type] Bool (List Assumption) (List Assumption)) + (-> [Type Type] Bit (List Assumption) (List Assumption)) (#.Cons [ea status] assumptions)) (def: (on id type then else) @@ -633,7 +633,7 @@ (def: #export (checks? expected actual) {#.doc "A simple type-checking function that just returns a yes/no answer."} - (-> Type Type Bool) + (-> Type Type Bit) (case (run fresh-context (check expected actual)) (#e.Error error) false diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux index a39168fa7..d063f1ab2 100644 --- a/stdlib/source/lux/macro.lux +++ b/stdlib/source/lux/macro.lux @@ -98,7 +98,7 @@ (def: #export (assert message test) {#.doc "Fails with the given message if the test is false."} - (-> Text Bool (Meta Any)) + (-> Text Bit (Meta Any)) (function (_ compiler) (if test (#e.Success [compiler []]) @@ -171,7 +171,7 @@ _ #.None))] - [get-bool-ann #.Bool Bool] + [get-bit-ann #.Bit Bit] [get-int-ann #.Int Int] [get-frac-ann #.Frac Frac] [get-text-ann #.Text Text] @@ -189,13 +189,13 @@ (def: #export (flag-set? flag-name anns) {#.doc "Finds out whether an annotation-as-a-flag is set (has value 'true')."} - (-> Ident Code Bool) - (maybe.default false (get-bool-ann flag-name anns))) + (-> Ident Code Bit) + (maybe.default false (get-bit-ann flag-name anns))) (do-template [ ] [(def: #export {#.doc (code.text ($_ text/compose "Checks whether a definition is " "."))} - (-> Code Bool) + (-> Code Bit) (flag-set? (ident-for )))] [export? #.export? "exported"] @@ -207,7 +207,7 @@ ) (def: #export (aliased? annotations) - (-> Code Bool) + (-> Code Bit) (case (get-symbol-ann (ident-for #.alias) annotations) (#.Some _) true @@ -417,7 +417,7 @@ (fail "Macro expanded to more than 1 element.")))) (def: #export (module-exists? module) - (-> Text (Meta Bool)) + (-> Text (Meta Bit)) (function (_ compiler) (#e.Success [compiler (case (get module (get@ #.modules compiler)) (#.Some _) @@ -465,7 +465,7 @@ {#.doc "Looks-up the type of a local variable somewhere in the environment."} (-> Text (Meta Type)) (function (_ compiler) - (let [test (: (-> [Text [Type Any]] Bool) + (let [test (: (-> [Text [Type Any]] Bit) (|>> product.left (text/= name)))] (case (do maybe.Monad [scope (list.find (function (_ env) @@ -607,13 +607,13 @@ (wrap imports))) (def: #export (imported-by? import module) - (-> Text Text (Meta Bool)) + (-> Text Text (Meta Bit)) (do Monad [(^slots [#.imports]) (find-module module)] (wrap (list.any? (text/= import) imports)))) (def: #export (imported? import) - (-> Text (Meta Bool)) + (-> Text (Meta Bit)) (let [(^open) Monad] (|> current-module-name (map find-module) join @@ -697,7 +697,7 @@ (def: (foo bar baz) (-> Int Int Int) (i/+ bar baz))))} - (case (: (Maybe [Bool Code]) + (case (: (Maybe [Bit Code]) (case tokens (^ (list [_ (#.Tag ["" "omit"])] token)) diff --git a/stdlib/source/lux/macro/code.lux b/stdlib/source/lux/macro/code.lux index d8763c3e5..67be6ce56 100644 --- a/stdlib/source/lux/macro/code.lux +++ b/stdlib/source/lux/macro/code.lux @@ -1,17 +1,18 @@ (.module: [lux (#- nat int rev) - [control [equivalence (#+ Equivalence)]] + [control + [equivalence (#+ Equivalence)]] [data - bool + bit number [text (#+ Equivalence) ("text/" Monoid)] ident - [collection [list #* ("list/" Functor Fold)]] + [collection [list ("list/" Functor Fold)]] ]]) ## [Types] ## (type: (Code' w) -## (#.Bool Bool) +## (#.Bit Bit) ## (#.Nat Nat) ## (#.Int Int) ## (#.Frac Frac) @@ -34,7 +35,7 @@ (-> Code) [_cursor ( x)])] - [bool Bool #.Bool] + [bit Bit #.Bit] [nat Nat #.Nat] [int Int #.Int] [rev Rev #.Rev] @@ -63,7 +64,7 @@ (^template [ ] [[_ ( x')] [_ ( y')]] (:: = x' y')) - ([#.Bool Equivalence] + ([#.Bit Equivalence] [#.Nat Equivalence] [#.Int Equivalence] [#.Rev Equivalence] @@ -74,20 +75,13 @@ (^template [] [[_ ( xs')] [_ ( ys')]] - (and (:: Equivalence = (size xs') (size ys')) - (list/fold (function (_ [x' y'] old) - (and old (= x' y'))) - true - (zip2 xs' ys')))) + (:: (list.Equivalence =) = xs' ys')) ([#.Form] [#.Tuple]) [[_ (#.Record xs')] [_ (#.Record ys')]] - (and (:: Equivalence = (size xs') (size ys')) - (list/fold (function (_ [[xl' xr'] [yl' yr']] old) - (and old (= xl' yl') (= xr' yr'))) - true - (zip2 xs' ys'))) + (:: (list.Equivalence (equivalence.product = =)) + = xs' ys') _ false))) @@ -99,7 +93,7 @@ (^template [ ] [_ ( value)] (:: encode value)) - ([#.Bool Codec] + ([#.Bit Codec] [#.Nat Codec] [#.Int Codec] [#.Rev Codec] @@ -114,12 +108,19 @@ (^template [ ] [_ ( members)] - ($_ text/compose (|> members (list/map to-text) (interpose " ") (text.join-with "")) )) + ($_ text/compose (|> members (list/map to-text) (list.interpose " ") (text.join-with "")) )) ([#.Form "(" ")"] [#.Tuple "[" "]"]) [_ (#.Record pairs)] - ($_ text/compose "{" (|> pairs (list/map (function (_ [left right]) ($_ text/compose (to-text left) " " (to-text right)))) (interpose " ") (text.join-with "")) "}") + ($_ text/compose + "{" + (|> pairs + (list/map (function (_ [left right]) + ($_ text/compose (to-text left) " " (to-text right)))) + (list.interpose " ") + (text.join-with "")) + "}") )) (def: #export (replace original substitute ast) diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux index 7a7375e12..7c86a952a 100644 --- a/stdlib/source/lux/macro/poly.lux +++ b/stdlib/source/lux/macro/poly.lux @@ -13,7 +13,7 @@ ["dict" dictionary (#+ Dictionary)]] [number ("nat/" Codec)] [product] - [bool] + [bit] [maybe] [ident ("ident/" Equivalence Codec)] ["e" error]] @@ -354,7 +354,7 @@ ((~' wrap) (.list (~ g!output)))))))))))) (def: (common-poly-name? poly-func) - (-> Text Bool) + (-> Text Bit) (text.contains? "?" poly-func)) (def: (derivation-name poly args) diff --git a/stdlib/source/lux/macro/poly/equivalence.lux b/stdlib/source/lux/macro/poly/equivalence.lux index 189179e13..66bc621ca 100644 --- a/stdlib/source/lux/macro/poly/equivalence.lux +++ b/stdlib/source/lux/macro/poly/equivalence.lux @@ -17,7 +17,7 @@ [tree [rose]]] [number ("nat/" Codec)] [product] - [bool] + [bit] [maybe]] [time ["du" duration] @@ -50,7 +50,7 @@ ))))] [(poly.exactly Any) (function ((~ g!_) (~ g!_) (~ g!_)) true)] - [(poly.similar Bool) bool.Equivalence] + [(poly.similar Bit) bit.Equivalence] [(poly.similar Nat) number.Equivalence] [(poly.similar Int) number.Equivalence] [(poly.similar Rev) number.Equivalence] diff --git a/stdlib/source/lux/macro/poly/json.lux b/stdlib/source/lux/macro/poly/json.lux index 0474c3d4b..1f5b4aab6 100644 --- a/stdlib/source/lux/macro/poly/json.lux +++ b/stdlib/source/lux/macro/poly/json.lux @@ -6,7 +6,7 @@ codec ["p" parser]] [data - [bool] + [bit] maybe ["e" error] [sum] @@ -91,7 +91,7 @@ ))))] [(poly.exactly Any) (function ((~ g!_) (~ (code.symbol ["" "0"]))) #//.Null)] - [(poly.similar Bool) (|>> #//.Boolean)] + [(poly.similar Bit) (|>> #//.Boolean)] [(poly.similar Nat) (:: (~! ..Codec) (~' encode))] [(poly.similar Int) (:: (~! ..Codec) (~' encode))] [(poly.similar Frac) (|>> #//.Number)] @@ -206,8 +206,8 @@ (wrap (` (: (~ (@JSON//decode inputT)) ))))] - [(poly.exactly Any) //.null] - [(poly.similar Bool) //.boolean] + [(poly.exactly Any) //.null] + [(poly.similar Bit) //.boolean] [(poly.similar Nat) (p.codec (~! ..Codec) //.any)] [(poly.similar Int) (p.codec (~! ..Codec) //.any)] [(poly.similar Frac) //.number] @@ -296,18 +296,18 @@ (syntax: #export (Codec inputT) {#.doc (doc "A macro for automatically producing JSON codecs." (type: Variant - (#Case0 Bool) + (#Case0 Bit) (#Case1 Text) (#Case2 Frac)) (type: Record - {#bool Bool + {#bit Bit #frac Frac #text Text #maybe (Maybe Frac) #list (List Frac) #variant Variant - #tuple [Bool Frac Text] + #tuple [Bit Frac Text] #dict (Dictionary Text Frac)}) (derived: (Codec Record)))} diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux index 3b6623b3e..630dd5a0e 100644 --- a/stdlib/source/lux/macro/syntax.lux +++ b/stdlib/source/lux/macro/syntax.lux @@ -6,7 +6,7 @@ [equivalence (#+ Equivalence)] ["p" parser]] [data - [bool] + [bit] [number] [text ("text/" Monoid)] [ident] @@ -54,7 +54,7 @@ _ (#error.Error ($_ text/compose "Cannot parse " (remaining-inputs tokens))))))] - [ bool Bool #.Bool bool.Equivalence "bool"] + [ bit Bit #.Bit bit.Equivalence "bit"] [ nat Nat #.Nat number.Equivalence "nat"] [ int Int #.Int number.Equivalence "int"] [ rev Rev #.Rev number.Equivalence "rev"] @@ -66,7 +66,7 @@ (def: #export (this? ast) {#.doc "Asks if the given Code is the next input."} - (-> Code (Syntax Bool)) + (-> Code (Syntax Bit)) (function (_ tokens) (case tokens (#.Cons [token tokens']) @@ -152,7 +152,7 @@ (def: #export end? {#.doc "Checks whether there are no more inputs."} - (Syntax Bool) + (Syntax Bit) (function (_ tokens) (case tokens #.Nil (#error.Success [tokens true]) @@ -212,7 +212,7 @@ (with-brackets (spaced (list/map constructor-arg$ constructor-args))) (with-brackets (spaced (list/map (method-def$ id) methods))))))] (wrap (list (` ((~ (code.text def-code)))))))))} - (let [[exported? tokens] (: [Bool (List Code)] + (let [[exported? tokens] (: [Bit (List Code)] (case tokens (^ (list& [_ (#.Tag ["" "export"])] tokens')) [true tokens'] diff --git a/stdlib/source/lux/macro/syntax/common/reader.lux b/stdlib/source/lux/macro/syntax/common/reader.lux index 58a502c56..408edae91 100644 --- a/stdlib/source/lux/macro/syntax/common/reader.lux +++ b/stdlib/source/lux/macro/syntax/common/reader.lux @@ -14,7 +14,7 @@ ## Exports (def: #export export - (Syntax Bool) + (Syntax Bit) (p.either (p.after (s.this (' #export)) (parser/wrap true)) (parser/wrap false))) diff --git a/stdlib/source/lux/macro/syntax/common/writer.lux b/stdlib/source/lux/macro/syntax/common/writer.lux index d482bc2c3..7a7416894 100644 --- a/stdlib/source/lux/macro/syntax/common/writer.lux +++ b/stdlib/source/lux/macro/syntax/common/writer.lux @@ -8,7 +8,7 @@ [//]) (def: #export (export exported?) - (-> Bool (List Code)) + (-> Bit (List Code)) (if exported? (list (' #export)) (list))) diff --git a/stdlib/source/lux/math.lux b/stdlib/source/lux/math.lux index c04f31c73..d90db4a33 100644 --- a/stdlib/source/lux/math.lux +++ b/stdlib/source/lux/math.lux @@ -192,7 +192,7 @@ (<| p.rec (function (_ infix^)) ($_ p.alt ($_ p.either - (parser/map code.bool s.bool) + (parser/map code.bit s.bit) (parser/map code.nat s.nat) (parser/map code.int s.int) (parser/map code.rev s.rev) diff --git a/stdlib/source/lux/math/modular.lux b/stdlib/source/lux/math/modular.lux index cef3cbf6f..bb15adac1 100644 --- a/stdlib/source/lux/math/modular.lux +++ b/stdlib/source/lux/math/modular.lux @@ -48,7 +48,7 @@ " Sample: " (int/encode (to-int sample)) "\n")) (def: #export (congruent? modulus reference sample) - (All [m] (-> (Modulus m) Int Int Bool)) + (All [m] (-> (Modulus m) Int Int Bit)) (|> sample (i/- reference) (i/% (to-int modulus)) @@ -116,7 +116,7 @@ (do-template [ ] [(def: #export ( reference sample) - (All [m] (-> (Mod m) (Mod m) Bool)) + (All [m] (-> (Mod m) (Mod m) Bit)) (let [[reference _] (:representation reference) [sample _] (:representation sample)] ( reference sample)))] diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux index 2ddb64f32..86c7d9efd 100644 --- a/stdlib/source/lux/math/random.lux +++ b/stdlib/source/lux/math/random.lux @@ -63,7 +63,7 @@ (def: #export (filter pred gen) {#.doc "Retries the generator until the output satisfies a predicate."} - (All [a] (-> (-> a Bool) (Random a) (Random a))) + (All [a] (-> (-> a Bit) (Random a) (Random a))) (do Monad [sample gen] (if (pred sample) @@ -82,8 +82,8 @@ #.None (refine refiner gen)))) -(def: #export bool - (Random Bool) +(def: #export bit + (Random Bit) (function (_ prng) (let [[prng output] (prng [])] [prng (|> output (i64.and +1) (n/= +1))]))) @@ -164,7 +164,7 @@ {#.doc "Heterogeneous alternative combinator."} (All [a b] (-> (Random a) (Random b) (Random (| a b)))) (do Monad - [? bool] + [? bit] (if ? (do @ [=left left] @@ -177,7 +177,7 @@ {#.doc "Homogeneous alternative combinator."} (All [a] (-> (Random a) (Random a) (Random a))) (do Monad - [? bool] + [? bit] (if ? left right))) @@ -192,7 +192,7 @@ (def: #export (maybe value-gen) (All [a] (-> (Random a) (Random (Maybe a)))) (do Monad - [some? bool] + [some? bit] (if some? (do @ [value value-gen] diff --git a/stdlib/source/lux/test.lux b/stdlib/source/lux/test.lux index 00cbcca91..d4fb7108f 100644 --- a/stdlib/source/lux/test.lux +++ b/stdlib/source/lux/test.lux @@ -49,7 +49,7 @@ (def: #export (assert message condition) {#.doc "Check that a condition is true, and fail with the given message otherwise."} - (-> Text Bool (Promise [Counters Text])) + (-> Text Bit (Promise [Counters Text])) (<| (:: promise.Monad wrap) (if condition [success (format "[Success] " message)] @@ -57,7 +57,7 @@ (def: #export (test message condition) {#.doc "Check that a condition is true, and fail with the given message otherwise."} - (-> Text Bool Test) + (-> Text Bit Test) (:: r.Monad wrap (assert message condition))) (def: (run' tests) @@ -83,7 +83,7 @@ (wrap (list/fold add-counters start test-runs)))) (def: failed? - (-> Counters Bool) + (-> Counters Bit) (|>> product.right (n/> +0))) (def: #export (seed value test) diff --git a/stdlib/source/lux/time/date.lux b/stdlib/source/lux/time/date.lux index 068936f47..e80db8bac 100644 --- a/stdlib/source/lux/time/date.lux +++ b/stdlib/source/lux/time/date.lux @@ -198,7 +198,7 @@ (get@ #day sample))))) (def: (date/< reference sample) - (-> Date Date Bool) + (-> Date Date Bit) (or (i/< (get@ #year reference) (get@ #year sample)) (:: Order < @@ -265,11 +265,11 @@ (row.update [+1] inc normal-months)) (def: (divisible? factor input) - (-> Int Int Bool) + (-> Int Int Bit) (|> input (i/% factor) (i/= 0))) (def: (leap-year? year) - (-> Int Bool) + (-> Int Bit) (and (divisible? 4 year) (or (not (divisible? 100 year)) (divisible? 400 year)))) diff --git a/stdlib/source/lux/time/duration.lux b/stdlib/source/lux/time/duration.lux index 92e35a7fb..b9300b7c3 100644 --- a/stdlib/source/lux/time/duration.lux +++ b/stdlib/source/lux/time/duration.lux @@ -61,7 +61,7 @@ (do-template [ ] [(def: #export ( duration) - (-> Duration Bool) + (-> Duration Bit) ( 0 (:representation duration)))] [positive? i/>] diff --git a/stdlib/source/lux/time/instant.lux b/stdlib/source/lux/time/instant.lux index ce97cecea..9002ff9ef 100644 --- a/stdlib/source/lux/time/instant.lux +++ b/stdlib/source/lux/time/instant.lux @@ -80,11 +80,11 @@ ## Codec::encode (def: (divisible? factor input) - (-> Int Int Bool) + (-> Int Int Bit) (|> input (i/% factor) (i/= 0))) (def: (leap-year? year) - (-> Int Bool) + (-> Int Bit) (and (divisible? 4 year) (or (not (divisible? 100 year)) (divisible? 400 year)))) diff --git a/stdlib/source/lux/type/implicit.lux b/stdlib/source/lux/type/implicit.lux index 8e1c92f84..b2c747028 100644 --- a/stdlib/source/lux/type/implicit.lux +++ b/stdlib/source/lux/type/implicit.lux @@ -9,7 +9,6 @@ [number] [collection [list ("list/" Monad Fold)] ["dict" dictionary (#+ Dictionary)]] - [bool] [product] [maybe]] [macro (#+ Monad) @@ -285,7 +284,7 @@ (do Monad [alts import-structs] (test alts))))) (def: (var? input) - (-> Code Bool) + (-> Code Bit) (case input [_ (#.Symbol _)] true diff --git a/stdlib/source/lux/type/object/interface.lux b/stdlib/source/lux/type/object/interface.lux index c90965c2d..42284b4b3 100644 --- a/stdlib/source/lux/type/object/interface.lux +++ b/stdlib/source/lux/type/object/interface.lux @@ -98,7 +98,7 @@ (~ g!method))))) (def: (definition export [interface parameters] g!self-object g!ext g!states (^open)) - (-> Bool Declaration Code Code (List Code) Method Code) + (-> Bit Declaration Code Code (List Code) Method Code) (let [g!method (code.local-symbol name) g!parameters (list/map code.local-symbol parameters) g!type-vars (list/map code.local-symbol type-vars) @@ -125,7 +125,7 @@ (def: no-parent Ident ["" ""]) (def: (no-parent? parent) - (-> Ident Bool) + (-> Ident Bit) (ident/= no-parent parent)) (def: (with-interface parent interface) @@ -247,7 +247,7 @@ ) (def: (getterN export interface g!parameters g!ext g!child ancestors) - (-> Bool Text (List Code) Code Code (List Ident) + (-> Bit Text (List Code) Code Code (List Ident) Code) (let [g!get (code.local-symbol (getN interface)) g!interface (code.local-symbol interface) @@ -266,7 +266,7 @@ (~ g!_state)))))) (def: (setterN export interface g!parameters g!ext g!child ancestors) - (-> Bool Text (List Code) Code Code (List Ident) + (-> Bit Text (List Code) Code Code (List Ident) Code) (let [g!set (code.local-symbol (setN interface)) g!interface (code.local-symbol interface) @@ -289,7 +289,7 @@ (~ g!build-up)))))) (def: (updaterN export interface g!parameters g!ext g!child ancestors) - (-> Bool Text (List Code) Code Code (List Ident) + (-> Bit Text (List Code) Code Code (List Ident) Code) (let [g!update (code.local-symbol (updateN interface)) g!interface (code.local-symbol interface) diff --git a/stdlib/source/lux/type/object/protocol.lux b/stdlib/source/lux/type/object/protocol.lux index 495aaebd4..ebbf9cc4b 100644 --- a/stdlib/source/lux/type/object/protocol.lux +++ b/stdlib/source/lux/type/object/protocol.lux @@ -78,7 +78,7 @@ (Method (~ inputC) (~ outputC) (~ g!return))))))) (def: (method|c export protocol method) - (-> Bool cs.Declaration Method-Syntax (Meta Code)) + (-> Bit cs.Declaration Method-Syntax (Meta Code)) (let [methodC (code.local-symbol (get@ #method-name method)) tagC (code.local-tag (get@ #method-name method)) protocolC (code.local-symbol (get@ #cs.declaration-name protocol)) @@ -110,7 +110,7 @@ (` ((~ tagC) ((~ protocolC) (~ g!return)))))) (def: (class|c export protocol class) - (-> Bool cs.Declaration Class-Syntax (Meta Code)) + (-> Bit cs.Declaration Class-Syntax (Meta Code)) (let [classC (code.local-symbol (get@ #class-name class)) tagC (code.local-tag (get@ #class-name class)) protocolC (code.local-symbol (get@ #cs.declaration-name protocol)) @@ -138,7 +138,7 @@ (class|w g!return))) (def: (super|c export protocol) - (-> Bool cs.Declaration (| Method-Syntax Class-Syntax) (Meta Code)) + (-> Bit cs.Declaration (| Method-Syntax Class-Syntax) (Meta Code)) (sum.either (method|c export protocol) (class|c export protocol))) diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux index d62c77182..6630f8a60 100644 --- a/stdlib/source/lux/world/file.lux +++ b/stdlib/source/lux/world/file.lux @@ -52,14 +52,14 @@ [last-modified Instant]) (do-template [] - [(: (-> File (m Bool)) + [(: (-> File (m Bit)) )] [file?] [directory?] ) - (: (-> Permission File (m Bool)) + (: (-> Permission File (m Bit)) can?) (do-template [] @@ -240,7 +240,7 @@ })) (def: #export (exists? System file) - (All [m] (-> (System m) File (m Bool))) + (All [m] (-> (System m) File (m Bit))) (|> file (do> (:: System &monad) [(:: System file?)] diff --git a/stdlib/test/test/lux/concurrency/promise.lux b/stdlib/test/test/lux/concurrency/promise.lux index f0b0bb865..29bab782c 100644 --- a/stdlib/test/test/lux/concurrency/promise.lux +++ b/stdlib/test/test/lux/concurrency/promise.lux @@ -61,7 +61,7 @@ (test "Cannot re-resolve a resolved promise." (and (not (io.run (&.resolve false (&/wrap true)))) - (io.run (&.resolve true (: (&.Promise Bool) (&.promise #.None)))))) + (io.run (&.resolve true (: (&.Promise Bit) (&.promise #.None)))))) (wrap (do &.Monad [?none (&.time-out +100 (&.delay +200 true)) diff --git a/stdlib/test/test/lux/control/exception.lux b/stdlib/test/test/lux/control/exception.lux index 85b331620..9e11dbe0f 100644 --- a/stdlib/test/test/lux/control/exception.lux +++ b/stdlib/test/test/lux/control/exception.lux @@ -22,9 +22,9 @@ (context: "Exceptions" (<| (times +100) (do @ - [should-throw? r.bool - which? r.bool - should-catch? r.bool + [should-throw? r.bit + which? r.bit + should-catch? r.bit default-val r.nat some-val r.nat another-val r.nat diff --git a/stdlib/test/test/lux/control/parser.lux b/stdlib/test/test/lux/control/parser.lux index a8ec24446..6028eed1a 100644 --- a/stdlib/test/test/lux/control/parser.lux +++ b/stdlib/test/test/lux/control/parser.lux @@ -16,13 +16,13 @@ ## [Utils] (def: (should-fail input) - (All [a] (-> (Error a) Bool)) + (All [a] (-> (Error a) Bit)) (case input (#error.Error _) true _ false)) (def: (enforced? parser input) - (All [s] (-> (&.Parser s Any) s Bool)) + (All [s] (-> (&.Parser s Any) s Bit)) (case (&.run input parser) (#error.Success [_ []]) true @@ -31,7 +31,7 @@ false)) (def: (found? parser input) - (All [s] (-> (&.Parser s Bool) s Bool)) + (All [s] (-> (&.Parser s Bit) s Bit)) (case (&.run input parser) (#error.Success [_ true]) true @@ -40,7 +40,7 @@ false)) (def: (fails? input) - (All [a] (-> (Error a) Bool)) + (All [a] (-> (Error a) Bit)) (case input (#error.Error _) true @@ -60,9 +60,9 @@ (context: "Assertions" (test "Can make assertions while parsing." (and (match [] - (&.run (list (code.bool true) (code.int 123)) + (&.run (list (code.bit true) (code.int 123)) (&.assert "yolo" true))) - (fails? (&.run (list (code.bool true) (code.int 123)) + (fails? (&.run (list (code.bit true) (code.int 123)) (&.assert "yolo" false)))))) (context: "Combinators [Part 1]" @@ -105,14 +105,14 @@ (match -123 (&.run (list (code.int -123) (code.int 456) (code.int 789)) (&.either positive s.int))) - (fails? (&.run (list (code.bool true) (code.int 456) (code.int 789)) + (fails? (&.run (list (code.bit true) (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)) (&.not s.int))) (match [] - (&.run (list (code.bool true) (code.int 456) (code.int 789)) + (&.run (list (code.bit true) (code.int 456) (code.int 789)) (&.not s.int))))) )) diff --git a/stdlib/test/test/lux/control/region.lux b/stdlib/test/test/lux/control/region.lux index 606be66bf..544b42982 100644 --- a/stdlib/test/test/lux/control/region.lux +++ b/stdlib/test/test/lux/control/region.lux @@ -18,7 +18,7 @@ (do-template [ ] [(def: ( result) - (All [a] (-> (Error a) Bool)) + (All [a] (-> (Error a) Bit)) (case result (#e.Success _) (#e.Error _) ))] diff --git a/stdlib/test/test/lux/control/state.lux b/stdlib/test/test/lux/control/state.lux index 9f352df48..c39be3197 100644 --- a/stdlib/test/test/lux/control/state.lux +++ b/stdlib/test/test/lux/control/state.lux @@ -12,7 +12,7 @@ lux/test) (def: (with-conditions [state output] computation) - (-> [Nat Nat] (&.State Nat Nat) Bool) + (-> [Nat Nat] (&.State Nat Nat) Bit) (|> computation (&.run state) product.right diff --git a/stdlib/test/test/lux/data/bit.lux b/stdlib/test/test/lux/data/bit.lux new file mode 100644 index 000000000..f9ab9551f --- /dev/null +++ b/stdlib/test/test/lux/data/bit.lux @@ -0,0 +1,38 @@ +(.module: + [lux #* + [control + ["M" monad (#+ do Monad)]] + [io] + [data + bit] + [math + ["r" random]]] + lux/test) + +(context: "Bit operations." + (<| (times +100) + (do @ + [value r.bit] + (test "" (and (not (and value (not value))) + (or value (not value)) + + (not (:: Or@Monoid identity)) + (:: Or@Monoid compose value (not value)) + (:: And@Monoid identity) + (not (:: And@Monoid compose value (not value))) + + (:: Equivalence = value (not (not value))) + (not (:: Equivalence = value (not value))) + + (not (:: Equivalence = value ((complement id) value))) + (:: Equivalence = value ((complement not) value)) + + (case (|> value + (:: Codec encode) + (:: Codec decode)) + (#.Right dec-value) + (:: Equivalence = value dec-value) + + (#.Left _) + false) + ))))) diff --git a/stdlib/test/test/lux/data/bool.lux b/stdlib/test/test/lux/data/bool.lux deleted file mode 100644 index 0413c2632..000000000 --- a/stdlib/test/test/lux/data/bool.lux +++ /dev/null @@ -1,38 +0,0 @@ -(.module: - [lux #* - [control - ["M" monad (#+ do Monad)]] - [io] - [data - bool] - [math - ["r" random]]] - lux/test) - -(context: "Boolean operations." - (<| (times +100) - (do @ - [value r.bool] - (test "" (and (not (and value (not value))) - (or value (not value)) - - (not (:: Or@Monoid identity)) - (:: Or@Monoid compose value (not value)) - (:: And@Monoid identity) - (not (:: And@Monoid compose value (not value))) - - (:: Equivalence = value (not (not value))) - (not (:: Equivalence = value (not value))) - - (not (:: Equivalence = value ((complement id) value))) - (:: Equivalence = value ((complement not) value)) - - (case (|> value - (:: Codec encode) - (:: Codec decode)) - (#.Right dec-value) - (:: Equivalence = value dec-value) - - (#.Left _) - false) - ))))) diff --git a/stdlib/test/test/lux/data/collection/list.lux b/stdlib/test/test/lux/data/collection/list.lux index f7e73ef9b..0945a9abb 100644 --- a/stdlib/test/test/lux/data/collection/list.lux +++ b/stdlib/test/test/lux/data/collection/list.lux @@ -5,7 +5,7 @@ [monad (#+ do Monad)] pipe] [data [number] - [bool] + [bit] [product] [maybe] [collection @@ -48,7 +48,7 @@ (test "Filtering by a predicate and its complement should result in a number of elements equal to the original list." (and (n/= (&.size sample) (n/+ (&.size (&.filter n/even? sample)) - (&.size (&.filter (bool.complement n/even?) sample)))) + (&.size (&.filter (bit.complement n/even?) sample)))) (let [[plus minus] (&.partition n/even? sample)] (n/= (&.size sample) (n/+ (&.size plus) @@ -56,9 +56,9 @@ (test "If every element in a list satisfies a predicate, there can't be any that satisfy its complement." (if (&.every? n/even? sample) - (and (not (&.any? (bool.complement n/even?) sample)) - (&.empty? (&.filter (bool.complement n/even?) sample))) - (&.any? (bool.complement n/even?) sample))) + (and (not (&.any? (bit.complement n/even?) sample)) + (&.empty? (&.filter (bit.complement n/even?) sample))) + (&.any? (bit.complement n/even?) sample))) (test "Any element of the list can be considered its member." (let [elem (maybe.assume (&.nth idx sample))] @@ -196,11 +196,11 @@ (#.Some found) (and (n/even? found) (&.any? n/even? sample) - (not (&.every? (bool.complement n/even?) sample))) + (not (&.every? (bit.complement n/even?) sample))) #.None (and (not (&.any? n/even? sample)) - (&.every? (bool.complement n/even?) sample)))) + (&.every? (bit.complement n/even?) sample)))) (test "You can iteratively construct a list, generating values until you're done." (= (&.n/range +0 (dec size)) diff --git a/stdlib/test/test/lux/data/format/json.lux b/stdlib/test/test/lux/data/format/json.lux index e3b3c6f66..f648dce28 100644 --- a/stdlib/test/test/lux/data/format/json.lux +++ b/stdlib/test/test/lux/data/format/json.lux @@ -9,7 +9,7 @@ ["p" parser]] [data ["e" error] - [bool] + [bit] [maybe] [number] ["." text @@ -50,7 +50,7 @@ [size (:: @ map (n/% +2) r.nat)] ($_ r.alt (:: @ wrap []) - r.bool + r.bit (|> r.frac (:: @ map (f/* 1_000_000.0))) (r.unicode size) (r.row size gen-json) @@ -77,7 +77,7 @@ )))) (type: Variant - (#Case0 Bool) + (#Case0 Bit) (#Case1 Text) (#Case2 Frac)) @@ -86,14 +86,14 @@ (#Addition Frac Recursive)) (type: Record - {#bool Bool + {#bit Bit #frac Frac #text Text #maybe (Maybe Frac) #list (List Frac) #dict (d.Dictionary Text Frac) ## #variant Variant - ## #tuple [Bool Frac Text] + ## #tuple [Bit Frac Text] #recursive Recursive ## #instant ti.Instant #duration tdu.Duration @@ -118,14 +118,14 @@ (do r.Monad [size (:: @ map (n/% +2) r.nat)] ($_ r.seq - r.bool + r.bit r.frac (r.unicode size) (r.maybe r.frac) (r.list size r.frac) (r.dictionary text.Hash size (r.unicode size) r.frac) - ## ($_ r.alt r.bool (r.unicode size) r.frac) - ## ($_ r.seq r.bool r.frac (r.unicode size)) + ## ($_ r.alt r.bit (r.unicode size) r.frac) + ## ($_ r.seq r.bit r.frac (r.unicode size)) gen-recursive ## _instant.instant _duration.duration @@ -140,7 +140,7 @@ (let [variant/= (function (_ left right) (case [left right] [(#Case0 left') (#Case0 right')] - (:: bool.Equivalence = left' right') + (:: bit.Equivalence = left' right') [(#Case1 left') (#Case1 right')] (:: text.Equivalence = left' right') @@ -150,7 +150,7 @@ _ false))] - (and (:: bool.Equivalence = (get@ #bool recL) (get@ #bool recR)) + (and (:: bit.Equivalence = (get@ #bit recL) (get@ #bit recR)) (f/= (get@ #frac recL) (get@ #frac recR)) (:: text.Equivalence = (get@ #text recL) (get@ #text recR)) (:: (maybe.Equivalence number.Equivalence) = (get@ #maybe recL) (get@ #maybe recR)) @@ -159,7 +159,7 @@ ## (variant/= (get@ #variant recL) (get@ #variant recR)) ## (let [[tL0 tL1 tL2] (get@ #tuple recL) ## [tR0 tR1 tR2] (get@ #tuple recR)] - ## (and (:: bool.Equivalence = tL0 tR0) + ## (and (:: bit.Equivalence = tL0 tR0) ## (f/= tL1 tR1) ## (:: text.Equivalence = tL2 tR2))) (:: Equivalence = (get@ #recursive recL) (get@ #recursive recR)) diff --git a/stdlib/test/test/lux/data/number/complex.lux b/stdlib/test/test/lux/data/number/complex.lux index 03ec307ff..15d759ba7 100644 --- a/stdlib/test/test/lux/data/number/complex.lux +++ b/stdlib/test/test/lux/data/number/complex.lux @@ -19,7 +19,7 @@ (def: margin-of-error Frac 1.0e-9) (def: (within? margin standard value) - (-> Frac &.Complex &.Complex Bool) + (-> Frac &.Complex &.Complex Bit) (let [real-dist (frac/abs (f/- (get@ #&.real standard) (get@ #&.real value))) imgn-dist (frac/abs (f/- (get@ #&.imaginary standard) @@ -161,7 +161,7 @@ )))) (def: (trigonometric-symmetry forward backward angle) - (-> (-> &.Complex &.Complex) (-> &.Complex &.Complex) &.Complex Bool) + (-> (-> &.Complex &.Complex) (-> &.Complex &.Complex) &.Complex Bit) (let [normal (|> angle forward backward)] (|> normal forward backward (within? margin-of-error normal)))) diff --git a/stdlib/test/test/lux/data/number/i64.lux b/stdlib/test/test/lux/data/number/i64.lux index 1dd9dd314..52b80ea25 100644 --- a/stdlib/test/test/lux/data/number/i64.lux +++ b/stdlib/test/test/lux/data/number/i64.lux @@ -39,7 +39,7 @@ (n/= &.width (n/+ (&.count pattern) (&.count (&.not pattern))))) - (test "Can do simple binary boolean logic." + (test "Can do simple binary logic." (and (n/= +0 (&.and pattern (&.not pattern))) diff --git a/stdlib/test/test/lux/data/text/lexer.lux b/stdlib/test/test/lux/data/text/lexer.lux index 25abe3ae4..b02082357 100644 --- a/stdlib/test/test/lux/data/text/lexer.lux +++ b/stdlib/test/test/lux/data/text/lexer.lux @@ -18,13 +18,13 @@ ## [Utils] (def: (should-fail input) - (All [a] (-> (E.Error a) Bool)) + (All [a] (-> (E.Error a) Bit)) (case input (#.Left _) true _ false)) (def: (should-passT test input) - (-> Text (E.Error Text) Bool) + (-> Text (E.Error Text) Bit) (case input (#.Right output) (text/= test output) @@ -33,7 +33,7 @@ false)) (def: (should-passL test input) - (-> (List Text) (E.Error (List Text)) Bool) + (-> (List Text) (E.Error (List Text)) Bit) (let [(^open "list/") (list.Equivalence text.Equivalence)] (case input (#.Right output) @@ -43,7 +43,7 @@ false))) (def: (should-passE test input) - (-> (Either Text Text) (E.Error (Either Text Text)) Bool) + (-> (Either Text Text) (E.Error (Either Text Text)) Bit) (case input (#.Right output) (case [test output] diff --git a/stdlib/test/test/lux/data/text/regex.lux b/stdlib/test/test/lux/data/text/regex.lux index 16970af9c..ff09a55db 100644 --- a/stdlib/test/test/lux/data/text/regex.lux +++ b/stdlib/test/test/lux/data/text/regex.lux @@ -20,7 +20,7 @@ ## [Utils] (def: (should-pass regex input) - (-> (lexer.Lexer Text) Text Bool) + (-> (lexer.Lexer Text) Text Bit) (|> (lexer.run input regex) (case> (#.Right parsed) (text/= parsed input) @@ -29,7 +29,7 @@ false))) (def: (should-passT test regex input) - (-> Text (lexer.Lexer Text) Text Bool) + (-> Text (lexer.Lexer Text) Text Bit) (|> (lexer.run input regex) (case> (#.Right parsed) (text/= test parsed) @@ -38,7 +38,7 @@ false))) (def: (should-fail regex input) - (All [a] (-> (lexer.Lexer a) Text Bool)) + (All [a] (-> (lexer.Lexer a) Text Bit)) (|> (lexer.run input regex) (case> (#.Left _) true _ false))) diff --git a/stdlib/test/test/lux/language/compiler/analysis/case.lux b/stdlib/test/test/lux/language/compiler/analysis/case.lux index 4e01ae3bd..14b762271 100644 --- a/stdlib/test/test/lux/language/compiler/analysis/case.lux +++ b/stdlib/test/test/lux/language/compiler/analysis/case.lux @@ -44,9 +44,9 @@ (wrap (#.Cons head tail+))))) (def: #export (exhaustive-branches allow-literals? variantTC inputC) - (-> Bool (List [Code Code]) Code (r.Random (List Code))) + (-> Bit (List [Code Code]) Code (r.Random (List Code))) (case inputC - [_ (#.Bool _)] + [_ (#.Bit _)] (random/wrap (list (' true) (' false))) (^template [ ] diff --git a/stdlib/test/test/lux/language/compiler/analysis/function.lux b/stdlib/test/test/lux/language/compiler/analysis/function.lux index 1edbfd949..32ef59e3f 100644 --- a/stdlib/test/test/lux/language/compiler/analysis/function.lux +++ b/stdlib/test/test/lux/language/compiler/analysis/function.lux @@ -35,7 +35,7 @@ (def: analyse (expression.analyser (:coerce language.Eval []))) (def: (check-apply expectedT num-args analysis) - (-> Type Nat (Operation Analysis) Bool) + (-> Type Nat (Operation Analysis) Bit) (|> analysis (typeA.with-type expectedT) (compiler.run [analysisE.bundle (init.compiler [])]) diff --git a/stdlib/test/test/lux/language/compiler/analysis/primitive.lux b/stdlib/test/test/lux/language/compiler/analysis/primitive.lux index 8cd764b00..fadde9bb0 100644 --- a/stdlib/test/test/lux/language/compiler/analysis/primitive.lux +++ b/stdlib/test/test/lux/language/compiler/analysis/primitive.lux @@ -36,7 +36,7 @@ [(r.seq (random/wrap ) (random/map ))] [Any code.tuple (r.list +0 ..unit)] - [Bool code.bool r.bool] + [Bit code.bit r.bit] [Nat code.nat r.nat] [Int code.int r.int] [Rev code.rev r.rev] @@ -83,7 +83,7 @@ _ false))))] - ["bool" Bool #analysis.Bool r.bool code.bool] + ["bit" Bit #analysis.Bit r.bit code.bit] ["nat" Nat #analysis.Nat r.nat code.nat] ["int" Int #analysis.Int r.int code.int] ["rev" Rev #analysis.Rev r.rev code.rev] diff --git a/stdlib/test/test/lux/language/compiler/analysis/procedure/common.lux b/stdlib/test/test/lux/language/compiler/analysis/procedure/common.lux index e3b8cc9b5..7ea4a23bd 100644 --- a/stdlib/test/test/lux/language/compiler/analysis/procedure/common.lux +++ b/stdlib/test/test/lux/language/compiler/analysis/procedure/common.lux @@ -30,7 +30,7 @@ (do-template [ ] [(def: ( procedure params output-type) - (-> Text (List Code) Type Bool) + (-> Text (List Code) Type Bit) (|> (scope.with-scope "" (typeA.with-type output-type (_primitive.analyse (` ((~ (code.text procedure)) (~+ params)))))) @@ -53,9 +53,9 @@ (r.filter (|>> product.left (type/= primT) not)))] ($_ seq (test "Can test for reference equality." - (check-success+ "lux is" (list primC primC) Bool)) + (check-success+ "lux is" (list primC primC) Bit)) (test "Reference equality must be done with elements of the same type." - (check-failure+ "lux is" (list primC antiC) Bool)) + (check-failure+ "lux is" (list primC antiC) Bit)) (test "Can 'try' risky IO computations." (check-success+ "lux try" (list (` ([(~' _) (~' _)] (~ primC)))) @@ -100,9 +100,9 @@ (test "Can calculate remainder of integers." (check-success+ "lux int %" (list subjectC paramC) Int)) (test "Can test equivalence of integers." - (check-success+ "lux int =" (list subjectC paramC) Bool)) + (check-success+ "lux int =" (list subjectC paramC) Bit)) (test "Can compare integers." - (check-success+ "lux int <" (list subjectC paramC) Bool)) + (check-success+ "lux int <" (list subjectC paramC) Bit)) (test "Can convert integer to fraction." (check-success+ "lux int to-frac" (list subjectC) Frac)) (test "Can convert integer to text." @@ -127,9 +127,9 @@ (test "Can calculate remainder of frac numbers." (check-success+ "lux frac %" (list subjectC paramC) Frac)) (test "Can test equivalence of frac numbers." - (check-success+ "lux frac =" (list subjectC paramC) Bool)) + (check-success+ "lux frac =" (list subjectC paramC) Bit)) (test "Can compare frac numbers." - (check-success+ "lux frac <" (list subjectC paramC) Bool)) + (check-success+ "lux frac <" (list subjectC paramC) Bit)) (test "Can obtain minimum frac number." (check-success+ "lux frac min" (list) Frac)) (test "Can obtain maximum frac number." @@ -154,9 +154,9 @@ toC (|> r.nat (:: @ map code.nat))] ($_ seq (test "Can test text equivalence." - (check-success+ "lux text =" (list subjectC paramC) Bool)) + (check-success+ "lux text =" (list subjectC paramC) Bit)) (test "Compare texts in lexicographical order." - (check-success+ "lux text <" (list subjectC paramC) Bool)) + (check-success+ "lux text <" (list subjectC paramC) Bit)) (test "Can concatenate one text to another." (check-success+ "lux text concat" (list subjectC paramC) Text)) (test "Can find the index of a piece of text inside a larger one that (may) contain it." @@ -262,7 +262,7 @@ (test "Can swap the value of an atomic reference." (|> (scope.with-scope "" (scope.with-local [var-name atomT] - (typeA.with-type Bool + (typeA.with-type Bit (_primitive.analyse (` ("lux atom compare-and-swap" (~ (code.symbol ["" var-name])) (~ elemC) diff --git a/stdlib/test/test/lux/language/compiler/analysis/reference.lux b/stdlib/test/test/lux/language/compiler/analysis/reference.lux index 00ab606a3..d68e2e8f4 100644 --- a/stdlib/test/test/lux/language/compiler/analysis/reference.lux +++ b/stdlib/test/test/lux/language/compiler/analysis/reference.lux @@ -31,7 +31,7 @@ (def: analyse (expression.analyser (:coerce language.Eval []))) -(type: Check (-> (e.Error Any) Bool)) +(type: Check (-> (e.Error Any) Bit)) (do-template [ ] [(def: @@ -47,7 +47,7 @@ ) (def: (reach-test var-name [export? def-module] [import? dependent-module] check!) - (-> Text [Bool Text] [Bool Text] Check Bool) + (-> Text [Bit Text] [Bit Text] Check Bit) (|> (do compiler.Monad [_ (module.with-module +0 def-module (module.define var-name [Any diff --git a/stdlib/test/test/lux/language/compiler/analysis/structure.lux b/stdlib/test/test/lux/language/compiler/analysis/structure.lux index 664e6e29f..8d8ce4cd0 100644 --- a/stdlib/test/test/lux/language/compiler/analysis/structure.lux +++ b/stdlib/test/test/lux/language/compiler/analysis/structure.lux @@ -4,7 +4,7 @@ [monad (#+ do)] pipe] [data - [bool ("bool/" Equivalence)] + [bit ("bit/" Equivalence)] ["e" error] [product] [maybe] @@ -36,7 +36,7 @@ (do-template [ ] [(def: #export - (All [a] (-> (Operation a) Bool)) + (All [a] (-> (Operation a) Bit)) (|>> (compiler.run [analysisE.bundle (init.compiler [])]) (case> (#e.Success _) @@ -49,16 +49,16 @@ ) (def: (check-sum' size tag variant) - (-> Nat Tag (Variant Analysis) Bool) + (-> Nat Tag (Variant Analysis) Bit) (let [variant-tag (if (get@ #analysis.right? variant) (inc (get@ #analysis.lefts variant)) (get@ #analysis.lefts variant))] (|> size dec (n/= tag) - (bool/= (get@ #analysis.right? variant)) + (bit/= (get@ #analysis.right? variant)) (and (n/= tag variant-tag))))) (def: (check-sum type size tag analysis) - (-> Type Nat Tag (Operation Analysis) Bool) + (-> Type Nat Tag (Operation Analysis) Bit) (|> analysis (typeA.with-type type) (compiler.run [analysisE.bundle (init.compiler [])]) @@ -77,7 +77,7 @@ (module.with-module +0 module))) (def: (check-variant module tags type size tag analysis) - (-> Text (List module.Tag) Type Nat Tag (Operation Analysis) Bool) + (-> Text (List module.Tag) Type Nat Tag (Operation Analysis) Bit) (|> analysis (tagged module tags type) (typeA.with-type type) @@ -91,11 +91,11 @@ false))) (def: (right-size? size) - (-> Nat (-> Analysis Bool)) + (-> Nat (-> Analysis Bit)) (|>> analysis.tuple list.size (n/= size))) (def: (check-record-inference module tags type size analysis) - (-> Text (List module.Tag) Type Nat (Operation [Type Analysis]) Bool) + (-> Text (List module.Tag) Type Nat (Operation [Type Analysis]) Bit) (|> analysis (tagged module tags type) (compiler.run [analysisE.bundle (init.compiler [])]) diff --git a/stdlib/test/test/lux/language/compiler/synthesis/case.lux b/stdlib/test/test/lux/language/compiler/synthesis/case.lux index 264bc0967..ff84207a1 100644 --- a/stdlib/test/test/lux/language/compiler/synthesis/case.lux +++ b/stdlib/test/test/lux/language/compiler/synthesis/case.lux @@ -60,15 +60,15 @@ (context: "If expressions." (<| (times +100) (do @ - [then|else r.bool + [then|else r.bit inputA //primitive.primitive thenA //primitive.primitive elseA //primitive.primitive #let [thenB (: Branch - [(#analysisL.Simple (#analysisL.Bool true)) + [(#analysisL.Simple (#analysisL.Bit true)) thenA]) elseB (: Branch - [(#analysisL.Simple (#analysisL.Bool false)) + [(#analysisL.Simple (#analysisL.Bit false)) elseA]) ifA (if then|else (analysisL.control/case [inputA [thenB (list elseB)]]) diff --git a/stdlib/test/test/lux/language/compiler/synthesis/function.lux b/stdlib/test/test/lux/language/compiler/synthesis/function.lux index 51b2a2e17..0116033bd 100644 --- a/stdlib/test/test/lux/language/compiler/synthesis/function.lux +++ b/stdlib/test/test/lux/language/compiler/synthesis/function.lux @@ -30,7 +30,7 @@ (r.rec (function (_ constant-function) (do r.Monad - [function? r.bool] + [function? r.bit] (if function? (do @ [[arity bodyA predictionA] constant-function] @@ -62,7 +62,7 @@ (dict.new number.Hash)) (list.enumerate current-env))] (do @ - [nest? r.bool] + [nest? r.bit] (if nest? (do @ [num-picks (:: @ map (n/max +1) (pick (inc current-env/size))) @@ -91,7 +91,7 @@ nest? true] (if nest? (do r.Monad - [nest?' r.bool + [nest?' r.bit [arity' bodyA predictionA] (recur (inc arity) nest?')] (wrap [arity' (#analysisL.Function (list) bodyA) diff --git a/stdlib/test/test/lux/language/compiler/synthesis/primitive.lux b/stdlib/test/test/lux/language/compiler/synthesis/primitive.lux index 3bea7682d..c804b94ff 100644 --- a/stdlib/test/test/lux/language/compiler/synthesis/primitive.lux +++ b/stdlib/test/test/lux/language/compiler/synthesis/primitive.lux @@ -24,7 +24,7 @@ [primitive (: (r.Random analysisL.Primitive) ($_ r.alt (wrap []) - r.bool + r.bit r.nat r.int r.rev @@ -33,14 +33,14 @@ (wrap (#analysisL.Primitive primitive)))) (def: #export (corresponds? analysis synthesis) - (-> Analysis Synthesis Bool) + (-> Analysis Synthesis Bit) (case [synthesis analysis] [(#//.Primitive (#//.Text valueS)) (#analysisL.Primitive (#analysisL.Unit valueA))] (is? valueS (:coerce Text valueA)) - [(#//.Primitive (#//.Bool valueS)) - (#analysisL.Primitive (#analysisL.Bool valueA))] + [(#//.Primitive (#//.Bit valueS)) + (#analysisL.Primitive (#analysisL.Bit valueA))] (is? valueS valueA) [(#//.Primitive (#//.I64 valueS)) @@ -69,7 +69,7 @@ (context: "Primitives." (<| (times +100) (do @ - [%bool% r.bool + [%bit% r.bit %nat% r.nat %int% r.int %rev% r.rev @@ -88,7 +88,7 @@ false)))] ["unit" #analysisL.Unit #//.Text //.unit] - ["bool" #analysisL.Bool #//.Bool %bool%] + ["bit" #analysisL.Bit #//.Bit %bit%] ["nat" #analysisL.Nat #//.I64 (.i64 %nat%)] ["int" #analysisL.Int #//.I64 (.i64 %int%)] ["rev" #analysisL.Rev #//.I64 (.i64 %rev%)] diff --git a/stdlib/test/test/lux/language/compiler/synthesis/structure.lux b/stdlib/test/test/lux/language/compiler/synthesis/structure.lux index 0b9f705ff..db56757d1 100644 --- a/stdlib/test/test/lux/language/compiler/synthesis/structure.lux +++ b/stdlib/test/test/lux/language/compiler/synthesis/structure.lux @@ -5,7 +5,7 @@ [monad (#+ do)] pipe] [data - [bool ("bool/" Equivalence)] + [bit ("bit/" Equivalence)] [product] [error] [collection @@ -35,7 +35,7 @@ (case> (#error.Success (#//.Structure (#//.Variant [leftsS right?S valueS]))) (let [tagS (if right?S (inc leftsS) leftsS)] (and (n/= tagA tagS) - (|> tagS (n/= (dec size)) (bool/= right?S)) + (|> tagS (n/= (dec size)) (bit/= right?S)) (//primitive.corresponds? memberA valueS))) _ diff --git a/stdlib/test/test/lux/language/syntax.lux b/stdlib/test/test/lux/language/syntax.lux index 22420e3eb..8c93867aa 100644 --- a/stdlib/test/test/lux/language/syntax.lux +++ b/stdlib/test/test/lux/language/syntax.lux @@ -47,7 +47,7 @@ (r.Random Code) (let [numeric^ (: (r.Random Code) ($_ r.either - (|> r.bool (r/map code.bool)) + (|> r.bit (r/map code.bit)) (|> r.nat (r/map code.nat)) (|> r.int (r/map code.int)) (|> r.rev (r/map code.rev)) @@ -116,7 +116,7 @@ (do @ [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.bool + 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) diff --git a/stdlib/test/test/lux/language/type.lux b/stdlib/test/test/lux/language/type.lux index 7be06000b..5f2cff09b 100644 --- a/stdlib/test/test/lux/language/type.lux +++ b/stdlib/test/test/lux/language/type.lux @@ -57,14 +57,14 @@ (test "Can apply quantified types (universal and existential quantification)." (and (maybe.default false (do maybe.Monad - [partial (&.apply (list Bool) Ann) + [partial (&.apply (list Bit) Ann) full (&.apply (list Int) partial)] - (wrap (:: &.Equivalence = full (#.Product Bool Int))))) - (|> (&.apply (list Bool) Text) + (wrap (:: &.Equivalence = full (#.Product Bit Int))))) + (|> (&.apply (list Bit) Text) (case> #.None true _ false))))) (context: "Naming" - (let [base (#.Named ["" "a"] (#.Product Bool Int)) + (let [base (#.Named ["" "a"] (#.Product Bit Int)) aliased (#.Named ["" "c"] (#.Named ["" "b"] base))] diff --git a/stdlib/test/test/lux/language/type/check.lux b/stdlib/test/test/lux/language/type/check.lux index 8fe7f2bf6..c2db4533c 100644 --- a/stdlib/test/test/lux/language/type/check.lux +++ b/stdlib/test/test/lux/language/type/check.lux @@ -50,7 +50,7 @@ ))))) (def: (valid-type? type) - (-> Type Bool) + (-> Type Bit) (case type (#.Primitive name params) (list.every? valid-type? params) @@ -70,7 +70,7 @@ false)) (def: (type-checks? input) - (-> (@.Check []) Bool) + (-> (@.Check []) Bit) (case (@.run @.fresh-context input) (#.Right []) true @@ -177,20 +177,20 @@ (test "Cannot rebind already bound type-vars." (not (type-checks? (do @.Monad [[id var] @.var - _ (@.check var .Bool)] + _ (@.check var .Bit)] (@.check var .Nat))))) (test "If the type bound to a var is a super-type to another, then the var is also a super-type." (type-checks? (do @.Monad [[id var] @.var _ (@.check var Any)] - (@.check var .Bool)))) + (@.check var .Bit)))) (test "If the type bound to a var is a sub-type of another, then the var is also a sub-type." (type-checks? (do @.Monad [[id var] @.var _ (@.check var Nothing)] - (@.check .Bool var)))) + (@.check .Bit var)))) )) (def: (build-ring num-connections) diff --git a/stdlib/test/test/lux/macro/code.lux b/stdlib/test/test/lux/macro/code.lux index 6c5a28265..0dfcd8fa0 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 = )))] - [(&.bool true) "true"] - [(&.bool false) "false"] - [(&.int 123) "123"] - [(&.frac 123.0) "123.0"] - [(&.text "\n") "\"\\n\""] - [(&.tag ["yolo" "lol"]) "#yolo.lol"] - [(&.symbol ["yolo" "lol"]) "yolo.lol"] - [(&.form (list (&.bool true) (&.int 123))) "(true 123)"] - [(&.tuple (list (&.bool true) (&.int 123))) "[true 123]"] - [(&.record (list [(&.bool true) (&.int 123)])) "{true 123}"] - [(&.local-tag "lol") "#lol"] - [(&.local-symbol "lol") "lol"] + [(&.bit true) "true"] + [(&.bit false) "false"] + [(&.int 123) "123"] + [(&.frac 123.0) "123.0"] + [(&.text "\n") "\"\\n\""] + [(&.tag ["yolo" "lol"]) "#yolo.lol"] + [(&.symbol ["yolo" "lol"]) "yolo.lol"] + [(&.form (list (&.bit true) (&.int 123))) "(true 123)"] + [(&.tuple (list (&.bit true) (&.int 123))) "[true 123]"] + [(&.record (list [(&.bit true) (&.int 123)])) "{true 123}"] + [(&.local-tag "lol") "#lol"] + [(&.local-symbol "lol") "lol"] )] ($_ seq ))) diff --git a/stdlib/test/test/lux/macro/poly/equivalence.lux b/stdlib/test/test/lux/macro/poly/equivalence.lux index 3ae57cd40..d6b48428a 100644 --- a/stdlib/test/test/lux/macro/poly/equivalence.lux +++ b/stdlib/test/test/lux/macro/poly/equivalence.lux @@ -5,7 +5,7 @@ [monad (#+ do Monad)] [equivalence (#+ Equivalence)]] [data - [bool] + [bit] [maybe] [number ("int/" Number)] ["." text @@ -20,7 +20,7 @@ ## [Utils] (type: Variant - (#Case0 Bool) + (#Case0 Bit) (#Case1 Int) (#Case2 Frac)) @@ -29,7 +29,7 @@ (#Addition Frac Recursive)) (type: Record - {#bool Bool + {#bit Bit #int Int #frac Frac #text Text @@ -51,13 +51,13 @@ [size (:: @ map (n/% +2) r.nat) #let [gen-int (|> r.int (:: @ map (|>> int/abs (i/% 1_000_000))))]] ($_ r.seq - r.bool + r.bit gen-int r.frac (r.unicode size) (r.maybe gen-int) (r.list size gen-int) - ($_ r.alt r.bool gen-int r.frac) + ($_ r.alt r.bit gen-int r.frac) ($_ r.seq gen-int r.frac (r.unicode size)) gen-recursive))) diff --git a/stdlib/test/test/lux/macro/syntax.lux b/stdlib/test/test/lux/macro/syntax.lux index 8d2b5ff8c..35e25734f 100644 --- a/stdlib/test/test/lux/macro/syntax.lux +++ b/stdlib/test/test/lux/macro/syntax.lux @@ -6,7 +6,7 @@ [equivalence (#+ Equivalence)] ["p" parser]] [data - [bool] + [bit] [ident] ["e" error] [number] @@ -21,7 +21,7 @@ ## [Utils] (def: (enforced? parser input) - (-> (Syntax []) (List Code) Bool) + (-> (Syntax []) (List Code) Bit) (case (p.run input parser) (#.Right [_ []]) true @@ -30,7 +30,7 @@ false)) (def: (found? parser input) - (-> (Syntax Bool) (List Code) Bool) + (-> (Syntax Bit) (List Code) Bit) (case (p.run input parser) (#.Right [_ true]) true @@ -39,7 +39,7 @@ false)) (def: (equals? Equivalence reference parser input) - (All [a] (-> (Equivalence a) a (Syntax a) (List Code) Bool)) + (All [a] (-> (Equivalence a) a (Syntax a) (List Code) Bit)) (case (p.run input parser) (#.Right [_ output]) (:: Equivalence = reference output) @@ -48,7 +48,7 @@ false)) (def: (fails? input) - (All [a] (-> (e.Error a) Bool)) + (All [a] (-> (e.Error a) Bit)) (case input (#.Left _) true @@ -73,7 +73,7 @@ (found? (s.this? ( )) (list ( ))) (enforced? (s.this ( )) (list ( )))))] - ["Can parse Bool syntax." true code.bool bool.Equivalence s.bool] + ["Can parse Bit syntax." true 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 Rev syntax." .123 code.rev number.Equivalence s.rev] @@ -105,21 +105,21 @@ [ (do-template [ ] [(test (format "Can parse " " syntax.") (and (match [true 123] - (p.run (list ( (list (code.bool true) (code.int 123)))) - ( (p.seq s.bool s.int)))) + (p.run (list ( (list (code.bit true) (code.int 123)))) + ( (p.seq s.bit s.int)))) (match true - (p.run (list ( (list (code.bool true)))) - ( s.bool))) - (fails? (p.run (list ( (list (code.bool true) (code.int 123)))) - ( s.bool))) + (p.run (list ( (list (code.bit true)))) + ( s.bit))) + (fails? (p.run (list ( (list (code.bit true) (code.int 123)))) + ( s.bit))) (match (#.Left true) - (p.run (list ( (list (code.bool true)))) - ( (p.alt s.bool s.int)))) + (p.run (list ( (list (code.bit true)))) + ( (p.alt s.bit s.int)))) (match (#.Right 123) (p.run (list ( (list (code.int 123)))) - ( (p.alt s.bool s.int)))) + ( (p.alt s.bit s.int)))) (fails? (p.run (list ( (list (code.frac 123.0)))) - ( (p.alt s.bool s.int))))))] + ( (p.alt s.bit s.int))))))] ["form" s.form code.form] ["tuple" s.tuple code.tuple])] @@ -128,15 +128,15 @@ (test "Can parse record syntax." (match [true 123] - (p.run (list (code.record (list [(code.bool true) (code.int 123)]))) - (s.record (p.seq s.bool s.int))))) + (p.run (list (code.record (list [(code.bit true) (code.int 123)]))) + (s.record (p.seq s.bit s.int))))) ))) (context: "Combinators" ($_ seq (test "Can parse any Code." - (match [_ (#.Bool true)] - (p.run (list (code.bool true) (code.int 123)) + (match [_ (#.Bit true)] + (p.run (list (code.bit true) (code.int 123)) s.any))) (test "Can check whether the end has been reached." @@ -144,13 +144,13 @@ (p.run (list) s.end?)) (match false - (p.run (list (code.bool true)) + (p.run (list (code.bit true)) s.end?)))) (test "Can ensure the end has been reached." (and (match [] (p.run (list) s.end!)) - (fails? (p.run (list (code.bool true)) + (fails? (p.run (list (code.bit true)) s.end!)))) )) diff --git a/stdlib/test/test/lux/math.lux b/stdlib/test/test/lux/math.lux index ab12c4894..920b0c951 100644 --- a/stdlib/test/test/lux/math.lux +++ b/stdlib/test/test/lux/math.lux @@ -4,21 +4,21 @@ [control [monad (#+ do Monad)]] [data - [bool ("bool/" Equivalence)] + [bit ("bit/" Equivalence)] [number ("frac/" Number)]] ["&" math ["r" random]]] lux/test) (def: (within? margin-of-error standard value) - (-> Frac Frac Frac Bool) + (-> Frac Frac Frac Bit) (f/< margin-of-error (frac/abs (f/- standard value)))) (def: margin Frac 0.0000001) (def: (trigonometric-symmetry forward backward angle) - (-> (-> Frac Frac) (-> Frac Frac) Frac Bool) + (-> (-> Frac Frac) (-> Frac Frac) Frac Bit) (let [normal (|> angle forward backward)] (|> normal forward backward (within? margin normal)))) @@ -114,12 +114,12 @@ (&.infix [(n/* +3 +9) &.n/gcd +450]))) (test "Can use non-numerical functions/macros as operators." - (bool/= (and (n/< y x) (n/< z y)) - (&.infix [[x n/< y] and [y n/< z]]))) - - (test "Can combine boolean operations in special ways via special keywords." - (and (bool/= (and (n/< y x) (n/< z y)) - (&.infix [#and x n/< y n/< z])) - (bool/= (and (n/< y x) (n/> z y)) - (&.infix [#and x n/< y n/> z])))) + (bit/= (and (n/< y x) (n/< z y)) + (&.infix [[x n/< y] and [y n/< z]]))) + + (test "Can combine bit operations in special ways via special keywords." + (and (bit/= (and (n/< y x) (n/< z y)) + (&.infix [#and x n/< y n/< z])) + (bit/= (and (n/< y x) (n/> z y)) + (&.infix [#and x n/< y n/> z])))) )))) diff --git a/stdlib/test/test/lux/math/logic/fuzzy.lux b/stdlib/test/test/lux/math/logic/fuzzy.lux index 53e183b35..104c0cf76 100644 --- a/stdlib/test/test/lux/math/logic/fuzzy.lux +++ b/stdlib/test/test/lux/math/logic/fuzzy.lux @@ -4,7 +4,7 @@ [control [monad (#+ do Monad)]] [data - [bool ("bool/" Equivalence)] + [bit ("bit/" Equivalence)] [number] [text format] @@ -46,14 +46,14 @@ (r/= ~false (&.membership top triangle)))) (test "Values within range, will have membership > 0." - (bool/= (r/> ~false (&.membership sample triangle)) - (and ( bottom sample) - ( top sample)))) + (bit/= (r/> ~false (&.membership sample triangle)) + (and ( bottom sample) + ( top sample)))) (test "Values outside of range, will have membership = 0." - (bool/= (r/= ~false (&.membership sample triangle)) - (or ( bottom sample) - ( top sample)))) + (bit/= (r/= ~false (&.membership sample triangle)) + (or ( bottom sample) + ( top sample)))) ))))] ["Rev" number.Hash r.rev &.triangle r/< r/<= r/> r/>=] @@ -88,19 +88,19 @@ (r/= ~false (&.membership top trapezoid)))) (test "Values within inner range will have membership = 1" - (bool/= (r/= ~true (&.membership sample trapezoid)) - (and ( middle-bottom sample) - ( middle-top sample)))) + (bit/= (r/= ~true (&.membership sample trapezoid)) + (and ( middle-bottom sample) + ( middle-top sample)))) (test "Values within range, will have membership > 0." - (bool/= (r/> ~false (&.membership sample trapezoid)) - (and ( bottom sample) - ( top sample)))) + (bit/= (r/> ~false (&.membership sample trapezoid)) + (and ( bottom sample) + ( top sample)))) (test "Values outside of range, will have membership = 0." - (bool/= (r/= ~false (&.membership sample trapezoid)) - (or ( bottom sample) - ( top sample)))) + (bit/= (r/= ~false (&.membership sample trapezoid)) + (or ( bottom sample) + ( top sample)))) ))))] ["Rev" number.Hash r.rev &.trapezoid r/< r/<= r/> r/>=] @@ -142,10 +142,10 @@ (~not (&.membership sample (&.complement left))))) (test "Membership in the difference will never be higher than in the set being subtracted." - (bool/= (r/> (&.membership sample right) - (&.membership sample left)) - (r/< (&.membership sample left) - (&.membership sample (&.difference left right))))) + (bit/= (r/> (&.membership sample right) + (&.membership sample left)) + (r/< (&.membership sample left) + (&.membership sample (&.difference left right))))) )))) (context: "From predicates and sets" @@ -156,13 +156,13 @@ ($_ seq (test "Values that satisfy a predicate have membership = 1. Values that don't have membership = 0." - (bool/= (r/= ~true (&.membership sample (&.from-predicate n/even?))) - (n/even? sample))) + (bit/= (r/= ~true (&.membership sample (&.from-predicate n/even?))) + (n/even? sample))) (test "Values that belong to a set have membership = 1. Values that don't have membership = 0." - (bool/= (r/= ~true (&.membership sample (&.from-set set-10))) - (set.member? set-10 sample))) + (bit/= (r/= ~true (&.membership sample (&.from-set set-10))) + (set.member? set-10 sample))) )))) (context: "Thresholds" @@ -175,10 +175,10 @@ member? (&.to-predicate threshold fuzzy)]] ($_ seq (test "Can increase the threshold of membership of a fuzzy set." - (bool/= (r/> ~false (&.membership sample vip-fuzzy)) - (r/> threshold (&.membership sample fuzzy)))) + (bit/= (r/> ~false (&.membership sample vip-fuzzy)) + (r/> threshold (&.membership sample fuzzy)))) (test "Can turn fuzzy sets into predicates through a threshold." - (bool/= (member? sample) - (r/> threshold (&.membership sample fuzzy)))) + (bit/= (member? sample) + (r/> threshold (&.membership sample fuzzy)))) )))) diff --git a/stdlib/test/test/lux/math/modular.lux b/stdlib/test/test/lux/math/modular.lux index 8bbaf1292..47b8b8aba 100644 --- a/stdlib/test/test/lux/math/modular.lux +++ b/stdlib/test/test/lux/math/modular.lux @@ -4,7 +4,7 @@ [monad (#+ do)]] [data [product] - [bool ("bool/" Equivalence)] + [bit ("bit/" Equivalence)] ["e" error] [text format]] @@ -39,20 +39,20 @@ (def: (comparison m/? i/?) (All [m] - (-> (-> (/.Mod m) (/.Mod m) Bool) - (-> Int Int Bool) - (-> (/.Mod m) (/.Mod m) Bool))) + (-> (-> (/.Mod m) (/.Mod m) Bit) + (-> Int Int Bit) + (-> (/.Mod m) (/.Mod m) Bit))) (function (_ param subject) - (bool/= (m/? param subject) - (i/? (value param) - (value subject))))) + (bit/= (m/? param subject) + (i/? (value param) + (value subject))))) (def: (arithmetic modulus m/! i/!) (All [m] (-> (/.Modulus m) (-> (/.Mod m) (/.Mod m) (/.Mod m)) (-> Int Int Int) - (-> (/.Mod m) (/.Mod m) Bool))) + (-> (/.Mod m) (/.Mod m) Bit))) (function (_ param subject) (|> (i/! (value param) (value subject)) @@ -91,13 +91,13 @@ ((comparison /.m/>= i/>=) param subject))) (test "Mod'ed values are ordered." - (and (bool/= (/.m/< param subject) - (not (/.m/>= param subject))) - (bool/= (/.m/> param subject) - (not (/.m/<= param subject))) - (bool/= (/.m/= param subject) - (not (or (/.m/< param subject) - (/.m/> param subject)))))) + (and (bit/= (/.m/< param subject) + (not (/.m/>= param subject))) + (bit/= (/.m/> param subject) + (not (/.m/<= param subject))) + (bit/= (/.m/= param subject) + (not (or (/.m/< param subject) + (/.m/> param subject)))))) (test "Can do arithmetic." (and ((arithmetic normalM /.m/+ i/+) param subject) @@ -145,6 +145,6 @@ (/.congruent? normalM _subject _subject)) (test "If 2 numbers are congruent under a modulus, then they must also be equal under the same modulus." - (bool/= (/.congruent? normalM _param _subject) - (/.m/= param subject))) + (bit/= (/.congruent? normalM _param _subject) + (/.m/= param subject))) )))) diff --git a/stdlib/test/test/lux/type/implicit.lux b/stdlib/test/test/lux/type/implicit.lux index e19f672e0..71e2f29c6 100644 --- a/stdlib/test/test/lux/type/implicit.lux +++ b/stdlib/test/test/lux/type/implicit.lux @@ -6,7 +6,7 @@ [functor] [monad (#+ do Monad)]] [data - [bool ("bool/" Equivalence)] + [bit ("bit/" Equivalence)] [number] [collection [list]]] [math @@ -22,8 +22,8 @@ ($_ seq (test "Can automatically select first-order structures." (let [(^open "list/") (list.Equivalence number.Equivalence)] - (and (bool/= (:: number.Equivalence = x y) - (::: = x y)) + (and (bit/= (:: number.Equivalence = x y) + (::: = x y)) (list/= (list.n/range +1 +10) (::: map inc (list.n/range +0 +9))) ))) diff --git a/stdlib/test/test/lux/type/object/protocol.lux b/stdlib/test/test/lux/type/object/protocol.lux index 0ec93442b..2e2ae212f 100644 --- a/stdlib/test/test/lux/type/object/protocol.lux +++ b/stdlib/test/test/lux/type/object/protocol.lux @@ -23,9 +23,9 @@ ((counter +0) (message []))) (protocol: Protocol0 - (method0 [Bool Nat Text] Bool) - (method1 [Nat Text Bool] Nat) - (method2 [Text Bool Nat] Text)) + (method0 [Bit Nat Text] Bit) + (method1 [Nat Text Bit] Nat) + (method2 [Text Bit Nat] Text)) (type: Object0 (Object Protocol0)) diff --git a/stdlib/test/test/lux/world/blob.lux b/stdlib/test/test/lux/world/blob.lux index f93b4e5dd..ea9dc4087 100644 --- a/stdlib/test/test/lux/world/blob.lux +++ b/stdlib/test/test/lux/world/blob.lux @@ -20,7 +20,7 @@ ["_eq" equivalence]]]]) (def: (succeed result) - (-> (e.Error Bool) Bool) + (-> (e.Error Bit) Bit) (case result (#e.Error _) false @@ -40,7 +40,7 @@ (:: r.Monad wrap output))))) (def: (bits-io bytes read write value) - (-> Nat (-> Nat /.Blob (e.Error Nat)) (-> Nat Nat /.Blob (e.Error Any)) Nat Bool) + (-> Nat (-> Nat /.Blob (e.Error Nat)) (-> Nat Nat /.Blob (e.Error Any)) Nat Bit) (let [blob (/.create +8) bits (n/* +8 bytes) capped-value (|> +1 (i64.left-shift bits) dec (i64.and value))] diff --git a/stdlib/test/test/lux/world/net/tcp.lux b/stdlib/test/test/lux/world/net/tcp.lux index 26b7703ea..1c315c7f5 100644 --- a/stdlib/test/test/lux/world/net/tcp.lux +++ b/stdlib/test/test/lux/world/net/tcp.lux @@ -42,7 +42,7 @@ (wrap (do P.Monad [result (do T.Monad [[server-close server] (@.server port) - #let [from-worked? (: (T.Task Bool) + #let [from-worked? (: (T.Task Bit) (P.promise #.Nil)) _ (frp/map (function (_ socket) (do @ -- cgit v1.2.3