fused-effects-1.0.2.0: src/Control/Effect/Catch/Internal.hs
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE StandaloneDeriving #-}
module Control.Effect.Catch.Internal
( Catch(..)
) where
import Control.Effect.Class
-- | 'Catch' effects can be used alongside 'Control.Effect.Throw.Throw' to provide recoverable exceptions.
--
-- @since 1.0.0.0
data Catch e m k
= forall b . Catch (m b) (e -> m b) (b -> m k)
deriving instance Functor m => Functor (Catch e m)
instance HFunctor (Catch e) where
hmap f (Catch m h k) = Catch (f m) (f . h) (f . k)
instance Effect (Catch e) where
thread ctx handler (Catch m h k) = Catch (handler (m <$ ctx)) (handler . (<$ ctx) . h) (handler . fmap k)