Safe Haskell | None |
---|---|
Language | Haskell2010 |
This provides an interface to working with boxed arrays
with elements of type Maybe a
. That is:
SmallMaybeArray a ≅ SmallArray (Maybe a)
However, this type provided by this module is more efficient
than its naive SmallArray
counterpart. It consumes less
memory and has fewer heap indirections.
Synopsis
- data SmallMaybeArray a
- data SmallMutableMaybeArray s a
- indexSmallMaybeArray :: SmallMaybeArray a -> Int -> Maybe a
- newSmallMaybeArray :: PrimMonad m => Int -> Maybe a -> m (SmallMutableMaybeArray (PrimState m) a)
- readSmallMaybeArray :: PrimMonad m => SmallMutableMaybeArray (PrimState m) a -> Int -> m (Maybe a)
- writeSmallMaybeArray :: PrimMonad m => SmallMutableMaybeArray (PrimState m) a -> Int -> Maybe a -> m ()
- sequenceSmallMaybeArray :: SmallMaybeArray a -> Maybe (SmallArray a)
- unsafeFreezeSmallMaybeArray :: PrimMonad m => SmallMutableMaybeArray (PrimState m) a -> m (SmallMaybeArray a)
- thawSmallMaybeArray :: PrimMonad m => SmallMaybeArray a -> Int -> Int -> m (SmallMutableMaybeArray (PrimState m) a)
- smallMaybeArrayFromList :: [a] -> SmallMaybeArray a
- smallMaybeArrayFromListN :: Int -> [a] -> SmallMaybeArray a
- sizeofSmallMaybeArray :: SmallMaybeArray a -> Int
Documentation
data SmallMaybeArray a Source #
An immutable array of boxed values of type
.Maybe
a
Instances
data SmallMutableMaybeArray s a Source #
A mutable array of boxed values of type
.Maybe
a
Instances
PrimUnlifted (SmallMutableMaybeArray s a) Source # | |
Defined in Data.Primitive.SmallArray.Maybe toArrayArray# :: SmallMutableMaybeArray s a -> ArrayArray# # fromArrayArray# :: ArrayArray# -> SmallMutableMaybeArray s a # |
indexSmallMaybeArray :: SmallMaybeArray a -> Int -> Maybe a Source #
Get the Maybe
value at the given index out of a SmallMaybeArray
.
newSmallMaybeArray :: PrimMonad m => Int -> Maybe a -> m (SmallMutableMaybeArray (PrimState m) a) Source #
Create a new SmallMutableMaybeArray
of the given size and initialize all elements with the given Maybe
value.
readSmallMaybeArray :: PrimMonad m => SmallMutableMaybeArray (PrimState m) a -> Int -> m (Maybe a) Source #
Get the Maybe
value at the given index out of a SmallMutableMaybeArray
.
writeSmallMaybeArray :: PrimMonad m => SmallMutableMaybeArray (PrimState m) a -> Int -> Maybe a -> m () Source #
Write a Maybe
value to the given index of a SmallMutableMaybeArray
.
sequenceSmallMaybeArray :: SmallMaybeArray a -> Maybe (SmallArray a) Source #
This is like calling sequence
on a SmallArray
. However, in
the event that all the values are Just
, it does not need
to allocate a new array since the array backing the SmallMaybeArray
can be reused.
unsafeFreezeSmallMaybeArray :: PrimMonad m => SmallMutableMaybeArray (PrimState m) a -> m (SmallMaybeArray a) Source #
Convert a SmallMutableMaybeArray
to an immutable one without copying.
The array should not be modified after the conversion.
:: PrimMonad m | |
=> SmallMaybeArray a | source |
-> Int | offset |
-> Int | length |
-> m (SmallMutableMaybeArray (PrimState m) a) |
Create a SmallMutableMaybeArray
from a slice of an immutable array. This operation makes a copy of
the specified slice, so it is safe to use the immutable array afterward.
smallMaybeArrayFromList :: [a] -> SmallMaybeArray a Source #
Given a list of a
, build a SmallMaybeArray
from the values in the list.
smallMaybeArrayFromListN :: Int -> [a] -> SmallMaybeArray a Source #
Given the length of the list and a list of a
, build a SmallMaybeArray
from the values in the list.
If the given Int
does not match the length of the list, this function calls error
. You should prefer
this to maybeArrayFromList
if the length of the list has already been computed.
sizeofSmallMaybeArray :: SmallMaybeArray a -> Int Source #
Yield the size of the SmallMaybeArray
.