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-lib-parser-9.14.1.20251220GHC2021

GHC.Parser.Lexer

  • 7 types
  • 1 class
  • 39 values
datadata Token
#

Constructors

Instances2Show, Outputable
  • Show TokenDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Parser.Lexer
  • Outputable TokenDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Parser.Lexer
datadata PState
#
newtypenewtype P a
#

The parsing monad, isomorphic to StateT PState Maybe.

Constructors

Instances4Monad, Functor, Applicative, MonadP
  • Monad PDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Parser.Lexer
  • Functor PDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Parser.Lexer
  • Applicative PDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Parser.Lexer
  • MonadP PDefined in ghc-lib-parser-9.14.1.20251220 · 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-lib-parser-9.14.1.20251220 · GHC.Parser.Lexer
  • MonadP PVDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Parser.PostProcess
datadata ExtBits
#
Instances1Enum
  • Enum ExtBitsDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Parser.Lexer
datadata HdkComment
#

Haddock comment as produced by the lexer. These are accumulated in PState and then processed in GHC.Parser.PostProcess.Haddock. The location of the HsDocStrings spans over the contents of the docstring - i.e. it does not include the decorator ("-- |", "{-|" etc.)

Instances1Show
  • Show HdkCommentDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Parser.Lexer