Commit eb8fb434 authored by parcs's avatar parcs
Browse files

Simplify and improve coverage of ":info" instance lookup

During instance lookup, we can treat classes and data families like any
other TyCon instead of special-casing them.  This approach, aside from
being simpler, has the benefit of returning extra relevant instances for
classes and data families.  For example, given

class A a
instance B (a :: Constraint)
instance A B

":info B" will now also print "instance A B" where previously it didn't
due to the special casing of class TyCons in lookupInsts.

This improves upon the existing patch for Trac #4175
parent 19b8809c
......@@ -2055,15 +2055,6 @@ tcRnGetInfo hsc_env name
lookupInsts :: TyThing -> TcM ([ClsInst],[FamInst])
lookupInsts (ATyCon tc)
| Just cls <- tyConClass_maybe tc
= do { inst_envs <- tcGetInstEnvs
; return (classInstances inst_envs cls, []) }
| isOpenFamilyTyCon tc || isTyConAssoc tc
= do { inst_envs <- tcGetFamInstEnvs
; return ([], familyInstances inst_envs tc) }
| otherwise
= do { (pkg_ie, home_ie) <- tcGetInstEnvs
; (pkg_fie, home_fie) <- tcGetFamInstEnvs
-- Load all instances for all classes that are
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment