make LTS branch pre-releases
[cabal.git] / Cabal-syntax / src / Distribution / Types / LibraryVisibility.hs
blobbf113488a5ca40c3a0daf9736f9ba47866a61561
1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE DeriveGeneric #-}
3 {-# LANGUAGE OverloadedStrings #-}
5 module Distribution.Types.LibraryVisibility
6 ( LibraryVisibility (..)
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 -- | Multi-lib visibility
20 -- @since 3.0.0.0
21 data LibraryVisibility
22 = -- | Can be used as a dependency for other packages
23 LibraryVisibilityPublic
24 | -- | Internal library, default
25 LibraryVisibilityPrivate
26 deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)
28 instance Pretty LibraryVisibility where
29 pretty LibraryVisibilityPublic = Disp.text "public"
30 pretty LibraryVisibilityPrivate = Disp.text "private"
32 instance Parsec LibraryVisibility where
33 parsec = do
34 name <- P.munch1 isAlpha
35 case name of
36 "public" -> return LibraryVisibilityPublic
37 "private" -> return LibraryVisibilityPrivate
38 _ -> fail $ "Unknown visibility: " ++ name
40 instance Binary LibraryVisibility
41 instance Structured LibraryVisibility
42 instance NFData LibraryVisibility where rnf = genericRnf
44 instance Semigroup LibraryVisibility where
45 LibraryVisibilityPrivate <> LibraryVisibilityPrivate = LibraryVisibilityPrivate
46 _ <> _ = LibraryVisibilityPublic
48 instance Monoid LibraryVisibility where
49 mempty = LibraryVisibilityPrivate
50 mappend = (<>)