aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/data/format/json.lux
diff options
context:
space:
mode:
authorEduardo Julian2022-06-16 00:48:19 -0400
committerEduardo Julian2022-06-16 00:48:19 -0400
commit9e2f1e76f2c8df01ed7687d934c3210fcf676bd6 (patch)
tree115fab5bd8a5f53dc0d13ce5453095324a83496f /stdlib/source/library/lux/data/format/json.lux
parentf92c806ee8da63f04bbefbf558f6249bacdb47ea (diff)
De-sigil-ification: suffix : [Part 13]
Diffstat (limited to 'stdlib/source/library/lux/data/format/json.lux')
-rw-r--r--stdlib/source/library/lux/data/format/json.lux72
1 files changed, 36 insertions, 36 deletions
diff --git a/stdlib/source/library/lux/data/format/json.lux b/stdlib/source/library/lux/data/format/json.lux
index 19c3a9bba..af8a52bb4 100644
--- a/stdlib/source/library/lux/data/format/json.lux
+++ b/stdlib/source/library/lux/data/format/json.lux
@@ -59,12 +59,12 @@
[Object (Dictionary String JSON)]
)
-(def: .public null?
+(def .public null?
(Predicate JSON)
(|>> (pipe.case {#Null} true
_ false)))
-(def: .public object
+(def .public object
(-> (List [String JSON]) JSON)
(|>> (dictionary.of_list text.hash) {..#Object}))
@@ -79,7 +79,7 @@
{#Object' (Dictionary String JSON')}
{#Code' Code})))
-(def: jsonP
+(def jsonP
(<code>.Parser JSON')
(<>.rec
(function (_ jsonP)
@@ -95,7 +95,7 @@
<code>.any
))))
-(def: (jsonF token)
+(def (jsonF token)
(-> JSON' Code)
(case token
{#Null' _}
@@ -122,11 +122,11 @@
{#Code' code}
code))
-(def: .public json
+(def .public json
(syntax (_ [token ..jsonP])
(in (list (` (is JSON (~ (jsonF token))))))))
-(def: .public (fields json)
+(def .public (fields json)
(-> JSON (Try (List String)))
(case json
{#Object obj}
@@ -135,7 +135,7 @@
_
{try.#Failure (all text#composite "Cannot get the fields of a non-object.")}))
-(def: .public (field key json)
+(def .public (field key json)
(-> String JSON (Try JSON))
(case json
{#Object obj}
@@ -149,7 +149,7 @@
_
{try.#Failure (all text#composite "Cannot get field '" key "' on a non-object.")}))
-(def: .public (has key value json)
+(def .public (has key value json)
(-> String JSON JSON (Try JSON))
(case json
{#Object obj}
@@ -159,7 +159,7 @@
{try.#Failure (all text#composite "Cannot set field '" key "' on a non-object.")}))
(with_template [<name> <tag> <type>]
- [(def: .public (<name> key json)
+ [(def .public (<name> key json)
(-> Text JSON (Try <type>))
(case (field key json)
{try.#Success {<tag> value}}
@@ -178,10 +178,10 @@
[object_field #Object Object]
)
-(def: .public equivalence
+(def .public equivalence
(Equivalence JSON)
(implementation
- (def: (= x y)
+ (def (= x y)
(case [x y]
[{#Null} {#Null}]
#1
@@ -222,17 +222,17 @@
............................................................
............................................................
-(def: (null_format _)
+(def (null_format _)
(-> Null Text)
"null")
-(def: boolean_format
+(def boolean_format
(-> Boolean Text)
(|>> (pipe.case
#0 "false"
#1 "true")))
-(def: number_format
+(def number_format
(-> Number Text)
(|>> (pipe.case
+0.0 ... OR -0.0
@@ -244,16 +244,16 @@
raw
(|> raw (text.split_at 1) maybe.trusted product.right))))))
-(def: escape "\")
-(def: escaped_dq (text#composite ..escape text.double_quote))
+(def escape "\")
+(def escaped_dq (text#composite ..escape text.double_quote))
-(def: string_format
+(def string_format
(-> String Text)
(|>> (text.replaced text.double_quote ..escaped_dq)
(text.enclosed [text.double_quote text.double_quote])))
(with_template [<token> <name>]
- [(def: <name>
+ [(def <name>
Text
<token>)]
@@ -267,14 +267,14 @@
["}" object_end]
)
-(def: (array_format format)
+(def (array_format format)
(-> (-> JSON Text) (-> Array Text))
(|>> (sequence#each format)
sequence.list
(text.interposed ..value_separator)
(text.enclosed [..array_start ..array_end])))
-(def: (kv_format format [key value])
+(def (kv_format format [key value])
(-> (-> JSON Text) (-> [String JSON] Text))
(all text#composite
(..string_format key)
@@ -282,14 +282,14 @@
(format value)
))
-(def: (object_format format)
+(def (object_format format)
(-> (-> JSON Text) (-> Object Text))
(|>> dictionary.entries
(list#each (..kv_format format))
(text.interposed ..value_separator)
(text.enclosed [..object_start ..object_end])))
-(def: .public (format json)
+(def .public (format json)
(-> JSON Text)
(case json
(^.with_template [<tag> <format>]
@@ -307,25 +307,25 @@
............................................................
............................................................
-(def: space_parser
+(def space_parser
(Parser Text)
(<text>.some <text>.space))
-(def: value_separator_parser
+(def value_separator_parser
(Parser [Text Any Text])
(all <>.and
..space_parser
(<text>.this ..value_separator)
..space_parser))
-(def: null_parser
+(def null_parser
(Parser Null)
(do <>.monad
[_ (<text>.this "null")]
(in [])))
(with_template [<name> <token> <value>]
- [(def: <name>
+ [(def <name>
(Parser Boolean)
(do <>.monad
[_ (<text>.this <token>)]
@@ -335,13 +335,13 @@
[false_parser "false" #0]
)
-(def: boolean_parser
+(def boolean_parser
(Parser Boolean)
(all <>.either
..true_parser
..false_parser))
-(def: number_parser
+(def number_parser
(Parser Number)
(do [! <>.monad]
[signed? (<>.parses? (<text>.this "-"))
@@ -363,7 +363,7 @@
{try.#Success value}
(in value))))
-(def: escaped_parser
+(def escaped_parser
(Parser Text)
(all <>.either
(<>.after (<text>.this "\t")
@@ -381,7 +381,7 @@
(<>.after (<text>.this "\\")
(<>#in "\"))))
-(def: string_parser
+(def string_parser
(Parser String)
(<| (<text>.enclosed [text.double_quote text.double_quote])
(loop (again [_ []]))
@@ -395,7 +395,7 @@
(in (all text#composite chars escaped next_chars)))
(in chars))))
-(def: (kv_parser json_parser)
+(def (kv_parser json_parser)
(-> (Parser JSON) (Parser [String JSON]))
(do <>.monad
[key ..string_parser
@@ -406,7 +406,7 @@
(in [key value])))
(with_template [<name> <type> <open> <close> <elem_parser> <prep>]
- [(def: (<name> json_parser)
+ [(def (<name> json_parser)
(-> (Parser JSON) (Parser <type>))
(do <>.monad
[_ (<text>.this <open>)
@@ -420,7 +420,7 @@
[object_parser Object ..object_start ..object_end (kv_parser json_parser) (dictionary.of_list text.hash)]
)
-(def: json_parser
+(def json_parser
(Parser JSON)
(<>.rec
(function (_ json_parser)
@@ -432,8 +432,8 @@
(array_parser json_parser)
(object_parser json_parser)))))
-(def: .public codec
+(def .public codec
(Codec Text JSON)
(implementation
- (def: encoded ..format)
- (def: decoded (<text>.result json_parser))))
+ (def encoded ..format)
+ (def decoded (<text>.result json_parser))))