summaryrefslogtreecommitdiffstats
path: root/Utils.hs
blob: 2ccf4f7ddf2ebe9d80ba29d34b7f4f5227b647d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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