HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulemegaparsec-9.7.0Haskell2010

Text.Megaparsec.Error

Parse errors. The current version of Megaparsec supports typed errors instead of String-based ones. This gives a lot of flexibility in describing what exactly went wrong as well as a way to return arbitrary data in case of failure.

You probably do not want to import this module directly because Text.Megaparsec re-exports it anyway.

  • 4 types
  • 1 class
  • 10 values
  • Packagemegaparsec-9.7.0
  • Exports15
  • LanguageHaskell2010
  • LicenceBSD-2-Clause
  • SourceError.hs

Parse error type

8 declarations
datadata ErrorItem t
#

A data type that is used to represent “unexpected/expected” items in ParseError. It is parametrized over the token type t.

Constructors

Instances9Functor, Eq, Data, Ord, Read, Show, …
datadata ErrorFancy e
#

Additional error data, extendable by user. When no custom data is necessary, the type is typically indexed by Void to “cancel” the ErrorCustom constructor.

Constructors

Instances9Functor, Eq, Data, Ord, Read, Show, …
datadata ParseError s e
#

ParseError s e represents a parse error parametrized over the stream type s and the custom data e.

Semigroup and Monoid instances of the data type allow us to merge parse errors from different branches of parsing. When merging two ParseErrors, the longest match is preferred; if positions are the same, custom data sets and collections of message items are combined. Note that fancy errors take precedence over trivial errors in merging.

Constructors

  • TrivialError Int (Maybe (ErrorItem (Token s))) (Set (ErrorItem (Token s)))

    Trivial errors, generated by the Megaparsec's machinery. The data constructor includes the offset of error, unexpected token (if any), and expected tokens.

    Type of the first argument was changed in the version 7.0.0.

  • FancyError Int (Set (ErrorFancy e))

    Fancy, custom errors.

    Type of the first argument was changed in the version 7.0.0.

Instances9Eq, Data, Show, Generic, Semigroup, Monoid, …
datadata ParseErrorBundle s e
#

A non-empty collection of ParseErrors equipped with PosState that allows us to pretty-print the errors efficiently and correctly.

Constructors

Instances7Eq, Data, Show, Generic, Exception, NFData, …

Pretty-printing

7 declarations