{-# LANGUAGE RecordWildCards #-}
module FRP.Rhine.ResamplingBuffer.LIFO where
import Prelude hiding (length, take)
import Data.Sequence
import FRP.Rhine.ResamplingBuffer
import FRP.Rhine.ResamplingBuffer.Timeless
lifoUnbounded :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a)
lifoUnbounded :: forall (m :: Type -> Type) cl1 cl2 a.
Monad m =>
ResamplingBuffer m cl1 cl2 a (Maybe a)
lifoUnbounded = forall (m :: Type -> Type) s a b cl1 cl2.
Monad m =>
AsyncMealy m s a b -> s -> ResamplingBuffer m cl1 cl2 a b
timelessResamplingBuffer AsyncMealy {forall {m :: Type -> Type} {a}.
Monad m =>
Seq a -> m (Maybe a, Seq a)
forall {m :: Type -> Type} {a}. Monad m => Seq a -> a -> m (Seq a)
amGet :: Seq a -> m (Maybe a, Seq a)
amPut :: Seq a -> a -> m (Seq a)
amGet :: forall {m :: Type -> Type} {a}.
Monad m =>
Seq a -> m (Maybe a, Seq a)
amPut :: forall {m :: Type -> Type} {a}. Monad m => Seq a -> a -> m (Seq a)
..} forall a. Seq a
empty
where
amPut :: Seq a -> a -> m (Seq a)
amPut Seq a
as a
a = forall (m :: Type -> Type) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ a
a forall a. a -> Seq a -> Seq a
<| Seq a
as
amGet :: Seq a -> m (Maybe a, Seq a)
amGet Seq a
as = case forall a. Seq a -> ViewL a
viewl Seq a
as of
ViewL a
EmptyL -> forall (m :: Type -> Type) a. Monad m => a -> m a
return (forall a. Maybe a
Nothing, forall a. Seq a
empty)
a
a :< Seq a
as' -> forall (m :: Type -> Type) a. Monad m => a -> m a
return (forall a. a -> Maybe a
Just a
a, Seq a
as')
lifoBounded :: Monad m => Int -> ResamplingBuffer m cl1 cl2 a (Maybe a)
lifoBounded :: forall (m :: Type -> Type) cl1 cl2 a.
Monad m =>
Int -> ResamplingBuffer m cl1 cl2 a (Maybe a)
lifoBounded Int
threshold = forall (m :: Type -> Type) s a b cl1 cl2.
Monad m =>
AsyncMealy m s a b -> s -> ResamplingBuffer m cl1 cl2 a b
timelessResamplingBuffer AsyncMealy {forall {m :: Type -> Type} {a}.
Monad m =>
Seq a -> m (Maybe a, Seq a)
forall {m :: Type -> Type} {a}. Monad m => Seq a -> a -> m (Seq a)
amGet :: forall {m :: Type -> Type} {a}.
Monad m =>
Seq a -> m (Maybe a, Seq a)
amPut :: forall {m :: Type -> Type} {a}. Monad m => Seq a -> a -> m (Seq a)
amGet :: Seq a -> m (Maybe a, Seq a)
amPut :: Seq a -> a -> m (Seq a)
..} forall a. Seq a
empty
where
amPut :: Seq a -> a -> m (Seq a)
amPut Seq a
as a
a = forall (m :: Type -> Type) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ forall a. Int -> Seq a -> Seq a
take Int
threshold forall a b. (a -> b) -> a -> b
$ a
a forall a. a -> Seq a -> Seq a
<| Seq a
as
amGet :: Seq a -> m (Maybe a, Seq a)
amGet Seq a
as = case forall a. Seq a -> ViewL a
viewl Seq a
as of
ViewL a
EmptyL -> forall (m :: Type -> Type) a. Monad m => a -> m a
return (forall a. Maybe a
Nothing, forall a. Seq a
empty)
a
a :< Seq a
as' -> forall (m :: Type -> Type) a. Monad m => a -> m a
return (forall a. a -> Maybe a
Just a
a, Seq a
as')
lifoWatch :: Monad m => ResamplingBuffer m cl1 cl2 a (Maybe a, Int)
lifoWatch :: forall (m :: Type -> Type) cl1 cl2 a.
Monad m =>
ResamplingBuffer m cl1 cl2 a (Maybe a, Int)
lifoWatch = forall (m :: Type -> Type) s a b cl1 cl2.
Monad m =>
AsyncMealy m s a b -> s -> ResamplingBuffer m cl1 cl2 a b
timelessResamplingBuffer AsyncMealy {forall {m :: Type -> Type} {a}.
Monad m =>
Seq a -> m ((Maybe a, Int), Seq a)
forall {m :: Type -> Type} {a}. Monad m => Seq a -> a -> m (Seq a)
amGet :: forall {m :: Type -> Type} {a}.
Monad m =>
Seq a -> m ((Maybe a, Int), Seq a)
amPut :: forall {m :: Type -> Type} {a}. Monad m => Seq a -> a -> m (Seq a)
amGet :: Seq a -> m ((Maybe a, Int), Seq a)
amPut :: Seq a -> a -> m (Seq a)
..} forall a. Seq a
empty
where
amPut :: Seq a -> a -> m (Seq a)
amPut Seq a
as a
a = forall (m :: Type -> Type) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ a
a forall a. a -> Seq a -> Seq a
<| Seq a
as
amGet :: Seq a -> m ((Maybe a, Int), Seq a)
amGet Seq a
as = case forall a. Seq a -> ViewL a
viewl Seq a
as of
ViewL a
EmptyL -> forall (m :: Type -> Type) a. Monad m => a -> m a
return ((forall a. Maybe a
Nothing, Int
0), forall a. Seq a
empty)
a
a :< Seq a
as' -> forall (m :: Type -> Type) a. Monad m => a -> m a
return ((forall a. a -> Maybe a
Just a
a, forall a. Seq a -> Int
length Seq a
as'), Seq a
as')