Change Semigroup (ClientM a) to Alt ClientM

This commit is contained in:
Oleg Grenrus 2017-01-20 14:26:26 +02:00
parent fdf86b0e15
commit 6fafaec51a
2 changed files with 5 additions and 3 deletions

View file

@ -52,6 +52,7 @@ library
, monad-control >= 1.0.0.4 && < 1.1 , monad-control >= 1.0.0.4 && < 1.1
, network-uri >= 2.6 && < 2.7 , network-uri >= 2.6 && < 2.7
, safe >= 0.3.9 && < 0.4 , safe >= 0.3.9 && < 0.4
, semigroupoids >= 4.3 && < 5.2
, servant == 0.9.* , servant == 0.9.*
, string-conversions >= 0.3 && < 0.5 , string-conversions >= 0.3 && < 0.5
, text >= 1.2 && < 1.3 , text >= 1.2 && < 1.3

View file

@ -16,7 +16,8 @@ import Control.Exception
import Control.Monad import Control.Monad
import Control.Monad.Catch (MonadThrow, MonadCatch) import Control.Monad.Catch (MonadThrow, MonadCatch)
import Data.Foldable (toList) 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.Error.Class (MonadError(..))
import Control.Monad.Trans.Except import Control.Monad.Trans.Except
@ -216,8 +217,8 @@ instance MonadBaseControl IO ClientM where
restoreM st = ClientM (restoreM st) restoreM st = ClientM (restoreM st)
-- | Try clients in order, last error is preserved. -- | Try clients in order, last error is preserved.
instance Semigroup (ClientM a) where instance Alt ClientM where
a <> b = a `catchError` \_ -> b a <!> b = a `catchError` \_ -> b
runClientM :: ClientM a -> ClientEnv -> IO (Either ServantError a) runClientM :: ClientM a -> ClientEnv -> IO (Either ServantError a)
runClientM cm env = runExceptT $ (flip runReaderT env) $ runClientM' cm runClientM cm env = runExceptT $ (flip runReaderT env) $ runClientM' cm