diff options
| author | hallgren <hallgren@chalmers.se> | 2014-09-08 15:43:20 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2014-09-08 15:43:20 +0000 |
| commit | 4eb6b55e980fda9c4d260820f5a6d38dde3d0991 (patch) | |
| tree | c771181c860137fb7a5bec7eaf3f899292b00aae /src/compiler/GF/Grammar | |
| parent | 4d28c7632e83aed413c22001ec0821971f58f14d (diff) | |
(1) Refactor concurrency, (2) write to .gfo.tmp then rename to .gfo
(1) introduces the module GF.Infra.Concurreny with lifted concurrency
operators (to reduce uses of liftIO) and some additional concurrency
utilities, e.g. a function for sequential logging that is used in
both GF.CompileInParallel and GFServer.
(2) avoids leaving broken .gfo files behind if compilation is aborted.
Diffstat (limited to 'src/compiler/GF/Grammar')
| -rw-r--r-- | src/compiler/GF/Grammar/Binary.hs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/compiler/GF/Grammar/Binary.hs b/src/compiler/GF/Grammar/Binary.hs index ad9df8b92..1bdadabd6 100644 --- a/src/compiler/GF/Grammar/Binary.hs +++ b/src/compiler/GF/Grammar/Binary.hs @@ -21,6 +21,7 @@ import qualified Data.ByteString.Char8 as BS import GF.Data.Operations
import GF.Infra.Ident
import GF.Infra.Option
+import GF.Infra.UseIO(MonadIO(..))
import GF.Grammar.Grammar
import PGF() -- Binary instances
@@ -314,8 +315,8 @@ gfoBinVersion = (b1,b2,b3,b4) where [b1,b2,b3,b4] = map (toEnum.fromEnum) gfoVersion :: [Word8]
-decodeModule :: FilePath -> IO SourceModule
-decodeModule fpath = check =<< decodeFile' fpath
+decodeModule :: MonadIO io => FilePath -> io SourceModule
+decodeModule fpath = liftIO $ check =<< decodeFile' fpath
where
check (Tagged m) = return m
check _ = fail ".gfo file version mismatch"
@@ -336,8 +337,8 @@ decodeModuleHeader fpath = fmap check $ decodeFile' fpath (Just (m,ModInfo mtype mstatus mflags mextend mwith mopens med msrc Nothing Map.empty))
check _ = Nothing
--}
-encodeModule :: FilePath -> SourceModule -> IO ()
-encodeModule fpath mo = encodeFile fpath (Tagged mo)
+encodeModule :: MonadIO io => FilePath -> SourceModule -> io ()
+encodeModule fpath mo = liftIO $ encodeFile fpath (Tagged mo)
-- | like 'decodeFile' but adds file name to error message if there was an error
decodeFile' fpath = addFPath fpath (decodeFile fpath)
|
