Change Semigroup (ClientM a) to Alt ClientM
This commit is contained in:
parent
fdf86b0e15
commit
6fafaec51a
2 changed files with 5 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue