@@ -217,6 +217,7 @@ mkDeserializeExpr True False headTy tyOfTy =
217mkDeserializeExpr False False headTy tyOfTy =
217mkDeserializeExpr False False headTy tyOfTy =
218 case tyOfTy of
218 case tyOfTy of
219 -- Unit constructor
219 -- Unit constructor
220+ -- XXX Should we peek and check if the byte value is 0?
220 UnitType cname ->
221 UnitType cname ->
221 [|pure ($(varE _initialOffset) + 1, $(conE cname))|]
222 [|pure ($(varE _initialOffset) + 1, $(conE cname))|]
222 -- Product type
223 -- Product type
@@ -341,7 +342,8 @@ mkSerializeExpr True False tyOfTy =
341mkSerializeExpr False False tyOfTy =
342mkSerializeExpr False False tyOfTy =
342 case tyOfTy of
343 case tyOfTy of
343 -- Unit type
344 -- Unit type
344− UnitType _ -> [|pure ($(varE _initialOffset) + 1)|]
346+ [|serializeAt $(varE _initialOffset) $(varE _arr) (0 :: Word8)|]
345 -- Product type
347 -- Product type
346 (TheType (SimpleDataCon cname fields)) ->
348 (TheType (SimpleDataCon cname fields)) ->
@@ -395,7 +397,7 @@ mkSerializeDec (SerializeConfig {..}) headTy cons = do
395 'serializeAt
397 'serializeAt
397 (if isUnitType cons && not cfgConstructorTagAsString
399 (if isUnitType cons && not cfgConstructorTagAsString
398− then [VarP _initialOffset, WildP, WildP]
400+ then [VarP _initialOffset, VarP _arr, WildP]
399 else [VarP _initialOffset, VarP _arr, VarP _val])
401 else [VarP _initialOffset, VarP _arr, VarP _val])
400 (NormalB pokeMethod)
402 (NormalB pokeMethod)