From b3912ef355dee6a459d2839e804a71632d52772c Mon Sep 17 00:00:00 2001 From: quintela Date: Tue, 2 Dec 1997 18:11:33 +0000 Subject: [PATCH] [project @ 1997-12-02 18:11:33 by quintela] data types with one constructor doesn't need WildCadr cases --- ghc/compiler/typecheck/TcGenDeriv.lhs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ghc/compiler/typecheck/TcGenDeriv.lhs b/ghc/compiler/typecheck/TcGenDeriv.lhs index dde873e..c2e2cf5 100644 --- a/ghc/compiler/typecheck/TcGenDeriv.lhs +++ b/ghc/compiler/typecheck/TcGenDeriv.lhs @@ -286,6 +286,9 @@ cmp_eq _ _ = EQ \end{verbatim} \end{itemize} +If there is only one constructor in the Data Type we don't need the WildCard Patern. +JJQC-30-Nov-1997 + \begin{code} gen_Ord_binds :: TyCon -> RdrNameMonoBinds @@ -320,7 +323,10 @@ gen_Ord_binds tycon cmp_eq = mk_FunMonoBind tycon_loc cmp_eq_RDR (map pats_etc nonnullary_cons ++ - [([WildPatIn, WildPatIn], default_rhs)]) + if ((length nonnullary_cons + length nullary_cons) == 1) + then [] + else [([WildPatIn, WildPatIn], + default_rhs)]) where pats_etc data_con = ([con1_pat, con2_pat], -- 1.7.10.4