{"action":"created","issue":{"url":"https://api.github.com/repos/slamdata/purescript-halogen/issues/246","labels_url":"https://api.github.com/repos/slamdata/purescript-halogen/issues/246/labels{/name}","comments_url":"https://api.github.com/repos/slamdata/purescript-halogen/issues/246/comments","events_url":"https://api.github.com/repos/slamdata/purescript-halogen/issues/246/events","html_url":"https://github.com/slamdata/purescript-halogen/pull/246","id":117370179,"number":246,"title":"Subscriptions","user":{"login":"garyb","id":693642,"avatar_url":"https://avatars.githubusercontent.com/u/693642?v=3","gravatar_id":"","url":"https://api.github.com/users/garyb","html_url":"https://github.com/garyb","followers_url":"https://api.github.com/users/garyb/followers","following_url":"https://api.github.com/users/garyb/following{/other_user}","gists_url":"https://api.github.com/users/garyb/gists{/gist_id}","starred_url":"https://api.github.com/users/garyb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garyb/subscriptions","organizations_url":"https://api.github.com/users/garyb/orgs","repos_url":"https://api.github.com/users/garyb/repos","events_url":"https://api.github.com/users/garyb/events{/privacy}","received_events_url":"https://api.github.com/users/garyb/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/slamdata/purescript-halogen/labels/in%20review","name":"in review","color":"fef2c0"}],"state":"open","locked":false,"assignee":{"login":"jonsterling","id":55057,"avatar_url":"https://avatars.githubusercontent.com/u/55057?v=3","gravatar_id":"","url":"https://api.github.com/users/jonsterling","html_url":"https://github.com/jonsterling","followers_url":"https://api.github.com/users/jonsterling/followers","following_url":"https://api.github.com/users/jonsterling/following{/other_user}","gists_url":"https://api.github.com/users/jonsterling/gists{/gist_id}","starred_url":"https://api.github.com/users/jonsterling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonsterling/subscriptions","organizations_url":"https://api.github.com/users/jonsterling/orgs","repos_url":"https://api.github.com/users/jonsterling/repos","events_url":"https://api.github.com/users/jonsterling/events{/privacy}","received_events_url":"https://api.github.com/users/jonsterling/received_events","type":"User","site_admin":false},"milestone":null,"comments":6,"created_at":"2015-11-17T14:52:21Z","updated_at":"2015-11-18T17:35:03Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/slamdata/purescript-halogen/pulls/246","html_url":"https://github.com/slamdata/purescript-halogen/pull/246","diff_url":"https://github.com/slamdata/purescript-halogen/pull/246.diff","patch_url":"https://github.com/slamdata/purescript-halogen/pull/246.patch"},"body":"@jonsterling Here we go again...\r\n\r\n- This time we keep the coroutine inside `EventSource`.\r\n- `EventSource` can only be constructed or deconstructed with the `MonadAff` constraint so that we know `g` can somehow deal with the inner `Aff`.\r\n- We allow hoisting of `EventSource` with a natural transformation. We don't need the `MonadAff` constraint as it's implied by the natural transformation. This allows us to change the `g` to `QueryF s s' f f' g p` when subscribing in a parent. Relying on natural transformation also means we don't need to impose a global `MonadAff` constraint throughout Halogen.\r\n- We allow \"contra-hoisting\" of `EventSource` so we can return a hoisted `EventSource` to an earlier `g`. This allows us to get our `g` back out of `QueryF`.\r\n- `g` is a phantom type for `EventSource`, so hoist/contrahoist actually do nothing at the value level. \r\n\r\nI'm pretty sure with the above rules this is all safe.\r\n\r\nIt's still a rather hacky solution really. This whole thing is to allow our `EventSource` to sail through from definition to `runUI` without having to hoist the coroutine directly, we keep the internal `Aff` so we can `forkAff` in `runUI`. The reason my first `subscribe'` blocked is this: https://github.com/slamdata/purescript-halogen/blob/75ee1641c34f555b34c4cc3165de8ee295772f67/src/Halogen/Component.purs#L330... we run the coroutine after hoisting it into `QueryF` rather than when it is `Aff`, so have no opportunity to `forkAff`. I first tried reworking this function to avoid the need for running the coroutine, but I can't see a way of doing it."},"comment":{"url":"https://api.github.com/repos/slamdata/purescript-halogen/issues/comments/157790897","html_url":"https://github.com/slamdata/purescript-halogen/pull/246#issuecomment-157790897","issue_url":"https://api.github.com/repos/slamdata/purescript-halogen/issues/246","id":157790897,"user":{"login":"garyb","id":693642,"avatar_url":"https://avatars.githubusercontent.com/u/693642?v=3","gravatar_id":"","url":"https://api.github.com/users/garyb","html_url":"https://github.com/garyb","followers_url":"https://api.github.com/users/garyb/followers","following_url":"https://api.github.com/users/garyb/following{/other_user}","gists_url":"https://api.github.com/users/garyb/gists{/gist_id}","starred_url":"https://api.github.com/users/garyb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garyb/subscriptions","organizations_url":"https://api.github.com/users/garyb/orgs","repos_url":"https://api.github.com/users/garyb/repos","events_url":"https://api.github.com/users/garyb/events{/privacy}","received_events_url":"https://api.github.com/users/garyb/received_events","type":"User","site_admin":false},"created_at":"2015-11-18T17:35:03Z","updated_at":"2015-11-18T17:35:03Z","body":"Whipped up a little something on the train that means the halt stuff is gone too - added a parameter to `HalogenF` so we can provably know we're dealing with an `EventSource` rather than a `ParentEventSource`"}}