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
Ben wrote:
this throws a permission denied exception, presumably because the file
is still open when the removeFile is called.
Yes. The file handle opened by encodeFile won't be closed until its
finalizer is run. There is no guarantee that the finalizer will be run
immediately. In fact, you
On Sun, 2008-04-20 at 14:02 -0700, Ben wrote:
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
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
On Sun, 2008-04-20 at 14:24 -0700, Bryan O'Sullivan wrote:
Doh! For all that I wrote about encodeFile, substitute decodeFile.
Indeed the version of encodeFile you wrote should be exactly identical
to the original because the lazy bytestring writeFile already uses
bracket like that:
writeFile
FWIW, installed bytestring-0.9.1.0, ran ghc-pkg hide
bytestring-0.9.0.1, recompiled and reinstalled binary-0.4.1. then i
played around with all that you suggested, and came to the conclusion
that i don't understand seq!
import Control.Exception (bracket)
import System.Directory
import System.IO
Am Montag, 21. April 2008 01:35 schrieb Ben:
FWIW, installed bytestring-0.9.1.0, ran ghc-pkg hide
bytestring-0.9.0.1, recompiled and reinstalled binary-0.4.1. then i
played around with all that you suggested, and came to the conclusion
that i don't understand seq!
import Control.Exception
one more piece of email pollution:
import Control.Exception (bracket)
import System.IO
import Data.Binary
import qualified Data.ByteString.Lazy as B
strictDecodeFile :: Binary a = FilePath - IO a
strictDecodeFile path =
bracket (openBinaryFile path ReadMode) hClose $ \h - do
c -
Am Montag, 21. April 2008 02:34 schrieb Daniel Fischer:
This means that force (decode c) is reduced to head normal form, not fully
evaluated.
Ooops, _weak_ head normal form, of course.
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
Ben wrote:
i played around with all that you suggested, and came to the conclusion
that i don't understand seq!
That's certainly possible, but you also got the type of your first
forcing function wrong :-)
strictDecodeFile :: Binary a = FilePath - (a - b) - IO ()
encodeFile fname dat
10 matches
Mail list logo