Newer
Older
module Lib ( boundedPushRight
) where
import qualified Data.Sequence as S
-- | use Seq as a ring buffer. push new item to Seq on the right, if length is
-- greater than given size, remove item from the left, so that size is always
-- within maxSize.
boundedPushRight :: S.Seq a -> Int -> a -> S.Seq a
boundedPushRight buffer maxSize item =
if S.length buffer == maxSize
then