Typechecking class declarations
\begin{code}
+{-# OPTIONS_GHC -w #-}
+-- The above warning supression flag is a temporary kludge.
+-- While working on this module you are encouraged to remove it and fix
+-- any warnings in the module. See
+-- http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings
+-- for details
+
module TcClassDcl ( tcClassSigs, tcClassDecl2,
getGenericInstances,
MethodSpec, tcMethodBind, mkMethodBind,
rho_ty = ASSERT( length tyvars == length inst_tys )
substTyWith tyvars inst_tys rho
(preds,tau) = tcSplitPhiTy rho_ty
- first_pred = head preds
+ first_pred = ASSERT( not (null preds)) head preds
in
-- The first predicate should be of form (C a b)
-- where C is the class in question
-- case we require that the instance decl is for a single-parameter
-- type class with type variable arguments:
-- instance (...) => C (T a b)
- clas_tyvar = head (classTyVars clas)
+ clas_tyvar = ASSERT (not (null (classTyVars clas))) head (classTyVars clas)
Just tycon = maybe_tycon
maybe_tycon = case inst_tys of
[ty] -> case tcSplitTyConApp_maybe ty of
else "data type" ++ maybeInst
| isFamilyDecl decl = "family"
- maybeInst | isFamInstDecl decl = " family"
+ maybeInst | isFamInstDecl decl = " instance"
| otherwise = ""
ctxt = hsep [ptext SLIT("In the"), text thing,