Skip to content

Commit

Permalink
add map
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Ritchie committed Feb 14, 2013
1 parent 8e38487 commit 7dfd9d8
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import com.twitter.util.{ Future, Return, Try }

object UtilAlgebras {
implicit val futureMonad: Monad[Future] = new Monad[Future] {
def apply[T](v: T) = Future.value(v);
def apply[T](v: T) = Future.value(v)
override def map[T, U](m: Future[T])(fn: T => U) = m.map(fn)
def flatMap[T, U](m: Future[T])(fn: T => Future[U]) = m.flatMap(fn)
}
implicit val tryMonad: Monad[Try] = new Monad[Try] {
def apply[T](v: T) = Return(v);
def apply[T](v: T) = Return(v)
override def map[T, U](m: Try[T])(fn: T => U) = m.map(fn)
def flatMap[T,U](m: Try[T])(fn: T => Try[U]) = m.flatMap(fn)
}

Expand Down

0 comments on commit 7dfd9d8

Please sign in to comment.