aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/control/parser/json.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/lux/control/parser/json.lux')
-rw-r--r--stdlib/source/lux/control/parser/json.lux36
1 files changed, 18 insertions, 18 deletions
diff --git a/stdlib/source/lux/control/parser/json.lux b/stdlib/source/lux/control/parser/json.lux
index 1ef75eab4..ed1620627 100644
--- a/stdlib/source/lux/control/parser/json.lux
+++ b/stdlib/source/lux/control/parser/json.lux
@@ -3,10 +3,10 @@
[abstract
["." monad (#+ do)]]
[control
+ ["." try (#+ Try)]
["." exception (#+ exception:)]]
[data
["." bit]
- ["." error (#+ Error)]
["." text ("#@." equivalence monoid)]
[number
["." frac]]
@@ -31,23 +31,23 @@
(exception: #export empty-input)
(def: #export (run json parser)
- (All [a] (-> JSON (Parser a) (Error a)))
+ (All [a] (-> JSON (Parser a) (Try a)))
(case (//.run parser (list json))
- (#error.Success [remainder output])
+ (#try.Success [remainder output])
(case remainder
#.Nil
- (#error.Success output)
+ (#try.Success output)
_
(exception.throw unconsumed-input remainder))
- (#error.Failure error)
- (#error.Failure error)))
+ (#try.Failure error)
+ (#try.Failure error)))
(def: #export (fail error)
(All [a] (-> Text (Parser a)))
(function (_ inputs)
- (#error.Failure error)))
+ (#try.Failure error)))
(def: #export any
{#.doc "Just returns the JSON input without applying any logic."}
@@ -58,7 +58,7 @@
(exception.throw empty-input [])
(#.Cons head tail)
- (#error.Success [tail head]))))
+ (#try.Success [tail head]))))
(template [<name> <type> <tag> <desc>]
[(def: #export <name>
@@ -124,10 +124,10 @@
(case head
(#/.Array values)
(case (//.run parser (row.to-list values))
- (#error.Failure error)
+ (#try.Failure error)
(fail error)
- (#error.Success [remainder output])
+ (#try.Success [remainder output])
(case remainder
#.Nil
(wrap output)
@@ -151,10 +151,10 @@
(list (#/.String key) value)))
list.concat
(//.run parser))
- (#error.Failure error)
+ (#try.Failure error)
(fail error)
- (#error.Success [remainder output])
+ (#try.Success [remainder output])
(case remainder
#.Nil
(wrap output)
@@ -173,15 +173,15 @@
(^ (list& (#/.String key) value inputs'))
(if (text@= key field-name)
(case (//.run parser (list value))
- (#error.Success [#.Nil output])
- (#error.Success [inputs' output])
+ (#try.Success [#.Nil output])
+ (#try.Success [inputs' output])
- (#error.Success [inputs'' _])
+ (#try.Success [inputs'' _])
(exception.throw unconsumed-input inputs'')
- (#error.Failure error)
- (#error.Failure error))
- (do error.monad
+ (#try.Failure error)
+ (#try.Failure error))
+ (do try.monad
[[inputs'' output] (recur inputs')]
(wrap [(list& (#/.String key) value inputs'')
output])))