HORIZON HASKELLDocslts/ghc-10.0.x8174fa42026-10-11Search names, modules, packages, or :: a typeCtrl K

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8174fa4 · 2026-10-11

Modulemegaparsec-9.8.3Haskell2010

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.8.3
  • Exports11
  • LanguageHaskell2010
  • LicenceBSD-2-Clause
  • SourceInternal.hs

Data types

5 declarations
newtypenewtype Hints t
#

Hints represent a collection of ErrorItems to be included in a ParseError (when it's a TrivialError) as “expected” message items when a parser fails without consuming input right after a 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.8.3 · Text.Megaparsec.Internal
  • Ord t => Monoid (Hints t)Defined in megaparsec-9.8.3 · 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 the 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.8.3 · 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.8.3 · Text.Megaparsec.Internal
newtypenewtype ParsecT e s (m :: Type -> Type) a
#

ParsecT e s m a is a parser with custom error data component 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 the “error” continuation c use the given hints hs.

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

valueaccHints
  1. :: Stream s
  2. => Hints (Token s)

    Hints to add

  3. -> (a -> State s e -> Hints (Token s) -> m b)

    An “OK” continuation to alter

  4. -> a

    Altered “OK” continuation

  5. -> State s e
  6. -> Hints (Token s)
  7. -> m b
#

accHints hs c results in an “OK” continuation that will add the given hints hs to the third argument of the original continuation c.

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.