summaryrefslogtreecommitdiff
path: root/src/Data/Binary.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/Binary.hs')
-rw-r--r--src/Data/Binary.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Data/Binary.hs b/src/Data/Binary.hs
index 1b287a099..786f5a09e 100644
--- a/src/Data/Binary.hs
+++ b/src/Data/Binary.hs
@@ -734,9 +734,13 @@ instance (Binary e) => Binary (IntMap.IntMap e) where
--
instance (Binary e) => Binary (Seq.Seq e) where
- -- any better way to do this?
- put = put . Fold.toList
- get = fmap Seq.fromList get
+ put s = put (Seq.length s) >> Fold.mapM_ put s
+ get = do n <- get :: Get Int
+ rep Seq.empty n get
+ where rep xs 0 _ = return $! xs
+ rep xs n g = xs `seq` n `seq` do
+ x <- g
+ rep (xs Seq.|> x) (n-1) g
#endif