-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Closed
add RFC for HKTs #134
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
|
||
# 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.