diff options
Diffstat (limited to 'stdlib/source/lux/data/format/json.lux')
-rw-r--r-- | stdlib/source/lux/data/format/json.lux | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux index 95d689059..1cbf9e665 100644 --- a/stdlib/source/lux/data/format/json.lux +++ b/stdlib/source/lux/data/format/json.lux @@ -102,7 +102,7 @@ (#R;Success (d;keys obj)) _ - (#R;Error ($_ text/append "Cannot get the fields of a non-object.")))) + (#R;Error ($_ text/compose "Cannot get the fields of a non-object.")))) (def: #export (get key json) {#;doc "A JSON object field getter."} @@ -114,10 +114,10 @@ (#R;Success value) #;None - (#R;Error ($_ text/append "Missing field \"" key "\" on object."))) + (#R;Error ($_ text/compose "Missing field \"" key "\" on object."))) _ - (#R;Error ($_ text/append "Cannot get field \"" key "\" of a non-object.")))) + (#R;Error ($_ text/compose "Cannot get field \"" key "\" of a non-object.")))) (def: #export (set key value json) {#;doc "A JSON object field setter."} @@ -127,18 +127,18 @@ (#R;Success (#Object (d;put key value obj))) _ - (#R;Error ($_ text/append "Cannot set field \"" key "\" of a non-object.")))) + (#R;Error ($_ text/compose "Cannot set field \"" key "\" of a non-object.")))) (do-template [<name> <tag> <type> <desc>] [(def: #export (<name> key json) - {#;doc (#;TextA ($_ text/append "A JSON object field getter for " <desc> "."))} + {#;doc (#;TextA ($_ text/compose "A JSON object field getter for " <desc> "."))} (-> Text JSON (R;Result <type>)) (case (get key json) (#R;Success (<tag> value)) (#R;Success value) (#R;Success _) - (#R;Error ($_ text/append "Wrong value type at key: " key)) + (#R;Error ($_ text/compose "Wrong value type at key: " key)) (#R;Error error) (#R;Error error)))] @@ -226,7 +226,7 @@ (do-template [<name> <type> <tag> <desc>] [(def: #export <name> - {#;doc (#;TextA ($_ text/append "Reads a JSON value as " <desc> "."))} + {#;doc (#;TextA ($_ text/compose "Reads a JSON value as " <desc> "."))} (Reader <type>) (do p;Monad<Parser> [head any] @@ -235,7 +235,7 @@ (wrap value) _ - (fail ($_ text/append "JSON value is not " <desc> ".")))))] + (fail ($_ text/compose "JSON value is not " <desc> ".")))))] [null Unit #Null "null"] [boolean Bool #Boolean "boolean"] @@ -245,7 +245,7 @@ (do-template [<test> <check> <type> <eq> <encoder> <tag> <desc> <pre>] [(def: #export (<test> test) - {#;doc (#;TextA ($_ text/append "Asks whether a JSON value is a " <desc> "."))} + {#;doc (#;TextA ($_ text/compose "Asks whether a JSON value is a " <desc> "."))} (-> <type> (Reader Bool)) (do p;Monad<Parser> [head any] @@ -254,10 +254,10 @@ (wrap (:: <eq> = test (<pre> value))) _ - (fail ($_ text/append "JSON value is not " <desc> "."))))) + (fail ($_ text/compose "JSON value is not " <desc> "."))))) (def: #export (<check> test) - {#;doc (#;TextA ($_ text/append "Ensures a JSON value is a " <desc> "."))} + {#;doc (#;TextA ($_ text/compose "Ensures a JSON value is a " <desc> "."))} (-> <type> (Reader Unit)) (do p;Monad<Parser> [head any] @@ -266,10 +266,10 @@ (let [value (<pre> value)] (if (:: <eq> = test value) (wrap []) - (fail ($_ text/append "Value mismatch: " (<encoder> test) "=/=" (<encoder> value))))) + (fail ($_ text/compose "Value mismatch: " (<encoder> test) "=/=" (<encoder> value))))) _ - (fail ($_ text/append "JSON value is not a " <desc> ".")))))] + (fail ($_ text/compose "JSON value is not a " <desc> ".")))))] [boolean? boolean! Bool bool;Eq<Bool> (:: bool;Codec<Text,Bool> encode) #Boolean "boolean" id] [number? number! Frac number;Eq<Frac> (:: number;Codec<Text,Frac> encode) #Number "number" id] @@ -347,7 +347,7 @@ (fail error)) _ - (fail ($_ text/append "JSON object does not have field \"" field-name "\"."))) + (fail ($_ text/compose "JSON object does not have field \"" field-name "\"."))) _ (fail "JSON value is not an object.")))) @@ -366,16 +366,16 @@ (def: (show-array show-json elems) (-> (-> JSON Text) (-> Array Text)) - ($_ text/append "[" + ($_ text/compose "[" (|> elems (Vector/map show-json) vector;to-list (text;join-with ",")) "]")) (def: (show-object show-json object) (-> (-> JSON Text) (-> Object Text)) - ($_ text/append "{" + ($_ text/compose "{" (|> object d;entries - (L/map (function [[key value]] ($_ text/append (show-string key) ":" (show-json value)))) + (L/map (function [[key value]] ($_ text/compose (show-string key) ":" (show-json value)))) (text;join-with ",")) "}")) @@ -436,8 +436,8 @@ [mark (l;one-of "eE") signed?' (l;this? "-") offset (l;many l;decimal)] - (wrap ($_ text/append mark (if signed?' "-" "") offset))))] - (case (frac/decode ($_ text/append (if signed? "-" "") digits "." decimals exp)) + (wrap ($_ text/compose mark (if signed?' "-" "") offset))))] + (case (frac/decode ($_ text/compose (if signed? "-" "") digits "." decimals exp)) (#R;Error message) (p;fail message) @@ -466,7 +466,7 @@ (do @ [escaped escaped~ next-chars (recur [])] - (wrap ($_ text/append chars escaped next-chars))) + (wrap ($_ text/compose chars escaped next-chars))) (wrap chars)))) (def: (kv~ json~) |