diff options
| author | kr.angelov <kr.angelov@gmail.com> | 2011-11-15 19:12:22 +0000 |
|---|---|---|
| committer | kr.angelov <kr.angelov@gmail.com> | 2011-11-15 19:12:22 +0000 |
| commit | a2626e24dd9e468ee0c5ccd455e4a5f782d56522 (patch) | |
| tree | c222b77a1b7ccba40b3bd244ae00f1945eb3a3c8 /src/runtime/haskell/Data/Binary.hs | |
| parent | 8a10aa5cf969caf482a7e852562caad815d74672 (diff) | |
now we store version number in every .gfo file. If the file is compiled with different compiler then we simply recompile it.
Diffstat (limited to 'src/runtime/haskell/Data/Binary.hs')
| -rw-r--r-- | src/runtime/haskell/Data/Binary.hs | 11 |
1 files changed, 11 insertions, 0 deletions
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 ------------------------------------------------------------------------ |
