{-# options_haddock prune #-}
module Polysemy.Conc.Effect.Critical where
data Critical :: Effect where
Catch :: Exception e => m a -> Critical m (Either e a)
makeSem ''Critical
catchAs ::
∀ e a r .
Exception e =>
Member Critical r =>
a ->
Sem r a ->
Sem r a
catchAs :: a -> Sem r a -> Sem r a
catchAs a
a =
(Either e a -> a) -> Sem r (Either e a) -> Sem r a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a -> Either e a -> a
forall b a. b -> Either a b -> b
fromRight a
a) (Sem r (Either e a) -> Sem r a)
-> (Sem r a -> Sem r (Either e a)) -> Sem r a -> Sem r a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (r :: [Effect]) e a.
(MemberWithError Critical r, Exception e) =>
Sem r a -> Sem r (Either e a)
forall a.
(MemberWithError Critical r, Exception e) =>
Sem r a -> Sem r (Either e a)
catch @_ @e
run ::
Member Critical r =>
Sem r a ->
Sem r (Either SomeException a)
run :: Sem r a -> Sem r (Either SomeException a)
run =
Sem r a -> Sem r (Either SomeException a)
forall (r :: [Effect]) e a.
(MemberWithError Critical r, Exception e) =>
Sem r a -> Sem r (Either e a)
catch
runAs ::
Member Critical r =>
a ->
Sem r a ->
Sem r a
runAs :: a -> Sem r a -> Sem r a
runAs a
a =
(Either SomeException a -> a)
-> Sem r (Either SomeException a) -> Sem r a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (a -> Either SomeException a -> a
forall b a. b -> Either a b -> b
fromRight a
a) (Sem r (Either SomeException a) -> Sem r a)
-> (Sem r a -> Sem r (Either SomeException a))
-> Sem r a
-> Sem r a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sem r a -> Sem r (Either SomeException a)
forall (r :: [Effect]) a.
Member Critical r =>
Sem r a -> Sem r (Either SomeException a)
run