Closed turion closed 6 years ago
I'd like to have a go at this if it's ok! Beginner towards intermediate, however this library has several new concepts that I'd like to look into.
@alexpeits By any means give it a go! Just create a pull request, and we'll work on it in until we can merge it :)
@alexpeits it's probably easiest if you just copy the module FRP.Rhine.ResamplingBuffer.FIFO
and then reverse the order in which elements are taken from the buffer.
@turion Any examples on how to use the resampling buffers would be welcome to test my additions. In any case, the implementation is what you mentioned. Elements are still pushed to the left of the Seq
and popped with viewl
, which, from my understanding, yields the same results and performance as pushing to the right end with |>
and popping with viewr
.
Great! You can test the buffer by creating a simple interactive example like this:
{-# LANGUAGE DataKinds #-}
import FRP.Rhine
import FRP.Rhine.Clock.Realtime.Millisecond
import FRP.Rhine.Clock.Realtime.Stdin
import FRP.Rhine.ResamplingBuffer.LIFO
import FRP.Rhine.Schedule.Concurrently
main = flow $ count @@ (waitClock :: Millisecond 500) >-- lifo -@- concurrently --> arrMSync print @@ StdinClock
Every half second, a number is put onto the buffer, and on every return press, a number is popped from it and output.
You can write an automatable test, you can use pure clocks like those from #40.
Thanks for your contribution, you're welcome to write more ;)
All FIFO buffers can also exist in a LIFO variant.