summaryrefslogtreecommitdiff
path: root/lib/zipper.mli
diff options
context:
space:
mode:
authorFederico Igne <undyamon@disroot.org>2024-01-26 20:35:57 +0100
committerFederico Igne <undyamon@disroot.org>2024-01-26 20:35:57 +0100
commit1154021614181f2b62ced31cde8b9ac761f91312 (patch)
tree1f0cd0b52e21d0aaf7ebbd6d48d9abeb88cc356e /lib/zipper.mli
parent477dd3d2a9f452d06912f9f56c6eee831a15aead (diff)
downloadsandy-1154021614181f2b62ced31cde8b9ac761f91312.tar.gz
sandy-1154021614181f2b62ced31cde8b9ac761f91312.zip
refactor: make zippers return 'pop'ped elements
Diffstat (limited to 'lib/zipper.mli')
-rw-r--r--lib/zipper.mli26
1 files changed, 7 insertions, 19 deletions
diff --git a/lib/zipper.mli b/lib/zipper.mli
index 0bbdf27..a300b12 100644
--- a/lib/zipper.mli
+++ b/lib/zipper.mli
@@ -106,30 +106,18 @@ val goto : int -> 'a zipper -> 'a zipper
106 This involve [push]ing and [pop]ping elements before and after the 106 This involve [push]ing and [pop]ping elements before and after the
107 cursor. *) 107 cursor. *)
108 108
109val pop : ?n:int -> 'a zipper -> 'a zipper 109val pop : ?n:int -> 'a zipper -> 'a Sequence.t * 'a zipper
110(** Remove [n] elements at the cursor position (1 by default), if any, 110(** Remove [n] elements at the cursor position (1 by default), if any,
111 and return the modified zipper. Calling [pop z], 111 and return them alongside the modified zipper. *)
112 112
113 - if [z] is [([3; 2; 1], [4; 5])], the result is [([3; 2; 1], [5])], 113val pop_before : ?n:int -> 'a zipper -> 'a Sequence.t * 'a zipper
114 - if [z] is [([1; 2; 3], [])], the result is [([1; 2; 3], [])].
115 *)
116
117val pop_before : ?n:int -> 'a zipper -> 'a zipper
118(** Remove [n] elements before the cursor (1 by default), if any, and 114(** Remove [n] elements before the cursor (1 by default), if any, and
119 return the modified zipper. Calling [pop_before z], 115 return them alongside the modified zipper. *)
120
121 - if [z] is [([3; 2; 1], [4; 5])], the result is [([2; 1], [4, 5])],
122 - if [z] is [([], [1; 2; 3])], the result is [([], [1; 2; 3])].
123 *)
124 116
125val pop_after : ?n:int -> 'a zipper -> 'a zipper 117val pop_after : ?n:int -> 'a zipper -> 'a Sequence.t * 'a zipper
126(** Remove [n] elements after (and {b not} including) the cursor 118(** Remove [n] elements after (and {b not} including) the cursor
127 (1 by default), if any, and return the modified zipper. 119 (1 by default), if any, and return them alongside the modified
128 Calling [pop_after z], 120 zipper. *)
129
130 - if [z] is [([3; 2; 1], [4; 5])], the result is [([3; 2; 1], [4])],
131 - if [z] is [([1; 2; 3], [4])], the result is [([1; 2; 3], [4])].
132 *)
133 121
134val push : 'a -> 'a zipper -> 'a zipper 122val push : 'a -> 'a zipper -> 'a zipper
135(** Insert an element at the cursor position. 123(** Insert an element at the cursor position.