{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleContexts #-}
module Utils.Drasil.FileData (FileAndContents(filePath, fileDoc),
fileAndContents, hasPathAndDocToFileAndContents) where
import Text.PrettyPrint.HughesPJ (Doc)
import Utils.Drasil.TypeClasses (HasPathAndDoc(..))
data FileAndContents = FileAndContents {FileAndContents -> FilePath
filePath :: FilePath, FileAndContents -> Doc
fileDoc :: Doc}
fileAndContents :: FilePath -> Doc -> FileAndContents
fileAndContents :: FilePath -> Doc -> FileAndContents
fileAndContents = FilePath -> Doc -> FileAndContents
FileAndContents
instance HasPathAndDoc FileAndContents Doc where
getPath :: FileAndContents -> FilePath
getPath = FileAndContents -> FilePath
filePath
getDoc :: FileAndContents -> Doc
getDoc = FileAndContents -> Doc
fileDoc
hasPathAndDocToFileAndContents :: (HasPathAndDoc a Doc) => a -> FileAndContents
hasPathAndDocToFileAndContents :: forall a. HasPathAndDoc a Doc => a -> FileAndContents
hasPathAndDocToFileAndContents a
file = FilePath -> Doc -> FileAndContents
fileAndContents (a -> FilePath
forall a b. HasPathAndDoc a b => a -> FilePath
getPath a
file) (a -> Doc
forall a b. HasPathAndDoc a b => a -> b
getDoc a
file)