What does :-
mean in 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}))))))
As mentioned, :-
is just a keyword. However, in your context it's part of core.typed
's annotations, marking loop 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, while results
is a map associating a player name with an integer. These can be verified using core.typed
's type checker.
:-
is a keyword of a single character, -
.
user=> :-
:-
user=> (class :-)
clojure.lang.Keyword
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With