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

add RFC for HKTs #134

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions text/0060-hkts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
- Feature Name: higher kinded types
- Start Date: 2018-11-11
- RFC PR:
- Pony Issue:

# Summary

Higher kinded types (HKTs) are a way to refer to generic types which are themselves generic.

# Motivation

By supporting HKTs, Pony code could be made more generic by defining interfaces that support HKTs instead of concrete polymorphic types. This allow for strong static functional programming using Pony.

# Detailed design

Implementation of HKTs would likely be based on the Scala implementation. An example usage in Pony may be:

```
interface Functor[F[_]]
fun map[A, B](f: {(A): B}): F[B]
```

It seems like `[_]` could reference to any `_: Any val`.

# How We Teach This

Luckily, HKTs are pretty familiar to people using functional programming and are potentially transparent to those not using it. As such, reusing terminology is possible.

The guides, especially those which discuss generic types, would need to be reworked. This should be as simple as introducing generic types which also have generic parameters.

# How We Test This

If Pony internals can be ported to use HKTs, this indicates an acceptance criteria. Inspiration can be taken from [typelevel Scala libraries](https://typelevel.org/projects/) with support for HKT.

# Drawbacks

Why should we *not* do this? Things you might want to note:

tl;dr: scary for users and maintainers

If this is accepted, it could (and perhaps should) be used throughout the implementation of Pony to write more generic code. This is risky. It also can make the code (on first blush) a bit more opaque to those not familiar with HKTs.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could there be another set of standard-lib-like modules instead? I'm thinking of scala's cats stuff; not necessarily as the one true way to go, but as a means to reduce this risk, and letting users opt into this.

Copy link
Author

@erip erip Nov 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and no, I think. If the standard lib supported HKTs, I could definitely see libraries to support more functional style things (like Cats as you mentioned). I actually opened this because I was hoping to create such a lib. The ultimate blocker is that there's no such language feature for HKTs.



# Alternatives

By not integrating HKT support, we would need to write more concrete code. More code means more bugs and more maintenance.

# Unresolved questions

None