Skip to content

Instantly share code, notes, and snippets.

View davidpeklak's full-sized avatar

David Peklak davidpeklak

  • Winterthur, Switzerland
View GitHub Profile
import scala.util.control.Exception
import scalaz._
import scalaz.Free.FreeC
import scalaz.Scalaz._
object Kasten {
/////////////////////////
// The State stuff
/////////////////////////
import scala.annotation.tailrec
object MyIo2 {
sealed trait IO[+A] {
def flatMap[B](f: A => IO[B]): IO[B] = this match {
case FlatMap(x, g) => FlatMap(x, (a: Any) => g(a).flatMap(f))
case x => FlatMap(x, f)
}
@davidpeklak
davidpeklak / MatchTee
Last active August 29, 2015 13:56
scalaz stream matchTee
import scalaz.concurrent.Task
import scalaz.stream._
import scalaz.stream.Process._
import scalaz.stream.Process.Emit
import scalaz.stream.Tee
object MatchTee {
def matchTee[I: Ordering]: Tee[I, I, (Option[I], Option[I])] = {
val ord = implicitly[Ordering[I]]