{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}

module Distribution.Types.ExecutableScope (
    ExecutableScope(..),
) where

import Prelude ()
import Distribution.Compat.Prelude

import Distribution.Pretty
import Distribution.Parsec

import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp

data ExecutableScope = ExecutablePublic
                     | ExecutablePrivate
    deriving (forall x. Rep ExecutableScope x -> ExecutableScope
forall x. ExecutableScope -> Rep ExecutableScope x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExecutableScope x -> ExecutableScope
$cfrom :: forall x. ExecutableScope -> Rep ExecutableScope x
Generic, Int -> ExecutableScope -> ShowS
[ExecutableScope] -> ShowS
ExecutableScope -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExecutableScope] -> ShowS
$cshowList :: [ExecutableScope] -> ShowS
show :: ExecutableScope -> String
$cshow :: ExecutableScope -> String
showsPrec :: Int -> ExecutableScope -> ShowS
$cshowsPrec :: Int -> ExecutableScope -> ShowS
Show, ReadPrec [ExecutableScope]
ReadPrec ExecutableScope
Int -> ReadS ExecutableScope
ReadS [ExecutableScope]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExecutableScope]
$creadListPrec :: ReadPrec [ExecutableScope]
readPrec :: ReadPrec ExecutableScope
$creadPrec :: ReadPrec ExecutableScope
readList :: ReadS [ExecutableScope]
$creadList :: ReadS [ExecutableScope]
readsPrec :: Int -> ReadS ExecutableScope
$creadsPrec :: Int -> ReadS ExecutableScope
Read, ExecutableScope -> ExecutableScope -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExecutableScope -> ExecutableScope -> Bool
$c/= :: ExecutableScope -> ExecutableScope -> Bool
== :: ExecutableScope -> ExecutableScope -> Bool
$c== :: ExecutableScope -> ExecutableScope -> Bool
Eq, Typeable, Typeable ExecutableScope
ExecutableScope -> DataType
ExecutableScope -> Constr
(forall b. Data b => b -> b) -> ExecutableScope -> ExecutableScope
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) -> ExecutableScope -> u
forall u. (forall d. Data d => d -> u) -> ExecutableScope -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ExecutableScope -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ExecutableScope -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ExecutableScope -> m ExecutableScope
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ExecutableScope -> m ExecutableScope
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExecutableScope
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExecutableScope -> c ExecutableScope
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ExecutableScope)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ExecutableScope)
gmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ExecutableScope -> m ExecutableScope
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ExecutableScope -> m ExecutableScope
gmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ExecutableScope -> m ExecutableScope
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ExecutableScope -> m ExecutableScope
gmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ExecutableScope -> m ExecutableScope
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ExecutableScope -> m ExecutableScope
gmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ExecutableScope -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ExecutableScope -> u
gmapQ :: forall u. (forall d. Data d => d -> u) -> ExecutableScope -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ExecutableScope -> [u]
gmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ExecutableScope -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> ExecutableScope -> r
gmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ExecutableScope -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> ExecutableScope -> r
gmapT :: (forall b. Data b => b -> b) -> ExecutableScope -> ExecutableScope
$cgmapT :: (forall b. Data b => b -> b) -> ExecutableScope -> ExecutableScope
dataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ExecutableScope)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ExecutableScope)
dataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ExecutableScope)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c ExecutableScope)
dataTypeOf :: ExecutableScope -> DataType
$cdataTypeOf :: ExecutableScope -> DataType
toConstr :: ExecutableScope -> Constr
$ctoConstr :: ExecutableScope -> Constr
gunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExecutableScope
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c ExecutableScope
gfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExecutableScope -> c ExecutableScope
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExecutableScope -> c ExecutableScope
Data)

instance Pretty ExecutableScope where
    pretty :: ExecutableScope -> Doc
pretty ExecutableScope
ExecutablePublic       = String -> Doc
Disp.text String
"public"
    pretty ExecutableScope
ExecutablePrivate      = String -> Doc
Disp.text String
"private"

instance Parsec ExecutableScope where
    parsec :: forall (m :: * -> *). CabalParsing m => m ExecutableScope
parsec = forall (m :: * -> *) a. Parsing m => m a -> m a
P.try m ExecutableScope
pub forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> m ExecutableScope
pri where
        pub :: m ExecutableScope
pub = ExecutableScope
ExecutablePublic  forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). CharParsing m => String -> m String
P.string String
"public"
        pri :: m ExecutableScope
pri = ExecutableScope
ExecutablePrivate forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (m :: * -> *). CharParsing m => String -> m String
P.string String
"private"

instance Binary ExecutableScope
instance Structured ExecutableScope
instance NFData ExecutableScope where rnf :: ExecutableScope -> ()
rnf = forall a. (Generic a, GNFData (Rep a)) => a -> ()
genericRnf

-- | 'Any' like semigroup, where 'ExecutablePrivate' is 'Any True'
instance Semigroup ExecutableScope where
    ExecutableScope
ExecutablePublic    <> :: ExecutableScope -> ExecutableScope -> ExecutableScope
<> ExecutableScope
x = ExecutableScope
x
    x :: ExecutableScope
x@ExecutableScope
ExecutablePrivate <> ExecutableScope
_ = ExecutableScope
x

-- | 'mempty' = 'ExecutablePublic'
instance Monoid ExecutableScope where
    mempty :: ExecutableScope
mempty = ExecutableScope
ExecutablePublic
    mappend :: ExecutableScope -> ExecutableScope -> ExecutableScope
mappend = forall a. Semigroup a => a -> a -> a
(<>)