-- | Defines the underlying data types used in the package extension.
module Language.Drasil.Code.Imperative.GOOL.Data (AuxData(auxFilePath, auxDoc),
  ad, PackData(packProg, packAux), packD
) where

import Drasil.GOOL (ProgData)

import Text.PrettyPrint.HughesPJ (Doc, isEmpty)

-- | The underlying data type for auxiliary files in all renderers.
data AuxData =  {AuxData -> FilePath
auxFilePath :: FilePath, AuxData -> Doc
auxDoc :: Doc}

-- | Constructor for auxiliary files.
ad :: FilePath -> Doc -> AuxData
 = FilePath -> Doc -> AuxData
AD

-- | The underlying data type for packages in all renderers.
data PackData = PackD {PackData -> ProgData
packProg :: ProgData, PackData -> [AuxData]
packAux :: [AuxData]}

-- | Constructor for package data.
packD :: ProgData -> [AuxData] -> PackData
packD :: ProgData -> [AuxData] -> PackData
packD ProgData
p [AuxData]
as = ProgData -> [AuxData] -> PackData
PackD ProgData
p ((AuxData -> Bool) -> [AuxData] -> [AuxData]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool) -> (AuxData -> Bool) -> AuxData -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Doc -> Bool
isEmpty (Doc -> Bool) -> (AuxData -> Doc) -> AuxData -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AuxData -> Doc
auxDoc) [AuxData]
as)