core: parseTheseChars

This commit is contained in:
Nathan McCarty 2025-01-24 23:57:16 -05:00
parent 7dba492535
commit 38c69c0ae3

View file

@ -198,6 +198,19 @@ parseExactChar c = do
EndOfInput => throwParseError "End of input"
```
Attempt to parse one of a list of chars
```idris
export
parseTheseChars : List Char -> Parser Char
parseTheseChars cs = do
result <- parseChar (\x => any (== x) cs) id
case result of
GotChar char => pure char
GotError err => throwParseError "Got \{show err} Expected one of \{show cs}"
EndOfInput => throwParseError "End of input"
```
### Composition of boolean functions
```idris