Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(def-alias Zipper
(HMap :mandatory {:focus (U nil Node) :left (Vec Node) :right (Vec Node) :path Path :counter Integer}
:complete? true))
(ann left [Zipper -> Zipper])
(defn left [zipper]
(let [prev (peek (:left zipper))]
(if (nil? prev)
zipper
{:focus prev
:left (pop (:left zipper))
:right (if (nil? (:focus zipper)) (:right zipper) (conj (:right zipper) (:focus zipper)))
:path (:path zipper)
:counter (:counter zipper)})))
Currently getting:
ype Error (hlin.tree:46:14) Polymorphic function cljs.core/peek could not be applied to arguments:
Polymorphic Variables:
x
Domains:
(clojure.core.typed/I cljs.core.typed/NonEmptyCount (cljs.core.typed/Stack x))
(cljs.core.typed/Stack x)
Arguments:
(cljs.core.typed/Vec hlin.tree/Node)
Ranges:
x
x
in: (cljs.core/peek (:left zipper))
in: (cljs.core/peek (:left zipper))
Type Error (hlin.tree:51:58) Polymorphic function cljs.core/conj could not be applied to arguments:
Polymorphic Variables:
x
y
Domains:
(cljs.core.typed/IPersistentVector x) x x *
(cljs.core.typed/APersistentMap x y) (clojure.core.typed/U (cljs.core/IMap x y) (cljs.core/ISeqable (cljs.core/IMapEntry x y)) (cljs.core/IMapEntry x y) nil (clojure.core.typed/HVec [x y])) (clojure.core.typed/U (cljs.core/IMap x y) (cljs.core/ISeqable (cljs.core/IMapEntry x y)) (cljs.core/IMapEntry x y) nil (clojure.core.typed/HVec [x y])) *
(cljs.core.typed/IPersistentMap x y) (clojure.core.typed/U (cljs.core/IMap x y) (cljs.core/ISeqable (cljs.core/IMapEntry x y)) (cljs.core/IMapEntry x y) nil (clojure.core.typed/HVec [x y])) (clojure.core.typed/U (cljs.core/IMap x y) (cljs.core/ISeqable (cljs.core/IMapEntry x y)) (cljs.core/IMapEntry x y) nil (clojure.core.typed/HVec [x y])) *
(cljs.core.typed/IPersistentSet x) x x *
(cljs.core/ASeq x) x x *
(cljs.core.typed/Coll clojure.core.typed/Any) clojure.core.typed/Any clojure.core.typed/Any *
Arguments:
(cljs.core.typed/Vec hlin.tree/Node) (clojure.core.typed/U nil hlin.tree/Node)
Ranges:
(cljs.core.typed/IPersistentVector x)
(cljs.core.typed/APersistentMap x y)
(cljs.core.typed/IPersistentMap x y)
(cljs.core.typed/IPersistentSet x)
(cljs.core/ASeq x)
(cljs.core.typed/Coll clojure.core.typed/Any)
with expected type:
(cljs.core.typed/Vec hlin.tree/Node)
in: (cljs.core/conj (:right zipper) (:focus zipper))
in: (cljs.core/conj (:right zipper) (:focus zipper))
Type Checker: Found 2 errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.