TcHoleErrors

ghc-8.8.0.20190424: The GHC API

Safe Haskell | None
Language | Haskell2010

TcHoleErrors

Synopsis

- findValidHoleFits :: TidyEnv -> [Implication] -> [Ct] -> Ct -> TcM (TidyEnv, SDoc)
- tcFilterHoleFits :: Maybe Int -> [Implication] -> [Ct] -> (TcType, [TcTyVar]) -> [HoleFitCandidate] -> TcM (Bool, [HoleFit])
- data HoleFit = HoleFit {
  - hfId :: Id
  - hfCand :: HoleFitCandidate
  - hfType :: TcType
  - hfRefLvl :: Int
  - hfWrap :: [TcType]
  - hfMatches :: [TcType]
  - hfDoc :: Maybe HsDocString
  }
- data HoleFitCandidate
  - = IdHFCand Id
  - | NameHFCand Name
  - | GreHFCand GlobalRdrElt
- tcCheckHoleFit :: Cts -> [Implication] -> TcSigmaType -> TcSigmaType -> TcM (Bool, HsWrapper)
- tcSubsumes :: TcSigmaType -> TcSigmaType -> TcM Bool
- withoutUnification :: FV -> TcM a -> TcM a

# Documentation

findValidHoleFits Source #

Arguments

:: TidyEnv | The tidy_env for zonking
-> [Implication] | Enclosing implications for givens
-> [Ct] | The unsolved simple constraints in the implication for the hole.
-> Ct | The hole constraint itself
-> TcM (TidyEnv, SDoc) |

tcFilterHoleFits Source #

Arguments

:: Maybe Int | How many we should output, if limited
-> [Implication] | Enclosing implications for givens
-> [Ct] | Any relevant unsolved simple constraints
-> (TcType, [TcTyVar]) | The type to check for fits and a list of refinement variables (free type variables in the type) for emulating additional holes.
-> [HoleFitCandidate] | The candidates to check whether fit.
-> TcM (Bool, [HoleFit]) | We return whether or not we stopped due to hitting the limit and the fits we found.

tcFilterHoleFits filters the candidates by whether, given the implications and the relevant constraints, they can be made to match the type by running the type checker. Stops after finding limit matches.

data HoleFit Source #

HoleFit is the type we use for valid hole fits. It contains the element that was checked, the Id of that element as found by `tcLookup`, and the refinement level of the fit, which is the number of extra argument holes that this fit uses (e.g. if hfRefLvl is 2, the fit is for `Id _ _`).

Constructors

HoleFit |
Fields hfId :: Id hfCand :: HoleFitCandidate hfType :: TcType hfRefLvl :: Int hfWrap :: [TcType] hfMatches :: [TcType] hfDoc :: Maybe HsDocString

#### Instances

Instances details

Eq HoleFit # |
Instance details Defined in TcHoleErrors Methods (==) :: HoleFit -> HoleFit -> Bool # (/=) :: HoleFit -> HoleFit -> Bool #
Ord HoleFit # |
Instance details Defined in TcHoleErrors Methods compare :: HoleFit -> HoleFit -> Ordering # (<) :: HoleFit -> HoleFit -> Bool # (<=) :: HoleFit -> HoleFit -> Bool # (>) :: HoleFit -> HoleFit -> Bool # (>=) :: HoleFit -> HoleFit -> Bool # max :: HoleFit -> HoleFit -> HoleFit # min :: HoleFit -> HoleFit -> HoleFit #
Outputable HoleFit # |
Instance details Defined in TcHoleErrors Methods ppr :: HoleFit -> SDoc Source # pprPrec :: Rational -> HoleFit -> SDoc Source #

data HoleFitCandidate Source #

HoleFitCandidates are passed to the filter and checked whether they can be made to fit.

Constructors

IdHFCand Id |
NameHFCand Name |
GreHFCand GlobalRdrElt |

#### Instances

Instances details

Eq HoleFitCandidate # |
Instance details Defined in TcHoleErrors Methods (==) :: HoleFitCandidate -> HoleFitCandidate -> Bool # (/=) :: HoleFitCandidate -> HoleFitCandidate -> Bool #
Outputable HoleFitCandidate # |
Instance details Defined in TcHoleErrors Methods ppr :: HoleFitCandidate -> SDoc Source # pprPrec :: Rational -> HoleFitCandidate -> SDoc Source #
HasOccName HoleFitCandidate # |
Instance details Defined in TcHoleErrors Methods occName :: HoleFitCandidate -> OccName Source #

tcCheckHoleFit Source #

Arguments

:: Cts | Any relevant Cts to the hole.
-> [Implication] | The nested implications of the hole with the innermost implication first.
-> TcSigmaType | The type of the hole.
-> TcSigmaType | The type to check whether fits.
-> TcM (Bool, HsWrapper) | Whether it was a match, and the wrapper from hole_ty to ty.

A tcSubsumes which takes into account relevant constraints, to fix trac #14273. This makes sure that when checking whether a type fits the hole, the type has to be subsumed by type of the hole as well as fulfill all constraints on the type of the hole. Note: The simplifier may perform unification, so make sure to restore any free type variables to avoid side-effects.

tcSubsumes :: TcSigmaType -> TcSigmaType -> TcM Bool Source #

Reports whether first type (ty_a) subsumes the second type (ty_b), discarding any errors. Subsumption here means that the ty_b can fit into the ty_a, i.e. `tcSubsumes a b == True` if b is a subtype of a.

withoutUnification :: FV -> TcM a -> TcM a Source #

Takes a list of free variables and restores any Flexi type variables in free_vars after the action is run.