zipper

package zipper

Members list

Type members

Classlikes

trait Unzip[A]

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 Object
trait Matchable
class Any
object Unzip

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Unzip.type
case class Zipper[A](left: List[A], focus: A, right: List[A], top: Option[Zipper[A]])(implicit unzip: Unzip[A])

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 Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object Zipper

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
Zipper.type