I'm using fp-ts
to fetch two data sets and then pass that to a single function (or handle errors). This function works, but I have to use .then()
or await to get it to work.
How can I make this "more functional" by using some native fp-ts
functions, so that I can have everything in one nice pipe()
function, but get the same result?
export default async function CalendarRoute() {
return pipe(
TE.Do, // Start the computation
TE.bind("events", () => getEvents),
TE.bind("route", () => getRoute("kalender")),
)().then(matchEither(renderError, ({ events, route }) => renderCalendarPage(events, route)));
}
The getter functions have return types TaskEither<Error, MyType>
.