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

GHC 9.14.1 · lts/ghc-9.14.x · b2f3bfd · 2026-10-11

Moduleghc-9.14.1GHC2021

GHC.Parser.Lexer

  • 7 types
  • 1 class
  • 39 values
  • Packageghc-9.14.1
  • Exports49
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourceLexer.x
datadata Token
#

Constructors

Instances2Show, Outputable
datadata PState
#
newtypenewtype P a
#

The parsing monad, isomorphic to StateT PState Maybe.

Constructors

Instances4Monad, Functor, Applicative, MonadP
  • Monad PDefined in ghc-9.14.1 · GHC.Parser.Lexer
  • Functor PDefined in ghc-9.14.1 · GHC.Parser.Lexer
  • Applicative PDefined in ghc-9.14.1 · GHC.Parser.Lexer
  • MonadP PDefined in ghc-9.14.1 · GHC.Parser.Lexer
newtypenewtype ParseResult a
#

The result of running a parser.

patternpattern POk :: PState -> a -> ParseResult a
#

The parser has consumed a (possibly empty) prefix of the input and produced a result. Use getPsMessages to check for accumulated warnings and non-fatal errors.

The carried parsing state can be used to resume parsing.

patternpattern PFailed :: PState -> ParseResult a
#

The parser has consumed a (possibly empty) prefix of the input and failed.

The carried parsing state can be used to resume parsing. It is the state right before failure, including the fatal parse error. getPsMessages and getPsErrorMessages must return a non-empty bag of errors.

classclass Monad m => MonadP (m :: Type -> Type) where
#

An mtl-style class for monads that support parsing-related operations. For example, sometimes we make a second pass over the parsing results to validate, disambiguate, or rearrange them, and we do so in the PV monad which cannot consume input but can report parsing errors, check for extension bits, and accumulate parsing annotations. Both P and PV are instances of MonadP.

MonadP grants us convenient overloading. The other option is to have separate operations for each monad: addErrorP vs addErrorPV, getBitP vs getBitPV, and so on.

Methods

Instances2MonadP
  • MonadP PDefined in ghc-9.14.1 · GHC.Parser.Lexer
  • MonadP PVDefined in ghc-9.14.1 · GHC.Parser.PostProcess
datadata ExtBits
#
Instances1Enum