{-# LANGUAGE CPP #-}
module UnliftIO.Foreign (
module Data.Bits
, module Data.Int
, module Data.Word
, module Foreign.C.Types
, 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
, 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_
, Ptr
, nullPtr
, castPtr
, plusPtr
, alignPtr
, minusPtr
, FunPtr
, nullFunPtr
, castFunPtr
, castFunPtrToPtr
, castPtrToFunPtr
, freeHaskellFunPtr
, IntPtr(..)
, ptrToIntPtr
, intPtrToPtr
, WordPtr(..)
, ptrToWordPtr
, wordPtrToPtr
, 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
, StablePtr
, newStablePtr
, deRefStablePtr
, freeStablePtr
, castStablePtrToPtr
, castPtrToStablePtr
, Storable(..)
, alloca
, allocaBytes
, allocaBytesAligned
, malloc
, mallocBytes
#if MIN_VERSION_base(4,8,0)
, calloc
, callocBytes
#endif
, realloc
, reallocBytes
, free
, finalizerFree
, 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
, throwIf
, throwIf_
, throwIfNeg
, throwIfNeg_
, throwIfNull
, Pool
, newPool
, freePool
, withPool
, pooledMalloc
, pooledMallocBytes
, pooledRealloc
, pooledReallocBytes
, pooledMallocArray
, pooledMallocArray0
, pooledReallocArray
, pooledReallocArray0
, pooledNew
, pooledNewArray
, pooledNewArray0
, 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
{-# INLINE peekCString #-}
peekCString :: MonadIO m => CString -> m String
peekCString :: forall (m :: * -> *). MonadIO m => CString -> m String
peekCString = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. CString -> IO String
F.peekCString
{-# INLINE peekCStringLen #-}
peekCStringLen :: MonadIO m => CStringLen -> m String
peekCStringLen :: forall (m :: * -> *). MonadIO m => CStringLen -> m String
peekCStringLen = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. CStringLen -> IO String
F.peekCStringLen
{-# INLINE newCString #-}
newCString :: MonadIO m => String -> m CString
newCString :: forall (m :: * -> *). MonadIO m => String -> m CString
newCString = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO CString
F.newCString
{-# INLINE newCStringLen #-}
newCStringLen :: MonadIO m => String -> m CStringLen
newCStringLen :: forall (m :: * -> *). MonadIO m => String -> m CStringLen
newCStringLen = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO CStringLen
F.newCStringLen
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. String -> (CString -> IO a) -> IO a
F.withCString String
s (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. CString -> m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. String -> (CStringLen -> IO a) -> IO a
F.withCStringLen String
s (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. CStringLen -> m a
f))
{-# INLINE peekCAString #-}
peekCAString :: MonadIO m => CString -> m String
peekCAString :: forall (m :: * -> *). MonadIO m => CString -> m String
peekCAString = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. CString -> IO String
F.peekCAString
{-# INLINE peekCAStringLen #-}
peekCAStringLen :: MonadIO m => CStringLen -> m String
peekCAStringLen :: forall (m :: * -> *). MonadIO m => CStringLen -> m String
peekCAStringLen = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. CStringLen -> IO String
F.peekCAStringLen
{-# INLINE newCAString #-}
newCAString :: MonadIO m => String -> m CString
newCAString :: forall (m :: * -> *). MonadIO m => String -> m CString
newCAString = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO CString
F.newCAString
{-# INLINE newCAStringLen #-}
newCAStringLen :: MonadIO m => String -> m CStringLen
newCAStringLen :: forall (m :: * -> *). MonadIO m => String -> m CStringLen
newCAStringLen = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO CStringLen
F.newCAStringLen
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. String -> (CString -> IO a) -> IO a
F.withCAString String
str (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. CString -> m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. String -> (CStringLen -> IO a) -> IO a
F.withCAStringLen String
str (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. CStringLen -> m a
f))
{-# INLINE peekCWString #-}
peekCWString :: MonadIO m => CWString -> m String
peekCWString :: forall (m :: * -> *). MonadIO m => CWString -> m String
peekCWString = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. CWString -> IO String
F.peekCWString
{-# INLINE peekCWStringLen #-}
peekCWStringLen :: MonadIO m => CWStringLen -> m String
peekCWStringLen :: forall (m :: * -> *). MonadIO m => CWStringLen -> m String
peekCWStringLen = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. CWStringLen -> IO String
F.peekCWStringLen
{-# INLINE newCWString #-}
newCWString :: MonadIO m => String -> m CWString
newCWString :: forall (m :: * -> *). MonadIO m => String -> m CWString
newCWString = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO CWString
F.newCWString
{-# INLINE newCWStringLen #-}
newCWStringLen :: MonadIO m => String -> m CWStringLen
newCWStringLen :: forall (m :: * -> *). MonadIO m => String -> m CWStringLen
newCWStringLen = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> IO CWStringLen
F.newCWStringLen
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. String -> (CWString -> IO a) -> IO a
F.withCWString String
str (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. CWString -> m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. String -> (CWStringLen -> IO a) -> IO a
F.withCWStringLen String
str (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. CWStringLen -> m a
f))
{-# INLINE getErrno #-}
getErrno :: MonadIO m => m Errno
getErrno :: forall (m :: * -> *). MonadIO m => m Errno
getErrno = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO Errno
F.getErrno
{-# INLINE resetErrno #-}
resetErrno :: MonadIO m => m ()
resetErrno :: forall (m :: * -> *). MonadIO m => m ()
resetErrno = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO ()
F.resetErrno
{-# INLINE throwErrno #-}
throwErrno :: MonadIO m => String -> m a
throwErrno :: forall (m :: * -> *) a. MonadIO m => String -> m a
throwErrno = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. String -> IO a
F.throwErrno
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (a -> Bool) -> String -> IO a -> IO a
F.throwErrnoIf a -> Bool
pred_ String
loc (forall a. m a -> IO a
u m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (a -> Bool) -> String -> IO a -> IO ()
F.throwErrnoIf_ a -> Bool
pred_ String
loc (forall a. m a -> IO a
u m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (a -> Bool) -> String -> IO a -> IO a
F.throwErrnoIfRetry a -> Bool
pred_ String
loc (forall a. m a -> IO a
u m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (a -> Bool) -> String -> IO a -> IO ()
F.throwErrnoIfRetry_ a -> Bool
pred_ String
loc (forall a. m a -> IO a
u m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (Eq a, Num a) => String -> IO a -> IO a
F.throwErrnoIfMinus1 String
loc (forall a. m a -> IO a
u m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (Eq a, Num a) => String -> IO a -> IO ()
F.throwErrnoIfMinus1_ String
loc (forall a. m a -> IO a
u m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (Eq a, Num a) => String -> IO a -> IO a
F.throwErrnoIfMinus1Retry String
loc (forall a. m a -> IO a
u m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (Eq a, Num a) => String -> IO a -> IO ()
F.throwErrnoIfMinus1Retry_ String
loc (forall a. m a -> IO a
u m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. String -> IO (Ptr a) -> IO (Ptr a)
F.throwErrnoIfNull String
loc (forall a. m a -> IO a
u m (Ptr a)
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. String -> IO (Ptr a) -> IO (Ptr a)
F.throwErrnoIfNullRetry String
loc (forall a. m a -> IO a
u m (Ptr a)
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. (a -> Bool) -> String -> IO a -> IO b -> IO a
F.throwErrnoIfRetryMayBlock a -> Bool
pred_ String
loc (forall a. m a -> IO a
u m a
f) (forall a. m a -> IO a
u m b
on_block))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. (a -> Bool) -> String -> IO a -> IO b -> IO ()
F.throwErrnoIfRetryMayBlock_ a -> Bool
pred_ String
loc (forall a. m a -> IO a
u m a
f) (forall a. m a -> IO a
u m b
on_block))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. (Eq a, Num a) => String -> IO a -> IO b -> IO a
F.throwErrnoIfMinus1RetryMayBlock String
loc (forall a. m a -> IO a
u m a
f) (forall a. m a -> IO a
u m b
on_block))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. (Eq a, Num a) => String -> IO a -> IO b -> IO ()
F.throwErrnoIfMinus1RetryMayBlock_ String
loc (forall a. m a -> IO a
u m a
f) (forall a. m a -> IO a
u m b
on_block))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. String -> IO (Ptr a) -> IO b -> IO (Ptr a)
F.throwErrnoIfNullRetryMayBlock String
loc (forall a. m a -> IO a
u m (Ptr a)
f) (forall a. m a -> IO a
u m b
on_block))
{-# INLINE throwErrnoPath #-}
throwErrnoPath :: MonadIO m => String -> FilePath -> m a
throwErrnoPath :: forall (m :: * -> *) a. MonadIO m => String -> String -> m a
throwErrnoPath String
loc String
path = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. String -> String -> IO a
F.throwErrnoPath String
loc String
path)
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (a -> Bool) -> String -> String -> IO a -> IO a
F.throwErrnoPathIf a -> Bool
pred_ String
loc String
path (forall a. m a -> IO a
u m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (a -> Bool) -> String -> String -> IO a -> IO ()
F.throwErrnoPathIf_ a -> Bool
pred_ String
loc String
path (forall a. m a -> IO a
u m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. String -> String -> IO (Ptr a) -> IO (Ptr a)
F.throwErrnoPathIfNull String
loc String
path (forall a. m a -> IO a
u m (Ptr a)
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (Eq a, Num a) => String -> String -> IO a -> IO a
F.throwErrnoPathIfMinus1 String
loc String
path (forall a. m a -> IO a
u m a
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (Eq a, Num a) => String -> String -> IO a -> IO ()
F.throwErrnoPathIfMinus1_ String
loc String
path (forall a. m a -> IO a
u m a
f))
{-# INLINE freeHaskellFunPtr #-}
freeHaskellFunPtr :: MonadIO m => FunPtr a -> m ()
freeHaskellFunPtr :: forall (m :: * -> *) a. MonadIO m => FunPtr a -> m ()
freeHaskellFunPtr = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. FunPtr a -> IO ()
F.freeHaskellFunPtr
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. FinalizerPtr a -> Ptr a -> IO (ForeignPtr a)
F.newForeignPtr FinalizerPtr a
finalizer Ptr a
p)
{-# INLINE newForeignPtr_ #-}
newForeignPtr_ :: MonadIO m => Ptr a -> m (ForeignPtr a)
newForeignPtr_ :: forall (m :: * -> *) a. MonadIO m => Ptr a -> m (ForeignPtr a)
newForeignPtr_ = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Ptr a -> IO (ForeignPtr a)
F.newForeignPtr_
{-# 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 =
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. FinalizerPtr a -> ForeignPtr a -> IO ()
F.addForeignPtrFinalizer FinalizerPtr a
finalizer_ptr ForeignPtr a
foreign_ptr)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (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)
{-# 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 =
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall env a.
FinalizerEnvPtr env a -> Ptr env -> ForeignPtr a -> IO ()
F.addForeignPtrFinalizerEnv FinalizerEnvPtr env a
finalizer Ptr env
env ForeignPtr a
fp)
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. ForeignPtr a -> (Ptr a -> IO b) -> IO b
F.withForeignPtr ForeignPtr a
fo (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
io))
{-# INLINE finalizeForeignPtr #-}
finalizeForeignPtr :: MonadIO m => ForeignPtr a -> m ()
finalizeForeignPtr :: forall (m :: * -> *) a. MonadIO m => ForeignPtr a -> m ()
finalizeForeignPtr = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. ForeignPtr a -> IO ()
F.finalizeForeignPtr
{-# INLINE touchForeignPtr #-}
touchForeignPtr :: MonadIO m => ForeignPtr a -> m ()
touchForeignPtr :: forall (m :: * -> *) a. MonadIO m => ForeignPtr a -> m ()
touchForeignPtr = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. ForeignPtr a -> IO ()
F.touchForeignPtr
{-# INLINE mallocForeignPtr #-}
mallocForeignPtr :: (MonadIO m, Storable a) => m (ForeignPtr a)
mallocForeignPtr :: forall (m :: * -> *) a. (MonadIO m, Storable a) => m (ForeignPtr a)
mallocForeignPtr = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a. Storable a => IO (ForeignPtr a)
F.mallocForeignPtr
{-# INLINE mallocForeignPtrBytes #-}
mallocForeignPtrBytes :: MonadIO m => Int -> m (ForeignPtr a)
mallocForeignPtrBytes :: forall (m :: * -> *) a. MonadIO m => Int -> m (ForeignPtr a)
mallocForeignPtrBytes = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Int -> IO (ForeignPtr a)
F.mallocForeignPtrBytes
{-# INLINE mallocForeignPtrArray #-}
mallocForeignPtrArray :: (MonadIO m, Storable a) => Int -> m (ForeignPtr a)
mallocForeignPtrArray :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> m (ForeignPtr a)
mallocForeignPtrArray = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Storable a => Int -> IO (ForeignPtr a)
F.mallocForeignPtrArray
{-# INLINE mallocForeignPtrArray0 #-}
mallocForeignPtrArray0 :: (MonadIO m, Storable a) => Int -> m (ForeignPtr a)
mallocForeignPtrArray0 :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> m (ForeignPtr a)
mallocForeignPtrArray0 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Storable a => Int -> IO (ForeignPtr a)
F.mallocForeignPtrArray0
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. Ptr a -> IO () -> IO (ForeignPtr a)
FC.newForeignPtr Ptr a
ptr (forall a. m a -> IO a
u m ()
f))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. ForeignPtr a -> IO () -> IO ()
FC.addForeignPtrFinalizer ForeignPtr a
fptr (forall a. m a -> IO a
u m ()
f))
{-# INLINE newStablePtr #-}
newStablePtr :: MonadIO m => a -> m (StablePtr a)
newStablePtr :: forall (m :: * -> *) a. MonadIO m => a -> m (StablePtr a)
newStablePtr = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. a -> IO (StablePtr a)
F.newStablePtr
{-# INLINE deRefStablePtr #-}
deRefStablePtr :: MonadIO m => StablePtr a -> m a
deRefStablePtr :: forall (m :: * -> *) a. MonadIO m => StablePtr a -> m a
deRefStablePtr = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. StablePtr a -> IO a
F.deRefStablePtr
{-# INLINE freeStablePtr #-}
freeStablePtr :: MonadIO m => StablePtr a -> m ()
freeStablePtr :: forall (m :: * -> *) a. MonadIO m => StablePtr a -> m ()
freeStablePtr = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. StablePtr a -> IO ()
F.freeStablePtr
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. Storable a => (Ptr a -> IO b) -> IO b
F.alloca (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. Int -> (Ptr a -> IO b) -> IO b
F.allocaBytes Int
size (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. Int -> Int -> (Ptr a -> IO b) -> IO b
F.allocaBytesAligned Int
size Int
align (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))
{-# INLINE malloc #-}
malloc :: (MonadIO m, Storable a) => m (Ptr a)
malloc :: forall (m :: * -> *) a. (MonadIO m, Storable a) => m (Ptr a)
malloc = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a. Storable a => IO (Ptr a)
F.malloc
{-# INLINE mallocBytes #-}
mallocBytes :: MonadIO m => Int -> m (Ptr a)
mallocBytes :: forall (m :: * -> *) a. MonadIO m => Int -> m (Ptr a)
mallocBytes = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Int -> IO (Ptr a)
F.mallocBytes
#if MIN_VERSION_base(4,8,0)
{-# INLINE calloc #-}
calloc :: (MonadIO m, Storable a) => m (Ptr a)
calloc :: forall (m :: * -> *) a. (MonadIO m, Storable a) => m (Ptr a)
calloc = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a. Storable a => IO (Ptr a)
F.calloc
{-# INLINE callocBytes #-}
callocBytes :: MonadIO m => Int -> m (Ptr a)
callocBytes :: forall (m :: * -> *) a. MonadIO m => Int -> m (Ptr a)
callocBytes = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Int -> IO (Ptr a)
F.callocBytes
#endif
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. Storable b => Ptr a -> IO (Ptr b)
F.realloc
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Ptr a -> Int -> IO (Ptr a)
F.reallocBytes Ptr a
ptr Int
size)
{-# INLINE free #-}
free :: MonadIO m => Ptr a -> m ()
free :: forall (m :: * -> *) a. MonadIO m => Ptr a -> m ()
free = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Ptr a -> IO ()
F.free
{-# INLINE mallocArray #-}
mallocArray :: (MonadIO m, Storable a) => Int -> m (Ptr a)
mallocArray :: forall (m :: * -> *) a. (MonadIO m, Storable a) => Int -> m (Ptr a)
mallocArray = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Storable a => Int -> IO (Ptr a)
F.mallocArray
{-# INLINE mallocArray0 #-}
mallocArray0 :: (MonadIO m, Storable a) => Int -> m (Ptr a)
mallocArray0 :: forall (m :: * -> *) a. (MonadIO m, Storable a) => Int -> m (Ptr a)
mallocArray0 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Storable a => Int -> IO (Ptr a)
F.mallocArray
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
F.allocaArray Int
size (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. Storable a => Int -> (Ptr a -> IO b) -> IO b
F.allocaArray0 Int
size (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Ptr a -> Int -> IO (Ptr a)
F.reallocArray Ptr a
ptr Int
size)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Ptr a -> Int -> IO (Ptr a)
F.reallocArray0 Ptr a
ptr Int
size)
#if MIN_VERSION_base(4,8,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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Storable a => Int -> IO (Ptr a)
F.callocArray
{-# INLINE callocArray0 #-}
callocArray0 :: (MonadIO m, Storable a) => Int -> m (Ptr a)
callocArray0 :: forall (m :: * -> *) a. (MonadIO m, Storable a) => Int -> m (Ptr a)
callocArray0 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Storable a => Int -> IO (Ptr a)
F.callocArray0
#endif
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Int -> Ptr a -> IO [a]
F.peekArray Int
size Ptr a
ptr)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. (Storable a, Eq a) => a -> Ptr a -> IO [a]
F.peekArray0 a
marker Ptr a
ptr)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Ptr a -> [a] -> IO ()
F.pokeArray Ptr a
ptr [a]
vals0)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => a -> Ptr a -> [a] -> IO ()
F.pokeArray0 a
marker Ptr a
ptr [a]
vals0)
{-# INLINE newArray #-}
newArray :: (MonadIO m, Storable a) => [a] -> m (Ptr a)
newArray :: forall (m :: * -> *) a. (MonadIO m, Storable a) => [a] -> m (Ptr a)
newArray = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Storable a => [a] -> IO (Ptr a)
F.newArray
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => a -> [a] -> IO (Ptr a)
F.newArray0 a
marker [a]
vals)
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. Storable a => [a] -> (Ptr a -> IO b) -> IO b
F.withArray [a]
vals (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. Storable a => a -> [a] -> (Ptr a -> IO b) -> IO b
F.withArray0 a
marker [a]
vals (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
action))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. Storable a => [a] -> (Int -> Ptr a -> IO b) -> IO b
F.withArrayLen [a]
vals (\Int
s Ptr a
p -> forall a. m a -> IO a
u (Int -> Ptr a -> m b
f Int
s Ptr a
p)))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> 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 -> forall a. m a -> IO a
u (Int -> Ptr a -> m b
f Int
s Ptr a
p)))
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Ptr a -> Ptr a -> Int -> IO ()
F.copyArray Ptr a
dest Ptr a
src Int
size)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Ptr a -> Ptr a -> Int -> IO ()
F.moveArray Ptr a
dest Ptr a
src Int
size)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. (Storable a, Eq a) => a -> Ptr a -> IO Int
F.lengthArray0 a
marker Ptr a
ptr)
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (a -> Bool) -> (a -> String) -> IO a -> IO a
F.throwIf a -> Bool
pred_ a -> String
msgfct (forall a. m a -> IO a
u m a
act))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (a -> Bool) -> (a -> String) -> IO a -> IO ()
F.throwIf_ a -> Bool
pred_ a -> String
msgfct (forall a. m a -> IO a
u m a
act))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (Ord a, Num a) => (a -> String) -> IO a -> IO a
F.throwIfNeg a -> String
msgfct (forall a. m a -> IO a
u m a
act))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. (Ord a, Num a) => (a -> String) -> IO a -> IO ()
F.throwIfNeg_ a -> String
msgfct (forall a. m a -> IO a
u m a
act))
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a. String -> IO (Ptr a) -> IO (Ptr a)
F.throwIfNull String
msg (forall a. m a -> IO a
u m (Ptr a)
act))
{-# INLINE newPool #-}
newPool :: MonadIO m => m Pool
newPool :: forall (m :: * -> *). MonadIO m => m Pool
newPool = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO Pool
F.newPool
{-# INLINE freePool #-}
freePool :: MonadIO m => Pool -> m ()
freePool :: forall (m :: * -> *). MonadIO m => Pool -> m ()
freePool = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pool -> IO ()
F.freePool
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall b. (Pool -> IO b) -> IO b
F.withPool (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. Pool -> m b
act))
{-# INLINE pooledMalloc #-}
pooledMalloc :: (MonadIO m, Storable a) => Pool -> m (Ptr a)
pooledMalloc :: forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Pool -> m (Ptr a)
pooledMalloc = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Storable a => Pool -> IO (Ptr a)
F.pooledMalloc
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Pool -> Int -> IO (Ptr a)
F.pooledMallocBytes Pool
pool Int
size)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Pool -> Ptr a -> IO (Ptr a)
F.pooledRealloc Pool
pool Ptr a
ptr)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Pool -> Ptr a -> Int -> IO (Ptr a)
F.pooledReallocBytes Pool
pool Ptr a
ptr Int
size)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Pool -> Int -> IO (Ptr a)
F.pooledMallocArray Pool
pool Int
size)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Pool -> Int -> IO (Ptr a)
F.pooledMallocArray0 Pool
pool Int
size)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Pool -> Ptr a -> Int -> IO (Ptr a)
F.pooledReallocArray Pool
pool Ptr a
ptr Int
size)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Pool -> Ptr a -> Int -> IO (Ptr a)
F.pooledReallocArray0 Pool
pool Ptr a
ptr Int
size)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Pool -> a -> IO (Ptr a)
F.pooledNew Pool
pool a
val)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Pool -> [a] -> IO (Ptr a)
F.pooledNewArray Pool
pool [a]
vals)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Storable a => Pool -> a -> [a] -> IO (Ptr a)
F.pooledNewArray0 Pool
pool a
marker [a]
vals)
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. Storable a => a -> (Ptr a -> IO b) -> IO b
F.with a
val (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
f))
{-# INLINE new #-}
new :: (MonadIO m, Storable a) => a -> m (Ptr a)
new :: forall (m :: * -> *) a. (MonadIO m, Storable a) => a -> m (Ptr a)
new = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Storable a => a -> IO (Ptr a)
F.new
{-# 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 = forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall (m :: * -> *) a. Monad m => a -> m a
return forall a. Ptr a
nullPtr)
{-# 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 = forall b a. b -> (a -> b) -> Maybe a -> b
maybe (forall a b. (a -> b) -> a -> b
$ forall a. Ptr a
nullPtr)
{-# 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 (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (\forall a. m a -> IO a
u -> forall a b. (Ptr a -> IO b) -> Ptr a -> IO (Maybe b)
F.maybePeek (forall a. m a -> IO a
u forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ptr a -> m b
peek_) Ptr a
ptr)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Ptr a -> Ptr a -> Int -> IO ()
F.copyBytes Ptr a
dest Ptr a
src Int
size)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (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)
{-# 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 = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (forall a. Ptr a -> Word8 -> Int -> IO ()
F.fillBytes Ptr a
dest Word8
char Int
size)
#endif