diff options
author | Eduardo Julian | 2018-07-13 22:01:32 -0400 |
---|---|---|
committer | Eduardo Julian | 2018-07-13 22:01:32 -0400 |
commit | 69fefab57c40f323d759dc444dbcebad15071585 (patch) | |
tree | db08a3ea37c7818c8a98fc995d3c19440141b700 /stdlib/source/lux/data/format/json.lux | |
parent | 6acf4ffc362c0f8ef77d96f8cfe991adb2d9a0eb (diff) |
Re-named "Bool" type to "Bit".
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/data/format/json.lux | 28 |
1 files changed, 17 insertions, 11 deletions
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<Parser>)]] [data - [bool] + [bit] [text ("text/" Equivalence<Text> Monoid<Text>) ["l" lexer]] [number ("frac/" Codec<Text,Frac>) ("nat/" Codec<Text,Nat>)] @@ -28,7 +28,7 @@ [(type: #export <name> <type>)] [Null Any] - [Boolean Bool] + [Boolean Bit] [Number Frac] [String Text] ) @@ -67,9 +67,9 @@ (^template [<ast-tag> <ctor> <json-tag>] [_ (<ast-tag> value)] (wrap (list (` (: JSON (<json-tag> (~ (<ctor> 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 [<tag> <struct>] [(<tag> x') (<tag> y')] (:: <struct> = x' y')) - ([#Boolean bool.Equivalence<Bool>] + ([#Boolean bit.Equivalence<Bit>] [#Number number.Equivalence<Frac>] [#String text.Equivalence<Text>]) @@ -237,16 +237,22 @@ _ (fail ($_ text/compose "JSON value is not " <desc> ".")))))] - [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 [<test> <check> <type> <eq> <encoder> <tag> <desc> <pre>] [(def: #export (<test> test) {#.doc (code.text ($_ text/compose "Asks whether a JSON value is a " <desc> "."))} - (-> <type> (Reader Bool)) + (-> <type> (Reader Bit)) (do p.Monad<Parser> [head any] (case head @@ -271,7 +277,7 @@ _ (fail ($_ text/compose "JSON value is not a " <desc> ".")))))] - [boolean? boolean! Bool bool.Equivalence<Bool> (:: bool.Codec<Text,Bool> encode) #Boolean "boolean" id] + [boolean? boolean! Bit bit.Equivalence<Bit> encode-boolean #Boolean "boolean" id] [number? number! Frac number.Equivalence<Frac> (:: number.Codec<Text,Frac> encode) #Number "number" id] [string? string! Text text.Equivalence<Text> text.encode #String "string" id] ) @@ -360,7 +366,7 @@ (do-template [<name> <type> <codec>] [(def: <name> (-> <type> Text) <codec>)] - [show-boolean Boolean (:: bool.Codec<Text,Bool> encode)] + [show-boolean Boolean encode-boolean] [show-number Number (:: number.Codec<Text,Frac> encode)] [show-string String text.encode]) |