1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE DeriveGeneric #-}
3 {-# LANGUAGE OverloadedStrings #-}
5 module Distribution
.Types
.LibraryVisibility
6 ( LibraryVisibility
(..)
9 import Distribution
.Compat
.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
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
34 name
<- P
.munch1
isAlpha
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