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/data/format/json.lux | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'stdlib/source/lux/data/format/json.lux') 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])
 
-- 
cgit v1.2.3