Safe Haskell | None |
---|---|
Language | Haskell98 |
This modules extends the Prim
from Data.Primitive class to cases
where we don't know the primitive information (like the size) at compile
time. Instead, we must pass in a PseudoPrimInfo
object that will get
evaluated on every function call and that contains the needed information.
For PseudoPrim
instances that are also Prim
instances, this involves
no run time overhead. For PseudoPrim
instances that cannot be made
Prim
instances, this involves a mild memory and speed bookkeeping
overhead.
Documentation
class PseudoPrim a where Source
data PseudoPrimInfo a Source
pp_sizeOf# :: PseudoPrimInfo a -> Int# Source
pp_alignment# :: PseudoPrimInfo a -> Int# Source
pp_indexByteArray# :: PseudoPrimInfo a -> ByteArray# -> Int# -> a Source
pp_readByteArray# :: PseudoPrimInfo a -> MutableByteArray# s -> Int# -> State# s -> (#State# s, a#) Source
pp_writeByteArray# :: PseudoPrimInfo a -> MutableByteArray# s -> Int# -> a -> State# s -> State# s Source
Do we need to evaluate the info in order to call these functions?
emptyInfo :: PseudoPrimInfo a Source
If seqInfo
returns True
, then this function is undefined.
Otherwise, it containes an empty PseudoPrimInfo
whose type is
sufficient to determine all the needed information.
PseudoPrim Char | |
PseudoPrim Double | |
PseudoPrim Float | |
PseudoPrim Int | |
PseudoPrim Word8 | |
PseudoPrim Word16 | |
PseudoPrim Word32 | |
PseudoPrim Word64 | |
PseudoPrim elem => PseudoPrim (Vector (Automatic Nat) elem) | |
(PseudoPrim elem, ViewParam Param_len (Vector (RunTime Nat) elem)) => PseudoPrim (Vector (RunTime Nat) elem) | |
(PseudoPrim elem, KnownNat len, Show elem) => PseudoPrim (Vector (Static Nat len) elem) |
pp_sizeOf :: PseudoPrim a => PseudoPrimInfo a -> Int Source
pp_alignment :: PseudoPrim a => PseudoPrimInfo a -> Int Source
pp_readByteArray :: (PseudoPrim a, PrimMonad m) => PseudoPrimInfo a -> MutableByteArray (PrimState m) -> Int -> m a Source
pp_writeByteArray :: (PseudoPrim a, PrimMonad m) => PseudoPrimInfo a -> MutableByteArray (PrimState m) -> Int -> a -> m () Source
pp_indexByteArray :: PseudoPrim a => PseudoPrimInfo a -> ByteArray -> Int -> a Source