{-# LANGUAGE CPP #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleContexts #-}
#if __GLASGOW_HASKELL__ >= 710
{-# LANGUAGE Safe #-}
#elif __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif
module Foreign.Marshal.Utils.Lifted
( with
) where
import qualified Foreign as F
import System.IO ( IO )
import Prelude ( (.) )
import Control.Monad.Trans.Control ( MonadBaseControl
, liftBaseOp )
with :: (MonadBaseControl IO m, F.Storable a)
=> a
-> (F.Ptr a -> m b)
-> m b
with :: forall (m :: * -> *) a b.
(MonadBaseControl IO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with = ((Ptr a -> IO (StM m b)) -> IO (StM m b)) -> (Ptr a -> m b) -> m b
forall (b :: * -> *) (m :: * -> *) a c d.
MonadBaseControl b m =>
((a -> b (StM m c)) -> b (StM m d)) -> (a -> m c) -> m d
liftBaseOp (((Ptr a -> IO (StM m b)) -> IO (StM m b))
-> (Ptr a -> m b) -> m b)
-> (a -> (Ptr a -> IO (StM m b)) -> IO (StM m b))
-> a
-> (Ptr a -> m b)
-> m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> (Ptr a -> IO (StM m b)) -> IO (StM m b)
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
F.with
{-# INLINEABLE with #-}