import TcMonoType ( TcSigInfo(..), tcHsType, tcHsTheta, mkTcSig )
import TcSimplify ( tcSimplifyCheck )
import TcUnify ( checkSigTyVars, sigCtxt )
import TcMonoType ( TcSigInfo(..), tcHsType, tcHsTheta, mkTcSig )
import TcSimplify ( tcSimplifyCheck )
import TcUnify ( checkSigTyVars, sigCtxt )
import TcType ( Type, TyVarDetails(..), TcType, TcThetaType, TcTyVar,
mkTyVarTys, mkPredTys, mkClassPred,
import TcType ( Type, TyVarDetails(..), TcType, TcThetaType, TcTyVar,
mkTyVarTys, mkPredTys, mkClassPred,
-import Class ( classTyVars, classBigSig, classTyCon, className,
+import Class ( classTyVars, classBigSig, classTyCon,
import MkId ( mkDictSelId, mkDataConId, mkDataConWrapId, mkDefaultMethodId )
import DataCon ( mkDataCon )
import Id ( Id, idType, idName, setIdLocalExported )
import MkId ( mkDictSelId, mkDataConId, mkDataConWrapId, mkDefaultMethodId )
import DataCon ( mkDataCon )
import Id ( Id, idType, idName, setIdLocalExported )
-import Util ( count, isSingleton, lengthIs, equalLength )
-import Maybes ( seqMaybe, maybeToBool )
+import Util ( count, lengthIs, equalLength )
+import Maybes ( seqMaybe )
+import Maybe ( isJust )
-- instance declaration is for a single-parameter type class with
-- a type constructor applied to type arguments in the instance decl
-- (checkTc, so False provokes the error)
-- instance declaration is for a single-parameter type class with
-- a type constructor applied to type arguments in the instance decl
-- (checkTc, so False provokes the error)
- checkTc (not (isInstDecl origin) || simple_inst)
- (badGenericInstance sel_id) `thenTc_`
+ ASSERT( isInstDecl origin ) -- We never get here from a class decl
+
+ checkTc (isJust maybe_tycon)
+ (badGenericInstance sel_id (notSimple inst_tys)) `thenTc_`
+ checkTc (isJust (tyConGenInfo tycon))
+ (badGenericInstance sel_id (notGeneric tycon)) `thenTc_`
-- case we require that the instance decl is for a single-parameter
-- type class with type variable arguments:
-- instance (...) => C (T a b)
-- case we require that the instance decl is for a single-parameter
-- type class with type variable arguments:
-- instance (...) => C (T a b)
- ptext SLIT("because the instance declaration is not for a simple type (T a b c)"),
- ptext SLIT("(where T is a derivable type constructor)")]
+ because]
+
+notSimple inst_tys
+ = vcat [ptext SLIT("because the instance type(s)"),
+ nest 2 (ppr inst_tys),
+ ptext SLIT("is not a simple type of form (T a b c)")]
+
+notGeneric tycon
+ = vcat [ptext SLIT("because the instance type constructor") <+> quotes (ppr tycon) <+>
+ ptext SLIT("was not compiled with -fgenerics")]