X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcUnify.lhs;h=67a6743c374e0a526f97485870226cdd6a26cf86;hb=e062d977204e0aa21f391f8ee23b8a941e041583;hp=c9def341360c63c00ddcf8ab0501744fd8e77fc2;hpb=5822cb8d13aa3c05d2b46b4510c13d94b902eb21;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcUnify.lhs b/compiler/typecheck/TcUnify.lhs index c9def34..67a6743 100644 --- a/compiler/typecheck/TcUnify.lhs +++ b/compiler/typecheck/TcUnify.lhs @@ -6,6 +6,13 @@ Type subsumption and unification \begin{code} +{-# OPTIONS -w #-} +-- The above warning supression flag is a temporary kludge. +-- While working on this module you are encouraged to remove it and fix +-- any warnings in the module. See +-- http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings +-- for details + module TcUnify ( -- Full-blown subsumption tcSubExp, tcFunResTy, tcGen, @@ -851,8 +858,8 @@ tcGen expected_ty extra_tvs thing_inside -- We expect expected_ty to be a forall ; let -- The WpLet binds any Insts which came out of the simplification. - dict_ids = map instToId dicts - co_fn = mkWpTyLams tvs' <.> mkWpLams dict_ids <.> WpLet inst_binds + dict_vars = map instToVar dicts + co_fn = mkWpTyLams tvs' <.> mkWpLams dict_vars <.> WpLet inst_binds ; returnM (co_fn, result) } where free_tvs = tyVarsOfType expected_ty `unionVarSet` extra_tvs @@ -1362,9 +1369,15 @@ involves the unfication x = y. It is deferred until we bring into account the context x ~ y to establish that it holds. If available, we defer original types (rather than those where closed type -synonyms have already been expanded via tcCoreView). This is as usual, to +synonyms have already been expanded via tcCoreView). This is, as usual, to improve error messages. +We need to both 'unBox' and zonk deferred types. We need to unBox as +functions, such as TcExpr.tcMonoExpr promise to fill boxes in the expected +type. We need to zonk as the types go into the kind of the coercion variable +`cotv' and those are not zonked in Inst.zonkInst. (Maybe it would be better +to zonk in zonInst instead. Would that be sufficient?) + \begin{code} defer_unification :: Bool -- pop innermost context? -> SwapFlag @@ -1374,8 +1387,8 @@ defer_unification :: Bool -- pop innermost context? defer_unification outer True ty1 ty2 = defer_unification outer False ty2 ty1 defer_unification outer False ty1 ty2 - = do { ty1' <- zonkTcType ty1 - ; ty2' <- zonkTcType ty2 + = do { ty1' <- unBox ty1 >>= zonkTcType -- unbox *and* zonk.. + ; ty2' <- unBox ty2 >>= zonkTcType -- ..see preceding note ; traceTc $ text "deferring:" <+> ppr ty1 <+> text "~" <+> ppr ty2 ; cotv <- newMetaTyVar TauTv (mkCoKind ty1' ty2') -- put ty1 ~ ty2 in LIE