{"action":"created","issue":{"url":"https://api.github.com/repos/polysemy-research/polysemy-zoo/issues/34","repository_url":"https://api.github.com/repos/polysemy-research/polysemy-zoo","labels_url":"https://api.github.com/repos/polysemy-research/polysemy-zoo/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/polysemy-research/polysemy-zoo/issues/34/comments","events_url":"https://api.github.com/repos/polysemy-research/polysemy-zoo/issues/34/events","html_url":"https://github.com/polysemy-research/polysemy-zoo/pull/34","id":464718693,"node_id":"MDExOlB1bGxSZXF1ZXN0Mjk0OTM5Mjcx","number":34,"title":"Continuation Effects","user":{"login":"KingoftheHomeless","id":25914237,"node_id":"MDQ6VXNlcjI1OTE0MjM3","avatar_url":"https://avatars1.githubusercontent.com/u/25914237?v=4","gravatar_id":"","url":"https://api.github.com/users/KingoftheHomeless","html_url":"https://github.com/KingoftheHomeless","followers_url":"https://api.github.com/users/KingoftheHomeless/followers","following_url":"https://api.github.com/users/KingoftheHomeless/following{/other_user}","gists_url":"https://api.github.com/users/KingoftheHomeless/gists{/gist_id}","starred_url":"https://api.github.com/users/KingoftheHomeless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KingoftheHomeless/subscriptions","organizations_url":"https://api.github.com/users/KingoftheHomeless/orgs","repos_url":"https://api.github.com/users/KingoftheHomeless/repos","events_url":"https://api.github.com/users/KingoftheHomeless/events{/privacy}","received_events_url":"https://api.github.com/users/KingoftheHomeless/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":29,"created_at":"2019-07-05T17:09:36Z","updated_at":"2019-07-06T18:02:18Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/polysemy-research/polysemy-zoo/pulls/34","html_url":"https://github.com/polysemy-research/polysemy-zoo/pull/34","diff_url":"https://github.com/polysemy-research/polysemy-zoo/pull/34.diff","patch_url":"https://github.com/polysemy-research/polysemy-zoo/pull/34.patch"},"body":"This adds the effects `Cont` and `Shift`, for abortive and delimited continuations respectively.\r\n\r\nThese effects work by being parametrized by `s` and `m`, where `s` is the final result type, and `m` is the final monad type.\r\nPolymorphic code with these effects are intended to be polymorphic in `m`, and may choose to be polymorphic in `s`. This way, you can get the traditional `callCC`/`shift`/`reset` operations. If you specialize `s`, you also get access to `abort`, which lets you end a computation early.\r\n\r\nUnfortunately, the interpreters for these are wonky. The only way to transform\r\n `Union r (Sem (Cont s m ': r)) x`  to `Sem r x` is to \"replace\" any higher-order use of values of type `Sem (Cont s m ': r)` within the union with a _pure_ value of `Sem r`. The effect of this is that any continuation you get with `callCC`/`shift` is unaffected by higher-order operations such as `local` and `censor`, and `listen` on a continuation will just return `mempty`.\r\n\r\nStill, it's pretty neat that this is at all even possible, considering `ContT` is not a functor on monads."},"comment":{"url":"https://api.github.com/repos/polysemy-research/polysemy-zoo/issues/comments/508944022","html_url":"https://github.com/polysemy-research/polysemy-zoo/pull/34#issuecomment-508944022","issue_url":"https://api.github.com/repos/polysemy-research/polysemy-zoo/issues/34","id":508944022,"node_id":"MDEyOklzc3VlQ29tbWVudDUwODk0NDAyMg==","user":{"login":"KingoftheHomeless","id":25914237,"node_id":"MDQ6VXNlcjI1OTE0MjM3","avatar_url":"https://avatars1.githubusercontent.com/u/25914237?v=4","gravatar_id":"","url":"https://api.github.com/users/KingoftheHomeless","html_url":"https://github.com/KingoftheHomeless","followers_url":"https://api.github.com/users/KingoftheHomeless/followers","following_url":"https://api.github.com/users/KingoftheHomeless/following{/other_user}","gists_url":"https://api.github.com/users/KingoftheHomeless/gists{/gist_id}","starred_url":"https://api.github.com/users/KingoftheHomeless/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KingoftheHomeless/subscriptions","organizations_url":"https://api.github.com/users/KingoftheHomeless/orgs","repos_url":"https://api.github.com/users/KingoftheHomeless/repos","events_url":"https://api.github.com/users/KingoftheHomeless/events{/privacy}","received_events_url":"https://api.github.com/users/KingoftheHomeless/received_events","type":"User","site_admin":false},"created_at":"2019-07-06T18:02:18Z","updated_at":"2019-07-06T18:02:18Z","author_association":"NONE","body":"Oh, there's actually a much easier solution!\r\n```\r\nrunM' :: Monad m => Sem [Lift' m, Lift m] a -> m a\r\nrunM' (Sem m) = m $ \\u -> case decomp u of\r\n  Right (Yo (WithWeaving wav) s wv ex ins) -> ex <$> wav s (runLift' . wv) ins\r\n  Left g -> case extract g of\r\n    Yo (Lift m) s wv ex ins -> fmap (ex . (<$ s)) m\r\n```\r\nThis way, everything works out. `withWeaving` relies on the `Lift' m` constraint, `Lift` isn't replaced, so `runIO` and `runEmbedded` still work. Plus, things that rely on `LastMember (Lift IO)` still work.\r\n\r\nMy opinion is that we give `Lift'` a better, catchier name, and then add it to polysemy."}}
{"actor":{"display_login":"KingoftheHomeless"}}