Fork me on GitHub
#core-typed
<
2020-06-15
>
ambrosebs02:06:40

just wrote a typing rule for async/go

(defmethod -unanalyzed-special 'clojure.core.async/go
  [{:keys [form env] :as expr} expected]
  (let [;; type check the go body
        cbody (-> `(do ~@(rest form))
                  (ana2/unanalyzed env)
                  check-expr)]
    (-> expr
        ;; put expanded body back into go call
        (update :form (fn [form]
                        (with-meta (list `async/go (emit-form/emit-form cbody))
                                   (meta form))))
        ;; evaluate partially expanded go call if top-level
        ana2/eval-top-level
        ;; use checked body to populate return type and check against expected
        (assoc
          u/expr-type (below/maybe-check-below
                        (r/ret (c/-name `tasync/Chan (-> cbody u/expr-type :t))
                               (fo/-true-filter))
                        expected)
          :tag nil))))

ambrosebs04:06:02

News update: "Performance improvements (25%), async type rules" https://www.patreon.com/posts/38246734