From: simonpj@microsoft.com Date: Tue, 14 Sep 2010 11:35:23 +0000 (+0000) Subject: More wibbles to deriving error messages X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=1285cf63bc086f323d6b935948388970ce047f59 More wibbles to deriving error messages --- diff --git a/compiler/typecheck/TcDeriv.lhs b/compiler/typecheck/TcDeriv.lhs index 992e35e..86194c0 100644 --- a/compiler/typecheck/TcDeriv.lhs +++ b/compiler/typecheck/TcDeriv.lhs @@ -830,15 +830,11 @@ type Condition = (DynFlags, TyCon) -> Maybe SDoc orCond :: Condition -> Condition -> Condition orCond c1 c2 tc = case c1 tc of - Nothing -> Nothing -- c1 succeeds - Just {} -> c2 tc -- c1 fails, try c2 --- orCond produced just one error message, namely from c2 --- Getting two can be confusing. For a zero-constructor --- type with a standalone isntance decl, we previously got: --- Can't make a derived instance of `Bounded (Test a)': --- `Test' has no data constructors --- and --- `Test' does not have precisely one constructor + Nothing -> Nothing -- c1 succeeds + Just x -> case c2 tc of -- c1 fails + Nothing -> Nothing + Just y -> Just (x $$ ptext (sLit " and") $$ y) + -- Both fail andCond :: Condition -> Condition -> Condition andCond c1 c2 tc = case c1 tc of @@ -886,12 +882,13 @@ cond_noUnliftedArgs (_, tc) cond_isEnumeration :: Condition cond_isEnumeration (_, rep_tc) - | null (tyConDataCons rep_tc) = Just (no_cons_why rep_tc) | isEnumerationTyCon rep_tc = Nothing | otherwise = Just why where - why = quotes (pprSourceTyCon rep_tc) <+> - ptext (sLit "has non-nullary constructors") + why = sep [ quotes (pprSourceTyCon rep_tc) <+> + ptext (sLit "is not an enumeration type") + , nest 2 $ ptext (sLit "(an enumeration consists of one or more nullary constructors)") ] + -- See Note [Enumeration types] in TyCon cond_isProduct :: Condition cond_isProduct (_, rep_tc)