Commit 2b4320f3 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Define bracketOnError in compat; fixes the build for GHC 6.4

parent 6696ad57
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -cpp #-}
{-# OPTIONS_NHC98 -cpp #-}
{-# OPTIONS_JHC -fcpp #-}
-- #hide
module Distribution.Compat.Exception (bracketOnError) where
import Control.Exception as Exception
#if defined(__GLASGOW_HASKELL__) && (__GLASGOW_HASKELL__ < 606)
bracketOnError
:: IO a -- ^ computation to run first (\"acquire resource\")
-> (a -> IO b) -- ^ computation to run last (\"release resource\")
-> (a -> IO c) -- ^ computation to run in-between
-> IO c -- returns the value from the in-between computation
bracketOnError before after thing =
Exception.block (do
a <- before
Exception.catch
(Exception.unblock (thing a))
(\e -> do { after a; Exception.throw e }))
#endif
......@@ -135,7 +135,7 @@ import System.IO
import System.IO.Error as IO.Error
( try )
import qualified Control.Exception as Exception
( bracket, bracket_, bracketOnError, catch, finally )
( bracket, bracket_, catch, finally )
import Distribution.Text
( display )
......@@ -157,6 +157,7 @@ import qualified Control.Exception as Exception
( throwIO )
#endif
import Distribution.Compat.Exception as Exception (bracketOnError)
import Distribution.Compat.TempFile (openTempFile, openBinaryTempFile)
import Distribution.Verbosity
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment