Search⌘ K

Solution Review: Working with TaskEither

Explore how to work with the TaskEither monad in fp-ts to manage errors in asynchronous operations. Understand the step-by-step process of using functions like checkInput, externalService, and errorMapper to handle successes and failures effectively in TypeScript. This lesson helps you apply functional programming techniques for robust application deployment and monitoring.

We'll cover the following...

Solution

TypeScript 3.3.4
const application = (input: string) => {
return pipe(
checkInput(input),
TE.fromEither,
TE.chain((input: string) => TE.tryCatch(() => externalService(input), errorMapper)),
TE.map(toUpperCase),
TE.getOrElse((err) => T.of(`We got back an error: ${err}`))
)();
};

Explanation

Here’s a line-by-line explanation of the solution above:

  • Line 1
...