Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

schema inference from source code #181

Open
xificurC opened this issue Feb 20, 2020 · 6 comments
Open

schema inference from source code #181

xificurC opened this issue Feb 20, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@xificurC
Copy link
Contributor

Schema providers can take sample input and generate a schema. How magical would it be if one could infer a schema from code?

(defn-magic foo [m] (+ (:x m) (-> m :y :yy)))
;; => [:map [:x number?] [:y [:map [:yy number?]]]]

I think this could be done by code-walking or something similar. If done right I think this would be invaluable, we'd get type-inference-like capabilities in the language :)

@ikitommi
Copy link
Member

Tools like clj-kondo and core.typed are both actively developed, I think this falls into scope of those libs. Plan is to integrate malli with clj-kondo later anyway.

@piotr-yuxuan
Copy link
Contributor

clj-kondo integration might be quite a killer feature!

@ikitommi
Copy link
Member

ikitommi commented Mar 7, 2020

WIP.
clj-kondo

@ikitommi ikitommi added the enhancement New feature or request label Mar 7, 2020
@nilern
Copy link
Contributor

nilern commented Jan 27, 2021

Apparently Typed Clojure can automagically infer Specs.

@ikitommi
Copy link
Member

malli.typed ?

@frenchy64
Copy link
Collaborator

Unfortunately, Typed Clojure can only infer specs from data (not code), like malli does :) It instruments your code and then runs your tests.

It does some fancy things around deciding whether something is a multispec, but that's about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants