-- Collect together all the bad guys
bad_guys = non_stds ++ concat std_bads
(non_ips, bad_ips) = partition isClassDict bad_guys
- (ambigs, no_insts) = partition is_ambig non_ips
- is_ambig d = not (tyVarsOfInst d `subVarSet` fixed_tvs)
- fixed_tvs = oclose (fdPredsOfInsts irreds) emptyVarSet
- -- If the dict has free type variables, it's almost certainly ambiguous,
- -- and that's the first thing to fix.
- -- Otherwise, addNoInstanceErrs does the right thing
- -- I say "almost certain" because we might have
- -- class C a b | a -> B where ...
- -- plus an Inst (C Int x). Then the 'x' isn't ambiguous; it's just that
- -- there's no instance decl for (C Int ...). Hence the oclose.
+ (ambigs, no_insts) = partition isTyVarDict non_ips
+ -- If the dict has no type constructors involved, it must be ambiguous,
+ -- except I suppose that another error with fundeps maybe should have
+ -- constrained those type variables
in
-- Report definite errors