-- | Defines the underlying data types used in the package extension.
module Language.Drasil.Code.FileData (FileAndContents(filePath,
  fileDoc), fileAndContents, PackageData(packageProg, packageAux), packageData
) where

import Text.PrettyPrint.HughesPJ (Doc, isEmpty)

-- | The underlying data type for auxiliary files in all renderers.
data FileAndContents = FileAndContents {FileAndContents -> FilePath
filePath :: FilePath, FileAndContents -> Doc
fileDoc :: Doc}

-- | Constructor for auxiliary files.
fileAndContents :: FilePath -> Doc -> FileAndContents
fileAndContents :: FilePath -> Doc -> FileAndContents
fileAndContents = FilePath -> Doc -> FileAndContents
FileAndContents

-- | The underlying data type for packages in all renderers.
data PackageData a = PackD {forall a. PackageData a -> a
packageProg :: a, forall a. PackageData a -> [FileAndContents]
packageAux :: [FileAndContents]}

-- | Constructor for package data.
packageData :: a -> [FileAndContents] -> PackageData a
packageData :: forall a. a -> [FileAndContents] -> PackageData a
packageData a
p [FileAndContents]
as = a -> [FileAndContents] -> PackageData a
forall a. a -> [FileAndContents] -> PackageData a
PackD a
p ((FileAndContents -> Bool) -> [FileAndContents] -> [FileAndContents]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (FileAndContents -> Bool) -> FileAndContents -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> Bool
isEmpty (Doc -> Bool)
-> (FileAndContents -> Doc) -> FileAndContents -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FileAndContents -> Doc
fileDoc) [FileAndContents]
as)