{-# LANGUAGE ScopedTypeVariables #-}
module GHC.Core.Lint.Interactive (
interactiveInScope,
) where
import GHC.Prelude
import GHC.Runtime.Context
import GHC.Core.Coercion
import GHC.Core.TyCo.FVs
import GHC.Core.InstEnv ( instanceDFunId, instEnvElts )
import GHC.Types.Id
import GHC.Types.TypeEnv
interactiveInScope :: InteractiveContext -> [Var]
interactiveInScope :: InteractiveContext -> [Var]
interactiveInScope InteractiveContext
ictxt
= [Var]
tyvars [Var] -> [Var] -> [Var]
forall a. [a] -> [a] -> [a]
++ [Var]
ids
where
(InstEnv
cls_insts, [FamInst]
_fam_insts) = InteractiveContext -> (InstEnv, [FamInst])
ic_instances InteractiveContext
ictxt
te1 :: TypeEnv
te1 = [TyThing] -> TypeEnv
mkTypeEnvWithImplicits (InteractiveContext -> [TyThing]
ic_tythings InteractiveContext
ictxt)
te :: TypeEnv
te = TypeEnv -> [Var] -> TypeEnv
extendTypeEnvWithIds TypeEnv
te1 ((ClsInst -> Var) -> [ClsInst] -> [Var]
forall a b. (a -> b) -> [a] -> [b]
map ClsInst -> Var
instanceDFunId ([ClsInst] -> [Var]) -> [ClsInst] -> [Var]
forall a b. (a -> b) -> a -> b
$ InstEnv -> [ClsInst]
instEnvElts InstEnv
cls_insts)
ids :: [Var]
ids = TypeEnv -> [Var]
typeEnvIds TypeEnv
te
tyvars :: [Var]
tyvars = [Type] -> [Var]
tyCoVarsOfTypesList ([Type] -> [Var]) -> [Type] -> [Var]
forall a b. (a -> b) -> a -> b
$ (Var -> Type) -> [Var] -> [Type]
forall a b. (a -> b) -> [a] -> [b]
map Var -> Type
idType [Var]
ids