+ unsolved = Bag.mapBag WcEvVar unsolved_flats `unionBags`
+ Bag.mapBag WcImplic unsolved_implics
+
+ zonk_frozen (FrozenError frknd fl ty1 ty2)
+ = do { ty1z <- zonkTcType ty1
+ ; ty2z <- zonkTcType ty2
+ ; return (FrozenError frknd fl ty1z ty2z) }
+
+ tyVarsOfFrozen fr
+ = unionVarSets $ bagToList (mapBag tvs_of_frozen fr)
+ tvs_of_frozen (FrozenError _ _ ty1 ty2) = tyVarsOfTypes [ty1,ty2]
+
+ tidyFrozen env fr = mapBag (tidy_frozen env) fr
+ tidy_frozen env (FrozenError frknd fl ty1 ty2)
+ = FrozenError frknd fl (tidyType env ty1) (tidyType env ty2)
+
+reportTidyFrozens :: TidyEnv -> Bag FrozenError -> TcM ()
+reportTidyFrozens tidy_env fr = mapBagM_ (reportTidyFrozen tidy_env) fr
+
+reportTidyFrozen :: TidyEnv -> FrozenError -> TcM ()
+reportTidyFrozen tidy_env err@(FrozenError _ fl _ty1 _ty2)
+ = do { let dec_errs = decompFrozenError err
+ init_err_ctxt = CEC { cec_encl = []
+ , cec_extra = empty
+ , cec_tidy = tidy_env }
+ ; mapM_ (report_dec_err init_err_ctxt) dec_errs }
+ where
+ report_dec_err err_ctxt (ty1,ty2)
+ -- The only annoying thing here is that in the given case,
+ -- the ``Inaccessible code'' message will be printed once for
+ -- each decomposed equality.
+ = do { (tidy_env2,extra2)
+ <- if isGiven fl
+ then return (cec_tidy err_ctxt, inaccessible_msg)
+ else getWantedEqExtra emptyTvSubst (cec_tidy err_ctxt) loc_orig ty1 ty2
+ ; let err_ctxt2 = err_ctxt { cec_tidy = tidy_env2
+ , cec_extra = cec_extra err_ctxt $$ extra2 }
+ ; setCtFlavorLoc fl $
+ reportEqErr err_ctxt2 ty1 ty2
+ }
+
+ loc_orig | Wanted loc <- fl = ctLocOrigin loc
+ | Derived loc _ <- fl = ctLocOrigin loc
+ | otherwise = pprPanic "loc_orig" empty