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.
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.
- Alphabetic
- By Inheritance
- Zipper
- Serializable
- Product
- Equals
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def advanceLeftDepthFirst: Zipper[A]
Move to the next position in depth-first left-to-right order, or throw if impossible
- def advanceRightDepthFirst: Zipper[A]
Move to the next position in depth-first right-to-left order, or throw if impossible
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
- def commit: A
Zip to the top and return the resulting value
- def cycle(move0: Move[A], moves: Move[A]*): Zipper[A]
Cycle through the moves until a failure is produced and return the last success
- def deleteAndAdvanceLeftDepthFirst: Zipper[A]
Delete the value in focus and move to the next position in depth-first right-to-left order, or throw if impossible
- def deleteAndAdvanceRightDepthFirst: Zipper[A]
Delete the value in focus and move to the next position in depth-first left-to-right order, or throw if impossible
- def deleteAndMoveLeft: Zipper[A]
Delete the value in focus and move left, or throw if impossible
- def deleteAndMoveRight: Zipper[A]
Delete the value in focus and move right, or throw if impossible
- def deleteAndMoveUp: Zipper[A]
Delete the value in focus and move up, or throw if impossible
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def fail: MoveResult[A]
- val focus: A
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @IntrinsicCandidate() @native()
- def insertDownLeft(values: List[A]): Zipper[A]
Move down left and insert a list of values on the left, focusing on the first one
- def insertDownRight(values: List[A]): Zipper[A]
Move down right and insert a list of values on the right, focusing on the last one
- def insertLeft(value: A): Zipper[A]
Insert a new value to the left of focus
- def insertRight(value: A): Zipper[A]
Insert a new value to the right of focus
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- val left: List[A]
- final def loopAccum[B](acc: B)(f: (Zipper[A], B) => (MoveResult[A], B)): (Zipper[A], B)
Loop and accumulate state until a failure is produced
Loop and accumulate state until a failure is produced
- Annotations
- @tailrec()
- def moveDownAt(index: Int): Zipper[A]
Unzip the current node and focus on the nth child, or throw if impossible
- def moveDownLeft: Zipper[A]
Unzip the current node and focus on the left child, or throw if impossible
- def moveDownRight: Zipper[A]
Unzip the current node and focus on the right child, or throw if impossible
- def moveLeft: Zipper[A]
Move left or throw if impossible
- def moveLeftBy(n: Int): Zipper[A]
Move left by n or throw if impossible
- def moveRight: Zipper[A]
Move right or throw if impossible
- def moveRightBy(n: Int): Zipper[A]
Move right by n or throw if impossible
- def moveTo(z: Zipper[A]): MoveResult[A]
- def moveUp: Zipper[A]
Zip the current layer and move up, or throw if impossible
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @IntrinsicCandidate() @native()
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- def repeat(n: Int, move: Move[A]): Zipper[A]
Repeat a move
n
times or throw if impossible - def repeatWhile(condition: (A) => Boolean, move: Move[A]): Zipper[A]
Repeat a move while the condition is satisfied or throw if impossible
Repeat a move while the condition is satisfied or throw if impossible
- returns
the first zipper that does not satisfy the condition
- def repeatWhileNot(condition: (A) => Boolean, move: Move[A]): Zipper[A]
Repeat a move while the condition is not satisfied or throw if impossible
Repeat a move while the condition is not satisfied or throw if impossible
- returns
the first zipper that satisfies the condition
- def rewindLeft: Zipper[A]
Move to the leftmost position
- def rewindRight: Zipper[A]
Move to the rightmost position
- val right: List[A]
- def set(value: A): Zipper[A]
Replace the focus with a different value
- def stay: MoveResult[A]
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def tapFocus(f: (A) => Unit): Zipper[A]
Perform a side-effect on the focus
- val top: Option[Zipper[A]]
- def tryAdvanceLeftDepthFirst: MoveResult[A]
Move to the next position in depth-first left-to-right order
- def tryAdvanceRightDepthFirst: MoveResult[A]
Move to the next position in depth-first right-to-left order
- def tryDeleteAndAdvanceLeftDepthFirst: MoveResult[A]
Delete the value in focus and move to the next position in depth-first right-to-left order
- def tryDeleteAndAdvanceRightDepthFirst: MoveResult[A]
Delete the value in focus and move to the next position in depth-first left-to-right order
- def tryDeleteAndMoveLeft: MoveResult[A]
Delete the value in focus and move left
- def tryDeleteAndMoveRight: MoveResult[A]
Delete the value in focus and move right
- def tryDeleteAndMoveUp: MoveResult[A]
Delete the value in focus and move up
- def tryInsertDownLeft(values: List[A]): MoveResult[A]
Move down left and insert a list of values on the left, focusing on the first one
- def tryInsertDownRight(values: List[A]): MoveResult[A]
Move down right and insert a list of values on the right, focusing on the last one
- def tryMoveDownAt(index: Int): MoveResult[A]
Unzip the current node and focus on the nth child
- def tryMoveDownLeft: MoveResult[A]
Unzip the current node and focus on the left child
- def tryMoveDownRight: MoveResult[A]
Unzip the current node and focus on the right child
- def tryMoveLeft: MoveResult[A]
Move left
- def tryMoveLeftBy(n: Int): MoveResult[A]
Move left by n
- def tryMoveRight: MoveResult[A]
Move right
- def tryMoveRightBy(n: Int): MoveResult[A]
Move right by n
- def tryMoveUp: MoveResult[A]
Zip the current layer and move up
- def tryRepeat(n: Int, move: Move[A]): MoveResult[A]
Repeat a move
n
times - def tryRepeatWhile(condition: (A) => Boolean, move: Move[A]): MoveResult[A]
Repeat a move while the condition is satisfied
Repeat a move while the condition is satisfied
- returns
the first zipper that does not satisfy the condition, or failure
- def tryRepeatWhileNot(condition: (A) => Boolean, move: Move[A]): MoveResult[A]
Repeat a move while the condition is not satisfied
Repeat a move while the condition is not satisfied
- returns
the first zipper that satisfies the condition, or failure
- implicit val unzip: Unzip[A]
- def update(f: (A) => A): Zipper[A]
Update the focus by applying a function
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)