ghc-9.10.1: The GHC API
Safe HaskellNone
LanguageGHC2021

GHC.Tc.Zonk.Env

Description

The ZonkEnv zonking environment, and the ZonkT and ZonkBndrT monad transformers, for the final zonking to type in GHC.Tc.Zonk.Type.

See Note [Module structure for zonking] in GHC.Tc.Zonk.Type.

Synopsis

The ZonkEnv

data ZonkEnv Source #

See Note [The ZonkEnv]

Instances

Instances details
Outputable ZonkEnv Source # 
Instance details

Defined in GHC.Tc.Zonk.Env

Methods

ppr :: ZonkEnv -> SDoc Source #

getZonkEnv :: forall (m :: Type -> Type). Monad m => ZonkT m ZonkEnv Source #

data ZonkFlexi Source #

How should we handle unfilled unification variables in the zonker?

See Note [Un-unified unification variables]

Constructors

DefaultFlexi

Default unbound unification variables to Any

SkolemiseFlexi

Skolemise unbound unification variables See Note [Zonking the LHS of a RULE]

RuntimeUnkFlexi

Used in the GHCi debugger

NoFlexi

Panic on unfilled meta-variables See Note [Error on unconstrained meta-variables] in GHC.Tc.Utils.TcMType

initZonkEnv :: MonadIO m => ZonkFlexi -> ZonkT m b -> m b Source #

The ZonkT and ZonkBndrT zonking monad transformers

data ZonkT (m :: Type -> Type) a where Source #

A reader monad over ZonkEnv, for zonking computations which don't modify the ZonkEnv (e.g. don't bind any variables).

Use ZonkBndrT when you need to modify the ZonkEnv (e.g. to bind a variable).

Bundled Patterns

pattern ZonkT :: (ZonkEnv -> m a) -> ZonkT m a 

Instances

Instances details
MonadTrans ZonkT Source # 
Instance details

Defined in GHC.Tc.Zonk.Env

Methods

lift :: Monad m => m a -> ZonkT m a Source #

MonadIO m => MonadIO (ZonkT m) Source # 
Instance details

Defined in GHC.Tc.Zonk.Env

Methods

liftIO :: IO a -> ZonkT m a Source #

Applicative m => Applicative (ZonkT m) Source # 
Instance details

Defined in GHC.Tc.Zonk.Env

Methods

pure :: a -> ZonkT m a #

(<*>) :: ZonkT m (a -> b) -> ZonkT m a -> ZonkT m b #

liftA2 :: (a -> b -> c) -> ZonkT m a -> ZonkT m b -> ZonkT m c #

(*>) :: ZonkT m a -> ZonkT m b -> ZonkT m b #

(<*) :: ZonkT m a -> ZonkT m b -> ZonkT m a #

Functor m => Functor (ZonkT m) Source # 
Instance details

Defined in GHC.Tc.Zonk.Env

Methods

fmap :: (a -> b) -> ZonkT m a -> ZonkT m b #

(<$) :: a -> ZonkT m b -> ZonkT m a #

Monad m => Monad (ZonkT m) Source # 
Instance details

Defined in GHC.Tc.Zonk.Env

Methods

(>>=) :: ZonkT m a -> (a -> ZonkT m b) -> ZonkT m b #

(>>) :: ZonkT m a -> ZonkT m b -> ZonkT m b #

return :: a -> ZonkT m a #

MonadFix m => MonadFix (ZonkT m) Source # 
Instance details

Defined in GHC.Tc.Zonk.Env

Methods

mfix :: (a -> ZonkT m a) -> ZonkT m a #

newtype ZonkBndrT (m :: Type -> Type) a Source #

Zonk binders, bringing them into scope in the inner computation.

Can be thought of as a state monad transformer StateT ZonkEnv m a, but written in continuation-passing style.

See Note [Continuation-passing style for zonking].

Constructors

ZonkBndrT 

Fields

Instances

Instances details
MonadIO m => MonadIO (ZonkBndrT m) Source # 
Instance details

Defined in GHC.Tc.Zonk.Env

Methods

liftIO :: IO a -> ZonkBndrT m a Source #

Applicative (ZonkBndrT m) Source # 
Instance details

Defined in GHC.Tc.Zonk.Env

Methods

pure :: a -> ZonkBndrT m a #

(<*>) :: ZonkBndrT m (a -> b) -> ZonkBndrT m a -> ZonkBndrT m b #

liftA2 :: (a -> b -> c) -> ZonkBndrT m a -> ZonkBndrT m b -> ZonkBndrT m c #

(*>) :: ZonkBndrT m a -> ZonkBndrT m b -> ZonkBndrT m b #

(<*) :: ZonkBndrT m a -> ZonkBndrT m b -> ZonkBndrT m a #

Functor (ZonkBndrT m) Source # 
Instance details

Defined in GHC.Tc.Zonk.Env

Methods

fmap :: (a -> b) -> ZonkBndrT m a -> ZonkBndrT m b #

(<$) :: a -> ZonkBndrT m b -> ZonkBndrT m a #

Monad (ZonkBndrT m) Source # 
Instance details

Defined in GHC.Tc.Zonk.Env

Methods

(>>=) :: ZonkBndrT m a -> (a -> ZonkBndrT m b) -> ZonkBndrT m b #

(>>) :: ZonkBndrT m a -> ZonkBndrT m b -> ZonkBndrT m b #

return :: a -> ZonkBndrT m a #

MonadIO m => MonadFix (ZonkBndrT m) Source # 
Instance details

Defined in GHC.Tc.Zonk.Env

Methods

mfix :: (a -> ZonkBndrT m a) -> ZonkBndrT m a #

Going between ZonkT and ZonkBndrT

runZonkBndrT :: forall (m :: Type -> Type) a. ZonkBndrT m a -> forall r. (a -> ZonkT m r) -> ZonkT m r Source #

Zonk some binders and run the continuation.

Example:

zonk (ForAllTy (Bndr tv vis) body_ty)
 = runZonkBndrT (zonkTyBndrX tv) $ \ tv' ->
   do { body_ty' <- zonkTcTypeToTypeX body_ty
      ; return (ForAllTy (Bndr tv' vis) body_ty') }

See Note [Continuation-passing style for zonking].

noBinders :: forall (m :: Type -> Type) a. Monad m => ZonkT m a -> ZonkBndrT m a Source #

Embed a computation that doesn't modify the ZonkEnv into ZonkBndrT.

don'tBind :: forall (m :: Type -> Type) a. Monad m => ZonkBndrT m a -> ZonkT m a Source #

Run a nested computation that modifies the ZonkEnv, without affecting the outer environment.

Modifying and extending the ZonkEnv in ZonkBndrT

setZonkType :: forall (m :: Type -> Type) a. ZonkFlexi -> ZonkT m a -> ZonkT m a Source #

extendZonkEnv :: forall (m :: Type -> Type). [Var] -> ZonkBndrT m () Source #

extendIdZonkEnv :: forall (m :: Type -> Type). Var -> ZonkBndrT m () Source #

extendIdZonkEnvRec :: forall (m :: Type -> Type). [Var] -> ZonkBndrT m () Source #

Extend the knot-tied environment.

extendTyZonkEnv :: forall (m :: Type -> Type). TyVar -> ZonkBndrT m () Source #