json: More refactor
This commit is contained in:
parent
a3c7729ab2
commit
91e1d2c9b1
1 changed files with 10 additions and 6 deletions
|
@ -185,21 +185,25 @@ array = do
|
|||
where
|
||||
emptyArray : Parser (JSONValue TArray)
|
||||
emptyArray = do
|
||||
_ <- parseExactChar '['
|
||||
_ <- many whitespace
|
||||
_ <- parseExactChar ']'
|
||||
delimited '[' ']' (nom whitespace)
|
||||
pure $ VArray Nil
|
||||
restValue : Parser (t : JSONType ** JSONValue t)
|
||||
restValue = do
|
||||
_ <- parseExactChar ','
|
||||
value
|
||||
values : Parser (List1 (t : JSONType ** JSONValue t))
|
||||
values = do
|
||||
first <- value
|
||||
rest <- many restValue
|
||||
pure $ first ::: rest
|
||||
occupiedArray : Parser (JSONValue TArray)
|
||||
occupiedArray = do
|
||||
_ <- parseExactChar '['
|
||||
first <- value
|
||||
rest <- many restValue
|
||||
xs <- values
|
||||
_ <- parseExactChar ']'
|
||||
let (types ** xs) = DList.fromList (first :: rest)
|
||||
-- TODO: Why is this busted?
|
||||
-- xs <- delimited '[' ']' values
|
||||
let (types ** xs) = DList.fromList (forget xs)
|
||||
pure $ VArray xs
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue