Title: Support Higher Kinded Types · Issue #408 · dry-python/returns · GitHub
Open Graph Title: Support Higher Kinded Types · Issue #408 · dry-python/returns
X Title: Support Higher Kinded Types · Issue #408 · dry-python/returns
Description: This feature is crutial before 1.0 release. Currently, our interfaces are not universal. Many functions and methods do require to explicitly annotate all containers that they can work with. As a result users cannot create their own conta...
Open Graph Description: This feature is crutial before 1.0 release. Currently, our interfaces are not universal. Many functions and methods do require to explicitly annotate all containers that they can work with. As a re...
X Description: This feature is crutial before 1.0 release. Currently, our interfaces are not universal. Many functions and methods do require to explicitly annotate all containers that they can work with. As a re...
Opengraph URL: https://github.com/dry-python/returns/issues/408
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support Higher Kinded Types","articleBody":"This feature is crutial before `1.0` release.\r\n\r\nCurrently, our interfaces are not universal. Many functions and methods do require to explicitly annotate all containers that they can work with. As a result users cannot create their own containers. \r\n\r\nAnd we struggle to build useful abstractions (like `MonadIO` on top of `IO` and `Future`, see https://github.com/gcanti/fp-ts/blob/master/src/MonadIO.ts). Let's see this example: https://returns.readthedocs.io/en/latest/pages/context.html#requirescontextfutureresult-container\r\n\r\nIt can possibly work with both `IO` and `Future` containers. In the first case, it would be sync. But, in the second one it would be async. And the source code won't be changed at all! We would only need to substitute our monad stack. \r\n\r\n```python\r\ndef _fetch_post(\r\n post_id: int,\r\n client_get: Callable[[str], MonadIO[Response]],\r\n ) -> MonadIO[_Post]:\r\n return client_get(_URL.format(post_id)).bind_result(\r\n safe(tap(httpx.Response.raise_for_status)),\r\n ).map(\r\n lambda response: response.json(),\r\n )\r\n```\r\n\r\nPassing `IOResult` will run this code in sync, while `FutureResult` will run like real `async` code.\r\n\r\nTo make this happen, we need HKT!\r\nI have spent a lot of time working on the initial implementation, but still no luck.\r\n\r\nRelated:\r\n- Lightweight higher-kinded polymorphism: https://www.cl.cam.ac.uk/~jdy22/papers/lightweight-higher-kinded-polymorphism.pdf\r\n- Swift: https://bow-swift.io/docs/fp-concepts/higher-kinded-types/\r\n- TypeScript: https://github.com/gcanti/fp-ts/blob/master/docs/guides/HKT.md\r\n\r\nNative blockers:\r\n\r\n- https://github.com/python/typing/issues/548\r\n- https://github.com/python/mypy/issues/8848","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2020-06-07T10:49:05Z","url":"https://github.com/dry-python/returns/issues/408"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e1f9a5ca-f1ed-010f-0e6d-4e8a74d7b67b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D238:3AC034:B724C4:F695F0:6B004DD4 |
| html-safe-nonce | 18df0eb74c6817a823a0361253960b4c145d4243e5dc63dfc55096c26f23c899 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjM4OjNBQzAzNDpCNzI0QzQ6RjY5NUYwOjZCMDA0REQ0IiwidmlzaXRvcl9pZCI6IjIyNzE1OTAxOTE1NTY3NDI2MTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | e39119270ee909fb794609e27916eea8f76d706890e0f1cdd167f8a0baa8e773 |
| hovercard-subject-tag | issue:633295571 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/dry-python/returns/408/issue_layout |
| twitter:image | https://opengraph.githubassets.com/631ef638f153355d0b9c215a7fed8cb853b0ed65987e1bc30ee63d7925e69099/dry-python/returns/issues/408 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/631ef638f153355d0b9c215a7fed8cb853b0ed65987e1bc30ee63d7925e69099/dry-python/returns/issues/408 |
| og:image:alt | This feature is crutial before 1.0 release. Currently, our interfaces are not universal. Many functions and methods do require to explicitly annotate all containers that they can work with. As a re... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sobolevn |
| hostname | github.com |
| expected-hostname | github.com |
| None | f9517bf360d46638a1e5e7daee7158842fe5ef43c9000afa0e127564a7c2f39b |
| turbo-cache-control | no-preview |
| go-import | github.com/dry-python/returns git https://github.com/dry-python/returns.git |
| octolytics-dimension-user_id | 37993755 |
| octolytics-dimension-user_login | dry-python |
| octolytics-dimension-repository_id | 167689891 |
| octolytics-dimension-repository_nwo | dry-python/returns |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 167689891 |
| octolytics-dimension-repository_network_root_nwo | dry-python/returns |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b27c5dde30676028abd5c5fc53ce5c9b625f8281 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width