From: Ian Lynagh Date: Tue, 24 Nov 2009 01:13:13 +0000 (+0000) Subject: Treat () as an enumeration tycon X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=ae6378d0e49a3ffb68c58fb71dfa01ae13bd680f;p=ghc-hetmet.git Treat () as an enumeration tycon This fixes deriving Ord (), which previously failed with ghc-stage1: panic! (the 'impossible' happened) (GHC version 6.13.20091123 for x86_64-unknown-linux): TcGenDeriv:mk_FunBind --- diff --git a/compiler/types/TyCon.lhs b/compiler/types/TyCon.lhs index 43fb524..958a0cb 100644 --- a/compiler/types/TyCon.lhs +++ b/compiler/types/TyCon.lhs @@ -864,6 +864,7 @@ isGadtSyntaxTyCon _ = False -- | Is this an algebraic 'TyCon' which is just an enumeration of values? isEnumerationTyCon :: TyCon -> Bool isEnumerationTyCon (AlgTyCon {algTcRhs = DataTyCon { is_enum = res }}) = res +isEnumerationTyCon (TupleTyCon {tyConArity = arity}) = arity == 0 isEnumerationTyCon _ = False -- | Is this a 'TyCon', synonym or otherwise, that may have further instances appear? @@ -1093,8 +1094,9 @@ tyConFamilySize other = pprPanic "tyConFamilySize:" (ppr other) -- | Extract an 'AlgTyConRhs' with information about data constructors from an algebraic or tuple -- 'TyCon'. Panics for any other sort of 'TyCon' algTyConRhs :: TyCon -> AlgTyConRhs -algTyConRhs (AlgTyCon {algTcRhs = rhs}) = rhs -algTyConRhs (TupleTyCon {dataCon = con}) = DataTyCon { data_cons = [con], is_enum = False } +algTyConRhs (AlgTyCon {algTcRhs = rhs}) = rhs +algTyConRhs (TupleTyCon {dataCon = con, tyConArity = arity}) + = DataTyCon { data_cons = [con], is_enum = arity == 0 } algTyConRhs other = pprPanic "algTyConRhs" (ppr other) \end{code}