License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Different collections (list, vector, string, ..) unified under 1 API. an API to rules them all, and in the darkness bind them.
- class Eq ty => PrimType ty where
- class (Functor m, Applicative m, Monad m) => PrimMonad m where
- class ByteSwap a
- newtype LE a = LE {
- unLE :: a
- toLE :: ByteSwap a => a -> LE a
- fromLE :: ByteSwap a => LE a -> a
- newtype BE a = BE {
- unBE :: a
- toBE :: ByteSwap a => a -> BE a
- fromBE :: ByteSwap a => BE a -> a
- class IntegralUpsize a b where
- class IntegralDownsize a b where
- class IntegralCast a b where
- class NormalForm a where
- force :: NormalForm a => a -> a
- deepseq :: NormalForm a => a -> b -> b
- data These a b
- data Block ty
- data MutableBlock ty st
Documentation
class Eq ty => PrimType ty where Source #
Represent the accessor for types that can be stored in the UArray and MUArray.
Types need to be a instance of storable and have fixed sized.
primSizeInBytes, primBaUIndex, primMbaURead, primMbaUWrite, primAddrIndex, primAddrRead, primAddrWrite
primSizeInBytes :: Proxy ty -> Size8 Source #
get the size in bytes of a ty element
primBaUIndex :: ByteArray# -> Offset ty -> ty Source #
return the element stored at a specific index
primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset ty -> prim ty Source #
Read an element at an index in a mutable array
primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim () Source #
Write an element to a specific cell in a mutable array.
primAddrIndex :: Addr# -> Offset ty -> ty Source #
Read from Address, without a state. the value read should be considered a constant for all pratical purpose, otherwise bad thing will happens.
primAddrRead :: PrimMonad prim => Addr# -> Offset ty -> prim ty Source #
Read a value from Addr in a specific primitive monad
primAddrWrite :: PrimMonad prim => Addr# -> Offset ty -> ty -> prim () Source #
Write a value to Addr in a specific primitive monad
class (Functor m, Applicative m, Monad m) => PrimMonad m where Source #
Primitive monad that can handle mutation.
For example: IO and ST.
type of state token associated with the PrimMonad m
type PrimVar m :: * -> * Source #
type of variable associated with the PrimMonad m
primitive :: (State# (PrimState m) -> (#State# (PrimState m), a#)) -> m a Source #
Unwrap the State# token to pass to a function a primitive function that returns an unboxed state and a value.
primThrow :: Exception e => e -> m a Source #
Throw Exception in the primitive monad
unPrimMonad :: m a -> State# (PrimState m) -> (#State# (PrimState m), a#) Source #
Run a Prim monad from a dedicated state#
primVarNew :: a -> m (PrimVar m a) Source #
Build a new variable in the Prim Monad
primVarRead :: PrimVar m a -> m a Source #
Read the variable in the Prim Monad
primVarWrite :: PrimVar m a -> a -> m () Source #
Write the variable in the Prim Monad
endianess
Class of types that can be byte-swapped.
e.g. Word16, Word32, Word64
byteSwap
Little Endian value
Eq a => Eq (LE a) Source # | |
(ByteSwap a, Ord a) => Ord (LE a) Source # | |
Show a => Show (LE a) Source # | |
PrimType a => PrimType (LE a) Source # | |
StorableFixed (LE Word16) Source # | |
StorableFixed (LE Word32) Source # | |
StorableFixed (LE Word64) Source # | |
Storable (LE Word16) Source # | |
Storable (LE Word32) Source # | |
Storable (LE Word64) Source # | |
Big Endian value
Eq a => Eq (BE a) Source # | |
(ByteSwap a, Ord a) => Ord (BE a) Source # | |
Show a => Show (BE a) Source # | |
PrimType a => PrimType (BE a) Source # | |
StorableFixed (BE Word16) Source # | |
StorableFixed (BE Word32) Source # | |
StorableFixed (BE Word64) Source # | |
Storable (BE Word16) Source # | |
Storable (BE Word32) Source # | |
Storable (BE Word64) Source # | |
Integral convertion
class IntegralUpsize a b where Source #
Upsize an integral value
The destination type b
size need to be greater or equal
than the size type of a
integralUpsize :: a -> b Source #
class IntegralDownsize a b where Source #
Downsize an integral value
integralDownsize :: a -> b Source #
integralDownsize :: a ~ b => a -> b Source #
integralDownsizeCheck :: a -> Maybe b Source #
class IntegralCast a b where Source #
Cast an integral value to another value that have the same representional size
integralCast :: a -> b Source #
integralCast :: a ~ b => a -> b Source #
IntegralCast Int Word Source # | |
IntegralCast Int64 Word64 Source # | |
IntegralCast Word Int Source # | |
IntegralCast Word64 Int64 Source # | |
IntegralCast Int (CountOf ty) Source # | |
IntegralCast Int (Offset ty) Source # | |
IntegralCast Word (CountOf ty) Source # | |
IntegralCast Word (Offset ty) Source # | |
Evaluation
class NormalForm a where Source #
Data that can be fully evaluated in Normal Form
toNormalForm :: a -> () Source #
force :: NormalForm a => a -> a Source #
deepseq :: NormalForm a => a -> b -> b Source #
These
Either a or b or both.
Block of memory
A block of memory containing unpacked bytes representing values of type ty
PrimType ty => IsList (Block ty) Source # | |
(PrimType ty, Eq ty) => Eq (Block ty) Source # | |
Data ty => Data (Block ty) Source # | |
(PrimType ty, Ord ty) => Ord (Block ty) Source # | |
(PrimType ty, Show ty) => Show (Block ty) Source # | |
PrimType ty => Monoid (Block ty) Source # | |
NormalForm (Block ty) Source # | |
PrimType ty => Copy (Block ty) Source # | |
PrimType ty => Collection (Block ty) Source # | |
PrimType ty => Foldable (Block ty) Source # | |
PrimType ty => IndexedCollection (Block ty) Source # | |
PrimType ty => Sequential (Block ty) Source # | |
type Item (Block ty) Source # | |
type Element (Block ty) Source # | |
data MutableBlock ty st Source #
A Mutable block of memory containing unpacked bytes representing values of type ty
PrimType ty => MutableCollection (MutableBlock ty) Source # | |
type MutableFreezed (MutableBlock ty) Source # | |
type MutableKey (MutableBlock ty) Source # | |
type MutableValue (MutableBlock ty) Source # | |