summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-06-24 12:21:09 +0000
committerkrasimir <krasimir@chalmers.se>2009-06-24 12:21:09 +0000
commitd965cf475562e6c61185e1cea4ee9fbdf45fdf21 (patch)
tree657dd16f91df49598cd2bd06c9bd786e2e9d41c8
parentf20dd0ba4a3a073cd82c27690afcd6b9d8c66bae (diff)
simplification: decodeFile doesn't have to check that the file is empty anymore
-rw-r--r--src/Data/Binary.hs10
1 files changed, 1 insertions, 9 deletions
diff --git a/src/Data/Binary.hs b/src/Data/Binary.hs
index 86353e143..1b287a099 100644
--- a/src/Data/Binary.hs
+++ b/src/Data/Binary.hs
@@ -264,18 +264,10 @@ encodeFile f v = L.writeFile f (encode v)
--
-- > return . decode . decompress =<< B.readFile f
--
--- After contructing the data from the input file, 'decodeFile' checks
--- if the file is empty, and in doing so will force the associated file
--- handle closed, if it is indeed empty. If the file is not empty,
--- it is up to the decoding instance to consume the rest of the data,
--- or otherwise finalise the resource.
---
decodeFile :: Binary a => FilePath -> IO a
decodeFile f = bracket (openBinaryFile f ReadMode) hClose $ \h -> do
s <- L.hGetContents h
- evaluate $ runGet (do v <- get
- m <- isEmpty
- m `seq` return v) s
+ evaluate $ runGet get s
-- needs bytestring 0.9.1.x to work