-gen_inst_info :: Maybe Module -- Module name; Nothing => Prelude
- -> [RenamedFixityDecl] -- all known fixities;
- -- may be needed for Text
- -> GlobalNameMappers -- lookup stuff for names we may use
- -> InstInfo -- the main stuff to work on
- -> TcM s InstInfo -- the gen'd (filled-in) "instance decl"
-
-gen_inst_info modname fixities deriver_name_funs
- info@(InstInfo clas tyvars ty inst_decl_theta _ _ _ _ _ _ locn _)
+-- Generate the method bindings for the required instance
+-- (paired with class name, as we need that when generating dict
+-- names.)
+gen_bind :: Fixities -> InstInfo -> ({-class-}OccName, {-tyCon-}OccName, RdrNameMonoBinds)
+gen_bind fixities (InstInfo clas _ [ty] _ _ _ _ _)
+ | not from_here
+ = (clas_nm, tycon_nm, EmptyMonoBinds)
+ | ckey == showClassKey
+ = (clas_nm, tycon_nm, gen_Show_binds fixities tycon)
+ | ckey == readClassKey
+ = (clas_nm, tycon_nm, gen_Read_binds fixities tycon)
+ | otherwise
+ = (clas_nm, tycon_nm,
+ assoc "gen_bind:bad derived class"
+ [(eqClassKey, gen_Eq_binds)
+ ,(ordClassKey, gen_Ord_binds)
+ ,(enumClassKey, gen_Enum_binds)
+ ,(boundedClassKey, gen_Bounded_binds)
+ ,(ixClassKey, gen_Ix_binds)
+ ]
+ ckey
+ tycon)
+ where
+ clas_nm = nameOccName (getName clas)
+ tycon_nm = nameOccName (getName tycon)
+ from_here = isLocallyDefined tycon
+ (tycon,_,_) = splitAlgTyConApp ty
+ ckey = classKey clas
+
+
+gen_inst_info :: InstInfo
+ -> (Name, RenamedMonoBinds)
+ -> InstInfo -- the gen'd (filled-in) "instance decl"
+
+gen_inst_info (InstInfo clas tyvars tys@(ty:_) inst_decl_theta _ _ locn _)
+ (dfun_name, meth_binds)