primitive-maybe-0.1.1.1: Arrays of Maybes

Safe HaskellNone
LanguageHaskell2010

Data.Primitive.SmallArray.Maybe

Description

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

Documentation

data SmallMaybeArray a Source #

An immutable array of boxed values of type Maybe a.

Instances
Monad SmallMaybeArray Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

Functor SmallMaybeArray Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

Methods

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

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

MonadFail SmallMaybeArray Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

Methods

fail :: String -> SmallMaybeArray a #

Applicative SmallMaybeArray Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

Foldable SmallMaybeArray Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

Methods

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

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

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

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

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

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

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

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

toList :: SmallMaybeArray a -> [a] #

null :: SmallMaybeArray a -> Bool #

length :: SmallMaybeArray a -> Int #

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

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

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

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

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

Traversable SmallMaybeArray Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

Methods

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

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

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

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

Eq1 SmallMaybeArray Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

Methods

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

Ord1 SmallMaybeArray Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

Methods

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

Read1 SmallMaybeArray Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

Show1 SmallMaybeArray Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

Methods

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

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

MonadZip SmallMaybeArray Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

Alternative SmallMaybeArray Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

MonadPlus SmallMaybeArray Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

IsList (SmallMaybeArray a) Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

Associated Types

type Item (SmallMaybeArray a) :: Type #

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

Defined in Data.Primitive.SmallArray.Maybe

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

Defined in Data.Primitive.SmallArray.Maybe

Methods

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

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

toConstr :: SmallMaybeArray a -> Constr #

dataTypeOf :: SmallMaybeArray a -> DataType #

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

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

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

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

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

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

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

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

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

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

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

Defined in Data.Primitive.SmallArray.Maybe

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

Defined in Data.Primitive.SmallArray.Maybe

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

Defined in Data.Primitive.SmallArray.Maybe

Semigroup (SmallMaybeArray a) Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

Monoid (SmallMaybeArray a) Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

PrimUnlifted (SmallMaybeArray a) Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

type Item (SmallMaybeArray a) Source # 
Instance details

Defined in Data.Primitive.SmallArray.Maybe

type Item (SmallMaybeArray a) = a

data SmallMutableMaybeArray s a Source #

A mutable array of boxed values of type Maybe 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.

thawSmallMaybeArray Source #

Arguments

:: 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.