Skip to content

Commit

Permalink
update to work with base 4, extensible-exceptions package and build w…
Browse files Browse the repository at this point in the history
…ell with ghc 6.10
  • Loading branch information
thoughtpolice committed Jan 18, 2009
1 parent 129e557 commit a1dffd1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
16 changes: 8 additions & 8 deletions Hyena/Server.hs
@@ -1,4 +1,4 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE GeneralizedNewtypeDeriving, ScopedTypeVariables #-}


------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | -- |
Expand All @@ -21,7 +21,7 @@ module Hyena.Server
) where ) where


import Control.Concurrent (ThreadId, forkIO) 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 (unless, when)
import Control.Monad.Reader (MonadIO, MonadReader, ReaderT, ask, asks, import Control.Monad.Reader (MonadIO, MonadReader, ReaderT, ask, asks,
liftIO, runReaderT) liftIO, runReaderT)
Expand All @@ -34,7 +34,7 @@ import Network.Socket (Family(..), HostAddress, SockAddr(..), Socket,
setSocketOption, socket, withSocketsDo) setSocketOption, socket, withSocketsDo)
import Network.Wai import Network.Wai
import Prelude hiding (catch, log) import Prelude hiding (catch, log)
import System.Exit (exitFailure) import System.Exit (exitFailure, ExitCode(..))
import System.IO (Handle, stderr, hPutStrLn) import System.IO (Handle, stderr, hPutStrLn)
import System.Posix.Signals (Handler(..), installHandler, sigPIPE) import System.Posix.Signals (Handler(..), installHandler, sigPIPE)


Expand Down Expand Up @@ -69,13 +69,13 @@ runServer conf (Server a) = runReaderT a conf


-- | Run action in the server monad, and in case of exception, and -- | Run action in the server monad, and in case of exception, and
-- catch it and run the error case. -- 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 catchServer m k = do
conf <- ask conf <- ask
io $ runServer conf m `catch` \e -> io $ runServer conf m `catches` handlers conf
case e of where handlers c
ExitException {} -> throw e = [ Handler $ \(e::ExitCode) ->throw e
_ -> runServer conf $ k e , Handler $ \(e::SomeException) ->runServer c $ k e ]


-- | Run the first action and then the second action. The second -- | Run the first action and then the second action. The second
-- action is run even if the first action threw and exception. -- action is run even if the first action threw and exception.
Expand Down
2 changes: 1 addition & 1 deletion Network/Wai.hs
@@ -1,4 +1,4 @@
{-# LANGUAGE Rank2Types #-} {-# LANGUAGE Rank2Types, ImpredicativeTypes #-}


------------------------------------------------------------------------ ------------------------------------------------------------------------
-- | -- |
Expand Down
20 changes: 6 additions & 14 deletions hyena.cabal
Expand Up @@ -6,10 +6,7 @@ license-file: LICENSE
author: Johan Tibell author: Johan Tibell
maintainer: johan.tibell@gmail.com maintainer: johan.tibell@gmail.com
build-type: Simple build-type: Simple
cabal-version: >= 1.2 cabal-version: >= 1.6

flag split-base
description: Choose the new smaller, split-up base package.


library library
exposed-modules: Hyena.Config exposed-modules: Hyena.Config
Expand All @@ -21,15 +18,10 @@ library
Hyena.Logging Hyena.Logging
Hyena.Parser Hyena.Parser


if flag(split-base) build-depends: base == 4.*, bytestring, containers, directory,
build-depends: base >= 3 && < 3.1, bytestring, containers, directory, filepath, network >= 2.1 && < 2.3,
filepath mtl >= 1 && < 1.2,
else network-bytestring >= 0.1.1.2 && < 0.2,
build-depends: base >= 2.1 && < 3 unix, extensible-exceptions
build-depends: network >= 2.1 && < 2.3,
mtl >= 1 && < 1.2,
network-bytestring >= 0.1.1.2 && < 0.2,
unix

extensions: Rank2Types extensions: Rank2Types
ghc-options: -funbox-strict-fields -Wall ghc-options: -funbox-strict-fields -Wall

0 comments on commit a1dffd1

Please sign in to comment.