Copyright | (c) 2019 Composewell Technologies |
---|---|
License | BSD-3-Clause |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- data SmallArray a = SmallArray (SmallArray# a)
- foldl' :: (b -> a -> b) -> b -> SmallArray a -> b
- foldr :: (a -> b -> b) -> b -> SmallArray a -> b
- length :: SmallArray a -> Int
- writeN :: MonadIO m => Int -> Fold m a (SmallArray a)
- toStreamD :: Monad m => SmallArray a -> Stream m a
- toStreamDRev :: Monad m => SmallArray a -> Stream m a
- toStream :: Monad m => SmallArray a -> SerialT m a
- toStreamRev :: Monad m => SmallArray a -> SerialT m a
- read :: Monad m => Unfold m (SmallArray a) a
- fromListN :: Int -> [a] -> SmallArray a
- fromStreamDN :: MonadIO m => Int -> Stream m a -> m (SmallArray a)
- fromStreamN :: MonadIO m => Int -> SerialT m a -> m (SmallArray a)
- streamFold :: Monad m => (SerialT m a -> m b) -> SmallArray a -> m b
- fold :: Monad m => Fold m a b -> SmallArray a -> m b
Documentation
data SmallArray a Source #
Instances
foldl' :: (b -> a -> b) -> b -> SmallArray a -> b Source #
foldr :: (a -> b -> b) -> b -> SmallArray a -> b Source #
length :: SmallArray a -> Int Source #
writeN :: MonadIO m => Int -> Fold m a (SmallArray a) Source #
writeN n
folds a maximum of n
elements from the input stream to an
SmallArray
.
Since we are folding to a SmallArray
n
should be <= 128, for larger number
of elements use an Array
from either Streamly.Data.Array or Streamly.Data.Array.Foreign.
toStreamDRev :: Monad m => SmallArray a -> Stream m a Source #
toStreamRev :: Monad m => SmallArray a -> SerialT m a Source #
fromListN :: Int -> [a] -> SmallArray a Source #
Create a SmallArray
from the first n
elements of a list. The
array may hold less than n
elements if the length of the list <=
n
.
It is recommended to use a value of n
<= 128. For larger sized
arrays, use an Array
from Streamly.Data.Array or
Streamly.Data.Array.Foreign
fromStreamDN :: MonadIO m => Int -> Stream m a -> m (SmallArray a) Source #
fromStreamN :: MonadIO m => Int -> SerialT m a -> m (SmallArray a) Source #
Create a SmallArray
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.
For optimal performance use this with n
<= 128.
streamFold :: Monad m => (SerialT m a -> m b) -> SmallArray a -> m b Source #
Orphan instances
NFData a => NFData (SmallArray a) Source # | |
rnf :: SmallArray a -> () # |