+ ; let (eq_theta, dict_theta) = partition isEqPred sc_theta
+
+ -- We only make selectors for the *value* superclasses,
+ -- not equality predicates
+ ; sc_sel_names <- mapM (newImplicitBinder class_name . mkSuperDictSelOcc)
+ [1..length dict_theta]
+ ; let sc_sel_ids = [ mkDictSelId no_unf sc_name rec_clas
+ | sc_name <- sc_sel_names]
+ -- We number off the Dict superclass selectors, 1, 2, 3 etc so that we
+ -- can construct names for the selectors. Thus
+ -- class (C a, C b) => D a b where ...
+ -- gives superclass selectors
+ -- D_sc1, D_sc2
+ -- (We used to call them D_C, but now we can have two different
+ -- superclasses both called C!)
+
+ ; let use_newtype = null eq_theta && (length dict_theta + length sig_stuff == 1)
+ -- Use a newtype if the data constructor has
+ -- (a) exactly one value field
+ -- (b) no existential or equality-predicate fields
+ -- i.e. exactly one operation or superclass taken together
+ -- See note [Class newtypes and equality predicates]
+
+ -- We play a bit fast and loose by treating the dictionary
+ -- superclasses as ordinary arguments. That means that in
+ -- the case of
+ -- class C a => D a
+ -- we don't get a newtype with no arguments!
+ args = sc_sel_names ++ op_names
+ op_tys = [ty | (_,_,ty) <- sig_stuff]
+ op_names = [op | (op,_,_) <- sig_stuff]
+ arg_tys = map mkPredTy dict_theta ++ op_tys
+ rec_tycon = classTyCon rec_clas
+