{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Types.LibraryVisibility(
LibraryVisibility(..),
) where
import Distribution.Compat.Prelude
import Prelude ()
import Distribution.Parsec
import Distribution.Pretty
import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint as Disp
data LibraryVisibility
= LibraryVisibilityPublic
| LibraryVisibilityPrivate
deriving (Generic, Show, Read, Eq, Typeable, Data)
instance Pretty LibraryVisibility where
pretty LibraryVisibilityPublic = Disp.text "public"
pretty LibraryVisibilityPrivate = Disp.text "private"
instance Parsec LibraryVisibility where
parsec = do
name <- P.munch1 isAlpha
case name of
"public" -> return LibraryVisibilityPublic
"private" -> return LibraryVisibilityPrivate
_ -> fail $ "Unknown visibility: " ++ name
instance Binary LibraryVisibility
instance NFData LibraryVisibility where rnf = genericRnf
instance Semigroup LibraryVisibility where
LibraryVisibilityPrivate <> LibraryVisibilityPrivate = LibraryVisibilityPrivate
_ <> _ = LibraryVisibilityPublic
instance Monoid LibraryVisibility where
mempty = LibraryVisibilityPrivate
mappend = (<>)