aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/data/format/json.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/data/format/json.lux')
-rw-r--r--stdlib/source/lux/data/format/json.lux28
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])