-- |Combinators for 'Stop'.
-- Internal.
module Helic.Stop where

-- |Catch all exceptions in an 'IO' action, embed it into a 'Sem' and convert exceptions to 'Stop'.
tryStop ::
  Members [Stop Text, Embed IO] r =>
  IO a ->
  Sem r a
tryStop :: IO a -> Sem r a
tryStop =
  Either Text a -> Sem r a
forall err (r :: EffectRow) a.
Member (Stop err) r =>
Either err a -> Sem r a
stopEither (Either Text a -> Sem r a)
-> (IO a -> Sem r (Either Text a)) -> IO a -> Sem r a
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< IO a -> Sem r (Either Text a)
forall (r :: EffectRow) a.
Member (Embed IO) r =>
IO a -> Sem r (Either Text a)
tryAny