License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Foundation.Primitive
Description
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 #
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.
Methods
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
Arguments
:: 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
Arguments
:: 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.
Associated Types
type PrimState (m :: 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
Methods
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 Methods 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 Methods 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
Minimal complete definition
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
Methods
integralUpsize :: a -> b #
Instances
class IntegralDownsize a b where #
Downsize an integral value
Minimal complete definition
Instances
Evaluation
class NormalForm a where #
Data that can be fully evaluated in Normal Form
Methods
toNormalForm :: a -> () #
Instances
force :: NormalForm a => a -> a #
deepseq :: NormalForm a => a -> b -> b #
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 Methods toNormalForm :: These a b -> () # | |
(Eq a, Eq b) => Eq (These a b) | |
(Ord a, Ord b) => Ord (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 ty => Data (Block ty) | |
Defined in Basement.Block.Base Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Block ty -> c (Block ty) # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (Block ty) # toConstr :: Block ty -> Constr # dataTypeOf :: Block ty -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (Block ty)) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (Block ty)) # gmapT :: (forall b. Data b => b -> b) -> Block ty -> Block ty # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Block ty -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Block ty -> r # gmapQ :: (forall d. Data d => d -> u) -> Block ty -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Block ty -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Block ty -> m (Block ty) # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Block ty -> m (Block ty) # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Block ty -> m (Block ty) # | |
PrimType ty => Monoid (Block ty) | |
PrimType ty => Semigroup (Block ty) | |
PrimType ty => IsList (Block ty) | |
(PrimType ty, Show ty) => Show (Block ty) | |
NormalForm (Block ty) | |
Defined in Basement.Block.Base Methods toNormalForm :: Block ty -> () # | |
PrimType ty => Collection (Block ty) # | |
Defined in Foundation.Collection.Collection Methods length :: Block ty -> CountOf (Element (Block ty)) # elem :: (Eq a, a ~ Element (Block ty)) => Element (Block ty) -> Block ty -> Bool # notElem :: (Eq a, a ~ Element (Block ty)) => Element (Block ty) -> Block ty -> Bool # maximum :: (Ord a, a ~ Element (Block ty)) => NonEmpty (Block ty) -> Element (Block ty) # minimum :: (Ord a, a ~ Element (Block ty)) => NonEmpty (Block ty) -> Element (Block ty) # | |
PrimType ty => Copy (Block ty) # | |
Defined in Foundation.Collection.Copy | |
PrimType ty => Fold1able (Block ty) # | |
PrimType ty => Foldable (Block ty) # | |
PrimType ty => IndexedCollection (Block ty) # | |
PrimType ty => Sequential (Block ty) # | |
Defined in Foundation.Collection.Sequential Methods take :: CountOf (Element (Block ty)) -> Block ty -> Block ty # revTake :: CountOf (Element (Block ty)) -> Block ty -> Block ty # drop :: CountOf (Element (Block ty)) -> Block ty -> Block ty # revDrop :: CountOf (Element (Block ty)) -> Block ty -> Block ty # splitAt :: CountOf (Element (Block ty)) -> Block ty -> (Block ty, Block ty) # revSplitAt :: CountOf (Element (Block ty)) -> Block ty -> (Block ty, Block ty) # splitOn :: (Element (Block ty) -> Bool) -> Block ty -> [Block ty] # break :: (Element (Block ty) -> Bool) -> Block ty -> (Block ty, Block ty) # breakEnd :: (Element (Block ty) -> Bool) -> Block ty -> (Block ty, Block ty) # breakElem :: Element (Block ty) -> Block ty -> (Block ty, Block ty) # takeWhile :: (Element (Block ty) -> Bool) -> Block ty -> Block ty # dropWhile :: (Element (Block ty) -> Bool) -> Block ty -> Block ty # intersperse :: Element (Block ty) -> Block ty -> Block ty # intercalate :: Element (Block ty) -> Block ty -> Element (Block ty) # span :: (Element (Block ty) -> Bool) -> Block ty -> (Block ty, Block ty) # spanEnd :: (Element (Block ty) -> Bool) -> Block ty -> (Block ty, Block ty) # filter :: (Element (Block ty) -> Bool) -> Block ty -> Block ty # partition :: (Element (Block ty) -> Bool) -> Block ty -> (Block ty, Block ty) # reverse :: Block ty -> Block ty # uncons :: Block ty -> Maybe (Element (Block ty), Block ty) # unsnoc :: Block ty -> Maybe (Block ty, Element (Block ty)) # snoc :: Block ty -> Element (Block ty) -> Block ty # cons :: Element (Block ty) -> Block ty -> Block ty # find :: (Element (Block ty) -> Bool) -> Block ty -> Maybe (Element (Block ty)) # sortBy :: (Element (Block ty) -> Element (Block ty) -> Ordering) -> Block ty -> Block ty # singleton :: Element (Block ty) -> Block ty # head :: NonEmpty (Block ty) -> Element (Block ty) # last :: NonEmpty (Block ty) -> Element (Block ty) # tail :: NonEmpty (Block ty) -> Block ty # init :: NonEmpty (Block ty) -> Block ty # replicate :: CountOf (Element (Block ty)) -> Element (Block ty) -> Block ty # isPrefixOf :: Block ty -> Block ty -> Bool # isSuffixOf :: Block ty -> Block ty -> Bool # isInfixOf :: Block ty -> Block ty -> Bool # | |
(PrimType ty, Eq ty) => Eq (Block ty) | |
(PrimType ty, Ord ty) => Ord (Block ty) | |
Defined in Basement.Block.Base | |
Cast (Block a) (Block Word8) | |
PrimType ty => From (Block ty) (UArray ty) | |
Defined in Basement.From | |
PrimType ty => From (Array ty) (Block ty) | |
Defined in Basement.From | |
PrimType ty => From (UArray ty) (Block ty) | |
Defined in Basement.From | |
(NatWithinBound (CountOf ty) n, KnownNat n, PrimType ty) => TryFrom (Block ty) (BlockN n ty) | |
From (BlockN n ty) (Block ty) | |
Defined in Basement.From | |
type Item (Block ty) | |
Defined in Basement.Block.Base | |
type Element (Block ty) # | |
Defined in Foundation.Collection.Element |
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
Show Char7 | |
NormalForm Char7 | |
Defined in Basement.NormalForm Methods toNormalForm :: Char7 -> () # | |
PrimType Char7 | |
Defined in Basement.PrimType Methods 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 # | |
Defined in Foundation.Check.Arbitrary | |
Eq Char7 | |
Ord Char7 | |
type NatNumMaxBound Char7 | |
Defined in Basement.Nat | |
type PrimSize Char7 | |
Defined in Basement.PrimType |
data AsciiString #
Opaque packed array of characters in the ASCII encoding