{-# 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
$cto :: forall x. Rep ExecutableScope x -> ExecutableScope
$cfrom :: forall x. ExecutableScope -> Rep ExecutableScope x
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
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]
(Int -> ReadS ExecutableScope)
-> ReadS [ExecutableScope]
-> ReadPrec ExecutableScope
-> ReadPrec [ExecutableScope]
-> Read 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
(ExecutableScope -> ExecutableScope -> Bool)
-> (ExecutableScope -> ExecutableScope -> Bool)
-> Eq ExecutableScope
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
DataType
Constr
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 -> DataType
ExecutableScope -> Constr
(forall b. Data b => b -> b) -> ExecutableScope -> ExecutableScope
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> ExecutableScope -> c ExecutableScope
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c 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)
$cExecutablePrivate :: Constr
$cExecutablePublic :: Constr
$tExecutableScope :: DataType
gmapMo :: (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 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 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 :: Int -> (forall d. Data d => d -> u) -> ExecutableScope -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> ExecutableScope -> u
gmapQ :: (forall d. Data d => d -> u) -> ExecutableScope -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> ExecutableScope -> [u]
gmapQr :: (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 :: (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 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 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 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 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
$cp1Data :: Typeable 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 :: m ExecutableScope
parsec = m ExecutableScope -> m ExecutableScope
forall (m :: * -> *) a. Parsing m => m a -> m a
P.try m ExecutableScope
pub m ExecutableScope -> m ExecutableScope -> m ExecutableScope
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 (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 (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
(<>)