Packages

p

zipper

package zipper

Ordering
  1. Alphabetic
Visibility
  1. Public
  2. All

Type Members

  1. trait Unzip[A] extends AnyRef

    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
    Annotations
    @implicitNotFound( ... )
  2. case class Zipper[A](left: List[A], focus: A, right: List[A], top: Option[Zipper[A]])(implicit unzip: Unzip[A]) extends Product with Serializable

    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.

Value Members

  1. object Unzip extends GenericUnzipInstances
  2. object Zipper extends Serializable

Ungrouped