Skip to content

Commit cfaa7a0

Browse files
authored
Merge pull request #665 from phadej/client-monad-control
Add MonadBaseControl IO ClientM instance
2 parents eac364e + e6206cc commit cfaa7a0

File tree

5 files changed

+40
-6
lines changed

5 files changed

+40
-6
lines changed

servant-client/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
0.10
2+
----
3+
4+
* Add MonadBase and MonadBaseControl instances for ClientM
5+
([#663](https://github.com/haskell-servant/servant/issues/663))
6+
7+
* client asks for any content-type in Accept contentTypes non-empty list
8+
([#615](https://github.com/haskell-servant/servant/pull/615))
9+
110
0.9.1.1
211
-------
312

servant-client/servant-client.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,14 @@ library
4747
, http-client-tls >= 0.2.2 && < 0.4
4848
, http-media >= 0.6.2 && < 0.7
4949
, http-types >= 0.8.6 && < 0.10
50+
, monad-control >= 1.0.0.4 && < 1.1
5051
, network-uri >= 2.6 && < 2.7
5152
, safe >= 0.3.9 && < 0.4
5253
, servant == 0.9.*
5354
, string-conversions >= 0.3 && < 0.5
5455
, text >= 1.2 && < 1.3
5556
, transformers >= 0.3 && < 0.6
57+
, transformers-base >= 0.4.4 && < 0.5
5658
, transformers-compat >= 0.4 && < 0.6
5759
, mtl
5860
hs-source-dirs: src

servant-client/src/Servant/Common/Req.hs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
{-# LANGUAGE DeriveDataTypeable #-}
2-
{-# LANGUAGE DeriveGeneric #-}
3-
{-# LANGUAGE CPP #-}
4-
{-# LANGUAGE OverloadedStrings #-}
5-
{-# LANGUAGE ScopedTypeVariables #-}
6-
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
1+
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE DeriveDataTypeable #-}
3+
{-# LANGUAGE DeriveGeneric #-}
4+
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5+
{-# LANGUAGE MultiParamTypeClasses #-}
6+
{-# LANGUAGE TypeFamilies #-}
7+
{-# LANGUAGE OverloadedStrings #-}
8+
{-# LANGUAGE ScopedTypeVariables #-}
79

810
module Servant.Common.Req where
911

@@ -24,8 +26,10 @@ import Control.Monad.Trans.Except
2426

2527

2628
import GHC.Generics
29+
import Control.Monad.Base (MonadBase (..))
2730
import Control.Monad.IO.Class ()
2831
import Control.Monad.Reader
32+
import Control.Monad.Trans.Control (MonadBaseControl (..))
2933
import Data.ByteString.Lazy hiding (pack, filter, map, null, elem, any)
3034
import Data.String
3135
import Data.String.Conversions
@@ -203,6 +207,18 @@ newtype ClientM a = ClientM { runClientM' :: ReaderT ClientEnv (ExceptT ServantE
203207
, MonadThrow, MonadCatch
204208
)
205209

210+
instance MonadBase IO ClientM where
211+
liftBase = ClientM . liftBase
212+
213+
instance MonadBaseControl IO ClientM where
214+
type StM ClientM a = Either ServantError a
215+
216+
-- liftBaseWith :: (RunInBase ClientM IO -> IO a) -> ClientM a
217+
liftBaseWith f = ClientM (liftBaseWith (\g -> f (g . runClientM')))
218+
219+
-- restoreM :: StM ClientM a -> ClientM a
220+
restoreM st = ClientM (restoreM st)
221+
206222
runClientM :: ClientM a -> ClientEnv -> IO (Either ServantError a)
207223
runClientM cm env = runExceptT $ (flip runReaderT env) $ runClientM' cm
208224

servant-server/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
0.10
2+
----
3+
4+
* Add `err422` Unprocessable Entity
5+
([#646](https://github.com/haskell-servant/servant/pull/646))
6+
17
0.7.1
28
------
39

servant/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
------
33

44
* Use `NT` from `natural-transformation` for `Enter`
5+
([#616](https://github.com/haskell-servant/servant/issues/616))
56

67
0.9.1
78
------

0 commit comments

Comments
 (0)