Skip to content

Instantly share code, notes, and snippets.

trait IsNotFuture[+F]
object IsNotFuture{
def apply[F](implicit isf: IsNotFuture[F]) = isf
implicit def mkFuture[A] = new IsNotFuture[Future[A]] {}
implicit object isf extends IsNotFuture[Any] {}
}
//No need for a dependent type. All you need is the implicit ambiguity.
@wheaties
wheaties / Effects
Last active December 10, 2015 19:48 — forked from anonymous/gist:4484300
An effect which can be "undone."
trait Change[+A]{
def map[B](f: A => B): Change[B]
def flatMap[B](f: A => Change[B]): Change[B]
def foreach(f: A => Unit): Unit
def filter(pred: A => Boolean): Change[A]
}
case class Reversible[+A](value: A, undo: List[Undo]) extends Change[A]{
def map[B](f: A => B) = Reversible(f(value), undo)
def flatMap[B](f: A => Change[B]) = f(value) match{