Fork me on GitHub
#clojure
<
2020-08-20
>
kenny02:08:36

Is there anyway to get a release for this issue? https://clojure.atlassian.net/browse/DIMAP-15. It looks like the fix is https://github.com/clojure/data.int-map/commits/master but there’s been no release for ~3 years.

seancorfield02:08:37

Hmm, no release for 4 years -- and this (and DIMAP-14) were fixed 3 years ago. I looked at https://clojure.org/community/contrib_libs but it's not even listed there so I don't even know what its status is supposed to be at this point @kenny 😐

😢 3
kenny02:08:27

Thanks for that contrib list reference. I hadn’t seen that before.

seancorfield02:08:15

I think it's probably reasonable to assume it's "Inactive" in those terms.

3
Alex Miller (Clojure team)04:08:50

added, I'd say it's stable, should be working fine

kenny15:08:22

fyi, that data int map link goes to https://clojure.github.io/data.int-map/ which is a 404.

Alex Miller (Clojure team)15:08:37

yeah, the docs need to be gen'ed for it

kenny15:08:23

Ah, got it.

seancorfield02:08:43

I don't have permission to cut a release on http://build.clojure.org otherwise I'd be happy to update the readme/changelog etc and put a release out. @alexmiller is anyone considered a maintainer for this lib these days?

kenny02:08:00

That’d be awesome if you’d be able to! We can work around this internally too. Just seems sad to have the latest version be broken in a pretty bad way.

seancorfield02:08:36

I just tried to run mvn test locally and it doesn't build/run...

kenny02:08:09

Oh no... perhaps that’s why no one cut a release.

seancorfield02:08:25

It doesn't seem to build/run on the CI box tho'...

kenny02:08:46

I’m quite curious why it would’ve stopped working. Maybe it never worked?

seancorfield02:08:36

Ah, it needs pom.xml updating for the parent pom.

kenny03:08:13

Why’d it stop working? If everything referred to immutable artifacts, I’d think it would work “until the end of time”

seancorfield03:08:26

The build environment overrides some stuff that you don't have in the local env.

seancorfield03:08:45

So the parent pom version is likely overridden, I suspect that's all it is.

seancorfield03:08:52

Maven... ¯\(ツ)

😩 3
Alex Miller (Clojure team)03:08:14

I think it's just the jenkins jobs that need to be refreshed, I'll take a look

Alex Miller (Clojure team)03:08:39

it's not the parent pom, this was due to the default Clojure version that was used during compile - we only build/test with clojure 1.7+ now

Alex Miller (Clojure team)03:08:42

anyhow, working now and I kicked off a release build

3
Alex Miller (Clojure team)04:08:59

ok, org.clojure/data.int-map 1.0.0 is out there now. I closed the DIMAP-14 and DIMAP-15 tickets

kenny04:08:59

Thank you Alex!

seancorfield04:08:21

Thank you Alex!

seancorfield04:08:00

@alexmiller FWIW, when I first tried to build it tonight, it failed with

[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ data.int-map ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 4 source files to /Developer/clojure/data.int-map/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Source option 6 is no longer supported. Use 7 or later.
[ERROR] Target option 6 is no longer supported. Use 7 or later.
[INFO] 2 errors
so I updated the parent pom version from 0.2.2 to 1.0.0 here
<parent>
    <groupId>org.clojure</groupId>
    <artifactId>pom.contrib</artifactId>
    <version>0.2.2</version>
  </parent>
and then mvn test ran just fine. After you did the release, that has 1.0.0 and it builds/runs/locally just fine. And that was one of the changes you made https://github.com/clojure/data.int-map/commit/f3febf5d3ac0632f58bb9623d99c41a562aafebf before the release.

seancorfield04:08:35

(I didn't touch the clojure.version in my copy when I updated the parent pom -- so that's why I said it was the parent pom)

bobbycalderwood04:08:43

Hi Clojurians! My company, Evident Systems, just launched a product written in Clojure and especially ClojureScript called oNote https://onote.com/. oNote is an Event Modeling (https://eventmodeling.org/) platform to help software teams design, implement, and operate simpler systems. It’s still very early, but I’d really appreciate any feedback from the Clojure community either in a thread off this message, or in DM to me. Thanks!

👍 9
millettjon01:08:59

Is it possible to create an account with email?

svt07:08:58

is there any tool which can combine the functionality of cloverage and kaocha?

grounded_sage10:08:53

It seems macros silently fail at expansion. I’ve had some experiences of macros not existing because of a var not existing. Tbh I’m not sure why they fail. Is this a known issue? I’m currently working with cross platform macros so this is both a Clojure and clojurescript question. I think one place I tripped up on recently was self requiring the namespace with :require-macros. If I miss a macro that is actually used inside of another macro. Everything seemed to compile without error or warning. Would appreciate any material or references for learning more deeply about Clojure macros.

p-himik10:08:36

I found this to be a great material, if a bit entry-level: https://www.braveclojure.com/writing-macros/

grounded_sage10:08:47

@U2FRKM4TW that is always my first point of reference when looking for a bit more guidance 🙂

Ian Fernandez13:08:43

@U3Y18N0UC knows some good resource?

mauricio.szabo13:08:46

@U05095F2K this will probably help you a lot: https://code.thheller.com/blog/shadow-cljs/2019/10/12/clojurescript-macros.html That's how I found out how to write good macros in ClojureScript.

mauricio.szabo13:08:47

Also, if you're not using it yet, I really recommend shadow-cljs for ClojureScript. In the past, I had lots of problems with "code is compiling but things fail", but I almost never see it anymore with Shadow-CLJS

grounded_sage13:08:22

I use shadow. I have seen this post several times I do check it from time to time. I am hoping for a deeper dive but I guess most of that would come from actually delving more into the compiler

mauricio.szabo14:08:00

I believe the best way to debug it is to print the result of macroexpand-1. On ClojureScript, I believe that it'll print in the same console as shadow-cljs' watch process

grounded_sage15:08:10

The problem I had was that I wasn’t aware that macros failed until way later. Once I knew they failed it was easy to debug them. But I didn’t get any warnings that a macro was using a function that wasn’t available for example.

p-himik15:08:11

That's because the macro didn't fail. It's the generated code that fails.

p-himik15:08:52

It's more or less the same if you wrote some incorrect code in an NS and then loaded that NS with a call to (require ...) in runtime. Maybe it's possible to guard against such things, I don't know.

grounded_sage17:08:00

yes perhaps the way I phrased it was incorrect. I’m somewhat leaning towards having a convention of running a test on macros.

Daniel Schlager14:08:40

Hi Clojurians, I hope this question isn’t too silly, but I'm getting nowhere here. I got this xml:

(def xml-text "<text>abc<p>defgh<hi>ij</hi>klmn</p><p>opqrs</p></text>")
(def xml-doc (-> xml-text .getBytes java.io.ByteArrayInputStream. parse))
Which results in this:
{:tag :text,
 :attrs {},
 :content
 ("abc"
  {:tag :p,
   :attrs {},
   :content ("defgh" {:tag :hi, :attrs {}, :content ("ij")} "klmn")}
  {:tag :p, :attrs {}, :content ("opqrs")})}
I need to construct the following output:
("abc" "defgh" "ij" "klmn" "opqrs")
I’ve tried
(for [x (xml-seq xml-doc)] (first (:content x)))
But i only get
("abc" nil "defgh" nil "ij" nil nil "opqrs" nil)
„klmn“ is missing here. Because it’s outside of the :content ? Thanks for your help.

Alex Miller (Clojure team)14:08:20

well you're doing first - that's ignoring the rest of the child content

Alex Miller (Clojure team)14:08:00

content is a vector or sequence of children and "klmn" is the second text node

Daniel Schlager14:08:23

But how to get the second node to be attached to the list?

Alex Miller (Clojure team)14:08:08

I wouldn't use for to do this

Alex Miller (Clojure team)14:08:11

if you want to look at all nodes, you could do something like (mapcat :content (xml-seq xml-doc))

Alex Miller (Clojure team)14:08:55

and then filter the nils:

Alex Miller (Clojure team)14:08:16

(->> xml-doc xml-seq (mapcat :content) (remove nil?))

dpsutton14:08:19

is there no tree-seq for xml? figured there would be one

Alex Miller (Clojure team)14:08:38

you can use tree-seq - it's generic

Alex Miller (Clojure team)14:08:01

but xml-seq is that basically

dpsutton14:08:23

yeah that's what i was thinking of. figured there was one that knew what branches and children were

Daniel Schlager15:08:36

@alexmiller I've tried it, but I can't figure it out

(->> xml-doc xml-seq (mapcat :content) (remove nil?))
("abc"
 {:tag :p,
  :attrs {},
  :content ("defgh" {:tag :hi, :attrs {}, :content ("ij")} "klmn")}
 {:tag :p, :attrs {}, :content ("opqrs")}
 "defgh"
 {:tag :hi, :attrs {}, :content ("ij")}
 "klmn"
 "ij"
 "opqrs")

Daniel Schlager15:08:54

Sorry I'm a beginner with Clojure

Daniel Schlager15:08:38

I've found this one http://josf.info/blog/2014/10/02/practical-zippers-extracting-text-with-enlive/ Not the path I wanted to take, but this is how I get ahead. Thanks for your help.

flowthing17:08:41

I’m not sure why I find myself advocating XPath and XSLT so much recently, but with XPath, you could just do something like this:

λ clj -Sdeps '{:deps {me.flowthing/sigel {:mvn/version "1.0.0"}}}'
Clojure 1.10.1
user=> (require '[sigel.xpath.core :as xpath])
nil
user=> (map str (xpath/select "<text>abc<p>defgh<hi>ij</hi>klmn</p><p>opqrs</p></text>" "//text()"))
("abc" "defgh" "ij" "klmn" "opqrs")

lilactown15:08:08

FWIW it seems like at the point you got to w/ the suggestions here, you could filter out the non-string values and be done?

Nikolas Pafitis20:08:11

?Hey guys, could anyone help me out with calling Clojure from Java interop. Mainly, how would i import the ManyToManyChannels class from core.async that is defined using deftype into my Java class??

Alex Miller (Clojure team)20:08:16

you probably shouldn't use that class directly, but you would just import it like any Java class

Nikolas Pafitis20:08:20

So i'm importing like this

import clojure.core.async.impl.channels.ManyToManyChannel;

Alex Miller (Clojure team)20:08:33

I guess you would need a compiled version of core.async for that to work

Nikolas Pafitis20:08:42

And my IDE also recognizes it (using Cursive/Intellij)

Alex Miller (Clojure team)20:08:11

what are you going to do with it?

Nikolas Pafitis20:08:46

I'm creating a DSL using clojure, but i want to give to the user some kind of Java API as well. I want to create a Base implementation of a class that will have methods which will receive clojure objects and that base implementation will translate those to Java POJOs which in turn will be passed to the interface methods that the user has to implement.

Nikolas Pafitis20:08:21

I can import other classes like PersistentArrayMap

Nikolas Pafitis20:08:35

and then convert it to a Java POJO no problem

Nikolas Pafitis20:08:10

But PersistentArrayMap has been defined in Java in clojure.core while classes like ManyToManyChannel are defiined using deftype

Nikolas Pafitis20:08:18

i can find many sources for Clojure calling java, that's no problem. But not many for Java calling clojure except the few stuff that's on their main website.

Nikolas Pafitis20:08:25

I guess i'll just use Object instead

Alex Miller (Clojure team)20:08:56

my standard advice for this is to: 1. define the Java API you want using Java interfaces - this can have precise types, javadoc, etc 2. implement the Java API using Clojure 3. use the Clojure Java API to implement the factory "hook" that gives Java users the impl

🙌 3
Alex Miller (Clojure team)20:08:50

https://github.com/puredanger/clojure-from-java is an example (maybe not the best impl example, but follows this pattern)

Nikolas Pafitis20:08:55

Yes this is what i would usually do, but this scenario is different and i'm having difficulty explaining.

Nikolas Pafitis20:08:21

Thanks for the help anyways

Alex Miller (Clojure team)20:08:24

those deftype classes don't exist until you load those namespaces

Alex Miller (Clojure team)20:08:23

so either they need to be AOT compiled and available or you need to use Clojure enough to load the namespace and have the side effect of loading those deftype classes dynamically. if you need the actual class reference in Java (for a type-based check for example, then you have to AOT)

Nikolas Pafitis20:08:31

Hmmm, so but if i have a clojure/java lein project (as i currently do) how do i AOT dependencies (like core.async)?

Alex Miller (Clojure team)20:08:02

well, it depends a bit. but you could probably :aot :all

Nikolas Pafitis20:08:31

Yeah, i do that already.

Nikolas Pafitis20:08:17

I guess it doesn't matter anyways

Nikolas Pafitis20:08:27

I resorted to doing

IFn put_Bang = Clojure.var("clojure.core.async", "put!");
put_Bang.invoke(this.channel, this.barToClojureMap(bar));

Nikolas Pafitis20:08:34

where this.channel is of type Object

Nikolas Pafitis20:08:45

this is hidden from the user anyways

Alex Miller (Clojure team)20:08:07

yeah, the type is truly not important anyways here - IFn.invoke takes Objects

Alex Miller (Clojure team)20:08:28

the whole "dynamically typed" thing

Nikolas Pafitis20:08:19

Thanks for the help, much appreciated

lpan21:08:00

Hi everyone, it seems that destructuring doesn't work in macros. Wondering if there is a workaround. Thanks! 🙏

dominicm21:08:19

I think this isn't the same as what's being asked

potetm21:08:37

yeah prolly

dominicm21:08:53

Link is about destructuring parameters. Question is about use.

👍 3
lpan21:08:38

Thanks for sharing anyway 🙂

dominicm21:08:24

@lpan not for this case. In a macro, bindings must be gensym (end with #) in order to work. But :keys won't work in that case, because it's looking for the wrong key.

lpan21:08:15

got it 👍 I ended up doing

(let [{k0# :k0}] ....)

👌 3
potetm21:08:57

you can get around this by avoiding :keys