summaryrefslogtreecommitdiff
path: root/src/Data
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2019-10-10 00:52:45 +0000
committerJames Crayne <jim.crayne@gmail.com>2019-10-10 00:52:45 +0000
commitbcbf4dedaab127ac43d46147e6a7699d833890cf (patch)
tree77e0ba6f56c95d0e9627e46cd2657980de01d10f /src/Data
parentddb64d2b6fdbd77a244f1716c862938055bdfdd4 (diff)
Start documentingHEADmaster
Diffstat (limited to 'src/Data')
-rw-r--r--src/Data/Primitive/Struct.hs18
1 files changed, 18 insertions, 0 deletions
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
22import Foreign.Storable 22import Foreign.Storable
23import GHC.TypeLits 23import GHC.TypeLits
24 24
25-- | A Record Field
26--
27-- Type Parameters:
28-- @tag@ - Type constructor, which identifies the struct, typically unpopulated.
29-- @typ@ - The type of the value stored at this field
30-- @n@ - The byte-offset as a type-level natural within the struct (location of field's value).
31--
32-- Data Parameter: The 'Offset' corresponding to @n@.
33--
34-- To associate a field name with a field, see the 'IsField' type class.
25newtype Field tag typ n = Field (Offset n) 35newtype Field tag typ n = Field (Offset n)
26 36
37-- | Structs in the garbage collected heap modifiable in either IO or ST
38--
39-- Type Parameters:
40-- @m@ - Monad, typically or IO,ST, but any instance of 'Control.Monad.Primitive.PrimMonad' will do
41-- @base@ - The byte-address of the struct, within the 'structArray'
42-- @tag@ - Type constructor identifying the struct, helps for inferring 'IsField' instances
27data Struct m base tag = Struct 43data Struct m base tag = Struct
28 { structOffset :: !(Offset base) 44 { structOffset :: !(Offset base)
45 -- ^ 'Offset' corresponding to the @base@ type parameter
29 , structArray :: !(MutableByteArray (PrimState m)) 46 , structArray :: !(MutableByteArray (PrimState m))
47 -- ^ mutuable array where values are stored
30 } 48 }
31 49
32newStruct :: forall tag m. (KnownNat (SizeOf tag), PrimMonad m) => m (Struct m 0 tag) 50newStruct :: forall tag m. (KnownNat (SizeOf tag), PrimMonad m) => m (Struct m 0 tag)