Doh!  For all that I wrote about encodeFile, substitute decodeFile.
You'll need to write something to force the value that you're decoding.
 Something like this ought to do the trick.

import Data.Binary (Binary, decode)
import Control.Exception (bracket)
import qualified Data.ByteString.Lazy as L
import System.IO (IOMode(..), hClose, openFile)

strictDecodeFile :: Binary a => FilePath -> (a -> b) -> IO ()
strictDecodeFile path force =
    bracket (openFile path ReadMode) hClose $ \h -> do
      c <- L.hGetContents h
      force (decode c) `seq` return ()

        <b
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to