typeparams-0.0.6: Lens-like interface for type level parameters; allows unboxed unboxed vectors and supercompilation

Safe HaskellNone



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.


class PseudoPrim a where Source

Associated Types

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

seqInfo :: a -> Bool 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.