+@mkMethodId@ manufactures an id for a local method.
+It's rather turgid stuff, because there are two cases:
+
+ (a) For methods with no local polymorphism, we can make an Inst of the
+ class-op selector function and a corresp InstId;
+ which is good because then other methods which call
+ this one will do so directly.
+
+ (b) For methods with local polymorphism, we can't do this. For example,
+
+ class Foo a where
+ op :: (Num b) => a -> b -> a
+
+ Here the type of the class-op-selector is
+
+ forall a b. (Foo a, Num b) => a -> b -> a
+
+ The locally defined method at (say) type Float will have type
+
+ forall b. (Num b) => Float -> b -> Float
+
+ and the one is not an instance of the other.
+
+ So for these we just make a local (non-Inst) id with a suitable type.
+
+How disgusting.
+
+\begin{code}
+newMethodId sel_id inst_ty origin loc
+ = let (sel_tyvars,sel_theta,sel_tau) = splitSigmaTy (idType sel_id)
+ (_:meth_theta) = sel_theta -- The local theta is all except the
+ -- first element of the context
+ in
+ case sel_tyvars of
+ -- Ah! a selector for a class op with no local polymorphism
+ -- Build an Inst for this
+ [clas_tyvar] -> newMethod origin (RealId sel_id) [inst_ty]
+
+ -- Ho! a selector for a class op with local polymorphism.
+ -- Just make a suitably typed local id for this
+ (clas_tyvar:local_tyvars) ->
+ tcInstType [(clas_tyvar,inst_ty)]
+ (mkSigmaTy local_tyvars meth_theta sel_tau)
+ `thenNF_Tc` \ method_ty ->
+ newLocalId (getOccurrenceName sel_id) method_ty `thenNF_Tc` \ meth_id ->
+ returnNF_Tc (emptyLIE, meth_id)
+\end{code}
+
+The next function makes a default method which calls the global default method, at