(no title)
lacampbell | 6 years ago
interface Functor<A> {
map<B>(f: (a: A) => A): Functor<A>;
}
You map over an option, you get an option. You map over an either, you get an either. etc etc.lacampbell | 6 years ago
interface Functor<A> {
map<B>(f: (a: A) => A): Functor<A>;
}
You map over an option, you get an option. You map over an either, you get an either. etc etc.
tel|6 years ago
So you end up with
where `Self` needs to recognize that the type being defined to implement this interface has a "slot". This tends to make things tough.rubyn00bie|6 years ago
lacampbell|6 years ago
I'm a very low level functional programmer. I'm big on immutability, big on not using loops and instead using map/flatMap/filter/fold, I tend to roll my own either and option implementations when they don't exist because it's the tidiest way of handling errors I've come across, etc etc. But when it comes to stuff like functors I don't get what it's buying me. What interesting stuff can I do if I know that both an option and a list can be mapped over?
I really need to look more deeply into it at some stage. I might be missing out on some powerful tools. Or it might be a bunch of stuff that's theoretically interesting but practically useless.
smegma2|6 years ago