@@ -15,16 +15,14 @@ import Language.Drasil.GOOL (AuxiliarySym(..), package,
1515 unPP , unJP , unCSP , unCPPP , unSP , unJLP )
1616import qualified Language.Drasil.GOOL as D (filePath , FileAndContents (.. ))
1717
18- import Utils.Drasil (createDirIfMissing )
18+ import Utils.Drasil (createDirIfMissing , createFile )
1919
2020import Text.PrettyPrint.HughesPJ (render )
2121import Control.Monad.State (evalState , runState )
2222import Control.Lens ((^.) )
2323import Data.Functor ((<&>) )
2424import Data.Foldable (traverse_ )
2525import System.Directory (setCurrentDirectory , getCurrentDirectory )
26- import System.FilePath.Posix (takeDirectory )
27- import System.IO (hClose , hPutStrLn , openFile , IOMode (WriteMode ))
2826import Prelude hiding (return ,print ,log ,exp ,sin ,cos ,tan )
2927
3028import HelloWorld (helloWorldOO , helloWorldProc )
@@ -104,17 +102,6 @@ jlClasses unRepr unRepr' = zipWith
104102
105103-- | Creates the requested 'Code' by producing files.
106104createCodeFiles :: [(Label , D. FileAndContents )] -> IO ()
107- createCodeFiles = traverse_ createCodeFile
108-
109- -- | Helper that creates the file and renders code.
110- createCodeFile :: (Label , D. FileAndContents ) -> IO ()
111- createCodeFile (n, file) = do
112- let path = D. filePath file
113- code = D. fileDoc file
114- createDirIfMissing False n
115- setCurrentDirectory n
116- createDirIfMissing True (takeDirectory path)
117- h <- openFile path WriteMode
118- hPutStrLn h (render code)
119- hClose h
120- setCurrentDirectory " .."
105+ createCodeFiles = traverse_ $ \ (name, file) -> do
106+ let path = name ++ " /" ++ D. filePath file
107+ createFile path (render $ D. fileDoc file)
0 commit comments