From d8b0b99edf73aad7e0039c38f4ef9c5d27f398e0 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Tue, 10 May 2016 00:13:14 +0200 Subject: [PATCH] HPath.IO.Errors: provide all exception constructor checkers --- src/HPath/IO/Errors.hs | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/HPath/IO/Errors.hs b/src/HPath/IO/Errors.hs index 8ee1f73..770884f 100644 --- a/src/HPath/IO/Errors.hs +++ b/src/HPath/IO/Errors.hs @@ -98,25 +98,17 @@ instance Show HPathIOException where instance Exception HPathIOException +isFileDoesNotExist, isDirDoesNotExist, isSameFile, isDestinationInSource, isFileDoesExist, isDirDoesExist, isInvalidOperation, isCan'tOpenDirectory, isCopyFailed :: HPathIOException -> Bool +isFileDoesNotExist ex = toConstr (ex :: HPathIOException) == toConstr FileDoesNotExist{} +isDirDoesNotExist ex = toConstr (ex :: HPathIOException) == toConstr DirDoesNotExist{} +isSameFile ex = toConstr (ex :: HPathIOException) == toConstr SameFile{} +isDestinationInSource ex = toConstr (ex :: HPathIOException) == toConstr DestinationInSource{} +isFileDoesExist ex = toConstr (ex :: HPathIOException) == toConstr FileDoesExist{} +isDirDoesExist ex = toConstr (ex :: HPathIOException) == toConstr DirDoesExist{} +isInvalidOperation ex = toConstr (ex :: HPathIOException) == toConstr InvalidOperation{} +isCan'tOpenDirectory ex = toConstr (ex :: HPathIOException) == toConstr Can'tOpenDirectory{} +isCopyFailed ex = toConstr (ex :: HPathIOException) == toConstr CopyFailed{} -isDestinationInSource :: HPathIOException -> Bool -isDestinationInSource (DestinationInSource _ _) = True -isDestinationInSource _ = False - - -isSameFile :: HPathIOException -> Bool -isSameFile (SameFile _ _) = True -isSameFile _ = False - - -isFileDoesExist :: HPathIOException -> Bool -isFileDoesExist (FileDoesExist _) = True -isFileDoesExist _ = False - - -isDirDoesExist :: HPathIOException -> Bool -isDirDoesExist (DirDoesExist _) = True -isDirDoesExist _ = False