Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Chunks a
- = ChunksCons !(SmallArray a) !(Chunks a)
- | ChunksNil
- null :: Chunks a -> Bool
- reverse :: Chunks a -> Chunks a
- reverseOnto :: Chunks a -> Chunks a -> Chunks a
- copy :: SmallMutableArray s a -> Int -> Chunks a -> ST s Int
- copyReverse :: SmallMutableArray s a -> Int -> Chunks a -> ST s Int
- concat :: Chunks a -> SmallArray a
- concatReverse :: Chunks a -> SmallArray a
- index :: Chunks a -> Int -> Maybe a
- map' :: (a -> b) -> Chunks a -> SmallArray b
- singleton :: a -> Chunks a
- doubleton :: a -> a -> Chunks a
- tripleton :: a -> a -> a -> Chunks a
- quadrupleton :: a -> a -> a -> a -> Chunks a
- quintupleton :: a -> a -> a -> a -> a -> Chunks a
- sextupleton :: a -> a -> a -> a -> a -> a -> Chunks a
- septupleton :: a -> a -> a -> a -> a -> a -> a -> Chunks a
- octupleton :: a -> a -> a -> a -> a -> a -> a -> a -> Chunks a
- nonupleton :: a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a
- decupleton :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a
- undecupleton :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a
- duodecupleton :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a
- construct1 :: a -> Chunks a
- construct2 :: a -> a -> Chunks a
- construct3 :: a -> a -> a -> Chunks a
- construct4 :: a -> a -> a -> a -> Chunks a
- construct5 :: a -> a -> a -> a -> a -> Chunks a
- construct6 :: a -> a -> a -> a -> a -> a -> Chunks a
- construct7 :: a -> a -> a -> a -> a -> a -> a -> Chunks a
- construct8 :: a -> a -> a -> a -> a -> a -> a -> a -> Chunks a
- construct9 :: a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a
- construct10 :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a
- construct11 :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a
- construct12 :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a
Documentation
A list of chunks. This is a foundation on top of which efficient builder-like abstractions can be implemented. There are no restrictions on the number of elements in each chunk, although extremely small chunks (singleton or doubleton chunks) may lead to poor performance.
ChunksCons !(SmallArray a) !(Chunks a) | |
ChunksNil |
Instances
Foldable Chunks Source # | |
Defined in Data.Chunks fold :: Monoid m => Chunks m -> m # foldMap :: Monoid m => (a -> m) -> Chunks a -> m # foldMap' :: Monoid m => (a -> m) -> Chunks a -> m # foldr :: (a -> b -> b) -> b -> Chunks a -> b # foldr' :: (a -> b -> b) -> b -> Chunks a -> b # foldl :: (b -> a -> b) -> b -> Chunks a -> b # foldl' :: (b -> a -> b) -> b -> Chunks a -> b # foldr1 :: (a -> a -> a) -> Chunks a -> a # foldl1 :: (a -> a -> a) -> Chunks a -> a # elem :: Eq a => a -> Chunks a -> Bool # maximum :: Ord a => Chunks a -> a # minimum :: Ord a => Chunks a -> a # | |
Monoid (Chunks a) Source # | |
Semigroup (Chunks a) Source # | |
IsList (Chunks a) Source # | |
Show a => Show (Chunks a) Source # | |
Eq a => Eq (Chunks a) Source # | |
type Item (Chunks a) Source # | |
Defined in Data.Chunks |
reverse :: Chunks a -> Chunks a Source #
Reverse chunks but not the elements within each chunk.
>>>
reverse [[42,17,94],[6,12],[3,14]]
[[3,14],[6,12],[42,17,94]]
reverseOnto :: Chunks a -> Chunks a -> Chunks a Source #
Variant of reverse
that allows the caller to provide
an initial list of chunks that the reversed chunks will
be pushed onto.
>>>
reverseOnto [[15],[12,4]] [[42,17,94],[6,12],[3,14]]
[[3,14],[6,12],[42,17,94],[15],[12,4]]
:: SmallMutableArray s a | Destination |
-> Int | Destination offset |
-> Chunks a | Source |
-> ST s Int | Returns the next index into the destination after the payload |
Copy the contents of the chunks into a mutable array. Precondition: The destination must have enough space to house the contents. This is not checked.
dest (before): [x,x,x,x,x,x,x,x,x,x,x,x] copy dest 2 [[X,Y,Z],[A,B],[C,D]] (returns 9) dest (after): [x,x,X,Y,Z,A,B,C,D,x,x,x]
:: SmallMutableArray s a | Destination |
-> Int | Destination range successor |
-> Chunks a | Source |
-> ST s Int | Returns the next index into the destination after the payload |
Copy the contents of the chunks into a mutable array, reversing the order of the chunks. Precondition: The destination must have enough space to house the contents. This is not checked.
dest (before): [x,x,x,x,x,x,x,x,x,x,x,x] copyReverse dest 10 [[X,Y,Z],[A,B],[C,D]] (returns 3) dest (after): [x,x,x,C,D,A,B,X,Y,Z,x,x]
concat :: Chunks a -> SmallArray a Source #
concatReverse :: Chunks a -> SmallArray a Source #
Indexing
index :: Chunks a -> Int -> Maybe a Source #
Indexing into the chunked list, returning Nothing
if there
are not enough elements.
Traversals
map' :: (a -> b) -> Chunks a -> SmallArray b Source #
Mapping over chunks is a little unusual in that the result
is just a SmallArray
.
Construction
quadrupleton :: a -> a -> a -> a -> Chunks a Source #
Create chunks with 4 elements.
quintupleton :: a -> a -> a -> a -> a -> Chunks a Source #
Create chunks with 5 elements.
sextupleton :: a -> a -> a -> a -> a -> a -> Chunks a Source #
Create chunks with 6 elements.
septupleton :: a -> a -> a -> a -> a -> a -> a -> Chunks a Source #
Create chunks with 7 elements.
octupleton :: a -> a -> a -> a -> a -> a -> a -> a -> Chunks a Source #
Create chunks with 8 elements.
nonupleton :: a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a Source #
Create chunks with 9 elements.
decupleton :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a Source #
Create chunks with 10 elements.
undecupleton :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a Source #
Create chunks with 11 elements.
duodecupleton :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a Source #
Create chunks with 12 elements.
Construction Alternate
construct1 :: a -> Chunks a Source #
construct2 :: a -> a -> Chunks a Source #
construct3 :: a -> a -> a -> Chunks a Source #
construct4 :: a -> a -> a -> a -> Chunks a Source #
construct5 :: a -> a -> a -> a -> a -> Chunks a Source #
construct6 :: a -> a -> a -> a -> a -> a -> Chunks a Source #
construct7 :: a -> a -> a -> a -> a -> a -> a -> Chunks a Source #
construct8 :: a -> a -> a -> a -> a -> a -> a -> a -> Chunks a Source #
construct9 :: a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a Source #
construct10 :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a Source #
construct11 :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a Source #
construct12 :: a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> a -> Chunks a Source #