@@ -63,6 +63,7 @@ import Data.Traversable (for)
6363import Data.Version (showVersion)
6464import Data.Aeson (encode, decode)
6565import qualified Data.ByteString.Lazy as B
66+import qualified Data.ByteString.UTF8 as BU8
6667import qualified Data.Set as S
6768import qualified Data.Map as M
6869
@@ -70,6 +71,7 @@ import System.Directory
7071 (doesFileExist, getModificationTime, createDirectoryIfMissing)
7172import System.FilePath ((</>), takeDirectory)
7273import System.IO.Error (tryIOError)
74+import System.IO.UTF8 (readUTF8File, writeUTF8File)
7375
7476import Language.PureScript.Crash
7577import Language.PureScript.AST
@@ -123,7 +125,7 @@ data MakeActions m = MakeActions {
123125 -- |
124126 -- Read the externs file for a module as a string and also return the actual
125127 -- path for the file.
126− , readExterns :: ModuleName -> m (FilePath, B.ByteString)
128+ , readExterns :: ModuleName -> m (FilePath, Externs)
127129 -- |
128130 -- Run the code generator for the module and write any required output files.
129131 --
@@ -137,7 +139,7 @@ data MakeActions m = MakeActions {
137139-- |
138140-- Generated code for an externs file.
139141--
140−type Externs = B.ByteString
142+type Externs = String
141143
142144-- |
143145-- Determines when to rebuild a module
@@ -231,7 +233,7 @@ make MakeActions{..} ms = do
231233 corefn = CF.moduleToCoreFn env' mod'
232234 [renamed] = renameInModules [corefn]
233235 exts = moduleToExternsFile mod' env'
234− evalSupplyT nextVar $ codegen renamed env' $ encode exts
236+ evalSupplyT nextVar . codegen renamed env' . BU8.toString . B.toStrict . encode $ exts
235237 return exts
236238 markComplete (Just (warnings, exts)) Nothing
237239
@@ -258,9 +260,9 @@ make MakeActions{..} ms = do
258260 shouldExist (Just t) = t
259261 shouldExist _ = internalError "make: dependency should already have been built."
260262
261− decodeExterns :: B.ByteString -> Maybe ExternsFile
263+ decodeExterns :: Externs -> Maybe ExternsFile
262264 decodeExterns bs = do
263− externs <- decode bs
265+ externs <- decode (fromString bs)
264266 guard $ efVersion externs == showVersion Paths.version
265267 return externs
266268
@@ -335,7 +337,7 @@ buildMakeActions outputDir filePathMap foreigns usePrefix =
335337 externsFile = outputDir </> filePath </> "externs.json"
336338 min <$> getTimestamp jsFile <*> getTimestamp externsFile
337339
338− readExterns :: ModuleName -> Make (FilePath, B.ByteString)
340+ readExterns :: ModuleName -> Make (FilePath, Externs)
339341 readExterns mn = do
340342 let path = outputDir </> runModuleName mn </> "externs.json"
341343 (path, ) <$> readTextFile path
@@ -371,13 +373,13 @@ buildMakeActions outputDir filePathMap foreigns usePrefix =
371373 exists <- doesFileExist path
372374 traverse (const $ getModificationTime path) $ guard exists
373375
374− readTextFile :: FilePath -> Make B.ByteString
375− readTextFile path = makeIO (const (ErrorMessage [] $ CannotReadFile path)) $ B.readFile path
376+ readTextFile :: FilePath -> Make String
377+ readTextFile path = makeIO (const (ErrorMessage [] $ CannotReadFile path)) $ readUTF8File path
376378
377− writeTextFile :: FilePath -> B.ByteString -> Make ()
379+ writeTextFile :: FilePath -> String -> Make ()
378380 writeTextFile path text = makeIO (const (ErrorMessage [] $ CannotWriteFile path)) $ do
379381 mkdirp path
380− B.writeFile path text
382+ writeUTF8File path text
381383 where
382384 mkdirp :: FilePath -> IO ()
383385 mkdirp = createDirectoryIfMissing True . takeDirectory