diff options
Diffstat (limited to 'Utils.hs')
-rw-r--r-- | Utils.hs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Utils.hs b/Utils.hs new file mode 100644 index 0000000..2ccf4f7 --- /dev/null +++ b/Utils.hs @@ -0,0 +1,16 @@ +module Utils where + +import Control.Exception +import Data.Monoid +import System.Directory +import System.IO + + +withTempFile :: FilePath -> String -> ((FilePath, Handle) -> IO a) -> IO a +withTempFile tmpdir template = + bracket (openTempFile tmpdir template) (removeFile . fst) + + +mintercalate :: Monoid b => b -> [b] -> b +mintercalate c (h:t) = foldl (\acc x -> acc <> c <> x) h t +mintercalate _ [] = mempty |