clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
Oliver George 2020-11-22T02:05:28.048200Z

This surprised me....

user=> (#())
()
user=> ((fn []))
nil

Oliver George 2020-11-22T02:05:44.048600Z

Is it important/intentional that an anonymous function created with the literal #(…​) returns an empty list?

2020-11-22T02:19:49.050Z

I doubt it is intentional for any deep reason, but it is a consequence of the implementation

Jan K 2020-11-22T02:21:13.052100Z

(macroexpand '#()) => (fn* [] ())

2020-11-22T02:21:16.052200Z

A function created with #() always expands to a fn form that has a body wrapped in parens

dpsutton 2020-11-22T02:21:57.053100Z

you don't need the macroexpand in this case. just '#() will expand it

dpsutton 2020-11-22T02:22:54.054100Z

i suspect you are sending in a function maybe in a test? if so, the idiom (constantly nil) or whatever appropriate value is always the best way to accomplish this (in my opinion)

valerauko 2020-11-22T08:41:33.055100Z

Can anything be done about some-> boxing math?

user=> (some-> 1.12 (int) (pos?))
Boxed math warning, /tmp/form-init1986363389393762289.clj:3:35 - call: public static boolean clojure.lang.Numbers.isPos(java.lang.Object).

true
user=> (-> 1.12 (int) (pos?))
true

p-himik 2020-11-22T09:18:19.055200Z

I think only rewriting it with when or if with a proper tag can get rid of the boxing.

william 2020-11-22T11:22:22.059100Z

Hi, I just created a new clojurescript project via lein new figwheel hello_world. Then in the new folder, lein figwheel starts something, but I can never get the repl. If I connect to 0.0.0.0:3449 with my browser, I get the text Figwheel template. Checkout your developer console. and in my console, the error

GET <http://0.0.0.0:3449/js/compiled/hello_world.js>
Loading failed for the &lt;script&gt; with source "<http://0.0.0.0:3449/js/compiled/hello_world.js>".
and indeed in the resources/public/js/compiled/ folder of my project there's no hello_world.js. On the other hand, I can use figwheel on the flappy-birds demo. Does anyone have any idea on what's going on?

william 2020-11-22T11:31:27.060100Z

I think I got it (I was skipping npm install). And also, there's a clojurescript channel! Sorry 🙈

valerauko 2020-11-22T11:46:15.060300Z

is there any way to +1 issues https://clojure.atlassian.net/browse/CLJ-2365

borkdude 2020-11-22T12:21:23.060400Z

valerauko 2020-11-22T12:23:59.061Z

guess i'd need to log in for that then

borkdude 2020-11-22T12:24:47.061300Z

You can also vote on ask.clojure

valerauko 2020-11-22T12:37:22.061500Z

done that!

jmckitrick 2020-11-22T12:51:20.062600Z

Is ‘cucumber’ still relevant in Clojure land? Most of the libraries I’ve found seem stale.

2020-11-23T19:47:27.111Z

I'd expect the introduction of cucumber to be an ask from the product team, the clojure libs mean it's possible (and I think this has mainly happened where an organization migrated from mostly ruby dev to making new services in clojure)

kwladyka 2020-11-23T21:41:57.117300Z

heh it was like that in my current company, ruby and clojure

kwladyka 2020-11-23T21:44:16.117600Z

but as far as I know (i wasn’t there when this decision was made) it was about QA and consistency. So everyone use cucumber to make things the same for QA.

kwladyka 2020-11-23T21:45:08.117900Z

At least this was an idea 😉

2020-11-23T23:27:16.118300Z

yeah, my recent jobs didn't have qa (internal only tools...) so that stuff folded into product

John Oerter 2020-11-23T23:28:15.119500Z

I’ve had good experiences using Specflow for C# but have never tried in Clojure

valerauko 2020-11-22T13:04:37.062700Z

never heard of it, what does it do?

alexmiller 2020-11-22T14:31:02.064800Z

That’s the important bit, thanks. If you have a specific use case you’re running into, a comment there describing it would be very useful

John Oerter 2020-11-22T14:55:46.066Z

The BDD library, right? I would be interested to know how many Clojure users use this as well.

jmckitrick 2020-11-22T14:55:49.066200Z

It’s a Behavior Driven Development tool.

jmckitrick 2020-11-22T14:56:08.066400Z

Uses Gherkin syntax to define behavior and then test for impl.

jmckitrick 2020-11-22T14:56:14.066600Z

I did just find this:

jmckitrick 2020-11-22T14:56:16.066800Z

https://github.com/lambdaisland/kaocha-cucumber

kwladyka 2020-11-22T15:03:43.069200Z

I use cucumber everyday in my work. It works but It is bad idea to use it in project. Just don’t use it :)

kwladyka 2020-11-22T15:04:22.070Z

I use it because of legacy business decision, so I have to.

John Oerter 2020-11-22T15:07:32.071Z

@kwladyka what problems have you had?

valerauko 2020-11-22T15:12:26.071200Z

last I ran into it was trying to use .listFiles with a FileFilter

kwladyka 2020-11-22T15:14:47.073Z

In short words it makes code unnecessary complex and tests take longer.

kwladyka 2020-11-22T15:15:47.075600Z

You can write similar syntax using pure Clojure.

kwladyka 2020-11-22T15:16:57.078400Z

It is hard to describe that ad hoc, but keep your projects simple and don’t look fancy stuff :)

eoliphant 2020-11-22T15:18:44.080500Z

Hi, anyone know a way to read an EDN file that was mistakenly spit from a clojure seq via print vs pr or pr-str? Fortunately the structure is simple. it’s just a big vector of maps that only have a few keys. Just getting it in with all the map values as strings would work fine, as I could then do the transforms I need to the correct data types afterwards

John Oerter 2020-11-22T15:25:42.081200Z

Yes that makes sense. Thank you!

borkdude 2020-11-22T15:28:53.081600Z

@eloipoch small example?

eoliphant 2020-11-22T15:37:05.084100Z

sure here’s whats in my “edn” lol

{:KEY_VALS {:NGA_ID 1036089}, 
 :TABLE_OWNER EGMS, 
 :START_SCN 9525183027094M, 
 :XID 3A0013005E210100, 
 :LOGON_USER XXX, 
 :ROW_ID AABcYQAASAABtcmAAK, 
 :COMMIT_SCN 9525183027136M, 
 :TABLE_NAME NGA_BASE, 
 :OPERATION UPDATE, 
 :UNDO_CHANGE# 2M}
I think it’s making a best effort based on the first char or something. it doesn’t complain until it hits the :XID value about the value being a number

eoliphant 2020-11-22T15:37:25.084300Z

‘not’ being a number

eoliphant 2020-11-22T15:41:00.086900Z

In looking at the docs, wasn’t sure about how to handle that situation, as most what’s there seems to understandably be focused on handlers for tagged literals

borkdude 2020-11-22T15:42:33.087800Z

so you could start by placing a double quote before each comma, this seems a safe bet from your example

borkdude 2020-11-22T15:42:50.088500Z

and then work your way back to the first space and also place a double quote there?

borkdude 2020-11-22T15:43:19.089700Z

hmm, not exactly, but maybe something like this

2020-11-22T15:43:44.090600Z

I am guessing you might have thousands of those, though? If so, one might consider writing some kind of one-off text processing hack-ish program that uses regex to process each line and look for things that seem like they ought to have double quotes around them, and add them.

2020-11-22T15:43:56.091300Z

After that, then use clojure.edn/read on the resulting text file.

eoliphant 2020-11-22T15:44:45.092100Z

ah yeah, I can do that for sure. Just fixup the string first. I didn’t even think of that, was wondering if I could be done with some sort of otps/handlers to read-string. And yeah, only about 300,000 lool

2020-11-22T15:45:22.092800Z

I do not know of any variations or options on clojure.core/read, clojure.edn/read, or similar Clojure data readers that would accept that input.

borkdude 2020-11-22T15:45:51.094100Z

@eloipoch what you can also do is use edamame, which gives fairly accurate locations in its exceptions:

user=&gt; (require '[edamame.core :as e])
nil
user=&gt; (def ex (slurp "/tmp/example.edn"))
#'user/ex
user=&gt; (e/parse-string ex)
Execution error (ExceptionInfo) at clojure.tools.reader.impl.errors/throw-ex (errors.clj:34).
[line 4, col 23] Invalid number: 3A0013005E210100.
user=&gt; (ex-data *e)
{:type :reader-exception, :ex-kind :reader-error, :file nil, :line 4, :col 23}
and then fix it accordingly, in a loop

2020-11-22T15:46:47.095500Z

If there are 300,000, though, the one-off regex-based text processing program will probably be a lot faster.

eoliphant 2020-11-22T15:46:56.095800Z

but to you guys point, just fixing it prior is workable. fortunately the data, strucutre-wise are homogenous, so a regex or pretty simple algo, should allow me to stick the quotes in

2020-11-22T15:47:30.096300Z

especially if you can use the keyword names to avoid replacing things that shouldn't be.

borkdude 2020-11-22T15:48:28.097700Z

hmm, you can use edamame in a loop and just do search and replace on the invalid number. the rest will be parsed as symbols

borkdude 2020-11-22T15:49:11.098500Z

heck, that will even work with clojure.edn

eoliphant 2020-11-22T15:49:21.098800Z

yeap, i’m actually messing with it now as we speak with intellij’s regex find/replace. This came up at 2AM, so my mental backtracking algo, for my solution search wasn’t exactly working well lol

eoliphant 2020-11-22T15:50:00.099200Z

yah that works too

eoliphant 2020-11-22T15:50:55.099900Z

thanks a mil guys., Other set of eyes, the most important tool in comp sci lol

😁 1
dpsutton 2020-11-22T16:12:36.100600Z

I’d probably do a keyboard macro in emacs or vim and be done pretty quick

2020-11-22T16:43:58.100900Z

No problem. Also, you've probably already done it, but probably a good time to go back and change that print to pr

alexmiller 2020-11-22T16:54:59.102Z

If you can add it to the ask question, that’s where we will look for that info

2020-11-22T20:08:22.102700Z

Hello everyone 🙂 I am a fellow Clojure dev thinking about a potential future Clojure project in the message queues space. I’d like to know more about the interests of Clojurians in this space - with the aim of building something to eventually meet those needs. I made a short survey if you have a few minutes (it’s really short) https://account606590.typeform.com/to/sirkUS13 EDIT: looking at the first results, it takes about 1:20min to complete on average

adamfeldman 2020-11-26T15:50:03.233Z

Am curious to hear more about what you have in mind, and what pain points you’ve previously experienced. Survey feedback: The answer options for Q3 did not match the question 🙂. For Q4, I would have preferred to choose all that are acceptable to me, instead of just one.

2020-11-27T07:29:15.242200Z

Hi 😊 I'll definitely write more about the pain points. I don't want to influence the survey right now. How does Q3 not match ? It mean "or" as is: " (or (choose-own-tools you) (choose-team-tools you ) ). " Noted for Q4, I agree it would have been better. Feel free to comment extra choices in the free form.