These are chat archives for akkadotnet/AkkaStreams

30th
Jun 2016
Marc Piechura
@marcpiechura
Jun 30 2016 08:56
@Danthar regarding to the last point Extending Flow Combinators with Custom OperatorsI think we have the same problem, as I understand it they mean you can't write one extension method to rule them all and that applies in .Net too. Flow, Source, Sink and SubFlow all implement IFlow<TOut, TMat> but Flow and SubFlow have additional type parameter so what we do internally is, we have InteralFlowOperations which contains extension methods for IFlow and then we cast the result back to the actual type like so return (Flow<TIn, TOut, TMat>)InternalFlowOperations.Where(flow, predicate);
@Horusiath @cconstantin maybe you could verify that I don't miss something, it's about that part
Advanced Scala users may wonder whether it is possible to write extension methods that enrich FlowOps to allow nicer syntax. The short answer is that Scala 2 does not support this in a fully generic fashion, the problem is that it is impossible to abstract over the kind of stream that is being extended because Source, Flow and SubFlow differ in the number and kind of their type parameters. While it would be possible to write an implicit class that enriches them generically, this class would require explicit instantiation with all type parameters due to SI-2712. For a partial workaround that unifies extensions to Source and Flow see this sketch by R. Kuhn.