ring-buffers-0.1: mutable ring buffers with atomic updates in GHC Haskell

Safe HaskellNone
LanguageHaskell2010

RingBuffers.Lifted

Synopsis

Documentation

new Source #

Arguments

:: Int

capacity of buffer

-> IO (RingBuffer a) 

Return a new ring buffer of the specified size.

clear Source #

Arguments

:: RingBuffer a

buffer to clear

-> IO () 

Reset the buffer to its empty state.

append :: a -> RingBuffer a -> IO () Source #

Add an item to the end of the buffer.

capacity :: RingBuffer a -> IO Int Source #

Get the maximum number of items the ring can contain

filledLength :: RingBuffer a -> IO Int Source #

Get the current filled length of the ring

latest :: RingBuffer a -> Int -> IO (Maybe a) Source #

Retrieve the \(n\)th most-recently added item of the ring

foldMap :: Monoid b => RingBuffer a -> (a -> IO b) -> IO b Source #

Execute the given action with the items of the ring, accumulating its results.