{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Types.Library (
Library(..),
emptyLibrary,
explicitLibModules,
libModulesAutogen,
libModules,
) where
import Prelude ()
import Distribution.Compat.Prelude
import Distribution.Types.BuildInfo
import Distribution.Types.ModuleReexport
import Distribution.Types.UnqualComponentName
import Distribution.ModuleName
data Library = Library {
libName :: Maybe UnqualComponentName,
exposedModules :: [ModuleName],
reexportedModules :: [ModuleReexport],
signatures:: [ModuleName],
libExposed :: Bool,
libBuildInfo :: BuildInfo
}
deriving (Generic, Show, Eq, Read, Typeable, Data)
instance Binary Library
instance Monoid Library where
mempty = Library {
libName = mempty,
exposedModules = mempty,
reexportedModules = mempty,
signatures = mempty,
libExposed = True,
libBuildInfo = mempty
}
mappend = (<>)
instance Semigroup Library where
a <> b = Library {
libName = combine libName,
exposedModules = combine exposedModules,
reexportedModules = combine reexportedModules,
signatures = combine signatures,
libExposed = libExposed a && libExposed b,
libBuildInfo = combine libBuildInfo
}
where combine field = field a `mappend` field b
emptyLibrary :: Library
emptyLibrary = mempty
explicitLibModules :: Library -> [ModuleName]
explicitLibModules lib = exposedModules lib
++ otherModules (libBuildInfo lib)
++ signatures lib
libModulesAutogen :: Library -> [ModuleName]
libModulesAutogen lib = autogenModules (libBuildInfo lib)
{-# DEPRECATED libModules "If you want all modules that are built with a library, use 'allLibModules'. Otherwise, use 'explicitLibModules' for ONLY the modules explicitly mentioned in the package description." #-}
libModules :: Library -> [ModuleName]
libModules = explicitLibModules