License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- class Eq ty => PrimType ty where
- type PrimSize ty :: Nat
- primSizeInBytes :: Proxy ty -> CountOf Word8
- primShiftToBytes :: Proxy ty -> Int
- primBaUIndex :: ByteArray# -> Offset ty -> ty
- primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset ty -> prim ty
- primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset ty -> ty -> prim ()
- primAddrIndex :: Addr# -> Offset ty -> ty
- primAddrRead :: PrimMonad prim => Addr# -> Offset ty -> prim ty
- primAddrWrite :: PrimMonad prim => Addr# -> Offset ty -> ty -> prim ()
- class (Functor m, Applicative m, Monad m) => PrimMonad (m :: Type -> Type) where
- type PrimState (m :: Type -> Type)
- type PrimVar (m :: Type -> Type) :: Type -> Type
- primitive :: (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
- primThrow :: Exception e => e -> m a
- unPrimMonad :: m a -> State# (PrimState m) -> (# State# (PrimState m), a #)
- primVarNew :: a -> m (PrimVar m a)
- primVarRead :: PrimVar m a -> m a
- primVarWrite :: PrimVar m a -> a -> m ()
- 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
- integralUpsize :: a -> b
- class IntegralDownsize a b where
- integralDownsize :: a -> b
- integralDownsizeCheck :: a -> Maybe b
- class NormalForm a where
- toNormalForm :: a -> ()
- force :: NormalForm a => a -> a
- deepseq :: NormalForm a => a -> b -> b
- data These a b
- data Block ty
- data MutableBlock ty st
- data Char7
- data AsciiString
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 :: Proxy ty -> CountOf Word8 Source #
get the size in bytes of a ty element
primShiftToBytes :: Proxy ty -> Int Source #
get the shift size
primBaUIndex :: ByteArray# -> Offset ty -> ty Source #
return the element stored at a specific index
:: PrimMonad prim | |
=> MutableByteArray# (PrimState prim) | mutable array to read from |
-> Offset ty | index of the element to retrieve |
-> prim ty | the element returned |
Read an element at an index in a mutable array
:: PrimMonad prim | |
=> MutableByteArray# (PrimState prim) | mutable array to modify |
-> Offset ty | index of the element to modify |
-> ty | the new value to store |
-> prim () |
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
Instances
class (Functor m, Applicative m, Monad m) => PrimMonad (m :: Type -> Type) where Source #
Primitive monad that can handle mutation.
For example: IO and ST.
type PrimState (m :: Type -> Type) Source #
type of state token associated with the PrimMonad m
type PrimVar (m :: Type -> Type) :: Type -> Type 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
Instances
PrimMonad IO | |
Defined in Basement.Monad primitive :: (State# (PrimState IO) -> (# State# (PrimState IO), a #)) -> IO a Source # primThrow :: Exception e => e -> IO a Source # unPrimMonad :: IO a -> State# (PrimState IO) -> (# State# (PrimState IO), a #) Source # primVarNew :: a -> IO (PrimVar IO a) Source # | |
PrimMonad (ST s) | |
Defined in Basement.Monad primitive :: (State# (PrimState (ST s)) -> (# State# (PrimState (ST s)), a #)) -> ST s a Source # primThrow :: Exception e => e -> ST s a Source # unPrimMonad :: ST s a -> State# (PrimState (ST s)) -> (# State# (PrimState (ST s)), a #) Source # primVarNew :: a -> ST s (PrimVar (ST s) a) Source # |
endianess
Class of types that can be byte-swapped.
e.g. Word16, Word32, Word64
byteSwap
Little Endian value
Instances
Big Endian value
Instances
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 #
Instances
class IntegralDownsize a b where Source #
Downsize an integral value
integralDownsize :: a -> b Source #
integralDownsizeCheck :: a -> Maybe b Source #
Instances
Evaluation
class NormalForm a where Source #
Data that can be fully evaluated in Normal Form
toNormalForm :: a -> () Source #
Instances
force :: NormalForm a => a -> a Source #
deepseq :: NormalForm a => a -> b -> b Source #
These
Either a or b or both.
Instances
(Show a, Show b) => Show (These a b) | |
(NormalForm a, NormalForm b) => NormalForm (These a b) | |
Defined in Basement.These toNormalForm :: These a b -> () Source # | |
(Eq a, Eq b) => Eq (These a b) | |
(Ord a, Ord b) => Ord (These a b) | |
Defined in Basement.These | |
From (Either a b) (These a b) | |
Block of memory
A block of memory containing unpacked bytes representing values of type ty
Instances
data MutableBlock ty st Source #
A Mutable block of memory containing unpacked bytes representing values of type ty
Instances
Ascii
ASCII value between 0x0 and 0x7f
Instances
Show Char7 | |
NormalForm Char7 | |
Defined in Basement.NormalForm toNormalForm :: Char7 -> () Source # | |
PrimType Char7 | |
Defined in Basement.PrimType primSizeInBytes :: Proxy Char7 -> CountOf Word8 Source # primShiftToBytes :: Proxy Char7 -> Int Source # primBaUIndex :: ByteArray# -> Offset Char7 -> Char7 Source # primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Char7 -> prim Char7 Source # primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Char7 -> Char7 -> prim () Source # primAddrIndex :: Addr# -> Offset Char7 -> Char7 Source # primAddrRead :: PrimMonad prim => Addr# -> Offset Char7 -> prim Char7 Source # primAddrWrite :: PrimMonad prim => Addr# -> Offset Char7 -> Char7 -> prim () Source # | |
Arbitrary Char7 Source # | |
Eq Char7 | |
Ord Char7 | |
type NatNumMaxBound Char7 | |
Defined in Basement.Nat | |
type PrimSize Char7 | |
Defined in Basement.PrimType |
data AsciiString Source #
Opaque packed array of characters in the ASCII encoding