Alter TailRec to have map and flatMap

As described in the "Stackless Scala with Free Monads" paper

scala> import scala.util.control.TailCalls._
import scala.util.control.TailCalls._

scala> :paste
// Entering paste mode (ctrl-D to finish)

def isEven(xs: List[Int]): TailRec[Boolean] =
  if (xs.isEmpty) done(true) else tailcall(isOdd(xs.tail))

def isOdd(xs: List[Int]): TailRec[Boolean] =
  if (xs.isEmpty) done(false) else tailcall(isEven(xs.tail))

// Exiting paste mode, now interpreting.

isEven: (xs: List[Int])util.control.TailCalls.TailRec[Boolean]
isOdd: (xs: List[Int])util.control.TailCalls.TailRec[Boolean]

scala> isEven((1 to 100000).toList).result
res0: Boolean = true

scala> def fib(n: Int): TailRec[Int] =
     |   if (n < 2) done(n) else for {
     |     x <- tailcall(fib(n - 1))
     |     y <- tailcall(fib(n - 2))
     |   } yield (x + y)
fib: (n: Int)util.control.TailCalls.TailRec[Int]

scala> fib(40).result
res1: Int = 102334155
Stackless implementation of TailRec in constant memory.
Merge pull request #2865 from folone/trampolines

Alter TailRec to have map and flatMap