Slide 81
Slide 81 text
Example
import {
TaskEither, tryCatch, taskEither, fromLeft
} from "fp-ts/lib/TaskEither";
function validate(user: User): TaskEither {
tryCatch(() => fetch("/myApi/validateUser", {
method: "POST", body: JSON.stringify(user)
})
).chain(response => {
return reponse.ok ?
taskEither.of(user) :
fromLeft("User is invalid");
});
}