{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE Trustworthy #-}

-- |
-- Module      :   Grisette.Lib.Control.Monad.Trans
-- Copyright   :   (c) Sirui Lu 2021-2023
-- License     :   BSD-3-Clause (see the LICENSE file)
--
-- Maintainer  :   siruilu@cs.washington.edu
-- Stability   :   Experimental
-- Portability :   GHC only
module Grisette.Lib.Control.Monad.Trans
  ( -- * mrg* variants for operations in "Control.Monad.Trans"
    mrgLift,
  )
where

import Control.Monad.Trans
import Grisette.Core.Control.Monad.Union
import Grisette.Core.Data.Class.Mergeable
import Grisette.Core.Data.Class.SimpleMergeable

-- | 'lift' with 'MergingStrategy' knowledge propagation.
mrgLift ::
  forall t m a.
  (MonadUnion (t m), MonadTrans t, Monad m, Mergeable a) =>
  m a ->
  t m a
mrgLift :: forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadUnion (t m), MonadTrans t, Monad m, Mergeable a) =>
m a -> t m a
mrgLift m a
v = t m a -> t m a
forall (u :: * -> *) a. (UnionLike u, Mergeable a) => u a -> u a
merge (t m a -> t m a) -> t m a -> t m a
forall a b. (a -> b) -> a -> b
$ m a -> t m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m a
v
{-# INLINE mrgLift #-}