What does `: -` mean in clojure core.typed?

What does it mean :- into this code from the core.typed library?

 (t/ann play-many [(ta/Chan RPSResult) t/Int -> (t/Map t/Any t/Any)]) (defn play-many "Play n matches from out-chan and report a summary of the results." [out-chan n] (t/loop [remaining :- t/Int, n ;; <======== This line results :- (t/Map PlayerName t/Int), {}] (if (zero? remaining) results (let [[m1 m2 winner] (a/<!! out-chan)] (assert m1) (assert m2) (assert winner) (recur (dec remaining) (merge-with + results {winner 1})))))) 
+6
source share
2 answers

As already mentioned :- is just a keyword. However, in your context, this is part of the core.typed annotations, designating core.typed bindings as being of a specific type:

 (t/loop [remaining :- t/Int, n results :- (t/Map PlayerName t/Int), {}] ...) 

This means that remaining is an integer, and results is a match of the player’s name with an integer. They can be checked using core.typed type checking.

+12
source

:- is the keyword of one character, - .

 user=> :- :- user=> (class :-) clojure.lang.Keyword 
+6
source

Source: https://habr.com/ru/post/978405/


All Articles