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

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8174fa4 · 2026-10-11

Moduleghc-10.0.0.20260917GHC2024

GHC.HsToCore.Pmc.Types

Types used through-out pattern match checking. This module is mostly there to be imported from GHC.HsToCore.Types. The exposed API is that of GHC.HsToCore.Pmc.

These types model the paper Lower Your Guards: A Compositional Pattern-Match Coverage Checker".

  • 15 types
  • 5 values

LYG syntax

0 declarations

Guard language

newtypenewtype SrcInfo
#

Means by which we identify a source construct for later pretty-printing in a warning message. SDoc for the equation to show, Located for the location.

Constructors

Instances1Outputable
datadata PmGrd
#

A very simple language for pattern guards. Let bindings, bang patterns, and matching variables against flat constructor patterns. The LYG guard language.

Constructors

Instances1Outputable
  • Outputable PmGrdDefined in ghc-10.0.0.20260917 · GHC.HsToCore.Pmc.Types

    Should not be user-facing.

datadata GrdDag
#

A series-parallel graph of PmGrds, so very nearly a guard tree, if it weren't for or-patterns/GdAlt! The implicit "source" corresponds to "before the match" and the implicit "sink" corresponds to "after a successful match".

  • GdEnd is a GrdDag that always matches.

  • GdOne is a GrdDag that matches iff its PmGrd matches.

  • GdSeq g1 g2 corresponds to matching guards g1 and then g2 if matching g1 succeeded. Example: The Haskell guard | x > 1, x < 10 = ... will test x > 1 before x < 10, failing if either test fails.

  • GdAlt g1 g2 is far less common than GdSeq and corresponds to matching an or-pattern (LT; EQ), succeeding if the match variable matches either LT or EQ. See Note [Implementation of OrPatterns] for a larger example.

Instances1Outputable
  • Outputable GrdDagDefined in ghc-10.0.0.20260917 · GHC.HsToCore.Pmc.Types

    Format LYG guards as | True <- x, let x = 42, !z

Guard tree language

Coverage Checking types

3 declarations
datadata RedSets
#

Redundancy sets, used to determine redundancy of RHSs and bang patterns (later digested into a CIRB).

Constructors

  • RedSets
    • rs_cov :: !Nablas

      The Covered set; the set of values reaching a particular program point.

    • rs_div :: !Nablas

      The Diverging set; empty if no match can lead to divergence. If it wasn't empty, we have to turn redundancy warnings into inaccessibility warnings for any subclauses.

    • rs_bangs :: !OrdList (Nablas, SrcInfo)

      If any of the Nablas is empty, the corresponding SrcInfo pin-points a bang pattern in source that is redundant. See Note [Dead bang patterns].

Instances1Outputable
datadata CheckResult a
#

Pattern-match coverage check result

Constructors

  • CheckResult
    • cr_ret :: !a

      A hole for redundancy info and covered sets.

    • cr_uncov :: !Nablas

      The set of uncovered values falling out at the bottom. (for -Wincomplete-patterns, but also important state for the algorithm)

    • cr_approx :: !Precision

      A flag saying whether we ran into the maxPmCheckModels limit for the purpose of suggesting to crank it up in the warning message. Writer state.

Instances2Functor, Outputable

Pre and post coverage checking synonyms

2 declarations
typetype Pre = GrdDag
#

Used as tree payload pre-checking. The LYG guards to check.

typetype Post = RedSets
#

Used as tree payload post-checking. The redundancy info we elaborated.

Normalised refinement types

0 declarations