My goal is to request transactions from an API and store them to a database. The response is paginated and I want to read every page and store the transactions in batches.
So for one request/response cycle I wish to then process the result and store it to the database before fetching the next batch.
How do I do this in an idiomatic way in fp-ts? I inject the actual HTTP fetch call as (url:string, init:RequestInit) => TE.TaskEither<Error, Response>
in order to keep it testable.
So far I've tested RxJS and fp-ts and that got a bit complicated even if I got it to work.
Did give both recursive function and generators a try but I'm not succeeding in getting it to be lazily evaluated.
Are there any existing examples with fp-ts that shows a lazily evaluated stream where each element is dependent on the previous?