HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Core Types

13 declarations
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.

typetype Offset = Int
#

How far into the given Ptr to look

Encode ByteString

1 declaration
valueunsafeEncodeWith :: Poke () -> Int -> 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

7 declarations

Storable

3 declarations

ForeignPtr

3 declarations
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

2 declarations

Creation of PokeState / PeekState

3 declarations
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

If store-core is built with the force-alignment flag, then this will be a Just value indicating the amount of memory that is expected in the alignment buffer used by PeekState and PokeState. Currently this will either be Just 32 or Nothing.