Skip to content

Instantly share code, notes, and snippets.

@loicdescotte
Last active September 12, 2018 13:38
Show Gist options
  • Select an option

  • Save loicdescotte/a35350580358b260965e9c2e6392f6af to your computer and use it in GitHub Desktop.

Select an option

Save loicdescotte/a35350580358b260965e9c2e6392f6af to your computer and use it in GitHub Desktop.
Cats sequence functions
import cats.implicits._
val f = (x: Int) => x+1
val g = (x: Int) => x+2
val h = (x: Int) => x+3
// Cats has an Applicative instance for Function1 so you can traverse/sequence it
val l = List(f, g, h).sequence //l : Function1[Int, List[Int]]
l(1) //List(2, 3, 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment