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

Moduleghc-9.10.3GHC2021

GHC.Hs.Pat

  • 16 types
  • 29 values
  • Packageghc-9.10.3
  • Exports46
  • LanguageGHC2021
  • LicenceBSD-3-Clause
  • SourcePat.hs
datadata Pat p
#

Constructors

Instances7Data, Outputable, HasType, ToHie, Anno, …
datadata ConPatTc
#

This is the extension field for ConPat, added after typechecking It adds quite a few extra fields, to support elaboration of pattern matching.

Constructors

  • ConPatTc
    • cpt_arg_tys :: [Type]

      The universal arg types 1-1 with the universal tyvars of the constructor/pattern synonym Use (conLikeResTy pat_con cpt_arg_tys) to get the type of the pattern

    • cpt_tvs :: [TyVar]

      Existentially bound type variables in correctly-scoped order e.g. [k:* x:k]

    • cpt_dicts :: [EvVar]

      Ditto *coercion variables* and *dictionaries* One reason for putting coercion variable here I think is to ensure their kinds are zonked

    • cpt_binds :: TcEvBinds

      Bindings involving those dictionaries

    • cpt_wrap :: HsWrapper

      Extra wrapper to pass to the matcher Only relevant for pattern-synonyms; ignored for data cons

Instances1Data
  • Data ConPatTcDefined in ghc-9.10.3 · GHC.Hs.Instances · orphan
datadata XXPatGhcTc
#

Extension constructor for Pat, added after typechecking.

Constructors

  • CoPat

    Coercion Pattern (translation only)

    During desugaring a (CoPat co pat) turns into a cast with co on the scrutinee, followed by a match on pat.

  • ExpansionPat (Pat GhcRn) (Pat GhcTc)

    Pattern expansion: original pattern, and desugared pattern, for RebindableSyntax and other overloaded syntax such as OverloadedLists. See Note [Rebindable syntax and XXExprGhcRn].

Instances1Data
datadata HsConPatTyArg p
#

Type argument in a data constructor pattern, e.g. the @a in f (Just @a x) = ....

Constructors

Instances4Data, Outputable
datadata HsRecFields p arg
#

Haskell Record Fields

HsRecFields is used only for patterns and expressions (not data type declarations)

Instances5ToHie, Data, Outputable
datadata HsFieldBind lhs rhs
#

Haskell Field Binding

For details on above see Note [exact print annotations] in GHC.Parser.Annotation

Constructors

Instances7Functor, Foldable, Traversable, ToHie, Data, Outputable, …
valueisIrrefutableHsPatHelper
  1. :: OutputableBndrId p
  2. => Bool

    Are we in a -XStrict context? See Note [-XStrict and irrefutability]

  3. -> LPat (GhcPass p)
  4. -> Bool
#

(isIrrefutableHsPat p) is true if matching against p cannot fail in the sense of falling through to the next pattern. (NB: this is not quite the same as the (silly) defn in 3.17.2 of the Haskell 98 report.)

WARNING: isIrrefutableHsPat returns False if it's in doubt. Specifically on a ConPatIn, which is what it sees for a (LPat Name) in the renamer, it doesn't know the size of the constructor family, so it returns False. Result: only tuple patterns are considered irrefutable at the renamer stage.

But if it returns True, the pattern is definitely irrefutable Instantiates isIrrefutableHsPatHelperM with a trivial identity monad

Is this pattern boring from the perspective of pattern-match checking, i.e. introduces no new pieces of long-distance information which could influence pattern-match checking?

See Note [Boring patterns].

Orphan instances

4 instances