-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support for higher kinded types with arbitrary type arguments. #14
Comments
(2) is fine. You can actually live with just That is you can define |
And (2) is actually more safe. It allows you to define abstraction that can disassemble type parameters all the way. (Like how |
@clinuxrulz true, but if we allow, eg. Either<A, B> implements __<__<µ, A>, B> {} then we must get ride of https://github.com/derive4j/hkt/blob/master/src/main/java/org/derive4j/hkt/__2.java#L11 and friends: static <f, A, B> __2<f, A, B> coerce(__<__<f, A>, B> fab) {
return (__2<f, A, B>) fab;
} that would then be unsafe. But maybe we are ok with removing those coerce methods...? |
I have to have more of a think about it later. I got to go to work soon. But at the moment I would argue to keep the coerce methods and that they are actually still type safe. Remember that |
Sorry. You are correct. It would mean dropping those coerce methods you mentioned. (Class cast exception) |
I would vote to drop those |
Just a thought. If we choose to stop at We could stop at |
@clinuxrulz this is also exactly what I had in mind! |
For a practical standpoint, even if we don't support arbitrary number of type parameters we should aim to support up to 62 (as it is currently the limit for haskell tuples, cf. https://hackage.haskell.org/package/ghc-prim-0.5.0.0/docs/src/GHC.Tuple.html#Unit). |
Let's assume we offer interfaces up to
__n
(currently 5, soon 9).There will be a day when someone would need to create a class with
n + x
type parameters (x >= 1).We cannot add new interface infinitely, so there must be a way to cope with this situation.
My take would be that if a class has more that 9 type parameters then the higher kinded interface will only expose the last 9 type parameters, and the first "non hkt" type parameters would need to be backed in the type constructor witness in one of the two following way:
The later encoding is more consistent with the hierarchy and eventually allow to abstract over all type parameters, but the first one may be simpler for types with lots of type parameters.
The text was updated successfully, but these errors were encountered: