HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Modulemempack-0.2.1.0Haskell2010

Data.MemPack.Buffer

  • 1 class
  • 9 values
  • Packagemempack-0.2.1.0
  • Exports10
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceBuffer.hs
classclass Buffer b where
#

Immutable memory buffer

Methods

Instances6Buffer
valuenewMutableByteArray
  1. :: Bool

    Should the mutable array be allocated as pinned or not

  2. -> Int

    Size of the mutable array in number of bytes.

  3. -> ST s (MutableByteArray s)
#

Allocate a new uninitialized MutableByteArray.

  • Warning - Memory allocated might contain random garbage and must be fully overwritten.

⚠ - Violation of the above rule could lead non-determinism and breakage of referential transparency.

valuewithPtrByteStringST :: ByteString -> (Ptr a -> ST s b) -> ST s b
#

Run ST action on the underlying Ptr that points to the beginning of the ByteString buffer. It is ok to use ByteString withing ST, as long as underlying pointer is never mutated or returned from the supplied action.

  • Warning - It is important for the supplied action to not produce bottom, i.e. runtime exceptions or infinite loops are not allowed within its body.

⚠ - Violation of the above rule could potentially lead to corrupt memory and segfaults.

valuewithForeignPtrST :: ForeignPtr a -> (Addr# -> ST s b) -> ST s b
#

Run an ST action on the underlying Ptr that points to the beginning of the ByteString buffer. It is ok to use ByteString withing ST, as long as underlying pointer is never mutated or returned from the supplied action.

  • Warning - It is important for the memory that backs the underlying ForeignPtr to not be mutated outside of the ST monad that this action operates in, which is only allowed if it was allocated in this execution of the ST monad.

  • Warning - It is important for the memory that backs the underlying ForeignPtr to not be mutated at all if ForeignPtr was not allocated within the ST monad that this action operates in.

  • Warning - It is important for the supplied action to not produce bottom, i.e. runtime exceptions or infinite loops are not allowed within its body.

⚠ - Violation of the above rules could potentially lead to corrupt memory and segfaults.