From a91d70a90e354d569e00d93305dcda51b05eca16 Mon Sep 17 00:00:00 2001
From: Nikita Karetnikov <nikita@karetnikov.org>
Date: Mon, 8 Jul 2013 09:06:21 +0000
Subject: [PATCH 1/2] Replace 'TorDNSEL.Compat.Exception' with
 'Control.Exception'.

* src/TorDNSEL/Util.hsc (ignoreJust, syncExceptions, showException):
  Adjust to work with 'Control.Exception'.
---
 src/TorDNSEL/Util.hsc |   21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/TorDNSEL/Util.hsc b/src/TorDNSEL/Util.hsc
index 92c7ca3..5d38468 100644
--- a/src/TorDNSEL/Util.hsc
+++ b/src/TorDNSEL/Util.hsc
@@ -101,7 +101,7 @@ module TorDNSEL.Util (
   ) where
 
 import Control.Arrow ((&&&), first, second)
-import qualified TorDNSEL.Compat.Exception as E
+import qualified Control.Exception as E
 import Control.Monad.Error
   (Error(..), MonadError(..), MonadTrans(..), MonadIO(..))
 import qualified Control.Monad.State as State
@@ -328,13 +328,14 @@ split :: Int -> ByteString -> [ByteString]
 split x = takeWhile (not . B.null) . map (B.take x) . iterate (B.drop x)
 
 -- | Catch and discard exceptions matching the predicate.
-ignoreJust :: (E.Exception -> Maybe a) -> IO () -> IO ()
+ignoreJust :: (E.SomeException -> Maybe a) -> IO () -> IO ()
 ignoreJust p = E.handleJust p . const . return $ ()
 
 -- | A predicate matching synchronous exceptions.
-syncExceptions :: E.Exception -> Maybe E.Exception
-syncExceptions (E.AsyncException _) = Nothing
-syncExceptions e                    = Just e
+syncExceptions :: E.SomeException -> Maybe E.SomeException
+syncExceptions e = case E.fromException e :: Maybe E.AsyncException of
+  Nothing -> Just e
+  Just _  -> Nothing
 
 -- | Print a usage message to the given handle and exit with the given code.
 exitUsage :: Handle -> ExitCode -> IO a
@@ -385,10 +386,12 @@ splitByDelimiter delimiter bs = subst (-len : B.findSubstrings delimiter bs)
 
 -- | Convert an exception to a string given a list of functions for displaying
 -- dynamically typed exceptions.
-showException :: [Dynamic -> Maybe String] -> E.Exception -> String
-showException fs (E.DynException dyn)
-  | str:_ <- mapMaybe ($ dyn) fs = str
-showException _ e                = show e
+showException :: [Dynamic -> Maybe String] -> E.SomeException -> String
+showException fs e
+  | Just e' <- E.fromException e :: Maybe Dynamic
+  , str:_   <- mapMaybe ($ e') fs
+  = str
+  | otherwise = show e
 
 -- | Convert a 'UTCTime' to a string in ISO 8601 format.
 showUTCTime :: UTCTime -> String
-- 
1.7.9.5

