Monads for Asynchronous Behavior

Learn about combining Task and Either to handle asynchronous Tasks.

TaskEither vs. Task

TaskEither is a monad provided by fp-ts. It’s actually a monad Transformer. We already mentioned how we can stack monads on top of each other to combine their effects. That helps us understand why Either reference is there. What about Task? We haven’t seen that one before!

Task is a monad for asynchronous non-failing calls. A Promise is easily converted into a Task. Simply create a function that returns a Promise. That’s it!

Get hands-on with 1200+ tech skills courses.