IssueRaiser

Higher-Kinded TypeVars

aka type constructors, generic TypeVars Has there already been discussion about those? I do a lot of FP that results in impossible situations because of this. Consider an example: ```python A = TypeVar('A') B = TypeVar('B') F = TypeVar('F') class M(Generic[F[X], A]): def x(fa: F[A], f: Callable[[A], B]) -> F[B]: return map(f, fa) M().x([1], str) ``` I haven't found a way to make this work, does anyone know a trick or is it impossible? If not, consider the syntax as a proposal. Reference implementations would be Haskell, Scala. optimally, the HK's type param would be indexable as well, allowing for `F[X[X, X], X[X]]` ---- Summary of current status (by @smheidrich, 2024-02-08): - @JelleZijlstra [has indicated interest](https://github.com/python/typing/issues/548#issuecomment-1193345123) in sponsoring a PEP, conditional on a prototype implementation in a major type checker and a well-specified draft PEP. - Drafting the PEP takes place in @nekitdev's [fork](https://github.com/nekitdev/peps) of the `peps` repo. The [**stub PEP draft**](https://github.com/nekitdev/peps/blob/main/pep-9999.rst) so far contains a few examples of the proposed syntax. - That same repo's [**GitHub Discussions forum**](https://github.com/nekitdev/peps/discussions) forum has been [designated](https://github.com/python/typing/issues/548#issuecomment-1193348994) as the place to discuss the PEP (and presumably the prototype implementation?). Some limited further discussions have taken plac

Posted by tek on Mar 30, 2018, 10:56 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.4,000 issues0 comments

github (Software)

Higher-Kinded TypeVars

tekMar 30, 2018, 10:56 PM

aka type constructors, generic TypeVars Has there already been discussion about those? I do a lot of FP that results in impossible situations because of this. Consider an example: ```python A = TypeVar('A') B = TypeVar('B') F = TypeVar('F') class M(Generic[F[X], A]): def x(fa: F[A], f: Callable[[A], B]) -> F[B]: return map(f, fa) M().x([1], str) ``` I haven't found a way to make this work, does anyone know a trick or is it impossible? If not, consider the syntax as a proposal. Reference implementations would be Haskell, Scala. optimally, the HK's type param would be indexable as well, allowing for `F[X[X, X], X[X]]` ---- Summary of current status (by @smheidrich, 2024-02-08): - @JelleZijlstra [has indicated interest](https://github.com/python/typing/issues/548#issuecomment-1193345123) in sponsoring a PEP, conditional on a prototype implementation in a major type checker and a well-specified draft PEP. - Drafting the PEP takes place in @nekitdev's [fork](https://github.com/nekitdev/peps) of the `peps` repo. The [**stub PEP draft**](https://github.com/nekitdev/peps/blob/main/pep-9999.rst) so far contains a few examples of the proposed syntax. - That same repo's [**GitHub Discussions forum**](https://github.com/nekitdev/peps/discussions) forum has been [designated](https://github.com/python/typing/issues/548#issuecomment-1193348994) as the place to discuss the PEP (and presumably the prototype implementation?). Some limited further discussions have taken plac

Comments (0)

No comments yet. Start the discussion.

Comment on this issue