Copyright | (c) 2021 Composewell Technologies |
---|---|
License | BSD-3-Clause |
Maintainer | streamly@composewell.com |
Stability | experimental |
Portability | GHC |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- data Ring a = Ring {}
- createRing :: MonadIO m => Int -> m (Ring a)
- writeLastN :: MonadIO m => Int -> Fold m a (Ring a)
- seek :: MonadIO m => Int -> Ring a -> m (Ring a)
- unsafeInsertRingWith :: Ring a -> a -> IO Int
- toMutArray :: MonadIO m => Int -> Int -> Ring a -> m (MutArray a)
- copyToMutArray :: MonadIO m => Int -> Int -> Ring a -> m (MutArray a)
- toStreamWith :: Int -> Ring a -> Stream m a
Documentation
Generation
writeLastN :: MonadIO m => Int -> Fold m a (Ring a) Source #
Note that it is not safe to return a reference to the mutable Ring using a scan as the Ring is continuously getting mutated. You could however copy out the Ring.
Modification
seek :: MonadIO m => Int -> Ring a -> m (Ring a) Source #
Move the ring head clockwise (+ve adj) or counter clockwise (-ve adj) by the given amount.
Conversion
toMutArray :: MonadIO m => Int -> Int -> Ring a -> m (MutArray a) Source #
toMutArray rignHeadAdjustment lengthToRead ring
.
Convert the ring into a boxed mutable array. Note that the returned MutArray
shares the same underlying memory as the Ring, the user of this API needs to
ensure that the ring is not mutated during and after the conversion.