diff options
author | Eduardo Julian | 2019-07-02 23:36:02 -0400 |
---|---|---|
committer | Eduardo Julian | 2019-07-02 23:36:02 -0400 |
commit | 91c0619657bcf2ac520e7dd2912188f66bbe2157 (patch) | |
tree | f26675f263eb5f0285c1674b0777a7369248fe07 /stdlib/source/lux/data/format/json.lux | |
parent | 4f191540f831a7bba0e262b1a6b598f99fb9b35c (diff) |
Re-name "lux/data/error" to "lux/control/try".
Diffstat (limited to '')
-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 219f7cd9b..2c4d3ada1 100644 --- a/stdlib/source/lux/data/format/json.lux +++ b/stdlib/source/lux/data/format/json.lux @@ -7,13 +7,13 @@ codec] [control pipe + ["." try (#+ Try)] ["p" parser ("#@." monad) ["l" text (#+ Parser)] ["s" code]]] [data ["." bit] ["." maybe] - ["." error (#+ Error)] ["." product] [number ["." frac ("#@." decimal)]] @@ -93,52 +93,52 @@ (def: #export (get-fields json) {#.doc "Get all the fields in a JSON object."} - (-> JSON (Error (List String))) + (-> JSON (Try (List String))) (case json (#Object obj) - (#error.Success (dictionary.keys obj)) + (#try.Success (dictionary.keys obj)) _ - (#error.Failure ($_ text@compose "Cannot get the fields of a non-object.")))) + (#try.Failure ($_ text@compose "Cannot get the fields of a non-object.")))) (def: #export (get key json) {#.doc "A JSON object field getter."} - (-> String JSON (Error JSON)) + (-> String JSON (Try JSON)) (case json (#Object obj) (case (dictionary.get key obj) (#.Some value) - (#error.Success value) + (#try.Success value) #.None - (#error.Failure ($_ text@compose "Missing field '" key "' on object."))) + (#try.Failure ($_ text@compose "Missing field '" key "' on object."))) _ - (#error.Failure ($_ text@compose "Cannot get field '" key "' of a non-object.")))) + (#try.Failure ($_ text@compose "Cannot get field '" key "' of a non-object.")))) (def: #export (set key value json) {#.doc "A JSON object field setter."} - (-> String JSON JSON (Error JSON)) + (-> String JSON JSON (Try JSON)) (case json (#Object obj) - (#error.Success (#Object (dictionary.put key value obj))) + (#try.Success (#Object (dictionary.put key value obj))) _ - (#error.Failure ($_ text@compose "Cannot set field '" key "' of a non-object.")))) + (#try.Failure ($_ text@compose "Cannot set field '" key "' of a non-object.")))) (template [<name> <tag> <type> <desc>] [(def: #export (<name> key json) {#.doc (code.text ($_ text@compose "A JSON object field getter for " <desc> "."))} - (-> Text JSON (Error <type>)) + (-> Text JSON (Try <type>)) (case (get key json) - (#error.Success (<tag> value)) - (#error.Success value) + (#try.Success (<tag> value)) + (#try.Success value) - (#error.Success _) - (#error.Failure ($_ text@compose "Wrong value type at key: " key)) + (#try.Success _) + (#try.Failure ($_ text@compose "Wrong value type at key: " key)) - (#error.Failure error) - (#error.Failure error)))] + (#try.Failure error) + (#try.Failure error)))] [get-boolean #Boolean Boolean "booleans"] [get-number #Number Number "numbers"] @@ -287,10 +287,10 @@ offset (l.many l.decimal)] (wrap ($_ text@compose mark (if signed?' "-" "") offset))))] (case (frac@decode ($_ text@compose (if signed? "-" "") digits "." decimals exp)) - (#error.Failure message) + (#try.Failure message) (p.fail message) - (#error.Success value) + (#try.Success value) (wrap value)))) (def: escaped~ |