Class/Object

zipper

Zipper

Related Docs: object Zipper | package zipper

Permalink

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])

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def advanceLeftDepthFirst: Zipper[A]

    Permalink

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

  5. def advanceRightDepthFirst: Zipper[A]

    Permalink

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

  6. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def commit: A

    Permalink

    Zip to the top and return the resulting value

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

    Permalink

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

  10. def deleteAndAdvanceLeftDepthFirst: Zipper[A]

    Permalink

    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]

    Permalink

    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]

    Permalink

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

  13. def deleteAndMoveRight: Zipper[A]

    Permalink

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

  14. def deleteAndMoveUp: Zipper[A]

    Permalink

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

  15. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  16. def fail: MoveResult[A]

    Permalink
  17. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. val focus: A

    Permalink
  19. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  20. def insertDownLeft(values: List[A]): Zipper[A]

    Permalink

    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]

    Permalink

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

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

    Permalink

    Insert a new value to the left of focus

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

    Permalink

    Insert a new value to the right of focus

  24. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  25. val left: List[A]

    Permalink
  26. final def loopAccum[B](acc: B)(f: (Zipper[A], B) ⇒ (MoveResult[A], B)): (Zipper[A], B)

    Permalink

    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]

    Permalink

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

  28. def moveDownLeft: Zipper[A]

    Permalink

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

  29. def moveDownRight: Zipper[A]

    Permalink

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

  30. def moveLeft: Zipper[A]

    Permalink

    Move left or throw if impossible

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

    Permalink

    Move left by n or throw if impossible

  32. def moveRight: Zipper[A]

    Permalink

    Move right or throw if impossible

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

    Permalink

    Move right by n or throw if impossible

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

    Permalink
  35. def moveUp: Zipper[A]

    Permalink

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

  36. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  37. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  38. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  39. def repeat(n: Int, move: Move[A]): Zipper[A]

    Permalink

    Repeat a move n times or throw if impossible

  40. def repeatWhile(condition: (A) ⇒ Boolean, move: Move[A]): Zipper[A]

    Permalink

    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]

    Permalink

    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]

    Permalink

    Move to the leftmost position

  43. def rewindRight: Zipper[A]

    Permalink

    Move to the rightmost position

  44. val right: List[A]

    Permalink
  45. def set(value: A): Zipper[A]

    Permalink

    Replace the focus with a different value

  46. def stay: MoveResult[A]

    Permalink
  47. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  48. def tapFocus(f: (A) ⇒ Unit): Zipper[A]

    Permalink

    Perform a side-effect on the focus

  49. val top: Option[Zipper[A]]

    Permalink
  50. def tryAdvanceLeftDepthFirst: MoveResult[A]

    Permalink

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

  51. def tryAdvanceRightDepthFirst: MoveResult[A]

    Permalink

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

  52. def tryDeleteAndAdvanceLeftDepthFirst: MoveResult[A]

    Permalink

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

  53. def tryDeleteAndAdvanceRightDepthFirst: MoveResult[A]

    Permalink

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

  54. def tryDeleteAndMoveLeft: MoveResult[A]

    Permalink

    Delete the value in focus and move left

  55. def tryDeleteAndMoveRight: MoveResult[A]

    Permalink

    Delete the value in focus and move right

  56. def tryDeleteAndMoveUp: MoveResult[A]

    Permalink

    Delete the value in focus and move up

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

    Permalink

    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]

    Permalink

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

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

    Permalink

    Unzip the current node and focus on the nth child

  60. def tryMoveDownLeft: MoveResult[A]

    Permalink

    Unzip the current node and focus on the left child

  61. def tryMoveDownRight: MoveResult[A]

    Permalink

    Unzip the current node and focus on the right child

  62. def tryMoveLeft: MoveResult[A]

    Permalink

    Move left

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

    Permalink

    Move left by n

  64. def tryMoveRight: MoveResult[A]

    Permalink

    Move right

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

    Permalink

    Move right by n

  66. def tryMoveUp: MoveResult[A]

    Permalink

    Zip the current layer and move up

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

    Permalink

    Repeat a move n times

  68. def tryRepeatWhile(condition: (A) ⇒ Boolean, move: Move[A]): MoveResult[A]

    Permalink

    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]

    Permalink

    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]

    Permalink
  71. def update(f: (A) ⇒ A): Zipper[A]

    Permalink

    Update the focus by applying a function

  72. final def wait(): Unit

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  74. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Serializable

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped