Skip to content

Instantly share code, notes, and snippets.

@joshcough
Created July 26, 2015 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshcough/cfce120c60057a203275 to your computer and use it in GitHub Desktop.
Save joshcough/cfce120c60057a203275 to your computer and use it in GitHub Desktop.
def convert[A](str: => Stream[A]): Process[Task, Throwable \/ A] =
Process.eval((Task delay str map {
case hd #:: tail => emit(hd.right) ++ convert(tail)
case Stream.Empty => halt
}).attempt) flatMap {
case lf@ -\/(_) => emit(lf)
case \/-(p) => p
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment