Closed parenthetical closed 4 years ago
Coming back to this, the following seems to do the trick!
runE :: (t ~ SpiderTimeline Global)
=> (Event t a -> PushM t (Event t b))
-> [a]
-> IO [Maybe b]
runE p input = runSpiderHost $ do
let p' e =
switchHoldPromptOnly never
. pushAlways (const (p e))
=<< headE e
(inE, trigRef) <- newEventWithTriggerRef
outE <- runHostFrame (p' inE)
outHnd <- subscribeEvent outE
forM input (\a -> fireEventRefAndRead trigRef a outHnd)
I need to run a program returning an event in a way that I can tell what the value of a possible event occurrence at "now" is, maybe even allowing an input event to have an occurrence at now.
For example with a function
runE
behaving like so:where
produces:
[2,1]
.What would be the best way to implement such a function?