checkRecTc :: RecTcChecker -> TyCon -> Maybe RecTcChecker
-- Nothing      => Recursion detected
-- Just rec_tcs => Keep going
checkRecTc (RC rec_nts) tc
  | not (isRecursiveTyCon tc)     = Just (RC rec_nts)
  | tc_name `elemNameSet` rec_nts = Nothing
  | otherwise                     = Just (RC (extendNameSet rec_nts tc_name))
  where
    tc_name = tyConName tc
checkRecTc :: RecTcChecker -> TyCon -> Maybe RecTcChecker
checkRecTc (RC rec_nts) tc
  | not (isRecursiveTyCon tc)     = Just (RC rec_nts)
  | tc_name `elemNameSet` rec_nts = Nothing
  | otherwise                     = Just (RC (extendNameSet rec_nts tc_name))
  where
    tc_name = tyConName tc
checkRecTc (RC rec_nts) tc
  | not (isRecursiveTyCon tc)     = Just (RC rec_nts)
  | tc_name `elemNameSet` rec_nts = Nothing
  | otherwise                     = Just (RC (extendNameSet rec_nts tc_name))
  where
    tc_name = tyConName tc