3 ms·
Yeah, Promise really helps illustrating these concepts. Also while being less explicit in the syntax, the combination of Promise and Promise.then forms a functo
by pgorczak 5y ago
Yeah, Promise really helps illustrating these concepts. Also while being less explicit in the syntax, the combination of Promise and Promise.then forms a functor that
- maps type x to type Promise<x>
- maps function x -> y to function Promise<x> -> Promise<y>
- frogulis 5y agoOh hmm, that raises a good point. I guess the types I provided in my comment are actually for `then` as `map`, not as `bind`, oops. Both of these exist: `Promise<T1>.then(T1 => Promise<T2>): Promise<T2> // equivalent to bind` `Promise<T1>.then(T1 => T2): Promise<T2> // equivalent to map`