Fork me on GitHub
#clojure
<
2021-05-29
>
Crispin04:05:47

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"

dpsutton05:05:36

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

seancorfield05:05:09

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

3
😍 3
dpsutton05:05:14

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

☝️ 3
💯 2
seancorfield05:05:20

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

seancorfield05:05:41

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

dpsutton05:05:56

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

🙌 9
km06:05:31

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

noisesmith18:06:42

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

borkdude09:05:47

@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.

borkdude10:05:52

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

borkdude10:05:20

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?

👍 3
Karol Wójcik10:05:17

Per request of @U04V15CAJ 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

borkdude14:05:35

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

p-himik14:05:26

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.

rmxm17:05:18

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))

rmxm17:05:58

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)))

sandeep17:05:58

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

3
seancorfield17:05:38

That sounds like a #heroku question @spamails29?

seancorfield18:05:01

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…

3
sandeep18:05:12

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

sandeep18:05:52

since it is giving error while deploying

seancorfield19:05:58

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?

sandeep19:05:42

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

sandeep19:05:17

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

seancorfield19:05:00

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

seancorfield19:05:27

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

seancorfield19:05:46

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

sandeep20:05:20

tried looks like heroku is rejecting it

sandeep20:05:21

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

seancorfield22:05:44

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

seancorfield22:05:48

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.

seancorfield22:05:23

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).

sandeep07:05:09

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

sandeep14:05:04

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

p-himik18:05:51

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.

sandeep18:05:42

increased it to 180 same error

p-himik18:05:11

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

seancorfield18:05:09

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).

zendevil.eth20:05:21

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

phronmophobic20:05:41

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

seancorfield20:05:15

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.

reveal 6
seancorfield20:05:26

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.

Rob Haisfield21:05:37

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

6
andy.fingerhut23:05:39

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

Rob Haisfield01:05:16

Thank you for the pointer