HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Core Types

newtypenewtype Poke a

Poke actions are useful for building sequential serializers.

They are actions which write values to bytes into memory specified by a Ptr base. The Applicative and Monad instances make it easy to write serializations, by keeping track of the Offset of the current byte. They allow you to chain Poke action such that subsequent Pokes write into subsequent portions of the output.

Constructors

  • Poke
    • runPoke :: PokeState -> Offset -> IO (Offset, a)

      Run the Poke action, with the Ptr to the buffer where data is poked, and the current Offset. The result is the new offset, along with a return value.

      May throw a PokeException, though this should be avoided when possible. They usually indicate a programming error.

Instances5Monad, Functor, MonadFail, Applicative, MonadIO
  • Monad PokeDefined in store-core-0.4.4.7 · Data.Store.Core
  • Functor PokeDefined in store-core-0.4.4.7 · Data.Store.Core
  • MonadFail PokeDefined in store-core-0.4.4.7 · Data.Store.Core
  • Applicative PokeDefined in store-core-0.4.4.7 · Data.Store.Core
  • MonadIO PokeDefined in store-core-0.4.4.7 · Data.Store.Core
datadata PokeException

Exception thrown while running poke. Note that other types of exceptions could also be thrown. Invocations of fail in the Poke monad causes this exception to be thrown.

PokeExceptions are not expected to occur in ordinary circumstances, and usually indicate a programming error.

Instances3Eq, Show, Exception
newtypenewtype Peek a

Peek actions are useful for building sequential deserializers.

They are actions which read from memory and construct values from it. The Applicative and Monad instances make it easy to chain these together to get more complicated deserializers. This machinery keeps track of the current Ptr and end-of-buffer Ptr.

Constructors

Instances7Monad, Functor, MonadFail, Applicative, MonadIO, PrimMonad, …
datadata PeekException

Exception thrown while running peek. Note that other types of exceptions can also be thrown. Invocations of fail in the Poke monad causes this exception to be thrown.

PeekException is thrown when the data being decoded is invalid.

Instances3Eq, Show, Exception
newtypenewtype PokeState

Holds a pokeStatePtr, which is passed in to each Poke action. If the package is built with the 'force-alignment' flag, this also has a hidden Ptr field, which is used as scratch space during unaligned writes.

newtypenewtype PeekState

Holds a peekStatePtr, which is passed in to each Peek action. If the package is built with the 'force-alignment' flag, this also has a hidden Ptr field, which is used as scratch space during unaligned reads.

Encode ByteString

Given a Poke and its length, uses it to fill a ByteString

This function is unsafe because the provided length must exactly match the number of bytes used by the Poke. It will throw PokeException errors when the buffer is under or overshot. However, in the case of overshooting the buffer, memory corruption and segfaults may occur.

Decode ByteString

Storable

ForeignPtr

valuepokeFromPtr :: Ptr a -> Int -> Int -> Poke ()

Copy a section of memory, based on a Ptr, to the output. Note that this operation is unsafe, because the offset and length parameters are not checked.

ByteArray

Creation of PokeState / PeekState

valueunsafeMakePokeState
  1. :: Ptr Word8

    pokeStatePtr

  2. -> IO (Ptr Word8)

    action to produce pokeStateAlignPtr

  3. -> IO PokeState

Make a PokeState from a buffer pointer.

The first argument is a pointer to the memory to write to. The second argument is an IO action which is invoked if the store-core package was built with the force-alignment flag. The action should yield a pointer to scratch memory as large as maybeAlignmentBufferSize.

Since 0.4.2

valueunsafeMakePeekState
  1. :: Ptr Word8

    peekStateEndPtr

  2. -> IO (Ptr Word8)

    action to produce peekStateAlignPtr

  3. -> IO PeekState

Make a PeekState from a buffer pointer.

The first argument is a pointer to the memory to write to. The second argument is an IO action which is invoked if the store-core package was built with the force-alignment flag. The action should yield a pointer to scratch memory as large as maybeAlignmentBufferSize.

Since 0.4.2