From a2626e24dd9e468ee0c5ccd455e4a5f782d56522 Mon Sep 17 00:00:00 2001 From: "kr.angelov" Date: Tue, 15 Nov 2011 19:12:22 +0000 Subject: now we store version number in every .gfo file. If the file is compiled with different compiler then we simply recompile it. --- src/runtime/haskell/Data/Binary.hs | 11 +++++++++++ src/runtime/haskell/PGF/Binary.hs | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/runtime') diff --git a/src/runtime/haskell/Data/Binary.hs b/src/runtime/haskell/Data/Binary.hs index ab6fcc2a3..2bebaf148 100644 --- a/src/runtime/haskell/Data/Binary.hs +++ b/src/runtime/haskell/Data/Binary.hs @@ -48,6 +48,9 @@ module Data.Binary ( , encodeFile -- :: Binary a => FilePath -> a -> IO () , decodeFile -- :: Binary a => FilePath -> IO a + , encodeFile_ -- :: FilePath -> Put -> IO () + , decodeFile_ -- :: FilePath -> Get a -> IO a + -- Lazy put and get -- , lazyPut -- , lazyGet @@ -254,6 +257,9 @@ decode = runGet get encodeFile :: Binary a => FilePath -> a -> IO () encodeFile f v = L.writeFile f (encode v) +encodeFile_ :: FilePath -> Put -> IO () +encodeFile_ f m = L.writeFile f (runPut m) + -- | Lazily reconstruct a value previously written to a file. -- -- This is just a convenience function, it's defined simply as: @@ -269,6 +275,11 @@ decodeFile f = bracket (openBinaryFile f ReadMode) hClose $ \h -> do s <- L.hGetContents h evaluate $ runGet get s +decodeFile_ :: FilePath -> Get a -> IO a +decodeFile_ f m = bracket (openBinaryFile f ReadMode) hClose $ \h -> do + s <- L.hGetContents h + evaluate $ runGet m s + -- needs bytestring 0.9.1.x to work ------------------------------------------------------------------------ diff --git a/src/runtime/haskell/PGF/Binary.hs b/src/runtime/haskell/PGF/Binary.hs index 32b751159..22a6ef464 100644 --- a/src/runtime/haskell/PGF/Binary.hs +++ b/src/runtime/haskell/PGF/Binary.hs @@ -200,4 +200,4 @@ getArray2 = do n <- get -- read the length xs <- replicateM n getArray -- now the elems. return (listArray (0,n-1) xs) -decodingError = fail "This PGF file was compiled with different version of GF" +decodingError = fail "This file was compiled with different version of GF" -- cgit v1.2.3