Safe Haskell | None |
---|---|
Language | Haskell2010 |
This provides an interface to working with boxed arrays
with elements of type Maybe a
. That is:
MaybeArray a ≅ Array (Maybe a)
However, this type provided by this module is more efficient
than its naive Array
counterpart. It consumes less
memory and has fewer heap indirections.
Synopsis
- data MaybeArray a
- data MutableMaybeArray s a
- indexMaybeArray :: MaybeArray a -> Int -> Maybe a
- newMaybeArray :: PrimMonad m => Int -> Maybe a -> m (MutableMaybeArray (PrimState m) a)
- readMaybeArray :: PrimMonad m => MutableMaybeArray (PrimState m) a -> Int -> m (Maybe a)
- writeMaybeArray :: PrimMonad m => MutableMaybeArray (PrimState m) a -> Int -> Maybe a -> m ()
- sequenceMaybeArray :: MaybeArray a -> Maybe (Array a)
- unsafeFreezeMaybeArray :: PrimMonad m => MutableMaybeArray (PrimState m) a -> m (MaybeArray a)
Documentation
data MaybeArray a Source #
data MutableMaybeArray s a Source #
indexMaybeArray :: MaybeArray a -> Int -> Maybe a Source #
newMaybeArray :: PrimMonad m => Int -> Maybe a -> m (MutableMaybeArray (PrimState m) a) Source #
readMaybeArray :: PrimMonad m => MutableMaybeArray (PrimState m) a -> Int -> m (Maybe a) Source #
writeMaybeArray :: PrimMonad m => MutableMaybeArray (PrimState m) a -> Int -> Maybe a -> m () Source #
sequenceMaybeArray :: MaybeArray a -> Maybe (Array a) Source #
This is like calling sequence
on an Array
. However, in
the event that all the values are Just
, it does not need
to allocate a new array since the array backing the MaybeArray
can be reused.
unsafeFreezeMaybeArray :: PrimMonad m => MutableMaybeArray (PrimState m) a -> m (MaybeArray a) Source #