From 77dcc4d95329648f406702ab4fc8e91057bc2b52 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Sat, 25 Jan 2025 13:37:20 -0500 Subject: [PATCH] json: oneOfM refactor --- src/Parser/JSON.md | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Parser/JSON.md b/src/Parser/JSON.md index 1f1ccde..50c24a2 100644 --- a/src/Parser/JSON.md +++ b/src/Parser/JSON.md @@ -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