{-# LANGUAGE RecordWildCards #-}
module FRP.Rhine.ResamplingBuffer.MSF where
import FRP.Rhine
msfBuffer
:: Monad m
=> MSF m (TimeInfo cl2, [(TimeInfo cl1, a)]) b
-> ResamplingBuffer m cl1 cl2 a b
msfBuffer msf = msfBuffer' msf []
where
msfBuffer'
:: Monad m
=> MSF m (TimeInfo cl2, [(TimeInfo cl1, a)]) b
-> [(TimeInfo cl1, a)]
-> ResamplingBuffer m cl1 cl2 a b
msfBuffer' msf as = ResamplingBuffer {..}
where
put ti1 a = return $ msfBuffer' msf $ (ti1, a) : as
get ti2 = do
(b, msf') <- unMSF msf (ti2, as)
return (b, msfBuffer msf')