Skip to content

Instantly share code, notes, and snippets.

@stanch
Created January 24, 2016 14:39
Show Gist options
  • Save stanch/81f9981f7ab473ff4419 to your computer and use it in GitHub Desktop.
Save stanch/81f9981f7ab473ff4419 to your computer and use it in GitHub Desktop.
Extending Quicklens (https://github.com/adamw/quicklens) to support sealed traits
case class Grand(parent: Parent)
sealed trait Parent { def x: Int }
case class Child1(x: Int) extends Parent
case class Child2(x: Int) extends Parent
val grand = Grand(Child1(3))
it should "modify a field in a sealed trait" in {
modify(grand)(_.parent.x).using(_ + 1) should be (Grand(Child1(4)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment