portal

markaddleman 2023-12-15T22:54:38.047169Z

Continuing the conversation from https://clojurians.slack.com/archives/C03S1KBA2/p1702680404451899?thread_ts=1702674938.791789&cid=C03S1KBA2 …

πŸ‘Œ 2
markaddleman 2023-12-15T22:55:36.403469Z

One more request: It would be nice to have a function equivalent of portal.console/debug to use in transducer pipelines.

markaddleman 2023-12-15T22:56:17.089079Z

I find myself writing code like this:

(sequence (comp 
            ...
            (map (fn[x] (portal.console/debug x)))
            ...)
 ...)

djblue 2023-12-15T22:56:32.921169Z

Can you have both a fn and macro version? Or do they need different names?

markaddleman 2023-12-15T22:56:52.509299Z

I don’t understand

djblue 2023-12-15T22:58:55.302499Z

I was wondering if a var could have both a runtime fn and a macro, but that doesn't make sense. I guess the other issue here is that passing in a fn references doesn't allow for capturing the source context πŸ€”

markaddleman 2023-12-15T23:00:29.414289Z

Right. My use case is entirely about transducer pipelines so maybe a macro would do the trick. Something like:

markaddleman 2023-12-15T23:00:48.728059Z

(sequence (comp 
            ...
           (portal.console/debug-xf)
            ...)
 ...)

djblue 2023-12-15T23:01:18.250489Z

Ohh you still call the code, but it returns a transduce instead πŸ‘Œ

markaddleman 2023-12-15T23:01:24.983879Z

Yep!

djblue 2023-12-15T23:02:42.650249Z

I wonder if we can do it like the transducer collection fns. If you call the fn with no args it returns an "identity" transducer that calls tap>?

markaddleman 2023-12-15T23:03:02.284649Z

I like that a lot

djblue 2023-12-15T23:03:56.169759Z

Did you want to submit a PR?

markaddleman 2023-12-15T23:04:10.300539Z

Sure. I’ll put one together this weekend

djblue 2023-12-15T23:04:23.204829Z

Awesome, thanks!

markaddleman 2023-12-15T23:04:27.576329Z

Thank you!

djblue 2023-12-15T23:06:04.639749Z

In terms of the reader macro, I feel like it's coinvent but feels like a bit of a hack, which is why I haven't gotten around to doing it.

djblue 2023-12-15T23:07:42.540219Z

I feel like the main annoyance is having to ensure the ns is loaded and having to type out the full name all the time or alias it. tap> is so coinvent because it's always there and so short πŸ˜‚

djblue 2023-12-15T23:09:40.052299Z

Is there a way to globally refer a var into every ns? πŸ˜‚