René's URL Explorer Experiment


Title: Extendable typed functions · Issue #447 · dry-python/returns · GitHub

Open Graph Title: Extendable typed functions · Issue #447 · dry-python/returns

X Title: Extendable typed functions · Issue #447 · dry-python/returns

Description: Ok, here's the deal. We need to somehow make our pointfree and other helper functions trully generic. Currently we have a hardcoded set of containers that each of these functions support. It is not a scallable solution. Let's say I want ...

Open Graph Description: Ok, here's the deal. We need to somehow make our pointfree and other helper functions trully generic. Currently we have a hardcoded set of containers that each of these functions support. It is not...

X Description: Ok, here's the deal. We need to somehow make our pointfree and other helper functions trully generic. Currently we have a hardcoded set of containers that each of these functions support. It is...

Opengraph URL: https://github.com/dry-python/returns/issues/447

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Extendable typed functions","articleBody":"Ok, here's the deal.\r\n\r\nWe need to somehow make our pointfree and other helper functions trully generic.\r\nCurrently we have a hardcoded set of containers that each of these functions support.\r\n\r\nIt is not a scallable solution. \r\n\r\nLet's say I want to create a new monad called `Example[T] extends Monad[T]`.\r\n\r\nHere's what I need to do:\r\n\r\n```python\r\nfrom typing import Callable, Generic, TypeVar\r\nfrom returns.typeclasses.monad import Monad\r\nfrom returns.hkt import Kind\r\n\r\nT = TypeVar('T')\r\nN = TypeVar('N')\r\n\r\nclass Example(Kind['Example', T], Generic[T], Monad[T]):\r\n    def bind(self, function: Callable[[T], Kind['Example', N]]) -> 'Example[N]':\r\n         ...\r\n```\r\n\r\nIt works just fine! Now, what about using `bind()` pointfree function? It will work in runtime, but fail during the type-checking.\r\nBecause it is defined using `overload`s and is hardcoded.\r\n\r\nThe problem is that HKT functions are not supported. And possibly won't be supported anytime soon (unless `get_function_sig_hook` will be released).\r\n\r\nI suggest to rewrite it as follows (let's start with the contract definition):\r\n\r\n```python\r\nK = TypeVar(K, bound=Monad)\r\n\r\n@contract\r\ndef bind(instance: Monad[T], function: Callable[[T], Monad[N]]) -> Monad[N]:\r\n     return instance.bind(function)\r\n```\r\n\r\nAnd then add a special case for our existing containers:\r\n\r\n```python\r\nfrom returns.pointfree import bind\r\n\r\n@bind.negotiate\r\ndef bind_maybe(instance: Maybe[T], function: Callable[[T], Maybe[N]]) -> Maybe[N]:\r\n    \"\"\"Case for Maybe.\"\"\"\r\n\r\n@bind.negotiate\r\ndef bind_example(instance: Example[T], function: Callable[[T], Example[N]]) -> Example[N]:\r\n    \"\"\"Case for Example.\"\"\"\r\n```\r\n\r\nThis way we would provide:\r\n1. Default implementation for types we own\r\n2. Ability to add your own types and extend the typing of existing things","author":{"url":"https://github.com/sobolevn","@type":"Person","name":"sobolevn"},"datePublished":"2020-07-05T16:22:13Z","url":"https://github.com/dry-python/returns/issues/447"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:16ba16be-543c-6773-06b3-cd528dbf296e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC7CE:3E4AC7:28CC76D:376E7C2:6B004571
html-safe-nonce0b43d8f1ab4e74c32a6caee60877b4646f15fb4cfa13875a74a75df011fb8c33
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDN0NFOjNFNEFDNzoyOENDNzZEOjM3NkU3QzI6NkIwMDQ1NzEiLCJ2aXNpdG9yX2lkIjoiNDYzMTgwNDU0ODk4MDE2Mzk1MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac56f375b70addd3fb6ed5519a4f4436d4af50bc55e6c752211b6393843cbd0f24
hovercard-subject-tagissue:651100051
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/dry-python/returns/447/issue_layout
twitter:imagehttps://opengraph.githubassets.com/502cef1b2ebcbfde68684819c2401e44f11f5ceca509b968c4cf6a41f3e56c18/dry-python/returns/issues/447
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/502cef1b2ebcbfde68684819c2401e44f11f5ceca509b968c4cf6a41f3e56c18/dry-python/returns/issues/447
og:image:altOk, here's the deal. We need to somehow make our pointfree and other helper functions trully generic. Currently we have a hardcoded set of containers that each of these functions support. It is not...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesobolevn
hostnamegithub.com
expected-hostnamegithub.com
None7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0
turbo-cache-controlno-preview
go-importgithub.com/dry-python/returns git https://github.com/dry-python/returns.git
octolytics-dimension-user_id37993755
octolytics-dimension-user_logindry-python
octolytics-dimension-repository_id167689891
octolytics-dimension-repository_nwodry-python/returns
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id167689891
octolytics-dimension-repository_network_root_nwodry-python/returns
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef3f3a43ca095cdea3abbb394112e971f9fdb94fa
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/dry-python/returns/issues/447#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fdry-python%2Freturns%2Fissues%2F447
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fdry-python%2Freturns%2Fissues%2F447
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=dry-python%2Freturns
Reloadhttps://github.com/dry-python/returns/issues/447
Reloadhttps://github.com/dry-python/returns/issues/447
Reloadhttps://github.com/dry-python/returns/issues/447
dry-pythonhttps://github.com/dry-python
returnshttps://github.com/dry-python/returns
Codehttps://github.com/dry-python/returns
Issues66 (66)https://github.com/dry-python/returns/issues
Pull requests11 (11)https://github.com/dry-python/returns/pulls
Actionshttps://github.com/dry-python/returns/actions
Security and qualityhttps://github.com/dry-python/returns/security
Insightshttps://github.com/dry-python/returns/insights
https://github.com/dry-python/returns
New issuehttps://github.com/login?return_to=https://github.com/dry-python/returns/issues/447
New issuehttps://github.com/login?return_to=https://github.com/dry-python/returns/issues/447
Extendable typed functionshttps://github.com/dry-python/returns/issues/447#top
enhancementNew feature or requesthttps://github.com/dry-python/returns/issues?q=state%3Aopen%20label%3A%22enhancement%22
https://github.com/sobolevn
sobolevnhttps://github.com/sobolevn
on Jul 5, 2020https://github.com/dry-python/returns/issues/447#issue-651100051
sobolevnhttps://github.com/sobolevn
enhancementNew feature or requesthttps://github.com/dry-python/returns/issues?q=state%3Aopen%20label%3A%22enhancement%22
on Jul 5, 2020https://github.com/dry-python/returns/issues/447#event-3513463869
https://github.com/sobolevn
sobolevnhttps://github.com/sobolevn
on Jul 5, 2020https://github.com/dry-python/returns/issues/447#issuecomment-653908677
#446https://github.com/dry-python/returns/pull/446
#408https://github.com/dry-python/returns/issues/408
https://github.com/sobolevn
sobolevnhttps://github.com/sobolevn
on Jul 12, 2020https://github.com/dry-python/returns/issues/447#issuecomment-657227274
#446https://github.com/dry-python/returns/pull/446
sobolevnhttps://github.com/sobolevn
completedhttps://github.com/dry-python/returns/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Jul 12, 2020https://github.com/dry-python/returns/issues/447#event-3537140263
Sign up for freehttps://github.com/signup?return_to=https://github.com/dry-python/returns/issues/447
Sign in to commenthttps://github.com/login?return_to=https://github.com/dry-python/returns/issues/447
enhancementNew feature or requesthttps://github.com/dry-python/returns/issues?q=state%3Aopen%20label%3A%22enhancement%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.