storable-offset- Storable offsets for record fields
Safe HaskellSafe-Inferred



Utility functions for using Storable to access record fields of data structures.

Functions in this module rely on the TypeApplications pragma (the Offset class itself doesn't).



class Offset (x :: Symbol) r where Source #


rawOffset :: Int Source #

Byte distance between the start of datatype r within memory and its field x.

offset :: forall x r a. (HasField x r a, Offset x r) => Ptr r -> Ptr a Source #

Advances a pointer based on field's Offset, inheriting field's type.

Resulting pointer can be used to peek or poke the field directly.

Helper functions

pokeField :: forall x r a. (HasField x r a, Offset x r, Storable a) => Ptr r -> r -> IO () Source #

Retrieves the field and pokes it at proper offset.

Useful for declaring poke for the entire datatype.