Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update to work with base-4, extensible-exceptions and GHC 6.10.

  • Loading branch information...
commit 510a0573dd0ba7fcc24d81073ae5e59e01cf5ad5 1 parent 129e557
@thoughtpolice thoughtpolice authored committed
Showing with 15 additions and 23 deletions.
  1. +8 −8 Hyena/Server.hs
  2. +1 −1  Network/Wai.hs
  3. +6 −14 hyena.cabal
View
16 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.
View
2  Network/Wai.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE Rank2Types #-}
+{-# LANGUAGE Rank2Types, ImpredicativeTypes #-}
------------------------------------------------------------------------
-- |
View
20 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
Please sign in to comment.
Something went wrong with that request. Please try again.