Skip to content

Instantly share code, notes, and snippets.

@knightpop
Created November 5, 2017 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knightpop/4d6aee076ac8d34b0c13ae23de1031d6 to your computer and use it in GitHub Desktop.
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 = Instant.now
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 = Instant.now
println(printInterval(userInfo3, start3, end3)) // UserInfo(31337,ktz,helloworld@example.com,None) take 5 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment