- chk_out :: (Class, TyCon) -> TcM s ()
- chk_out this_one@(clas, tycon)
- = let
- clas_key = classKey clas
-
- is_enumeration = isEnumerationTyCon tycon
- is_single_con = maybeToBool (maybeTyConSingleCon tycon)
-
- single_nullary_why = SLIT("one constructor data type or type with all nullary constructors expected")
- nullary_why = SLIT("data type with all nullary constructors expected")
-
- chk_clas clas_uniq clas_str clas_why cond
- = if (clas_uniq == clas_key)
- then checkTc cond (derivingThingErr clas_str clas_why tycon)
- else returnTc ()
- in
- -- Are things OK for deriving Enum (if appropriate)?
- chk_clas enumClassKey (SLIT("Enum")) nullary_why is_enumeration `thenTc_`
-
- -- Are things OK for deriving Bounded (if appropriate)?
- chk_clas boundedClassKey (SLIT("Bounded")) single_nullary_why
- (is_enumeration || is_single_con) `thenTc_`
-
- -- Are things OK for deriving Ix (if appropriate)?
- chk_clas ixClassKey (SLIT("Ix.Ix")) single_nullary_why
- (is_enumeration || is_single_con)
-
- ------------------------------------------------------------------