From 19ce8ac79897c8a7ccdfe00fc6f312a352da6f55 Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Sat, 25 Jan 2025 05:09:24 -0500 Subject: [PATCH] json: Bool and null --- src/Parser/JSON.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Parser/JSON.md b/src/Parser/JSON.md index c4d987d..7e83fd7 100644 --- a/src/Parser/JSON.md +++ b/src/Parser/JSON.md @@ -215,3 +215,25 @@ number = do d <- double pure $ VNumber d ``` + +```idris +bool = do + oneOfE + (throwParseError "Expected Bool") + (the (List _) [true, false]) + where + true : Parser (JSONValue TBool) + true = do + _ <- exactString "true" + pure $ VBool True + false : Parser (JSONValue TBool) + false = do + _ <- exactString "false" + pure $ VBool False +``` + +```idris +null = do + _ <- exactString "null" + pure VNull +```