From bcbf4dedaab127ac43d46147e6a7699d833890cf Mon Sep 17 00:00:00 2001 From: James Crayne Date: Thu, 10 Oct 2019 00:52:45 +0000 Subject: Start documenting --- src/Data/Primitive/Struct.hs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Data/Primitive/Struct.hs b/src/Data/Primitive/Struct.hs index 92bd387..9175cc5 100644 --- a/src/Data/Primitive/Struct.hs +++ b/src/Data/Primitive/Struct.hs @@ -22,11 +22,29 @@ import Foreign.Ptr import Foreign.Storable import GHC.TypeLits +-- | A Record Field +-- +-- Type Parameters: +-- @tag@ - Type constructor, which identifies the struct, typically unpopulated. +-- @typ@ - The type of the value stored at this field +-- @n@ - The byte-offset as a type-level natural within the struct (location of field's value). +-- +-- Data Parameter: The 'Offset' corresponding to @n@. +-- +-- To associate a field name with a field, see the 'IsField' type class. newtype Field tag typ n = Field (Offset n) +-- | Structs in the garbage collected heap modifiable in either IO or ST +-- +-- Type Parameters: +-- @m@ - Monad, typically or IO,ST, but any instance of 'Control.Monad.Primitive.PrimMonad' will do +-- @base@ - The byte-address of the struct, within the 'structArray' +-- @tag@ - Type constructor identifying the struct, helps for inferring 'IsField' instances data Struct m base tag = Struct { structOffset :: !(Offset base) + -- ^ 'Offset' corresponding to the @base@ type parameter , structArray :: !(MutableByteArray (PrimState m)) + -- ^ mutuable array where values are stored } newStruct :: forall tag m. (KnownNat (SizeOf tag), PrimMonad m) => m (Struct m 0 tag) -- cgit v1.2.3