DEV Community

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

Collapse
 
davidchase profile image
David Chase

Neat write up, have you thought about using Free or Tagless ? something along the lines of writing the program without committing to a specific type until you write the program's interpreter. Essentially you could have used any mechanism of fetching that could be a Future/Task etc and would compose with the other types you already provided from fp-ts.

Collapse
 
remojansen profile image
Remo H. Jansen

No, I didn't think about Free or Tagless but I will take a look. Thanks for the suggestion!

I've been thinking that better than Promise<Either<Error>, T> I could use TaskEither:

TaskEither<L, A> represents an asynchronous computation that either yields a value of type A or fails yielding an
error of type L.