Skip to content

Instantly share code, notes, and snippets.

@julien-truffaut
Last active August 29, 2015 14:05
Show Gist options
  • Save julien-truffaut/aef35820727888b3411e to your computer and use it in GitHub Desktop.
Save julien-truffaut/aef35820727888b3411e to your computer and use it in GitHub Desktop.
Multi compose
import monocle._ Monocle._
case class Order(name: String, articles: List[Article])
case class Article(properties: Map[String, String])
val order = Order("name", List(Article(Map("name" -> "door", "colour" -> "red")), Article(Map("name" -> "shoes"))))
val _articles = Lenser[Order](_.articles)
val _properties = SimpleIso[Article, Map[String, String]](_.properties, Article(_))
val names = order |-> _articles |->> each |->> _properties |->> index("name") getAll
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment