/** * @tsplus static effect/core/stream/Channel.Aspects contramapIn * @tsplus pipeable effect/core/stream/Channel contramapIn */ export function contramapIn(f: (a: InElem0) => InElem) { return ( self: Channel ): Channel => contramapInReader(f) >> self } function contramapInReader( f: (a: InElem0) => InElem ): Channel { return Channel.readWith( (inElem) => Channel.write(f(inElem)) .flatMap(() => contramapInReader(f)), (inErr) => Channel.fail(inErr), (inDone) => Channel.succeed(inDone) ) }