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 +++++++++++++++++++++++++------------------------- 1 file changed, 94 insertions(+), 94 deletions(-) (limited to 'stdlib/source/lux.lux') 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$] -- cgit v1.2.3