diff --git a/src/Parser/Interface.md b/src/Parser/Interface.md index 2c65cfa..3dc4251 100644 --- a/src/Parser/Interface.md +++ b/src/Parser/Interface.md @@ -238,6 +238,7 @@ parseTheseChars cs = do Attempt to parse an exact string ```idris +export exactString : String -> Parser String exactString str with (asList str) exactString "" | [] = pure "" diff --git a/src/Parser/JSON.md b/src/Parser/JSON.md index 453177a..7e83fd7 100644 --- a/src/Parser/JSON.md +++ b/src/Parser/JSON.md @@ -209,3 +209,31 @@ string = do _ <- parseExactChar '"' pure $ VString contents ``` + +```idris +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 +```