Replies: 11 comments
-
|
Good catch. This problem seems to clearly stem from the use of Two observations:
|
Beta Was this translation helpful? Give feedback.
-
|
@walseb Can you please check what happens if you remove the |
Beta Was this translation helpful? Give feedback.
-
|
Yeah it works then and I haven't observed any problems with removing Crashes: sf = proc _ -> do
rec
foo <- accumHoldBy (+) (1 :: Float) -< Event bar
bar <- iPre 1 -< 1
returnA -< fooDoesn't crash sf = proc _ -> do
rec
-- Notice the extra iPre, you could probably also use (-->)
foo <- iPre 1 <<< accumHoldBy (+) (1 :: Float) -< Event bar
bar <- iPre 1 -< 1
returnA -< fooIn yampa the first one doesn't crash which caused me further confusion. It's also strange how it crashes despite me initializing |
Beta Was this translation helpful? Give feedback.
-
I don't see why it can't be. The result of The upshot if this is that if an MSF has some accumulator that it wants to be forced on each tick, it needs to make sure the accumulateWith f s0 = feedback s0 $ arr g
where
g (a, s) = let s' = f a s in (s', s')to accumulateWith' f s0 = feedback s0 $ arr g
where
g (a, s) = let s' = f a s in s' `seq` (s', s')Other users of |
Beta Was this translation helpful? Give feedback.
-
|
I was just bitten by this same thing. Essentially I was building a loop, and an arrow within would fail, depending on associativity: (f >>> g) >>> iPre 0 -- infinite loop
f >>> (g >>> iPre 0) -- worksI had a helluva time debugging that, but, good to know you all are aware of it :D |
Beta Was this translation helpful? Give feedback.
-
|
So:
But I think, fundamentally, it's probably better to tell people that they need to make MSFs strict in their arguments if they don't want values to accumulate. That gives them both the control and the responsibility. So, if we can always get what we had by just adding seqs to MSFs we (as dunai users) compose, then I think the best course of action is to remove that |
Beta Was this translation helpful? Give feedback.
-
|
out of curiousity, is it possible to execute looping streams without needing delays? I think not, and therefore I struggle to understand why we have |
Beta Was this translation helpful? Give feedback.
-
Usually not, but there could be special cases where e.g. some type or some monad is sufficiently lazy so that it might work. But definitely not in general.
I was wondering about that myself as well many times in the past. Basically,
Probably. It definitely gives you a finer control. But I never was in a position where I strictly needed them. I think there are some situations where syntax and performance are improved over As another reason, there are sometimes library functions that already introduce delays. Using them together with Plus, the
Yes, that's true, and that's probably also what we should teach. |
Beta Was this translation helpful? Give feedback.
-
I more or less agree with this point of view. Loop was present in signal processing languages like Lustre. Implementations like Yampa also inherited this construct. The fact that a standard class like For me, this has been a point of disagreement with Henrik Nilsson (one of the creators of Yampa). I have expressed, again and again, that for me it is almost never the case that introducing a delay in That being said, I have found the use of There are many possible ways we could address this:
|
Beta Was this translation helpful? Give feedback.
-
|
Another example which might be related: https://gitlab.com/gerold.meisinger/yampa-book/-/raw/main/src/textfield1.hs Entering characters in the textfield only works when |
Beta Was this translation helpful? Give feedback.
-
|
That's very useful! I'm really happy that you found this example. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! I was re-reading the old issue @turion helped me with (#236) and noticed that he mentioned the issue with MSF compose strictness way before I eventually figured out that was the problem, I think I just didn't make the connection. But more relevant to this issue, I was reminded of the problem I encountered there with MSF arrows not being associative. Back then I was more concerned with just getting my yampa stuff working in bearriver, but today I decided to give it a go.
I have managed to reduce it down to this:
In
sfAthe output ofconstant undefinedis never evaluated as it isn't needed to create a result.In
sfBthe output ofconstant undefinedis reduced to WHNF which results in undefined being thrown.But in both examples the output of
constant undefinedisn't actually needed to get the result so they shouldn't be evaluated even to WHNF. If we put theundefinedinto a data structure so it can't be fully evaluated with just WHNF we can see that this is indeed a evaluation problem:Beyond this I haven't made any progress yet. For easy reference here are the relevant functions:
Beta Was this translation helpful? Give feedback.
All reactions