{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Types.LibraryVisibility(
LibraryVisibility(..),
) where
import Distribution.Compat.Prelude
import Prelude ()
import Distribution.Parsec
import Distribution.Pretty
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
data LibraryVisibility
= LibraryVisibilityPublic
| LibraryVisibilityPrivate
deriving ((forall x. LibraryVisibility -> Rep LibraryVisibility x)
-> (forall x. Rep LibraryVisibility x -> LibraryVisibility)
-> Generic LibraryVisibility
forall x. Rep LibraryVisibility x -> LibraryVisibility
forall x. LibraryVisibility -> Rep LibraryVisibility x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LibraryVisibility x -> LibraryVisibility
$cfrom :: forall x. LibraryVisibility -> Rep LibraryVisibility x
Generic, Int -> LibraryVisibility -> ShowS
[LibraryVisibility] -> ShowS
LibraryVisibility -> String
(Int -> LibraryVisibility -> ShowS)
-> (LibraryVisibility -> String)
-> ([LibraryVisibility] -> ShowS)
-> Show LibraryVisibility
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LibraryVisibility] -> ShowS
$cshowList :: [LibraryVisibility] -> ShowS
show :: LibraryVisibility -> String
$cshow :: LibraryVisibility -> String
showsPrec :: Int -> LibraryVisibility -> ShowS
$cshowsPrec :: Int -> LibraryVisibility -> ShowS
Show, ReadPrec [LibraryVisibility]
ReadPrec LibraryVisibility
Int -> ReadS LibraryVisibility
ReadS [LibraryVisibility]
(Int -> ReadS LibraryVisibility)
-> ReadS [LibraryVisibility]
-> ReadPrec LibraryVisibility
-> ReadPrec [LibraryVisibility]
-> Read LibraryVisibility
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LibraryVisibility]
$creadListPrec :: ReadPrec [LibraryVisibility]
readPrec :: ReadPrec LibraryVisibility
$creadPrec :: ReadPrec LibraryVisibility
readList :: ReadS [LibraryVisibility]
$creadList :: ReadS [LibraryVisibility]
readsPrec :: Int -> ReadS LibraryVisibility
$creadsPrec :: Int -> ReadS LibraryVisibility
Read, LibraryVisibility -> LibraryVisibility -> Bool
(LibraryVisibility -> LibraryVisibility -> Bool)
-> (LibraryVisibility -> LibraryVisibility -> Bool)
-> Eq LibraryVisibility
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LibraryVisibility -> LibraryVisibility -> Bool
$c/= :: LibraryVisibility -> LibraryVisibility -> Bool
== :: LibraryVisibility -> LibraryVisibility -> Bool
$c== :: LibraryVisibility -> LibraryVisibility -> Bool
Eq, Typeable, Typeable LibraryVisibility
DataType
Constr
Typeable LibraryVisibility
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> LibraryVisibility
-> c LibraryVisibility)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LibraryVisibility)
-> (LibraryVisibility -> Constr)
-> (LibraryVisibility -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c LibraryVisibility))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c LibraryVisibility))
-> ((forall b. Data b => b -> b)
-> LibraryVisibility -> LibraryVisibility)
-> (forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LibraryVisibility -> r)
-> (forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LibraryVisibility -> r)
-> (forall u.
(forall d. Data d => d -> u) -> LibraryVisibility -> [u])
-> (forall u.
Int -> (forall d. Data d => d -> u) -> LibraryVisibility -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> LibraryVisibility -> m LibraryVisibility)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> LibraryVisibility -> m LibraryVisibility)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> LibraryVisibility -> m LibraryVisibility)
-> Data LibraryVisibility
LibraryVisibility -> DataType
LibraryVisibility -> Constr
(forall b. Data b => b -> b)
-> LibraryVisibility -> LibraryVisibility
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LibraryVisibility -> c LibraryVisibility
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LibraryVisibility
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) -> LibraryVisibility -> u
forall u. (forall d. Data d => d -> u) -> LibraryVisibility -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LibraryVisibility -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LibraryVisibility -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> LibraryVisibility -> m LibraryVisibility
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> LibraryVisibility -> m LibraryVisibility
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LibraryVisibility
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LibraryVisibility -> c LibraryVisibility
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c LibraryVisibility)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c LibraryVisibility)
$cLibraryVisibilityPrivate :: Constr
$cLibraryVisibilityPublic :: Constr
$tLibraryVisibility :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> LibraryVisibility -> m LibraryVisibility
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> LibraryVisibility -> m LibraryVisibility
gmapMp :: (forall d. Data d => d -> m d)
-> LibraryVisibility -> m LibraryVisibility
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> LibraryVisibility -> m LibraryVisibility
gmapM :: (forall d. Data d => d -> m d)
-> LibraryVisibility -> m LibraryVisibility
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> LibraryVisibility -> m LibraryVisibility
gmapQi :: Int -> (forall d. Data d => d -> u) -> LibraryVisibility -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> LibraryVisibility -> u
gmapQ :: (forall d. Data d => d -> u) -> LibraryVisibility -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> LibraryVisibility -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LibraryVisibility -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> LibraryVisibility -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LibraryVisibility -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> LibraryVisibility -> r
gmapT :: (forall b. Data b => b -> b)
-> LibraryVisibility -> LibraryVisibility
$cgmapT :: (forall b. Data b => b -> b)
-> LibraryVisibility -> LibraryVisibility
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c LibraryVisibility)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c LibraryVisibility)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c LibraryVisibility)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c LibraryVisibility)
dataTypeOf :: LibraryVisibility -> DataType
$cdataTypeOf :: LibraryVisibility -> DataType
toConstr :: LibraryVisibility -> Constr
$ctoConstr :: LibraryVisibility -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LibraryVisibility
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c LibraryVisibility
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LibraryVisibility -> c LibraryVisibility
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> LibraryVisibility -> c LibraryVisibility
$cp1Data :: Typeable LibraryVisibility
Data)
instance Pretty LibraryVisibility where
pretty :: LibraryVisibility -> Doc
pretty LibraryVisibility
LibraryVisibilityPublic = String -> Doc
Disp.text String
"public"
pretty LibraryVisibility
LibraryVisibilityPrivate = String -> Doc
Disp.text String
"private"
instance Parsec LibraryVisibility where
parsec :: m LibraryVisibility
parsec = do
String
name <- (Char -> Bool) -> m String
forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m String
P.munch1 Char -> Bool
isAlpha
case String
name of
String
"public" -> LibraryVisibility -> m LibraryVisibility
forall (m :: * -> *) a. Monad m => a -> m a
return LibraryVisibility
LibraryVisibilityPublic
String
"private" -> LibraryVisibility -> m LibraryVisibility
forall (m :: * -> *) a. Monad m => a -> m a
return LibraryVisibility
LibraryVisibilityPrivate
String
_ -> String -> m LibraryVisibility
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> m LibraryVisibility) -> String -> m LibraryVisibility
forall a b. (a -> b) -> a -> b
$ String
"Unknown visibility: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
name
instance Binary LibraryVisibility
instance NFData LibraryVisibility where rnf :: LibraryVisibility -> ()
rnf = LibraryVisibility -> ()
forall a. (Generic a, GNFData (Rep a)) => a -> ()
genericRnf
instance Semigroup LibraryVisibility where
LibraryVisibility
LibraryVisibilityPrivate <> :: LibraryVisibility -> LibraryVisibility -> LibraryVisibility
<> LibraryVisibility
LibraryVisibilityPrivate = LibraryVisibility
LibraryVisibilityPrivate
LibraryVisibility
_ <> LibraryVisibility
_ = LibraryVisibility
LibraryVisibilityPublic
instance Monoid LibraryVisibility where
mempty :: LibraryVisibility
mempty = LibraryVisibility
LibraryVisibilityPrivate
mappend :: LibraryVisibility -> LibraryVisibility -> LibraryVisibility
mappend = LibraryVisibility -> LibraryVisibility -> LibraryVisibility
forall a. Semigroup a => a -> a -> a
(<>)