This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-06
Channels
- # announcements (12)
- # babashka (34)
- # beginners (85)
- # calva (76)
- # cider (14)
- # clj-kondo (49)
- # cljs-dev (32)
- # clojure (418)
- # clojure-europe (3)
- # clojure-france (4)
- # clojure-italy (17)
- # clojure-losangeles (8)
- # clojure-nl (5)
- # clojure-norway (2)
- # clojure-spec (2)
- # clojure-uk (88)
- # clojuredesign-podcast (4)
- # clojurescript (49)
- # clojurex (75)
- # clr (2)
- # core-async (13)
- # cursive (6)
- # datomic (57)
- # duct (31)
- # emacs (6)
- # fulcro (25)
- # graalvm (67)
- # graphql (13)
- # hoplon (1)
- # java (6)
- # juxt (11)
- # kaocha (5)
- # keechma (2)
- # leiningen (16)
- # mount (1)
- # off-topic (19)
- # pathom (2)
- # pedestal (1)
- # re-frame (11)
- # reagent (21)
- # reitit (22)
- # rewrite-clj (1)
- # shadow-cljs (98)
- # spacemacs (5)
- # sql (16)
- # tools-deps (8)
- # vim (28)
- # xtdb (4)
@mfikes Would it make sense to propagate function return type through apply
call?
unless target function is of multiple arities
could you give an example?
alright 🙂
@mfikes looks like return type of apply
(`any`) is prioritized over return type hint, is this intentional?
(defn ^number f [x] x)
(apply f [1]) ;; tag here is `any`
That’s a trivial example, but there are probably semi-complicated higher order cases where, as a human you can statically deduce types where the compiler is not yet doing so.
oh wait, the example is wrong
hm, this is a different question, but I’m hitting a weird case where return type of fx
is any
even though there’s return type hint
(defn f [x] x)
(defn ^number fx []
(apply f [1]))
(fx)
can’t repro in master though
placing the hint onto return value itself seem to fix this
Isn’t that type hint in the wrong place?
I think with apply
you’d need to be careful in the multi-arity case to ensure that, you get the union of all return types
Should be on the arg vector
Ah, sorry
@mfikes Should I file a JIRA then for higher order inference?
@roman01la Off the top of my head, I don’t know of any general algorithm. Maybe it makes sense to do specific things like apply
, and see if any generaliztion falls out of those kinds of things?
yeah I think it should be a good start
identity
should be trivial as well
An example of a complex higher order inference might be (first (map inc [1]))
being of numeric type.
As a human, you can easily see this is the case, but the compiler is far away from being able to handle stuff like that.