From 6fafaec51ada3025b1087e162daf49eba1af87f1 Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Fri, 20 Jan 2017 14:26:26 +0200 Subject: [PATCH] Change Semigroup (ClientM a) to Alt ClientM --- servant-client/servant-client.cabal | 1 + servant-client/src/Servant/Common/Req.hs | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/servant-client/servant-client.cabal b/servant-client/servant-client.cabal index 97f79174..f48d69a0 100644 --- a/servant-client/servant-client.cabal +++ b/servant-client/servant-client.cabal @@ -52,6 +52,7 @@ library , monad-control >= 1.0.0.4 && < 1.1 , network-uri >= 2.6 && < 2.7 , safe >= 0.3.9 && < 0.4 + , semigroupoids >= 4.3 && < 5.2 , servant == 0.9.* , string-conversions >= 0.3 && < 0.5 , text >= 1.2 && < 1.3 diff --git a/servant-client/src/Servant/Common/Req.hs b/servant-client/src/Servant/Common/Req.hs index b9dbba0b..f3de9687 100644 --- a/servant-client/src/Servant/Common/Req.hs +++ b/servant-client/src/Servant/Common/Req.hs @@ -16,7 +16,8 @@ import Control.Exception import Control.Monad import Control.Monad.Catch (MonadThrow, MonadCatch) import Data.Foldable (toList) -import Data.Semigroup (Semigroup (..)) +import Data.Functor.Alt (Alt (..)) +import Data.Semigroup ((<>)) import Control.Monad.Error.Class (MonadError(..)) import Control.Monad.Trans.Except @@ -216,8 +217,8 @@ instance MonadBaseControl IO ClientM where restoreM st = ClientM (restoreM st) -- | Try clients in order, last error is preserved. -instance Semigroup (ClientM a) where - a <> b = a `catchError` \_ -> b +instance Alt ClientM where + a b = a `catchError` \_ -> b runClientM :: ClientM a -> ClientEnv -> IO (Either ServantError a) runClientM cm env = runExceptT $ (flip runReaderT env) $ runClientM' cm