contraMap
Generates a new sink of type T2.
Given a transform closure, the following code is functionally equivalent:
sink.send(transform(value))
sink.contraMap(transform).send(value)
Content copied to clipboard
Trivia: Why is this called contraMap
? - map
turns Type<T>
into Type<U>
via (T)->U
. - contraMap
turns Type<T>
into Type<U>
via (U)->T
Another way to think about this is: map
transforms a type by changing the output types of its API, while contraMap
transforms a type by changing the input types of its API.