haskell - Using netwire's periodic vs. at wires -


i'm trying write framework real-time interactive graphics in haskell. i've been trying handle on things using netwire 5, don't seem have handle on how things "depend" on 1 another. for example, following code should produce val 2 seconds before switching (val + 1), , continuing on indefinitely.

somewire :: num => -> wire s e m a somewire x = (-->) ((pure x) &&& (periodic 2) >>> until) (somewire (x + 1)) 

however, creates sort of memory leak program stalls , keeps allocating memory until on system crashes. alternatively, definition

somewire :: num => -> wire s e m a somewire x = (-->) ((pure x) &&& (at 2) >>> until) (somewire (x + 1)) 

behaves way expect to: count val onwards having value change every 2 seconds. can please explain behavior?

the key insight periodic produces event immediately.

hence, when go produce value wire, have evaluate following:

somewire x (-->) ((pure x) &&& (periodic 2) >>> until) (somewire (x + 1)) (-->) (pure (x, event _) >>> until) (somewire (x + 1)) (-->) *inhibition* (somewire (x + 1)) somewire (x + 1) 

since isn't tail recursive, garbage collector isn't allowed clean previous instances allocated wire , run out of memory (instead of getting infinite loop).


Comments

Popular posts from this blog

android - Automated my builds -

how to proxy from https to http with lighttpd -

python - Flask migration error -