milibopp/carboxyl

Implement coalesce

Closed this issue · 0 comments

From the Sodium docs:

coalesce :: (a -> a -> a) -> Event r a -> Event r a

If there's more than one firing in a single transaction, combine them into one using the specified combining function.

If the event firings are ordered, then the first will appear at the left input of the combining function. In most common cases it's best not to make any assumptions about the ordering, and the combining function would ideally be commutative.

That would translate into Rust as a method of Stream<A>:

fn coalesce<F: Fn(A, A) -> A>(&self, f: F) -> Stream<A>;