Skip to content

Instantly share code, notes, and snippets.

Created November 5, 2017 14:23
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save knightpop/4d6aee076ac8d34b0c13ae23de1031d6 to your computer and use it in GitHub Desktop.
* 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