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

instance Binary ExecutableScope
instance Structured ExecutableScope
instance NFData ExecutableScope where rnf :: ExecutableScope -> ()
rnf = ExecutableScope -> ()
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 = ExecutableScope -> ExecutableScope -> ExecutableScope
forall a. Semigroup a => a -> a -> a
(<>)