foundation-0.0.3: Alternative prelude with batteries and no dependencies

License | BSD-style
Maintainer | Vincent Hanquez <vincent@snarc.org>
Stability | experimental
Portability | portable
Safe Haskell | None
Language | Haskell2010

Foundation.Collection

Description

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
- type family Element container
- class InnerFunctor c where
- class Foldable collection where
- class (IsList c, Item c ~ Element c) => Collection c where
- data NonEmpty a
- getNonEmpty :: NonEmpty a -> a
- nonEmpty :: Collection c => c -> Maybe (NonEmpty c)
- nonEmpty_ :: Collection c => c -> NonEmpty c
- class (IsList c, Item c ~ Element c, Monoid c, Collection c) => Sequential c where
- class MutableCollection c where
  - type MutableFreezed c
  - type MutableKey c
  - type MutableValue c
- class IndexedCollection c where
- class KeyedCollection c where
  - type Key c
  - type Value c
- class Sequential col => Zippable col where
- class Buildable col where
  - type Mutable col :: * -> *
  - type Step col
- newtype Builder col st a = Builder {
  - runBuilder :: State (Offset (Step col), BuildingState col (PrimState st)) st a
  }
- data BuildingState col st = BuildingState {
  - prevChunks :: [col]
  - prevChunksSize :: !(Size (Step col))
  - curChunk :: Mutable col st
  - chunkSize :: !(Size (Step col))
  }

# Documentation

class Zippable col => BoxedZippable col where #

Methods

zip :: (Sequential a, Sequential b, Element col ~ (Element a, Element b)) => a -> b -> col #

`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 #

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 #

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 #

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 #

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 #

Like `zip`, but works with 7 collections.

unzip :: (Sequential a, Sequential b, Element col ~ (Element a, Element b)) => col -> (a, b) #

`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) #

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) #

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) #

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) #

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) #

Like `unzip`, but works on a collection of 7-element tuples.

Instances

BoxedZippable [a] # |
Methods zip :: (Sequential a, Sequential b, (* ~ Element [a]) (Element a, Element b)) => a -> b -> [a] # zip3 :: (Sequential a, Sequential b, Sequential c, (* ~ Element [a]) (Element a, Element b, Element c)) => a -> b -> c -> [a] # zip4 :: (Sequential a, Sequential b, Sequential c, Sequential d, (* ~ Element [a]) (Element a, Element b, Element c, Element d)) => a -> b -> c -> d -> [a] # zip5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, (* ~ Element [a]) (Element a, Element b, Element c, Element d, Element e)) => a -> b -> c -> d -> e -> [a] # zip6 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, (* ~ Element [a]) (Element a, Element b, Element c, Element d, Element e, Element f)) => a -> b -> c -> d -> e -> f -> [a] # zip7 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Sequential g, (* ~ Element [a]) (Element a, Element b, Element c, Element d, Element e, Element f, Element g)) => a -> b -> c -> d -> e -> f -> g -> [a] # unzip :: (Sequential a, Sequential b, (* ~ Element [a]) (Element a, Element b)) => [a] -> (a, b) # unzip3 :: (Sequential a, Sequential b, Sequential c, (* ~ Element [a]) (Element a, Element b, Element c)) => [a] -> (a, b, c) # unzip4 :: (Sequential a, Sequential b, Sequential c, Sequential d, (* ~ Element [a]) (Element a, Element b, Element c, Element d)) => [a] -> (a, b, c, d) # unzip5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, (* ~ Element [a]) (Element a, Element b, Element c, Element d, Element e)) => [a] -> (a, b, c, d, e) # unzip6 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, (* ~ Element [a]) (Element a, Element b, Element c, Element d, Element e, Element f)) => [a] -> (a, b, c, d, e, f) # unzip7 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Sequential g, (* ~ Element [a]) (Element a, Element b, Element c, Element d, Element e, Element f, Element g)) => [a] -> (a, b, c, d, e, f, g) #
BoxedZippable (Array ty) # |
Methods zip :: (Sequential a, Sequential b, (* ~ Element (Array ty)) (Element a, Element b)) => a -> b -> Array ty # zip3 :: (Sequential a, Sequential b, Sequential c, (* ~ Element (Array ty)) (Element a, Element b, Element c)) => a -> b -> c -> Array ty # zip4 :: (Sequential a, Sequential b, Sequential c, Sequential d, (* ~ Element (Array ty)) (Element a, Element b, Element c, Element d)) => a -> b -> c -> d -> Array ty # zip5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, (* ~ Element (Array ty)) (Element a, Element b, Element c, Element d, Element e)) => a -> b -> c -> d -> e -> Array ty # zip6 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, (* ~ Element (Array ty)) (Element a, Element b, Element c, Element d, Element e, Element f)) => a -> b -> c -> d -> e -> f -> Array ty # zip7 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Sequential g, (* ~ Element (Array ty)) (Element a, Element b, Element c, Element d, Element e, Element f, Element g)) => a -> b -> c -> d -> e -> f -> g -> Array ty # unzip :: (Sequential a, Sequential b, (* ~ Element (Array ty)) (Element a, Element b)) => Array ty -> (a, b) # unzip3 :: (Sequential a, Sequential b, Sequential c, (* ~ Element (Array ty)) (Element a, Element b, Element c)) => Array ty -> (a, b, c) # unzip4 :: (Sequential a, Sequential b, Sequential c, Sequential d, (* ~ Element (Array ty)) (Element a, Element b, Element c, Element d)) => Array ty -> (a, b, c, d) # unzip5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, (* ~ Element (Array ty)) (Element a, Element b, Element c, Element d, Element e)) => Array ty -> (a, b, c, d, e) # unzip6 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, (* ~ Element (Array ty)) (Element a, Element b, Element c, Element d, Element e, Element f)) => Array ty -> (a, b, c, d, e, f) # unzip7 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e, Sequential f, Sequential g, (* ~ Element (Array ty)) (Element a, Element b, Element c, Element d, Element e, Element f, Element g)) => Array ty -> (a, b, c, d, e, f, g) #

type family Element container #

Element type of a collection

Instances

type Element Bitmap # |
type Element Bitmap = Bool
type Element AsciiString # |
type Element AsciiString = CUChar
type Element String # |
type Element String = Char
type Element [a] # |
type Element [a] = a
type Element (UArray ty) # |
type Element (UArray ty) = ty
type Element (NonEmpty a) # |
type Element (NonEmpty a) = Element a
type Element (Array ty) # |
type Element (Array ty) = ty
type Element (ChunkedUArray ty) # |
type Element (ChunkedUArray ty) = ty

class InnerFunctor c where #

A monomorphic functor that maps the inner values to values of the same type

Methods

imap :: (Element c -> Element c) -> c -> c #

imap :: (Functor f, Element (f a) ~ a, f a ~ c) => (a -> a) -> f a -> f a #

Instances

InnerFunctor Bitmap # |
Methods imap :: (Element Bitmap -> Element Bitmap) -> Bitmap -> Bitmap #
InnerFunctor AsciiString # |
Methods imap :: (Element AsciiString -> Element AsciiString) -> AsciiString -> AsciiString #
InnerFunctor String # |
Methods imap :: (Element String -> Element String) -> String -> String #
InnerFunctor [a] # |
Methods imap :: (Element [a] -> Element [a]) -> [a] -> [a] #
PrimType ty => InnerFunctor (UArray ty) # |
Methods imap :: (Element (UArray ty) -> Element (UArray ty)) -> UArray ty -> UArray ty #
InnerFunctor (Array ty) # |
Methods imap :: (Element (Array ty) -> Element (Array ty)) -> Array ty -> Array ty #

class Foldable collection where #

Give the ability to fold a collection on itself

Minimal complete definition

foldl, foldl', foldr

Methods

foldl :: (a -> Element collection -> a) -> a -> collection -> a #

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.

Also note that if you want an efficient left-fold, you probably want to use foldl' instead of foldl. The reason for this is that latter does not force the "inner" results (e.g. z f x1 in the above example) before applying them to the operator (e.g. to (f x2)). This results in a thunk chain O(n) elements long, which then must be evaluated from the outside-in.

foldl' :: (a -> Element collection -> a) -> a -> collection -> a #

Left-associative fold of a structure but with strict application of the operator.

foldr :: (Element collection -> a -> a) -> a -> collection -> a #

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 #

Right-associative fold of a structure, but with strict application of the operator.

Instances

Foldable Bitmap # |
Methods foldl :: (a -> Element Bitmap -> a) -> a -> Bitmap -> a # foldl' :: (a -> Element Bitmap -> a) -> a -> Bitmap -> a # foldr :: (Element Bitmap -> a -> a) -> a -> Bitmap -> a # foldr' :: (Element Bitmap -> a -> a) -> a -> Bitmap -> a #
Foldable [a] # |
Methods foldl :: (a -> Element [a] -> a) -> a -> [a] -> a # foldl' :: (a -> Element [a] -> a) -> a -> [a] -> a # foldr :: (Element [a] -> a -> a) -> a -> [a] -> a # foldr' :: (Element [a] -> a -> a) -> a -> [a] -> a #
PrimType ty => Foldable (UArray ty) # |
Methods foldl :: (a -> Element (UArray ty) -> a) -> a -> UArray ty -> a # foldl' :: (a -> Element (UArray ty) -> a) -> a -> UArray ty -> a # foldr :: (Element (UArray ty) -> a -> a) -> a -> UArray ty -> a # foldr' :: (Element (UArray ty) -> a -> a) -> a -> UArray ty -> a #
Foldable (Array ty) # |
Methods foldl :: (a -> Element (Array ty) -> a) -> a -> Array ty -> a # foldl' :: (a -> Element (Array ty) -> a) -> a -> Array ty -> a # foldr :: (Element (Array ty) -> a -> a) -> a -> Array ty -> a # foldr' :: (Element (Array ty) -> a -> a) -> a -> Array ty -> a #

class (IsList c, Item c ~ Element c) => Collection c where #

A set of methods for ordered colection

Minimal complete definition

null, length, (elem | notElem), minimum, maximum

Methods

null :: c -> Bool #

Check if a collection is empty

length :: c -> Int #

Length of a collection (number of Element c)

elem :: forall a. (Eq a, a ~ Element c) => Element c -> c -> Bool #

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 #

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 #

Get the maximum element of a collection

minimum :: forall a. (Ord a, a ~ Element c) => NonEmpty c -> Element c #

Get the minimum element of a collection

Instances

Collection Bitmap # |
Methods null :: Bitmap -> Bool # length :: Bitmap -> Int # elem :: (Eq a, (* ~ a) (Element Bitmap)) => Element Bitmap -> Bitmap -> Bool # notElem :: (Eq a, (* ~ a) (Element Bitmap)) => Element Bitmap -> Bitmap -> Bool # maximum :: (Ord a, (* ~ a) (Element Bitmap)) => NonEmpty Bitmap -> Element Bitmap # minimum :: (Ord a, (* ~ a) (Element Bitmap)) => NonEmpty Bitmap -> Element Bitmap #
Collection AsciiString # |
Methods null :: AsciiString -> Bool # length :: AsciiString -> Int # elem :: (Eq a, (* ~ a) (Element AsciiString)) => Element AsciiString -> AsciiString -> Bool # notElem :: (Eq a, (* ~ a) (Element AsciiString)) => Element AsciiString -> AsciiString -> Bool # maximum :: (Ord a, (* ~ a) (Element AsciiString)) => NonEmpty AsciiString -> Element AsciiString # minimum :: (Ord a, (* ~ a) (Element AsciiString)) => NonEmpty AsciiString -> Element AsciiString #
Collection String # |
Methods null :: String -> Bool # length :: String -> Int # elem :: (Eq a, (* ~ a) (Element String)) => Element String -> String -> Bool # notElem :: (Eq a, (* ~ a) (Element String)) => Element String -> String -> Bool # maximum :: (Ord a, (* ~ a) (Element String)) => NonEmpty String -> Element String # minimum :: (Ord a, (* ~ a) (Element String)) => NonEmpty String -> Element String #
Collection [a] # |
Methods null :: [a] -> Bool # length :: [a] -> Int # elem :: (Eq a, (* ~ a) (Element [a])) => Element [a] -> [a] -> Bool # notElem :: (Eq a, (* ~ a) (Element [a])) => Element [a] -> [a] -> Bool # maximum :: (Ord a, (* ~ a) (Element [a])) => NonEmpty [a] -> Element [a] # minimum :: (Ord a, (* ~ a) (Element [a])) => NonEmpty [a] -> Element [a] #
PrimType ty => Collection (UArray ty) # |
Methods null :: UArray ty -> Bool # length :: UArray ty -> Int # elem :: (Eq a, (* ~ a) (Element (UArray ty))) => Element (UArray ty) -> UArray ty -> Bool # notElem :: (Eq a, (* ~ a) (Element (UArray ty))) => Element (UArray ty) -> UArray ty -> Bool # maximum :: (Ord a, (* ~ a) (Element (UArray ty))) => NonEmpty (UArray ty) -> Element (UArray ty) # minimum :: (Ord a, (* ~ a) (Element (UArray ty))) => NonEmpty (UArray ty) -> Element (UArray ty) #
Collection c => Collection (NonEmpty c) # |
Methods null :: NonEmpty c -> Bool # length :: NonEmpty c -> Int # elem :: (Eq a, (* ~ a) (Element (NonEmpty c))) => Element (NonEmpty c) -> NonEmpty c -> Bool # notElem :: (Eq a, (* ~ a) (Element (NonEmpty c))) => Element (NonEmpty c) -> NonEmpty c -> Bool # maximum :: (Ord a, (* ~ a) (Element (NonEmpty c))) => NonEmpty (NonEmpty c) -> Element (NonEmpty c) # minimum :: (Ord a, (* ~ a) (Element (NonEmpty c))) => NonEmpty (NonEmpty c) -> Element (NonEmpty c) #
Collection (Array ty) # |
Methods null :: Array ty -> Bool # length :: Array ty -> Int # elem :: (Eq a, (* ~ a) (Element (Array ty))) => Element (Array ty) -> Array ty -> Bool # notElem :: (Eq a, (* ~ a) (Element (Array ty))) => Element (Array ty) -> Array ty -> Bool # maximum :: (Ord a, (* ~ a) (Element (Array ty))) => NonEmpty (Array ty) -> Element (Array ty) # minimum :: (Ord a, (* ~ a) (Element (Array ty))) => NonEmpty (Array ty) -> Element (Array ty) #
PrimType ty => Collection (ChunkedUArray ty) # |
Methods null :: ChunkedUArray ty -> Bool # length :: ChunkedUArray ty -> Int # elem :: (Eq a, (* ~ a) (Element (ChunkedUArray ty))) => Element (ChunkedUArray ty) -> ChunkedUArray ty -> Bool # notElem :: (Eq a, (* ~ a) (Element (ChunkedUArray ty))) => Element (ChunkedUArray ty) -> ChunkedUArray ty -> Bool # maximum :: (Ord a, (* ~ a) (Element (ChunkedUArray ty))) => NonEmpty (ChunkedUArray ty) -> Element (ChunkedUArray ty) # minimum :: (Ord a, (* ~ a) (Element (ChunkedUArray ty))) => NonEmpty (ChunkedUArray ty) -> Element (ChunkedUArray ty) #

data NonEmpty a #

NonEmpty property for any Collection

This can only be made, through the `nonEmpty` smart contructor

Instances

Collection c => IsList (NonEmpty c) # |
Associated Types type Item (NonEmpty c) :: * # Methods fromList :: [Item (NonEmpty c)] -> NonEmpty c # fromListN :: Int -> [Item (NonEmpty c)] -> NonEmpty c # toList :: NonEmpty c -> [Item (NonEmpty c)] #
Eq a => Eq (NonEmpty a) # |
Methods (==) :: NonEmpty a -> NonEmpty a -> Bool # (/=) :: NonEmpty a -> NonEmpty a -> Bool #
Show a => Show (NonEmpty a) # |
Methods showsPrec :: Int -> NonEmpty a -> ShowS # show :: NonEmpty a -> String # showList :: [NonEmpty a] -> ShowS #
Collection c => Collection (NonEmpty c) # |
Methods null :: NonEmpty c -> Bool # length :: NonEmpty c -> Int # elem :: (Eq a, (* ~ a) (Element (NonEmpty c))) => Element (NonEmpty c) -> NonEmpty c -> Bool # notElem :: (Eq a, (* ~ a) (Element (NonEmpty c))) => Element (NonEmpty c) -> NonEmpty c -> Bool # maximum :: (Ord a, (* ~ a) (Element (NonEmpty c))) => NonEmpty (NonEmpty c) -> Element (NonEmpty c) # minimum :: (Ord a, (* ~ a) (Element (NonEmpty c))) => NonEmpty (NonEmpty c) -> Element (NonEmpty c) #
type Item (NonEmpty c) # |
type Item (NonEmpty c) = Item c
type Element (NonEmpty a) # |
type Element (NonEmpty a) = Element a

getNonEmpty :: NonEmpty a -> a #

nonEmpty :: Collection c => c -> Maybe (NonEmpty c) #

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 #

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 #

A set of methods for ordered colection

Methods

take :: Int -> c -> c #

Take the first @n elements of a collection

revTake :: Int -> c -> c #

Take the last @n elements of a collection

drop :: Int -> c -> c #

Drop the first @n elements of a collection

revDrop :: Int -> c -> c #

Drop the last @n elements of a collection

splitAt :: Int -> c -> (c, c) #

Split the collection at the @n'th elements

revSplitAt :: Int -> c -> (c, c) #

Split the collection at the @n'th elements from the end

splitOn :: (Element c -> Bool) -> c -> [c] #

Split on a specific elements returning a list of colletion

break :: (Element c -> Bool) -> c -> (c, c) #

Split a collection when the predicate return true

breakElem :: Eq (Element c) => Element c -> c -> (c, c) #

Split a collection when the predicate return true

intersperse :: Element c -> c -> c #

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 #

`intercalate` `xs xss` is equivalent to `(`mconcat` (`intersperse` xs xss))`. It inserts the list `xs` in between the lists in `xss` and concatenates the result.

span :: (Element c -> Bool) -> c -> (c, c) #

Split a collection while the predicate return true

filter :: (Element c -> Bool) -> c -> c #

Filter all the elements that satisfy the predicate

partition :: (Element c -> Bool) -> c -> (c, c) #

Partition the elements thtat satisfy the predicate and those that don't

reverse :: c -> c #

Reverse a collection

uncons :: c -> Maybe (Element c, c) #

Decompose a collection into its first element and the remaining collection. If the collection is empty, returns Nothing.

unsnoc :: c -> Maybe (c, Element c) #

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 #

Prepend an element to an ordered collection

cons :: Element c -> c -> c #

Append an element to an ordered collection

find :: (Element c -> Bool) -> c -> Maybe (Element c) #

Find an element in an ordered collection

sortBy :: (Element c -> Element c -> Ordering) -> c -> c #

Sort an ordered collection using the specified order function

singleton :: Element c -> c #

Create a collection with a single element

head :: NonEmpty c -> Element c #

get the first element of a non-empty collection

last :: NonEmpty c -> Element c #

get the last element of a non-empty collection

tail :: NonEmpty c -> c #

Extract the elements after the first element of a non-empty collection.

init :: NonEmpty c -> c #

Extract the elements before the last element of a non-empty collection.

isPrefixOf :: Eq (Element c) => c -> c -> Bool #

Takes two collections and returns True iff the first collection is a prefix of the second.

isPrefixOf :: Eq c => c -> c -> Bool #

Takes two collections and returns True iff the first collection is a prefix of the second.

isSuffixOf :: Eq (Element c) => c -> c -> Bool #

Takes two collections and returns True iff the first collection is a suffix of the second.

isSuffixOf :: Eq c => c -> c -> Bool #

Takes two collections and returns True iff the first collection is a suffix of the second.

Instances

Sequential Bitmap # |
Methods take :: Int -> Bitmap -> Bitmap # revTake :: Int -> Bitmap -> Bitmap # drop :: Int -> Bitmap -> Bitmap # revDrop :: Int -> Bitmap -> Bitmap # splitAt :: Int -> Bitmap -> (Bitmap, Bitmap) # revSplitAt :: Int -> Bitmap -> (Bitmap, Bitmap) # splitOn :: (Element Bitmap -> Bool) -> Bitmap -> [Bitmap] # break :: (Element Bitmap -> Bool) -> Bitmap -> (Bitmap, Bitmap) # breakElem :: Element Bitmap -> Bitmap -> (Bitmap, Bitmap) # intersperse :: Element Bitmap -> Bitmap -> Bitmap # intercalate :: Element Bitmap -> Bitmap -> Element Bitmap # span :: (Element Bitmap -> Bool) -> Bitmap -> (Bitmap, Bitmap) # filter :: (Element Bitmap -> Bool) -> Bitmap -> Bitmap # partition :: (Element Bitmap -> Bool) -> Bitmap -> (Bitmap, Bitmap) # reverse :: Bitmap -> Bitmap # uncons :: Bitmap -> Maybe (Element Bitmap, Bitmap) # unsnoc :: Bitmap -> Maybe (Bitmap, Element Bitmap) # snoc :: Bitmap -> Element Bitmap -> Bitmap # cons :: Element Bitmap -> Bitmap -> Bitmap # find :: (Element Bitmap -> Bool) -> Bitmap -> Maybe (Element Bitmap) # sortBy :: (Element Bitmap -> Element Bitmap -> Ordering) -> Bitmap -> Bitmap # singleton :: Element Bitmap -> Bitmap # head :: NonEmpty Bitmap -> Element Bitmap # last :: NonEmpty Bitmap -> Element Bitmap # tail :: NonEmpty Bitmap -> Bitmap # init :: NonEmpty Bitmap -> Bitmap # isPrefixOf :: Bitmap -> Bitmap -> Bool # isSuffixOf :: Bitmap -> Bitmap -> Bool #
Sequential AsciiString # |
Methods take :: Int -> AsciiString -> AsciiString # revTake :: Int -> AsciiString -> AsciiString # drop :: Int -> AsciiString -> AsciiString # revDrop :: Int -> AsciiString -> AsciiString # splitAt :: Int -> AsciiString -> (AsciiString, AsciiString) # revSplitAt :: Int -> AsciiString -> (AsciiString, AsciiString) # splitOn :: (Element AsciiString -> Bool) -> AsciiString -> [AsciiString] # break :: (Element AsciiString -> Bool) -> AsciiString -> (AsciiString, AsciiString) # breakElem :: Element AsciiString -> AsciiString -> (AsciiString, AsciiString) # intersperse :: Element AsciiString -> AsciiString -> AsciiString # intercalate :: Element AsciiString -> AsciiString -> Element AsciiString # span :: (Element AsciiString -> Bool) -> AsciiString -> (AsciiString, AsciiString) # filter :: (Element AsciiString -> Bool) -> AsciiString -> AsciiString # partition :: (Element AsciiString -> Bool) -> AsciiString -> (AsciiString, AsciiString) # reverse :: AsciiString -> AsciiString # uncons :: AsciiString -> Maybe (Element AsciiString, AsciiString) # unsnoc :: AsciiString -> Maybe (AsciiString, Element AsciiString) # snoc :: AsciiString -> Element AsciiString -> AsciiString # cons :: Element AsciiString -> AsciiString -> AsciiString # find :: (Element AsciiString -> Bool) -> AsciiString -> Maybe (Element AsciiString) # sortBy :: (Element AsciiString -> Element AsciiString -> Ordering) -> AsciiString -> AsciiString # singleton :: Element AsciiString -> AsciiString # head :: NonEmpty AsciiString -> Element AsciiString # last :: NonEmpty AsciiString -> Element AsciiString # tail :: NonEmpty AsciiString -> AsciiString # init :: NonEmpty AsciiString -> AsciiString # isPrefixOf :: AsciiString -> AsciiString -> Bool # isSuffixOf :: AsciiString -> AsciiString -> Bool #
Sequential String # |
Methods take :: Int -> String -> String # revTake :: Int -> String -> String # drop :: Int -> String -> String # revDrop :: Int -> String -> String # splitAt :: Int -> String -> (String, String) # revSplitAt :: Int -> String -> (String, String) # splitOn :: (Element String -> Bool) -> String -> [String] # break :: (Element String -> Bool) -> String -> (String, String) # breakElem :: Element String -> String -> (String, String) # intersperse :: Element String -> String -> String # intercalate :: Element String -> String -> Element String # span :: (Element String -> Bool) -> String -> (String, String) # filter :: (Element String -> Bool) -> String -> String # partition :: (Element String -> Bool) -> String -> (String, String) # reverse :: String -> String # uncons :: String -> Maybe (Element String, String) # unsnoc :: String -> Maybe (String, Element String) # snoc :: String -> Element String -> String # cons :: Element String -> String -> String # find :: (Element String -> Bool) -> String -> Maybe (Element String) # sortBy :: (Element String -> Element String -> Ordering) -> String -> String # singleton :: Element String -> String # head :: NonEmpty String -> Element String # last :: NonEmpty String -> Element String # tail :: NonEmpty String -> String # init :: NonEmpty String -> String # isPrefixOf :: String -> String -> Bool # isSuffixOf :: String -> String -> Bool #
Sequential [a] # |
Methods take :: Int -> [a] -> [a] # revTake :: Int -> [a] -> [a] # drop :: Int -> [a] -> [a] # revDrop :: Int -> [a] -> [a] # splitAt :: Int -> [a] -> ([a], [a]) # revSplitAt :: Int -> [a] -> ([a], [a]) # splitOn :: (Element [a] -> Bool) -> [a] -> [[a]] # break :: (Element [a] -> Bool) -> [a] -> ([a], [a]) # breakElem :: Element [a] -> [a] -> ([a], [a]) # intersperse :: Element [a] -> [a] -> [a] # intercalate :: Element [a] -> [a] -> Element [a] # span :: (Element [a] -> Bool) -> [a] -> ([a], [a]) # filter :: (Element [a] -> Bool) -> [a] -> [a] # partition :: (Element [a] -> Bool) -> [a] -> ([a], [a]) # reverse :: [a] -> [a] # uncons :: [a] -> Maybe (Element [a], [a]) # unsnoc :: [a] -> Maybe ([a], Element [a]) # snoc :: [a] -> Element [a] -> [a] # cons :: Element [a] -> [a] -> [a] # find :: (Element [a] -> Bool) -> [a] -> Maybe (Element [a]) # sortBy :: (Element [a] -> Element [a] -> Ordering) -> [a] -> [a] # singleton :: Element [a] -> [a] # head :: NonEmpty [a] -> Element [a] # last :: NonEmpty [a] -> Element [a] # tail :: NonEmpty [a] -> [a] # init :: NonEmpty [a] -> [a] # isPrefixOf :: [a] -> [a] -> Bool # isSuffixOf :: [a] -> [a] -> Bool #
PrimType ty => Sequential (UArray ty) # |
Methods take :: Int -> UArray ty -> UArray ty # revTake :: Int -> UArray ty -> UArray ty # drop :: Int -> UArray ty -> UArray ty # revDrop :: Int -> UArray ty -> UArray ty # splitAt :: Int -> UArray ty -> (UArray ty, UArray ty) # revSplitAt :: Int -> UArray ty -> (UArray ty, UArray ty) # splitOn :: (Element (UArray ty) -> Bool) -> UArray ty -> [UArray ty] # break :: (Element (UArray ty) -> Bool) -> UArray ty -> (UArray ty, UArray ty) # breakElem :: Element (UArray ty) -> UArray ty -> (UArray ty, UArray ty) # intersperse :: Element (UArray ty) -> UArray ty -> UArray ty # intercalate :: Element (UArray ty) -> UArray ty -> Element (UArray ty) # span :: (Element (UArray ty) -> Bool) -> UArray ty -> (UArray ty, UArray ty) # filter :: (Element (UArray ty) -> Bool) -> UArray ty -> UArray ty # partition :: (Element (UArray ty) -> Bool) -> UArray ty -> (UArray ty, UArray ty) # reverse :: UArray ty -> UArray ty # uncons :: UArray ty -> Maybe (Element (UArray ty), UArray ty) # unsnoc :: UArray ty -> Maybe (UArray ty, Element (UArray ty)) # snoc :: UArray ty -> Element (UArray ty) -> UArray ty # cons :: Element (UArray ty) -> UArray ty -> UArray ty # find :: (Element (UArray ty) -> Bool) -> UArray ty -> Maybe (Element (UArray ty)) # sortBy :: (Element (UArray ty) -> Element (UArray ty) -> Ordering) -> UArray ty -> UArray ty # singleton :: Element (UArray ty) -> UArray ty # head :: NonEmpty (UArray ty) -> Element (UArray ty) # last :: NonEmpty (UArray ty) -> Element (UArray ty) # tail :: NonEmpty (UArray ty) -> UArray ty # init :: NonEmpty (UArray ty) -> UArray ty # isPrefixOf :: UArray ty -> UArray ty -> Bool # isSuffixOf :: UArray ty -> UArray ty -> Bool #
Sequential (Array ty) # |
Methods take :: Int -> Array ty -> Array ty # revTake :: Int -> Array ty -> Array ty # drop :: Int -> Array ty -> Array ty # revDrop :: Int -> Array ty -> Array ty # splitAt :: Int -> Array ty -> (Array ty, Array ty) # revSplitAt :: Int -> Array ty -> (Array ty, Array ty) # splitOn :: (Element (Array ty) -> Bool) -> Array ty -> [Array ty] # break :: (Element (Array ty) -> Bool) -> Array ty -> (Array ty, Array ty) # breakElem :: Element (Array ty) -> Array ty -> (Array ty, Array ty) # intersperse :: Element (Array ty) -> Array ty -> Array ty # intercalate :: Element (Array ty) -> Array ty -> Element (Array ty) # span :: (Element (Array ty) -> Bool) -> Array ty -> (Array ty, Array ty) # filter :: (Element (Array ty) -> Bool) -> Array ty -> Array ty # partition :: (Element (Array ty) -> Bool) -> Array ty -> (Array ty, Array ty) # reverse :: Array ty -> Array ty # uncons :: Array ty -> Maybe (Element (Array ty), Array ty) # unsnoc :: Array ty -> Maybe (Array ty, Element (Array ty)) # snoc :: Array ty -> Element (Array ty) -> Array ty # cons :: Element (Array ty) -> Array ty -> Array ty # find :: (Element (Array ty) -> Bool) -> Array ty -> Maybe (Element (Array ty)) # sortBy :: (Element (Array ty) -> Element (Array ty) -> Ordering) -> Array ty -> Array ty # singleton :: Element (Array ty) -> Array ty # head :: NonEmpty (Array ty) -> Element (Array ty) # last :: NonEmpty (Array ty) -> Element (Array ty) # tail :: NonEmpty (Array ty) -> Array ty # init :: NonEmpty (Array ty) -> Array ty # isPrefixOf :: Array ty -> Array ty -> Bool # isSuffixOf :: Array ty -> Array ty -> Bool #
PrimType ty => Sequential (ChunkedUArray ty) # |
Methods take :: Int -> ChunkedUArray ty -> ChunkedUArray ty # revTake :: Int -> ChunkedUArray ty -> ChunkedUArray ty # drop :: Int -> ChunkedUArray ty -> ChunkedUArray ty # revDrop :: Int -> ChunkedUArray ty -> ChunkedUArray ty # splitAt :: Int -> ChunkedUArray ty -> (ChunkedUArray ty, ChunkedUArray ty) # revSplitAt :: Int -> ChunkedUArray ty -> (ChunkedUArray ty, ChunkedUArray ty) # splitOn :: (Element (ChunkedUArray ty) -> Bool) -> ChunkedUArray ty -> [ChunkedUArray ty] # break :: (Element (ChunkedUArray ty) -> Bool) -> ChunkedUArray ty -> (ChunkedUArray ty, ChunkedUArray ty) # breakElem :: Element (ChunkedUArray ty) -> ChunkedUArray ty -> (ChunkedUArray ty, ChunkedUArray ty) # intersperse :: Element (ChunkedUArray ty) -> ChunkedUArray ty -> ChunkedUArray ty # intercalate :: Element (ChunkedUArray ty) -> ChunkedUArray ty -> Element (ChunkedUArray ty) # span :: (Element (ChunkedUArray ty) -> Bool) -> ChunkedUArray ty -> (ChunkedUArray ty, ChunkedUArray ty) # filter :: (Element (ChunkedUArray ty) -> Bool) -> ChunkedUArray ty -> ChunkedUArray ty # partition :: (Element (ChunkedUArray ty) -> Bool) -> ChunkedUArray ty -> (ChunkedUArray ty, ChunkedUArray ty) # reverse :: ChunkedUArray ty -> ChunkedUArray ty # uncons :: ChunkedUArray ty -> Maybe (Element (ChunkedUArray ty), ChunkedUArray ty) # unsnoc :: ChunkedUArray ty -> Maybe (ChunkedUArray ty, Element (ChunkedUArray ty)) # snoc :: ChunkedUArray ty -> Element (ChunkedUArray ty) -> ChunkedUArray ty # cons :: Element (ChunkedUArray ty) -> ChunkedUArray ty -> ChunkedUArray ty # find :: (Element (ChunkedUArray ty) -> Bool) -> ChunkedUArray ty -> Maybe (Element (ChunkedUArray ty)) # sortBy :: (Element (ChunkedUArray ty) -> Element (ChunkedUArray ty) -> Ordering) -> ChunkedUArray ty -> ChunkedUArray ty # singleton :: Element (ChunkedUArray ty) -> ChunkedUArray ty # head :: NonEmpty (ChunkedUArray ty) -> Element (ChunkedUArray ty) # last :: NonEmpty (ChunkedUArray ty) -> Element (ChunkedUArray ty) # tail :: NonEmpty (ChunkedUArray ty) -> ChunkedUArray ty # init :: NonEmpty (ChunkedUArray ty) -> ChunkedUArray ty # isPrefixOf :: ChunkedUArray ty -> ChunkedUArray ty -> Bool # isSuffixOf :: ChunkedUArray ty -> ChunkedUArray ty -> Bool #

class MutableCollection c where #

Collection of things that can be made mutable, modified and then freezed into an MutableFreezed collection

Minimal complete definition

thaw, freeze, mutNew, mutWrite, mutRead, mutUnsafeWrite, mutUnsafeRead

Associated Types

type MutableFreezed c #

type MutableKey c #

type MutableValue c #

Methods

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 => Int -> 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) #

Instances

MutableCollection MutableBitmap # |
Associated Types type MutableFreezed (MutableBitmap :: * -> *) :: * # type MutableKey (MutableBitmap :: * -> *) :: * # type MutableValue (MutableBitmap :: * -> *) :: * # Methods unsafeThaw :: PrimMonad prim => MutableFreezed MutableBitmap -> prim (MutableBitmap (PrimState prim)) # unsafeFreeze :: PrimMonad prim => MutableBitmap (PrimState prim) -> prim (MutableFreezed MutableBitmap) # thaw :: PrimMonad prim => MutableFreezed MutableBitmap -> prim (MutableBitmap (PrimState prim)) # freeze :: PrimMonad prim => MutableBitmap (PrimState prim) -> prim (MutableFreezed MutableBitmap) # mutNew :: PrimMonad prim => Int -> prim (MutableBitmap (PrimState prim)) # mutUnsafeWrite :: PrimMonad prim => MutableBitmap (PrimState prim) -> MutableKey MutableBitmap -> MutableValue MutableBitmap -> prim () # mutWrite :: PrimMonad prim => MutableBitmap (PrimState prim) -> MutableKey MutableBitmap -> MutableValue MutableBitmap -> prim () # mutUnsafeRead :: PrimMonad prim => MutableBitmap (PrimState prim) -> MutableKey MutableBitmap -> prim (MutableValue MutableBitmap) # mutRead :: PrimMonad prim => MutableBitmap (PrimState prim) -> MutableKey MutableBitmap -> prim (MutableValue MutableBitmap) #
PrimType ty => MutableCollection (MUArray ty) # |
Associated Types type MutableFreezed (MUArray ty :: * -> *) :: * # type MutableKey (MUArray ty :: * -> *) :: * # type MutableValue (MUArray ty :: * -> *) :: * # Methods unsafeThaw :: PrimMonad prim => MutableFreezed (MUArray ty) -> prim (MUArray ty (PrimState prim)) # unsafeFreeze :: PrimMonad prim => MUArray ty (PrimState prim) -> prim (MutableFreezed (MUArray ty)) # thaw :: PrimMonad prim => MutableFreezed (MUArray ty) -> prim (MUArray ty (PrimState prim)) # freeze :: PrimMonad prim => MUArray ty (PrimState prim) -> prim (MutableFreezed (MUArray ty)) # mutNew :: PrimMonad prim => Int -> prim (MUArray ty (PrimState prim)) # mutUnsafeWrite :: PrimMonad prim => MUArray ty (PrimState prim) -> MutableKey (MUArray ty) -> MutableValue (MUArray ty) -> prim () # mutWrite :: PrimMonad prim => MUArray ty (PrimState prim) -> MutableKey (MUArray ty) -> MutableValue (MUArray ty) -> prim () # mutUnsafeRead :: PrimMonad prim => MUArray ty (PrimState prim) -> MutableKey (MUArray ty) -> prim (MutableValue (MUArray ty)) # mutRead :: PrimMonad prim => MUArray ty (PrimState prim) -> MutableKey (MUArray ty) -> prim (MutableValue (MUArray ty)) #
MutableCollection (MArray ty) # |
Associated Types type MutableFreezed (MArray ty :: * -> *) :: * # type MutableKey (MArray ty :: * -> *) :: * # type MutableValue (MArray ty :: * -> *) :: * # Methods unsafeThaw :: PrimMonad prim => MutableFreezed (MArray ty) -> prim (MArray ty (PrimState prim)) # unsafeFreeze :: PrimMonad prim => MArray ty (PrimState prim) -> prim (MutableFreezed (MArray ty)) # thaw :: PrimMonad prim => MutableFreezed (MArray ty) -> prim (MArray ty (PrimState prim)) # freeze :: PrimMonad prim => MArray ty (PrimState prim) -> prim (MutableFreezed (MArray ty)) # mutNew :: PrimMonad prim => Int -> prim (MArray ty (PrimState prim)) # mutUnsafeWrite :: PrimMonad prim => MArray ty (PrimState prim) -> MutableKey (MArray ty) -> MutableValue (MArray ty) -> prim () # mutWrite :: PrimMonad prim => MArray ty (PrimState prim) -> MutableKey (MArray ty) -> MutableValue (MArray ty) -> prim () # mutUnsafeRead :: PrimMonad prim => MArray ty (PrimState prim) -> MutableKey (MArray ty) -> prim (MutableValue (MArray ty)) # mutRead :: PrimMonad prim => MArray ty (PrimState prim) -> MutableKey (MArray ty) -> prim (MutableValue (MArray ty)) #

class IndexedCollection c where #

Collection of elements that can indexed by int

Minimal complete definition

(!), findIndex

Methods

(!) :: c -> Int -> Maybe (Element c) #

findIndex :: (Element c -> Bool) -> c -> Maybe Int #

Instances

IndexedCollection Bitmap # |
Methods (!) :: Bitmap -> Int -> Maybe (Element Bitmap) # findIndex :: (Element Bitmap -> Bool) -> Bitmap -> Maybe Int #
IndexedCollection [a] # |
Methods (!) :: [a] -> Int -> Maybe (Element [a]) # findIndex :: (Element [a] -> Bool) -> [a] -> Maybe Int #
PrimType ty => IndexedCollection (UArray ty) # |
Methods (!) :: UArray ty -> Int -> Maybe (Element (UArray ty)) # findIndex :: (Element (UArray ty) -> Bool) -> UArray ty -> Maybe Int #
IndexedCollection (Array ty) # |
Methods (!) :: Array ty -> Int -> Maybe (Element (Array ty)) # findIndex :: (Element (Array ty) -> Bool) -> Array ty -> Maybe Int #
PrimType ty => IndexedCollection (ChunkedUArray ty) # |
Methods (!) :: ChunkedUArray ty -> Int -> Maybe (Element (ChunkedUArray ty)) # findIndex :: (Element (ChunkedUArray ty) -> Bool) -> ChunkedUArray ty -> Maybe Int #

class KeyedCollection c where #

Collection of things that can be looked up by Key

Minimal complete definition

lookup

Associated Types

type Key c #

type Value c #

Methods

lookup :: Key c -> c -> Maybe (Value c) #

Instances

Eq k => KeyedCollection [(k, v)] # |
Associated Types type Key [(k, v)] :: * # type Value [(k, v)] :: * # Methods lookup :: Key [(k, v)] -> [(k, v)] -> Maybe (Value [(k, v)]) #

class Sequential col => Zippable col where #

Methods

zipWith :: (Sequential a, Sequential b) => (Element a -> Element b -> Element col) -> a -> b -> col #

`zipWith` generalises `zip` by zipping with the function given as the first argument, instead of a tupling function. For example, ``zipWith` (+)` is applied to two collections to produce the collection of corresponding sums.

zipWith3 :: (Sequential a, Sequential b, Sequential c) => (Element a -> Element b -> Element c -> Element col) -> a -> b -> c -> col #

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 #

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 #

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 #

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 #

Like `zipWith`, but works with 7 collections.

Instances

Zippable AsciiString # |
Methods zipWith :: (Sequential a, Sequential b) => (Element a -> Element b -> Element AsciiString) -> a -> b -> AsciiString # zipWith3 :: (Sequential a, Sequential b, Sequential c) => (Element a -> Element b -> Element c -> Element AsciiString) -> a -> b -> c -> AsciiString # zipWith4 :: (Sequential a, Sequential b, Sequential c, Sequential d) => (Element a -> Element b -> Element c -> Element d -> Element AsciiString) -> a -> b -> c -> d -> AsciiString # zipWith5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element AsciiString) -> a -> b -> c -> d -> e -> AsciiString # 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 AsciiString) -> a -> b -> c -> d -> e -> f -> AsciiString # 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 AsciiString) -> a -> b -> c -> d -> e -> f -> g -> AsciiString #
Zippable String # |
Methods zipWith :: (Sequential a, Sequential b) => (Element a -> Element b -> Element String) -> a -> b -> String # zipWith3 :: (Sequential a, Sequential b, Sequential c) => (Element a -> Element b -> Element c -> Element String) -> a -> b -> c -> String # zipWith4 :: (Sequential a, Sequential b, Sequential c, Sequential d) => (Element a -> Element b -> Element c -> Element d -> Element String) -> a -> b -> c -> d -> String # zipWith5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element String) -> a -> b -> c -> d -> e -> String # 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 String) -> a -> b -> c -> d -> e -> f -> String # 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 String) -> a -> b -> c -> d -> e -> f -> g -> String #
Zippable [c] # |
Methods zipWith :: (Sequential a, Sequential b) => (Element a -> Element b -> Element [c]) -> a -> b -> [c] # zipWith3 :: (Sequential a, Sequential b, Sequential c) => (Element a -> Element b -> Element c -> Element [c]) -> a -> b -> c -> [c] # zipWith4 :: (Sequential a, Sequential b, Sequential c, Sequential d) => (Element a -> Element b -> Element c -> Element d -> Element [c]) -> a -> b -> c -> d -> [c] # zipWith5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element [c]) -> a -> b -> c -> d -> e -> [c] # 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 [c]) -> a -> b -> c -> d -> e -> f -> [c] # 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 [c]) -> a -> b -> c -> d -> e -> f -> g -> [c] #
PrimType ty => Zippable (UArray ty) # |
Methods zipWith :: (Sequential a, Sequential b) => (Element a -> Element b -> Element (UArray ty)) -> a -> b -> UArray ty # zipWith3 :: (Sequential a, Sequential b, Sequential c) => (Element a -> Element b -> Element c -> Element (UArray ty)) -> a -> b -> c -> UArray ty # zipWith4 :: (Sequential a, Sequential b, Sequential c, Sequential d) => (Element a -> Element b -> Element c -> Element d -> Element (UArray ty)) -> a -> b -> c -> d -> UArray ty # zipWith5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element (UArray ty)) -> a -> b -> c -> d -> e -> UArray ty # 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 (UArray ty)) -> a -> b -> c -> d -> e -> f -> UArray ty # 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 (UArray ty)) -> a -> b -> c -> d -> e -> f -> g -> UArray ty #
Zippable (Array ty) # |
Methods zipWith :: (Sequential a, Sequential b) => (Element a -> Element b -> Element (Array ty)) -> a -> b -> Array ty # zipWith3 :: (Sequential a, Sequential b, Sequential c) => (Element a -> Element b -> Element c -> Element (Array ty)) -> a -> b -> c -> Array ty # zipWith4 :: (Sequential a, Sequential b, Sequential c, Sequential d) => (Element a -> Element b -> Element c -> Element d -> Element (Array ty)) -> a -> b -> c -> d -> Array ty # zipWith5 :: (Sequential a, Sequential b, Sequential c, Sequential d, Sequential e) => (Element a -> Element b -> Element c -> Element d -> Element e -> Element (Array ty)) -> a -> b -> c -> d -> e -> Array ty # 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 (Array ty)) -> a -> b -> c -> d -> e -> f -> Array ty # 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 (Array ty)) -> a -> b -> c -> d -> e -> f -> g -> Array ty #

class Buildable col where #

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"

Minimal complete definition

append, build

Associated Types

type Mutable col :: * -> * #

Mutable collection type used for incrementally writing chunks.

type Step col #

Unit of the smallest step possible in an `append` operation.

A UTF-8 character can have a size between 1 and 4 bytes, so this should be defined as 1 byte for collections of `Char`.

Methods

append :: PrimMonad prim => Element col -> Builder col prim () #

build :: PrimMonad prim => Int -> Builder col prim () -> prim col #

Instances

Buildable String # |
Associated Types type Mutable String :: * -> * # type Step String :: * # Methods append :: PrimMonad prim => Element String -> Builder String prim () # build :: PrimMonad prim => Int -> Builder String prim () -> prim String #
PrimType ty => Buildable (UArray ty) # |
Associated Types type Mutable (UArray ty) :: * -> * # type Step (UArray ty) :: * # Methods append :: PrimMonad prim => Element (UArray ty) -> Builder (UArray ty) prim () # build :: PrimMonad prim => Int -> Builder (UArray ty) prim () -> prim (UArray ty) #
Buildable (Array ty) # |
Associated Types type Mutable (Array ty) :: * -> * # type Step (Array ty) :: * # Methods append :: PrimMonad prim => Element (Array ty) -> Builder (Array ty) prim () # build :: PrimMonad prim => Int -> Builder (Array ty) prim () -> prim (Array ty) #

newtype Builder col st a #

Constructors

Builder |
Fields runBuilder :: State (Offset (Step col), BuildingState col (PrimState st)) st a

Instances

Monad st => Monad (Builder col st) # |
Methods (>>=) :: Builder col st a -> (a -> Builder col st b) -> Builder col st b # (>>) :: Builder col st a -> Builder col st b -> Builder col st b # return :: a -> Builder col st a # fail :: String -> Builder col st a #
Monad st => Functor (Builder col st) # |
Methods fmap :: (a -> b) -> Builder col st a -> Builder col st b # (<$) :: a -> Builder col st b -> Builder col st a #
Monad st => Applicative (Builder col st) # |
Methods pure :: a -> Builder col st a # (<*>) :: Builder col st (a -> b) -> Builder col st a -> Builder col st b # (*>) :: Builder col st a -> Builder col st b -> Builder col st b # (<*) :: Builder col st a -> Builder col st b -> Builder col st a #

data BuildingState col st #

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.

Constructors

BuildingState |
Fields prevChunks :: [col] prevChunksSize :: !(Size (Step col)) curChunk :: Mutable col st chunkSize :: !(Size (Step col))