Feed predicates from clojure.spec to the inference engine/type checker from the Shen java port?

332 views
Skip to first unread message

lawrence...@gmail.com

unread,
Oct 27, 2017, 5:15:54 PM10/27/17
to Clojure
This sounds like an interesting idea. Does anyone know if this could work? 


The allure of Shen is that it offers a type system that is, roughly speaking, very similar to what you get with clojure.spec. You construct "predicates", what Shen calls sequents, which hold about your data. Shen goes a step further than clojure.spec in that it offers a way to prove that those predicates hold locally to each function and globally through your program.

I wonder if it might be possible to feed predicates from clojure.spec to the inference engine/type checker from the Shen java port to gain static type checking. I wish I had more time to work on this kind of fundamental research, but alas I'm merely a working programmer schlepping data to and fro.

Tiago Dall'Oca

unread,
Oct 29, 2017, 12:24:37 PM10/29/17
to Clojure
I'd very much appreciate this kind of thing. I'm not totally into neither static nor dynamic camp. I think we can be benefitted from ideas and philosophies of both.

Unfortunately I can't help by now but I guess there are people willing to.

Maybe you should also reference this in other clojure channels?

Didier

unread,
Oct 29, 2017, 3:14:51 PM10/29/17
to Clojure
I'm not sure how shen does it, but you should check out Spectrum: https://github.com/arohner/spectrum

It tries to do static analysis of your Clojure code based on your specs. My understanding of it is that it considers equal predicates to be a type. The challenge is knowing that two predicates are equal, or that one is a subtype of the other. I don't think its very dmart about that yet. But just cobsidering each spec as a type can catch a few bugs.

Didier

unread,
Oct 29, 2017, 3:16:42 PM10/29/17
to Clojure
Oh, it also follows known values around, and runs them against the specs at static time. So it can catch some value based errors, like a divide by zero, given that the value is available at static time too.
Reply all
Reply to author
Forward
0 new messages