core: parseExactChar

This commit is contained in:
Nathan McCarty 2025-01-24 22:36:08 -05:00
parent 40dd87a4f3
commit 7dba492535

View file

@ -185,6 +185,19 @@ parseString' : Parser (List1 Char) -> Parser String
parseString' x = parseString $ map forget x
```
Attempt to parse a specified character
```idris
export
parseExactChar : Char -> Parser Char
parseExactChar c = do
result <- parseChar (== c) id
case result of
GotChar char => pure char
GotError err => throwParseError "Got \{show err} Expected \{show c}"
EndOfInput => throwParseError "End of input"
```
### Composition of boolean functions
```idris