Skip to content

Commit

Permalink
7.5.2 - add MonadFail instances of WebT and ServerPartT when base >= 4.9
Browse files Browse the repository at this point in the history
  • Loading branch information
stepcut committed Sep 2, 2019
1 parent 7f8fcdd commit e60dd50
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
10 changes: 5 additions & 5 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
, filepath, hslogger, html, HUnit, monad-control, mtl, network
, network-uri, old-locale, parsec, process, semigroups, sendfile
, stdenv, syb, system-filepath, template-haskell, text, threads
, time, time-compat, transformers, transformers-base
, transformers-compat, unix, utf8-string, xhtml, zlib
, time, transformers, transformers-base, transformers-compat, unix
, utf8-string, xhtml, zlib
}:
mkDerivation {
pname = "happstack-server";
version = "7.5.0.2";
version = "7.5.1.4";
src = ./.;
libraryHaskellDepends = [
base base64-bytestring blaze-html bytestring containers directory
exceptions extensible-exceptions filepath hslogger html
monad-control mtl network network-uri old-locale parsec process
semigroups sendfile syb system-filepath template-haskell text
threads time time-compat transformers transformers-base
transformers-compat unix utf8-string xhtml zlib
threads time transformers transformers-base transformers-compat
unix utf8-string xhtml zlib
];
testHaskellDepends = [
base bytestring containers HUnit parsec zlib
Expand Down
2 changes: 1 addition & 1 deletion happstack-server.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: happstack-server
Version: 7.5.1.4
Version: 7.5.2
Synopsis: Web related tools and services.
Description: Happstack Server provides an HTTP server and a rich set of functions for routing requests, handling query parameters, generating responses, working with cookies, serving files, and more. For in-depth documentation see the Happstack Crash Course <http://happstack.com/docs/crashcourse/index.html>
License: BSD3
Expand Down
13 changes: 13 additions & 0 deletions src/Happstack/Server/Internal/Monads.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ import Control.Monad.Error ( ErrorT(ErrorT), runErrorT
, Error, MonadError, throwError
, catchError, mapErrorT
)
#if MIN_VERSION_base(4,9,0)
import Control.Monad.Fail (MonadFail)
import qualified Control.Monad.Fail as Fail
#endif
import Control.Monad.Reader ( ReaderT(ReaderT), runReaderT
, MonadReader, ask, local, mapReaderT
)
Expand Down Expand Up @@ -70,7 +74,11 @@ type ServerPart a = ServerPartT IO a
--
-- see also: 'simpleHTTP', 'ServerMonad', 'FilterMonad', 'WebMonad', and 'HasRqData'
newtype ServerPartT m a = ServerPartT { unServerPartT :: ReaderT Request (WebT m) a }
#if MIN_VERSION_base(4,9,0)
deriving (Monad, MonadFail, MonadPlus, Functor)
#else
deriving (Monad, MonadPlus, Functor)
#endif

instance MonadCatch m => MonadCatch (ServerPartT m) where
catch action handle = ServerPartT $ catch (unServerPartT action) (unServerPartT . handle)
Expand Down Expand Up @@ -392,6 +400,11 @@ instance (Monad m) => FilterMonad a (FilterT a m) where
newtype WebT m a = WebT { unWebT :: ErrorT Response (FilterT (Response) (MaybeT m)) a }
deriving (Functor)

#if MIN_VERSION_base(4,9,0)
instance MonadFail m => MonadFail (WebT m) where
fail s = lift (Fail.fail s)
#endif

instance MonadCatch m => MonadCatch (WebT m) where
catch action handle = WebT $ catch (unWebT action) (unWebT . handle)

Expand Down

0 comments on commit e60dd50

Please sign in to comment.