Skip to content

Instantly share code, notes, and snippets.

@joescii
Created July 13, 2016 20:30
Show Gist options
  • Save joescii/e120d2deba31993ebaf8bac8751b6206 to your computer and use it in GitHub Desktop.
Save joescii/e120d2deba31993ebaf8bac8751b6206 to your computer and use it in GitHub Desktop.
mergeSorted for the same type of Process
def mergeSorted[F[_], I, A: Order](sourceLeft: Process[F, I], sourceRight: Process[F, I])(f: I => A): Process[F, I] = {
mergeSorted(sourceLeft, f)(sourceRight, f).flatMap {
case Both(a, b) => Process.emit(a) ++ Process.emit(b)
case This(a) => Process.emit(a)
case That(b) => Process.emit(b)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment