/**
* Constructs a layer dynamically based on the output of this layer.
*
* @tsplus static effect/core/io/Layer.Aspects flatMap
* @tsplus pipeable effect/core/io/Layer flatMap
*/
export function flatMap(f: (a: Env) => Layer) {
return (self: Layer): Layer =>
self.foldLayer(
(e) => Layer.fail(e),
f
)
}