-reportUnsolvedImplication :: Implication -> TcM ()
-reportUnsolvedImplication implic
- = do { env0 <- tcInitTidyEnv
- ; let tidy_env = tidyFreeTyVars env0 (tyVarsOfImplication implic)
- tidy_implic = tidyImplication tidy_env implic
- new_tidy_env = foldNameEnv add tidy_env (ic_env implic)
- err_ctxt = CEC { cec_encl = [tidy_implic]
- , cec_extra = empty
- , cec_tidy = new_tidy_env }
- ; reportTidyWanteds err_ctxt (ic_wanted tidy_implic) }
- where
- -- Extend the tidy env with a mapping from tyvars to the
- -- names the user originally used. At the moment we do this
- -- from the type env, but it might be better to record the
- -- scoped type variable in the Implication. Urgh.
- add (ATyVar name ty) (occ_env, var_env)
- | Just tv <- tcGetTyVar_maybe ty
- , not (getUnique name `elemVarEnvByKey` var_env)
- = case tidyOccName occ_env (nameOccName name) of
- (occ_env', occ') -> (occ_env', extendVarEnv var_env tv tv')
- where
- tv' = setTyVarName tv name'
- name' = tidyNameOcc name occ'
- add _ tidy_env = tidy_env