Packages

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.

Linear Supertypes
Serializable, Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Zipper
  2. Serializable
  3. Serializable
  4. Product
  5. Equals
  6. AnyRef
  7. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Zipper(left: List[A], focus: A, right: List[A], top: Option[Zipper[A]])(implicit unzip: Unzip[A])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. def advanceLeftDepthFirst: Zipper[A]

    Move to the next position in depth-first left-to-right order, or throw if impossible

  5. def advanceRightDepthFirst: Zipper[A]

    Move to the next position in depth-first right-to-left order, or throw if impossible

  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def commit: A

    Zip to the top and return the resulting value

  9. def cycle(move0: Move[A], moves: Move[A]*): Zipper[A]

    Cycle through the moves until a failure is produced and return the last success

  10. 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

  11. 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

  12. def deleteAndMoveLeft: Zipper[A]

    Delete the value in focus and move left, or throw if impossible

  13. def deleteAndMoveRight: Zipper[A]

    Delete the value in focus and move right, or throw if impossible

  14. def deleteAndMoveUp: Zipper[A]

    Delete the value in focus and move up, or throw if impossible

  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def fail: MoveResult[A]
  17. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. val focus: A
  19. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  20. def insertDownLeft(values: List[A]): Zipper[A]

    Move down left and insert a list of values on the left, focusing on the first one

  21. def insertDownRight(values: List[A]): Zipper[A]

    Move down right and insert a list of values on the right, focusing on the last one

  22. def insertLeft(value: A): Zipper[A]

    Insert a new value to the left of focus

  23. def insertRight(value: A): Zipper[A]

    Insert a new value to the right of focus

  24. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  25. val left: List[A]
  26. 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()
  27. def moveDownAt(index: Int): Zipper[A]

    Unzip the current node and focus on the nth child, or throw if impossible

  28. def moveDownLeft: Zipper[A]

    Unzip the current node and focus on the left child, or throw if impossible

  29. def moveDownRight: Zipper[A]

    Unzip the current node and focus on the right child, or throw if impossible

  30. def moveLeft: Zipper[A]

    Move left or throw if impossible

  31. def moveLeftBy(n: Int): Zipper[A]

    Move left by n or throw if impossible

  32. def moveRight: Zipper[A]

    Move right or throw if impossible

  33. def moveRightBy(n: Int): Zipper[A]

    Move right by n or throw if impossible

  34. def moveTo(z: Zipper[A]): MoveResult[A]
  35. def moveUp: Zipper[A]

    Zip the current layer and move up, or throw if impossible

  36. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  37. final def notify(): Unit
    Definition Classes
    AnyRef
  38. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  39. def repeat(n: Int, move: Move[A]): Zipper[A]

    Repeat a move n times or throw if impossible

  40. 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

  41. 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

  42. def rewindLeft: Zipper[A]

    Move to the leftmost position

  43. def rewindRight: Zipper[A]

    Move to the rightmost position

  44. val right: List[A]
  45. def set(value: A): Zipper[A]

    Replace the focus with a different value

  46. def stay: MoveResult[A]
  47. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  48. def tapFocus(f: (A) ⇒ Unit): Zipper[A]

    Perform a side-effect on the focus

  49. val top: Option[Zipper[A]]
  50. def tryAdvanceLeftDepthFirst: MoveResult[A]

    Move to the next position in depth-first left-to-right order

  51. def tryAdvanceRightDepthFirst: MoveResult[A]

    Move to the next position in depth-first right-to-left order

  52. def tryDeleteAndAdvanceLeftDepthFirst: MoveResult[A]

    Delete the value in focus and move to the next position in depth-first right-to-left order

  53. def tryDeleteAndAdvanceRightDepthFirst: MoveResult[A]

    Delete the value in focus and move to the next position in depth-first left-to-right order

  54. def tryDeleteAndMoveLeft: MoveResult[A]

    Delete the value in focus and move left

  55. def tryDeleteAndMoveRight: MoveResult[A]

    Delete the value in focus and move right

  56. def tryDeleteAndMoveUp: MoveResult[A]

    Delete the value in focus and move up

  57. def tryInsertDownLeft(values: List[A]): MoveResult[A]

    Move down left and insert a list of values on the left, focusing on the first one

  58. def tryInsertDownRight(values: List[A]): MoveResult[A]

    Move down right and insert a list of values on the right, focusing on the last one

  59. def tryMoveDownAt(index: Int): MoveResult[A]

    Unzip the current node and focus on the nth child

  60. def tryMoveDownLeft: MoveResult[A]

    Unzip the current node and focus on the left child

  61. def tryMoveDownRight: MoveResult[A]

    Unzip the current node and focus on the right child

  62. def tryMoveLeft: MoveResult[A]

    Move left

  63. def tryMoveLeftBy(n: Int): MoveResult[A]

    Move left by n

  64. def tryMoveRight: MoveResult[A]

    Move right

  65. def tryMoveRightBy(n: Int): MoveResult[A]

    Move right by n

  66. def tryMoveUp: MoveResult[A]

    Zip the current layer and move up

  67. def tryRepeat(n: Int, move: Move[A]): MoveResult[A]

    Repeat a move n times

  68. 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

  69. 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

  70. implicit val unzip: Unzip[A]
  71. def update(f: (A) ⇒ A): Zipper[A]

    Update the focus by applying a function

  72. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  73. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  74. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped