Besides lazy execution, are Tasks and Promises pretty much the same thing? When I refer to a task, I refer to a class that is in its most basic behavior like the following:
class Task {
constructor(then) {
this.then = then;
}
map(mapper) {
return new Task((resolve, reject) => this.then(
x => resolve(mapper(x)),
reject
))
}
flatMap(mapper) {
return new Task((resolve, reject) => this.then(
x => mapper(x).then(resolve, reject),
reject
))
}
}
What type of (class?) is a task/promise? I'm learning about functional programming approaches, but I don't think I've gotten to this type yet. Is it a type of monad?