{"action":"closed","issue":{"url":"https://api.github.com/repos/HeinrichApfelmus/reactive-banana/issues/105","labels_url":"https://api.github.com/repos/HeinrichApfelmus/reactive-banana/issues/105/labels{/name}","comments_url":"https://api.github.com/repos/HeinrichApfelmus/reactive-banana/issues/105/comments","events_url":"https://api.github.com/repos/HeinrichApfelmus/reactive-banana/issues/105/events","html_url":"https://github.com/HeinrichApfelmus/reactive-banana/issues/105","id":104913838,"number":105,"title":"Monadic API: Confusion with observeE","user":{"login":"ocharles","id":20878,"avatar_url":"https://avatars.githubusercontent.com/u/20878?v=3","gravatar_id":"","url":"https://api.github.com/users/ocharles","html_url":"https://github.com/ocharles","followers_url":"https://api.github.com/users/ocharles/followers","following_url":"https://api.github.com/users/ocharles/following{/other_user}","gists_url":"https://api.github.com/users/ocharles/gists{/gist_id}","starred_url":"https://api.github.com/users/ocharles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocharles/subscriptions","organizations_url":"https://api.github.com/users/ocharles/orgs","repos_url":"https://api.github.com/users/ocharles/repos","events_url":"https://api.github.com/users/ocharles/events{/privacy}","received_events_url":"https://api.github.com/users/ocharles/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/HeinrichApfelmus/reactive-banana/labels/bug","name":"bug","color":"e10c02"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/HeinrichApfelmus/reactive-banana/milestones/7","html_url":"https://github.com/HeinrichApfelmus/reactive-banana/milestones/1.0","labels_url":"https://api.github.com/repos/HeinrichApfelmus/reactive-banana/milestones/7/labels","id":1280073,"number":7,"title":"1.0","description":null,"creator":{"login":"HeinrichApfelmus","id":564592,"avatar_url":"https://avatars.githubusercontent.com/u/564592?v=3","gravatar_id":"","url":"https://api.github.com/users/HeinrichApfelmus","html_url":"https://github.com/HeinrichApfelmus","followers_url":"https://api.github.com/users/HeinrichApfelmus/followers","following_url":"https://api.github.com/users/HeinrichApfelmus/following{/other_user}","gists_url":"https://api.github.com/users/HeinrichApfelmus/gists{/gist_id}","starred_url":"https://api.github.com/users/HeinrichApfelmus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HeinrichApfelmus/subscriptions","organizations_url":"https://api.github.com/users/HeinrichApfelmus/orgs","repos_url":"https://api.github.com/users/HeinrichApfelmus/repos","events_url":"https://api.github.com/users/HeinrichApfelmus/events{/privacy}","received_events_url":"https://api.github.com/users/HeinrichApfelmus/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":4,"state":"open","created_at":"2015-08-30T12:14:57Z","updated_at":"2015-09-12T20:57:30Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2015-09-04T15:32:09Z","updated_at":"2015-09-12T20:57:30Z","closed_at":"2015-09-12T20:57:30Z","body":"Take the following program:\r\n\r\n```haskell\r\nimport Control.Monad\r\nimport Reactive.Banana hiding (accumB)\r\nimport Reactive.Banana.Frameworks\r\nimport Control.Concurrent (forkIO)\r\n\r\nmain :: IO ()\r\nmain =\r\n  do (keyPressAh,fireKeyPress) <- newAddHandler\r\n     (clockAh,tickClock) <- newAddHandler\r\n     network <-\r\n       compile (do keyPress <- fromAddHandler keyPressAh\r\n                   clock <- fromAddHandler clockAh\r\n                   let n =\r\n                         switchB (pure 0)\r\n                                 (observeE (fmap (const (integrate clock 0 (pure 1))) keyPress))\r\n                   reactimate (print <$> n <@ clock))\r\n     actuate network\r\n     forkIO (forever (tickClock 1))\r\n     forever (getChar >>= fireKeyPress)\r\n  where integrate dt initial x =\r\n          accumB initial ((+) <$> ((*) <$> x <@> (dt :: Event Double)))\r\n        accumB initial e =\r\n          stepper initial =<< accumE initial e\r\n```\r\n\r\nIs this program we have a clock pulse that fires repeatedly. When the user presses a key, the local clock gets reset and we start counting from 0.\r\n\r\nHowever, the above program only allows the user to reset the clock once. When a key is pressed the local clock begins increasing, but repeated key presses have no effect. The expectation would be that subsequent key presses reset the clock to 0 and begin increasing again."}}