clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
Crispin 2021-05-29T04:53:47.134300Z

Is there a way to get prn and its ilk to print meta definitions? eg. how to get the following to include the meta data in its output?

> (prn-str '(def ^{:dynamic true} *foo* 10))
"(def *foo* 10)\n"

dpsutton 2021-05-29T05:17:36.135200Z

There’s a dynamic var for this. (apropos “meta”) should reveal it

seancorfield 2021-05-29T05:21:09.135500Z

user=> (binding [*print-meta* true] (prn (with-meta {:a 1} {:b 2})))
^{:b 2} {:a 1}

😍 1
1
dpsutton 2021-05-29T05:23:14.136900Z

Thanks. I’m on mobile so didn’t know the exact var. also I think apropos and find-doc are criminally under discussed so like to mention them

💯 1
☝️ 1
seancorfield 2021-05-29T05:23:20.137Z

(I didn't know about that until you mentioned it!)

seancorfield 2021-05-29T05:23:41.137700Z

And, yes, I used (apropos "meta") to find it.

dpsutton 2021-05-29T05:23:56.138300Z

A queryable runtime is very close to a hard requirement for all future programming languages I use

🙌 3
km 2021-05-29T06:55:31.139300Z

Any standard way to run leiningen in the background yet? Or otherwise to watch clj and cljs builds in the same shell?

2021-06-02T18:31:42.289900Z

lein doesn't support backgrounding and I don't think it ever will, as a compromise you could try tmux for switching between sessions in one terminal window

borkdude 2021-05-29T09:57:47.140100Z

@alexmiller @hiredman Getting closer to the weird offset issue with GraalVM: https://github.com/oracle/graal/issues/1613#issuecomment-850806194 Direct linking seems to affect it in that particular case.

borkdude 2021-05-29T10:06:52.140400Z

The problematic function that trips up native-image with direct linked Clojure compilation is defined here: https://github.com/dm3/clojure.java-time/blob/351fb243359635f4d1939e8112c3046d5edb7af1/src/java_time/amount.clj#L73-L84 Perhaps this non-standard way is causing issues

borkdude 2021-05-29T10:09:20.140800Z

Perhaps the eval is called again during native image compilation yielding a different copies of those functions wheres with defmacro you don't have this problem?

👍 1
Karol Wójcik 2021-05-29T10:46:17.141100Z

Per request of @borkdude I've tried to patch the library to use macro. Issue no longer exists: https://github.com/dm3/clojure.java-time/pull/72/commits/08a700a2583ada0908066dbc8d6684e3a032ce96

borkdude 2021-05-29T14:28:35.143Z

(require '[clojure.template])
(macroexpand '(clojure.template/do-template [] (def a b) x 1))

p-himik 2021-05-29T14:51:26.143200Z

I guess the 💥 result is to be expected: > values are automatically partitioned by the number of arguments in argv (partition 0 [1]) will explode in just the same way.

rmxm 2021-05-29T17:13:18.146100Z

Hey all, got a question - I am trying to flatten maps, so that map that looks like {:a {:b 2 :d 3}} would become:

((:a :b 2)(:a :d 3))

sandeep 2021-05-29T17:43:58.146600Z

hello, any idea how to fix the following error Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch proc file - > web: java -cp phs.jar clojure.main -m phs.system

✅ 1
rmxm 2021-05-29T17:45:58.146700Z

Ok, I think I can work this out... something like that:

(defn flatten-data2 [m key]
  (if (map? m)
    (for [[k v] m] (flatten-data2 v (conj key k)))
    (conj key m)))

seancorfield 2021-05-29T17:58:38.147100Z

That sounds like a #heroku question @spamails29?

sandeep 2021-05-29T17:59:20.147800Z

yes @seancorfield

seancorfield 2021-05-29T18:00:01.148600Z

Sounds like your app is just taking too long to start up. How exactly are you building phs.jar? Maybe AOT will make it start up faster…

✅ 1
sandeep 2021-05-30T07:48:09.168100Z

thanks.updated the cli, build error resolved. heroku not launching the app. will try with aws

sandeep 2021-05-30T14:47:04.170900Z

thanks for the help, looks like their was issue with the system file

p-himik 2021-05-29T18:03:51.149400Z

On Heroku, you can increase boot time out to 180 seconds. Had to do it - too many issues with AOT that were way too hard to solve. YMMV of course.

seancorfield 2021-05-29T18:09:09.150200Z

Jason has gone to DM with me about it, but for Heroku details, I’m recommending he ask in #heroku (since I don’t use Heroku at all).

sandeep 2021-05-29T18:43:42.150300Z

increased it to 180 same error

p-himik 2021-05-29T18:46:11.150500Z

I would try profiling the start-up time and see if there's something suspicious going on apart from just the compilation.

sandeep 2021-05-29T18:50:12.150700Z

same error with aot. added extra line to the existing edn file :depstar {:extra-deps {seancorfield/depstar {:mvn/version "1.0.94"}}}

sandeep 2021-05-29T18:50:52.151Z

since it is giving error while deploying

seancorfield 2021-05-29T19:17:58.151700Z

Adding an old version of depstar is not the solution to your problem — the repo is already using the more recent version. What is the error you are seeing during deployment?

sandeep 2021-05-29T19:35:42.151900Z

remote:    Running: bin/build remote:    Error building classpath. Specified aliases are undeclared: [:depstar]

sandeep 2021-05-29T19:36:17.152100Z

bin/build file #!/usr/bin/env bash clojure -A:depstar -m hf.depstar.uberjar pingcrm.jar

seancorfield 2021-05-29T19:48:00.152300Z

I said to use clojure -X:uberjar — that’s what the deps.edn in that project is expecting.

seancorfield 2021-05-29T19:48:27.152500Z

Again, using the alias you added and just that command you added will not AOT the JAR file.

seancorfield 2021-05-29T19:48:46.152700Z

The command I suggested — and the alias that is already in the project will AOT the JAR file.

zendevil 2021-05-29T20:10:21.153800Z

What’s the fun of using add-tap and tap>? Can someone give an example use case?

phronmophobic 2021-05-29T20:13:41.157100Z

One use case is to replace println in development. Instead of strings in the console, you get data and you can extend how tapped values are handled depending on the context

seancorfield 2021-05-29T20:18:15.160400Z

I use Reveal https://github.com/vlaaad/reveal/ as a tap> “client” to display every tap>’d value, either as a table, or in some other useful form. And as Adrian says, you can add tap> calls wherever you want for debugging (and leave them in the code if you want — since they do “nothing” if there are no clients added). You can have multiple clients attached via add-tap so you can have one client showing plain text output and another client showing graphs for vectors of numbers, for example. You can remove-tap to take a client away once you’re done with it.

2
seancorfield 2021-05-29T20:19:26.161300Z

Tools like Cognitect’s REBL, Reveal (linked above), and Portal from @djblue are great additions to a REPL-based development workflow and all act as tap> clients.

seancorfield 2021-05-29T20:20:01.161500Z

https://github.com/djblue/portal

sandeep 2021-05-29T20:39:20.162200Z

tried looks like heroku is rejecting it

sandeep 2021-05-29T20:39:21.162400Z

remote:    Exception in thread "main" java.io.FileNotFoundException: -X:uberjar (No such file or directory)

2021-05-29T21:17:37.164200Z

Any great writing or videos besides the documentation on how to really utilize IntelliJ + Cursive? I feel like I’m using 2% of its capabilities

➕ 2
seancorfield 2021-05-29T22:30:44.164300Z

The version of clojure is too old on Heroku I guess?

seancorfield 2021-05-29T22:33:28.164500Z

You can tell it to use a more recent version according to this: https://devcenter.heroku.com/articles/clojure-support#setting-clojure-cli-version

seancorfield 2021-05-29T22:34:48.164900Z

You would need to use https://clojure.org/releases/tools#v1.10.1.697 at the very oldest but preferably whatever is the latest version Heroku supports.

seancorfield 2021-05-29T22:57:23.165300Z

If you don’t want to try overriding the CLI version per that link and you want to continue to try to use depstar 1.0.94, you should read the docs for that version so you can see how to AOT the JAR:

clojure -A:depstar -m hf.depstar.uberjar pingcrm.jar -C -m pingcrm.system
from https://github.com/seancorfield/depstar/tree/v1.0.94 (the older version of the readme) That should produce a pingcrm.jar that can be run with just java -jar — although I suspect that old version might still require a pom.xml file for building an uberjar (which isn’t needed with the newer version).

2021-05-29T23:21:39.165700Z

There is a #cursive channel where the target audience might be more likely to know an answer to this.