4 ms·
It's been ages since I've used a "real" functional language but wouldn't it be nice to parameterise externalities like time, and have events occur "spontaneousl
by jb_s 5y ago
It's been ages since I've used a "real" functional language but wouldn't it be nice to parameterise externalities like time, and have events occur "spontaneously" that force application state to update? Kind of like interrupts. Or now that I think about it... it sounds a bit like React where DOM events etc force application state to update (in a pure fashion)
Has this been done before?
So your LED function in pseudocode looks like
ToggleLeds(leds, t):
for each LED
LED.power = (LED.start + 1s) > t ? ON : OFF
And this is invoked from main() as follows
main():
ToggleLeds(this.LEDs, Events.Time)
Where Events.Time is some kind of event stream which allows the runtime to reevaluate main() and any other dependent functions each time it's updated
edit: And to sidestep the obvious performance issue with the function being reevaluated every few microseconds :D you would implement something like this
main():
ToggleLeds(this.LEDs, Events.Time(ms=1000))