hledger-lib-1.2: Core data types, parsers and functionality for the hledger accounting tools

Safe Haskell | None
Language | Haskell2010

Hledger.Utils.Parse

Synopsis

- type TextParser m a = ParsecT Dec Text m a
- type JournalStateParser m a = StateT Journal (ParsecT Dec Text m) a
- type JournalParser a = StateT Journal (ParsecT Dec Text Identity) a
- type ErroringJournalParser m a = StateT Journal (ParsecT Dec Text (ExceptT String m)) a
- choice' :: [TextParser m a] -> TextParser m a
- choiceInState :: [StateT s (ParsecT Dec Text m) a] -> StateT s (ParsecT Dec Text m) a
- parsewith :: Parsec e Text a -> Text -> Either (ParseError Char e) a
- parsewithString :: Parsec e String a -> String -> Either (ParseError Char e) a
- parseWithState :: Monad m => st -> StateT st (ParsecT Dec Text m) a -> Text -> m (Either (ParseError Char Dec) a)
- parseWithState' :: (Stream s, ErrorComponent e) => st -> StateT st (ParsecT e s Identity) a -> s -> Either (ParseError (Token s) e) a
- fromparse :: (Show t, Show e) => Either (ParseError t e) a -> a
- parseerror :: (Show t, Show e) => ParseError t e -> a
- showParseError :: (Show t, Show e) => ParseError t e -> String
- showDateParseError :: (Show t, Show e) => ParseError t e -> String
- nonspace :: TextParser m Char
- spacenonewline :: (Stream s, Char ~ Token s) => ParsecT Dec s m Char
- restofline :: TextParser m String
- eolof :: TextParser m ()

# Documentation

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

A parser of strict text with generic user state, monad and return type.

type JournalStateParser m a = StateT Journal (ParsecT Dec Text m) a Source #

type JournalParser a = StateT Journal (ParsecT Dec Text Identity) a Source #

type ErroringJournalParser m a = StateT Journal (ParsecT Dec Text (ExceptT String m)) a Source #

A journal parser that runs in IO and can throw an error mid-parse.

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 Dec Text m) a] -> StateT s (ParsecT Dec Text m) a Source #

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

parsewith :: Parsec e Text a -> Text -> Either (ParseError Char e) a Source #

parsewithString :: Parsec e String a -> String -> Either (ParseError Char e) a Source #

parseWithState :: Monad m => st -> StateT st (ParsecT Dec Text m) a -> Text -> m (Either (ParseError Char Dec) a) Source #

parseWithState' :: (Stream s, ErrorComponent e) => st -> StateT st (ParsecT e s Identity) a -> s -> Either (ParseError (Token s) e) a Source #

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

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

showParseError :: (Show t, Show e) => ParseError t e -> String Source #

showDateParseError :: (Show t, Show e) => ParseError t e -> String Source #

nonspace :: TextParser m Char Source #

spacenonewline :: (Stream s, Char ~ Token s) => ParsecT Dec s m Char Source #

restofline :: TextParser m String Source #

eolof :: TextParser m () Source #