{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE LambdaCase #-}
module GHC.Tc.Types.Evidence (
HsWrapper(..),
(<.>), mkWpTyApps, mkWpEvApps, mkWpEvVarApps, mkWpTyLams,
mkWpEvLams, mkWpLet, mkWpFun, mkWpCastN, mkWpCastR, mkWpEta,
collectHsWrapBinders,
idHsWrapper, isIdHsWrapper,
pprHsWrapper, hsWrapDictBinders,
TcEvBinds(..), EvBindsVar(..),
EvBindMap(..), emptyEvBindMap, extendEvBinds,
lookupEvBind, evBindMapBinds,
foldEvBindMap, nonDetStrictFoldEvBindMap,
filterEvBindMap,
isEmptyEvBindMap,
evBindMapToVarSet,
varSetMinusEvBindMap,
EvBind(..), emptyTcEvBinds, isEmptyTcEvBinds, mkGivenEvBind, mkWantedEvBind,
evBindVar, isCoEvBindsVar,
EvTerm(..), EvExpr,
evId, evCoercion, evCast, evDFunApp, evDataConApp, evSelector,
mkEvCast, evVarsOfTerm, mkEvScSelectors, evTypeable, findNeededEvVars,
evTermCoercion, evTermCoercion_maybe,
EvCallStack(..),
EvTypeable(..),
HoleExprRef(..),
TcCoercion, TcCoercionR, TcCoercionN, TcCoercionP, CoercionHole,
TcMCoercion, TcMCoercionN, TcMCoercionR,
Role(..), LeftOrRight(..), pickLR,
maybeSymCo,
unwrapIP, wrapIP,
QuoteWrapper(..), applyQuoteWrapper, quoteWrapperTyVarTy
) where
import GHC.Prelude
import GHC.Types.Unique.DFM
import GHC.Types.Unique.FM
import GHC.Types.Var
import GHC.Types.Id( idScaledType )
import GHC.Core.Coercion.Axiom
import GHC.Core.Coercion
import GHC.Core.Ppr ()
import GHC.Tc.Utils.TcType
import GHC.Core.Type
import GHC.Core.TyCon
import GHC.Core.DataCon ( DataCon, dataConWrapId )
import GHC.Builtin.Names
import GHC.Types.Var.Env
import GHC.Types.Var.Set
import GHC.Core.Predicate
import GHC.Types.Basic
import GHC.Core
import GHC.Core.Class (Class, classSCSelId )
import GHC.Core.FVs ( exprSomeFreeVars )
import GHC.Utils.Misc
import GHC.Utils.Panic
import GHC.Utils.Outputable
import GHC.Data.Bag
import GHC.Data.FastString
import qualified Data.Data as Data
import GHC.Types.SrcLoc
import Data.IORef( IORef )
import GHC.Types.Unique.Set
import GHC.Core.Multiplicity
import qualified Data.Semigroup as S
type TcCoercion = Coercion
type TcCoercionN = CoercionN
type TcCoercionR = CoercionR
type TcCoercionP = CoercionP
type TcMCoercion = MCoercion
type TcMCoercionN = MCoercionN
type TcMCoercionR = MCoercionR
maybeSymCo :: SwapFlag -> TcCoercion -> TcCoercion
maybeSymCo :: SwapFlag -> TcCoercion -> TcCoercion
maybeSymCo SwapFlag
IsSwapped TcCoercion
co = TcCoercion -> TcCoercion
mkSymCo TcCoercion
co
maybeSymCo SwapFlag
NotSwapped TcCoercion
co = TcCoercion
co
data HsWrapper
= WpHole
| WpCompose HsWrapper HsWrapper
| WpFun HsWrapper HsWrapper (Scaled TcTypeFRR)
| WpCast TcCoercionR
| WpEvLam EvVar
| WpEvApp EvTerm
| WpTyLam TyVar
| WpTyApp KindOrType
| WpLet TcEvBinds
| WpMultCoercion Coercion
deriving Typeable HsWrapper
HsWrapper -> DataType
HsWrapper -> Constr
(forall b. Data b => b -> b) -> HsWrapper -> HsWrapper
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> HsWrapper -> u
forall u. (forall d. Data d => d -> u) -> HsWrapper -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HsWrapper -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HsWrapper -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HsWrapper -> m HsWrapper
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsWrapper -> m HsWrapper
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HsWrapper
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HsWrapper -> c HsWrapper
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HsWrapper)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsWrapper)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsWrapper -> m HsWrapper
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsWrapper -> m HsWrapper
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsWrapper -> m HsWrapper
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> HsWrapper -> m HsWrapper
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HsWrapper -> m HsWrapper
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> HsWrapper -> m HsWrapper
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HsWrapper -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> HsWrapper -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> HsWrapper -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> HsWrapper -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HsWrapper -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> HsWrapper -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HsWrapper -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> HsWrapper -> r
gmapT :: (forall b. Data b => b -> b) -> HsWrapper -> HsWrapper
$cgmapT :: (forall b. Data b => b -> b) -> HsWrapper -> HsWrapper
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsWrapper)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c HsWrapper)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HsWrapper)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c HsWrapper)
dataTypeOf :: HsWrapper -> DataType
$cdataTypeOf :: HsWrapper -> DataType
toConstr :: HsWrapper -> Constr
$ctoConstr :: HsWrapper -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HsWrapper
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HsWrapper
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HsWrapper -> c HsWrapper
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> HsWrapper -> c HsWrapper
Data.Data
instance S.Semigroup HsWrapper where
<> :: HsWrapper -> HsWrapper -> HsWrapper
(<>) = HsWrapper -> HsWrapper -> HsWrapper
(<.>)
instance Monoid HsWrapper where
mempty :: HsWrapper
mempty = HsWrapper
WpHole
(<.>) :: HsWrapper -> HsWrapper -> HsWrapper
HsWrapper
WpHole <.> :: HsWrapper -> HsWrapper -> HsWrapper
<.> HsWrapper
c = HsWrapper
c
HsWrapper
c <.> HsWrapper
WpHole = HsWrapper
c
HsWrapper
c1 <.> HsWrapper
c2 = HsWrapper
c1 HsWrapper -> HsWrapper -> HsWrapper
`WpCompose` HsWrapper
c2
mkWpFun :: HsWrapper -> HsWrapper
-> Scaled TcTypeFRR
-> TcType
-> HsWrapper
mkWpFun :: HsWrapper -> HsWrapper -> Scaled Mult -> Mult -> HsWrapper
mkWpFun HsWrapper
WpHole HsWrapper
WpHole Scaled Mult
_ Mult
_ = HsWrapper
WpHole
mkWpFun HsWrapper
WpHole (WpCast TcCoercion
co2) (Scaled Mult
w Mult
t1) Mult
_ = TcCoercion -> HsWrapper
WpCast (Mult -> TcCoercion -> TcCoercion -> TcCoercion
mk_wp_fun_co Mult
w (Mult -> TcCoercion
mkRepReflCo Mult
t1) TcCoercion
co2)
mkWpFun (WpCast TcCoercion
co1) HsWrapper
WpHole (Scaled Mult
w Mult
_) Mult
t2 = TcCoercion -> HsWrapper
WpCast (Mult -> TcCoercion -> TcCoercion -> TcCoercion
mk_wp_fun_co Mult
w (TcCoercion -> TcCoercion
mkSymCo TcCoercion
co1) (Mult -> TcCoercion
mkRepReflCo Mult
t2))
mkWpFun (WpCast TcCoercion
co1) (WpCast TcCoercion
co2) (Scaled Mult
w Mult
_) Mult
_ = TcCoercion -> HsWrapper
WpCast (Mult -> TcCoercion -> TcCoercion -> TcCoercion
mk_wp_fun_co Mult
w (TcCoercion -> TcCoercion
mkSymCo TcCoercion
co1) TcCoercion
co2)
mkWpFun HsWrapper
co1 HsWrapper
co2 Scaled Mult
t1 Mult
_ = HsWrapper -> HsWrapper -> Scaled Mult -> HsWrapper
WpFun HsWrapper
co1 HsWrapper
co2 Scaled Mult
t1
mkWpEta :: [Id] -> HsWrapper -> HsWrapper
mkWpEta :: [Id] -> HsWrapper -> HsWrapper
mkWpEta [Id]
xs HsWrapper
wrap = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Id -> HsWrapper -> HsWrapper
eta_one HsWrapper
wrap [Id]
xs
where
eta_one :: Id -> HsWrapper -> HsWrapper
eta_one Id
x HsWrapper
wrap = HsWrapper -> HsWrapper -> Scaled Mult -> HsWrapper
WpFun HsWrapper
idHsWrapper HsWrapper
wrap (Id -> Scaled Mult
idScaledType Id
x)
mk_wp_fun_co :: Mult -> TcCoercionR -> TcCoercionR -> TcCoercionR
mk_wp_fun_co :: Mult -> TcCoercion -> TcCoercion -> TcCoercion
mk_wp_fun_co Mult
mult TcCoercion
arg_co TcCoercion
res_co
= Role
-> FunTyFlag
-> TcCoercion
-> TcCoercion
-> TcCoercion
-> TcCoercion
mkNakedFunCo1 Role
Representational FunTyFlag
FTF_T_T (Mult -> TcCoercion
multToCo Mult
mult) TcCoercion
arg_co TcCoercion
res_co
mkWpCastR :: TcCoercionR -> HsWrapper
mkWpCastR :: TcCoercion -> HsWrapper
mkWpCastR TcCoercion
co
| TcCoercion -> Bool
isReflCo TcCoercion
co = HsWrapper
WpHole
| Bool
otherwise = forall a. HasCallStack => Bool -> SDoc -> a -> a
assertPpr (TcCoercion -> Role
coercionRole TcCoercion
co forall a. Eq a => a -> a -> Bool
== Role
Representational) (forall a. Outputable a => a -> SDoc
ppr TcCoercion
co) forall a b. (a -> b) -> a -> b
$
TcCoercion -> HsWrapper
WpCast TcCoercion
co
mkWpCastN :: TcCoercionN -> HsWrapper
mkWpCastN :: TcCoercion -> HsWrapper
mkWpCastN TcCoercion
co
| TcCoercion -> Bool
isReflCo TcCoercion
co = HsWrapper
WpHole
| Bool
otherwise = forall a. HasCallStack => Bool -> SDoc -> a -> a
assertPpr (TcCoercion -> Role
coercionRole TcCoercion
co forall a. Eq a => a -> a -> Bool
== Role
Nominal) (forall a. Outputable a => a -> SDoc
ppr TcCoercion
co) forall a b. (a -> b) -> a -> b
$
TcCoercion -> HsWrapper
WpCast (HasDebugCallStack => TcCoercion -> TcCoercion
mkSubCo TcCoercion
co)
mkWpTyApps :: [Type] -> HsWrapper
mkWpTyApps :: [Mult] -> HsWrapper
mkWpTyApps [Mult]
tys = forall a. (a -> HsWrapper) -> [a] -> HsWrapper
mk_co_app_fn Mult -> HsWrapper
WpTyApp [Mult]
tys
mkWpEvApps :: [EvTerm] -> HsWrapper
mkWpEvApps :: [EvTerm] -> HsWrapper
mkWpEvApps [EvTerm]
args = forall a. (a -> HsWrapper) -> [a] -> HsWrapper
mk_co_app_fn EvTerm -> HsWrapper
WpEvApp [EvTerm]
args
mkWpEvVarApps :: [EvVar] -> HsWrapper
mkWpEvVarApps :: [Id] -> HsWrapper
mkWpEvVarApps [Id]
vs = forall a. (a -> HsWrapper) -> [a] -> HsWrapper
mk_co_app_fn EvTerm -> HsWrapper
WpEvApp (forall a b. (a -> b) -> [a] -> [b]
map (EvExpr -> EvTerm
EvExpr forall b c a. (b -> c) -> (a -> b) -> a -> c
. Id -> EvExpr
evId) [Id]
vs)
mkWpTyLams :: [TyVar] -> HsWrapper
mkWpTyLams :: [Id] -> HsWrapper
mkWpTyLams [Id]
ids = forall a. (a -> HsWrapper) -> [a] -> HsWrapper
mk_co_lam_fn Id -> HsWrapper
WpTyLam [Id]
ids
mkWpEvLams :: [Var] -> HsWrapper
mkWpEvLams :: [Id] -> HsWrapper
mkWpEvLams [Id]
ids = forall a. (a -> HsWrapper) -> [a] -> HsWrapper
mk_co_lam_fn Id -> HsWrapper
WpEvLam [Id]
ids
mkWpLet :: TcEvBinds -> HsWrapper
mkWpLet :: TcEvBinds -> HsWrapper
mkWpLet (EvBinds Bag EvBind
b) | forall a. Bag a -> Bool
isEmptyBag Bag EvBind
b = HsWrapper
WpHole
mkWpLet TcEvBinds
ev_binds = TcEvBinds -> HsWrapper
WpLet TcEvBinds
ev_binds
mk_co_lam_fn :: (a -> HsWrapper) -> [a] -> HsWrapper
mk_co_lam_fn :: forall a. (a -> HsWrapper) -> [a] -> HsWrapper
mk_co_lam_fn a -> HsWrapper
f [a]
as = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\a
x HsWrapper
wrap -> a -> HsWrapper
f a
x HsWrapper -> HsWrapper -> HsWrapper
<.> HsWrapper
wrap) HsWrapper
WpHole [a]
as
mk_co_app_fn :: (a -> HsWrapper) -> [a] -> HsWrapper
mk_co_app_fn :: forall a. (a -> HsWrapper) -> [a] -> HsWrapper
mk_co_app_fn a -> HsWrapper
f [a]
as = forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (\a
x HsWrapper
wrap -> HsWrapper
wrap HsWrapper -> HsWrapper -> HsWrapper
<.> a -> HsWrapper
f a
x) HsWrapper
WpHole [a]
as
idHsWrapper :: HsWrapper
idHsWrapper :: HsWrapper
idHsWrapper = HsWrapper
WpHole
isIdHsWrapper :: HsWrapper -> Bool
isIdHsWrapper :: HsWrapper -> Bool
isIdHsWrapper HsWrapper
WpHole = Bool
True
isIdHsWrapper HsWrapper
_ = Bool
False
hsWrapDictBinders :: HsWrapper -> Bag DictId
hsWrapDictBinders :: HsWrapper -> Bag Id
hsWrapDictBinders HsWrapper
wrap = HsWrapper -> Bag Id
go HsWrapper
wrap
where
go :: HsWrapper -> Bag Id
go (WpEvLam Id
dict_id) = forall a. a -> Bag a
unitBag Id
dict_id
go (HsWrapper
w1 `WpCompose` HsWrapper
w2) = HsWrapper -> Bag Id
go HsWrapper
w1 forall a. Bag a -> Bag a -> Bag a
`unionBags` HsWrapper -> Bag Id
go HsWrapper
w2
go (WpFun HsWrapper
_ HsWrapper
w Scaled Mult
_) = HsWrapper -> Bag Id
go HsWrapper
w
go HsWrapper
WpHole = forall a. Bag a
emptyBag
go (WpCast {}) = forall a. Bag a
emptyBag
go (WpEvApp {}) = forall a. Bag a
emptyBag
go (WpTyLam {}) = forall a. Bag a
emptyBag
go (WpTyApp {}) = forall a. Bag a
emptyBag
go (WpLet {}) = forall a. Bag a
emptyBag
go (WpMultCoercion {}) = forall a. Bag a
emptyBag
collectHsWrapBinders :: HsWrapper -> ([Var], HsWrapper)
collectHsWrapBinders :: HsWrapper -> ([Id], HsWrapper)
collectHsWrapBinders HsWrapper
wrap = HsWrapper -> [HsWrapper] -> ([Id], HsWrapper)
go HsWrapper
wrap []
where
go :: HsWrapper -> [HsWrapper] -> ([Var], HsWrapper)
go :: HsWrapper -> [HsWrapper] -> ([Id], HsWrapper)
go (WpEvLam Id
v) [HsWrapper]
wraps = forall {a} {b}. a -> ([a], b) -> ([a], b)
add_lam Id
v ([HsWrapper] -> ([Id], HsWrapper)
gos [HsWrapper]
wraps)
go (WpTyLam Id
v) [HsWrapper]
wraps = forall {a} {b}. a -> ([a], b) -> ([a], b)
add_lam Id
v ([HsWrapper] -> ([Id], HsWrapper)
gos [HsWrapper]
wraps)
go (WpCompose HsWrapper
w1 HsWrapper
w2) [HsWrapper]
wraps = HsWrapper -> [HsWrapper] -> ([Id], HsWrapper)
go HsWrapper
w1 (HsWrapper
w2forall a. a -> [a] -> [a]
:[HsWrapper]
wraps)
go HsWrapper
wrap [HsWrapper]
wraps = ([], forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' HsWrapper -> HsWrapper -> HsWrapper
(<.>) HsWrapper
wrap [HsWrapper]
wraps)
gos :: [HsWrapper] -> ([Id], HsWrapper)
gos [] = ([], HsWrapper
WpHole)
gos (HsWrapper
w:[HsWrapper]
ws) = HsWrapper -> [HsWrapper] -> ([Id], HsWrapper)
go HsWrapper
w [HsWrapper]
ws
add_lam :: a -> ([a], b) -> ([a], b)
add_lam a
v ([a]
vs,b
w) = (a
vforall a. a -> [a] -> [a]
:[a]
vs, b
w)
data TcEvBinds
= TcEvBinds
EvBindsVar
| EvBinds
(Bag EvBind)
data EvBindsVar
= EvBindsVar {
EvBindsVar -> Unique
ebv_uniq :: Unique,
EvBindsVar -> IORef EvBindMap
ebv_binds :: IORef EvBindMap,
EvBindsVar -> IORef CoVarSet
ebv_tcvs :: IORef CoVarSet
}
| CoEvBindsVar {
ebv_uniq :: Unique,
ebv_tcvs :: IORef CoVarSet
}
instance Data.Data TcEvBinds where
toConstr :: TcEvBinds -> Constr
toConstr TcEvBinds
_ = String -> Constr
abstractConstr String
"TcEvBinds"
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c TcEvBinds
gunfold forall b r. Data b => c (b -> r) -> c r
_ forall r. r -> c r
_ = forall a. HasCallStack => String -> a
error String
"gunfold"
dataTypeOf :: TcEvBinds -> DataType
dataTypeOf TcEvBinds
_ = String -> DataType
Data.mkNoRepType String
"TcEvBinds"
isCoEvBindsVar :: EvBindsVar -> Bool
isCoEvBindsVar :: EvBindsVar -> Bool
isCoEvBindsVar (CoEvBindsVar {}) = Bool
True
isCoEvBindsVar (EvBindsVar {}) = Bool
False
newtype EvBindMap
= EvBindMap {
EvBindMap -> DVarEnv EvBind
ev_bind_varenv :: DVarEnv EvBind
}
emptyEvBindMap :: EvBindMap
emptyEvBindMap :: EvBindMap
emptyEvBindMap = EvBindMap { ev_bind_varenv :: DVarEnv EvBind
ev_bind_varenv = forall a. DVarEnv a
emptyDVarEnv }
extendEvBinds :: EvBindMap -> EvBind -> EvBindMap
extendEvBinds :: EvBindMap -> EvBind -> EvBindMap
extendEvBinds EvBindMap
bs EvBind
ev_bind
= EvBindMap { ev_bind_varenv :: DVarEnv EvBind
ev_bind_varenv = forall a. DVarEnv a -> Id -> a -> DVarEnv a
extendDVarEnv (EvBindMap -> DVarEnv EvBind
ev_bind_varenv EvBindMap
bs)
(EvBind -> Id
eb_lhs EvBind
ev_bind)
EvBind
ev_bind }
isEmptyEvBindMap :: EvBindMap -> Bool
isEmptyEvBindMap :: EvBindMap -> Bool
isEmptyEvBindMap (EvBindMap DVarEnv EvBind
m) = forall a. DVarEnv a -> Bool
isEmptyDVarEnv DVarEnv EvBind
m
lookupEvBind :: EvBindMap -> EvVar -> Maybe EvBind
lookupEvBind :: EvBindMap -> Id -> Maybe EvBind
lookupEvBind EvBindMap
bs = forall a. DVarEnv a -> Id -> Maybe a
lookupDVarEnv (EvBindMap -> DVarEnv EvBind
ev_bind_varenv EvBindMap
bs)
evBindMapBinds :: EvBindMap -> Bag EvBind
evBindMapBinds :: EvBindMap -> Bag EvBind
evBindMapBinds = forall a. (EvBind -> a -> a) -> a -> EvBindMap -> a
foldEvBindMap forall a. a -> Bag a -> Bag a
consBag forall a. Bag a
emptyBag
foldEvBindMap :: (EvBind -> a -> a) -> a -> EvBindMap -> a
foldEvBindMap :: forall a. (EvBind -> a -> a) -> a -> EvBindMap -> a
foldEvBindMap EvBind -> a -> a
k a
z EvBindMap
bs = forall a b. (a -> b -> b) -> b -> DVarEnv a -> b
foldDVarEnv EvBind -> a -> a
k a
z (EvBindMap -> DVarEnv EvBind
ev_bind_varenv EvBindMap
bs)
nonDetStrictFoldEvBindMap :: (EvBind -> a -> a) -> a -> EvBindMap -> a
nonDetStrictFoldEvBindMap :: forall a. (EvBind -> a -> a) -> a -> EvBindMap -> a
nonDetStrictFoldEvBindMap EvBind -> a -> a
k a
z EvBindMap
bs = forall a b. (a -> b -> b) -> b -> DVarEnv a -> b
nonDetStrictFoldDVarEnv EvBind -> a -> a
k a
z (EvBindMap -> DVarEnv EvBind
ev_bind_varenv EvBindMap
bs)
filterEvBindMap :: (EvBind -> Bool) -> EvBindMap -> EvBindMap
filterEvBindMap :: (EvBind -> Bool) -> EvBindMap -> EvBindMap
filterEvBindMap EvBind -> Bool
k (EvBindMap { ev_bind_varenv :: EvBindMap -> DVarEnv EvBind
ev_bind_varenv = DVarEnv EvBind
env })
= EvBindMap { ev_bind_varenv :: DVarEnv EvBind
ev_bind_varenv = forall a. (a -> Bool) -> DVarEnv a -> DVarEnv a
filterDVarEnv EvBind -> Bool
k DVarEnv EvBind
env }
evBindMapToVarSet :: EvBindMap -> VarSet
evBindMapToVarSet :: EvBindMap -> CoVarSet
evBindMapToVarSet (EvBindMap DVarEnv EvBind
dve) = forall a. UniqFM a a -> UniqSet a
unsafeUFMToUniqSet (forall elt1 elt2 key.
(elt1 -> elt2) -> UniqFM key elt1 -> UniqFM key elt2
mapUFM EvBind -> Id
evBindVar (forall key elt. UniqDFM key elt -> UniqFM key elt
udfmToUfm DVarEnv EvBind
dve))
varSetMinusEvBindMap :: VarSet -> EvBindMap -> VarSet
varSetMinusEvBindMap :: CoVarSet -> EvBindMap -> CoVarSet
varSetMinusEvBindMap CoVarSet
vs (EvBindMap DVarEnv EvBind
dve) = CoVarSet
vs forall key b. UniqSet key -> UniqDFM key b -> UniqSet key
`uniqSetMinusUDFM` DVarEnv EvBind
dve
instance Outputable EvBindMap where
ppr :: EvBindMap -> SDoc
ppr (EvBindMap DVarEnv EvBind
m) = forall a. Outputable a => a -> SDoc
ppr DVarEnv EvBind
m
data EvBind
= EvBind { EvBind -> Id
eb_lhs :: EvVar
, EvBind -> EvTerm
eb_rhs :: EvTerm
, EvBind -> Bool
eb_is_given :: Bool
}
evBindVar :: EvBind -> EvVar
evBindVar :: EvBind -> Id
evBindVar = EvBind -> Id
eb_lhs
mkWantedEvBind :: EvVar -> EvTerm -> EvBind
mkWantedEvBind :: Id -> EvTerm -> EvBind
mkWantedEvBind Id
ev EvTerm
tm = EvBind { eb_is_given :: Bool
eb_is_given = Bool
False, eb_lhs :: Id
eb_lhs = Id
ev, eb_rhs :: EvTerm
eb_rhs = EvTerm
tm }
mkGivenEvBind :: EvVar -> EvTerm -> EvBind
mkGivenEvBind :: Id -> EvTerm -> EvBind
mkGivenEvBind Id
ev EvTerm
tm = EvBind { eb_is_given :: Bool
eb_is_given = Bool
True, eb_lhs :: Id
eb_lhs = Id
ev, eb_rhs :: EvTerm
eb_rhs = EvTerm
tm }
data EvTerm
= EvExpr EvExpr
| EvTypeable Type EvTypeable
| EvFun
{ EvTerm -> [Id]
et_tvs :: [TyVar]
, EvTerm -> [Id]
et_given :: [EvVar]
, EvTerm -> TcEvBinds
et_binds :: TcEvBinds
, EvTerm -> Id
et_body :: EvVar }
deriving Typeable EvTerm
EvTerm -> DataType
EvTerm -> Constr
(forall b. Data b => b -> b) -> EvTerm -> EvTerm
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> EvTerm -> u
forall u. (forall d. Data d => d -> u) -> EvTerm -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> EvTerm -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> EvTerm -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EvTerm -> m EvTerm
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvTerm -> m EvTerm
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EvTerm
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EvTerm -> c EvTerm
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EvTerm)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EvTerm)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvTerm -> m EvTerm
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvTerm -> m EvTerm
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvTerm -> m EvTerm
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvTerm -> m EvTerm
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EvTerm -> m EvTerm
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EvTerm -> m EvTerm
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EvTerm -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EvTerm -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> EvTerm -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> EvTerm -> [u]
gmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> EvTerm -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> EvTerm -> r
gmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> EvTerm -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> EvTerm -> r
gmapT :: (forall b. Data b => b -> b) -> EvTerm -> EvTerm
$cgmapT :: (forall b. Data b => b -> b) -> EvTerm -> EvTerm
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EvTerm)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EvTerm)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EvTerm)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EvTerm)
dataTypeOf :: EvTerm -> DataType
$cdataTypeOf :: EvTerm -> DataType
toConstr :: EvTerm -> Constr
$ctoConstr :: EvTerm -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EvTerm
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EvTerm
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EvTerm -> c EvTerm
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EvTerm -> c EvTerm
Data.Data
type EvExpr = CoreExpr
evId :: EvId -> EvExpr
evId :: Id -> EvExpr
evId = forall b. Id -> Expr b
Var
evCoercion :: TcCoercion -> EvTerm
evCoercion :: TcCoercion -> EvTerm
evCoercion TcCoercion
co = EvExpr -> EvTerm
EvExpr (forall b. TcCoercion -> Expr b
Coercion TcCoercion
co)
evCast :: EvExpr -> TcCoercion -> EvTerm
evCast :: EvExpr -> TcCoercion -> EvTerm
evCast EvExpr
et TcCoercion
tc | TcCoercion -> Bool
isReflCo TcCoercion
tc = EvExpr -> EvTerm
EvExpr EvExpr
et
| Bool
otherwise = EvExpr -> EvTerm
EvExpr (forall b. Expr b -> TcCoercion -> Expr b
Cast EvExpr
et TcCoercion
tc)
evDFunApp :: DFunId -> [Type] -> [EvExpr] -> EvTerm
evDFunApp :: Id -> [Mult] -> [EvExpr] -> EvTerm
evDFunApp Id
df [Mult]
tys [EvExpr]
ets = EvExpr -> EvTerm
EvExpr forall a b. (a -> b) -> a -> b
$ forall b. Id -> Expr b
Var Id
df forall b. Expr b -> [Mult] -> Expr b
`mkTyApps` [Mult]
tys forall b. Expr b -> [Expr b] -> Expr b
`mkApps` [EvExpr]
ets
evDataConApp :: DataCon -> [Type] -> [EvExpr] -> EvTerm
evDataConApp :: DataCon -> [Mult] -> [EvExpr] -> EvTerm
evDataConApp DataCon
dc [Mult]
tys [EvExpr]
ets = Id -> [Mult] -> [EvExpr] -> EvTerm
evDFunApp (DataCon -> Id
dataConWrapId DataCon
dc) [Mult]
tys [EvExpr]
ets
evSelector :: Id -> [Type] -> [EvExpr] -> EvExpr
evSelector :: Id -> [Mult] -> [EvExpr] -> EvExpr
evSelector Id
sel_id [Mult]
tys [EvExpr]
tms = forall b. Id -> Expr b
Var Id
sel_id forall b. Expr b -> [Mult] -> Expr b
`mkTyApps` [Mult]
tys forall b. Expr b -> [Expr b] -> Expr b
`mkApps` [EvExpr]
tms
evTypeable :: Type -> EvTypeable -> EvTerm
evTypeable :: Mult -> EvTypeable -> EvTerm
evTypeable = Mult -> EvTypeable -> EvTerm
EvTypeable
data EvTypeable
= EvTypeableTyCon TyCon [EvTerm]
| EvTypeableTyApp EvTerm EvTerm
| EvTypeableTrFun EvTerm EvTerm EvTerm
| EvTypeableTyLit EvTerm
deriving Typeable EvTypeable
EvTypeable -> DataType
EvTypeable -> Constr
(forall b. Data b => b -> b) -> EvTypeable -> EvTypeable
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> EvTypeable -> u
forall u. (forall d. Data d => d -> u) -> EvTypeable -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EvTypeable -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EvTypeable -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EvTypeable -> m EvTypeable
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvTypeable -> m EvTypeable
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EvTypeable
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EvTypeable -> c EvTypeable
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EvTypeable)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EvTypeable)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvTypeable -> m EvTypeable
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvTypeable -> m EvTypeable
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvTypeable -> m EvTypeable
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvTypeable -> m EvTypeable
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EvTypeable -> m EvTypeable
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EvTypeable -> m EvTypeable
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EvTypeable -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EvTypeable -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> EvTypeable -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> EvTypeable -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EvTypeable -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EvTypeable -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EvTypeable -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EvTypeable -> r
gmapT :: (forall b. Data b => b -> b) -> EvTypeable -> EvTypeable
$cgmapT :: (forall b. Data b => b -> b) -> EvTypeable -> EvTypeable
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EvTypeable)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c EvTypeable)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EvTypeable)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EvTypeable)
dataTypeOf :: EvTypeable -> DataType
$cdataTypeOf :: EvTypeable -> DataType
toConstr :: EvTypeable -> Constr
$ctoConstr :: EvTypeable -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EvTypeable
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EvTypeable
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EvTypeable -> c EvTypeable
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EvTypeable -> c EvTypeable
Data.Data
data EvCallStack
= EvCsEmpty
| EvCsPushCall
FastString
RealSrcSpan
EvExpr
deriving Typeable EvCallStack
EvCallStack -> DataType
EvCallStack -> Constr
(forall b. Data b => b -> b) -> EvCallStack -> EvCallStack
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> EvCallStack -> u
forall u. (forall d. Data d => d -> u) -> EvCallStack -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EvCallStack -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EvCallStack -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EvCallStack -> m EvCallStack
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvCallStack -> m EvCallStack
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EvCallStack
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EvCallStack -> c EvCallStack
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EvCallStack)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EvCallStack)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvCallStack -> m EvCallStack
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvCallStack -> m EvCallStack
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvCallStack -> m EvCallStack
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> EvCallStack -> m EvCallStack
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EvCallStack -> m EvCallStack
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> EvCallStack -> m EvCallStack
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EvCallStack -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> EvCallStack -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> EvCallStack -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> EvCallStack -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EvCallStack -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> EvCallStack -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EvCallStack -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> EvCallStack -> r
gmapT :: (forall b. Data b => b -> b) -> EvCallStack -> EvCallStack
$cgmapT :: (forall b. Data b => b -> b) -> EvCallStack -> EvCallStack
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EvCallStack)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c EvCallStack)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EvCallStack)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c EvCallStack)
dataTypeOf :: EvCallStack -> DataType
$cdataTypeOf :: EvCallStack -> DataType
toConstr :: EvCallStack -> Constr
$ctoConstr :: EvCallStack -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EvCallStack
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c EvCallStack
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EvCallStack -> c EvCallStack
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> EvCallStack -> c EvCallStack
Data.Data
data HoleExprRef = HER (IORef EvTerm)
TcType
Unique
instance Outputable HoleExprRef where
ppr :: HoleExprRef -> SDoc
ppr (HER IORef EvTerm
_ Mult
_ Unique
u) = forall a. Outputable a => a -> SDoc
ppr Unique
u
instance Data.Data HoleExprRef where
toConstr :: HoleExprRef -> Constr
toConstr HoleExprRef
_ = String -> Constr
abstractConstr String
"HoleExprRef"
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c HoleExprRef
gunfold forall b r. Data b => c (b -> r) -> c r
_ forall r. r -> c r
_ = forall a. HasCallStack => String -> a
error String
"gunfold"
dataTypeOf :: HoleExprRef -> DataType
dataTypeOf HoleExprRef
_ = String -> DataType
Data.mkNoRepType String
"HoleExprRef"
mkEvCast :: EvExpr -> TcCoercion -> EvTerm
mkEvCast :: EvExpr -> TcCoercion -> EvTerm
mkEvCast EvExpr
ev TcCoercion
lco
| forall a. HasCallStack => Bool -> SDoc -> a -> a
assertPpr (TcCoercion -> Role
coercionRole TcCoercion
lco forall a. Eq a => a -> a -> Bool
== Role
Representational)
(forall doc. IsDoc doc => [doc] -> doc
vcat [forall doc. IsLine doc => String -> doc
text String
"Coercion of wrong role passed to mkEvCast:", forall a. Outputable a => a -> SDoc
ppr EvExpr
ev, forall a. Outputable a => a -> SDoc
ppr TcCoercion
lco]) forall a b. (a -> b) -> a -> b
$
TcCoercion -> Bool
isReflCo TcCoercion
lco = EvExpr -> EvTerm
EvExpr EvExpr
ev
| Bool
otherwise = EvExpr -> TcCoercion -> EvTerm
evCast EvExpr
ev TcCoercion
lco
mkEvScSelectors
:: Class -> [TcType]
-> [(TcPredType,
EvExpr)
]
mkEvScSelectors :: Class -> [Mult] -> [(Mult, EvExpr)]
mkEvScSelectors Class
cls [Mult]
tys
= forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
zipWith Mult -> Int -> (Mult, EvExpr)
mk_pr (Class -> [Mult] -> [Mult]
immSuperClasses Class
cls [Mult]
tys) [Int
0..]
where
mk_pr :: Mult -> Int -> (Mult, EvExpr)
mk_pr Mult
pred Int
i = (Mult
pred, forall b. Id -> Expr b
Var Id
sc_sel_id forall b. Expr b -> [Mult] -> Expr b
`mkTyApps` [Mult]
tys)
where
sc_sel_id :: Id
sc_sel_id = Class -> Int -> Id
classSCSelId Class
cls Int
i
emptyTcEvBinds :: TcEvBinds
emptyTcEvBinds :: TcEvBinds
emptyTcEvBinds = Bag EvBind -> TcEvBinds
EvBinds forall a. Bag a
emptyBag
isEmptyTcEvBinds :: TcEvBinds -> Bool
isEmptyTcEvBinds :: TcEvBinds -> Bool
isEmptyTcEvBinds (EvBinds Bag EvBind
b) = forall a. Bag a -> Bool
isEmptyBag Bag EvBind
b
isEmptyTcEvBinds (TcEvBinds {}) = forall a. HasCallStack => String -> a
panic String
"isEmptyTcEvBinds"
evTermCoercion_maybe :: EvTerm -> Maybe TcCoercion
evTermCoercion_maybe :: EvTerm -> Maybe TcCoercion
evTermCoercion_maybe EvTerm
ev_term
| EvExpr EvExpr
e <- EvTerm
ev_term = EvExpr -> Maybe TcCoercion
go EvExpr
e
| Bool
otherwise = forall a. Maybe a
Nothing
where
go :: EvExpr -> Maybe TcCoercion
go :: EvExpr -> Maybe TcCoercion
go (Var Id
v) = forall (m :: * -> *) a. Monad m => a -> m a
return (Id -> TcCoercion
mkCoVarCo Id
v)
go (Coercion TcCoercion
co) = forall (m :: * -> *) a. Monad m => a -> m a
return TcCoercion
co
go (Cast EvExpr
tm TcCoercion
co) = do { TcCoercion
co' <- EvExpr -> Maybe TcCoercion
go EvExpr
tm
; forall (m :: * -> *) a. Monad m => a -> m a
return (TcCoercion -> TcCoercion -> TcCoercion
mkCoCast TcCoercion
co' TcCoercion
co) }
go EvExpr
_ = forall a. Maybe a
Nothing
evTermCoercion :: EvTerm -> TcCoercion
evTermCoercion :: EvTerm -> TcCoercion
evTermCoercion EvTerm
tm = case EvTerm -> Maybe TcCoercion
evTermCoercion_maybe EvTerm
tm of
Just TcCoercion
co -> TcCoercion
co
Maybe TcCoercion
Nothing -> forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"evTermCoercion" (forall a. Outputable a => a -> SDoc
ppr EvTerm
tm)
findNeededEvVars :: EvBindMap -> VarSet -> VarSet
findNeededEvVars :: EvBindMap -> CoVarSet -> CoVarSet
findNeededEvVars EvBindMap
ev_binds CoVarSet
seeds
= (CoVarSet -> CoVarSet) -> CoVarSet -> CoVarSet
transCloVarSet CoVarSet -> CoVarSet
also_needs CoVarSet
seeds
where
also_needs :: VarSet -> VarSet
also_needs :: CoVarSet -> CoVarSet
also_needs CoVarSet
needs = forall elt a. (elt -> a -> a) -> a -> UniqSet elt -> a
nonDetStrictFoldUniqSet Id -> CoVarSet -> CoVarSet
add CoVarSet
emptyVarSet CoVarSet
needs
add :: Var -> VarSet -> VarSet
add :: Id -> CoVarSet -> CoVarSet
add Id
v CoVarSet
needs
| Just EvBind
ev_bind <- EvBindMap -> Id -> Maybe EvBind
lookupEvBind EvBindMap
ev_binds Id
v
, EvBind { eb_is_given :: EvBind -> Bool
eb_is_given = Bool
is_given, eb_rhs :: EvBind -> EvTerm
eb_rhs = EvTerm
rhs } <- EvBind
ev_bind
, Bool
is_given
= EvTerm -> CoVarSet
evVarsOfTerm EvTerm
rhs CoVarSet -> CoVarSet -> CoVarSet
`unionVarSet` CoVarSet
needs
| Bool
otherwise
= CoVarSet
needs
evVarsOfTerm :: EvTerm -> VarSet
evVarsOfTerm :: EvTerm -> CoVarSet
evVarsOfTerm (EvExpr EvExpr
e) = InterestingVarFun -> EvExpr -> CoVarSet
exprSomeFreeVars InterestingVarFun
isEvVar EvExpr
e
evVarsOfTerm (EvTypeable Mult
_ EvTypeable
ev) = EvTypeable -> CoVarSet
evVarsOfTypeable EvTypeable
ev
evVarsOfTerm (EvFun {}) = CoVarSet
emptyVarSet
evVarsOfTerms :: [EvTerm] -> VarSet
evVarsOfTerms :: [EvTerm] -> CoVarSet
evVarsOfTerms = forall a. (a -> CoVarSet) -> [a] -> CoVarSet
mapUnionVarSet EvTerm -> CoVarSet
evVarsOfTerm
evVarsOfTypeable :: EvTypeable -> VarSet
evVarsOfTypeable :: EvTypeable -> CoVarSet
evVarsOfTypeable EvTypeable
ev =
case EvTypeable
ev of
EvTypeableTyCon TyCon
_ [EvTerm]
e -> forall a. (a -> CoVarSet) -> [a] -> CoVarSet
mapUnionVarSet EvTerm -> CoVarSet
evVarsOfTerm [EvTerm]
e
EvTypeableTyApp EvTerm
e1 EvTerm
e2 -> [EvTerm] -> CoVarSet
evVarsOfTerms [EvTerm
e1,EvTerm
e2]
EvTypeableTrFun EvTerm
em EvTerm
e1 EvTerm
e2 -> [EvTerm] -> CoVarSet
evVarsOfTerms [EvTerm
em,EvTerm
e1,EvTerm
e2]
EvTypeableTyLit EvTerm
e -> EvTerm -> CoVarSet
evVarsOfTerm EvTerm
e
instance Outputable HsWrapper where
ppr :: HsWrapper -> SDoc
ppr HsWrapper
co_fn = HsWrapper -> (Bool -> SDoc) -> SDoc
pprHsWrapper HsWrapper
co_fn (SDoc -> Bool -> SDoc
no_parens (forall doc. IsLine doc => String -> doc
text String
"<>"))
pprHsWrapper :: HsWrapper -> (Bool -> SDoc) -> SDoc
pprHsWrapper :: HsWrapper -> (Bool -> SDoc) -> SDoc
pprHsWrapper HsWrapper
wrap Bool -> SDoc
pp_thing_inside
= forall a. (SDocContext -> a) -> (a -> SDoc) -> SDoc
sdocOption SDocContext -> Bool
sdocPrintTypecheckerElaboration forall a b. (a -> b) -> a -> b
$ \case
Bool
True -> (Bool -> SDoc) -> HsWrapper -> Bool -> SDoc
help Bool -> SDoc
pp_thing_inside HsWrapper
wrap Bool
False
Bool
False -> Bool -> SDoc
pp_thing_inside Bool
False
where
help :: (Bool -> SDoc) -> HsWrapper -> Bool -> SDoc
help :: (Bool -> SDoc) -> HsWrapper -> Bool -> SDoc
help Bool -> SDoc
it HsWrapper
WpHole = Bool -> SDoc
it
help Bool -> SDoc
it (WpCompose HsWrapper
f1 HsWrapper
f2) = (Bool -> SDoc) -> HsWrapper -> Bool -> SDoc
help ((Bool -> SDoc) -> HsWrapper -> Bool -> SDoc
help Bool -> SDoc
it HsWrapper
f2) HsWrapper
f1
help Bool -> SDoc
it (WpFun HsWrapper
f1 HsWrapper
f2 (Scaled Mult
w Mult
t1)) = SDoc -> Bool -> SDoc
add_parens forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => String -> doc
text String
"\\(x" forall doc. IsLine doc => doc -> doc -> doc
<> SDoc
dcolon forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc -> doc
brackets (forall a. Outputable a => a -> SDoc
ppr Mult
w) forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr Mult
t1 forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => String -> doc
text String
")." forall doc. IsLine doc => doc -> doc -> doc
<+>
(Bool -> SDoc) -> HsWrapper -> Bool -> SDoc
help (\Bool
_ -> Bool -> SDoc
it Bool
True forall doc. IsLine doc => doc -> doc -> doc
<+> (Bool -> SDoc) -> HsWrapper -> Bool -> SDoc
help (\Bool
_ -> forall doc. IsLine doc => String -> doc
text String
"x") HsWrapper
f1 Bool
True) HsWrapper
f2 Bool
False
help Bool -> SDoc
it (WpCast TcCoercion
co) = SDoc -> Bool -> SDoc
add_parens forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => [doc] -> doc
sep [Bool -> SDoc
it Bool
False, Int -> SDoc -> SDoc
nest Int
2 (forall doc. IsLine doc => String -> doc
text String
"|>"
forall doc. IsLine doc => doc -> doc -> doc
<+> TcCoercion -> SDoc
pprParendCo TcCoercion
co)]
help Bool -> SDoc
it (WpEvApp EvTerm
id) = SDoc -> Bool -> SDoc
no_parens forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => [doc] -> doc
sep [Bool -> SDoc
it Bool
True, Int -> SDoc -> SDoc
nest Int
2 (forall a. Outputable a => a -> SDoc
ppr EvTerm
id)]
help Bool -> SDoc
it (WpTyApp Mult
ty) = SDoc -> Bool -> SDoc
no_parens forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => [doc] -> doc
sep [Bool -> SDoc
it Bool
True, forall doc. IsLine doc => String -> doc
text String
"@" forall doc. IsLine doc => doc -> doc -> doc
<> Mult -> SDoc
pprParendType Mult
ty]
help Bool -> SDoc
it (WpEvLam Id
id) = SDoc -> Bool -> SDoc
add_parens forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => [doc] -> doc
sep [ forall doc. IsLine doc => String -> doc
text String
"\\" forall doc. IsLine doc => doc -> doc -> doc
<> Id -> SDoc
pprLamBndr Id
id forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
dot, Bool -> SDoc
it Bool
False]
help Bool -> SDoc
it (WpTyLam Id
tv) = SDoc -> Bool -> SDoc
add_parens forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => [doc] -> doc
sep [forall doc. IsLine doc => String -> doc
text String
"/\\" forall doc. IsLine doc => doc -> doc -> doc
<> Id -> SDoc
pprLamBndr Id
tv forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc
dot, Bool -> SDoc
it Bool
False]
help Bool -> SDoc
it (WpLet TcEvBinds
binds) = SDoc -> Bool -> SDoc
add_parens forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => [doc] -> doc
sep [forall doc. IsLine doc => String -> doc
text String
"let" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => doc -> doc
braces (forall a. Outputable a => a -> SDoc
ppr TcEvBinds
binds), Bool -> SDoc
it Bool
False]
help Bool -> SDoc
it (WpMultCoercion TcCoercion
co) = SDoc -> Bool -> SDoc
add_parens forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => [doc] -> doc
sep [Bool -> SDoc
it Bool
False, Int -> SDoc -> SDoc
nest Int
2 (forall doc. IsLine doc => String -> doc
text String
"<multiplicity coercion>"
forall doc. IsLine doc => doc -> doc -> doc
<+> TcCoercion -> SDoc
pprParendCo TcCoercion
co)]
pprLamBndr :: Id -> SDoc
pprLamBndr :: Id -> SDoc
pprLamBndr Id
v = forall a. OutputableBndr a => BindingSite -> a -> SDoc
pprBndr BindingSite
LambdaBind Id
v
add_parens, no_parens :: SDoc -> Bool -> SDoc
add_parens :: SDoc -> Bool -> SDoc
add_parens SDoc
d Bool
True = forall doc. IsLine doc => doc -> doc
parens SDoc
d
add_parens SDoc
d Bool
False = SDoc
d
no_parens :: SDoc -> Bool -> SDoc
no_parens SDoc
d Bool
_ = SDoc
d
instance Outputable TcEvBinds where
ppr :: TcEvBinds -> SDoc
ppr (TcEvBinds EvBindsVar
v) = forall a. Outputable a => a -> SDoc
ppr EvBindsVar
v
ppr (EvBinds Bag EvBind
bs) = forall doc. IsLine doc => String -> doc
text String
"EvBinds" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc -> doc
braces (forall doc. IsDoc doc => [doc] -> doc
vcat (forall a b. (a -> b) -> [a] -> [b]
map forall a. Outputable a => a -> SDoc
ppr (forall a. Bag a -> [a]
bagToList Bag EvBind
bs)))
instance Outputable EvBindsVar where
ppr :: EvBindsVar -> SDoc
ppr (EvBindsVar { ebv_uniq :: EvBindsVar -> Unique
ebv_uniq = Unique
u })
= forall doc. IsLine doc => String -> doc
text String
"EvBindsVar" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc -> doc
angleBrackets (forall a. Outputable a => a -> SDoc
ppr Unique
u)
ppr (CoEvBindsVar { ebv_uniq :: EvBindsVar -> Unique
ebv_uniq = Unique
u })
= forall doc. IsLine doc => String -> doc
text String
"CoEvBindsVar" forall doc. IsLine doc => doc -> doc -> doc
<> forall doc. IsLine doc => doc -> doc
angleBrackets (forall a. Outputable a => a -> SDoc
ppr Unique
u)
instance Uniquable EvBindsVar where
getUnique :: EvBindsVar -> Unique
getUnique = EvBindsVar -> Unique
ebv_uniq
instance Outputable EvBind where
ppr :: EvBind -> SDoc
ppr (EvBind { eb_lhs :: EvBind -> Id
eb_lhs = Id
v, eb_rhs :: EvBind -> EvTerm
eb_rhs = EvTerm
e, eb_is_given :: EvBind -> Bool
eb_is_given = Bool
is_given })
= forall doc. IsLine doc => [doc] -> doc
sep [ SDoc
pp_gw forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Id
v
, Int -> SDoc -> SDoc
nest Int
2 forall a b. (a -> b) -> a -> b
$ forall doc. IsLine doc => doc
equals forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr EvTerm
e ]
where
pp_gw :: SDoc
pp_gw = forall doc. IsLine doc => doc -> doc
brackets (if Bool
is_given then forall doc. IsLine doc => Char -> doc
char Char
'G' else forall doc. IsLine doc => Char -> doc
char Char
'W')
instance Outputable EvTerm where
ppr :: EvTerm -> SDoc
ppr (EvExpr EvExpr
e) = forall a. Outputable a => a -> SDoc
ppr EvExpr
e
ppr (EvTypeable Mult
ty EvTypeable
ev) = forall a. Outputable a => a -> SDoc
ppr EvTypeable
ev forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
dcolon forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"Typeable" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr Mult
ty
ppr (EvFun { et_tvs :: EvTerm -> [Id]
et_tvs = [Id]
tvs, et_given :: EvTerm -> [Id]
et_given = [Id]
gs, et_binds :: EvTerm -> TcEvBinds
et_binds = TcEvBinds
bs, et_body :: EvTerm -> Id
et_body = Id
w })
= SDoc -> Int -> SDoc -> SDoc
hang (forall doc. IsLine doc => String -> doc
text String
"\\" forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => [doc] -> doc
sep (forall a b. (a -> b) -> [a] -> [b]
map Id -> SDoc
pprLamBndr ([Id]
tvs forall a. [a] -> [a] -> [a]
++ [Id]
gs)) forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
arrow)
Int
2 (forall a. Outputable a => a -> SDoc
ppr TcEvBinds
bs forall doc. IsDoc doc => doc -> doc -> doc
$$ forall a. Outputable a => a -> SDoc
ppr Id
w)
instance Outputable EvCallStack where
ppr :: EvCallStack -> SDoc
ppr EvCallStack
EvCsEmpty
= forall doc. IsLine doc => String -> doc
text String
"[]"
ppr (EvCsPushCall FastString
orig RealSrcSpan
loc EvExpr
tm)
= forall a. Outputable a => a -> SDoc
ppr (FastString
orig,RealSrcSpan
loc) forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
":" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr EvExpr
tm
instance Outputable EvTypeable where
ppr :: EvTypeable -> SDoc
ppr (EvTypeableTyCon TyCon
ts [EvTerm]
_) = forall doc. IsLine doc => String -> doc
text String
"TyCon" forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr TyCon
ts
ppr (EvTypeableTyApp EvTerm
t1 EvTerm
t2) = forall doc. IsLine doc => doc -> doc
parens (forall a. Outputable a => a -> SDoc
ppr EvTerm
t1 forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr EvTerm
t2)
ppr (EvTypeableTyLit EvTerm
t1) = forall doc. IsLine doc => String -> doc
text String
"TyLit" forall doc. IsLine doc => doc -> doc -> doc
<> forall a. Outputable a => a -> SDoc
ppr EvTerm
t1
ppr (EvTypeableTrFun EvTerm
tm EvTerm
t1 EvTerm
t2) = forall doc. IsLine doc => doc -> doc
parens (forall a. Outputable a => a -> SDoc
ppr EvTerm
t1 forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc
arr forall doc. IsLine doc => doc -> doc -> doc
<+> forall a. Outputable a => a -> SDoc
ppr EvTerm
t2)
where
arr :: SDoc
arr = FunTyFlag -> Either Bool SDoc -> SDoc
pprArrowWithMultiplicity FunTyFlag
visArgTypeLike (forall a b. b -> Either a b
Right (forall a. Outputable a => a -> SDoc
ppr EvTerm
tm))
unwrapIP :: Type -> CoercionR
unwrapIP :: Mult -> TcCoercion
unwrapIP Mult
ty =
case TyCon -> Maybe ([Id], Mult, CoAxiom Unbranched)
unwrapNewTyCon_maybe TyCon
tc of
Just ([Id]
_,Mult
_,CoAxiom Unbranched
ax) -> Role -> CoAxiom Unbranched -> [Mult] -> [TcCoercion] -> TcCoercion
mkUnbranchedAxInstCo Role
Representational CoAxiom Unbranched
ax [Mult]
tys []
Maybe ([Id], Mult, CoAxiom Unbranched)
Nothing -> forall a. HasCallStack => String -> SDoc -> a
pprPanic String
"unwrapIP" forall a b. (a -> b) -> a -> b
$
forall doc. IsLine doc => String -> doc
text String
"The dictionary for" forall doc. IsLine doc => doc -> doc -> doc
<+> SDoc -> SDoc
quotes (forall a. Outputable a => a -> SDoc
ppr TyCon
tc)
forall doc. IsLine doc => doc -> doc -> doc
<+> forall doc. IsLine doc => String -> doc
text String
"is not a newtype!"
where
(TyCon
tc, [Mult]
tys) = Mult -> (TyCon, [Mult])
splitTyConApp Mult
ty
wrapIP :: Type -> CoercionR
wrapIP :: Mult -> TcCoercion
wrapIP Mult
ty = TcCoercion -> TcCoercion
mkSymCo (Mult -> TcCoercion
unwrapIP Mult
ty)
data QuoteWrapper = QuoteWrapper EvVar Type deriving Typeable QuoteWrapper
QuoteWrapper -> DataType
QuoteWrapper -> Constr
(forall b. Data b => b -> b) -> QuoteWrapper -> QuoteWrapper
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> QuoteWrapper -> u
forall u. (forall d. Data d => d -> u) -> QuoteWrapper -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> QuoteWrapper -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> QuoteWrapper -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> QuoteWrapper -> m QuoteWrapper
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QuoteWrapper -> m QuoteWrapper
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c QuoteWrapper
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> QuoteWrapper -> c QuoteWrapper
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c QuoteWrapper)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c QuoteWrapper)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QuoteWrapper -> m QuoteWrapper
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QuoteWrapper -> m QuoteWrapper
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QuoteWrapper -> m QuoteWrapper
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> QuoteWrapper -> m QuoteWrapper
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> QuoteWrapper -> m QuoteWrapper
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> QuoteWrapper -> m QuoteWrapper
gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> QuoteWrapper -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> QuoteWrapper -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> QuoteWrapper -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> QuoteWrapper -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> QuoteWrapper -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> QuoteWrapper -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> QuoteWrapper -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> QuoteWrapper -> r
gmapT :: (forall b. Data b => b -> b) -> QuoteWrapper -> QuoteWrapper
$cgmapT :: (forall b. Data b => b -> b) -> QuoteWrapper -> QuoteWrapper
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c QuoteWrapper)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c QuoteWrapper)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c QuoteWrapper)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c QuoteWrapper)
dataTypeOf :: QuoteWrapper -> DataType
$cdataTypeOf :: QuoteWrapper -> DataType
toConstr :: QuoteWrapper -> Constr
$ctoConstr :: QuoteWrapper -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c QuoteWrapper
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c QuoteWrapper
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> QuoteWrapper -> c QuoteWrapper
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> QuoteWrapper -> c QuoteWrapper
Data.Data
quoteWrapperTyVarTy :: QuoteWrapper -> Type
quoteWrapperTyVarTy :: QuoteWrapper -> Mult
quoteWrapperTyVarTy (QuoteWrapper Id
_ Mult
t) = Mult
t
applyQuoteWrapper :: QuoteWrapper -> HsWrapper
applyQuoteWrapper :: QuoteWrapper -> HsWrapper
applyQuoteWrapper (QuoteWrapper Id
ev_var Mult
m_var)
= [Id] -> HsWrapper
mkWpEvVarApps [Id
ev_var] HsWrapper -> HsWrapper -> HsWrapper
<.> [Mult] -> HsWrapper
mkWpTyApps [Mult
m_var]