Loading...
Skip to end of metadata
Go to start of metadata

Without knowing very much about CCW, this is how I'd expect core.typed to work.

Checking namespaces

core.typed works best at namespace granularity. When CCW has a namespace open, there should be a button that calls "check-ns" on this namespace.

LAP: it is definitely possible and probably quite easy to add a new command possibility (via keyboard shortcut, and contextual menu) for invoking some core.typed command, using the current active repl *if we find some core.typed marker namespace in the repl's classpath* and giving it the namespace name corresponding to the editor tab having the focus.

core.typed throws a clojure.lang.ExceptionInfo, accompanied by errors like:

Type Error (typed-demo.core:9:8) Static method clojure.lang.Numbers/add could not be applied to arguments:
 
Domains:
 t/AnyInteger t/AnyInteger
 Number Number
Arguments:
 (Value 1) (Fn [Number -> Number])
Ranges:
 t/AnyInteger
 Number
with expected type:
 Any
in: (clojure.lang.Numbers/add 1 typed-demo.core/my-adder)
 
Type Error (typed-demo.core:11) Cannot throw: (Value 1)
in: (throw 1)
 
 Type Checker: Found 2 errors
in: (clojure.lang.Numbers/add 1 typed-demo.core/my-adder)

CCW should present these errors to the user in the typical Eclipse fashion, with visual cues to the actual error source. Usually line and column number is provided.

LAP: would the only option available to parse the output printed? Seems a little bit fragile. Could there be a command returning a tiny datastructure: \[ \{ :filename "/home/lpetit/.../my_namespace.clj", :line 1234, :description "here the usual text", :summary "condensed version for quick single-line display" \}, \{ ... another type error ... \} ... \]

Ambrose: At the top level I have a sequence of Exceptions which I just dump to stderr or stdout after type checking. I can easily provide a map.

There might be an option for automatic type checking along with compilation.

LAP: CCW does not compile those days (as in AOT compile), but does provide option to automatically reload the namespace. So this could probably be added as well, indeed (maybe not in a first version). The problem being, as usual, how (and should we) determine all other dependent namespaces that should be recompiled / rechecked (once we enter the "automatic" realm, users demands are high Smile )

Ambrose: Yes that's what I meant. Users often want to do type checking when reloading namespaces.

Typed REPL

This is optional, but provide a REPL with the type checker always on. This would type check forms implicitly.

LAP: This could be an option. This would mean automatically encapsulating commands inside some core.typed call, right ?

Ambrose: Yes. It should be a matter of piping through a core.typed command.

Type queries

Hovering over locals could query core.typed for the type at particular positions. This could get complicated.

LAP: Let's save this for a later brainstorming.

Ambrose: Wise.

Labels: