HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulemegaparsec-9.7.0Haskell2010

Text.Megaparsec.Internal

Internal definitions. Versioning rules do not apply here. Please do not rely on these unless you really know what you're doing.

  • 5 types
  • 6 values
  • Packagemegaparsec-9.7.0
  • Exports11
  • LanguageHaskell2010
  • LicenceBSD-2-Clause
  • SourceInternal.hs

Data types

5 declarations
newtypenewtype Hints t
#

Hints represent a collection of ErrorItems to be included into ParseError (when it's a TrivialError) as “expected” message items when a parser fails without consuming input right after successful parser that produced the hints.

For example, without hints you could get:

Example1 expression
parseTest (many (char 'r') <* eof) "ra"1:2:unexpected 'a'expecting end of input

We're getting better error messages with the help of hints:

Example1 expression
parseTest (many (char 'r') <* eof) "ra"1:2:unexpected 'a'expecting 'r' or end of input

Constructors

Instances2Semigroup, Monoid
  • Ord t => Semigroup (Hints t)Defined in megaparsec-9.7.0 · Text.Megaparsec.Internal
  • Ord t => Monoid (Hints t)Defined in megaparsec-9.7.0 · Text.Megaparsec.Internal
datadata Reply e s a
#

All information available after parsing. This includes consumption of input, success (with the returned value) or failure (with the parse error), and parser state at the end of parsing. Reply can also be used to resume parsing.

See also: Consumption, Result.

Constructors

Instances1Functor
  • Functor (Reply e s)Defined in megaparsec-9.7.0 · Text.Megaparsec.Internal
datadata Result s e a
#

Whether the parser has failed or not. On success we include the resulting value, on failure we include a ParseError.

See also: Consumption, Reply.

Constructors

Instances1Functor
  • Functor (Result s e)Defined in megaparsec-9.7.0 · Text.Megaparsec.Internal
newtypenewtype ParsecT e s (m :: Type -> Type) a
#

ParsecT e s m a is a parser with custom data component of error e, stream type s, underlying monad m and return type a.

Constructors

Instances19MonadParsec, MonadParsecDbg, MonadError, MonadReader, MonadState, MonadWriter, …

Helper functions

6 declarations
valuewithHints
  1. :: Stream s
  2. => Hints (Token s)

    Hints to use

  3. -> (ParseError s e -> State s e -> m b)

    Continuation to influence

  4. -> ParseError s e

    First argument of resulting continuation

  5. -> State s e

    Second argument of resulting continuation

  6. -> m b
#

withHints hs c makes “error” continuation c use given hints hs.

Note that if resulting continuation gets ParseError that has custom data in it, hints are ignored.

valuewithParsecT
  1. :: Ord e'
  2. => (e -> e')
  3. -> ParsecT e s m a

    Inner parser

  4. -> ParsecT e' s m a

    Outer parser

#

Transform any custom errors thrown by the parser using the given function. Similar in function and purpose to withExceptT.

Note that the inner parser will start with an empty collection of “delayed” ParseErrors. Any delayed ParseErrors produced in the inner parser will be lifted by applying the provided function and added to the collection of delayed parse errors of the outer parser.