DEV Community

Discussion on: Data fetching in React the functional way powered by TypeScript, io-ts & fp-ts

Collapse
austindd profile image
Austin

First of all I really like this write-up. It demonstrates a very useful functional programming pattern! But did notice that instead of using fold to transform the Either<Errors, T> into Either<Error, T>, you could use mapLeft. I doubt it would ever matter in practice, since this is not a tight loop, but mapLeft is more efficient since it doesn't construct a second Right value every time it succeeds. Other than that (and the fact that the code is now out of date with the library API), this is super good!