{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Control.Carrier.Lift
(
runM
, LiftC(..)
, module Control.Effect.Lift
) where
import Control.Algebra
import Control.Applicative (Alternative)
import Control.Effect.Lift
import Control.Monad (MonadPlus)
import Control.Monad.Fail as Fail
import Control.Monad.Fix
import Control.Monad.IO.Class
import Control.Monad.Trans.Class
runM :: LiftC m a -> m a
runM (LiftC m) = m
{-# INLINE runM #-}
newtype LiftC m a = LiftC (m a)
deriving (Alternative, Applicative, Functor, Monad, Fail.MonadFail, MonadFix, MonadIO, MonadPlus)
instance MonadTrans LiftC where
lift = LiftC
{-# INLINE lift #-}
instance Monad m => Algebra (Lift m) (LiftC m) where
alg hdl (LiftWith with) = LiftC . with (runM . hdl)
{-# INLINE alg #-}