{-# LANGUAGE CPP #-}
module Distribution.Compat.Exception (
  catchIO,
  catchExit,
  tryIO,
  displayException,
  ) where

import System.Exit
import qualified Control.Exception as Exception
#if __GLASGOW_HASKELL__ >= 710
import Control.Exception (displayException)
#endif

tryIO :: IO a -> IO (Either Exception.IOException a)
tryIO :: IO a -> IO (Either IOException a)
tryIO = IO a -> IO (Either IOException a)
forall e a. Exception e => IO a -> IO (Either e a)
Exception.try

catchIO :: IO a -> (Exception.IOException -> IO a) -> IO a
catchIO :: IO a -> (IOException -> IO a) -> IO a
catchIO = IO a -> (IOException -> IO a) -> IO a
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
Exception.catch

catchExit :: IO a -> (ExitCode -> IO a) -> IO a
catchExit :: IO a -> (ExitCode -> IO a) -> IO a
catchExit = IO a -> (ExitCode -> IO a) -> IO a
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
Exception.catch

#if __GLASGOW_HASKELL__ < 710
displayException :: Exception.Exception e => e -> String
displayException = show
#endif