4 ms·
This is interesting stuff. I'm trying to figure out how to refer to flatMap directly from the abstract function, e.g. flatMapTwice(x, fun) { retur
by mrkeen 6y ago
This is interesting stuff.
I'm trying to figure out how to refer to flatMap directly from the abstract function, e.g.
flatMapTwice(x, fun) {
return x.flatMap(fun).flatMap(fun);
}
or
chain(x, fun1, fun2) {
return x.flatMap(fun1).flatMap(fun2);
}
It should also preserve the type information (just like you did above). I don't want the caller to need to downcast from FlatMappable.
It doesn't need to be x.flatMap(f) - I'd be interested seeing a flatMap(x, f) version.