Skip to content

Instantly share code, notes, and snippets.

@mattroberts297
Created August 19, 2017 07:14
Show Gist options
  • Save mattroberts297/89cc9b6449f601c3ce0139f0c06da569 to your computer and use it in GitHub Desktop.
Save mattroberts297/89cc9b6449f601c3ce0139f0c06da569 to your computer and use it in GitHub Desktop.
Scala for comprehensions and withFilter
libraryDependencies += "org.typelevel" %% "cats-core" % "1.0.0-MF"
scalaVersion := "2.12.2"
import cats._
import cats.data._
import cats.implicits._
object CatsNEL extends App {
val nss: NonEmptyList[(Int, String)] = NonEmptyList.of((1,"a"), (2, "b"), (3, "c"))
val ss: NonEmptyList[String] = for {
tuple <- nss
(n, s) = tuple
} yield s
}
import cats._
import cats.data._
import cats.implicits._
object CatsNEL extends App {
val nss: NonEmptyList[(Int, String)] = NonEmptyList.of((1,"a"), (2, "b"), (3, "c"))
val ss: NonEmptyList[String] = for {
(n, s) <- nss
} yield s
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment