json: oneOfM refactor
This commit is contained in:
parent
aa1ae93165
commit
77dcc4d953
1 changed files with 15 additions and 16 deletions
|
@ -122,16 +122,15 @@ export
|
|||
value : Parser (t : JSONType ** JSONValue t)
|
||||
value = do
|
||||
surround whitespace $ oneOfE
|
||||
(throwParseError "Expected JSON Value")
|
||||
(the (List _)
|
||||
[
|
||||
dpairize object
|
||||
, dpairize array
|
||||
, dpairize string
|
||||
, dpairize number
|
||||
, dpairize bool
|
||||
, dpairize null
|
||||
])
|
||||
"Expected JSON Value"
|
||||
[
|
||||
dpairize object
|
||||
, dpairize array
|
||||
, dpairize string
|
||||
, dpairize number
|
||||
, dpairize bool
|
||||
, dpairize null
|
||||
]
|
||||
```
|
||||
|
||||
Now go through our json value types
|
||||
|
@ -139,8 +138,8 @@ Now go through our json value types
|
|||
```idris
|
||||
object = do
|
||||
oneOfE
|
||||
(throwParseError "Expected Object")
|
||||
(the (List _) [emptyObject, occupiedObject])
|
||||
"Expected Object"
|
||||
[emptyObject, occupiedObject]
|
||||
where
|
||||
emptyObject : Parser (JSONValue TObject)
|
||||
emptyObject = do
|
||||
|
@ -171,8 +170,8 @@ object = do
|
|||
```idris
|
||||
array = do
|
||||
oneOfE
|
||||
(throwParseError "Expected Array")
|
||||
(the (List _) [emptyArray, occupiedArray])
|
||||
"Expected Array"
|
||||
[emptyArray, occupiedArray]
|
||||
where
|
||||
emptyArray : Parser (JSONValue TArray)
|
||||
emptyArray = do
|
||||
|
@ -214,8 +213,8 @@ number = do
|
|||
```idris
|
||||
bool = do
|
||||
oneOfE
|
||||
(throwParseError "Expected Bool")
|
||||
(the (List _) [true, false])
|
||||
"Expected Bool"
|
||||
[true, false]
|
||||
where
|
||||
true : Parser (JSONValue TBool)
|
||||
true = do
|
||||
|
|
Loading…
Add table
Reference in a new issue