buildAlgTyCon :: Name
              -> [TyVar]               -- ^ Kind variables and type variables
              -> [Role]
              -> Maybe CType
              -> ThetaType             -- ^ Stupid theta
              -> AlgTyConRhs
              -> RecFlag
              -> Bool                  -- ^ True <=> this TyCon is promotable
              -> Bool                  -- ^ True <=> was declared in GADT syntax
              -> TyConParent
              -> TyCon

buildAlgTyCon tc_name ktvs roles cType stupid_theta rhs
              is_rec is_promotable gadt_syn parent
  = tc
  where
    kind = mkPiKinds ktvs liftedTypeKind

    -- tc and mb_promoted_tc are mutually recursive
    tc = mkAlgTyCon tc_name kind ktvs roles cType stupid_theta
                    rhs parent is_rec gadt_syn
                    mb_promoted_tc

    mb_promoted_tc
      | is_promotable = Just (mkPromotedTyCon tc (promoteKind kind))
      | otherwise     = Nothing

{-
************************************************************************
*                                                                      *
        Promoting of data types to the kind level
*                                                                      *
************************************************************************

These two 'promoted..' functions are here because
 * They belong together
 * 'promoteDataCon' depends on DataCon stuff
-}
buildAlgTyCon :: Name
              -> [TyVar]               -- ^ Kind variables and type variables
              -> [Role]
              -> Maybe CType
              -> ThetaType             -- ^ Stupid theta
              -> AlgTyConRhs
              -> RecFlag
              -> Bool                  -- ^ True <=> this TyCon is promotable
              -> Bool                  -- ^ True <=> was declared in GADT syntax
              -> TyConParent
              -> TyCon
buildAlgTyCon tc_name ktvs roles cType stupid_theta rhs
              is_rec is_promotable gadt_syn parent
  = tc
  where
    kind = mkPiKinds ktvs liftedTypeKind

    -- tc and mb_promoted_tc are mutually recursive
    tc = mkAlgTyCon tc_name kind ktvs roles cType stupid_theta
                    rhs parent is_rec gadt_syn
                    mb_promoted_tc

    mb_promoted_tc
      | is_promotable = Just (mkPromotedTyCon tc (promoteKind kind))
      | otherwise     = Nothing

{-
************************************************************************
*                                                                      *
        Promoting of data types to the kind level
*                                                                      *
************************************************************************

These two 'promoted..' functions are here because
 * They belong together
 * 'promoteDataCon' depends on DataCon stuff
-}
buildAlgTyCon tc_name ktvs roles cType stupid_theta rhs
              is_rec is_promotable gadt_syn parent
  = tc
  where
    kind = mkPiKinds ktvs liftedTypeKind

    -- tc and mb_promoted_tc are mutually recursive
    tc = mkAlgTyCon tc_name kind ktvs roles cType stupid_theta
                    rhs parent is_rec gadt_syn
                    mb_promoted_tc

    mb_promoted_tc
      | is_promotable = Just (mkPromotedTyCon tc (promoteKind kind))
      | otherwise     = Nothing

{-
************************************************************************
*                                                                      *
        Promoting of data types to the kind level
*                                                                      *
************************************************************************

These two 'promoted..' functions are here because
 * They belong together
 * 'promoteDataCon' depends on DataCon stuff
-}