Skip to content

Instantly share code, notes, and snippets.

@polyglotpiglet
Created April 11, 2020 08:33
Show Gist options
  • Save polyglotpiglet/d721698f1d742e77159d31adf6651956 to your computer and use it in GitHub Desktop.
Save polyglotpiglet/d721698f1d742e77159d31adf6651956 to your computer and use it in GitHub Desktop.
object Main extends App {
import cats._
import cats.implicits._
val ans: Eval[Int] = for {
a <- Eval.now { println("a"); 40 }
b <- Eval.always { println( "b" ); 2 }
c <- Eval.later { println( "c" ); 2 }
} yield {
println("Adding!")
a + b + c
}
println("---")
ans.value // ignored
ans.value // ignored
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment