Skip to content

Instantly share code, notes, and snippets.

@davidandrzej
Created October 31, 2013 19:37
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 davidandrzej/7255536 to your computer and use it in GitHub Desktop.
Save davidandrzej/7255536 to your computer and use it in GitHub Desktop.
Get union of all keys from a collection of Maps, the scalaz way.
import scalaz._, Scalaz._
val data = Vector(Map(1 -> "a", 2 -> "b"), Map(2 -> "c", 3 -> "d"))
data.foldMap(_.keys.toSet)
// res0: scala.collection.immutable.Set[Int] = Set(1, 2, 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment