    {-# LANGUAGE CPP                   #-}
    {-# LANGUAGE TemplateHaskellQuotes #-}

    {-|
    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,
        giveGCStatsTypeName,
        doCostCentresTypeName,
        doHeapProfileTypeName,
        doTraceTypeName,
        ) where

    import GHC.RTS.Flags (GiveGCStats, DoCostCentres, DoHeapProfile, DoTrace)
    import Language.Haskell.TH.Syntax

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

    -- | Creates a 'Name' for a value from the "GHC.Event.Internal" module.
    mkEventName_v :: String -> Name
    #if MIN_VERSION_base(4,20,0)
    mkEventName_v :: String -> Name
    mkEventName_v = String -> String -> String -> Name
    mkNameG_v String
    "ghc-internal" String
    "GHC.Internal.Event.Internal.Types"
    #elif MIN_VERSION_base(4,15,0)
    mkEventName_v = mkNameG_v "base" "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
    #if MIN_VERSION_base(4,20,0)
    fdKeyTypeName :: Name
    fdKeyTypeName = String -> String -> String -> Name
    mkNameG_tc String
    "ghc-internal" String
    "GHC.Internal.Event.Manager" String
    "FdKey"
    #else
    fdKeyTypeName = mkNameG_tc "base" "GHC.Event.Manager" "FdKey"
    #endif

    -- | The 'Name' of 'Unique'.
    uniqueTypeName :: Name
    #if MIN_VERSION_base(4,20,0)
    uniqueTypeName :: Name
    uniqueTypeName = String -> String -> String -> Name
    mkNameG_tc String
    "ghc-internal" String
    "GHC.Internal.Event.Unique" String
    "Unique"
    #else
    uniqueTypeName = mkNameG_tc "base" "GHC.Event.Unique" "Unique"
    #endif

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

    -- | The 'Name' of 'GiveGCStats'.
    giveGCStatsTypeName :: Name
    giveGCStatsTypeName :: Name
    giveGCStatsTypeName = ''GiveGCStats

    -- | The 'Name' of 'DoCostCentres'.
    doCostCentresTypeName :: Name
    doCostCentresTypeName :: Name
    doCostCentresTypeName = ''DoCostCentres

    -- | The 'Name' of 'DoHeapProfile'.
    doHeapProfileTypeName :: Name
    doHeapProfileTypeName :: Name
    doHeapProfileTypeName = ''DoHeapProfile

    -- | The 'Name' of 'DoTrace'.
    doTraceTypeName :: Name
    doTraceTypeName :: Name
    doTraceTypeName = ''DoTrace