{-# LANGUAGE CPP #-}
-- | Unlifted "Foreign".
--
-- @since 0.2.5.0

module UnliftIO.Foreign (
  -- * Re-exported modules
    module Data.Bits
  , module Data.Int
  , module Data.Word
  , module Foreign.C.Types

  -- * Unlifted "Foreign.C.String"
  , CString
  , CStringLen
  , peekCString
  , peekCStringLen
  , newCString
  , newCStringLen
  , withCString
  , withCStringLen
  , charIsRepresentable
  , castCharToCChar
  , castCCharToChar
  , castCharToCUChar
  , castCUCharToChar
  , castCharToCSChar
  , castCSCharToChar
  , peekCAString
  , peekCAStringLen
  , newCAString
  , newCAStringLen
  , withCAString
  , withCAStringLen
  , CWString
  , CWStringLen
  , peekCWString
  , peekCWStringLen
  , newCWString
  , newCWStringLen
  , withCWString
  , withCWStringLen

  -- * Unlifted "Foreign.C.Error"
  , Errno(..)
  , eOK
  , e2BIG
  , eACCES
  , eADDRINUSE
  , eADDRNOTAVAIL
  , eADV
  , eAFNOSUPPORT
  , eAGAIN
  , eALREADY
  , eBADF
  , eBADMSG
  , eBADRPC
  , eBUSY
  , eCHILD
  , eCOMM
  , eCONNABORTED
  , eCONNREFUSED
  , eCONNRESET
  , eDEADLK
  , eDESTADDRREQ
  , eDIRTY
  , eDOM
  , eDQUOT
  , eEXIST
  , eFAULT
  , eFBIG
  , eFTYPE
  , eHOSTDOWN
  , eHOSTUNREACH
  , eIDRM
  , eILSEQ
  , eINPROGRESS
  , eINTR
  , eINVAL
  , eIO
  , eISCONN
  , eISDIR
  , eLOOP
  , eMFILE
  , eMLINK
  , eMSGSIZE
  , eMULTIHOP
  , eNAMETOOLONG
  , eNETDOWN
  , eNETRESET
  , eNETUNREACH
  , eNFILE
  , eNOBUFS
  , eNODATA
  , eNODEV
  , eNOENT
  , eNOEXEC
  , eNOLCK
  , eNOLINK
  , eNOMEM
  , eNOMSG
  , eNONET
  , eNOPROTOOPT
  , eNOSPC
  , eNOSR
  , eNOSTR
  , eNOSYS
  , eNOTBLK
  , eNOTCONN
  , eNOTDIR
  , eNOTEMPTY
  , eNOTSOCK
  , eNOTSUP
  , eNOTTY
  , eNXIO
  , eOPNOTSUPP
  , ePERM
  , ePFNOSUPPORT
  , ePIPE
  , ePROCLIM
  , ePROCUNAVAIL
  , ePROGMISMATCH
  , ePROGUNAVAIL
  , ePROTO
  , ePROTONOSUPPORT
  , ePROTOTYPE
  , eRANGE
  , eREMCHG
  , eREMOTE
  , eROFS
  , eRPCMISMATCH
  , eRREMOTE
  , eSHUTDOWN
  , eSOCKTNOSUPPORT
  , eSPIPE
  , eSRCH
  , eSRMNT
  , eSTALE
  , eTIME
  , eTIMEDOUT
  , eTOOMANYREFS
  , eTXTBSY
  , eUSERS
  , eWOULDBLOCK
  , eXDEV
  , isValidErrno
  , getErrno
  , resetErrno
  , errnoToIOError
  , throwErrno
  , throwErrnoIf
  , throwErrnoIf_
  , throwErrnoIfRetry
  , throwErrnoIfRetry_
  , throwErrnoIfMinus1
  , throwErrnoIfMinus1_
  , throwErrnoIfMinus1Retry
  , throwErrnoIfMinus1Retry_
  , throwErrnoIfNull
  , throwErrnoIfNullRetry
  , throwErrnoIfRetryMayBlock
  , throwErrnoIfRetryMayBlock_
  , throwErrnoIfMinus1RetryMayBlock
  , throwErrnoIfMinus1RetryMayBlock_
  , throwErrnoIfNullRetryMayBlock
  , throwErrnoPath
  , throwErrnoPathIf
  , throwErrnoPathIf_
  , throwErrnoPathIfNull
  , throwErrnoPathIfMinus1
  , throwErrnoPathIfMinus1_

  -- * Unlifted "Foreign.Ptr"
  , Ptr
  , nullPtr
  , castPtr
  , plusPtr
  , alignPtr
  , minusPtr
  , FunPtr
  , nullFunPtr
  , castFunPtr
  , castFunPtrToPtr
  , castPtrToFunPtr
  , freeHaskellFunPtr
  , IntPtr(..)
  , ptrToIntPtr
  , intPtrToPtr
  , WordPtr(..)
  , ptrToWordPtr
  , wordPtrToPtr

  -- * Unlifted "Foreign.ForeignPtr"
  , ForeignPtr
  , FinalizerPtr
  , FinalizerEnvPtr
  , newForeignPtr
  , newForeignPtr_
  , addForeignPtrFinalizer
  , newForeignPtrEnv
  , addForeignPtrFinalizerEnv
  , withForeignPtr
  , finalizeForeignPtr
  , touchForeignPtr
  , castForeignPtr
#if MIN_VERSION_base(4,10,0)
  , plusForeignPtr
#endif
  , mallocForeignPtr
  , mallocForeignPtrBytes
  , mallocForeignPtrArray
  , mallocForeignPtrArray0
  , newGHCForeignPtr
  , addGHCForeignPtrFinalizer
  , unsafeForeignPtrToPtr

  -- * Unlifted "Foreign.StablePtr"
  , StablePtr
  , newStablePtr
  , deRefStablePtr
  , freeStablePtr
  , castStablePtrToPtr
  , castPtrToStablePtr

  -- * Unlifted "Foreign.Storable"
  , Storable(..)

  -- * Unlifted "Foreign.Marshal.Alloc"
  , alloca
  , allocaBytes
  , allocaBytesAligned
  , malloc
  , mallocBytes
#if MIN_VERSION_base(4,8,0)
  , calloc
  , callocBytes
#endif
  , realloc
  , reallocBytes
  , free
  , finalizerFree

  -- * Unlifted "Foreign.Marshal.Array"
  , mallocArray
  , mallocArray0
  , allocaArray
  , allocaArray0
  , reallocArray
  , reallocArray0
#if MIN_VERSION_base(4,8,0)
  , callocArray
  , callocArray0
#endif
  , peekArray
  , peekArray0
  , pokeArray
  , pokeArray0
  , newArray
  , newArray0
  , withArray
  , withArray0
  , withArrayLen
  , withArrayLen0
  , copyArray
  , moveArray
  , lengthArray0
  , advancePtr

  -- * Unlifted "Foreign.Marshal.Error"
  , throwIf
  , throwIf_
  , throwIfNeg
  , throwIfNeg_
  , throwIfNull

  -- * Unlifted "Foreign.Marshal.Pool"
  , Pool
  , newPool
  , freePool
  , withPool
  , pooledMalloc
  , pooledMallocBytes
  , pooledRealloc
  , pooledReallocBytes
  , pooledMallocArray
  , pooledMallocArray0
  , pooledReallocArray
  , pooledReallocArray0
  , pooledNew
  , pooledNewArray
  , pooledNewArray0

  -- * Unlifted "Foreign.Marshal.Utils"
  , with
  , new
  , fromBool
  , toBool
  , maybeNew
  , maybeWith
  , maybePeek
  , withMany
  , copyBytes
  , moveBytes
#if MIN_VERSION_base(4,8,0)
  , fillBytes
#endif
  ) where

import Control.Monad.IO.Unlift
import Data.Bits
import Data.Int
import Data.Word
import qualified Foreign as F
import Foreign
  ( FinalizerEnvPtr
  , FinalizerPtr
  , ForeignPtr
  , FunPtr
  , IntPtr(..)
  , Pool
  , Ptr
  , StablePtr
  , Storable(..)
  , WordPtr(..)
  , advancePtr
  , alignPtr
  , castForeignPtr
  , castFunPtr
  , castFunPtrToPtr
  , castPtr
  , castPtrToFunPtr
  , castPtrToStablePtr
  , castStablePtrToPtr
  , finalizerFree
  , fromBool
  , intPtrToPtr
  , minusPtr
  , nullFunPtr
  , nullPtr
#if MIN_VERSION_base(4,10,0)
  , plusForeignPtr
#endif
  , plusPtr
  , ptrToIntPtr
  , ptrToWordPtr
  , toBool
  , withMany
  , wordPtrToPtr
  )

import qualified Foreign.C as F
import Foreign.C
  ( CString
  , CStringLen
  , CWString
  , CWStringLen
  , Errno(..)
  , castCCharToChar
  , castCSCharToChar
  , castCUCharToChar
  , castCharToCChar
  , castCharToCSChar
  , castCharToCSChar
  , castCharToCUChar
  , charIsRepresentable
  , e2BIG
  , eACCES
  , eADDRINUSE
  , eADDRNOTAVAIL
  , eADV
  , eAFNOSUPPORT
  , eAGAIN
  , eALREADY
  , eBADF
  , eBADMSG
  , eBADRPC
  , eBUSY
  , eCHILD
  , eCOMM
  , eCONNABORTED
  , eCONNREFUSED
  , eCONNRESET
  , eDEADLK
  , eDESTADDRREQ
  , eDIRTY
  , eDOM
  , eDQUOT
  , eEXIST
  , eFAULT
  , eFBIG
  , eFTYPE
  , eHOSTDOWN
  , eHOSTUNREACH
  , eIDRM
  , eILSEQ
  , eINPROGRESS
  , eINTR
  , eINVAL
  , eIO
  , eISCONN
  , eISDIR
  , eLOOP
  , eMFILE
  , eMLINK
  , eMSGSIZE
  , eMULTIHOP
  , eNAMETOOLONG
  , eNETDOWN
  , eNETRESET
  , eNETUNREACH
  , eNFILE
  , eNOBUFS
  , eNODATA
  , eNODEV
  , eNOENT
  , eNOEXEC
  , eNOLCK
  , eNOLINK
  , eNOMEM
  , eNOMSG
  , eNONET
  , eNOPROTOOPT
  , eNOSPC
  , eNOSR
  , eNOSTR
  , eNOSYS
  , eNOTBLK
  , eNOTCONN
  , eNOTDIR
  , eNOTEMPTY
  , eNOTSOCK
  , eNOTSUP
  , eNOTTY
  , eNXIO
  , eOK
  , eOPNOTSUPP
  , ePERM
  , ePFNOSUPPORT
  , ePIPE
  , ePROCLIM
  , ePROCUNAVAIL
  , ePROGMISMATCH
  , ePROGUNAVAIL
  , ePROTO
  , ePROTONOSUPPORT
  , ePROTOTYPE
  , eRANGE
  , eREMCHG
  , eREMOTE
  , eROFS
  , eRPCMISMATCH
  , eRREMOTE
  , eSHUTDOWN
  , eSOCKTNOSUPPORT
  , eSPIPE
  , eSRCH
  , eSRMNT
  , eSTALE
  , eTIME
  , eTIMEDOUT
  , eTOOMANYREFS
  , eTXTBSY
  , eUSERS
  , eWOULDBLOCK
  , eXDEV
  , errnoToIOError
  , isValidErrno
  )
import Foreign.C.Types
import qualified Foreign.Concurrent as FC
import Foreign.ForeignPtr.Unsafe

-- | Lifted 'F.peekCString'.
--
-- @since 0.2.5.0
{-# INLINE peekCString #-}
peekCString :: MonadIO m => CString -> m String
peekCString :: forall (m :: * -> *). MonadIO m => CString -> m String
peekCString = IO String -> m String
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String)
-> (CString -> IO String) -> CString -> m String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CString -> IO String
F.peekCString

-- | Lifted 'F.peekCStringLen'.
--
-- @since 0.2.5.0
{-# INLINE peekCStringLen #-}
peekCStringLen :: MonadIO m => CStringLen -> m String
peekCStringLen :: forall (m :: * -> *). MonadIO m => CStringLen -> m String
peekCStringLen = IO String -> m String
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String)
-> (CStringLen -> IO String) -> CStringLen -> m String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CStringLen -> IO String
F.peekCStringLen

-- | Lifted 'F.newCString'.
--
-- @since 0.2.5.0
{-# INLINE newCString #-}
newCString :: MonadIO m => String -> m CString
newCString :: forall (m :: * -> *). MonadIO m => String -> m CString
newCString = IO CString -> m CString
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CString -> m CString)
-> (String -> IO CString) -> String -> m CString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO CString
F.newCString

-- | Lifted 'F.newCStringLen'.
--
-- @since 0.2.5.0
{-# INLINE newCStringLen #-}
newCStringLen :: MonadIO m => String -> m CStringLen
newCStringLen :: forall (m :: * -> *). MonadIO m => String -> m CStringLen
newCStringLen = IO CStringLen -> m CStringLen
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CStringLen -> m CStringLen)
-> (String -> IO CStringLen) -> String -> m CStringLen
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO CStringLen
F.newCStringLen

-- | Unlifted 'F.withCString'.
--
-- @since 0.2.5.0
{-# INLINE withCString #-}
withCString :: MonadUnliftIO m => String -> (CString -> m a) -> m a
withCString :: forall (m :: * -> *) a.
MonadUnliftIO m =>
String -> (CString -> m a) -> m a
withCString String
s CString -> m a
f = ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> (CString -> IO a) -> IO a
forall a. String -> (CString -> IO a) -> IO a
F.withCString String
s (m a -> IO a
forall a. m a -> IO a
u (m a -> IO a) -> (CString -> m a) -> CString -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CString -> m a
f))

-- | Unlifted 'F.withCStringLen'.
--
-- @since 0.2.5.0
{-# INLINE withCStringLen #-}
withCStringLen :: MonadUnliftIO m => String -> (CStringLen -> m a) -> m a
withCStringLen :: forall (m :: * -> *) a.
MonadUnliftIO m =>
String -> (CStringLen -> m a) -> m a
withCStringLen String
s CStringLen -> m a
f = ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> (CStringLen -> IO a) -> IO a
forall a. String -> (CStringLen -> IO a) -> IO a
F.withCStringLen String
s (m a -> IO a
forall a. m a -> IO a
u (m a -> IO a) -> (CStringLen -> m a) -> CStringLen -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CStringLen -> m a
f))

-- | Lifted 'F.peekCAString'.
--
-- @since 0.2.5.0
{-# INLINE peekCAString #-}
peekCAString :: MonadIO m => CString -> m String
peekCAString :: forall (m :: * -> *). MonadIO m => CString -> m String
peekCAString = IO String -> m String
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String)
-> (CString -> IO String) -> CString -> m String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CString -> IO String
F.peekCAString

-- | Lifted 'F.peekCAStringLen'.
--
-- @since 0.2.5.0
{-# INLINE peekCAStringLen #-}
peekCAStringLen :: MonadIO m => CStringLen -> m String
peekCAStringLen :: forall (m :: * -> *). MonadIO m => CStringLen -> m String
peekCAStringLen = IO String -> m String
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String)
-> (CStringLen -> IO String) -> CStringLen -> m String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CStringLen -> IO String
F.peekCAStringLen

-- | Lifted 'F.newCAString'.
--
-- @since 0.2.5.0
{-# INLINE newCAString #-}
newCAString :: MonadIO m => String -> m CString
newCAString :: forall (m :: * -> *). MonadIO m => String -> m CString
newCAString = IO CString -> m CString
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CString -> m CString)
-> (String -> IO CString) -> String -> m CString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO CString
F.newCAString

-- | Lifted 'F.newCAStringLen'.
--
-- @since 0.2.5.0
{-# INLINE newCAStringLen #-}
newCAStringLen :: MonadIO m => String -> m CStringLen
newCAStringLen :: forall (m :: * -> *). MonadIO m => String -> m CStringLen
newCAStringLen = IO CStringLen -> m CStringLen
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CStringLen -> m CStringLen)
-> (String -> IO CStringLen) -> String -> m CStringLen
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO CStringLen
F.newCAStringLen

-- | Unlifted 'F.withCAString'.
--
-- @since 0.2.5.0
{-# INLINE withCAString #-}
withCAString :: MonadUnliftIO m => String -> (CString -> m a) -> m a
withCAString :: forall (m :: * -> *) a.
MonadUnliftIO m =>
String -> (CString -> m a) -> m a
withCAString String
str CString -> m a
f = ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> (CString -> IO a) -> IO a
forall a. String -> (CString -> IO a) -> IO a
F.withCAString String
str (m a -> IO a
forall a. m a -> IO a
u (m a -> IO a) -> (CString -> m a) -> CString -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CString -> m a
f))

-- | Unlifted 'F.withCAStringLen'.
--
-- @since 0.2.5.0
{-# INLINE withCAStringLen #-}
withCAStringLen :: MonadUnliftIO m => String -> (CStringLen -> m a) -> m a
withCAStringLen :: forall (m :: * -> *) a.
MonadUnliftIO m =>
String -> (CStringLen -> m a) -> m a
withCAStringLen String
str CStringLen -> m a
f = ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> (CStringLen -> IO a) -> IO a
forall a. String -> (CStringLen -> IO a) -> IO a
F.withCAStringLen String
str (m a -> IO a
forall a. m a -> IO a
u (m a -> IO a) -> (CStringLen -> m a) -> CStringLen -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CStringLen -> m a
f))

-- | Lifted 'F.peekCWString'.
--
-- @since 0.2.5.0
{-# INLINE peekCWString #-}
peekCWString :: MonadIO m => CWString -> m String
peekCWString :: forall (m :: * -> *). MonadIO m => CWString -> m String
peekCWString = IO String -> m String
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String)
-> (CWString -> IO String) -> CWString -> m String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CWString -> IO String
F.peekCWString

-- | Lifted 'F.peekCWStringLen'.
--
-- @since 0.2.5.0
{-# INLINE peekCWStringLen #-}
peekCWStringLen :: MonadIO m => CWStringLen -> m String
peekCWStringLen :: forall (m :: * -> *). MonadIO m => CWStringLen -> m String
peekCWStringLen = IO String -> m String
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String)
-> (CWStringLen -> IO String) -> CWStringLen -> m String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CWStringLen -> IO String
F.peekCWStringLen

-- | Lifted 'F.newCWString'.
--
-- @since 0.2.5.0
{-# INLINE newCWString #-}
newCWString :: MonadIO m => String -> m CWString
newCWString :: forall (m :: * -> *). MonadIO m => String -> m CWString
newCWString = IO CWString -> m CWString
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CWString -> m CWString)
-> (String -> IO CWString) -> String -> m CWString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO CWString
F.newCWString

-- | Lifted 'F.newCWStringLen'.
--
-- @since 0.2.5.0
{-# INLINE newCWStringLen #-}
newCWStringLen :: MonadIO m => String -> m CWStringLen
newCWStringLen :: forall (m :: * -> *). MonadIO m => String -> m CWStringLen
newCWStringLen = IO CWStringLen -> m CWStringLen
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CWStringLen -> m CWStringLen)
-> (String -> IO CWStringLen) -> String -> m CWStringLen
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO CWStringLen
F.newCWStringLen

-- | Unlifted 'F.withCWString'.
--
-- @since 0.2.5.0
{-# INLINE withCWString #-}
withCWString :: MonadUnliftIO m => String -> (CWString -> m a) -> m a
withCWString :: forall (m :: * -> *) a.
MonadUnliftIO m =>
String -> (CWString -> m a) -> m a
withCWString String
str CWString -> m a
f = ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> (CWString -> IO a) -> IO a
forall a. String -> (CWString -> IO a) -> IO a
F.withCWString String
str (m a -> IO a
forall a. m a -> IO a
u (m a -> IO a) -> (CWString -> m a) -> CWString -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CWString -> m a
f))

-- | Unlifted 'F.withCWStringLen'.
--
-- @since 0.2.5.0
{-# INLINE withCWStringLen #-}
withCWStringLen :: MonadUnliftIO m => String -> (CWStringLen -> m a) -> m a
withCWStringLen :: forall (m :: * -> *) a.
MonadUnliftIO m =>
String -> (CWStringLen -> m a) -> m a
withCWStringLen String
str CWStringLen -> m a
f = ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> (CWStringLen -> IO a) -> IO a
forall a. String -> (CWStringLen -> IO a) -> IO a
F.withCWStringLen String
str (m a -> IO a
forall a. m a -> IO a
u (m a -> IO a) -> (CWStringLen -> m a) -> CWStringLen -> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CWStringLen -> m a
f))

-- | Lifted 'F.getErrno'.
--
-- @since 0.2.5.0
{-# INLINE getErrno #-}
getErrno :: MonadIO m => m Errno
getErrno :: forall (m :: * -> *). MonadIO m => m Errno
getErrno = IO Errno -> m Errno
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO Errno
F.getErrno

-- | Lifted 'F.resetErrno'.
--
-- @since 0.2.5.0
{-# INLINE resetErrno #-}
resetErrno :: MonadIO m => m ()
resetErrno :: forall (m :: * -> *). MonadIO m => m ()
resetErrno = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO ()
F.resetErrno

-- | Lifted 'F.throwErrno'.
--
-- @since 0.2.5.0
{-# INLINE throwErrno #-}
throwErrno :: MonadIO m => String -> m a
throwErrno :: forall (m :: * -> *) a. MonadIO m => String -> m a
throwErrno = IO a -> m a
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> m a) -> (String -> IO a) -> String -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO a
forall a. String -> IO a
F.throwErrno

-- | Unlifted 'F.throwErrnoIf'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIf #-}
throwErrnoIf :: MonadUnliftIO m => (a -> Bool) -> String -> m a -> m a
throwErrnoIf :: forall (m :: * -> *) a.
MonadUnliftIO m =>
(a -> Bool) -> String -> m a -> m a
throwErrnoIf a -> Bool
pred_ String
loc m a
f = ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (a -> Bool) -> String -> IO a -> IO a
forall a. (a -> Bool) -> String -> IO a -> IO a
F.throwErrnoIf a -> Bool
pred_ String
loc (m a -> IO a
forall a. m a -> IO a
u m a
f))

-- | Unlifted 'F.throwErrnoIf_'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIf_ #-}
throwErrnoIf_ :: MonadUnliftIO m => (a -> Bool) -> String -> m a -> m ()
throwErrnoIf_ :: forall (m :: * -> *) a.
MonadUnliftIO m =>
(a -> Bool) -> String -> m a -> m ()
throwErrnoIf_ a -> Bool
pred_ String
loc m a
f = ((forall a. m a -> IO a) -> IO ()) -> m ()
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (a -> Bool) -> String -> IO a -> IO ()
forall a. (a -> Bool) -> String -> IO a -> IO ()
F.throwErrnoIf_ a -> Bool
pred_ String
loc (m a -> IO a
forall a. m a -> IO a
u m a
f))

-- | Unlifted 'F.throwErrnoIfRetry'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIfRetry #-}
throwErrnoIfRetry :: MonadUnliftIO m => (a -> Bool) -> String -> m a -> m a
throwErrnoIfRetry :: forall (m :: * -> *) a.
MonadUnliftIO m =>
(a -> Bool) -> String -> m a -> m a
throwErrnoIfRetry a -> Bool
pred_ String
loc m a
f =
  ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (a -> Bool) -> String -> IO a -> IO a
forall a. (a -> Bool) -> String -> IO a -> IO a
F.throwErrnoIfRetry a -> Bool
pred_ String
loc (m a -> IO a
forall a. m a -> IO a
u m a
f))

-- | Unlifted 'F.throwErrnoIfRetry_'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIfRetry_ #-}
throwErrnoIfRetry_ :: MonadUnliftIO m => (a -> Bool) -> String -> m a -> m ()
throwErrnoIfRetry_ :: forall (m :: * -> *) a.
MonadUnliftIO m =>
(a -> Bool) -> String -> m a -> m ()
throwErrnoIfRetry_ a -> Bool
pred_ String
loc m a
f =
  ((forall a. m a -> IO a) -> IO ()) -> m ()
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (a -> Bool) -> String -> IO a -> IO ()
forall a. (a -> Bool) -> String -> IO a -> IO ()
F.throwErrnoIfRetry_ a -> Bool
pred_ String
loc (m a -> IO a
forall a. m a -> IO a
u m a
f))

-- | Unlifted 'F.throwErrnoIfMinus1'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIfMinus1 #-}
throwErrnoIfMinus1 :: (MonadUnliftIO m, Eq a, Num a) => String -> m a -> m a
throwErrnoIfMinus1 :: forall (m :: * -> *) a.
(MonadUnliftIO m, Eq a, Num a) =>
String -> m a -> m a
throwErrnoIfMinus1 String
loc m a
f = ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> IO a -> IO a
forall a. (Eq a, Num a) => String -> IO a -> IO a
F.throwErrnoIfMinus1 String
loc (m a -> IO a
forall a. m a -> IO a
u m a
f))

-- | Unlifted 'F.throwErrnoIfMinus1_'
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIfMinus1_ #-}
throwErrnoIfMinus1_ :: (MonadUnliftIO m, Eq a, Num a) => String -> m a -> m ()
throwErrnoIfMinus1_ :: forall (m :: * -> *) a.
(MonadUnliftIO m, Eq a, Num a) =>
String -> m a -> m ()
throwErrnoIfMinus1_ String
loc m a
f = ((forall a. m a -> IO a) -> IO ()) -> m ()
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> IO a -> IO ()
forall a. (Eq a, Num a) => String -> IO a -> IO ()
F.throwErrnoIfMinus1_ String
loc (m a -> IO a
forall a. m a -> IO a
u m a
f))

-- | Unlifted 'F.throwErrnoIfMinus1Retry'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIfMinus1Retry #-}
throwErrnoIfMinus1Retry ::
     (MonadUnliftIO m, Eq a, Num a) => String -> m a -> m a
throwErrnoIfMinus1Retry :: forall (m :: * -> *) a.
(MonadUnliftIO m, Eq a, Num a) =>
String -> m a -> m a
throwErrnoIfMinus1Retry String
loc m a
f =
  ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> IO a -> IO a
forall a. (Eq a, Num a) => String -> IO a -> IO a
F.throwErrnoIfMinus1Retry String
loc (m a -> IO a
forall a. m a -> IO a
u m a
f))

-- | Unlifted 'F.throwErrnoIfMinus1Retry_'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIfMinus1Retry_ #-}
throwErrnoIfMinus1Retry_ ::
     (MonadUnliftIO m, Eq a, Num a) => String -> m a -> m ()
throwErrnoIfMinus1Retry_ :: forall (m :: * -> *) a.
(MonadUnliftIO m, Eq a, Num a) =>
String -> m a -> m ()
throwErrnoIfMinus1Retry_ String
loc m a
f =
  ((forall a. m a -> IO a) -> IO ()) -> m ()
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> IO a -> IO ()
forall a. (Eq a, Num a) => String -> IO a -> IO ()
F.throwErrnoIfMinus1Retry_ String
loc (m a -> IO a
forall a. m a -> IO a
u m a
f))

-- | Unlifted 'F.throwErrnoIfNull'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIfNull #-}
throwErrnoIfNull :: MonadUnliftIO m => String -> m (Ptr a) -> m (Ptr a)
throwErrnoIfNull :: forall (m :: * -> *) a.
MonadUnliftIO m =>
String -> m (Ptr a) -> m (Ptr a)
throwErrnoIfNull String
loc m (Ptr a)
f = ((forall a. m a -> IO a) -> IO (Ptr a)) -> m (Ptr a)
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> IO (Ptr a) -> IO (Ptr a)
forall a. String -> IO (Ptr a) -> IO (Ptr a)
F.throwErrnoIfNull String
loc (m (Ptr a) -> IO (Ptr a)
forall a. m a -> IO a
u m (Ptr a)
f))

-- | Unlifted 'F.throwErrnoIfNullRetry'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIfNullRetry #-}
throwErrnoIfNullRetry :: MonadUnliftIO m => String -> m (Ptr a) -> m (Ptr a)
throwErrnoIfNullRetry :: forall (m :: * -> *) a.
MonadUnliftIO m =>
String -> m (Ptr a) -> m (Ptr a)
throwErrnoIfNullRetry String
loc m (Ptr a)
f =
  ((forall a. m a -> IO a) -> IO (Ptr a)) -> m (Ptr a)
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> IO (Ptr a) -> IO (Ptr a)
forall a. String -> IO (Ptr a) -> IO (Ptr a)
F.throwErrnoIfNullRetry String
loc (m (Ptr a) -> IO (Ptr a)
forall a. m a -> IO a
u m (Ptr a)
f))

-- | Unlifted 'F.throwErrnoIfRetryMayBlock'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIfRetryMayBlock #-}
throwErrnoIfRetryMayBlock ::
     MonadUnliftIO m => (a -> Bool) -> String -> m a -> m b -> m a
throwErrnoIfRetryMayBlock :: forall (m :: * -> *) a b.
MonadUnliftIO m =>
(a -> Bool) -> String -> m a -> m b -> m a
throwErrnoIfRetryMayBlock a -> Bool
pred_ String
loc m a
f m b
on_block =
  ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (a -> Bool) -> String -> IO a -> IO b -> IO a
forall a b. (a -> Bool) -> String -> IO a -> IO b -> IO a
F.throwErrnoIfRetryMayBlock a -> Bool
pred_ String
loc (m a -> IO a
forall a. m a -> IO a
u m a
f) (m b -> IO b
forall a. m a -> IO a
u m b
on_block))

-- | Unlifted 'F.throwErrnoIfRetryMayBlock_'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIfRetryMayBlock_ #-}
throwErrnoIfRetryMayBlock_ ::
     MonadUnliftIO m => (a -> Bool) -> String -> m a -> m b -> m ()
throwErrnoIfRetryMayBlock_ :: forall (m :: * -> *) a b.
MonadUnliftIO m =>
(a -> Bool) -> String -> m a -> m b -> m ()
throwErrnoIfRetryMayBlock_ a -> Bool
pred_ String
loc m a
f m b
on_block =
  ((forall a. m a -> IO a) -> IO ()) -> m ()
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (a -> Bool) -> String -> IO a -> IO b -> IO ()
forall a b. (a -> Bool) -> String -> IO a -> IO b -> IO ()
F.throwErrnoIfRetryMayBlock_ a -> Bool
pred_ String
loc (m a -> IO a
forall a. m a -> IO a
u m a
f) (m b -> IO b
forall a. m a -> IO a
u m b
on_block))

-- | Unlifted 'F.throwErrnoIfMinus1RetryMayBlock'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIfMinus1RetryMayBlock #-}
throwErrnoIfMinus1RetryMayBlock ::
     (MonadUnliftIO m, Eq a, Num a) => String -> m a -> m b -> m a
throwErrnoIfMinus1RetryMayBlock :: forall (m :: * -> *) a b.
(MonadUnliftIO m, Eq a, Num a) =>
String -> m a -> m b -> m a
throwErrnoIfMinus1RetryMayBlock String
loc m a
f m b
on_block =
  ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> IO a -> IO b -> IO a
forall a b. (Eq a, Num a) => String -> IO a -> IO b -> IO a
F.throwErrnoIfMinus1RetryMayBlock String
loc (m a -> IO a
forall a. m a -> IO a
u m a
f) (m b -> IO b
forall a. m a -> IO a
u m b
on_block))

-- | Unlifted 'F.throwErrnoIfMinus1RetryMayBlock_'
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIfMinus1RetryMayBlock_ #-}
throwErrnoIfMinus1RetryMayBlock_ ::
     (MonadUnliftIO m, Eq a, Num a) => String -> m a -> m b -> m ()
throwErrnoIfMinus1RetryMayBlock_ :: forall (m :: * -> *) a b.
(MonadUnliftIO m, Eq a, Num a) =>
String -> m a -> m b -> m ()
throwErrnoIfMinus1RetryMayBlock_ String
loc m a
f m b
on_block =
  ((forall a. m a -> IO a) -> IO ()) -> m ()
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> IO a -> IO b -> IO ()
forall a b. (Eq a, Num a) => String -> IO a -> IO b -> IO ()
F.throwErrnoIfMinus1RetryMayBlock_ String
loc (m a -> IO a
forall a. m a -> IO a
u m a
f) (m b -> IO b
forall a. m a -> IO a
u m b
on_block))

-- | Unlifted 'F.throwErrnoIfNullRetryMayBlock'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoIfNullRetryMayBlock #-}
throwErrnoIfNullRetryMayBlock ::
     MonadUnliftIO m => String -> m (Ptr a) -> m b -> m (Ptr a)
throwErrnoIfNullRetryMayBlock :: forall (m :: * -> *) a b.
MonadUnliftIO m =>
String -> m (Ptr a) -> m b -> m (Ptr a)
throwErrnoIfNullRetryMayBlock String
loc m (Ptr a)
f m b
on_block =
  ((forall a. m a -> IO a) -> IO (Ptr a)) -> m (Ptr a)
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> IO (Ptr a) -> IO b -> IO (Ptr a)
forall a b. String -> IO (Ptr a) -> IO b -> IO (Ptr a)
F.throwErrnoIfNullRetryMayBlock String
loc (m (Ptr a) -> IO (Ptr a)
forall a. m a -> IO a
u m (Ptr a)
f) (m b -> IO b
forall a. m a -> IO a
u m b
on_block))

-- | Lifted 'F.throwErrnoPath'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoPath #-}
throwErrnoPath :: MonadIO m => String -> FilePath -> m a
throwErrnoPath :: forall (m :: * -> *) a. MonadIO m => String -> String -> m a
throwErrnoPath String
loc String
path = IO a -> m a
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (String -> String -> IO a
forall a. String -> String -> IO a
F.throwErrnoPath String
loc String
path)

-- | Unlifted 'F.throwErrnoPathIf'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoPathIf #-}
throwErrnoPathIf ::
     MonadUnliftIO m => (a -> Bool) -> String -> FilePath -> m a -> m a
throwErrnoPathIf :: forall (m :: * -> *) a.
MonadUnliftIO m =>
(a -> Bool) -> String -> String -> m a -> m a
throwErrnoPathIf a -> Bool
pred_ String
loc String
path m a
f =
  ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (a -> Bool) -> String -> String -> IO a -> IO a
forall a. (a -> Bool) -> String -> String -> IO a -> IO a
F.throwErrnoPathIf a -> Bool
pred_ String
loc String
path (m a -> IO a
forall a. m a -> IO a
u m a
f))

-- | Unlifted 'F.throwErrnoPathIf_'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoPathIf_ #-}
throwErrnoPathIf_ ::
     MonadUnliftIO m => (a -> Bool) -> String -> FilePath -> m a -> m ()
throwErrnoPathIf_ :: forall (m :: * -> *) a.
MonadUnliftIO m =>
(a -> Bool) -> String -> String -> m a -> m ()
throwErrnoPathIf_ a -> Bool
pred_ String
loc String
path m a
f =
  ((forall a. m a -> IO a) -> IO ()) -> m ()
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (a -> Bool) -> String -> String -> IO a -> IO ()
forall a. (a -> Bool) -> String -> String -> IO a -> IO ()
F.throwErrnoPathIf_ a -> Bool
pred_ String
loc String
path (m a -> IO a
forall a. m a -> IO a
u m a
f))

-- | Unlifted 'F.throwErrnoPathIfNull'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoPathIfNull #-}
throwErrnoPathIfNull ::
     MonadUnliftIO m => String -> FilePath -> m (Ptr a) -> m (Ptr a)
throwErrnoPathIfNull :: forall (m :: * -> *) a.
MonadUnliftIO m =>
String -> String -> m (Ptr a) -> m (Ptr a)
throwErrnoPathIfNull String
loc String
path m (Ptr a)
f =
  ((forall a. m a -> IO a) -> IO (Ptr a)) -> m (Ptr a)
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> String -> IO (Ptr a) -> IO (Ptr a)
forall a. String -> String -> IO (Ptr a) -> IO (Ptr a)
F.throwErrnoPathIfNull String
loc String
path (m (Ptr a) -> IO (Ptr a)
forall a. m a -> IO a
u m (Ptr a)
f))

-- | Unlifted 'F.throwErrnoPathIfMinus1'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoPathIfMinus1 #-}
throwErrnoPathIfMinus1 ::
     (MonadUnliftIO m, Eq a, Num a) => String -> FilePath -> m a -> m a
throwErrnoPathIfMinus1 :: forall (m :: * -> *) a.
(MonadUnliftIO m, Eq a, Num a) =>
String -> String -> m a -> m a
throwErrnoPathIfMinus1 String
loc String
path m a
f =
  ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> String -> IO a -> IO a
forall a. (Eq a, Num a) => String -> String -> IO a -> IO a
F.throwErrnoPathIfMinus1 String
loc String
path (m a -> IO a
forall a. m a -> IO a
u m a
f))

-- | Unlifted 'F.throwErrnoPathIfMinus1_'.
--
-- @since 0.2.5.0
{-# INLINE throwErrnoPathIfMinus1_ #-}
throwErrnoPathIfMinus1_ ::
     (MonadUnliftIO m, Eq a, Num a) => String -> FilePath -> m a -> m ()
throwErrnoPathIfMinus1_ :: forall (m :: * -> *) a.
(MonadUnliftIO m, Eq a, Num a) =>
String -> String -> m a -> m ()
throwErrnoPathIfMinus1_ String
loc String
path m a
f =
  ((forall a. m a -> IO a) -> IO ()) -> m ()
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> String -> IO a -> IO ()
forall a. (Eq a, Num a) => String -> String -> IO a -> IO ()
F.throwErrnoPathIfMinus1_ String
loc String
path (m a -> IO a
forall a. m a -> IO a
u m a
f))

-- | Lifted 'F.freeHaskellFunPtr'.
--
-- @since 0.2.5.0
{-# INLINE freeHaskellFunPtr #-}
freeHaskellFunPtr :: MonadIO m => FunPtr a -> m ()
freeHaskellFunPtr :: forall (m :: * -> *) a. MonadIO m => FunPtr a -> m ()
freeHaskellFunPtr = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (FunPtr a -> IO ()) -> FunPtr a -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FunPtr a -> IO ()
forall a. FunPtr a -> IO ()
F.freeHaskellFunPtr

-- | Lifted 'F.newForeignPtr'.
--
-- @since 0.2.5.0
{-# INLINE newForeignPtr #-}
newForeignPtr :: MonadIO m => FinalizerPtr a -> Ptr a -> m (ForeignPtr a)
newForeignPtr :: forall (m :: * -> *) a.
MonadIO m =>
FinalizerPtr a -> Ptr a -> m (ForeignPtr a)
newForeignPtr FinalizerPtr a
finalizer Ptr a
p = IO (ForeignPtr a) -> m (ForeignPtr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
F.newForeignPtr FinalizerPtr a
finalizer Ptr a
p)

-- | Lifted 'F.newForeignPtr_'.
--
-- @since 0.2.5.0
{-# INLINE newForeignPtr_ #-}
newForeignPtr_ :: MonadIO m => Ptr a -> m (ForeignPtr a)
newForeignPtr_ :: forall (m :: * -> *) a. MonadIO m => Ptr a -> m (ForeignPtr a)
newForeignPtr_ = IO (ForeignPtr a) -> m (ForeignPtr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (ForeignPtr a) -> m (ForeignPtr a))
-> (Ptr a -> IO (ForeignPtr a)) -> Ptr a -> m (ForeignPtr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> IO (ForeignPtr a)
forall a. Ptr a -> IO (ForeignPtr a)
F.newForeignPtr_

-- | Lifted 'F.addForeignPtrFinalizer'.
--
-- @since 0.2.5.0
{-# INLINE addForeignPtrFinalizer #-}
addForeignPtrFinalizer :: MonadIO m => FinalizerPtr a -> ForeignPtr a -> m ()
addForeignPtrFinalizer :: forall (m :: * -> *) a.
MonadIO m =>
FinalizerPtr a -> ForeignPtr a -> m ()
addForeignPtrFinalizer FinalizerPtr a
finalizer_ptr ForeignPtr a
foreign_ptr =
  IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (FinalizerPtr a -> ForeignPtr a -> IO ()
forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
F.addForeignPtrFinalizer FinalizerPtr a
finalizer_ptr ForeignPtr a
foreign_ptr)

-- | Lifted 'F.newForeignPtrEnv'.
--
-- @since 0.2.5.0
{-# INLINE newForeignPtrEnv #-}
newForeignPtrEnv ::
     MonadIO m => FinalizerEnvPtr env a -> Ptr env -> Ptr a -> m (ForeignPtr a)
newForeignPtrEnv :: forall (m :: * -> *) env a.
MonadIO m =>
FinalizerEnvPtr env a -> Ptr env -> Ptr a -> m (ForeignPtr a)
newForeignPtrEnv FinalizerEnvPtr env a
finalizer Ptr env
env Ptr a
p = IO (ForeignPtr a) -> m (ForeignPtr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (FinalizerEnvPtr env a -> Ptr env -> Ptr a -> IO (ForeignPtr a)
forall env a.
FinalizerEnvPtr env a -> Ptr env -> Ptr a -> IO (ForeignPtr a)
F.newForeignPtrEnv FinalizerEnvPtr env a
finalizer Ptr env
env Ptr a
p)

-- | Lifted 'F.addForeignPtrFinalizerEnv'.
--
-- @since 0.2.5.0
{-# INLINE addForeignPtrFinalizerEnv #-}
addForeignPtrFinalizerEnv ::
     MonadIO m => FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> m ()
addForeignPtrFinalizerEnv :: forall (m :: * -> *) env a.
MonadIO m =>
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> m ()
addForeignPtrFinalizerEnv FinalizerEnvPtr env a
finalizer Ptr env
env ForeignPtr a
fp =
  IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
F.addForeignPtrFinalizerEnv FinalizerEnvPtr env a
finalizer Ptr env
env ForeignPtr a
fp)

-- | Unlifted 'F.withForeignPtr'.
--
-- @since 0.2.5.0
{-# INLINE withForeignPtr #-}
withForeignPtr :: MonadUnliftIO m => ForeignPtr a -> (Ptr a -> m b) -> m b
withForeignPtr :: forall (m :: * -> *) a b.
MonadUnliftIO m =>
ForeignPtr a -> (Ptr a -> m b) -> m b
withForeignPtr ForeignPtr a
fo Ptr a -> m b
io = ((forall a. m a -> IO a) -> IO b) -> m b
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> ForeignPtr a -> (Ptr a -> IO b) -> IO b
forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
F.withForeignPtr ForeignPtr a
fo (m b -> IO b
forall a. m a -> IO a
u (m b -> IO b) -> (Ptr a -> m b) -> Ptr a -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
io))

-- | Lifted 'F.finalizeForeignPtr'.
--
-- @since 0.2.5.0
{-# INLINE finalizeForeignPtr #-}
finalizeForeignPtr :: MonadIO m => ForeignPtr a -> m ()
finalizeForeignPtr :: forall (m :: * -> *) a. MonadIO m => ForeignPtr a -> m ()
finalizeForeignPtr = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (ForeignPtr a -> IO ()) -> ForeignPtr a -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ForeignPtr a -> IO ()
forall a. ForeignPtr a -> IO ()
F.finalizeForeignPtr

-- | Lifted 'F.touchForeignPtr'.
--
-- @since 0.2.5.0
{-# INLINE touchForeignPtr #-}
touchForeignPtr :: MonadIO m => ForeignPtr a -> m ()
touchForeignPtr :: forall (m :: * -> *) a. MonadIO m => ForeignPtr a -> m ()
touchForeignPtr = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (ForeignPtr a -> IO ()) -> ForeignPtr a -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ForeignPtr a -> IO ()
forall a. ForeignPtr a -> IO ()
F.touchForeignPtr

-- | Lifted 'F.mallocForeignPtr'.
--
-- @since 0.2.5.0
{-# INLINE mallocForeignPtr #-}
mallocForeignPtr :: (MonadIO m, Storable a) => m (ForeignPtr a)
mallocForeignPtr :: forall (m :: * -> *) a. (MonadIO m, Storable a) => m (ForeignPtr a)
mallocForeignPtr = IO (ForeignPtr a) -> m (ForeignPtr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO (ForeignPtr a)
forall a. Storable a => IO (ForeignPtr a)
F.mallocForeignPtr

-- | Lifted 'F.mallocForeignPtrBytes'.
--
-- @since 0.2.5.0
{-# INLINE mallocForeignPtrBytes #-}
mallocForeignPtrBytes :: MonadIO m => Int -> m (ForeignPtr a)
mallocForeignPtrBytes :: forall (m :: * -> *) a. MonadIO m => Int -> m (ForeignPtr a)
mallocForeignPtrBytes = IO (ForeignPtr a) -> m (ForeignPtr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (ForeignPtr a) -> m (ForeignPtr a))
-> (Int -> IO (ForeignPtr a)) -> Int -> m (ForeignPtr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO (ForeignPtr a)
forall a. Int -> IO (ForeignPtr a)
F.mallocForeignPtrBytes

-- | Lifted 'F.mallocForeignPtrArray'.
--
-- @since 0.2.5.0
{-# INLINE mallocForeignPtrArray #-}
mallocForeignPtrArray :: (MonadIO m, Storable a) => Int -> m (ForeignPtr a)
mallocForeignPtrArray :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> m (ForeignPtr a)
mallocForeignPtrArray = IO (ForeignPtr a) -> m (ForeignPtr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (ForeignPtr a) -> m (ForeignPtr a))
-> (Int -> IO (ForeignPtr a)) -> Int -> m (ForeignPtr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO (ForeignPtr a)
forall a. Storable a => Int -> IO (ForeignPtr a)
F.mallocForeignPtrArray

-- | Lifted 'F.mallocForeignPtrArray0'.
--
-- @since 0.2.5.0
{-# INLINE mallocForeignPtrArray0 #-}
mallocForeignPtrArray0 :: (MonadIO m, Storable a) => Int -> m (ForeignPtr a)
mallocForeignPtrArray0 :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> m (ForeignPtr a)
mallocForeignPtrArray0 = IO (ForeignPtr a) -> m (ForeignPtr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (ForeignPtr a) -> m (ForeignPtr a))
-> (Int -> IO (ForeignPtr a)) -> Int -> m (ForeignPtr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO (ForeignPtr a)
forall a. Storable a => Int -> IO (ForeignPtr a)
F.mallocForeignPtrArray0

-- | Unlifted 'FC.newForeignPtr'.
--
-- @since 0.2.5.0
{-# INLINE newGHCForeignPtr #-}
newGHCForeignPtr :: MonadUnliftIO m => Ptr a -> m () -> m (ForeignPtr a)
newGHCForeignPtr :: forall (m :: * -> *) a.
MonadUnliftIO m =>
Ptr a -> m () -> m (ForeignPtr a)
newGHCForeignPtr Ptr a
ptr m ()
f = ((forall a. m a -> IO a) -> IO (ForeignPtr a)) -> m (ForeignPtr a)
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> Ptr a -> IO () -> IO (ForeignPtr a)
forall a. Ptr a -> IO () -> IO (ForeignPtr a)
FC.newForeignPtr Ptr a
ptr (m () -> IO ()
forall a. m a -> IO a
u m ()
f))

-- | Unlifted 'FC.addForeignPtrFinalizer'.
--
-- @since 0.2.5.0
{-# INLINE addGHCForeignPtrFinalizer #-}
addGHCForeignPtrFinalizer :: MonadUnliftIO m => ForeignPtr a -> m () -> m ()
addGHCForeignPtrFinalizer :: forall (m :: * -> *) a.
MonadUnliftIO m =>
ForeignPtr a -> m () -> m ()
addGHCForeignPtrFinalizer ForeignPtr a
fptr m ()
f =
  ((forall a. m a -> IO a) -> IO ()) -> m ()
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> ForeignPtr a -> IO () -> IO ()
forall a. ForeignPtr a -> IO () -> IO ()
FC.addForeignPtrFinalizer ForeignPtr a
fptr (m () -> IO ()
forall a. m a -> IO a
u m ()
f))

-- | Lifted 'F.newStablePtr'.
--
-- @since 0.2.5.0
{-# INLINE newStablePtr #-}
newStablePtr :: MonadIO m => a -> m (StablePtr a)
newStablePtr :: forall (m :: * -> *) a. MonadIO m => a -> m (StablePtr a)
newStablePtr = IO (StablePtr a) -> m (StablePtr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (StablePtr a) -> m (StablePtr a))
-> (a -> IO (StablePtr a)) -> a -> m (StablePtr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> IO (StablePtr a)
forall a. a -> IO (StablePtr a)
F.newStablePtr

-- | Lifted 'F.deRefStablePtr'.
--
-- @since 0.2.5.0
{-# INLINE deRefStablePtr #-}
deRefStablePtr :: MonadIO m => StablePtr a -> m a
deRefStablePtr :: forall (m :: * -> *) a. MonadIO m => StablePtr a -> m a
deRefStablePtr = IO a -> m a
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> m a) -> (StablePtr a -> IO a) -> StablePtr a -> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StablePtr a -> IO a
forall a. StablePtr a -> IO a
F.deRefStablePtr

-- | Lifted 'F.freeStablePtr'.
--
-- @since 0.2.5.0
{-# INLINE freeStablePtr #-}
freeStablePtr :: MonadIO m => StablePtr a -> m ()
freeStablePtr :: forall (m :: * -> *) a. MonadIO m => StablePtr a -> m ()
freeStablePtr = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (StablePtr a -> IO ()) -> StablePtr a -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StablePtr a -> IO ()
forall a. StablePtr a -> IO ()
F.freeStablePtr

-- | Unlifted 'F.alloca'.
--
-- @since 0.2.5.0
{-# INLINE alloca #-}
alloca :: (MonadUnliftIO m, Storable a) => (Ptr a -> m b) -> m b
alloca :: forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
(Ptr a -> m b) -> m b
alloca Ptr a -> m b
action = ((forall a. m a -> IO a) -> IO b) -> m b
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (Ptr a -> IO b) -> IO b
forall a b. Storable a => (Ptr a -> IO b) -> IO b
F.alloca (m b -> IO b
forall a. m a -> IO a
u (m b -> IO b) -> (Ptr a -> m b) -> Ptr a -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))

-- | Unlifted 'F.allocaBytes'.
--
-- @since 0.2.5.0
{-# INLINE allocaBytes #-}
allocaBytes :: MonadUnliftIO m => Int -> (Ptr a -> m b) -> m b
allocaBytes :: forall (m :: * -> *) a b.
MonadUnliftIO m =>
Int -> (Ptr a -> m b) -> m b
allocaBytes Int
size Ptr a -> m b
action = ((forall a. m a -> IO a) -> IO b) -> m b
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> Int -> (Ptr a -> IO b) -> IO b
forall a b. Int -> (Ptr a -> IO b) -> IO b
F.allocaBytes Int
size (m b -> IO b
forall a. m a -> IO a
u (m b -> IO b) -> (Ptr a -> m b) -> Ptr a -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))

-- | Unlifted 'F.allocaBytesAligned'.
--
-- @since 0.2.5.0
{-# INLINE allocaBytesAligned #-}
allocaBytesAligned :: MonadUnliftIO m => Int -> Int -> (Ptr a -> m b) -> m b
allocaBytesAligned :: forall (m :: * -> *) a b.
MonadUnliftIO m =>
Int -> Int -> (Ptr a -> m b) -> m b
allocaBytesAligned Int
size Int
align Ptr a -> m b
action =
  ((forall a. m a -> IO a) -> IO b) -> m b
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> Int -> Int -> (Ptr a -> IO b) -> IO b
forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
F.allocaBytesAligned Int
size Int
align (m b -> IO b
forall a. m a -> IO a
u (m b -> IO b) -> (Ptr a -> m b) -> Ptr a -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))

-- | Lifted 'F.malloc'.
--
-- @since 0.2.5.0
{-# INLINE malloc #-}
malloc :: (MonadIO m, Storable a) => m (Ptr a)
malloc :: forall (m :: * -> *) a. (MonadIO m, Storable a) => m (Ptr a)
malloc = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO (Ptr a)
forall a. Storable a => IO (Ptr a)
F.malloc

-- | Lifted 'F.mallocBytes'.
--
-- @since 0.2.5.0
{-# INLINE mallocBytes #-}
mallocBytes :: MonadIO m => Int -> m (Ptr a)
mallocBytes :: forall (m :: * -> *) a. MonadIO m => Int -> m (Ptr a)
mallocBytes = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr a) -> m (Ptr a))
-> (Int -> IO (Ptr a)) -> Int -> m (Ptr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO (Ptr a)
forall a. Int -> IO (Ptr a)
F.mallocBytes

#if MIN_VERSION_base(4,8,0)
-- | Lifted 'F.calloc'.
--
-- @since 0.2.5.0
{-# INLINE calloc #-}
calloc :: (MonadIO m, Storable a) => m (Ptr a)
calloc :: forall (m :: * -> *) a. (MonadIO m, Storable a) => m (Ptr a)
calloc = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO (Ptr a)
forall a. Storable a => IO (Ptr a)
F.calloc

-- | Lifted 'F.callocBytes'.
--
-- @since 0.2.5.0
{-# INLINE callocBytes #-}
callocBytes :: MonadIO m => Int -> m (Ptr a)
callocBytes :: forall (m :: * -> *) a. MonadIO m => Int -> m (Ptr a)
callocBytes = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr a) -> m (Ptr a))
-> (Int -> IO (Ptr a)) -> Int -> m (Ptr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO (Ptr a)
forall a. Int -> IO (Ptr a)
F.callocBytes
#endif

-- | Lifted 'F.realloc'.
--
-- @since 0.2.5.0
{-# INLINE realloc #-}
realloc :: (MonadIO m, Storable b) => Ptr a -> m (Ptr b)
realloc :: forall (m :: * -> *) b a.
(MonadIO m, Storable b) =>
Ptr a -> m (Ptr b)
realloc = IO (Ptr b) -> m (Ptr b)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr b) -> m (Ptr b))
-> (Ptr a -> IO (Ptr b)) -> Ptr a -> m (Ptr b)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> IO (Ptr b)
forall a b. Storable b => Ptr a -> IO (Ptr b)
F.realloc

-- | Lifted 'F.reallocBytes'.
--
-- @since 0.2.5.0
{-# INLINE reallocBytes #-}
reallocBytes :: MonadIO m => Ptr a -> Int -> m (Ptr a)
reallocBytes :: forall (m :: * -> *) a. MonadIO m => Ptr a -> Int -> m (Ptr a)
reallocBytes Ptr a
ptr Int
size = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Ptr a -> Int -> IO (Ptr a)
forall a. Ptr a -> Int -> IO (Ptr a)
F.reallocBytes Ptr a
ptr Int
size)

-- | Lifted 'F.free'.
--
-- @since 0.2.5.0
{-# INLINE free #-}
free :: MonadIO m => Ptr a -> m ()
free :: forall (m :: * -> *) a. MonadIO m => Ptr a -> m ()
free = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (Ptr a -> IO ()) -> Ptr a -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> IO ()
forall a. Ptr a -> IO ()
F.free

-- | Lifted 'F.mallocArray'.
--
-- @since 0.2.5.0
{-# INLINE mallocArray #-}
mallocArray :: (MonadIO m, Storable a) => Int -> m (Ptr a)
mallocArray :: forall (m :: * -> *) a. (MonadIO m, Storable a) => Int -> m (Ptr a)
mallocArray = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr a) -> m (Ptr a))
-> (Int -> IO (Ptr a)) -> Int -> m (Ptr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO (Ptr a)
forall a. Storable a => Int -> IO (Ptr a)
F.mallocArray

-- | Lifted 'F.mallocArray0'.
--
-- @since 0.2.5.0
{-# INLINE mallocArray0 #-}
mallocArray0 :: (MonadIO m, Storable a) => Int -> m (Ptr a)
mallocArray0 :: forall (m :: * -> *) a. (MonadIO m, Storable a) => Int -> m (Ptr a)
mallocArray0 = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr a) -> m (Ptr a))
-> (Int -> IO (Ptr a)) -> Int -> m (Ptr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO (Ptr a)
forall a. Storable a => Int -> IO (Ptr a)
F.mallocArray

-- | Unlifted 'F.allocaArray'.
--
-- @since 0.2.5.0
{-# INLINE allocaArray #-}
allocaArray :: (MonadUnliftIO m, Storable a) => Int -> (Ptr a -> m b) -> m b
allocaArray :: forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
Int -> (Ptr a -> m b) -> m b
allocaArray Int
size Ptr a -> m b
action = ((forall a. m a -> IO a) -> IO b) -> m b
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> Int -> (Ptr a -> IO b) -> IO b
forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
F.allocaArray Int
size (m b -> IO b
forall a. m a -> IO a
u (m b -> IO b) -> (Ptr a -> m b) -> Ptr a -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))

-- | Unlifted 'F.allocaArray0'.
--
-- @since 0.2.5.0
{-# INLINE allocaArray0 #-}
allocaArray0 :: (MonadUnliftIO m, Storable a) => Int -> (Ptr a -> m b) -> m b
allocaArray0 :: forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
Int -> (Ptr a -> m b) -> m b
allocaArray0 Int
size Ptr a -> m b
action = ((forall a. m a -> IO a) -> IO b) -> m b
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> Int -> (Ptr a -> IO b) -> IO b
forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
F.allocaArray0 Int
size (m b -> IO b
forall a. m a -> IO a
u (m b -> IO b) -> (Ptr a -> m b) -> Ptr a -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))

-- | Lifted 'F.reallocArray'.
--
-- @since 0.2.5.0
{-# INLINE reallocArray #-}
reallocArray :: (MonadIO m, Storable a) => Ptr a -> Int -> m (Ptr a)
reallocArray :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Ptr a -> Int -> m (Ptr a)
reallocArray Ptr a
ptr Int
size = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Ptr a -> Int -> IO (Ptr a)
forall a. Storable a => Ptr a -> Int -> IO (Ptr a)
F.reallocArray Ptr a
ptr Int
size)

-- | Lifted 'F.reallocArray0'.
--
-- @since 0.2.5.0
{-# INLINE reallocArray0 #-}
reallocArray0 :: (MonadIO m, Storable a) => Ptr a -> Int -> m (Ptr a)
reallocArray0 :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Ptr a -> Int -> m (Ptr a)
reallocArray0 Ptr a
ptr Int
size = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Ptr a -> Int -> IO (Ptr a)
forall a. Storable a => Ptr a -> Int -> IO (Ptr a)
F.reallocArray0 Ptr a
ptr Int
size)

#if MIN_VERSION_base(4,8,0)
-- | Lifted 'F.callocArray'.
--
-- @since 0.2.5.0
{-# INLINE callocArray #-}
callocArray :: (MonadIO m, Storable a) => Int -> m (Ptr a)
callocArray :: forall (m :: * -> *) a. (MonadIO m, Storable a) => Int -> m (Ptr a)
callocArray = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr a) -> m (Ptr a))
-> (Int -> IO (Ptr a)) -> Int -> m (Ptr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO (Ptr a)
forall a. Storable a => Int -> IO (Ptr a)
F.callocArray

-- | Lifted 'F.callocArray0'.
--
-- @since 0.2.5.0
{-# INLINE callocArray0 #-}
callocArray0 :: (MonadIO m, Storable a) => Int -> m (Ptr a)
callocArray0 :: forall (m :: * -> *) a. (MonadIO m, Storable a) => Int -> m (Ptr a)
callocArray0 = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr a) -> m (Ptr a))
-> (Int -> IO (Ptr a)) -> Int -> m (Ptr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> IO (Ptr a)
forall a. Storable a => Int -> IO (Ptr a)
F.callocArray0
#endif

-- | Lifted 'F.peekArray'.
--
-- @since 0.2.5.0
{-# INLINE peekArray #-}
peekArray :: (MonadIO m, Storable a) => Int -> Ptr a -> m [a]
peekArray :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> Ptr a -> m [a]
peekArray Int
size Ptr a
ptr = IO [a] -> m [a]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Int -> Ptr a -> IO [a]
forall a. Storable a => Int -> Ptr a -> IO [a]
F.peekArray Int
size Ptr a
ptr)

-- | Lifted 'F.peekArray0'.
--
-- @since 0.2.5.0
{-# INLINE peekArray0 #-}
peekArray0 :: (MonadIO m, Storable a, Eq a) => a -> Ptr a -> m [a]
peekArray0 :: forall (m :: * -> *) a.
(MonadIO m, Storable a, Eq a) =>
a -> Ptr a -> m [a]
peekArray0 a
marker Ptr a
ptr = IO [a] -> m [a]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (a -> Ptr a -> IO [a]
forall a. (Storable a, Eq a) => a -> Ptr a -> IO [a]
F.peekArray0 a
marker Ptr a
ptr)

-- | Lifted 'F.pokeArray'.
--
-- @since 0.2.5.0
{-# INLINE pokeArray #-}
pokeArray :: (MonadIO m, Storable a) => Ptr a -> [a] -> m ()
pokeArray :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Ptr a -> [a] -> m ()
pokeArray Ptr a
ptr [a]
vals0 = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Ptr a -> [a] -> IO ()
forall a. Storable a => Ptr a -> [a] -> IO ()
F.pokeArray Ptr a
ptr [a]
vals0)

-- | Lifted 'F.pokeArray0'.
--
-- @since 0.2.5.0
{-# INLINE pokeArray0 #-}
pokeArray0 :: (MonadIO m, Storable a) => a -> Ptr a -> [a] -> m ()
pokeArray0 :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
a -> Ptr a -> [a] -> m ()
pokeArray0 a
marker Ptr a
ptr [a]
vals0 = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (a -> Ptr a -> [a] -> IO ()
forall a. Storable a => a -> Ptr a -> [a] -> IO ()
F.pokeArray0 a
marker Ptr a
ptr [a]
vals0)

-- | Lifted 'F.newArray'.
--
-- @since 0.2.5.0
{-# INLINE newArray #-}
newArray :: (MonadIO m, Storable a) => [a] -> m (Ptr a)
newArray :: forall (m :: * -> *) a. (MonadIO m, Storable a) => [a] -> m (Ptr a)
newArray = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr a) -> m (Ptr a))
-> ([a] -> IO (Ptr a)) -> [a] -> m (Ptr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [a] -> IO (Ptr a)
forall a. Storable a => [a] -> IO (Ptr a)
F.newArray

-- | Lifted 'F.newArray0'
--
-- @since 0.2.5.0
{-# INLINE newArray0 #-}
newArray0 :: (MonadIO m, Storable a) => a -> [a] -> m (Ptr a)
newArray0 :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
a -> [a] -> m (Ptr a)
newArray0 a
marker [a]
vals = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (a -> [a] -> IO (Ptr a)
forall a. Storable a => a -> [a] -> IO (Ptr a)
F.newArray0 a
marker [a]
vals)

-- | Unlifted 'F.withArray'.
--
-- @since 0.2.5.0
{-# INLINE withArray #-}
withArray :: (MonadUnliftIO m, Storable a) => [a] -> (Ptr a -> m b) -> m b
withArray :: forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (Ptr a -> m b) -> m b
withArray [a]
vals Ptr a -> m b
action = ((forall a. m a -> IO a) -> IO b) -> m b
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> [a] -> (Ptr a -> IO b) -> IO b
forall a b. Storable a => [a] -> (Ptr a -> IO b) -> IO b
F.withArray [a]
vals (m b -> IO b
forall a. m a -> IO a
u (m b -> IO b) -> (Ptr a -> m b) -> Ptr a -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))

-- | Unlifted 'F.withArray0'.
--
-- @since 0.2.5.0
{-# INLINE withArray0 #-}
withArray0 :: (MonadUnliftIO m, Storable a) => a -> [a] -> (Ptr a -> m b) -> m b
withArray0 :: forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> [a] -> (Ptr a -> m b) -> m b
withArray0 a
marker [a]
vals Ptr a -> m b
action =
  ((forall a. m a -> IO a) -> IO b) -> m b
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> a -> [a] -> (Ptr a -> IO b) -> IO b
forall a b. Storable a => a -> [a] -> (Ptr a -> IO b) -> IO b
F.withArray0 a
marker [a]
vals (m b -> IO b
forall a. m a -> IO a
u (m b -> IO b) -> (Ptr a -> m b) -> Ptr a -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))

-- | Unlifted 'F.withArrayLen'.
--
-- @since 0.2.5.0
{-# INLINE withArrayLen #-}
withArrayLen ::
     (MonadUnliftIO m, Storable a) => [a] -> (Int -> Ptr a -> m b) -> m b
withArrayLen :: forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (Int -> Ptr a -> m b) -> m b
withArrayLen [a]
vals Int -> Ptr a -> m b
f =
  ((forall a. m a -> IO a) -> IO b) -> m b
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> [a] -> (Int -> Ptr a -> IO b) -> IO b
forall a b. Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b
F.withArrayLen [a]
vals (\Int
s Ptr a
p -> m b -> IO b
forall a. m a -> IO a
u (Int -> Ptr a -> m b
f Int
s Ptr a
p)))

-- | Unlifted 'F.withArrayLen0'.
--
-- @since 0.2.5.0
{-# INLINE withArrayLen0 #-}
withArrayLen0 ::
     (MonadUnliftIO m, Storable a) => a -> [a] -> (Int -> Ptr a -> m b) -> m b
withArrayLen0 :: forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> [a] -> (Int -> Ptr a -> m b) -> m b
withArrayLen0 a
marker [a]
vals Int -> Ptr a -> m b
f =
  ((forall a. m a -> IO a) -> IO b) -> m b
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> a -> [a] -> (Int -> Ptr a -> IO b) -> IO b
forall a b.
Storable a =>
a -> [a] -> (Int -> Ptr a -> IO b) -> IO b
F.withArrayLen0 a
marker [a]
vals (\Int
s Ptr a
p -> m b -> IO b
forall a. m a -> IO a
u (Int -> Ptr a -> m b
f Int
s Ptr a
p)))

-- | Lifted 'F.copyArray'.
--
-- @since 0.2.5.0
{-# INLINE copyArray #-}
copyArray :: (MonadIO m, Storable a) => Ptr a -> Ptr a -> Int -> m ()
copyArray :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Ptr a -> Ptr a -> Int -> m ()
copyArray Ptr a
dest Ptr a
src Int
size = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Ptr a -> Ptr a -> Int -> IO ()
forall a. Storable a => Ptr a -> Ptr a -> Int -> IO ()
F.copyArray Ptr a
dest Ptr a
src Int
size)

-- | Lifted 'F.moveArray'.
--
-- @since 0.2.5.0
{-# INLINE moveArray #-}
moveArray :: (MonadIO m, Storable a) => Ptr a -> Ptr a -> Int -> m ()
moveArray :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Ptr a -> Ptr a -> Int -> m ()
moveArray Ptr a
dest Ptr a
src Int
size = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Ptr a -> Ptr a -> Int -> IO ()
forall a. Storable a => Ptr a -> Ptr a -> Int -> IO ()
F.moveArray Ptr a
dest Ptr a
src Int
size)

-- | Lifted 'F.lengthArray0'.
--
-- @since 0.2.5.0
{-# INLINE lengthArray0 #-}
lengthArray0 :: (MonadIO m, Storable a, Eq a) => a -> Ptr a -> m Int
lengthArray0 :: forall (m :: * -> *) a.
(MonadIO m, Storable a, Eq a) =>
a -> Ptr a -> m Int
lengthArray0 a
marker Ptr a
ptr = IO Int -> m Int
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (a -> Ptr a -> IO Int
forall a. (Storable a, Eq a) => a -> Ptr a -> IO Int
F.lengthArray0 a
marker Ptr a
ptr)

-- | Unlifted 'F.throwIf'.
--
-- @since 0.2.5.0
{-# INLINE throwIf #-}
throwIf :: MonadUnliftIO m => (a -> Bool) -> (a -> String) -> m a -> m a
throwIf :: forall (m :: * -> *) a.
MonadUnliftIO m =>
(a -> Bool) -> (a -> String) -> m a -> m a
throwIf a -> Bool
pred_ a -> String
msgfct m a
act = ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (a -> Bool) -> (a -> String) -> IO a -> IO a
forall a. (a -> Bool) -> (a -> String) -> IO a -> IO a
F.throwIf a -> Bool
pred_ a -> String
msgfct (m a -> IO a
forall a. m a -> IO a
u m a
act))

-- | Unlifted 'F.throwIf_'.
--
-- @since 0.2.5.0
{-# INLINE throwIf_ #-}
throwIf_ :: MonadUnliftIO m => (a -> Bool) -> (a -> String) -> m a -> m ()
throwIf_ :: forall (m :: * -> *) a.
MonadUnliftIO m =>
(a -> Bool) -> (a -> String) -> m a -> m ()
throwIf_ a -> Bool
pred_ a -> String
msgfct m a
act = ((forall a. m a -> IO a) -> IO ()) -> m ()
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (a -> Bool) -> (a -> String) -> IO a -> IO ()
forall a. (a -> Bool) -> (a -> String) -> IO a -> IO ()
F.throwIf_ a -> Bool
pred_ a -> String
msgfct (m a -> IO a
forall a. m a -> IO a
u m a
act))

-- | Unlifted 'F.throwIfNeg'.
--
-- @since 0.2.5.0
{-# INLINE throwIfNeg #-}
throwIfNeg :: (MonadUnliftIO m, Ord a, Num a) => (a -> String) -> m a -> m a
throwIfNeg :: forall (m :: * -> *) a.
(MonadUnliftIO m, Ord a, Num a) =>
(a -> String) -> m a -> m a
throwIfNeg a -> String
msgfct m a
act = ((forall a. m a -> IO a) -> IO a) -> m a
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (a -> String) -> IO a -> IO a
forall a. (Ord a, Num a) => (a -> String) -> IO a -> IO a
F.throwIfNeg a -> String
msgfct (m a -> IO a
forall a. m a -> IO a
u m a
act))

-- | Unlifted 'F.throwIfNeg_'.
--
-- @since 0.2.5.0
{-# INLINE throwIfNeg_ #-}
throwIfNeg_ :: (MonadUnliftIO m, Ord a, Num a) => (a -> String) -> m a -> m ()
throwIfNeg_ :: forall (m :: * -> *) a.
(MonadUnliftIO m, Ord a, Num a) =>
(a -> String) -> m a -> m ()
throwIfNeg_ a -> String
msgfct m a
act = ((forall a. m a -> IO a) -> IO ()) -> m ()
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (a -> String) -> IO a -> IO ()
forall a. (Ord a, Num a) => (a -> String) -> IO a -> IO ()
F.throwIfNeg_ a -> String
msgfct (m a -> IO a
forall a. m a -> IO a
u m a
act))

-- | Unlifted 'F.throwIfNull'.
--
-- @since 0.2.5.0
{-# INLINE throwIfNull #-}
throwIfNull :: MonadUnliftIO m => String -> m (Ptr a) -> m (Ptr a)
throwIfNull :: forall (m :: * -> *) a.
MonadUnliftIO m =>
String -> m (Ptr a) -> m (Ptr a)
throwIfNull String
msg m (Ptr a)
act = ((forall a. m a -> IO a) -> IO (Ptr a)) -> m (Ptr a)
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> String -> IO (Ptr a) -> IO (Ptr a)
forall a. String -> IO (Ptr a) -> IO (Ptr a)
F.throwIfNull String
msg (m (Ptr a) -> IO (Ptr a)
forall a. m a -> IO a
u m (Ptr a)
act))

-- | Lifted 'F.newPool'.
--
-- @since 0.2.5.0
{-# INLINE newPool #-}
newPool :: MonadIO m => m Pool
newPool :: forall (m :: * -> *). MonadIO m => m Pool
newPool = IO Pool -> m Pool
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO Pool
F.newPool

-- | Lifted 'F.freePool'.
--
-- @since 0.2.5.0
{-# INLINE freePool #-}
freePool :: MonadIO m => Pool -> m ()
freePool :: forall (m :: * -> *). MonadIO m => Pool -> m ()
freePool = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> (Pool -> IO ()) -> Pool -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pool -> IO ()
F.freePool

-- | Unlifted 'F.withPool'.
--
-- @since 0.2.5.0
{-# INLINE withPool #-}
withPool :: MonadUnliftIO m => (Pool -> m b) -> m b
withPool :: forall (m :: * -> *) b. MonadUnliftIO m => (Pool -> m b) -> m b
withPool Pool -> m b
act = ((forall a. m a -> IO a) -> IO b) -> m b
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (Pool -> IO b) -> IO b
forall b. (Pool -> IO b) -> IO b
F.withPool (m b -> IO b
forall a. m a -> IO a
u (m b -> IO b) -> (Pool -> m b) -> Pool -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pool -> m b
act))

-- | Lifted 'F.pooledMalloc'.
--
-- @since 0.2.5.0
{-# INLINE pooledMalloc #-}
pooledMalloc :: (MonadIO m, Storable a) => Pool -> m (Ptr a)
pooledMalloc :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Pool -> m (Ptr a)
pooledMalloc = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr a) -> m (Ptr a))
-> (Pool -> IO (Ptr a)) -> Pool -> m (Ptr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pool -> IO (Ptr a)
forall a. Storable a => Pool -> IO (Ptr a)
F.pooledMalloc

-- | Lifted 'F.pooledMallocBytes'.
--
-- @since 0.2.5.0
{-# INLINE pooledMallocBytes #-}
pooledMallocBytes :: MonadIO m => Pool -> Int -> m (Ptr a)
pooledMallocBytes :: forall (m :: * -> *) a. MonadIO m => Pool -> Int -> m (Ptr a)
pooledMallocBytes Pool
pool Int
size = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Pool -> Int -> IO (Ptr a)
forall a. Pool -> Int -> IO (Ptr a)
F.pooledMallocBytes Pool
pool Int
size)

-- | Lifted 'F.pooledRealloc'.
--
-- @since 0.2.5.0
{-# INLINE pooledRealloc #-}
pooledRealloc :: (MonadIO m, Storable a) => Pool -> Ptr a -> m (Ptr a)
pooledRealloc :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Pool -> Ptr a -> m (Ptr a)
pooledRealloc Pool
pool Ptr a
ptr = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Pool -> Ptr a -> IO (Ptr a)
forall a. Storable a => Pool -> Ptr a -> IO (Ptr a)
F.pooledRealloc Pool
pool Ptr a
ptr)

-- | Lifted 'F.pooledReallocBytes'.
--
-- @since 0.2.5.0
{-# INLINE pooledReallocBytes #-}
pooledReallocBytes :: MonadIO m => Pool -> Ptr a -> Int -> m (Ptr a)
pooledReallocBytes :: forall (m :: * -> *) a.
MonadIO m =>
Pool -> Ptr a -> Int -> m (Ptr a)
pooledReallocBytes Pool
pool Ptr a
ptr Int
size = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Pool -> Ptr a -> Int -> IO (Ptr a)
forall a. Pool -> Ptr a -> Int -> IO (Ptr a)
F.pooledReallocBytes Pool
pool Ptr a
ptr Int
size)

-- | Lifted 'F.pooledMallocArray'.
--
-- @since 0.2.5.0
{-# INLINE pooledMallocArray #-}
pooledMallocArray :: (MonadIO m, Storable a) => Pool -> Int -> m (Ptr a)
pooledMallocArray :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Pool -> Int -> m (Ptr a)
pooledMallocArray Pool
pool Int
size = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Pool -> Int -> IO (Ptr a)
forall a. Storable a => Pool -> Int -> IO (Ptr a)
F.pooledMallocArray Pool
pool Int
size)

-- | Lifted 'F.pooledMallocArray0'.
--
-- @since 0.2.5.0
{-# INLINE pooledMallocArray0 #-}
pooledMallocArray0 :: (MonadIO m, Storable a) => Pool -> Int -> m (Ptr a)
pooledMallocArray0 :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Pool -> Int -> m (Ptr a)
pooledMallocArray0 Pool
pool Int
size = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Pool -> Int -> IO (Ptr a)
forall a. Storable a => Pool -> Int -> IO (Ptr a)
F.pooledMallocArray0 Pool
pool Int
size)

-- | Lifted 'F.pooledReallocArray'.
--
-- @since 0.2.5.0
{-# INLINE pooledReallocArray #-}
pooledReallocArray ::
     (MonadIO m, Storable a) => Pool -> Ptr a -> Int -> m (Ptr a)
pooledReallocArray :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Pool -> Ptr a -> Int -> m (Ptr a)
pooledReallocArray Pool
pool Ptr a
ptr Int
size = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Pool -> Ptr a -> Int -> IO (Ptr a)
forall a. Storable a => Pool -> Ptr a -> Int -> IO (Ptr a)
F.pooledReallocArray Pool
pool Ptr a
ptr Int
size)

-- | Lifted 'F.pooledReallocArray0'.
--
-- @since 0.2.5.0
{-# INLINE pooledReallocArray0 #-}
pooledReallocArray0 ::
     (MonadIO m, Storable a) => Pool -> Ptr a -> Int -> m (Ptr a)
pooledReallocArray0 :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Pool -> Ptr a -> Int -> m (Ptr a)
pooledReallocArray0 Pool
pool Ptr a
ptr Int
size = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Pool -> Ptr a -> Int -> IO (Ptr a)
forall a. Storable a => Pool -> Ptr a -> Int -> IO (Ptr a)
F.pooledReallocArray0 Pool
pool Ptr a
ptr Int
size)

-- | Lifted 'F.pooledNew'.
--
-- @since 0.2.5.0
{-# INLINE pooledNew #-}
pooledNew :: (MonadIO m, Storable a) => Pool -> a -> m (Ptr a)
pooledNew :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Pool -> a -> m (Ptr a)
pooledNew Pool
pool a
val = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Pool -> a -> IO (Ptr a)
forall a. Storable a => Pool -> a -> IO (Ptr a)
F.pooledNew Pool
pool a
val)

-- | Lifted 'F.pooledNewArray'.
--
-- @since 0.2.5.0
{-# INLINE pooledNewArray #-}
pooledNewArray :: (MonadIO m, Storable a) => Pool -> [a] -> m (Ptr a)
pooledNewArray :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Pool -> [a] -> m (Ptr a)
pooledNewArray Pool
pool [a]
vals = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Pool -> [a] -> IO (Ptr a)
forall a. Storable a => Pool -> [a] -> IO (Ptr a)
F.pooledNewArray Pool
pool [a]
vals)

-- | Lifted 'F.pooledNewArray0'.
--
-- @since 0.2.5.0
{-# INLINE pooledNewArray0 #-}
pooledNewArray0 :: (MonadIO m, Storable a) => Pool -> a -> [a] -> m (Ptr a)
pooledNewArray0 :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Pool -> a -> [a] -> m (Ptr a)
pooledNewArray0 Pool
pool a
marker [a]
vals = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Pool -> a -> [a] -> IO (Ptr a)
forall a. Storable a => Pool -> a -> [a] -> IO (Ptr a)
F.pooledNewArray0 Pool
pool a
marker [a]
vals)

-- | Unlifted 'F.with'.
--
-- @since 0.2.5.0
{-# INLINE with #-}
with :: (MonadUnliftIO m, Storable a) => a -> (Ptr a -> m b) -> m b
with :: forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with a
val Ptr a -> m b
f = ((forall a. m a -> IO a) -> IO b) -> m b
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> a -> (Ptr a -> IO b) -> IO b
forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
F.with a
val (m b -> IO b
forall a. m a -> IO a
u (m b -> IO b) -> (Ptr a -> m b) -> Ptr a -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
f))

-- | Lifted 'F.new'.
--
-- @since 0.2.5.0
{-# INLINE new #-}
new :: (MonadIO m, Storable a) => a -> m (Ptr a)
new :: forall (m :: * -> *) a. (MonadIO m, Storable a) => a -> m (Ptr a)
new = IO (Ptr a) -> m (Ptr a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr a) -> m (Ptr a)) -> (a -> IO (Ptr a)) -> a -> m (Ptr a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> IO (Ptr a)
forall a. Storable a => a -> IO (Ptr a)
F.new

-- | Lifted 'F.maybeNew'.
--
-- @since 0.2.5.0
{-# INLINE maybeNew #-}
maybeNew :: MonadIO m => (a -> m (Ptr b)) -> Maybe a -> m (Ptr b)
maybeNew :: forall (m :: * -> *) a b.
MonadIO m =>
(a -> m (Ptr b)) -> Maybe a -> m (Ptr b)
maybeNew = m (Ptr b) -> (a -> m (Ptr b)) -> Maybe a -> m (Ptr b)
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Ptr b -> m (Ptr b)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr b
forall a. Ptr a
nullPtr)

-- | Lifted 'F.maybeWith'.
--
-- @since 0.2.5.0
{-# INLINE maybeWith #-}
maybeWith ::
     MonadIO m
  => (a -> (Ptr b -> m c) -> m c)
  -> Maybe a
  -> (Ptr b -> m c)
  -> m c
maybeWith :: forall (m :: * -> *) a b c.
MonadIO m =>
(a -> (Ptr b -> m c) -> m c) -> Maybe a -> (Ptr b -> m c) -> m c
maybeWith = ((Ptr b -> m c) -> m c)
-> (a -> (Ptr b -> m c) -> m c) -> Maybe a -> (Ptr b -> m c) -> m c
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ((Ptr b -> m c) -> Ptr b -> m c
forall a b. (a -> b) -> a -> b
$ Ptr b
forall a. Ptr a
nullPtr)

-- | Unlifted 'F.maybePeek'.
--
-- @since 0.2.5.0
{-# INLINE maybePeek #-}
maybePeek :: MonadUnliftIO m => (Ptr a -> m b) -> Ptr a -> m (Maybe b)
maybePeek :: forall (m :: * -> *) a b.
MonadUnliftIO m =>
(Ptr a -> m b) -> Ptr a -> m (Maybe b)
maybePeek Ptr a -> m b
peek_ Ptr a
ptr = ((forall a. m a -> IO a) -> IO (Maybe b)) -> m (Maybe b)
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
forall a b. (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
F.maybePeek (m b -> IO b
forall a. m a -> IO a
u (m b -> IO b) -> (Ptr a -> m b) -> Ptr a -> IO b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
peek_) Ptr a
ptr)

-- | Lifted 'F.copyBytes'.
--
-- @since 0.2.5.0
{-# INLINE copyBytes #-}
copyBytes :: MonadIO m => Ptr a -> Ptr a -> Int -> m ()
copyBytes :: forall (m :: * -> *) a. MonadIO m => Ptr a -> Ptr a -> Int -> m ()
copyBytes Ptr a
dest Ptr a
src Int
size = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Ptr a -> Ptr a -> Int -> IO ()
forall a. Ptr a -> Ptr a -> Int -> IO ()
F.copyBytes Ptr a
dest Ptr a
src Int
size)

-- | Lifted 'F.moveBytes'.
--
-- @since 0.2.5.0
{-# INLINE moveBytes #-}
moveBytes :: MonadIO m => Ptr a -> Ptr a -> Int -> m ()
moveBytes :: forall (m :: * -> *) a. MonadIO m => Ptr a -> Ptr a -> Int -> m ()
moveBytes Ptr a
dest Ptr a
src Int
size = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Ptr a -> Ptr a -> Int -> IO ()
forall a. Ptr a -> Ptr a -> Int -> IO ()
F.moveBytes Ptr a
dest Ptr a
src Int
size)

#if MIN_VERSION_base(4,8,0)
-- | Lifted 'F.fillBytes'.
--
-- @since 0.2.5.0
{-# INLINE fillBytes #-}
fillBytes :: MonadIO m => Ptr a -> Word8 -> Int -> m ()
fillBytes :: forall (m :: * -> *) a. MonadIO m => Ptr a -> Word8 -> Int -> m ()
fillBytes Ptr a
dest Word8
char Int
size = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Ptr a -> Word8 -> Int -> IO ()
forall a. Ptr a -> Word8 -> Int -> IO ()
F.fillBytes Ptr a
dest Word8
char Int
size)
#endif