From 17fcce4ca5bf1418d8f335e869d328e1913d3f95 Mon Sep 17 00:00:00 2001 From: Zubin Duggal Date: Tue, 16 May 2023 14:34:19 +0530 Subject: compiler: Remove instance 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. --- compiler/GHC/Iface/Binary.hs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'compiler/GHC/Iface/Binary.hs') diff --git a/compiler/GHC/Iface/Binary.hs b/compiler/GHC/Iface/Binary.hs index a1611fe263..815ee817e4 100644 --- a/compiler/GHC/Iface/Binary.hs +++ b/compiler/GHC/Iface/Binary.hs @@ -106,12 +106,12 @@ readBinIfaceHeader profile _name_cache checkHiWay traceBinIFace hi_path = do (unFixedLength $ binaryInterfaceMagic platform) (unFixedLength magic) -- Check the interface file version and profile tag. - check_ver <- get bh + check_ver <- map getSerialisedChar <$> get bh let our_ver = show hiVersion wantedGot "Version" our_ver check_ver text errorOnMismatch "mismatched interface file versions" our_ver check_ver - check_tag <- get bh + check_tag <- map getSerialisedChar <$> get bh let tag = profileBuildTag profile wantedGot "Way" tag check_tag text when (checkHiWay == CheckHiWay) $ @@ -179,8 +179,8 @@ writeBinIface profile traceBinIface hi_path mod_iface = do put_ bh (binaryInterfaceMagic platform) -- The version, profile tag, and source hash go next - put_ bh (show hiVersion) - let tag = profileBuildTag profile + put_ bh (map SerialisableChar $ show hiVersion) + let tag = map SerialisableChar $ profileBuildTag profile put_ bh tag put_ bh (mi_src_hash mod_iface) -- cgit v1.2.1