autoproof-0.0.0.0: Propositional logic library
Copyright(c) Artem Mavrin 2021
LicenseBSD3
Maintainerartemvmavrin@gmail.com
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe
LanguageHaskell2010

AutoProof.Internal.Utils.Parser.Char

Description

Defines character- and string-related parsers.

Synopsis

Documentation

charIf :: (Char -> Bool) -> Parser Char Source #

Parse a single character if it satisfies a predicate

Examples

Expand
>>> runParser (charIf isDigit) "123"
Just ("23",'1')
>>> runParser (charIf isDigit) "abc"
Nothing

char :: Char -> Parser Char Source #

Parse a specific character.

Examples

Expand
>>> runParser (char 'a') "abc"
Just ("bc",'a')
>>> runParser (char 'a') "def"
Nothing

anyChar :: Parser Char Source #

Parse any character.

Examples

Expand
>>> runParser anyChar "abc"
Just ("bc",'a')
>>> runParser anyChar ""
Nothing

spaces :: Parser String Source #

Parse zero or more spaces.

Examples

Expand
>>> runParser spaces "   123"
Just ("123","   ")
>>> runParser spaces "123"
Just ("123","")
>>> runParser spaces ""
Just ("","")

string :: String -> Parser String Source #

Parse a specific string.

Examples

Expand
>>> runParser (string "foo") "foobar"
Just ("bar","foo")
>>> runParser (string "foo") "fobar"
Nothing

oneOf :: [Char] -> Parser Char Source #

Parse one out of a list of characters.

Examples

Expand
>>> runParser (oneOf ['a', 'b']) "bar"
Just ("ar",'b')
>>> runParser (oneOf ['a', 'b']) "foo"
Nothing