question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support Higher Kinded Types

See original GitHub issue

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:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:6
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
sobolevncommented, Aug 17, 2020

@antonagestam thanks! 👍

When this will be released, I will work with mypy team! I am pretty sure that we can incorporate some parts of our API into the standard API.

0reactions
antonagestamcommented, Aug 17, 2020

@sobolevn Thanks! I’m finding it hard to find the time to get it off the ground but I’m currently making some changes to make it much more based around predicate functions which I think will make it a lot more useful and adaptable to different contexts 😃

Exciting times in the world of typed Python!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Higher-Kinded Types | Baeldung on Scala
A higher-kinded type is a type that abstracts over some type that, in turn, abstracts over another type. It's a way to generically...
Read more >
Higher-kinded types: the difference between giving up, and ...
Various languages' chapter 11 support. Here is where abstracting over type constructors, or “higher-kinded types”, comes into play.
Read more >
Kinds and Higher-Kinded Types in Haskell - Serokell
Most programming languages support these kinds of types – the most common ... So why would a language need to support higher-kinded types?...
Read more >
Rust/Haskell: Higher-Kinded Types (HKT) - GitHub Gist
A higher kinded type is a concept that reifies a type constructor as an actual type. ... Haskell has good support for higher...
Read more >
What is a higher kinded type in Scala? - Stack Overflow
The term "higher order (type constructor) polymorphism" is used to describe systems that support "higher kinded types". Share.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found