X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcRnMonad.lhs;h=ca11d179de9381c14142c19a5053ddfbf231c0d2;hp=6df6e28128c29522e85d679c16c1ced8b1ac8c02;hb=296058a1cafa80dec0b3f998348bce7c65f668b0;hpb=25b72d3e7da625732cbfbbe729a3e4321fd91ced diff --git a/compiler/typecheck/TcRnMonad.lhs b/compiler/typecheck/TcRnMonad.lhs index 6df6e28..ca11d17 100644 --- a/compiler/typecheck/TcRnMonad.lhs +++ b/compiler/typecheck/TcRnMonad.lhs @@ -9,6 +9,8 @@ module TcRnMonad( module IOEnv ) where +#include "HsVersions.h" + import TcRnTypes -- Re-export all import IOEnv -- Re-export all @@ -123,7 +125,9 @@ initTc hsc_env hsc_src keep_rn_syntax mod do_this tcl_arrow_ctxt = NoArrowCtxt, tcl_env = emptyNameEnv, tcl_tyvars = tvs_var, - tcl_lie = panic "initTc:LIE" -- LIE only valid inside a getLIE + tcl_lie = panic "initTc:LIE", -- only valid inside getLIE + tcl_tybinds = panic "initTc:tybinds" + -- only valid inside a getTyBinds } ; } ; @@ -823,7 +827,7 @@ debugTc thing | otherwise = return () \end{code} - %************************************************************************ +%************************************************************************ %* * Type constraints (the so-called LIE) %* * @@ -881,6 +885,44 @@ setLclTypeEnv lcl_env thing_inside %************************************************************************ %* * + Meta type variable bindings +%* * +%************************************************************************ + +\begin{code} +getTcTyVarBindsVar :: TcM (TcRef TcTyVarBinds) +getTcTyVarBindsVar = do { env <- getLclEnv; return (tcl_tybinds env) } + +getTcTyVarBinds :: TcM a -> TcM (a, TcTyVarBinds) +getTcTyVarBinds thing_inside + = do { tybinds_var <- newMutVar emptyBag + ; res <- updLclEnv (\ env -> env { tcl_tybinds = tybinds_var }) + thing_inside + ; tybinds <- readMutVar tybinds_var + ; return (res, tybinds) + } + +bindMetaTyVar :: TcTyVar -> TcType -> TcM () +bindMetaTyVar tv ty + = do { ASSERTM2( do { details <- readMutVar (metaTvRef tv) + ; return (isFlexi details) }, ppr tv ) + ; tybinds_var <- getTcTyVarBindsVar + ; tybinds <- readMutVar tybinds_var + ; writeMutVar tybinds_var (tybinds `snocBag` TcTyVarBind tv ty) + } + +getTcTyVarBindsRelation :: TcM [(TcTyVar, TcTyVarSet)] +getTcTyVarBindsRelation + = do { tybinds_var <- getTcTyVarBindsVar + ; tybinds <- readMutVar tybinds_var + ; return $ map freeTvs (bagToList tybinds) + } + where + freeTvs (TcTyVarBind tv ty) = (tv, tyVarsOfType ty) +\end{code} + +%************************************************************************ +%* * Template Haskell context %* * %************************************************************************