You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all, i'm really sorry to ask questions in issues tab. I'll be sure to remove this post as soon as i get an answer.
I'm a java web developer who is serious about learning functional programming, with hopes to one day apply it in production level codes.
I've been trying really hard to figure out how lambda library works, but i can't figure out what "unification parameter" is in the library is supposed to be, or what it is for.
The bit of code i am referring to:
* @param <A> The type of the parameter
* @param <F> The unification parameter
...
@FunctionalInterface
public interface Functor<A, F extends Functor<?, F>> {
...
I've been unable to figure this out with regular google search, but i am guessing that this is some sort of compiler trick to enforce strict compile time type checks.
Any explanation or any directions to where i should be looking would be greatly appreciated.
Thank you very much.
The text was updated successfully, but these errors were encountered:
The parameter F is meant to be used as a recursively bound type parameter similar to T in Comparable<T> where Integer implements Comparable<Integer>. In this case it's the type that's actually implementing the functor interface so for example with Maybe:
publicabstractclassMaybe<T> implementsFunctor<T, Maybe<?>> {
// Implementation here
}
The "unification parameter" is necessary to have a sensible return type for the fmap method on Functor. We want fmap to return a Maybe when called and not some other type of a functor. So on the interface it has:
And in the case of MaybeF is Maybe so you can return a Maybe<B>. Please let me know if any of that doesn't make sense or if you have any other questions. Also, feel free to join the discord channel linked in the readme.
First of all, i'm really sorry to ask questions in issues tab. I'll be sure to remove this post as soon as i get an answer.
I'm a java web developer who is serious about learning functional programming, with hopes to one day apply it in production level codes.
I've been trying really hard to figure out how lambda library works, but i can't figure out what "unification parameter" is in the library is supposed to be, or what it is for.
The bit of code i am referring to:
I've been unable to figure this out with regular google search, but i am guessing that this is some sort of compiler trick to enforce strict compile time type checks.
Any explanation or any directions to where i should be looking would be greatly appreciated.
Thank you very much.
The text was updated successfully, but these errors were encountered: