Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prenex parametric polymorphism, a.k.a. generics #812

Open
anton-trunov opened this issue Sep 12, 2024 · 0 comments
Open

Prenex parametric polymorphism, a.k.a. generics #812

anton-trunov opened this issue Sep 12, 2024 · 0 comments

Comments

@anton-trunov
Copy link
Member

This would allow user-defined data types that include general operations on maps, like the map with the O(1) length operation, see #471 or the implementation of emptyMap can be moved to the standard library.

inline fun emptyMap<K, V>(): map<K, V> { return null }

Since key and value map types are strict subsets of all types, the right way to do it would be using bounded polymorphism, but at first we can just throw type errors at the time of instantiation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant