hledger-lib-1.21: A reusable library providing the core functionality of hledger
Safe HaskellNone
LanguageHaskell2010

Hledger.Utils.Parse

Contents

Synopsis

Documentation

type SimpleStringParser a = Parsec CustomErr String a Source #

A parser of string to some type.

type SimpleTextParser = Parsec CustomErr Text Source #

A parser of strict text to some type.

type TextParser m a = ParsecT CustomErr Text m a Source #

A parser of text that runs in some monad.

type JournalParser m a = StateT Journal (ParsecT CustomErr Text m) a Source #

A parser of text that runs in some monad, keeping a Journal as state.

type ErroringJournalParser m a = StateT Journal (ParsecT CustomErr Text (ExceptT FinalParseError m)) a Source #

A parser of text that runs in some monad, keeping a Journal as state, that can throw an exception to end parsing, preventing further parser backtracking.

choice' :: [TextParser m a] -> TextParser m a Source #

Backtracking choice, use this when alternatives share a prefix. Consumes no input if all choices fail.

choiceInState :: [StateT s (ParsecT CustomErr Text m) a] -> StateT s (ParsecT CustomErr Text m) a Source #

Backtracking choice, use this when alternatives share a prefix. Consumes no input if all choices fail.

surroundedBy :: Applicative m => m openclose -> m a -> m a Source #

parseWithState :: Monad m => st -> StateT st (ParsecT CustomErr Text m) a -> Text -> m (Either (ParseErrorBundle Text CustomErr) a) Source #

Run a stateful parser with some initial state on a text. See also: runTextParser, runJournalParser.

parseWithState' :: Stream s => st -> StateT st (ParsecT e s Identity) a -> s -> Either (ParseErrorBundle s e) a Source #

fromparse :: (Show t, Show (Token t), Show e) => Either (ParseErrorBundle t e) a -> a Source #

parseerror :: (Show t, Show (Token t), Show e) => ParseErrorBundle t e -> a Source #

re-exports

data CustomErr Source #

A custom error type for the parser. The type is specialized to parsers of Text streams.

Instances

Instances details
Eq CustomErr Source # 
Instance details

Defined in Text.Megaparsec.Custom

Ord CustomErr Source # 
Instance details

Defined in Text.Megaparsec.Custom

Show CustomErr Source # 
Instance details

Defined in Text.Megaparsec.Custom

ShowErrorComponent CustomErr Source # 
Instance details

Defined in Text.Megaparsec.Custom

Ord (ParseError Text CustomErr) Source # 
Instance details

Defined in Text.Megaparsec.Custom