Fork me on GitHub
#clj-kondo
<
2020-04-15
>
sogaiu12:04:45

@borkdude thought you'd appreciate this quote from a classic paper on incremental parsing

orestis13:04:08

So Malli showed a pretty nifty sneak peek of clj-kondo integration, where you could define the inputs and outputs of a defn and kondo could somehow lint their usage. Is that something that kondo can do today? And if yes, do the types “flow” down to functions calls etc?

borkdude13:04:11

yes, the types "flow" in let and function return types

orestis13:04:40

My use case is, I have some functions whose arguments can be described pretty tightly (they are GraphQL objects). I’d like to be able to catch mistypes, checking for keys that aren’t there (closed types) etc. Doing it at the syntax level like demonstrated would be cool, but I could also do it on my own.

orestis13:04:36

Some example:

(defn my-resolver [context args _]
  (let [subtype (:foo args)]
    (deal-with-subtype context subtype (:bar args))))

borkdude13:04:40

@orestis there is this now: {:op :keys, :req {:a :string} :opt {:b :int}}, but that's mostly for checking map literals at callsites

borkdude13:04:11

not sure how well that works with "flow", I expect it not to work at all at the moment.

orestis13:04:59

Can I somehow “lint” that :foo is actually part of some spec? Can I somehow lint that the third argument deal-with-subtype ( (:bar args) ) is a sub-spec of the bigger spec?

orestis13:04:24

Sorry if this sounds too vague, I don’t have the terminology figured out…

borkdude13:04:30

I have currently one function in clj-kondo that is typed using the :keys: https://github.com/borkdude/clj-kondo/blob/master/src/clj_kondo/impl/findings.types.edn No, there is no spec-like thing

orestis13:04:00

Where spec could be malli -> which is what piqued my interest

orestis13:04:33

I don’t necessarily want to have clj-kondo itself do this, but it seems like it may be generating information I could then piece together on my own? Or would I go to tools.analyzer for this?

borkdude13:04:18

@orestis clj-kondo doesn't generate any type information

borkdude13:04:29

afk now, ttyl

orestis13:04:04

Np, I’ll see if I can explain myself better in some clojureverse post 🙂 Thanks