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