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

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

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

    import Distribution.Pretty
    import Distribution.Parsec

    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. 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
    $cto :: forall x. Rep ComponentId x -> ComponentId
    $cfrom :: forall x. ComponentId -> Rep ComponentId x
    Generic, ReadPrec [ComponentId]
    ReadPrec ComponentId
    Int -> ReadS ComponentId
    ReadS [ComponentId]
    forall a.
    (Int -> ReadS a)
    -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
    readListPrec :: ReadPrec [ComponentId]
    $creadListPrec :: ReadPrec [ComponentId]
    readPrec :: ReadPrec ComponentId
    $creadPrec :: ReadPrec ComponentId
    readList :: ReadS [ComponentId]
    $creadList :: ReadS [ComponentId]
    readsPrec :: Int -> ReadS ComponentId
    $creadsPrec :: Int -> ReadS ComponentId
    Read, Int -> ComponentId -> ShowS
    [ComponentId] -> ShowS
    ComponentId -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [ComponentId] -> ShowS
    $cshowList :: [ComponentId] -> ShowS
    show :: ComponentId -> String
    $cshow :: ComponentId -> String
    showsPrec :: Int -> ComponentId -> ShowS
    $cshowsPrec :: Int -> ComponentId -> ShowS
    Show, ComponentId -> ComponentId -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: ComponentId -> ComponentId -> Bool
    $c/= :: ComponentId -> ComponentId -> Bool
    == :: ComponentId -> ComponentId -> Bool
    $c== :: ComponentId -> ComponentId -> Bool
    Eq, Eq 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
    min :: ComponentId -> ComponentId -> ComponentId
    $cmin :: ComponentId -> ComponentId -> ComponentId
    max :: ComponentId -> ComponentId -> ComponentId
    $cmax :: ComponentId -> ComponentId -> ComponentId
    >= :: ComponentId -> ComponentId -> Bool
    $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
    compare :: ComponentId -> ComponentId -> Ordering
    $ccompare :: ComponentId -> ComponentId -> Ordering
    Ord, Typeable, Typeable ComponentId
    ComponentId -> DataType
    ComponentId -> Constr
    (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)
    gmapMo :: 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
    gmapMp :: forall (m :: * -> *).
    MonadPlus 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
    gmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ComponentId -> m ComponentId
    $cgmapM :: forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> ComponentId -> m ComponentId
    gmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ComponentId -> u
    $cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ComponentId -> u
    gmapQ :: forall u. (forall d. Data d => d -> u) -> ComponentId -> [u]
    $cgmapQ :: forall u. (forall d. Data d => d -> u) -> ComponentId -> [u]
    gmapQr :: 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
    gmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ComponentId -> r
    $cgmapQl :: forall r r'.
    (r -> r' -> r)
    -> r -> (forall d. Data d => d -> r') -> ComponentId -> r
    gmapT :: (forall b. Data b => b -> b) -> ComponentId -> ComponentId
    $cgmapT :: (forall b. Data b => b -> b) -> ComponentId -> ComponentId
    dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ComponentId)
    $cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c ComponentId)
    dataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ComponentId)
    $cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c ComponentId)
    dataTypeOf :: ComponentId -> DataType
    $cdataTypeOf :: ComponentId -> DataType
    toConstr :: ComponentId -> Constr
    $ctoConstr :: ComponentId -> Constr
    gunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ComponentId
    $cgunfold :: forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c ComponentId
    gfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ComponentId -> c ComponentId
    $cgfoldl :: forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> ComponentId -> c 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 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 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 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    `fmap` 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 forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
    `elem` String
    "-_."

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