rephrase

phronmophobic 2026-06-05T20:25:12.274809Z

Can rephrase help with exceptions like https://clojurians.slack.com/archives/C03S1KBA2/p1780496934956719 >

Unhandled java.lang.ClassCastException
>    class user$build_adj$fn__11004$fn__11005 cannot be cast to class clojure.lang.IPersistentCollection
Actual problem: > I think you want >
(mapv (fn [_] #{}) (range n))
> instead of >
(mapv (fn [_] #()) (range n))

seancorfield 2026-06-05T20:45:44.044219Z

Currently:

user=> (reduce (fn [acc v] (update acc v conj v)) *1 (range n))
Expected IPersistentCollection, but was given user$eval18295$fn__18296$fn__18297, at user/eval18301$fn (REPL:1) - runtime error (unexpected type).

phronmophobic 2026-06-05T20:46:11.540509Z

not bad

seancorfield 2026-06-05T20:46:18.013909Z

I don't currently do any symbol demunging that would improve that.

phronmophobic 2026-06-05T20:46:31.961109Z

that's definitely more helpful.

seancorfield 2026-06-05T20:55:08.511109Z

Part of the difficulty with Jim's specific error is that you have an anonymous function #() inside an anonymous function (fn [..] ..). Compound that with the way the REPL wraps things in evalNNN.

👍 1
phronmophobic 2026-06-05T21:02:08.868329Z

ultimately, I think the best experience will require hacking the compiler as well as incorporating ideas from something like flowstorm

seancorfield 2026-06-05T21:04:13.586499Z

Yeah, I was pleased to hear Alex talk about a potential dev vs prod mode that might allow for more checking and better errors in dev mode.

💯 1
👀 1
🙌 1
seancorfield 2026-06-05T21:05:29.001279Z

I think jpmonettas suggested a compiler fork too -- but I don't want to maintain that (and it wouldn't "compose" with other compiler forks).

seancorfield 2026-06-05T21:07:26.128159Z

Rephrase is meant to show that you can improve a lot of error messages to some extent without going too deep. I use it all the time, in all my projects now, and if I hit an ugly error, I try to figure out a way to rephrase it. But I don't hit a lot of the errors that beginners do these days (15+ years of Clojure).