{-# 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)
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
$cto :: forall x. Rep ComponentId x -> ComponentId
$cfrom :: forall x. ComponentId -> Rep ComponentId x
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
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
(Int -> ComponentId -> ShowS)
-> (ComponentId -> String)
-> ([ComponentId] -> ShowS)
-> Show ComponentId
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
(ComponentId -> ComponentId -> Bool)
-> (ComponentId -> ComponentId -> Bool) -> Eq ComponentId
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
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
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
$cp1Ord :: Eq ComponentId
Ord, Typeable, Typeable ComponentId
DataType
Constr
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 -> DataType
ComponentId -> Constr
(forall b. Data b => b -> b) -> ComponentId -> ComponentId
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ComponentId -> c ComponentId
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cComponentId :: Constr
$tComponentId :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> ComponentId -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> ComponentId -> u
gmapQ :: (forall d. Data d => d -> u) -> ComponentId -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ComponentId -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable ComponentId
Data)
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
unComponentId :: ComponentId -> String
unComponentId :: ComponentId -> String
unComponentId (ComponentId ShortText
s) = ShortText -> String
fromShortText ShortText
s
instance IsString ComponentId where
fromString :: String -> ComponentId
fromString = String -> ComponentId
mkComponentId
instance Binary 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 :: m ComponentId
parsec = String -> ComponentId
mkComponentId (String -> ComponentId) -> m String -> m ComponentId
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 (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