I'm trying to annotate the Element record in clojure.data.xml which is:
(defrecord Element [tag attrs content])
I've annotated it as follows:
(t/ann-record Element [tag :- t/Keyword attrs :- (t/HMap :complete? false)
content :- (t/Vec Element)])
And I have the following function which doesn't type check:
(t/ann get-content [Element -> (t/Vec Element)])
(defn get-content [xml]
(:content xml))
with 'Expected: t/Vec clojure.data.xml.Element Actual: t/Any'
I've also tried replacing that with (get xml :content)
but it fails with the same output.
I wonder what I'm doing wrong :D
It might be that you need to fully qualify
Element
in yourann-record
call (I'm assuming your code is not actually in theclojure.data.xml
namespace).The docs for ann-record say
So in this particular case: