types - What does `:-` mean in clojure's core.typed? -
what :-
mean in this code core.typed library?
(t/ann play-many [(ta/chan rpsresult) t/int -> (t/map t/any t/any)]) (defn play-many "play n matches out-chan , report summary of results." [out-chan n] (t/loop [remaining :- t/int, n ;; <======== 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, :-
keyword. however, in context it's part of core.typed
's annotations, marking loop bindings being of specific type:
(t/loop [remaining :- t/int, n results :- (t/map playername t/int), {}] ...)
this means remaining
integer, while results
map associating player name integer. these can verified using core.typed
's type checker.
Comments
Post a Comment