Comment

Comment by tel

That gets closer to the problem, but the solution is further away. You don't want to return "Functor" (which is like a vtable, the interface itself) but instead the thing itself which is implementing the Functor interface.

So you end up with

    interface Functor<A> {
        map<B>(f: (a: A) => A): Self<B>
    }
where `Self` needs to recognize that the type being defined to implement this interface has a "slot". This tends to make things tough.
parent tel 7 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton