License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Different collections (list, vector, string, ..) unified under 1 API. an API to rules them all, and in the darkness bind them.
Synopsis
- class Zippable col => BoxedZippable col where
- zip :: (Sequential a, Sequential b, Element col ~ (Element a, Element b)) => a -> b -> col
- zip3 :: (Sequential a, Sequential b, Sequential c, Element col ~ (Element a, Element b, Element c)) => a -> b -> c -> col
- zip4 :: (Sequential a, Sequential b, Sequential c, Sequential d, Element col ~ (Element a, Element b, Element c, Element d)) => a -> b -> c -> d -> col
- zip5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Element col ~ (Element a, Element b, Element c, Element d, Element e)) => a -> b -> c -> d -> e -> col
- zip6 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Element col ~ (Element a, Element b, Element c, Element d, Element e, Element f)) => a -> b -> c -> d -> e -> f -> col
- zip7 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Sequential g, Element col ~ (Element a, Element b, Element c, Element d, Element e, Element f, Element g)) => a -> b -> c -> d -> e -> f -> g -> col
- unzip :: (Sequential a, Sequential b, Element col ~ (Element a, Element b)) => col -> (a, b)
- unzip3 :: (Sequential a, Sequential b, Sequential c, Element col ~ (Element a, Element b, Element c)) => col -> (a, b, c)
- unzip4 :: (Sequential a, Sequential b, Sequential c, Sequential d, Element col ~ (Element a, Element b, Element c, Element d)) => col -> (a, b, c, d)
- unzip5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Element col ~ (Element a, Element b, Element c, Element d, Element e)) => col -> (a, b, c, d, e)
- unzip6 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Element col ~ (Element a, Element b, Element c, Element d, Element e, Element f)) => col -> (a, b, c, d, e, f)
- unzip7 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Sequential g, Element col ~ (Element a, Element b, Element c, Element d, Element e, Element f, Element g)) => col -> (a, b, c, d, e, f, g)
- type family Element container
- class InnerFunctor c where
- class Foldable collection where
- class Foldable f => Fold1able f where
- class Functor collection => Mappable collection where
- traverse :: Applicative f => (a -> f b) -> collection a -> f (collection b)
- sequenceA :: Applicative f => collection (f a) -> f (collection a)
- mapM :: (Applicative m, Monad m) => (a -> m b) -> collection a -> m (collection b)
- sequence :: (Applicative m, Monad m) => collection (m a) -> m (collection a)
- traverse_ :: (Mappable col, Applicative f) => (a -> f b) -> col a -> f ()
- mapM_ :: (Mappable col, Applicative m, Monad m) => (a -> m b) -> col a -> m ()
- forM :: (Mappable col, Applicative m, Monad m) => col a -> (a -> m b) -> m (col b)
- forM_ :: (Mappable col, Applicative m, Monad m) => col a -> (a -> m b) -> m ()
- class (IsList c, Item c ~ Element c) => Collection c where
- null :: c -> Bool
- length :: c -> CountOf (Element c)
- elem :: forall a. (Eq a, a ~ Element c) => Element c -> c -> Bool
- notElem :: forall a. (Eq a, a ~ Element c) => Element c -> c -> Bool
- maximum :: forall a. (Ord a, a ~ Element c) => NonEmpty c -> Element c
- minimum :: forall a. (Ord a, a ~ Element c) => NonEmpty c -> Element c
- any :: (Element c -> Bool) -> c -> Bool
- all :: (Element c -> Bool) -> c -> Bool
- and :: (Collection col, Element col ~ Bool) => col -> Bool
- or :: (Collection col, Element col ~ Bool) => col -> Bool
- data NonEmpty a
- getNonEmpty :: NonEmpty a -> a
- nonEmpty :: Collection c => c -> Maybe (NonEmpty c)
- nonEmpty_ :: Collection c => c -> NonEmpty c
- nonEmptyFmap :: Functor f => (a -> b) -> NonEmpty (f a) -> NonEmpty (f b)
- class (IsList c, Item c ~ Element c, Monoid c, Collection c) => Sequential c where
- take :: CountOf (Element c) -> c -> c
- revTake :: CountOf (Element c) -> c -> c
- drop :: CountOf (Element c) -> c -> c
- revDrop :: CountOf (Element c) -> c -> c
- splitAt :: CountOf (Element c) -> c -> (c, c)
- revSplitAt :: CountOf (Element c) -> c -> (c, c)
- splitOn :: (Element c -> Bool) -> c -> [c]
- break :: (Element c -> Bool) -> c -> (c, c)
- breakEnd :: (Element c -> Bool) -> c -> (c, c)
- breakElem :: Eq (Element c) => Element c -> c -> (c, c)
- takeWhile :: (Element c -> Bool) -> c -> c
- dropWhile :: (Element c -> Bool) -> c -> c
- intersperse :: Element c -> c -> c
- intercalate :: Monoid (Item c) => Element c -> c -> Element c
- span :: (Element c -> Bool) -> c -> (c, c)
- spanEnd :: (Element c -> Bool) -> c -> (c, c)
- filter :: (Element c -> Bool) -> c -> c
- partition :: (Element c -> Bool) -> c -> (c, c)
- reverse :: c -> c
- uncons :: c -> Maybe (Element c, c)
- unsnoc :: c -> Maybe (c, Element c)
- snoc :: c -> Element c -> c
- cons :: Element c -> c -> c
- find :: (Element c -> Bool) -> c -> Maybe (Element c)
- sortBy :: (Element c -> Element c -> Ordering) -> c -> c
- singleton :: Element c -> c
- head :: NonEmpty c -> Element c
- last :: NonEmpty c -> Element c
- tail :: NonEmpty c -> c
- init :: NonEmpty c -> c
- replicate :: CountOf (Element c) -> Element c -> c
- isPrefixOf :: Eq (Element c) => c -> c -> Bool
- isSuffixOf :: Eq (Element c) => c -> c -> Bool
- isInfixOf :: Eq (Element c) => c -> c -> Bool
- stripPrefix :: Eq (Element c) => c -> c -> Maybe c
- stripSuffix :: Eq (Element c) => c -> c -> Maybe c
- class MutableCollection c where
- type MutableFreezed c
- type MutableKey c
- type MutableValue c
- unsafeThaw :: PrimMonad prim => MutableFreezed c -> prim (c (PrimState prim))
- unsafeFreeze :: PrimMonad prim => c (PrimState prim) -> prim (MutableFreezed c)
- thaw :: PrimMonad prim => MutableFreezed c -> prim (c (PrimState prim))
- freeze :: PrimMonad prim => c (PrimState prim) -> prim (MutableFreezed c)
- mutNew :: PrimMonad prim => CountOf (MutableValue c) -> prim (c (PrimState prim))
- mutUnsafeWrite :: PrimMonad prim => c (PrimState prim) -> MutableKey c -> MutableValue c -> prim ()
- mutWrite :: PrimMonad prim => c (PrimState prim) -> MutableKey c -> MutableValue c -> prim ()
- mutUnsafeRead :: PrimMonad prim => c (PrimState prim) -> MutableKey c -> prim (MutableValue c)
- mutRead :: PrimMonad prim => c (PrimState prim) -> MutableKey c -> prim (MutableValue c)
- class IndexedCollection c where
- class KeyedCollection c where
- class Sequential col => Zippable col where
- zipWith :: (Sequential a, Sequential b) => (Element a -> Element b -> Element col) -> a -> b -> col
- zipWith3 :: (Sequential a, Sequential b, Sequential c) => (Element a -> Element b -> Element c -> Element col) -> a -> b -> c -> col
- zipWith4 :: (Sequential a, Sequential b, Sequential c, Sequential d) => (Element a -> Element b -> Element c -> Element d -> Element col) -> a -> b -> c -> d -> col
- zipWith5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element col) -> a -> b -> c -> d -> e -> col
- zipWith6 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element f -> Element col) -> a -> b -> c -> d -> e -> f -> col
- zipWith7 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Sequential g) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element f -> Element g -> Element col) -> a -> b -> c -> d -> e -> f -> g -> col
- class Buildable col where
- build_ :: (Buildable c, PrimMonad prim) => Int -> Builder c (Mutable c) (Step c) prim () () -> prim c
- newtype Builder collection (mutCollection :: Type -> Type) step (state :: Type -> Type) err a = Builder {
- runBuilder :: State (Offset step, BuildingState collection mutCollection step (PrimState state), Maybe err) state a
- data BuildingState collection (mutCollection :: Type -> Type) step state = BuildingState {
- prevChunks :: [collection]
- prevChunksSize :: !(CountOf step)
- curChunk :: mutCollection state
- chunkSize :: !(CountOf step)
- class Copy a where
- copy :: a -> a
Documentation
class Zippable col => BoxedZippable col where Source #
Nothing
zip :: (Sequential a, Sequential b, Element col ~ (Element a, Element b)) => a -> b -> col Source #
zip
takes two collections and returns a collections of corresponding
pairs. If one input collection is short, excess elements of the longer
collection are discarded.
zip3 :: (Sequential a, Sequential b, Sequential c, Element col ~ (Element a, Element b, Element c)) => a -> b -> c -> col Source #
Like zip
, but works with 3 collections.
zip4 :: (Sequential a, Sequential b, Sequential c, Sequential d, Element col ~ (Element a, Element b, Element c, Element d)) => a -> b -> c -> d -> col Source #
Like zip
, but works with 4 collections.
zip5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Element col ~ (Element a, Element b, Element c, Element d, Element e)) => a -> b -> c -> d -> e -> col Source #
Like zip
, but works with 5 collections.
zip6 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Element col ~ (Element a, Element b, Element c, Element d, Element e, Element f)) => a -> b -> c -> d -> e -> f -> col Source #
Like zip
, but works with 6 collections.
zip7 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Sequential g, Element col ~ (Element a, Element b, Element c, Element d, Element e, Element f, Element g)) => a -> b -> c -> d -> e -> f -> g -> col Source #
Like zip
, but works with 7 collections.
unzip :: (Sequential a, Sequential b, Element col ~ (Element a, Element b)) => col -> (a, b) Source #
unzip
transforms a collection of pairs into a collection of first
components and a collection of second components.
unzip3 :: (Sequential a, Sequential b, Sequential c, Element col ~ (Element a, Element b, Element c)) => col -> (a, b, c) Source #
Like unzip
, but works on a collection of 3-element tuples.
unzip4 :: (Sequential a, Sequential b, Sequential c, Sequential d, Element col ~ (Element a, Element b, Element c, Element d)) => col -> (a, b, c, d) Source #
Like unzip
, but works on a collection of 4-element tuples.
unzip5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Element col ~ (Element a, Element b, Element c, Element d, Element e)) => col -> (a, b, c, d, e) Source #
Like unzip
, but works on a collection of 5-element tuples.
unzip6 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Element col ~ (Element a, Element b, Element c, Element d, Element e, Element f)) => col -> (a, b, c, d, e, f) Source #
Like unzip
, but works on a collection of 6-element tuples.
unzip7 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Sequential g, Element col ~ (Element a, Element b, Element c, Element d, Element e, Element f, Element g)) => col -> (a, b, c, d, e, f, g) Source #
Like unzip
, but works on a collection of 7-element tuples.
Instances
type family Element container Source #
Element type of a collection
Instances
class InnerFunctor c where Source #
A monomorphic functor that maps the inner values to values of the same type
Nothing
Instances
InnerFunctor String Source # | |
InnerFunctor Bitmap Source # | |
InnerFunctor (Array ty) Source # | |
PrimType ty => InnerFunctor (UArray ty) Source # | |
InnerFunctor [a] Source # | |
class Foldable collection where Source #
Give the ability to fold a collection on itself
foldl' :: (a -> Element collection -> a) -> a -> collection -> a Source #
Left-associative fold of a structure.
In the case of lists, foldl, when applied to a binary operator, a starting value (typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:
foldl f z [x1, x2, ..., xn] == (...((z `f` x1) `f` x2) `f`...) `f` xn
Note that to produce the outermost application of the operator the entire input list must be traversed. This means that foldl' will diverge if given an infinite list.
Note that Foundation only provides foldl'
, a strict version of foldl
because
the lazy version is seldom useful.
Left-associative fold of a structure with strict application of the operator.
foldr :: (Element collection -> a -> a) -> a -> collection -> a Source #
Right-associative fold of a structure.
foldr f z [x1, x2, ..., xn] == x1 `f` (x2 `f` ... (xn `f` z)...)
foldr' :: (Element collection -> a -> a) -> a -> collection -> a Source #
Right-associative fold of a structure, but with strict application of the operator.
Instances
Foldable Bitmap Source # | |
PrimType ty => Foldable (Block ty) Source # | |
Foldable (Array ty) Source # | |
PrimType ty => Foldable (UArray ty) Source # | |
PrimType ty => Foldable (ChunkedUArray ty) Source # | |
Defined in Foundation.Array.Chunked.Unboxed foldl' :: (a -> Element (ChunkedUArray ty) -> a) -> a -> ChunkedUArray ty -> a Source # foldr :: (Element (ChunkedUArray ty) -> a -> a) -> a -> ChunkedUArray ty -> a Source # foldr' :: (Element (ChunkedUArray ty) -> a -> a) -> a -> ChunkedUArray ty -> a Source # | |
Foldable (DList a) Source # | |
Foldable [a] Source # | |
PrimType ty => Foldable (BlockN n ty) Source # | |
Foldable (ListN n a) Source # | |
class Foldable f => Fold1able f where Source #
Fold1's. Like folds, but they assume to operate on a NonEmpty collection.
foldl1' :: (Element f -> Element f -> Element f) -> NonEmpty f -> Element f Source #
Left associative strict fold.
foldr1 :: (Element f -> Element f -> Element f) -> NonEmpty f -> Element f Source #
Right associative lazy fold.
class Functor collection => Mappable collection where Source #
Functors representing data structures that can be traversed from left to right.
Mostly like base's Traversable
but applied to collections only.
traverse :: Applicative f => (a -> f b) -> collection a -> f (collection b) Source #
Map each element of a structure to an action, evaluate these actions
from left to right, and collect the results. For a version that ignores
the results see traverse_
.
sequenceA :: Applicative f => collection (f a) -> f (collection a) Source #
Evaluate each actions of the given collections, from left to right,
and collect the results. For a version that ignores the results, see
sequenceA_
mapM :: (Applicative m, Monad m) => (a -> m b) -> collection a -> m (collection b) Source #
Map each element of the collection to an action, evaluate these actions
from left to right, and collect the results. For a version that ignores
the results see mapM_
.
sequence :: (Applicative m, Monad m) => collection (m a) -> m (collection a) Source #
Evaluate each actions of the given collections, from left to right,
and collect the results. For a version that ignores the results, see
sequence_
Instances
Mappable Array Source # | |
Defined in Foundation.Collection.Mappable | |
Mappable List Source # | |
Defined in Foundation.Collection.Mappable traverse :: Applicative f => (a -> f b) -> [a] -> f [b] Source # sequenceA :: Applicative f => [f a] -> f [a] Source # mapM :: (Applicative m, Monad m) => (a -> m b) -> [a] -> m [b] Source # sequence :: (Applicative m, Monad m) => [m a] -> m [a] Source # |
traverse_ :: (Mappable col, Applicative f) => (a -> f b) -> col a -> f () Source #
Map each element of a collection to an action, evaluate these
actions from left to right, and ignore the results. For a version
that doesn't ignore the results see traverse
mapM_ :: (Mappable col, Applicative m, Monad m) => (a -> m b) -> col a -> m () Source #
Evaluate each action in the collection from left to right, and
ignore the results. For a version that doesn't ignore the results
see sequenceA
.
sequenceA_ :: (Mappable col, Applicative f) => col (f a) -> f ()
sequenceA_ col = sequenceA col *> pure ()
Map each element of a collection to a monadic action, evaluate
these actions from left to right, and ignore the results. For a
version that doesn't ignore the results see
mapM
.
class (IsList c, Item c ~ Element c) => Collection c where Source #
A set of methods for ordered colection
Check if a collection is empty
length :: c -> CountOf (Element c) Source #
Length of a collection (number of Element c)
elem :: forall a. (Eq a, a ~ Element c) => Element c -> c -> Bool Source #
Check if a collection contains a specific element
This is the inverse of notElem
.
notElem :: forall a. (Eq a, a ~ Element c) => Element c -> c -> Bool Source #
Check if a collection does *not* contain a specific element
This is the inverse of elem
.
maximum :: forall a. (Ord a, a ~ Element c) => NonEmpty c -> Element c Source #
Get the maximum element of a collection
minimum :: forall a. (Ord a, a ~ Element c) => NonEmpty c -> Element c Source #
Get the minimum element of a collection
any :: (Element c -> Bool) -> c -> Bool Source #
Determine is any elements of the collection satisfy the predicate
all :: (Element c -> Bool) -> c -> Bool Source #
Determine is all elements of the collection satisfy the predicate
Instances
and :: (Collection col, Element col ~ Bool) => col -> Bool Source #
Return True if all the elements in the collection are True
or :: (Collection col, Element col ~ Bool) => col -> Bool Source #
Return True if at least one element in the collection is True
NonEmpty property for any Collection
Instances
IsList c => IsList (NonEmpty c) | |
Show a => Show (NonEmpty a) | |
Collection c => Collection (NonEmpty c) Source # | |
Defined in Foundation.Collection.Collection null :: NonEmpty c -> Bool Source # length :: NonEmpty c -> CountOf (Element (NonEmpty c)) Source # elem :: (Eq a, a ~ Element (NonEmpty c)) => Element (NonEmpty c) -> NonEmpty c -> Bool Source # notElem :: (Eq a, a ~ Element (NonEmpty c)) => Element (NonEmpty c) -> NonEmpty c -> Bool Source # maximum :: (Ord a, a ~ Element (NonEmpty c)) => NonEmpty (NonEmpty c) -> Element (NonEmpty c) Source # minimum :: (Ord a, a ~ Element (NonEmpty c)) => NonEmpty (NonEmpty c) -> Element (NonEmpty c) Source # any :: (Element (NonEmpty c) -> Bool) -> NonEmpty c -> Bool Source # all :: (Element (NonEmpty c) -> Bool) -> NonEmpty c -> Bool Source # | |
Eq a => Eq (NonEmpty a) | |
type Item (NonEmpty c) | |
Defined in Basement.NonEmpty | |
type Element (NonEmpty a) Source # | |
Defined in Foundation.Collection.Element |
getNonEmpty :: NonEmpty a -> a Source #
nonEmpty :: Collection c => c -> Maybe (NonEmpty c) Source #
Smart constructor to create a NonEmpty collection
If the collection is empty, then Nothing is returned Otherwise, the collection is wrapped in the NonEmpty property
nonEmpty_ :: Collection c => c -> NonEmpty c Source #
same as nonEmpty
, but assume that the collection is non empty,
and return an asynchronous error if it is.
class (IsList c, Item c ~ Element c, Monoid c, Collection c) => Sequential c where Source #
A set of methods for ordered colection
(take, drop | splitAt), (revTake, revDrop | revSplitAt), splitOn, (break | span), (breakEnd | spanEnd), intersperse, filter, reverse, uncons, unsnoc, snoc, cons, find, sortBy, singleton, replicate
take :: CountOf (Element c) -> c -> c Source #
Take the first @n elements of a collection
revTake :: CountOf (Element c) -> c -> c Source #
Take the last @n elements of a collection
drop :: CountOf (Element c) -> c -> c Source #
Drop the first @n elements of a collection
revDrop :: CountOf (Element c) -> c -> c Source #
Drop the last @n elements of a collection
splitAt :: CountOf (Element c) -> c -> (c, c) Source #
Split the collection at the @n'th elements
revSplitAt :: CountOf (Element c) -> c -> (c, c) Source #
Split the collection at the @n'th elements from the end
splitOn :: (Element c -> Bool) -> c -> [c] Source #
Split on a specific elements returning a list of colletion
break :: (Element c -> Bool) -> c -> (c, c) Source #
Split a collection when the predicate return true
breakEnd :: (Element c -> Bool) -> c -> (c, c) Source #
Split a collection when the predicate return true starting from the end of the collection
breakElem :: Eq (Element c) => Element c -> c -> (c, c) Source #
Split a collection at the given element
takeWhile :: (Element c -> Bool) -> c -> c Source #
Return the longest prefix in the collection that satisfy the predicate
dropWhile :: (Element c -> Bool) -> c -> c Source #
Return the longest prefix in the collection that satisfy the predicate
intersperse :: Element c -> c -> c Source #
The intersperse
function takes an element and a list and
`intersperses' that element between the elements of the list.
For example,
intersperse ',' "abcde" == "a,b,c,d,e"
intercalate :: Monoid (Item c) => Element c -> c -> Element c Source #
intercalate
xs xss
is equivalent to (
.
It inserts the list mconcat
(intersperse
xs xss))xs
in between the lists in xss
and concatenates the
result.
span :: (Element c -> Bool) -> c -> (c, c) Source #
Split a collection while the predicate return true
spanEnd :: (Element c -> Bool) -> c -> (c, c) Source #
Split a collection while the predicate return true starting from the end of the collection
filter :: (Element c -> Bool) -> c -> c Source #
Filter all the elements that satisfy the predicate
partition :: (Element c -> Bool) -> c -> (c, c) Source #
Partition the elements that satisfy the predicate and those that don't
Reverse a collection
uncons :: c -> Maybe (Element c, c) Source #
Decompose a collection into its first element and the remaining collection. If the collection is empty, returns Nothing.
unsnoc :: c -> Maybe (c, Element c) Source #
Decompose a collection into a collection without its last element, and the last element If the collection is empty, returns Nothing.
snoc :: c -> Element c -> c Source #
Prepend an element to an ordered collection
cons :: Element c -> c -> c Source #
Append an element to an ordered collection
find :: (Element c -> Bool) -> c -> Maybe (Element c) Source #
Find an element in an ordered collection
sortBy :: (Element c -> Element c -> Ordering) -> c -> c Source #
Sort an ordered collection using the specified order function
singleton :: Element c -> c Source #
Create a collection with a single element
head :: NonEmpty c -> Element c Source #
get the first element of a non-empty collection
last :: NonEmpty c -> Element c Source #
get the last element of a non-empty collection
tail :: NonEmpty c -> c Source #
Extract the elements after the first element of a non-empty collection.
init :: NonEmpty c -> c Source #
Extract the elements before the last element of a non-empty collection.
replicate :: CountOf (Element c) -> Element c -> c Source #
Create a collection where the element in parameter is repeated N time
isPrefixOf :: Eq (Element c) => c -> c -> Bool Source #
Takes two collections and returns True iff the first collection is a prefix of the second.
default isPrefixOf :: Eq c => c -> c -> Bool Source #
isSuffixOf :: Eq (Element c) => c -> c -> Bool Source #
Takes two collections and returns True iff the first collection is a suffix of the second.
default isSuffixOf :: Eq c => c -> c -> Bool Source #
isInfixOf :: Eq (Element c) => c -> c -> Bool Source #
Takes two collections and returns True iff the first collection is an infix of the second.
stripPrefix :: Eq (Element c) => c -> c -> Maybe c Source #
Try to strip a prefix from a collection
stripSuffix :: Eq (Element c) => c -> c -> Maybe c Source #
Try to strip a suffix from a collection
Instances
class MutableCollection c where Source #
Collection of things that can be made mutable, modified and then freezed into an MutableFreezed collection
unsafeThaw :: PrimMonad prim => MutableFreezed c -> prim (c (PrimState prim)) Source #
unsafeFreeze :: PrimMonad prim => c (PrimState prim) -> prim (MutableFreezed c) Source #
thaw :: PrimMonad prim => MutableFreezed c -> prim (c (PrimState prim)) Source #
freeze :: PrimMonad prim => c (PrimState prim) -> prim (MutableFreezed c) Source #
mutNew :: PrimMonad prim => CountOf (MutableValue c) -> prim (c (PrimState prim)) Source #
mutUnsafeWrite :: PrimMonad prim => c (PrimState prim) -> MutableKey c -> MutableValue c -> prim () Source #
mutWrite :: PrimMonad prim => c (PrimState prim) -> MutableKey c -> MutableValue c -> prim () Source #
mutUnsafeRead :: PrimMonad prim => c (PrimState prim) -> MutableKey c -> prim (MutableValue c) Source #
mutRead :: PrimMonad prim => c (PrimState prim) -> MutableKey c -> prim (MutableValue c) Source #
Instances
class IndexedCollection c where Source #
Collection of elements that can indexed by int
(!) :: c -> Offset (Element c) -> Maybe (Element c) Source #
findIndex :: (Element c -> Bool) -> c -> Maybe (Offset (Element c)) Source #
Instances
IndexedCollection String Source # | |
IndexedCollection Bitmap Source # | |
IndexedCollection CSV Source # | |
IndexedCollection Row Source # | |
PrimType ty => IndexedCollection (Block ty) Source # | |
IndexedCollection (Array ty) Source # | |
PrimType ty => IndexedCollection (UArray ty) Source # | |
PrimType ty => IndexedCollection (ChunkedUArray ty) Source # | |
Defined in Foundation.Array.Chunked.Unboxed (!) :: ChunkedUArray ty -> Offset (Element (ChunkedUArray ty)) -> Maybe (Element (ChunkedUArray ty)) Source # findIndex :: (Element (ChunkedUArray ty) -> Bool) -> ChunkedUArray ty -> Maybe (Offset (Element (ChunkedUArray ty))) Source # | |
IndexedCollection [a] Source # | |
(NatWithinBound (CountOf ty) n, KnownNat n, PrimType ty) => IndexedCollection (BlockN n ty) Source # | |
(NatWithinBound Int n, KnownNat n) => IndexedCollection (ListN n a) Source # | |
class KeyedCollection c where Source #
Collection of things that can be looked up by Key
class Sequential col => Zippable col where Source #
Nothing
zipWith :: (Sequential a, Sequential b) => (Element a -> Element b -> Element col) -> a -> b -> col Source #
zipWith
generalises zip
by zipping with the function given as the
first argument, instead of a tupling function. For example,
is applied to two collections to produce the collection of corresponding
sums.zipWith
(+)
zipWith3 :: (Sequential a, Sequential b, Sequential c) => (Element a -> Element b -> Element c -> Element col) -> a -> b -> c -> col Source #
Like zipWith
, but works with 3 collections.
zipWith4 :: (Sequential a, Sequential b, Sequential c, Sequential d) => (Element a -> Element b -> Element c -> Element d -> Element col) -> a -> b -> c -> d -> col Source #
Like zipWith
, but works with 4 collections.
zipWith5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element col) -> a -> b -> c -> d -> e -> col Source #
Like zipWith
, but works with 5 collections.
zipWith6 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element f -> Element col) -> a -> b -> c -> d -> e -> f -> col Source #
Like zipWith
, but works with 6 collections.
zipWith7 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Sequential g) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element f -> Element g -> Element col) -> a -> b -> c -> d -> e -> f -> g -> col Source #
Like zipWith
, but works with 7 collections.
Instances
class Buildable col where Source #
Collections that can be built chunk by chunk.
Use the Monad
instance of Builder
to chain append
operations
and feed it into build
:
>>>
runST $ build 32 (append 'a' >> append 'b' >> append 'c') :: UArray Char
"abc"
type Mutable col :: Type -> Type Source #
Mutable collection type used for incrementally writing chunks.
append :: PrimMonad prim => Element col -> Builder col (Mutable col) (Step col) prim err () Source #
Instances
Buildable String Source # | |
Defined in Foundation.Collection.Buildable | |
Buildable (Array ty) Source # | |
Defined in Foundation.Collection.Buildable append :: forall (prim :: Type -> Type) err. PrimMonad prim => Element (Array ty) -> Builder (Array ty) (Mutable (Array ty)) (Step (Array ty)) prim err () Source # build :: PrimMonad prim => Int -> Builder (Array ty) (Mutable (Array ty)) (Step (Array ty)) prim err () -> prim (Either err (Array ty)) Source # | |
PrimType ty => Buildable (UArray ty) Source # | |
Defined in Foundation.Collection.Buildable append :: forall (prim :: Type -> Type) err. PrimMonad prim => Element (UArray ty) -> Builder (UArray ty) (Mutable (UArray ty)) (Step (UArray ty)) prim err () Source # build :: PrimMonad prim => Int -> Builder (UArray ty) (Mutable (UArray ty)) (Step (UArray ty)) prim err () -> prim (Either err (UArray ty)) Source # |
newtype Builder collection (mutCollection :: Type -> Type) step (state :: Type -> Type) err a Source #
Builder | |
|
Instances
Monad state => Applicative (Builder collection mutCollection step state err) | |
Defined in Basement.MutableBuilder pure :: a -> Builder collection mutCollection step state err a # (<*>) :: Builder collection mutCollection step state err (a -> b) -> Builder collection mutCollection step state err a -> Builder collection mutCollection step state err b # liftA2 :: (a -> b -> c) -> Builder collection mutCollection step state err a -> Builder collection mutCollection step state err b -> Builder collection mutCollection step state err c # (*>) :: Builder collection mutCollection step state err a -> Builder collection mutCollection step state err b -> Builder collection mutCollection step state err b # (<*) :: Builder collection mutCollection step state err a -> Builder collection mutCollection step state err b -> Builder collection mutCollection step state err a # | |
Monad state => Functor (Builder collection mutCollection step state err) | |
Monad state => Monad (Builder collection mutCollection step state err) | |
Defined in Basement.MutableBuilder (>>=) :: Builder collection mutCollection step state err a -> (a -> Builder collection mutCollection step state err b) -> Builder collection mutCollection step state err b # (>>) :: Builder collection mutCollection step state err a -> Builder collection mutCollection step state err b -> Builder collection mutCollection step state err b # return :: a -> Builder collection mutCollection step state err a # | |
Monad state => MonadFailure (Builder collection mutCollection step state err) | |
type Failure (Builder collection mutCollection step state err) | |
Defined in Basement.MutableBuilder |
data BuildingState collection (mutCollection :: Type -> Type) step state Source #
The in-progress state of a building operation.
The previous buffers are in reverse order, and this contains the current buffer and the state of progress packing the elements inside.
BuildingState | |
|