aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/data/format/json.lux
diff options
context:
space:
mode:
authorEduardo Julian2021-07-27 03:51:10 -0400
committerEduardo Julian2021-07-27 03:51:10 -0400
commit061fd8a209bbcaffc2bfb850ac6046752a567d50 (patch)
tree8cd83ad7d0bc06ded7976eb5420467e485733ae8 /stdlib/source/library/lux/data/format/json.lux
parente64b6d0114c26a455e19a416b5f02a4d19dd711f (diff)
Re-named wrap => in && unwrap => out.
Diffstat (limited to 'stdlib/source/library/lux/data/format/json.lux')
-rw-r--r--stdlib/source/library/lux/data/format/json.lux53
1 files changed, 27 insertions, 26 deletions
diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux
index 30903df3c..417e7791d 100644
--- a/stdlib/source/library/lux/data/format/json.lux
+++ b/stdlib/source/library/lux/data/format/json.lux
@@ -1,5 +1,6 @@
-(.module: {#.doc (.doc "Functionality for reading and writing values in the JSON format."
- "For more information, please see: http://www.json.org/")}
+(.module:
+ {#.doc (.doc "Functionality for reading and writing values in the JSON format."
+ "For more information, please see: http://www.json.org/")}
[library
[lux #*
["." meta (#+ monad)]
@@ -79,16 +80,16 @@
(case token
(^template [<ast_tag> <ctor> <json_tag>]
[[_ (<ast_tag> value)]
- (wrap (list (` (: JSON (<json_tag> (~ (<ctor> value)))))))])
+ (in (list (` (: JSON (<json_tag> (~ (<ctor> value)))))))])
([#.Bit code.bit #..Boolean]
[#.Frac code.frac #..Number]
[#.Text code.text #..String])
[_ (#.Tag ["" "null"])]
- (wrap (list (` (: JSON #..Null))))
+ (in (list (` (: JSON #..Null))))
[_ (#.Tuple members)]
- (wrap (list (` (: JSON (#..Array ((~! row) (~+ (list\map wrapper members))))))))
+ (in (list (` (: JSON (#..Array ((~! row) (~+ (list\map wrapper members))))))))
[_ (#.Record pairs)]
(do {! ..monad}
@@ -96,17 +97,17 @@
(function (_ [slot value])
(case slot
[_ (#.Text key_name)]
- (wrap (` [(~ (code.text key_name)) (~ (wrapper value))]))
+ (in (` [(~ (code.text key_name)) (~ (wrapper value))]))
_
(meta.failure "Wrong syntax for JSON object.")))
pairs)]
- (wrap (list (` (: JSON (#..Object ((~! dictionary.of_list)
- (~! text.hash)
- (list (~+ pairs')))))))))
+ (in (list (` (: JSON (#..Object ((~! dictionary.of_list)
+ (~! text.hash)
+ (list (~+ pairs')))))))))
_
- (wrap (list token)))))
+ (in (list token)))))
(def: #export (fields json)
{#.doc "Get all the fields in a JSON object."}
@@ -187,7 +188,7 @@
(do maybe.monad
[x' (row.nth idx xs)
y' (row.nth idx ys)]
- (wrap (= x' y'))))))
+ (in (= x' y'))))))
#1
(list.indices (row.size xs))))
@@ -305,14 +306,14 @@
(Parser Null)
(do <>.monad
[_ (<text>.this "null")]
- (wrap [])))
+ (in [])))
(template [<name> <token> <value>]
[(def: <name>
(Parser Boolean)
(do <>.monad
[_ (<text>.this <token>)]
- (wrap <value>)))]
+ (in <value>)))]
[true_parser "true" #1]
[false_parser "false" #0]
@@ -338,31 +339,31 @@
[mark (<text>.one_of "eE")
signed?' (<>.parses? (<text>.this "-"))
offset (<text>.many <text>.decimal)]
- (wrap ($_ text\compose mark (if signed?' "-" "") offset))))]
+ (in ($_ text\compose mark (if signed?' "-" "") offset))))]
(case (f\decode ($_ text\compose (if signed? "-" "") digits "." decimals exp))
(#try.Failure message)
(<>.failure message)
(#try.Success value)
- (wrap value))))
+ (in value))))
(def: escaped_parser
(Parser Text)
($_ <>.either
(<>.after (<text>.this "\t")
- (<>\wrap text.tab))
+ (<>\in text.tab))
(<>.after (<text>.this "\b")
- (<>\wrap text.back_space))
+ (<>\in text.back_space))
(<>.after (<text>.this "\n")
- (<>\wrap text.new_line))
+ (<>\in text.new_line))
(<>.after (<text>.this "\r")
- (<>\wrap text.carriage_return))
+ (<>\in text.carriage_return))
(<>.after (<text>.this "\f")
- (<>\wrap text.form_feed))
+ (<>\in text.form_feed))
(<>.after (<text>.this (text\compose "\" text.double_quote))
- (<>\wrap text.double_quote))
+ (<>\in text.double_quote))
(<>.after (<text>.this "\\")
- (<>\wrap "\"))))
+ (<>\in "\"))))
(def: string_parser
(Parser String)
@@ -375,8 +376,8 @@
(do !
[escaped escaped_parser
next_chars (recur [])]
- (wrap ($_ text\compose chars escaped next_chars)))
- (wrap chars))))
+ (in ($_ text\compose chars escaped next_chars)))
+ (in chars))))
(def: (kv_parser json_parser)
(-> (Parser JSON) (Parser [String JSON]))
@@ -386,7 +387,7 @@
_ (<text>.this ..entry_separator)
_ ..space_parser
value json_parser]
- (wrap [key value])))
+ (in [key value])))
(template [<name> <type> <open> <close> <elem_parser> <prep>]
[(def: (<name> json_parser)
@@ -397,7 +398,7 @@
elems (<>.separated_by ..separator_parser <elem_parser>)
_ space_parser
_ (<text>.this <close>)]
- (wrap (<prep> elems))))]
+ (in (<prep> elems))))]
[array_parser Array ..open_array ..close_array json_parser row.of_list]
[object_parser Object ..open_object ..close_object (kv_parser json_parser) (dictionary.of_list text.hash)]