module CabalLenses.Section
( Section(..)
, allSections
) where
import Distribution.PackageDescription (GenericPackageDescription(..))
import Distribution.Types.UnqualComponentName (unUnqualComponentName)
type Name = String
data Section = Library
| Executable Name
| TestSuite Name
| Benchmark Name
deriving (Show, Eq)
allSections :: GenericPackageDescription -> [Section]
allSections pkgDescr =
concat [ maybe [] (const [Library]) (condLibrary pkgDescr)
, map (Executable . unUnqualComponentName . fst) (condExecutables pkgDescr)
, map (TestSuite . unUnqualComponentName . fst) (condTestSuites pkgDescr)
, map (Benchmark . unUnqualComponentName . fst) (condBenchmarks pkgDescr)
]