Copyright | (c) 2020 Composewell Technologies |
---|---|
License | BSD-3-Clause |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data Array a
- fromListN :: Prim a => Int -> [a] -> Array a
- fromList :: Prim a => [a] -> Array a
- fromStreamN :: (MonadIO m, Prim a) => Int -> SerialT m a -> m (Array a)
- fromStream :: (MonadIO m, Prim a) => SerialT m a -> m (Array a)
- writeN :: (MonadIO m, Prim a) => Int -> Fold m a (Array a)
- write :: (MonadIO m, Prim a) => Fold m a (Array a)
- toList :: Prim a => Array a -> [a]
- toStream :: (MonadIO m, IsStream t, Prim a) => Array a -> t m a
- toStreamRev :: (MonadIO m, IsStream t, Prim a) => Array a -> t m a
- read :: (MonadIO m, Prim a) => Unfold m (Array a) a
- unsafeRead :: (MonadIO m, Prim a) => Unfold m (Array a) a
- length :: Array a -> Int
- null :: Array a -> Bool
- last :: Prim a => Array a -> Maybe a
- readIndex :: Prim a => Array a -> Int -> Maybe a
- unsafeIndex :: Prim a => Array a -> Int -> a
- streamFold :: (MonadIO m, Prim a) => (SerialT m a -> m b) -> Array a -> m b
- fold :: forall m a b. (MonadIO m, Prim a) => Fold m a b -> Array a -> m b
- concat :: (IsStream t, MonadIO m, Prim a) => t m (Array a) -> t m a
- compact :: (MonadIO m, Prim a) => Int -> SerialT m (Array a) -> SerialT m (Array a)
Documentation
Instances
Prim a => IsList (Array a) Source # | |
(Eq a, Prim a) => Eq (Array a) Source # | |
(Ord a, Prim a) => Ord (Array a) Source # | Lexicographic ordering. Subject to change between major versions. |
Defined in Streamly.Internal.Data.Array.Prim.Type | |
(Prim a, Read a, Show a) => Read (Array a) Source # | |
(Show a, Prim a) => Show (Array a) Source # | |
a ~ Char => IsString (Array a) Source # | |
Defined in Streamly.Internal.Data.Array.Prim.Type fromString :: String -> Array a # | |
Prim a => Semigroup (Array a) Source # | |
Prim a => Monoid (Array a) Source # | |
NFData (Array a) Source # | |
Defined in Streamly.Internal.Data.Array.Prim.Type | |
type Item (Array a) Source # | |
Defined in Streamly.Internal.Data.Array.Prim.Type |
Construction
fromStreamN :: (MonadIO m, Prim a) => Int -> SerialT m a -> m (Array a) Source #
Create an Array
from the first N elements of a stream. The array is
allocated to size N, if the stream terminates before N elements then the
array may hold less than N elements.
Pre-release
fromStream :: (MonadIO m, Prim a) => SerialT m a -> m (Array a) Source #
Create an Array
from a stream. This is useful when we want to create a
single array from a stream of unknown size. writeN
is at least twice
as efficient when the size is already known.
Note that if the input stream is too large memory allocation for the array
may fail. When the stream size is not known, arraysOf
followed by
processing of indvidual arrays in the resulting stream should be preferred.
Pre-release
writeN :: (MonadIO m, Prim a) => Int -> Fold m a (Array a) Source #
writeN n
folds a maximum of n
elements from the input stream to an
Array
.
Pre-release
write :: (MonadIO m, Prim a) => Fold m a (Array a) Source #
Fold the whole input to a single array.
Caution! Do not use this on infinite streams.
Pre-release
Elimination
toStream :: (MonadIO m, IsStream t, Prim a) => Array a -> t m a Source #
Convert an Array
into a stream.
Pre-release
toStreamRev :: (MonadIO m, IsStream t, Prim a) => Array a -> t m a Source #
Convert an Array
into a stream in reverse order.
Pre-release
read :: (MonadIO m, Prim a) => Unfold m (Array a) a Source #
Unfold an array into a stream.
Since: 0.7.0
unsafeRead :: (MonadIO m, Prim a) => Unfold m (Array a) a Source #
Unfold an array into a stream, does not check the end of the array, the user is responsible for terminating the stream within the array bounds. For high performance application where the end condition can be determined by a terminating fold.
The following might not be true, not that the representation changed. Written in the hope that it may be faster than "read", however, in the case for which this was written, "read" proves to be faster even though the core generated with unsafeRead looks simpler.
Pre-release
Random Access
readIndex :: Prim a => Array a -> Int -> Maybe a Source #
O(1) Lookup the element at the given index, starting from 0.
Pre-release
Immutable Transformations
Folding Arrays
streamFold :: (MonadIO m, Prim a) => (SerialT m a -> m b) -> Array a -> m b Source #
Fold an array using a stream fold operation.
Pre-release
fold :: forall m a b. (MonadIO m, Prim a) => Fold m a b -> Array a -> m b Source #
Fold an array using a Fold
.
Pre-release