[Haskell-cafe] Yampa question
ninegua at gmail.com
Sun Sep 30 17:40:36 EDT 2007
On 9/29/07, Ryan Ingram <ryani.spam at gmail.com> wrote:
> > first bc = SF sf where
> > sf dt ~(b,d) = ((c,d), sfFirst bc') where
> > (c, bc') = runSF bc dt b
> One question I had was about the implementation of "first". Is it
> important that the pair match be lazy? Or is it safe to make it
> strict? What are the advantages and disadvantages of each choice?
The pattern match has to be lazy to make ArrowLoop/loop work.
> but there's a pretty clear space leak here with repeated "Right"
> calls, and I'm not sure if the inner signal should see the lost time
> or not.
In the original implementation, the inner signal function is
"suspended" or "frozen in time" when the input stream is not selecting
it. While your implementation wants the inner signal function to
"remember and recover" the lost time when it's not selected. This
would require the inner signal function to handle arbitarily large
delta time by itself though.
I guess either would make sense in different situations, so the
decision is purely yours.
Also you should be able to make the leak go away by forcing the
accumulated delta time to be fully evaluated before being passed on.
More information about the Haskell-Cafe