primitive-maybe-0.1.1: Arrays of Maybes

Safe HaskellNone
LanguageHaskell2010

Data.Primitive.Array.Maybe

Description

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

Documentation

data MaybeArray a Source #

An immutable array of boxed values of type Maybe a.

Instances
Monad MaybeArray Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Methods

(>>=) :: MaybeArray a -> (a -> MaybeArray b) -> MaybeArray b #

(>>) :: MaybeArray a -> MaybeArray b -> MaybeArray b #

return :: a -> MaybeArray a #

fail :: String -> MaybeArray a #

Functor MaybeArray Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Methods

fmap :: (a -> b) -> MaybeArray a -> MaybeArray b #

(<$) :: a -> MaybeArray b -> MaybeArray a #

MonadFail MaybeArray Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Methods

fail :: String -> MaybeArray a #

Applicative MaybeArray Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Methods

pure :: a -> MaybeArray a #

(<*>) :: MaybeArray (a -> b) -> MaybeArray a -> MaybeArray b #

liftA2 :: (a -> b -> c) -> MaybeArray a -> MaybeArray b -> MaybeArray c #

(*>) :: MaybeArray a -> MaybeArray b -> MaybeArray b #

(<*) :: MaybeArray a -> MaybeArray b -> MaybeArray a #

Foldable MaybeArray Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Methods

fold :: Monoid m => MaybeArray m -> m #

foldMap :: Monoid m => (a -> m) -> MaybeArray a -> m #

foldr :: (a -> b -> b) -> b -> MaybeArray a -> b #

foldr' :: (a -> b -> b) -> b -> MaybeArray a -> b #

foldl :: (b -> a -> b) -> b -> MaybeArray a -> b #

foldl' :: (b -> a -> b) -> b -> MaybeArray a -> b #

foldr1 :: (a -> a -> a) -> MaybeArray a -> a #

foldl1 :: (a -> a -> a) -> MaybeArray a -> a #

toList :: MaybeArray a -> [a] #

null :: MaybeArray a -> Bool #

length :: MaybeArray a -> Int #

elem :: Eq a => a -> MaybeArray a -> Bool #

maximum :: Ord a => MaybeArray a -> a #

minimum :: Ord a => MaybeArray a -> a #

sum :: Num a => MaybeArray a -> a #

product :: Num a => MaybeArray a -> a #

Traversable MaybeArray Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Methods

traverse :: Applicative f => (a -> f b) -> MaybeArray a -> f (MaybeArray b) #

sequenceA :: Applicative f => MaybeArray (f a) -> f (MaybeArray a) #

mapM :: Monad m => (a -> m b) -> MaybeArray a -> m (MaybeArray b) #

sequence :: Monad m => MaybeArray (m a) -> m (MaybeArray a) #

Eq1 MaybeArray Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Methods

liftEq :: (a -> b -> Bool) -> MaybeArray a -> MaybeArray b -> Bool #

Ord1 MaybeArray Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Methods

liftCompare :: (a -> b -> Ordering) -> MaybeArray a -> MaybeArray b -> Ordering #

Read1 MaybeArray Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Show1 MaybeArray Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Methods

liftShowsPrec :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> Int -> MaybeArray a -> ShowS #

liftShowList :: (Int -> a -> ShowS) -> ([a] -> ShowS) -> [MaybeArray a] -> ShowS #

MonadZip MaybeArray Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Methods

mzip :: MaybeArray a -> MaybeArray b -> MaybeArray (a, b) #

mzipWith :: (a -> b -> c) -> MaybeArray a -> MaybeArray b -> MaybeArray c #

munzip :: MaybeArray (a, b) -> (MaybeArray a, MaybeArray b) #

Alternative MaybeArray Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

MonadPlus MaybeArray Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

IsList (MaybeArray a) Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Associated Types

type Item (MaybeArray a) :: * #

Eq a => Eq (MaybeArray a) Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Methods

(==) :: MaybeArray a -> MaybeArray a -> Bool #

(/=) :: MaybeArray a -> MaybeArray a -> Bool #

Data a => Data (MaybeArray a) Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> MaybeArray a -> c (MaybeArray a) #

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (MaybeArray a) #

toConstr :: MaybeArray a -> Constr #

dataTypeOf :: MaybeArray a -> DataType #

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (MaybeArray a)) #

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (MaybeArray a)) #

gmapT :: (forall b. Data b => b -> b) -> MaybeArray a -> MaybeArray a #

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> MaybeArray a -> r #

gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> MaybeArray a -> r #

gmapQ :: (forall d. Data d => d -> u) -> MaybeArray a -> [u] #

gmapQi :: Int -> (forall d. Data d => d -> u) -> MaybeArray a -> u #

gmapM :: Monad m => (forall d. Data d => d -> m d) -> MaybeArray a -> m (MaybeArray a) #

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> MaybeArray a -> m (MaybeArray a) #

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> MaybeArray a -> m (MaybeArray a) #

Ord a => Ord (MaybeArray a) Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Read a => Read (MaybeArray a) Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Show a => Show (MaybeArray a) Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Semigroup (MaybeArray a) Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

Monoid (MaybeArray a) Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

PrimUnlifted (MaybeArray a) Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

type Item (MaybeArray a) Source # 
Instance details

Defined in Data.Primitive.Array.Maybe

type Item (MaybeArray a) = a

data MutableMaybeArray s a Source #

A mutable array of boxed values of type Maybe a.

indexMaybeArray :: MaybeArray a -> Int -> Maybe a Source #

Get the Maybe value at the given index out of a MaybeArray.

newMaybeArray :: PrimMonad m => Int -> Maybe a -> m (MutableMaybeArray (PrimState m) a) Source #

Create a new MutableMaybeArray of the given size and initialize all elements with the given Maybe value.

readMaybeArray :: PrimMonad m => MutableMaybeArray (PrimState m) a -> Int -> m (Maybe a) Source #

Get the Maybe value at the given index out of a MutableMaybeArray.

writeMaybeArray :: PrimMonad m => MutableMaybeArray (PrimState m) a -> Int -> Maybe a -> m () Source #

Write a Maybe value to the given index of a MutableMaybeArray.

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 #

Convert a MutableMaybeArray to an immutable one without copying. The array should not be modified after the conversion.

thawMaybeArray Source #

Arguments

:: PrimMonad m 
=> MaybeArray a

source

-> Int

offset

-> Int

length

-> m (MutableMaybeArray (PrimState m) a) 

Create a MutablePrimArray 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.

maybeArrayFromList :: [a] -> MaybeArray a Source #

Given a list of a, build a MaybeArray from the values in the list.

maybeArrayFromListN :: Int -> [a] -> MaybeArray a Source #

Given the length of a list and a list of a, build a MaybeArray 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.

sizeofMaybeArray :: MaybeArray a -> Int Source #

Yield the size of the MaybeArray.