    {-# LANGUAGE DeriveDataTypeable #-}
    {-# LANGUAGE DeriveGeneric #-}
    {-# LANGUAGE GeneralizedNewtypeDeriving #-}

    module Distribution.Types.ComponentId
      ( ComponentId
      , unComponentId
      , mkComponentId
      ) where

    import Distribution.Compat.Prelude
    import Distribution.Utils.ShortText
    import Prelude ()

    import Distribution.Parsec
    import Distribution.Pretty

    import qualified Distribution.Compat.CharParsing as P
    import Text.PrettyPrint (text)

    -- | A 'ComponentId' uniquely identifies the transitive source
    -- code closure of a component (i.e. libraries, executables).
    --
    -- For non-Backpack components, this corresponds one to one with
    -- the 'UnitId', which serves as the basis for install paths,
    -- linker symbols, etc.
    --
    -- Use 'mkComponentId' and 'unComponentId' to convert from/to a
    -- 'String'.
    --
    -- This type is opaque since @Cabal-2.0@
    --
    -- @since 2.0.0.2
    newtype ComponentId = ComponentId ShortText
      deriving ((forall x. ComponentId -> Rep ComponentId x)
    -> (forall x. Rep ComponentId x -> ComponentId)
    -> Generic ComponentId
    forall x. Rep ComponentId x -> ComponentId
    forall x. ComponentId -> Rep ComponentId x
    forall a.
    (forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
    $cfrom :: forall x. ComponentId -> Rep ComponentId x
    from :: forall x. ComponentId -> Rep ComponentId x
    $cto :: forall x. Rep ComponentId x -> ComponentId
    to :: forall x. Rep ComponentId x -> ComponentId
    Generic, ReadPrec [ComponentId]
    ReadPrec ComponentId
    Int -> ReadS ComponentId
    ReadS [ComponentId]
    (Int -> ReadS ComponentId)
    -> ReadS [ComponentId]
    -> ReadPrec ComponentId
    -> ReadPrec [ComponentId]
    -> Read ComponentId
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    $creadsPrec :: Int -> ReadS ComponentId
    readsPrec :: Int -> ReadS ComponentId
    $creadList :: ReadS [ComponentId]
    readList :: ReadS [ComponentId]
    $creadPrec :: ReadPrec ComponentId
    readPrec :: ReadPrec ComponentId
    $creadListPrec :: ReadPrec [ComponentId]
    readListPrec :: ReadPrec [ComponentId]
    Read, Int -> ComponentId -> ShowS
    [ComponentId] -> ShowS
    ComponentId -> String
    (Int -> ComponentId -> ShowS)
    -> (ComponentId -> String)
    -> ([ComponentId] -> ShowS)
    -> Show ComponentId
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: Int -> ComponentId -> ShowS
    showsPrec :: Int -> ComponentId -> ShowS
    $cshow :: ComponentId -> String
    show :: ComponentId -> String
    $cshowList :: [ComponentId] -> ShowS
    showList :: [ComponentId] -> ShowS
    Show, ComponentId -> ComponentId -> Bool
    (ComponentId -> ComponentId -> Bool)
    -> (ComponentId -> ComponentId -> Bool) -> Eq ComponentId
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: ComponentId -> ComponentId -> Bool
    == :: ComponentId -> ComponentId -> Bool
    $c/= :: ComponentId -> ComponentId -> Bool
    /= :: ComponentId -> ComponentId -> Bool
    Eq, Eq ComponentId
    Eq ComponentId =>
    (ComponentId -> ComponentId -> Ordering)
    -> (ComponentId -> ComponentId -> Bool)
    -> (ComponentId -> ComponentId -> Bool)
    -> (ComponentId -> ComponentId -> Bool)
    -> (ComponentId -> ComponentId -> Bool)
    -> (ComponentId -> ComponentId -> ComponentId)
    -> (ComponentId -> ComponentId -> ComponentId)
    -> Ord ComponentId
    ComponentId -> ComponentId -> Bool
    ComponentId -> ComponentId -> Ordering
    ComponentId -> ComponentId -> ComponentId
    forall a.
    Eq a =>
    (a -> a -> Ordering)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> Bool)
    -> (a -> a -> a)
    -> (a -> a -> a)
    -> Ord a
    $ccompare :: ComponentId -> ComponentId -> Ordering
    compare :: ComponentId -> ComponentId -> Ordering
    $c< :: ComponentId -> ComponentId -> Bool
    < :: ComponentId -> ComponentId -> Bool
    $c<= :: ComponentId -> ComponentId -> Bool
    <= :: ComponentId -> ComponentId -> Bool
    $c> :: ComponentId -> ComponentId -> Bool
    > :: ComponentId -> ComponentId -> Bool
    $c>= :: ComponentId -> ComponentId -> Bool
    >= :: ComponentId -> ComponentId -> Bool
    $cmax :: ComponentId -> ComponentId -> ComponentId
    max :: ComponentId -> ComponentId -> ComponentId
    $cmin :: ComponentId -> ComponentId -> ComponentId
    min :: ComponentId -> ComponentId -> ComponentId
    Ord, Typeable, Typeable ComponentId
    Typeable ComponentId =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> ComponentId -> c ComponentId)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c ComponentId)
    -> (ComponentId -> Constr)
    -> (ComponentId -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c ComponentId))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e))
        -> Maybe (c ComponentId))
    -> ((forall b. Data b => b -> b) -> ComponentId -> ComponentId)
    -> (forall r r'.
        (r -> r' -> r)
        -> r -> (forall d. Data d => d -> r') -> ComponentId -> r)
    -> (forall r r'.
        (r' -> r -> r)
        -> r -> (forall d. Data d => d -> r') -> ComponentId -> r)
    -> (forall u. (forall d. Data d => d -> u) -> ComponentId -> [u])
    -> (forall u.
        Int -> (forall d. Data d => d -> u) -> ComponentId -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> ComponentId -> m ComponentId)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> ComponentId -> m ComponentId)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> ComponentId -> m ComponentId)
    -> Data ComponentId
    ComponentId -> Constr
    ComponentId -> DataType
    (forall b. Data b => b -> b) -> ComponentId -> ComponentId
    forall a.
    Typeable a =>
    (forall (c :: * -> *).
     (forall d b. Data d => c (d -> b) -> d -> c b)
     -> (forall g. g -> c g) -> a -> c a)
    -> (forall (c :: * -> *).
        (forall b r. Data b => c (b -> r) -> c r)
        -> (forall r. r -> c r) -> Constr -> c a)
    -> (a -> Constr)
    -> (a -> DataType)
    -> (forall (t :: * -> *) (c :: * -> *).
        Typeable t =>
        (forall d. Data d => c (t d)) -> Maybe (c a))
    -> (forall (t :: * -> * -> *) (c :: * -> *).
        Typeable t =>
        (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
    -> ((forall b. Data b => b -> b) -> a -> a)
    -> (forall r r'.
        (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall r r'.
        (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
    -> (forall u. (forall d. Data d => d -> u) -> a -> [u])
    -> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
    -> (forall (m :: * -> *).
        Monad m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> (forall (m :: * -> *).
        MonadPlus m =>
        (forall d. Data d => d -> m d) -> a -> m a)
    -> Data a
    forall u. Int -> (forall d. Data d => d -> u) -> ComponentId -> u
    forall u. (forall d. Data d => d -> u) -> ComponentId -> [u]
    forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ComponentId -> r
    forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ComponentId -> r
    forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ComponentId -> m ComponentId
    forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ComponentId -> m ComponentId
    forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ComponentId
    forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ComponentId -> c ComponentId
    forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ComponentId)
    forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ComponentId)
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ComponentId -> c ComponentId
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ComponentId -> c ComponentId
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ComponentId
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ComponentId
    $ctoConstr :: ComponentId -> Constr
    toConstr :: ComponentId -> Constr
    $cdataTypeOf :: ComponentId -> DataType
    dataTypeOf :: ComponentId -> DataType
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ComponentId)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ComponentId)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ComponentId)
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ComponentId)
    $cgmapT :: (forall b. Data b => b -> b) -> ComponentId -> ComponentId
    gmapT :: (forall b. Data b => b -> b) -> ComponentId -> ComponentId
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ComponentId -> r
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ComponentId -> r
    $cgmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ComponentId -> r
    gmapQr :: forall r r'.
    (r' -> r -> r)
    -> r -> (forall d. Data d => d -> r') -> ComponentId -> r
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> ComponentId -> [u]
    gmapQ :: forall u. (forall d. Data d => d -> u) -> ComponentId -> [u]
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ComponentId -> u
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ComponentId -> u
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ComponentId -> m ComponentId
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ComponentId -> m ComponentId
    $cgmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ComponentId -> m ComponentId
    gmapMp :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ComponentId -> m ComponentId
    $cgmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ComponentId -> m ComponentId
    gmapMo :: forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> ComponentId -> m ComponentId
    Data)

    -- | Construct a 'ComponentId' from a 'String'
    --
    -- 'mkComponentId' is the inverse to 'unComponentId'
    --
    -- Note: No validations are performed to ensure that the resulting
    -- 'ComponentId' is valid
    --
    -- @since 2.0.0.2
    mkComponentId :: String -> ComponentId
    mkComponentId :: String -> ComponentId
    mkComponentId = ShortText -> ComponentId
    ComponentId (ShortText -> ComponentId)
    -> (String -> ShortText) -> String -> ComponentId
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> ShortText
    toShortText

    -- | Convert 'ComponentId' to 'String'
    --
    -- @since 2.0.0.2
    unComponentId :: ComponentId -> String
    unComponentId :: ComponentId -> String
    unComponentId (ComponentId ShortText
    s) = ShortText -> String
    fromShortText ShortText
    s

    -- | 'mkComponentId'
    --
    -- @since 2.0.0.2
    instance IsString ComponentId where
      fromString :: String -> ComponentId
    fromString = String -> ComponentId
    mkComponentId

    instance Binary ComponentId
    instance Structured ComponentId

    instance Pretty ComponentId where
      pretty :: ComponentId -> Doc
    pretty = String -> Doc
    text (String -> Doc) -> (ComponentId -> String) -> ComponentId -> Doc
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ComponentId -> String
    unComponentId

    instance Parsec ComponentId where
      parsec :: forall (m :: * -> *). CabalParsing m => m ComponentId
    parsec = String -> ComponentId
    mkComponentId (String -> ComponentId) -> m String -> m ComponentId
    forall a b. (a -> b) -> m a -> m b
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    `fmap` (Char -> Bool) -> m String
    forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m String
    P.munch1 Char -> Bool
    abi_char
        where
          abi_char :: Char -> Bool
    abi_char Char
    c = Char -> Bool
    isAlphaNum Char
    c Bool -> Bool -> Bool
    || Char
    c Char -> String -> Bool
    forall a. Eq a => a -> [a] -> Bool
    forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` String
    "-_."

    instance NFData ComponentId where
      rnf :: ComponentId -> ()
    rnf = String -> ()
    forall a. NFData a => a -> ()
    rnf (String -> ()) -> (ComponentId -> String) -> ComponentId -> ()
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . ComponentId -> String
    unComponentId