@@ -0,0 +1,29 @@
2+module Util.System(tempfile,environment) where
4+-- System helper functions.
6+import System.Environment
8+#if MIN_VERSION_base(4,0,0)
9+import Control.Exception as CE
12+#if MIN_VERSION_base(4,0,0)
13+catchIO :: IO a -> (IOError -> IO a) -> IO a
19+tempfile :: IO (FilePath, Handle)
20+tempfile = do env <- environment "TMPDIR"
21+ let dir = case env of
24+ openTempFile dir "esc"
26+environment :: String -> IO (Maybe String)
27+environment x = catchIO (do e <- getEnv x
29+ (\_ -> return Nothing)