make LTS branch pre-releases
[cabal.git] / Cabal-syntax / src / Distribution / Types / ExecutableScope.hs
blob1221fae1c1a7b7908600924b41b8d99c4ac43e05
1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE DeriveGeneric #-}
3 {-# LANGUAGE OverloadedStrings #-}
5 module Distribution.Types.ExecutableScope
6 ( ExecutableScope (..)
7 ) where
9 import Distribution.Compat.Prelude
10 import Prelude ()
12 import Distribution.Parsec
13 import Distribution.Pretty
15 import qualified Distribution.Compat.CharParsing as P
16 import qualified Text.PrettyPrint as Disp
18 data ExecutableScope
19 = ExecutablePublic
20 | ExecutablePrivate
21 deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)
23 instance Pretty ExecutableScope where
24 pretty ExecutablePublic = Disp.text "public"
25 pretty ExecutablePrivate = Disp.text "private"
27 instance Parsec ExecutableScope where
28 parsec = P.try pub <|> pri
29 where
30 pub = ExecutablePublic <$ P.string "public"
31 pri = ExecutablePrivate <$ P.string "private"
33 instance Binary ExecutableScope
34 instance Structured ExecutableScope
35 instance NFData ExecutableScope where rnf = genericRnf
37 -- | 'Any' like semigroup, where 'ExecutablePrivate' is 'Any True'
38 instance Semigroup ExecutableScope where
39 ExecutablePublic <> x = x
40 x@ExecutablePrivate <> _ = x
42 -- | 'mempty' = 'ExecutablePublic'
43 instance Monoid ExecutableScope where
44 mempty = ExecutablePublic
45 mappend = (<>)