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.Hs.Pat

  • 15 types
  • 26 values
datadata Pat p
#

Pattern

Constructors

Instances9Data, Outputable, CollectBinders, CollectFldBinders, Anno, …
  • Data (Pat GhcPs)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Hs.Instances · orphan
  • Data (Pat GhcRn)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Hs.Instances · orphan
  • Data (Pat GhcTc)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Hs.Instances · orphan
  • OutputableBndrId p => Outputable (Pat (GhcPass p))Defined in ghc-lib-parser-9.14.1.20251220 · GHC.Hs.Pat · orphan
  • CollectBinders (LocatedA (Pat GhcTc))Defined in ghc-lib-parser-9.14.1.20251220 · GHC.HsToCore.Ticks
  • CollectBinders [LocatedA (Pat GhcTc)]Defined in ghc-lib-parser-9.14.1.20251220 · GHC.HsToCore.Ticks
  • CollectFldBinders (Pat GhcTc)Defined in ghc-lib-parser-9.14.1.20251220 · GHC.HsToCore.Ticks
  • type Anno (Pat (GhcPass p)) = SrcSpanAnnADefined in ghc-lib-parser-9.14.1.20251220 · GHC.Hs.Pat · orphan
  • type Anno [LocatedA (Pat (GhcPass p))] = EpaLocationDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Hs.Expr · orphan
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-lib-parser-9.14.1.20251220 · 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].

Instances2Data, CollectFldBinders
  • Data XXPatGhcTcDefined in ghc-lib-parser-9.14.1.20251220 · GHC.Hs.Instances · orphan
  • CollectFldBinders XXPatGhcTcDefined in ghc-lib-parser-9.14.1.20251220 · GHC.HsToCore.Ticks
datadata HsRecFields p arg
#

Haskell Record Fields

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

Instances4Data, Outputable
datadata HsFieldBind lhs rhs
#

Haskell Field Binding

Constructors

Instances7Functor, Foldable, Traversable, Data, Outputable, CollectFldBinders, …
newtypenewtype RecFieldsDotDot
#

Newtype to be able to have a specific XRec instance for the Int in rec_dotdot

Instances4Eq, Data, Ord, Anno
valueisIrrefutableHsPat
  1. :: IsPass p
  2. => Bool

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

  3. -> (ConLikeP (GhcPass p) -> Bool)

    How to check whether the ConLike in a ConPat pattern is irrefutable

  4. -> LPat (GhcPass p)

    The (located) pattern to check

  5. -> 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.)

If isIrrefutableHsPat returns True, the pattern is definitely irrefutable.

However, isIrrefutableHsPat returns False if it's in doubt. It's a best effort guess with the information we have available:

  • we sometimes call isIrrefutableHsPat from the renamer, in which case we don't have type information to hand. This means we can't properly handle GADTs, nor the result TyCon of COMPLETE pragmas.

  • even when calling isIrrefutableHsPat in the typechecker, we don't keep track of any long distance information like the pattern-match checker does.

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

3 instances