Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve Streaming[A] and StreamingT[F[_], A].
This commit makes several changes: 1. Makes StreamingT ADT nodes final and private[cats]. 2. Provide more type class instances for StreamingT (including Eq) 3. Introduce a few new methods 4. Improve documentation substantially 5. Some minor performance improvements 6. Fix minor syntax problem. The most significant change is #1. If you expose the ADT and allow pattern-matching, then referential transparency requires that operations such as fa.flatMap(a => f(a).flatMap(g)) and fa.flatMap(f).flatMap(g) produce identical ADTs. In the case of StreamT this was not possible without dramatically bloating the number of allocations per "step" in all cases. By hiding the ADT and preventing pattern-matching (and folds over the underlying ADT structure) we can ensure that these are equivalent. The introduction of .zipMap and .izipMap are intended to make the process of combining streams via pairwise function application a bit less painful. Using these methods we can define Eq, Order, and so on without creating intermediate tuples, converting to a new data structure, etc. The minor syntax problem was a failure of OrderSyntax to extend PartialOrderSyntax; you can see similar problems anywhere there is an inheritance chain. Basically, the Ops class for a type class should only support methods directly added by that class. In other words, even if you are working with a Group[A], your |+| method should always come from SemigroupOps. This prevents ambiguities, and ensures that things work properly. This commit also fixes some minor typos, indentation problems, and removes some unused methods which were probably not necessary.
- Loading branch information