From 91e1d2c9b17f14ce5d4415032362e84a29ea436d Mon Sep 17 00:00:00 2001
From: Nathan McCarty <thatonelutenist@stranger.systems>
Date: Sat, 25 Jan 2025 14:21:53 -0500
Subject: [PATCH] json: More refactor

---
 src/Parser/JSON.md | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/Parser/JSON.md b/src/Parser/JSON.md
index c69ea2c..48ecdbe 100644
--- a/src/Parser/JSON.md
+++ b/src/Parser/JSON.md
@@ -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
 ```