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 containers.
And 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
It 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.
def _fetch_post(
post_id: int,
client_get: Callable[[str], MonadIO[Response]],
) -> MonadIO[_Post]:
return client_get(_URL.format(post_id)).bind_result(
safe(tap(httpx.Response.raise_for_status)),
).map(
lambda response: response.json(),
)
Passing IOResult will run this code in sync, while FutureResult will run like real async code.
To make this happen, we need HKT!
I have spent a lot of time working on the initial implementation, but still no luck.
Related:
Native blockers:
This feature is crutial before
1.0release.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 containers.
And we struggle to build useful abstractions (like
MonadIOon top ofIOandFuture, 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-containerIt can possibly work with both
IOandFuturecontainers. 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.Passing
IOResultwill run this code in sync, whileFutureResultwill run like realasynccode.To make this happen, we need HKT!
I have spent a lot of time working on the initial implementation, but still no luck.
Related:
Native blockers:
semanalandtypecheckerAPIs python/mypy#8848