Documentation.Haddock.Parser.Monad

haddock-library-1.4.3: Library exposing some functionality of Haddock.

Safe Haskell | None
Language | Haskell2010

Documentation.Haddock.Parser.Monad

Synopsis

- newtype ParserState = ParserState {
  - parserStateSince :: Maybe Version
  }
- initialParserState :: ParserState
- newtype Parser a = Parser (StateT ParserState Parser a)
- parseOnly :: Parser a -> ByteString -> Either String (ParserState, a)
- lift :: Parser a -> Parser a
- setParserState :: ParserState -> Parser ()
- setSince :: Version -> Parser ()
- char :: Char -> Parser Char
- char8 :: Char -> Parser Word8
- anyChar :: Parser Char
- notChar :: Char -> Parser Char
- satisfy :: (Char -> Bool) -> Parser Char
- peekChar :: Parser (Maybe Char)
- peekChar' :: Parser Char
- digit :: Parser Char
- letter_iso8859_15 :: Parser Char
- letter_ascii :: Parser Char
- space :: Parser Char
- string :: ByteString -> Parser ByteString
- stringCI :: ByteString -> Parser ByteString
- skipSpace :: Parser ()
- skipWhile :: (Char -> Bool) -> Parser ()
- take :: Int -> Parser ByteString
- scan :: s -> (s -> Char -> Maybe s) -> Parser ByteString
- takeWhile :: (Char -> Bool) -> Parser ByteString
- takeWhile1 :: (Char -> Bool) -> Parser ByteString
- takeTill :: (Char -> Bool) -> Parser ByteString
- takeByteString :: Parser ByteString
- takeLazyByteString :: Parser ByteString
- endOfLine :: Parser ()
- decimal :: Integral a => Parser a
- hexadecimal :: (Integral a, Bits a) => Parser a
- endOfInput :: Parser ()
- atEnd :: Parser Bool
- isDigit :: Char -> Bool
- isDigit_w8 :: Word8 -> Bool
- isAlpha_iso8859_15 :: Char -> Bool
- isAlpha_ascii :: Char -> Bool
- isSpace :: Char -> Bool
- isSpace_w8 :: Word8 -> Bool
- inClass :: String -> Char -> Bool
- notInClass :: String -> Char -> Bool
- isEndOfLine :: Word8 -> Bool
- isHorizontalSpace :: Word8 -> Bool
- choice :: Alternative f => [f a] -> f a
- count :: Monad m => Int -> m a -> m [a]
- option :: Alternative f => a -> f a -> f a
- many' :: MonadPlus m => m a -> m [a]
- many1 :: Alternative f => f a -> f [a]
- many1' :: MonadPlus m => m a -> m [a]
- manyTill :: Alternative f => f a -> f b -> f [a]
- manyTill' :: MonadPlus m => m a -> m b -> m [a]
- sepBy :: Alternative f => f a -> f s -> f [a]
- sepBy' :: MonadPlus m => m a -> m s -> m [a]
- sepBy1 :: Alternative f => f a -> f s -> f [a]
- sepBy1' :: MonadPlus m => m a -> m s -> m [a]
- skipMany :: Alternative f => f a -> f ()
- skipMany1 :: Alternative f => f a -> f ()
- eitherP :: Alternative f => f a -> f b -> f (Either a b)

# Documentation

newtype ParserState #

Constructors

ParserState |
Fields parserStateSince :: Maybe Version

Instances

Eq ParserState # |
Methods (==) :: ParserState -> ParserState -> Bool # (/=) :: ParserState -> ParserState -> Bool #
Show ParserState # |
Methods showsPrec :: Int -> ParserState -> ShowS # show :: ParserState -> String # showList :: [ParserState] -> ShowS #

initialParserState :: ParserState #

newtype Parser a #

Constructors

Parser (StateT ParserState Parser a) |

Instances

Monad Parser # |
Methods (>>=) :: Parser a -> (a -> Parser b) -> Parser b # (>>) :: Parser a -> Parser b -> Parser b # return :: a -> Parser a # fail :: String -> Parser a #
Functor Parser # |
Methods fmap :: (a -> b) -> Parser a -> Parser b # (<$) :: a -> Parser b -> Parser a #
Applicative Parser # |
Methods pure :: a -> Parser a # (<*>) :: Parser (a -> b) -> Parser a -> Parser b # (*>) :: Parser a -> Parser b -> Parser b # (<*) :: Parser a -> Parser b -> Parser a #
Alternative Parser # |
Methods empty :: Parser a # (<|>) :: Parser a -> Parser a -> Parser a # some :: Parser a -> Parser [a] # many :: Parser a -> Parser [a] #
MonadPlus Parser # |
Methods mzero :: Parser a # mplus :: Parser a -> Parser a -> Parser a #
(~) * a ByteString => IsString (Parser a) # |
Methods fromString :: String -> Parser a #

parseOnly :: Parser a -> ByteString -> Either String (ParserState, a) #

lift :: Parser a -> Parser a #

setParserState :: ParserState -> Parser () #

setSince :: Version -> Parser () #

char :: Char -> Parser Char #

char8 :: Char -> Parser Word8 #

anyChar :: Parser Char #

notChar :: Char -> Parser Char #

satisfy :: (Char -> Bool) -> Parser Char #

peekChar :: Parser (Maybe Char) #

peekChar' :: Parser Char #

digit :: Parser Char #

letter_iso8859_15 :: Parser Char #

letter_ascii :: Parser Char #

space :: Parser Char #

string :: ByteString -> Parser ByteString #

stringCI :: ByteString -> Parser ByteString #

skipSpace :: Parser () #

skipWhile :: (Char -> Bool) -> Parser () #

take :: Int -> Parser ByteString #

scan :: s -> (s -> Char -> Maybe s) -> Parser ByteString #

takeWhile :: (Char -> Bool) -> Parser ByteString #

takeWhile1 :: (Char -> Bool) -> Parser ByteString #

takeTill :: (Char -> Bool) -> Parser ByteString #

takeByteString :: Parser ByteString #

takeLazyByteString :: Parser ByteString #

endOfLine :: Parser () #

decimal :: Integral a => Parser a #

hexadecimal :: (Integral a, Bits a) => Parser a #

endOfInput :: Parser () #

atEnd :: Parser Bool #

isDigit :: Char -> Bool #

A fast digit predicate.

isDigit_w8 :: Word8 -> Bool #

A fast digit predicate.

isAlpha_iso8859_15 :: Char -> Bool #

A fast alphabetic predicate for the ISO-8859-15 encoding

Note: For all character encodings other than ISO-8859-15, and almost all Unicode code points above U+00A3, this predicate gives wrong answers.

isAlpha_ascii :: Char -> Bool #

A fast alphabetic predicate for the ASCII encoding

Note: For all character encodings other than ASCII, and almost all Unicode code points above U+007F, this predicate gives wrong answers.

isSpace :: Char -> Bool #

Fast predicate for matching ASCII space characters.

Note: This predicate only gives correct answers for the ASCII encoding. For instance, it does not recognise U+00A0 (non-breaking space) as a space character, even though it is a valid ISO-8859-15 byte. For a Unicode-aware and only slightly slower predicate, use `isSpace`

isSpace_w8 :: Word8 -> Bool #

Fast `Word8` predicate for matching ASCII space characters.

inClass :: String -> Char -> Bool #

Match any character in a set.

    vowel = inClass "aeiou"

Range notation is supported.

    halfAlphabet = inClass "a-nA-N"

To add a literal '-' to a set, place it at the beginning or end of the string.

notInClass :: String -> Char -> Bool #

Match any character not in a set.

isEndOfLine :: Word8 -> Bool #

A predicate that matches either a carriage return `'\r'` or newline `'\n'` character.

isHorizontalSpace :: Word8 -> Bool #

A predicate that matches either a space `' '` or horizontal tab `'\t'` character.

choice :: Alternative f => [f a] -> f a #

`choice ps` tries to apply the actions in the list `ps` in order, until one of them succeeds. Returns the value of the succeeding action.

count :: Monad m => Int -> m a -> m [a] #

Apply the given action repeatedly, returning every result.

option :: Alternative f => a -> f a -> f a #

`option x p` tries to apply action `p`. If `p` fails without consuming input, it returns the value `x`, otherwise the value returned by `p`.

    priority  = option 0 (digitToInt <$> digit)

many' :: MonadPlus m => m a -> m [a] #

`many' p` applies the action `p` zero or more times. Returns a list of the returned values of `p`. The value returned by `p` is forced to WHNF.

     word  = many' letter

many1 :: Alternative f => f a -> f [a] #

`many1 p` applies the action `p` one or more times. Returns a list of the returned values of `p`.

     word  = many1 letter

many1' :: MonadPlus m => m a -> m [a] #

`many1' p` applies the action `p` one or more times. Returns a list of the returned values of `p`. The value returned by `p` is forced to WHNF.

     word  = many1' letter

manyTill :: Alternative f => f a -> f b -> f [a] #

`manyTill p end` applies action `p` zero or more times until action `end` succeeds, and returns the list of values returned by `p`. This can be used to scan comments:

     simpleComment   = string "<!--" *> manyTill anyChar (string "-->")

(Note the overlapping parsers `anyChar` and `string "-->"`. While this will work, it is not very efficient, as it will cause a lot of backtracking.)

manyTill' :: MonadPlus m => m a -> m b -> m [a] #

`manyTill' p end` applies action `p` zero or more times until action `end` succeeds, and returns the list of values returned by `p`. This can be used to scan comments:

     simpleComment   = string "<!--" *> manyTill' anyChar (string "-->")

(Note the overlapping parsers `anyChar` and `string "-->"`. While this will work, it is not very efficient, as it will cause a lot of backtracking.)

The value returned by `p` is forced to WHNF.

sepBy :: Alternative f => f a -> f s -> f [a] #

`sepBy p sep` applies zero or more occurrences of `p`, separated by `sep`. Returns a list of the values returned by `p`.

    commaSep p  = p `sepBy` (symbol ",")

sepBy' :: MonadPlus m => m a -> m s -> m [a] #

`sepBy' p sep` applies zero or more occurrences of `p`, separated by `sep`. Returns a list of the values returned by `p`. The value returned by `p` is forced to WHNF.

    commaSep p  = p `sepBy'` (symbol ",")

sepBy1 :: Alternative f => f a -> f s -> f [a] #

`sepBy1 p sep` applies one or more occurrences of `p`, separated by `sep`. Returns a list of the values returned by `p`.

    commaSep p  = p `sepBy1` (symbol ",")

sepBy1' :: MonadPlus m => m a -> m s -> m [a] #

`sepBy1' p sep` applies one or more occurrences of `p`, separated by `sep`. Returns a list of the values returned by `p`. The value returned by `p` is forced to WHNF.

    commaSep p  = p `sepBy1'` (symbol ",")

skipMany :: Alternative f => f a -> f () #

Skip zero or more instances of an action.

skipMany1 :: Alternative f => f a -> f () #

Skip one or more instances of an action.

eitherP :: Alternative f => f a -> f b -> f (Either a b) #

Combine two alternatives.