module HaskellWorks.Polysemy.Data.Either
  ( onLeftThrow
  ) where

import           HaskellWorks.Polysemy.Prelude

import           Polysemy
import           Polysemy.Error

onLeftThrow :: forall e a r. ()
  => Member (Error e) r
  => Sem r (Either e a)
  -> Sem r a
onLeftThrow :: forall e a (r :: EffectRow).
Member (Error e) r =>
Sem r (Either e a) -> Sem r a
onLeftThrow Sem r (Either e a)
f =
  Sem r (Either e a)
f Sem r (Either e a) -> (Either e a -> Sem r a) -> Sem r a
forall a b. Sem r a -> (a -> Sem r b) -> Sem r b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (e -> Sem r a) -> (a -> Sem r a) -> Either e a -> Sem r a
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either e -> Sem r a
forall e (r :: EffectRow) a. Member (Error e) r => e -> Sem r a
throw a -> Sem r a
forall a. a -> Sem r a
forall (f :: * -> *) a. Applicative f => a -> f a
pure