Skip to content

Instantly share code, notes, and snippets.

@JosephMoniz
Created February 2, 2014 05:26
Show Gist options
  • Save JosephMoniz/8763471 to your computer and use it in GitHub Desktop.
Save JosephMoniz/8763471 to your computer and use it in GitHub Desktop.
Y U NO TRAMPOLINE
import scalaz._
import scalaz.concurrent._
import Future._
object Main {
def lamePrint(s: String): Future[Unit] = async { next =>
println(s)
next()
}
def loop(s: String): Future[Unit] = for (
sync <- lamePrint(s);
_ <- loop(s)
) yield ()
final def main(args: Array[String]) {
loop("boom").run
}
}
import scalaz._
import effect._
import IO._
object Main {
def loop(s: String): IO[Unit] = for(
_ <- putStrLn(s);
_ <- loop(s)
) yield ()
final def main(args: Array[String]) {
loop("boom").unsafePerformIO()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment