 (ns stch.zipper
-  "Zipper for sequential data. Keeps a
+  "Zipper for sequential data. Maintains a
   history of the traversed positions."
   (:require [clojure.core :as core])
   (:use

  [z :- Zipper]
  (peek (:left z)))

(defn' remove :- (Option Zipper)
  "Remove the current element from the zipper."
  [z :- Zipper]
  (when-not (core/empty? (:left z))
    (-> (update-in z [:left] pop)
        (update-in [:index] dec))))

(defn' replace :- (Option Zipper)
  "Replace the current element in the zipper
  with el."
  [z :- Zipper, el :- Any]
  (when-not (core/empty? (:left z))
    (update-in z [:left] #(-> % pop (conj el)))))

(defn' truncate :- Zipper
  "Truncate the right side of the zipper."
  [z :- Zipper]
  (assoc z :right (double-list)))

(defn' update :- (Option Zipper)
  "Update the current element in the zipper,
  calling f on it."
  [z :- Zipper, f :- (Fn Any [Any])]
  (when-not (core/empty? (:left z))
    (update-in z [:left] #(let [v (f (peek %))]
                            (-> % pop (conj v))))))

(defn' insert-right :- Zipper
  "Insert el to the right of the current

             (dec (:index z))
             (:traversed z))))

(defn' next :- Zipper
  "Move the zipper to the right."
  [z :- Zipper]
  (if (core/empty? (:right z))
