/** * @tsplus static effect/core/stream/Channel.Aspects contramap * @tsplus pipeable effect/core/stream/Channel.Aspects contramap */ export function contramap(f: (a: InDone0) => InDone) { return ( self: Channel ): Channel => contramapReader(f) >> self } function contramapReader( f: (a: InDone0) => InDone ): Channel { return Channel.readWith( (inElem: InElem) => Channel.write(inElem) .flatMap(() => contramapReader(f)), (inErr: InErr) => Channel.fail(inErr), (done: InDone0) => Channel.sync(f(done)) ) }