summaryrefslogtreecommitdiff
path: root/compiler/utils/Serialized.hs
diff options
context:
space:
mode:
author'Jose Pedro Magalhaes <jpm@cs.uu.nl>2009-01-19 11:23:21 +0000
committer'Jose Pedro Magalhaes <jpm@cs.uu.nl>2009-01-19 11:23:21 +0000
commit09dc0da9b6ac28a80bb0e0e8caa4f5c0c1b6bf0c (patch)
tree760c78ec7345ec2782a6599c71a9e81850ad0f88 /compiler/utils/Serialized.hs
parentfa1e4ffe87bc607e95a1e82c160ff1e821d28b6e (diff)
downloadhaskell-09dc0da9b6ac28a80bb0e0e8caa4f5c0c1b6bf0c.tar.gz
#2875: Correct SYB's representation of Char
Diffstat (limited to 'compiler/utils/Serialized.hs')
-rw-r--r--compiler/utils/Serialized.hs18
1 files changed, 18 insertions, 0 deletions
diff --git a/compiler/utils/Serialized.hs b/compiler/utils/Serialized.hs
index 82cc065aa9..06b92e4aa1 100644
--- a/compiler/utils/Serialized.hs
+++ b/compiler/utils/Serialized.hs
@@ -87,7 +87,12 @@ serializeConstr :: ConstrRep -> [Word8] -> [Word8]
serializeConstr (AlgConstr ix) = serializeWord8 1 . serializeInt ix
serializeConstr (IntConstr i) = serializeWord8 2 . serializeInteger i
serializeConstr (FloatConstr r) = serializeWord8 3 . serializeRational r
+#if __GLASGOW_HASKELL__ < 611
serializeConstr (StringConstr s) = serializeWord8 4 . serializeString s
+#else
+serializeConstr (CharConstr c) = serializeWord8 4 . serializeChar c
+#endif
+
deserializeConstr :: [Word8] -> (ConstrRep -> [Word8] -> a) -> a
deserializeConstr bytes k = deserializeWord8 bytes $ \constr_ix bytes ->
@@ -95,7 +100,11 @@ deserializeConstr bytes k = deserializeWord8 bytes $ \constr_ix bytes ->
1 -> deserializeInt bytes $ \ix -> k (AlgConstr ix)
2 -> deserializeInteger bytes $ \i -> k (IntConstr i)
3 -> deserializeRational bytes $ \r -> k (FloatConstr r)
+#if __GLASGOW_HASKELL__ >= 611
+ 4 -> deserializeChar bytes $ \c -> k (CharConstr c)
+#else
4 -> deserializeString bytes $ \s -> k (StringConstr s)
+#endif
x -> error $ "deserializeConstr: unrecognised serialized constructor type " ++ show x ++ " in context " ++ show bytes
@@ -154,6 +163,15 @@ deserializeInteger :: [Word8] -> (Integer -> [Word8] -> a) -> a
deserializeInteger bytes k = deserializeString bytes (k . read)
+#if __GLASGOW_HASKELL__ >= 611
+serializeChar :: Char -> [Word8] -> [Word8]
+serializeChar = serializeString . show
+
+deserializeChar :: [Word8] -> (Char -> [Word8] -> a) -> a
+deserializeChar bytes k = deserializeString bytes (k . read)
+#endif
+
+
serializeString :: String -> [Word8] -> [Word8]
serializeString = serializeList serializeEnum