1
0
Fork 0
No description
Find a file
2024-09-05 02:31:48 +02:00
.circleci Initial 2022-05-28 14:24:26 +07:00
src/Foreign/Storable Initial 2022-05-28 14:24:26 +07:00
LICENSE Initial 2022-05-28 14:24:26 +07:00
README.md Initial 2022-05-28 14:24:26 +07:00
storable-offset.cabal Bump upper bounds for base 2024-09-05 02:31:48 +02:00

storable-offset

Tiny helper library that provides a way to access fields of Storable data structures.

Given an instance

{-# LANGUAGE DataKinds
           , MultiParamTypeClasses #-}

instance Offset "fieldName" DataType where rawOffset = #{offset data_type, field_name}

, you can now peek/poke fieldName directly using

{-# LANGUAGE TypeApplications #-}

peek $ offset @"fieldName" (ptr @DataType)

poke (offset @"fieldName" ptr) (val @DataType)