summaryrefslogtreecommitdiff
path: root/compiler/GHC/StgToJS
diff options
context:
space:
mode:
authorZubin Duggal <zubin.duggal@gmail.com>2023-05-16 14:34:19 +0530
committerZubin Duggal <zubin.duggal@gmail.com>2023-05-17 12:21:31 +0530
commit17fcce4ca5bf1418d8f335e869d328e1913d3f95 (patch)
tree18f5adee7cbcc938d4a1dd9b359659ca161c4661 /compiler/GHC/StgToJS
parent2972fd66f91cb51426a1df86b8166a067015e231 (diff)
downloadhaskell-wip/no-binary-char.tar.gz
compiler: Remove instance Binary Charwip/no-binary-char
It is generally not a good idea to serialise strings as [Char] into interface files, as upon deserialisation each of these would be turned into a highly memory inefficient structure mostly composed of cons cells and pointers. If you really want to serialise a Char, use the SerialisableChar newtype.
Diffstat (limited to 'compiler/GHC/StgToJS')
-rw-r--r--compiler/GHC/StgToJS/Object.hs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/GHC/StgToJS/Object.hs b/compiler/GHC/StgToJS/Object.hs
index be87945f3f..adbc8d8fdd 100644
--- a/compiler/GHC/StgToJS/Object.hs
+++ b/compiler/GHC/StgToJS/Object.hs
@@ -227,12 +227,12 @@ putObject
-> IO ()
putObject bh mod_name deps os = do
forM_ magic (putByte bh . fromIntegral . ord)
- put_ bh (show hiVersion)
+ put_ bh (map SerialisableChar $ show hiVersion)
-- we store the module name as a String because we don't want to have to
-- decode the FastString table just to decode it when we're looking for an
-- object in an archive.
- put_ bh (moduleNameString mod_name)
+ put_ bh (moduleNameFS mod_name)
(bh_fs, _bin_dict, put_dict) <- initFSTable bh
@@ -281,12 +281,12 @@ getObjectHeader bh = do
case is_magic of
False -> pure (Left "invalid magic header")
True -> do
- is_correct_version <- ((== hiVersion) . read) <$> get bh
+ is_correct_version <- ((== hiVersion) . read . map getSerialisedChar) <$> get bh
case is_correct_version of
False -> pure (Left "invalid header version")
True -> do
mod_name <- get bh
- pure (Right (mkModuleName (mod_name)))
+ pure (Right (mkModuleNameFS mod_name))
-- | Parse object body. Must be called after a sucessful getObjectHeader