In object oriented languages supporting inheritance, a StreamSink
is a Stream
, so when Map
is called on the StreamSink
, it is implicitly converted to a Stream
at the call site before being mapped.
We could make this more functional by not inheriting and forcing a call to AsStream()
to convert the StreamSink
into a Stream
manually before mapping it, but as Stephen has often pointed out, he is fine with small differences in the API to account for the idioms of each language. In object oriented languages, developers are used to these implicit conversions which are possible due to inheritance. For example, in C#, pretty much any developer who has used LINQ will have written code using the Select
method on an object which implements IEnumerable<T>
(such as a List<T>
), but gets back an IEnumerable<T>
result. (In LINQ, Select
is the mapping function.)