    {-# LANGUAGE CPP             #-}
    {-# LANGUAGE TemplateHaskell #-}

    {-|
    Module:      TextShow.TH.Names
    Copyright:   (C) 2014-2017 Ryan Scott
    License:     BSD-style (see the file LICENSE)
    Maintainer:  Ryan Scott
    Stability:   Provisional
    Portability: GHC

    Template Haskell names to eliminate some boilerplate.
    -}
    module TextShow.TH.Names (
        evtCloseValName,
        eventIsValName,
        fdKeyTypeName,
        uniqueTypeName,
        asInt64ValName,
    #if MIN_VERSION_base(4,8,0)
        giveGCStatsTypeName,
        doCostCentresTypeName,
        doHeapProfileTypeName,
        doTraceTypeName,
    #endif
        ) where

    import Language.Haskell.TH.Syntax

    #if MIN_VERSION_base(4,8,2)
    import GHC.RTS.Flags (GiveGCStats, DoCostCentres, DoHeapProfile, DoTrace)
    #endif

    -------------------------------------------------------------------------------

    -- | Creates a 'Name' for a value from the "GHC.Event.Internal" module.
    mkEventName_v :: String -> Name
    #if MIN_VERSION_base(4,15,0)
    mkEventName_v :: String -> Name
    mkEventName_v = String -> String -> String -> Name
    mkNameG_v String
    "base" String
    "GHC.Event.Internal.Types"
    #else
    mkEventName_v = mkNameG_v "base" "GHC.Event.Internal"
    #endif

    -- | The 'Name' of 'evtClose'.
    evtCloseValName :: Name
    evtCloseValName :: Name
    evtCloseValName = String -> Name
    mkEventName_v String
    "evtClose"

    -- | The 'Name' of 'eventIs'.
    eventIsValName :: Name
    eventIsValName :: Name
    eventIsValName = String -> Name
    mkEventName_v String
    "eventIs"

    -- | The 'Name' of 'FdKey'.
    fdKeyTypeName :: Name
    fdKeyTypeName :: Name
    fdKeyTypeName = String -> String -> String -> Name
    mkNameG_tc String
    "base" String
    "GHC.Event.Manager" String
    "FdKey"

    -- | The 'Name' of 'Unique'.
    uniqueTypeName :: Name
    uniqueTypeName :: Name
    uniqueTypeName = String -> String -> String -> Name
    mkNameG_tc String
    "base" String
    "GHC.Event.Unique" String
    "Unique"

    -- | The 'Name' of 'asInt64' (or, 'asInt' on @base-4.10.0.0@ or later).
    asInt64ValName :: Name
    #if MIN_VERSION_base(4,19,0)
    asInt64ValName = mkNameG_fld "base" "GHC.Event.Unique" "Unique" "asInt"
    #elif MIN_VERSION_base(4,10,0)
    asInt64ValName :: Name
    asInt64ValName = String -> String -> String -> Name
    mkNameG_v String
    "base" String
    "GHC.Event.Unique" String
    "asInt"
    #else
    asInt64ValName = mkNameG_v "base" "GHC.Event.Unique" "asInt64"
    #endif

    #if MIN_VERSION_base(4,8,0)
    -- | The 'Name' of 'GiveGCStats'.
    giveGCStatsTypeName :: Name
    # if MIN_VERSION_base(4,8,2)
    giveGCStatsTypeName :: Name
    giveGCStatsTypeName = ''GiveGCStats
    # else
    giveGCStatsTypeName = mkFlagsName_tc "GiveGCStats"
    # endif

    -- | The 'Name' of 'DoCostCentres'.
    doCostCentresTypeName :: Name
    # if MIN_VERSION_base(4,8,2)
    doCostCentresTypeName :: Name
    doCostCentresTypeName = ''DoCostCentres
    # else
    doCostCentresTypeName = mkFlagsName_tc "DoCostCentres"
    # endif

    -- | The 'Name' of 'DoHeapProfile'.
    doHeapProfileTypeName :: Name
    # if MIN_VERSION_base(4,8,2)
    doHeapProfileTypeName :: Name
    doHeapProfileTypeName = ''DoHeapProfile
    # else
    doHeapProfileTypeName = mkFlagsName_tc "DoHeapProfile"
    # endif

    -- | The 'Name' of 'DoTrace'.
    doTraceTypeName :: Name
    # if MIN_VERSION_base(4,8,2)
    doTraceTypeName :: Name
    doTraceTypeName = ''DoTrace
    # else
    doTraceTypeName = mkFlagsName_tc "DoTrace"
    # endif

    -- | Creates a 'Name' for a type from the "GHC.RTS.Flags" module.
    # if !(MIN_VERSION_base(4,8,2))
    mkFlagsName_tc :: String -> Name
    mkFlagsName_tc = mkNameG_tc "base" "GHC.RTS.Flags"
    # endif
    #endif