[Haskell-cafe] letting go of file handles and Data.Binary

Ben midfield at gmail.com
Sun Apr 20 17:02:27 EDT 2008


hi all --

using binary 0.4.1 on ghc 6.8.2, vista 64 sp1.  consider the following program:

import System.Directory
import Data.Binary

main = do
  let dat = [1..10]::[Int]
      fname = "foo.dat"
  encodeFile fname dat
  dat2 <- decodeFile fname
  print (dat == dat2)
  removeFile fname

this throws a permission denied exception, presumably because the file
is still open when the removeFile is called.  i've grovelled the
source of Data.Bytestring.Lazy and all but i can't seem to understand
the "right" way to make this work.  note that i've forced the
evaluation of dat2 and presumably therefore the filehandle is at least
half-closed.

any suggestions?

take care, Ben


More information about the Haskell-Cafe mailing list