FileManip: migrated to extenible-exceptions
This commit is contained in:
parent
dbdcbd17b1
commit
3d3da401b8
5 changed files with 53 additions and 5 deletions
42
System/FilePath/Error.hs
Normal file
42
System/FilePath/Error.hs
Normal file
|
@ -0,0 +1,42 @@
|
|||
{-# LANGUAGE FlexibleInstances, TypeSynonymInstances #-}
|
||||
|
||||
-- |
|
||||
-- Module: System.FilePath.Manip
|
||||
-- Copyright: Sergei Trofimovich
|
||||
-- License: BSD3
|
||||
-- Maintainer: Bryan O'Sullivan <bos@serpentine.com>
|
||||
-- Stability: unstable
|
||||
-- Portability: Unix-like systems (requires flexible instances)
|
||||
|
||||
module System.FilePath.Error
|
||||
(
|
||||
bracket
|
||||
, bracket_
|
||||
, catch
|
||||
, handle
|
||||
, throwIO
|
||||
, Exception
|
||||
) where
|
||||
|
||||
import qualified Control.Exception.Extensible as EE
|
||||
import Prelude hiding (catch)
|
||||
|
||||
-- we can catch any exceptions if we need to
|
||||
-- type Exception = SomeException
|
||||
type Exception = EE.IOException
|
||||
|
||||
-- we just pin down 'EE.Exception e' to local Exception
|
||||
bracket :: IO a -> (a -> IO b) -> (a -> IO c) -> IO c
|
||||
bracket = EE.bracket
|
||||
|
||||
bracket_ :: IO a -> IO b -> IO c -> IO c
|
||||
bracket_ = EE.bracket_
|
||||
|
||||
catch :: IO a -> (Exception -> IO a) -> IO a
|
||||
catch = EE.catch
|
||||
|
||||
handle :: (Exception -> IO a) -> IO a -> IO a
|
||||
handle = EE.handle
|
||||
|
||||
throwIO :: (EE.Exception e) => e -> IO a
|
||||
throwIO = EE.throwIO
|
|
@ -119,7 +119,7 @@ import System.FilePath ((</>), takeDirectory, takeExtension, takeFileName)
|
|||
import System.FilePath.GlobPattern (GlobPattern, (~~), (/~))
|
||||
import System.IO (hPutStrLn, stderr)
|
||||
import System.IO.Unsafe (unsafeInterleaveIO, unsafePerformIO)
|
||||
import qualified Control.Exception as E
|
||||
import qualified System.FilePath.Error as E
|
||||
import qualified System.Posix.Files as F
|
||||
import qualified System.Posix.Types as T
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ module System.FilePath.Glob (
|
|||
namesMatching
|
||||
) where
|
||||
|
||||
import Control.Exception (handle)
|
||||
import Control.Monad (forM)
|
||||
import System.FilePath.GlobPattern ((~~))
|
||||
import System.Directory (doesDirectoryExist, doesFileExist,
|
||||
|
@ -18,6 +17,8 @@ import System.Directory (doesDirectoryExist, doesFileExist,
|
|||
import System.FilePath (dropTrailingPathSeparator, splitFileName, (</>))
|
||||
import System.IO.Unsafe (unsafeInterleaveIO)
|
||||
|
||||
import System.FilePath.Error (handle)
|
||||
|
||||
-- | Return a list of names matching a glob pattern. The list is
|
||||
-- generated lazily.
|
||||
namesMatching :: String -> IO [FilePath]
|
||||
|
|
|
@ -16,7 +16,8 @@ module System.FilePath.Manip (
|
|||
, modifyInPlace
|
||||
) where
|
||||
|
||||
import Control.Exception (bracket, bracket_, handle, throwIO)
|
||||
import System.FilePath.Error (bracket, bracket_, handle, throwIO)
|
||||
|
||||
import Control.Monad (liftM)
|
||||
import Data.Bits ((.&.))
|
||||
import System.Directory (removeFile)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue