- cmp_eq =
- mk_FunMonoBind tycon_loc
- cmp_eq_RDR
- (if null nonnullary_cons && isSingleton nullary_cons then
- -- catch this specially to avoid warnings
- -- about overlapping patterns from the desugarer.
- let
- data_con = head nullary_cons
- data_con_RDR = getRdrName data_con
- pat = mkNullaryConPat data_con_RDR
- in
- [([pat,pat], eqTag_Expr)]
- else
- map pats_etc nonnullary_cons ++
- -- leave out wildcards to silence desugarer.
- (if isSingleton tycon_data_cons then
- []
- else
- [([wildPat, wildPat], default_rhs)]))
+ cmp_eq = mk_FunMonoBind tycon_loc cmp_eq_RDR cmp_eq_match
+ cmp_eq_match
+ | isEnumerationTyCon tycon
+ -- We know the tags are equal, so if it's an enumeration TyCon,
+ -- then there is nothing left to do
+ -- Catch this specially to avoid warnings
+ -- about overlapping patterns from the desugarer,
+ -- and to avoid unnecessary pattern-matching
+ = [([wildPat,wildPat], eqTag_Expr)]
+ | otherwise
+ = map pats_etc nonnullary_cons ++
+ (if single_con_type then -- Omit wildcards when there's just one
+ [] -- constructor, to silence desugarer
+ else
+ [([wildPat, wildPat], default_rhs)])
+