This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-04
Channels
- # announcements (3)
- # babashka (14)
- # beginners (151)
- # calva (14)
- # cider (9)
- # clj-kondo (24)
- # cljdoc (12)
- # cljs-dev (195)
- # cljsjs (3)
- # cljsrn (13)
- # clojars (12)
- # clojure (234)
- # clojure-dev (3)
- # clojure-europe (9)
- # clojure-greece (1)
- # clojure-italy (2)
- # clojure-japan (4)
- # clojure-nl (4)
- # clojure-spec (89)
- # clojure-taiwan (1)
- # clojure-uk (16)
- # clojuredesign-podcast (2)
- # clojurescript (17)
- # conjure (11)
- # core-async (4)
- # core-typed (31)
- # cursive (9)
- # datomic (8)
- # emacs (17)
- # figwheel (1)
- # fulcro (5)
- # ghostwheel (42)
- # graphql (3)
- # hugsql (5)
- # jackdaw (3)
- # jobs-discuss (93)
- # joker (4)
- # meander (6)
- # mount (1)
- # off-topic (23)
- # pathom (10)
- # re-frame (23)
- # reitit (7)
- # remote-jobs (18)
- # shadow-cljs (153)
- # spacemacs (24)
- # sql (30)
- # tools-deps (14)
- # vim (12)
- # xtdb (1)
for anyone interested in reusing some of Typed Clojure's infrastructure for their own type system, https://www.patreon.com/posts/example-type-37870230 shows how to use its analyzer.
@U04V15CAJ No idea if this could be useful to the type checking in clj-kondo or not, but in case you don't monitor this channel, and it might be useful.
@U04V15CAJ if you ever find yourself wanting to partially expand something, it'll probably be useful. I think you use rewrite-clj right? my analyzer is intended for the use-case where you use tools.analyzer, but you need to check intermediate steps.
tools.analyzer is not suited for clj-kondo, it doesn't work with GraalVM unfortunately
oh interesting. my analyzer is a distinct entity from tools.analyzer (w/ no transitive dependency on it), do you know what the issues are? I might be able to fix them.
I think one issue was that tools.analyzer did macroexpansion which effectively uses eval
and eval uses dynamic classloading which is not supported by GraalVM
I'm working on a new macroexpand feature in clj-kondo that will be using this interpreter, so it can all still run in the native binary: https://clojureverse.org/t/feedback-wanted-on-new-clj-kondo-macroexpansion-feature/6043 feedback on that is most welcome
nice. I've thought a lot about this kind of thing. in typed clojure, the analyzer can return an ::unanalyzed
AST node, and then custom rules can be registered about how to type check a particular macro.
you'd register rules with this https://github.com/typedclojure/typedclojure/blob/master/typed/clj.checker/src/clojure/core/typed/checker/jvm/check.clj#L258-L282
here's the rule for clojure.core/ns
https://github.com/typedclojure/typedclojure/blob/94e6daefd70320b7effaf37f5d8bfb439c1aad29/typed/lib.clojure/src/clojure/core/typed/ext/clojure/core.clj#L21-L27
I haven't figured out how to properly handle macros that bind variables, but I would go in the direction of extending a type environment and passing that down, rather than your sketch of expanding to a let
(FWIW).
the clj-kondo approach is not only about validating a macro. it's foremost about expanding since it can't do that without eval. but since the user provides the code that macroexpands, it can do all kinds of checking on it as well and throw an exception. I'll probably let the user return an :findings
vector too.
potentially the expand function could get access to locals, etc too. that's why the function signature is a map to a map, to allow for more stuff in the future
nah I mean rebind this https://github.com/clojure/tools.analyzer/blob/master/src/main/clojure/clojure/tools/analyzer.clj#L129-L133