diff options
author | Eduardo Julian | 2021-09-12 15:39:55 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-09-12 15:39:55 -0400 |
commit | 2dbbaaec93a53f8dd0b96a0028b9cf125c9066cd (patch) | |
tree | 14bc8b5abe09b46ef005c3ff7cf132f1d98ddf0d /stdlib/source/library/lux/data/format/json.lux | |
parent | dda05bca0956af5e5b3875c4cc36e61aa04772e4 (diff) |
Re-named \ => # && \\ => ##
Diffstat (limited to 'stdlib/source/library/lux/data/format/json.lux')
-rw-r--r-- | stdlib/source/library/lux/data/format/json.lux | 72 |
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 734a38177..342e847f4 100644 --- a/stdlib/source/library/lux/data/format/json.lux +++ b/stdlib/source/library/lux/data/format/json.lux @@ -11,16 +11,16 @@ pipe ["[0]" maybe] ["[0]" try {"+" [Try]}] - ["<>" parser ("[1]\[0]" monad) + ["<>" parser ("[1]#[0]" monad) ["<[0]>" text {"+" [Parser]}] ["<[0]>" code]]] [data ["[0]" bit] ["[0]" product] - ["[0]" text ("[1]\[0]" equivalence monoid)] + ["[0]" text ("[1]#[0]" equivalence monoid)] [collection - ["[0]" list ("[1]\[0]" mix functor)] - ["[0]" row {"+" [Row row]} ("[1]\[0]" monad)] + ["[0]" list ("[1]#[0]" mix functor)] + ["[0]" row {"+" [Row row]} ("[1]#[0]" monad)] ["[0]" dictionary {"+" [Dictionary]}]]] [macro [syntax {"+" [syntax:]}] @@ -28,7 +28,7 @@ [math [number ["n" nat] - ["f" frac ("[1]\[0]" decimal)]]]]]) + ["f" frac ("[1]#[0]" decimal)]]]]]) (template [<name> <type>] [(type: .public <name> @@ -83,13 +83,13 @@ (<>.rec (function (_ jsonP) ($_ <>.or - (<code>.form (<>\in [])) + (<code>.form (<>#in [])) <code>.bit <code>.frac <code>.text - (<>\each row.of_list + (<>#each row.of_list (<code>.tuple (<>.some jsonP))) - (<>\each (dictionary.of_list text.hash) + (<>#each (dictionary.of_list text.hash) (<code>.variant (<>.some (<>.and <code>.text jsonP)))) <code>.any )))) @@ -108,14 +108,14 @@ [code.text ..#String' ..#String]) {#Array' members} - (` {..#Array ((~! row.row) (~+ (row.list (row\each jsonF members))))}) + (` {..#Array ((~! row.row) (~+ (row.list (row#each jsonF members))))}) {#Object' pairs} (` {..#Object ((~! dictionary.of_list) (~! text.hash) (list (~+ (|> pairs dictionary.entries - (list\each (function (_ [key_name value]) + (list#each (function (_ [key_name value]) (` [(~ (code.text key_name)) (~ (jsonF value))])))))))}) {#Code' code} @@ -131,7 +131,7 @@ {try.#Success (dictionary.keys obj)} _ - {try.#Failure ($_ text\composite "Cannot get the fields of a non-object.")})) + {try.#Failure ($_ text#composite "Cannot get the fields of a non-object.")})) (def: .public (field key json) (-> String JSON (Try JSON)) @@ -142,10 +142,10 @@ {try.#Success value} {.#None} - {try.#Failure ($_ text\composite "Missing field '" key "' on object.")}) + {try.#Failure ($_ text#composite "Missing field '" key "' on object.")}) _ - {try.#Failure ($_ text\composite "Cannot get field '" key "' on a non-object.")})) + {try.#Failure ($_ text#composite "Cannot get field '" key "' on a non-object.")})) (def: .public (has key value json) (-> String JSON JSON (Try JSON)) @@ -154,7 +154,7 @@ {try.#Success {#Object (dictionary.has key value obj)}} _ - {try.#Failure ($_ text\composite "Cannot set field '" key "' on a non-object.")})) + {try.#Failure ($_ text#composite "Cannot set field '" key "' on a non-object.")})) (template [<name> <tag> <type>] [(def: .public (<name> key json) @@ -164,7 +164,7 @@ {try.#Success value} {try.#Success _} - {try.#Failure ($_ text\composite "Wrong value type at key: " key)} + {try.#Failure ($_ text#composite "Wrong value type at key: " key)} {try.#Failure error} {try.#Failure error}))] @@ -186,14 +186,14 @@ (^template [<tag> <struct>] [[{<tag> x'} {<tag> y'}] - (\ <struct> = x' y')]) + (# <struct> = x' y')]) ([#Boolean bit.equivalence] [#Number f.equivalence] [#String text.equivalence]) [{#Array xs} {#Array ys}] (and (n.= (row.size xs) (row.size ys)) - (list\mix (function (_ idx prev) + (list#mix (function (_ idx prev) (and prev (maybe.else #0 (do maybe.monad @@ -205,7 +205,7 @@ [{#Object xs} {#Object ys}] (and (n.= (dictionary.size xs) (dictionary.size ys)) - (list\mix (function (_ [xk xv] prev) + (list#mix (function (_ [xk xv] prev) (and prev (case (dictionary.value xk ys) {.#None} #0 @@ -234,13 +234,13 @@ (-> Number Text) (|>> (case> (^or +0.0 -0.0) "0.0" - value (let [raw (\ f.decimal encoded value)] + value (let [raw (# f.decimal encoded value)] (if (f.< +0.0 value) raw (|> raw (text.split_at 1) maybe.trusted product.right)))))) (def: escape "\") -(def: escaped_dq (text\composite ..escape text.double_quote)) +(def: escaped_dq (text#composite ..escape text.double_quote)) (def: string_format (-> String Text) @@ -264,14 +264,14 @@ (def: (array_format format) (-> (-> JSON Text) (-> Array Text)) - (|>> (row\each format) + (|>> (row#each format) row.list (text.interposed ..value_separator) (text.enclosed [..array_start ..array_end]))) (def: (kv_format format [key value]) (-> (-> JSON Text) (-> [String JSON] Text)) - ($_ text\composite + ($_ text#composite (..string_format key) ..entry_separator (format value) @@ -280,7 +280,7 @@ (def: (object_format format) (-> (-> JSON Text) (-> Object Text)) (|>> dictionary.entries - (list\each (..kv_format format)) + (list#each (..kv_format format)) (text.interposed ..value_separator) (text.enclosed [..object_start ..object_end]))) @@ -350,8 +350,8 @@ [mark (<text>.one_of "eE") signed?' (<>.parses? (<text>.this "-")) offset (<text>.many <text>.decimal)] - (in ($_ text\composite mark (if signed?' "-" "") offset))))] - (case (f\decoded ($_ text\composite (if signed? "-" "") digits "." decimals exp)) + (in ($_ text#composite mark (if signed?' "-" "") offset))))] + (case (f#decoded ($_ text#composite (if signed? "-" "") digits "." decimals exp)) {try.#Failure message} (<>.failure message) @@ -362,32 +362,32 @@ (Parser Text) ($_ <>.either (<>.after (<text>.this "\t") - (<>\in text.tab)) + (<>#in text.tab)) (<>.after (<text>.this "\b") - (<>\in text.back_space)) + (<>#in text.back_space)) (<>.after (<text>.this "\n") - (<>\in text.new_line)) + (<>#in text.new_line)) (<>.after (<text>.this "\r") - (<>\in text.carriage_return)) + (<>#in text.carriage_return)) (<>.after (<text>.this "\f") - (<>\in text.form_feed)) - (<>.after (<text>.this (text\composite "\" text.double_quote)) - (<>\in text.double_quote)) + (<>#in text.form_feed)) + (<>.after (<text>.this (text#composite "\" text.double_quote)) + (<>#in text.double_quote)) (<>.after (<text>.this "\\") - (<>\in "\")))) + (<>#in "\")))) (def: string_parser (Parser String) (<| (<text>.enclosed [text.double_quote text.double_quote]) (loop [_ []]) (do [! <>.monad] - [chars (<text>.some (<text>.none_of (text\composite "\" text.double_quote))) + [chars (<text>.some (<text>.none_of (text#composite "\" text.double_quote))) stop <text>.next]) - (if (text\= "\" stop) + (if (text#= "\" stop) (do ! [escaped escaped_parser next_chars (recur [])] - (in ($_ text\composite chars escaped next_chars))) + (in ($_ text#composite chars escaped next_chars))) (in chars)))) (def: (kv_parser json_parser) |