Safe Haskell | Safe-Inferred |
---|
Parsing utilities for Text, using Attoparsec.
This module also exports some basic combinators. The idea is that modules that want to do a bit of parsing should be able to import this and need not import the underlying parsing library, which should make it easier to switch parsing libraries in the future if I want to. Of course the parsers may return a different type (ByteString vs. Text) so callers will still need a little modification to switch libraries.
Synopsis
- type Column = Int
- type Row = Int
- data Error = Error {}
- type Parser a = A.Parser a
- parse1 :: Parser a -> Text -> Either Text a
- parse :: Parser a -> Text -> Either Error a
- prefix :: Text -> Error -> Error
- offset :: (Row, Column) -> Error -> Error
- message :: Text -> Error
- show_error :: Error -> Text
- error_context :: Maybe Int -> Text -> Text
- parse_all :: A.Parser a -> Text -> Either (Text, Text) a
- infer_location :: Text -> Text -> Maybe (Text, (Int, Int))
- infer_column :: Text -> Text -> Maybe Int
- maybe_parse :: Parser a -> Text -> Maybe a
- maybe_parse_string :: Parser a -> String -> Maybe a
- float :: Text -> Maybe Double
- int :: Text -> Maybe Int
- nat :: Text -> Maybe Int
- between :: Parser x -> Parser y -> Parser a -> Parser a
- optional :: Parser a -> Parser (Maybe a)
- lexeme :: Parser a -> Parser a
- p_float :: Parser Double
- p_unsigned_float :: Parser Double
- p_int :: Parser Int
- p_nat :: Parser Int
- is_digit :: Char -> Bool
- p_word :: Parser Text
- many :: Alternative f => f a -> f [a]
Documentation
parse1 :: Parser a -> Text -> Either Text a Source #
Parse all the text, and annotate the error with the char number. For single-line input.
parse :: Parser a -> Text -> Either Error a Source #
Parse all of the text, and annotate the error with line number and column.
show_error :: Error -> Text Source #
lexeme :: Parser a -> Parser a Source #
Convert a parser into a lexeme parser by skipping whitespace afterwards.
many :: Alternative f => f a -> f [a] #
Zero or more.