zipper
package zipper
Members list
Type members
Classlikes
A typeclass that defines how a certain data structure can be unzipped and zipped back.
A typeclass that defines how a certain data structure can be unzipped and zipped back.
An instance of Unzip can be automatically derived for a case class C with a single field of type List[C]. In a similar situation, but with a different collection class used, say, Vector, an instance can still be derived like so:
implicit val instance = Unzip.For[C, Vector].derive
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
object Unzip
A Zipper allows to move around a recursive immutable data structure and perform updates.
A Zipper allows to move around a recursive immutable data structure and perform updates.
Example:
case class Tree(x: Int, c: List[Tree] = List.empty)
val before = Tree(1, List(Tree(2)))
val after = Tree(1, List(Tree(2), Tree(3)))
Zipper(before).moveDownRight.insertRight(Tree(3, Nil)).commit shouldEqual after
See https://www.st.cs.uni-saarland.de/edu/seminare/2005/advanced-fp/docs/huet-zipper.pdf.
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
In this article