diff --git a/Hyena/Server.hs b/Hyena/Server.hs index 092dfb4..80002fb 100644 --- a/Hyena/Server.hs +++ b/Hyena/Server.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE GeneralizedNewtypeDeriving #-} +{-# LANGUAGE GeneralizedNewtypeDeriving, ScopedTypeVariables #-} ------------------------------------------------------------------------ -- | @@ -21,7 +21,7 @@ module Hyena.Server ) where import Control.Concurrent (ThreadId, forkIO) -import Control.Exception (Exception(..), bracket, catch, finally, throw) +import Control.Exception.Extensible import Control.Monad (unless, when) import Control.Monad.Reader (MonadIO, MonadReader, ReaderT, ask, asks, liftIO, runReaderT) @@ -34,7 +34,7 @@ import Network.Socket (Family(..), HostAddress, SockAddr(..), Socket, setSocketOption, socket, withSocketsDo) import Network.Wai import Prelude hiding (catch, log) -import System.Exit (exitFailure) +import System.Exit (exitFailure, ExitCode(..)) import System.IO (Handle, stderr, hPutStrLn) import System.Posix.Signals (Handler(..), installHandler, sigPIPE) @@ -69,13 +69,13 @@ runServer conf (Server a) = runReaderT a conf -- | Run action in the server monad, and in case of exception, and -- catch it and run the error case. -catchServer :: Server a -> (Exception -> Server a) -> Server a +catchServer ::Server a -> (forall e. (Exception e) => e ->Server a) -> Server a catchServer m k = do conf <- ask - io $ runServer conf m `catch` \e -> - case e of - ExitException {} -> throw e - _ -> runServer conf $ k e + io $ runServer conf m `catches` handlers conf + where handlers c + = [ Handler $ \(e::ExitCode) ->throw e + , Handler $ \(e::SomeException) ->runServer c $ k e ] -- | Run the first action and then the second action. The second -- action is run even if the first action threw and exception. diff --git a/Network/Wai.hs b/Network/Wai.hs index 9323600..7bfacfc 100644 --- a/Network/Wai.hs +++ b/Network/Wai.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE Rank2Types #-} +{-# LANGUAGE Rank2Types, ImpredicativeTypes #-} ------------------------------------------------------------------------ -- | diff --git a/hyena.cabal b/hyena.cabal index 85fe9d8..5b27edc 100644 --- a/hyena.cabal +++ b/hyena.cabal @@ -6,10 +6,7 @@ license-file: LICENSE author: Johan Tibell maintainer: johan.tibell@gmail.com build-type: Simple -cabal-version: >= 1.2 - -flag split-base - description: Choose the new smaller, split-up base package. +cabal-version: >= 1.6 library exposed-modules: Hyena.Config @@ -21,15 +18,10 @@ library Hyena.Logging Hyena.Parser - if flag(split-base) - build-depends: base >= 3 && < 3.1, bytestring, containers, directory, - filepath - else - build-depends: base >= 2.1 && < 3 - build-depends: network >= 2.1 && < 2.3, - mtl >= 1 && < 1.2, - network-bytestring >= 0.1.1.2 && < 0.2, - unix - + build-depends: base == 4.*, bytestring, containers, directory, + filepath, network >= 2.1 && < 2.3, + mtl >= 1 && < 1.2, + network-bytestring >= 0.1.1.2 && < 0.2, + unix, extensible-exceptions extensions: Rank2Types ghc-options: -funbox-strict-fields -Wall