summaryrefslogtreecommitdiff
path: root/compiler/hieFile
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/hieFile')
-rw-r--r--compiler/hieFile/HieBin.hs8
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/hieFile/HieBin.hs b/compiler/hieFile/HieBin.hs
index fa33936f40..2734a9fce9 100644
--- a/compiler/hieFile/HieBin.hs
+++ b/compiler/hieFile/HieBin.hs
@@ -22,7 +22,8 @@ import Data.IORef
import Data.List ( mapAccumR )
import Data.Word ( Word32 )
import Control.Monad ( replicateM )
-
+import System.Directory ( createDirectoryIfMissing )
+import System.FilePath ( takeDirectory )
-- | `Name`'s get converted into `HieName`'s before being written into @.hie@
-- files. See 'toHieName' and 'fromHieName' for logic on how to convert between
@@ -63,7 +64,7 @@ initBinMemSize :: Int
initBinMemSize = 1024*1024
writeHieFile :: Binary a => FilePath -> a -> IO ()
-writeHieFile filename hiefile = do
+writeHieFile hie_file_path hiefile = do
bh0 <- openBinMem initBinMemSize
-- remember where the dictionary pointer will go
@@ -115,7 +116,8 @@ writeHieFile filename hiefile = do
putDictionary bh dict_next dict_map
-- and send the result to the file
- writeBinMem bh filename
+ createDirectoryIfMissing True (takeDirectory hie_file_path)
+ writeBinMem bh hie_file_path
return ()
readHieFile :: Binary a => NameCache -> FilePath -> IO (a, NameCache)