Permalink
Browse files

Adds an unsafe Copointed instance for FutureMonad

This is just for debug & test use.
  • Loading branch information...
1 parent 780c9ba commit c50abf6642f206d192dbcfc9882bbea7dff325d6 @nuttycom nuttycom committed Mar 19, 2013
Showing with 9 additions and 1 deletion.
  1. +8 −0 bkka/src/main/scala/blueeyes/bkka/FutureMonad.scala
  2. +1 −1 version.sbt
@@ -1,7 +1,9 @@
package blueeyes.bkka
import akka.dispatch.Future
+import akka.dispatch.Promise
import akka.dispatch.ExecutionContext
+import akka.dispatch.Await
import scalaz._
@@ -11,6 +13,12 @@ class FutureMonad(context: ExecutionContext) extends Applicative[Future] with Mo
override def ap[A,B](fa: => Future[A])(ff: => Future[A => B]) = (fa zip ff) map { case (a, f) => f(a) }
}
+class UnsafeFutureComonad(context: ExecutionContext, copointMaxWait: akka.util.Duration) extends FutureMonad(context) with Comonad[Future] {
+ def copoint[A](m: Future[A]) = Await.result(m, copointMaxWait)
+ def cojoin[A](a: Future[A]): Future[Future[A]] = Promise.successful(a)(context)
+ def cobind[A, B](fa: Future[A])(f: Future[A] => B): Future[B] = Promise.successful(f(fa))(context)
+}
+
object FutureMonad {
def M(implicit context: ExecutionContext): Monad[Future] = new FutureMonad(context)
}
View
@@ -1 +1 @@
-version in ThisBuild := "1.0.0-SNAPSHOT"
+version in ThisBuild := "1.0.0-M8.1"

0 comments on commit c50abf6

Please sign in to comment.