License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
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
- 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 #
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 #
get the size in bytes of a ty element
primShiftToBytes :: Proxy ty -> Int #
get the shift size
primBaUIndex :: ByteArray# -> Offset ty -> ty #
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 #
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 #
Read a value from Addr in a specific primitive monad
primAddrWrite :: PrimMonad prim => Addr# -> Offset ty -> ty -> prim () #
Write a value to Addr in a specific primitive monad
Instances
class (Functor m, Applicative m, Monad m) => PrimMonad (m :: Type -> Type) where #
Primitive monad that can handle mutation.
For example: IO and ST.
type PrimState (m :: Type -> Type) :: Type #
type of state token associated with the PrimMonad m
type PrimVar (m :: Type -> Type) :: Type -> Type #
type of variable associated with the PrimMonad m
primitive :: (State# (PrimState m) -> (#State# (PrimState m), a#)) -> m a #
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 #
Throw Exception in the primitive monad
unPrimMonad :: m a -> State# (PrimState m) -> (#State# (PrimState m), a#) #
Run a Prim monad from a dedicated state#
primVarNew :: a -> m (PrimVar m a) #
Build a new variable in the Prim Monad
primVarRead :: PrimVar m a -> m a #
Read the variable in the Prim Monad
primVarWrite :: PrimVar m a -> a -> m () #
Write the variable in the Prim Monad
Instances
PrimMonad IO | |
Defined in Basement.Monad primitive :: (State# (PrimState IO) -> (#State# (PrimState IO), a#)) -> IO a # primThrow :: Exception e => e -> IO a # unPrimMonad :: IO a -> State# (PrimState IO) -> (#State# (PrimState IO), a#) # primVarNew :: a -> IO (PrimVar IO a) # primVarRead :: PrimVar IO a -> IO a # primVarWrite :: PrimVar IO a -> a -> IO () # | |
PrimMonad (ST s) | |
Defined in Basement.Monad primitive :: (State# (PrimState (ST s)) -> (#State# (PrimState (ST s)), a#)) -> ST s a # primThrow :: Exception e => e -> ST s a # unPrimMonad :: ST s a -> State# (PrimState (ST s)) -> (#State# (PrimState (ST s)), a#) # primVarNew :: a -> ST s (PrimVar (ST s) a) # primVarRead :: PrimVar (ST s) a -> ST s a # primVarWrite :: PrimVar (ST s) a -> a -> ST s () # |
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 #
Upsize an integral value
The destination type b
size need to be greater or equal
than the size type of a
integralUpsize :: a -> b #
Instances
class IntegralDownsize a b where #
Downsize an integral value
integralDownsize :: a -> b #
integralDownsizeCheck :: a -> Maybe b #
Instances
Evaluation
class NormalForm a where #
Data that can be fully evaluated in Normal Form
toNormalForm :: a -> () #
Instances
force :: NormalForm a => a -> a #
deepseq :: NormalForm a => a -> b -> b #
These
Either a or b or both.
Instances
Bifunctor These | |
Functor (These a) | |
(Eq a, Eq b) => Eq (These a b) | |
(Ord a, Ord b) => Ord (These a b) | |
Defined in Basement.These | |
(Show a, Show b) => Show (These a b) | |
(NormalForm a, NormalForm b) => NormalForm (These a b) | |
Defined in Basement.These toNormalForm :: These a b -> () # | |
From (Either a b) (These a b) | |
Defined in Basement.From |
Block of memory
A block of memory containing unpacked bytes representing values of type ty
Instances
data MutableBlock ty st #
A Mutable block of memory containing unpacked bytes representing values of type ty
Instances
Ascii
ASCII value between 0x0 and 0x7f
Instances
Eq Char7 | |
Ord Char7 | |
Show Char7 | |
NormalForm Char7 | |
Defined in Basement.NormalForm toNormalForm :: Char7 -> () # | |
PrimType Char7 | |
Defined in Basement.PrimType primSizeInBytes :: Proxy Char7 -> CountOf Word8 # primShiftToBytes :: Proxy Char7 -> Int # primBaUIndex :: ByteArray# -> Offset Char7 -> Char7 # primMbaURead :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Char7 -> prim Char7 # primMbaUWrite :: PrimMonad prim => MutableByteArray# (PrimState prim) -> Offset Char7 -> Char7 -> prim () # primAddrIndex :: Addr# -> Offset Char7 -> Char7 # primAddrRead :: PrimMonad prim => Addr# -> Offset Char7 -> prim Char7 # primAddrWrite :: PrimMonad prim => Addr# -> Offset Char7 -> Char7 -> prim () # | |
Arbitrary Char7 Source # | |
type PrimSize Char7 | |
Defined in Basement.PrimType | |
type NatNumMaxBound Char7 | |
Defined in Basement.Nat |
data AsciiString #
Opaque packed array of characters in the ASCII encoding