Skip to content

Instantly share code, notes, and snippets.

Created November 5, 2017 14:23
What would you like to do?
* Use cats applicative
import cats.syntax.all._
import cats.instances.future._
val start3: Instant =
val fUserInfo3 = for {
nickname <- getNicknameById(userId)
(email, account) <- (getEmailAddressByNickname(nickname) |@| getAccountInfoByNickname(nickname)).tupled
} yield UserInfo(userId, nickname, email, account)
val userInfo3: UserInfo = Await.result(fUserInfo3, 10 second)
val end3: Instant =
println(printInterval(userInfo3, start3, end3)) // UserInfo(31337,ktz,,None) take 5 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment