trifecta-2.1.4: A modern parser combinator library with convenient diagnostics

Copyright | (c) Edward Kmett 2011-2019
License | BSD3
Maintainer | ekmett@gmail.com
Stability | experimental
Portability | non-portable
Safe Haskell | None
Language | Haskell2010

Text.Trifecta.Combinators

Description

Synopsis

- class (MonadPlus m, TokenParsing m) => DeltaParsing (m :: Type -> Type) where
  - line :: m ByteString
  - position :: m Delta
  - slicedWith :: (a -> ByteString -> r) -> m a -> m r
  - rend :: m Rendering
  - restOfLine :: m ByteString
- sliced :: DeltaParsing m => m a -> m ByteString
- careting :: DeltaParsing m => m Caret
- careted :: DeltaParsing m => m a -> m (Careted a)
- spanning :: DeltaParsing m => m a -> m Span
- spanned :: DeltaParsing m => m a -> m (Spanned a)
- fixiting :: DeltaParsing m => m ByteString -> m Fixit
- class (DeltaParsing m, HasDelta d) => MarkParsing d (m :: Type -> Type) | m -> d where
  - mark :: m d
  - release :: d -> m ()

# Documentation

class (MonadPlus m, TokenParsing m) => DeltaParsing (m :: Type -> Type) where Source #

This class provides parsers with easy access to:

1) the current line contents. 2) the current position as a `Delta`. 3) the ability to use `sliced` on any parser.

Minimal complete definition

line, position, slicedWith

Methods

line :: m ByteString Source #

Retrieve the contents of the current line (from the beginning of the line)

position :: m Delta Source #

Retrieve the current position as a `Delta`.

slicedWith :: (a -> ByteString -> r) -> m a -> m r Source #

Run a parser, grabbing all of the text between its start and end points

rend :: m Rendering Source #

Retrieve a `Rendering` of the current line noting this position, but not placing a `Caret` there.

restOfLine :: m ByteString Source #

Grab the remainder of the current line

#### Instances

Instances details

DeltaParsing Parser Source # |
Instance details Defined in Text.Trifecta.Parser Methods line :: Parser ByteString Source # position :: Parser Delta Source # slicedWith :: (a -> ByteString -> r) -> Parser a -> Parser r Source # rend :: Parser Rendering Source # restOfLine :: Parser ByteString Source #
(MonadPlus m, DeltaParsing m) => DeltaParsing (IdentityT m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods line :: IdentityT m ByteString Source # position :: IdentityT m Delta Source # slicedWith :: (a -> ByteString -> r) -> IdentityT m a -> IdentityT m r Source # rend :: IdentityT m Rendering Source # restOfLine :: IdentityT m ByteString Source #
(MonadPlus m, DeltaParsing m) => DeltaParsing (ReaderT e m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods line :: ReaderT e m ByteString Source # position :: ReaderT e m Delta Source # slicedWith :: (a -> ByteString -> r) -> ReaderT e m a -> ReaderT e m r Source # rend :: ReaderT e m Rendering Source # restOfLine :: ReaderT e m ByteString Source #
(MonadPlus m, DeltaParsing m) => DeltaParsing (StateT s m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods line :: StateT s m ByteString Source # position :: StateT s m Delta Source # slicedWith :: (a -> ByteString -> r) -> StateT s m a -> StateT s m r Source # rend :: StateT s m Rendering Source # restOfLine :: StateT s m ByteString Source #
(MonadPlus m, DeltaParsing m) => DeltaParsing (StateT s m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods line :: StateT s m ByteString Source # position :: StateT s m Delta Source # slicedWith :: (a -> ByteString -> r) -> StateT s m a -> StateT s m r Source # rend :: StateT s m Rendering Source # restOfLine :: StateT s m ByteString Source #
(MonadPlus m, DeltaParsing m, Monoid w) => DeltaParsing (WriterT w m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods line :: WriterT w m ByteString Source # position :: WriterT w m Delta Source # slicedWith :: (a -> ByteString -> r) -> WriterT w m a -> WriterT w m r Source # rend :: WriterT w m Rendering Source # restOfLine :: WriterT w m ByteString Source #
(MonadPlus m, DeltaParsing m, Monoid w) => DeltaParsing (WriterT w m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods line :: WriterT w m ByteString Source # position :: WriterT w m Delta Source # slicedWith :: (a -> ByteString -> r) -> WriterT w m a -> WriterT w m r Source # rend :: WriterT w m Rendering Source # restOfLine :: WriterT w m ByteString Source #
(MonadPlus m, DeltaParsing m, Monoid w) => DeltaParsing (RWST r w s m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods line :: RWST r w s m ByteString Source # position :: RWST r w s m Delta Source # slicedWith :: (a -> ByteString -> r0) -> RWST r w s m a -> RWST r w s m r0 Source # rend :: RWST r w s m Rendering Source # restOfLine :: RWST r w s m ByteString Source #
(MonadPlus m, DeltaParsing m, Monoid w) => DeltaParsing (RWST r w s m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods line :: RWST r w s m ByteString Source # position :: RWST r w s m Delta Source # slicedWith :: (a -> ByteString -> r0) -> RWST r w s m a -> RWST r w s m r0 Source # rend :: RWST r w s m Rendering Source # restOfLine :: RWST r w s m ByteString Source #

sliced :: DeltaParsing m => m a -> m ByteString Source #

Run a parser, grabbing all of the text between its start and end points and discarding the original result

careting :: DeltaParsing m => m Caret Source #

Grab a `Caret` pointing to the current location.

careted :: DeltaParsing m => m a -> m (Careted a) Source #

Parse a `Careted` result. Pointing the `Caret` to where you start.

spanning :: DeltaParsing m => m a -> m Span Source #

Discard the result of a parse, returning a `Span` from where we start to where it ended parsing.

spanned :: DeltaParsing m => m a -> m (Spanned a) Source #

Parse a `Spanned` result. The `Span` starts here and runs to the last position parsed.

fixiting :: DeltaParsing m => m ByteString -> m Fixit Source #

Grab a fixit.

class (DeltaParsing m, HasDelta d) => MarkParsing d (m :: Type -> Type) | m -> d where Source #

This class is a refinement of `DeltaParsing` that adds the ability to mark your position in the input and return there for further parsing later.

Methods

mark :: m d Source #

mark the current location so it can be used in constructing a span, or for later seeking

release :: d -> m () Source #

Seek a previously marked location

#### Instances

Instances details

MarkParsing Delta Parser Source # |
Instance details Defined in Text.Trifecta.Parser Methods mark :: Parser Delta Source # release :: Delta -> Parser () Source #
(MonadPlus m, MarkParsing d m) => MarkParsing d (IdentityT m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods mark :: IdentityT m d Source # release :: d -> IdentityT m () Source #
(MonadPlus m, MarkParsing d m) => MarkParsing d (ReaderT e m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods mark :: ReaderT e m d Source # release :: d -> ReaderT e m () Source #
(MonadPlus m, MarkParsing d m) => MarkParsing d (StateT s m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods mark :: StateT s m d Source # release :: d -> StateT s m () Source #
(MonadPlus m, MarkParsing d m) => MarkParsing d (StateT s m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods mark :: StateT s m d Source # release :: d -> StateT s m () Source #
(MonadPlus m, MarkParsing d m, Monoid w) => MarkParsing d (WriterT w m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods mark :: WriterT w m d Source # release :: d -> WriterT w m () Source #
(MonadPlus m, MarkParsing d m, Monoid w) => MarkParsing d (WriterT w m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods mark :: WriterT w m d Source # release :: d -> WriterT w m () Source #
(MonadPlus m, MarkParsing d m, Monoid w) => MarkParsing d (RWST r w s m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods mark :: RWST r w s m d Source # release :: d -> RWST r w s m () Source #
(MonadPlus m, MarkParsing d m, Monoid w) => MarkParsing d (RWST r w s m) Source # |
Instance details Defined in Text.Trifecta.Combinators Methods mark :: RWST r w s m d Source # release :: d -> RWST r w s m () Source #