New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LIFO buffers #34

Closed
turion opened this Issue Apr 25, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@turion
Copy link
Owner

turion commented Apr 25, 2018

All FIFO buffers can also exist in a LIFO variant.

@turion turion added this to the HS2018-submission milestone Apr 26, 2018

@alexpeits

This comment has been minimized.

Copy link
Contributor

alexpeits commented May 3, 2018

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.

@turion

This comment has been minimized.

Copy link
Owner

turion commented May 3, 2018

@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 :)

@turion

This comment has been minimized.

Copy link
Owner

turion commented May 4, 2018

@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.

@alexpeits

This comment has been minimized.

Copy link
Contributor

alexpeits commented May 5, 2018

@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.

@turion

This comment has been minimized.

Copy link
Owner

turion commented May 7, 2018

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 ;)

@turion turion closed this May 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment