{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
module Distribution.Types.UnqualComponentName
( UnqualComponentName, unUnqualComponentName, unUnqualComponentNameST, mkUnqualComponentName
, packageNameToUnqualComponentName, unqualComponentNameToPackageName
) where
import Distribution.Compat.Prelude
import Distribution.Utils.ShortText
import Prelude ()
import Distribution.Parsec
import Distribution.Pretty
import Distribution.Types.PackageName
newtype UnqualComponentName = UnqualComponentName ShortText
deriving ((forall x. UnqualComponentName -> Rep UnqualComponentName x)
-> (forall x. Rep UnqualComponentName x -> UnqualComponentName)
-> Generic UnqualComponentName
forall x. Rep UnqualComponentName x -> UnqualComponentName
forall x. UnqualComponentName -> Rep UnqualComponentName x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UnqualComponentName x -> UnqualComponentName
$cfrom :: forall x. UnqualComponentName -> Rep UnqualComponentName x
Generic, ReadPrec [UnqualComponentName]
ReadPrec UnqualComponentName
Int -> ReadS UnqualComponentName
ReadS [UnqualComponentName]
(Int -> ReadS UnqualComponentName)
-> ReadS [UnqualComponentName]
-> ReadPrec UnqualComponentName
-> ReadPrec [UnqualComponentName]
-> Read UnqualComponentName
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UnqualComponentName]
$creadListPrec :: ReadPrec [UnqualComponentName]
readPrec :: ReadPrec UnqualComponentName
$creadPrec :: ReadPrec UnqualComponentName
readList :: ReadS [UnqualComponentName]
$creadList :: ReadS [UnqualComponentName]
readsPrec :: Int -> ReadS UnqualComponentName
$creadsPrec :: Int -> ReadS UnqualComponentName
Read, Int -> UnqualComponentName -> ShowS
[UnqualComponentName] -> ShowS
UnqualComponentName -> String
(Int -> UnqualComponentName -> ShowS)
-> (UnqualComponentName -> String)
-> ([UnqualComponentName] -> ShowS)
-> Show UnqualComponentName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UnqualComponentName] -> ShowS
$cshowList :: [UnqualComponentName] -> ShowS
show :: UnqualComponentName -> String
$cshow :: UnqualComponentName -> String
showsPrec :: Int -> UnqualComponentName -> ShowS
$cshowsPrec :: Int -> UnqualComponentName -> ShowS
Show, UnqualComponentName -> UnqualComponentName -> Bool
(UnqualComponentName -> UnqualComponentName -> Bool)
-> (UnqualComponentName -> UnqualComponentName -> Bool)
-> Eq UnqualComponentName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UnqualComponentName -> UnqualComponentName -> Bool
$c/= :: UnqualComponentName -> UnqualComponentName -> Bool
== :: UnqualComponentName -> UnqualComponentName -> Bool
$c== :: UnqualComponentName -> UnqualComponentName -> Bool
Eq, Eq UnqualComponentName
Eq UnqualComponentName
-> (UnqualComponentName -> UnqualComponentName -> Ordering)
-> (UnqualComponentName -> UnqualComponentName -> Bool)
-> (UnqualComponentName -> UnqualComponentName -> Bool)
-> (UnqualComponentName -> UnqualComponentName -> Bool)
-> (UnqualComponentName -> UnqualComponentName -> Bool)
-> (UnqualComponentName
-> UnqualComponentName -> UnqualComponentName)
-> (UnqualComponentName
-> UnqualComponentName -> UnqualComponentName)
-> Ord UnqualComponentName
UnqualComponentName -> UnqualComponentName -> Bool
UnqualComponentName -> UnqualComponentName -> Ordering
UnqualComponentName -> UnqualComponentName -> UnqualComponentName
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 :: UnqualComponentName -> UnqualComponentName -> UnqualComponentName
$cmin :: UnqualComponentName -> UnqualComponentName -> UnqualComponentName
max :: UnqualComponentName -> UnqualComponentName -> UnqualComponentName
$cmax :: UnqualComponentName -> UnqualComponentName -> UnqualComponentName
>= :: UnqualComponentName -> UnqualComponentName -> Bool
$c>= :: UnqualComponentName -> UnqualComponentName -> Bool
> :: UnqualComponentName -> UnqualComponentName -> Bool
$c> :: UnqualComponentName -> UnqualComponentName -> Bool
<= :: UnqualComponentName -> UnqualComponentName -> Bool
$c<= :: UnqualComponentName -> UnqualComponentName -> Bool
< :: UnqualComponentName -> UnqualComponentName -> Bool
$c< :: UnqualComponentName -> UnqualComponentName -> Bool
compare :: UnqualComponentName -> UnqualComponentName -> Ordering
$ccompare :: UnqualComponentName -> UnqualComponentName -> Ordering
Ord, Typeable, Typeable UnqualComponentName
Typeable UnqualComponentName
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> UnqualComponentName
-> c UnqualComponentName)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnqualComponentName)
-> (UnqualComponentName -> Constr)
-> (UnqualComponentName -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnqualComponentName))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UnqualComponentName))
-> ((forall b. Data b => b -> b)
-> UnqualComponentName -> UnqualComponentName)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnqualComponentName -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnqualComponentName -> r)
-> (forall u.
(forall d. Data d => d -> u) -> UnqualComponentName -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> UnqualComponentName -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> UnqualComponentName -> m UnqualComponentName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UnqualComponentName -> m UnqualComponentName)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UnqualComponentName -> m UnqualComponentName)
-> Data UnqualComponentName
UnqualComponentName -> DataType
UnqualComponentName -> Constr
(forall b. Data b => b -> b)
-> UnqualComponentName -> UnqualComponentName
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) -> UnqualComponentName -> u
forall u.
(forall d. Data d => d -> u) -> UnqualComponentName -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnqualComponentName -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnqualComponentName -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> UnqualComponentName -> m UnqualComponentName
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UnqualComponentName -> m UnqualComponentName
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnqualComponentName
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> UnqualComponentName
-> c UnqualComponentName
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnqualComponentName)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UnqualComponentName)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UnqualComponentName -> m UnqualComponentName
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UnqualComponentName -> m UnqualComponentName
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UnqualComponentName -> m UnqualComponentName
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> UnqualComponentName -> m UnqualComponentName
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> UnqualComponentName -> m UnqualComponentName
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> UnqualComponentName -> m UnqualComponentName
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> UnqualComponentName -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> UnqualComponentName -> u
gmapQ :: forall u.
(forall d. Data d => d -> u) -> UnqualComponentName -> [u]
$cgmapQ :: forall u.
(forall d. Data d => d -> u) -> UnqualComponentName -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnqualComponentName -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> UnqualComponentName -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnqualComponentName -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> UnqualComponentName -> r
gmapT :: (forall b. Data b => b -> b)
-> UnqualComponentName -> UnqualComponentName
$cgmapT :: (forall b. Data b => b -> b)
-> UnqualComponentName -> UnqualComponentName
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UnqualComponentName)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c UnqualComponentName)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnqualComponentName)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c UnqualComponentName)
dataTypeOf :: UnqualComponentName -> DataType
$cdataTypeOf :: UnqualComponentName -> DataType
toConstr :: UnqualComponentName -> Constr
$ctoConstr :: UnqualComponentName -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnqualComponentName
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c UnqualComponentName
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> UnqualComponentName
-> c UnqualComponentName
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> UnqualComponentName
-> c UnqualComponentName
Data,
NonEmpty UnqualComponentName -> UnqualComponentName
UnqualComponentName -> UnqualComponentName -> UnqualComponentName
(UnqualComponentName -> UnqualComponentName -> UnqualComponentName)
-> (NonEmpty UnqualComponentName -> UnqualComponentName)
-> (forall b.
Integral b =>
b -> UnqualComponentName -> UnqualComponentName)
-> Semigroup UnqualComponentName
forall b.
Integral b =>
b -> UnqualComponentName -> UnqualComponentName
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
stimes :: forall b.
Integral b =>
b -> UnqualComponentName -> UnqualComponentName
$cstimes :: forall b.
Integral b =>
b -> UnqualComponentName -> UnqualComponentName
sconcat :: NonEmpty UnqualComponentName -> UnqualComponentName
$csconcat :: NonEmpty UnqualComponentName -> UnqualComponentName
<> :: UnqualComponentName -> UnqualComponentName -> UnqualComponentName
$c<> :: UnqualComponentName -> UnqualComponentName -> UnqualComponentName
Semigroup, Semigroup UnqualComponentName
UnqualComponentName
Semigroup UnqualComponentName
-> UnqualComponentName
-> (UnqualComponentName
-> UnqualComponentName -> UnqualComponentName)
-> ([UnqualComponentName] -> UnqualComponentName)
-> Monoid UnqualComponentName
[UnqualComponentName] -> UnqualComponentName
UnqualComponentName -> UnqualComponentName -> UnqualComponentName
forall a.
Semigroup a -> a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
mconcat :: [UnqualComponentName] -> UnqualComponentName
$cmconcat :: [UnqualComponentName] -> UnqualComponentName
mappend :: UnqualComponentName -> UnqualComponentName -> UnqualComponentName
$cmappend :: UnqualComponentName -> UnqualComponentName -> UnqualComponentName
mempty :: UnqualComponentName
$cmempty :: UnqualComponentName
Monoid)
unUnqualComponentName :: UnqualComponentName -> String
unUnqualComponentName :: UnqualComponentName -> String
unUnqualComponentName (UnqualComponentName ShortText
s) = ShortText -> String
fromShortText ShortText
s
unUnqualComponentNameST :: UnqualComponentName -> ShortText
unUnqualComponentNameST :: UnqualComponentName -> ShortText
unUnqualComponentNameST (UnqualComponentName ShortText
s) = ShortText
s
mkUnqualComponentName :: String -> UnqualComponentName
mkUnqualComponentName :: String -> UnqualComponentName
mkUnqualComponentName = ShortText -> UnqualComponentName
UnqualComponentName (ShortText -> UnqualComponentName)
-> (String -> ShortText) -> String -> UnqualComponentName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> ShortText
toShortText
instance IsString UnqualComponentName where
fromString :: String -> UnqualComponentName
fromString = String -> UnqualComponentName
mkUnqualComponentName
instance Binary UnqualComponentName
instance Structured UnqualComponentName
instance Pretty UnqualComponentName where
pretty :: UnqualComponentName -> Doc
pretty = String -> Doc
showToken (String -> Doc)
-> (UnqualComponentName -> String) -> UnqualComponentName -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnqualComponentName -> String
unUnqualComponentName
instance Parsec UnqualComponentName where
parsec :: forall (m :: * -> *). CabalParsing m => m UnqualComponentName
parsec = String -> UnqualComponentName
mkUnqualComponentName (String -> UnqualComponentName)
-> m String -> m UnqualComponentName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m String
forall (m :: * -> *). CabalParsing m => m String
parsecUnqualComponentName
instance NFData UnqualComponentName where
rnf :: UnqualComponentName -> ()
rnf (UnqualComponentName ShortText
pkg) = ShortText -> ()
forall a. NFData a => a -> ()
rnf ShortText
pkg
packageNameToUnqualComponentName :: PackageName -> UnqualComponentName
packageNameToUnqualComponentName :: PackageName -> UnqualComponentName
packageNameToUnqualComponentName = ShortText -> UnqualComponentName
UnqualComponentName (ShortText -> UnqualComponentName)
-> (PackageName -> ShortText) -> PackageName -> UnqualComponentName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageName -> ShortText
unPackageNameST
unqualComponentNameToPackageName :: UnqualComponentName -> PackageName
unqualComponentNameToPackageName :: UnqualComponentName -> PackageName
unqualComponentNameToPackageName = ShortText -> PackageName
mkPackageNameST (ShortText -> PackageName)
-> (UnqualComponentName -> ShortText)
-> UnqualComponentName
-> PackageName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnqualComponentName -> ShortText
unUnqualComponentNameST