Only generate tag2con for data cons (not newtypes)
ptext, text, char, hang, Doc )
import SrcLoc ( mkGeneratedSrcLoc, SrcLoc )
import TyCon ( tyConTyVars, tyConDataCons, tyConDerivings,
ptext, text, char, hang, Doc )
import SrcLoc ( mkGeneratedSrcLoc, SrcLoc )
import TyCon ( tyConTyVars, tyConDataCons, tyConDerivings,
- tyConTheta, maybeTyConSingleCon,
+ tyConTheta, maybeTyConSingleCon, isDataTyCon,
isEnumerationTyCon, isAlgTyCon, TyCon
)
import Type ( GenType(..), SYN_IE(TauType), mkTyVarTys, applyTyCon,
isEnumerationTyCon, isAlgTyCon, TyCon
)
import Type ( GenType(..), SYN_IE(TauType), mkTyVarTys, applyTyCon,
(tycons_of_interest, _) = removeDups cmp all_tycons
do_con2tag acc_Names tycon
(tycons_of_interest, _) = removeDups cmp all_tycons
do_con2tag acc_Names tycon
- = if (we_are_deriving eqClassKey tycon
+ | isDataTyCon tycon &&
+ (we_are_deriving eqClassKey tycon
&& any isNullaryDataCon (tyConDataCons tycon))
&& any isNullaryDataCon (tyConDataCons tycon))
- || (we_are_deriving ordClassKey tycon
+ || (we_are_deriving ordClassKey tycon
&& not (maybeToBool (maybeTyConSingleCon tycon)))
&& not (maybeToBool (maybeTyConSingleCon tycon)))
- || (we_are_deriving enumClassKey tycon)
- || (we_are_deriving ixClassKey tycon)
- then
- returnTc ((con2tag_RDR tycon, tycon, GenCon2Tag)
+ || (we_are_deriving enumClassKey tycon)
+ || (we_are_deriving ixClassKey tycon)
+
+ = returnTc ((con2tag_RDR tycon, tycon, GenCon2Tag)
- else
- returnTc acc_Names
+ | otherwise
+ = returnTc acc_Names
do_tag2con acc_Names tycon
= if (we_are_deriving enumClassKey tycon)
do_tag2con acc_Names tycon
= if (we_are_deriving enumClassKey tycon)