clojure

New to Clojure? Try the #beginners channel. Official docs: https://clojure.org/ Searchable message archives: https://clojurians-log.clojureverse.org/
dpsutton 2020-10-04T00:02:21.479700Z

You’re using the file on the file system which doesn’t exist when all you have is a jar. Use http://clojure.Java.io/resource

seancorfield 2020-10-04T00:04:53.479800Z

Datalog perhaps?

seancorfield 2020-10-04T00:05:35.480Z

Implemented over Clojure data: https://github.com/tonsky/datascript

Eamonn Sullivan 2020-10-04T00:22:37.480300Z

I'm sorry, I'm really, really stupid when it comes to building things in the jvm world. Do I need to do something else (in addition to this) in the pom.xml file? Now I just get

Execution error (IllegalArgumentException) at bbc.dpub.github-pr-tool/eval138$loading (github_pr_tool.clj:1).
Cannot open <nil> as a Reader.

Eamonn Sullivan 2020-10-04T00:23:58.480500Z

That's probably confusing -- I'm trying to load the library in a github-pr-tool and it just doesn't work.

Eamonn Sullivan 2020-10-04T00:24:47.480700Z

This is the library I'm trying to load: https://clojars.org/eamonnsullivan/github-pr-lib

Eamonn Sullivan 2020-10-04T00:40:37.481Z

Fix it. Just me working too late. Can't see straight.

2020-10-04T02:10:47.481200Z

The reason Im using it is simply because it was the first thing that google brought up when dealing with dates. Its a throw away project so I didnt look to deep into it.

👍 1
2020-10-04T02:55:53.484100Z

I thought about it, but I feel asking non Clojure devs to learn datalog isn't that much better then asking them to learn how to map/filter in Clojure itself. Which is what I have now, just take some Clojure code.

jamesleonis 2020-10-04T03:01:30.487700Z

I have a hard question that might not have an answer. I'm trying to build up an ns form from nothing but the surrounding REPL environment instead of Files. I can infer 90% of a given namespace's :require form from the interns and aliases. However a non-aliased namespace is giving me a headache. Consider the following ns form:

(ns some.awesome.namespace
  (:require [clojure.set :as cset]             ; This can be inferred from 'ns-alias
            [clojure.test :refer [is deftest]] ; This can be inferred from 'ns-refers and some poking
            clojure.string                     ; this is completely invisible to any known query
))
Is there a way to discover such a dependency on a naked symbol like 'clojure.string above, but without a file and/or existing 'ns form? I can see it in 'all-ns, so I know it's loaded...

dominicm 2020-10-04T08:40:11.493800Z

@jamesleonis palletops ns-reload hooks load-lib to do this. Might be worth a poke.

jamesleonis 2020-10-04T21:48:18.497900Z

These are all good suggestions. I'll look more into pallet. At least now I know where some limitations are, which still helps.

seancorfield 2020-10-04T03:01:55.487800Z

I admit, having a SQL JDBC driver that works on named collections of hash maps is quite appealing 🙂

seancorfield 2020-10-04T03:07:21.488100Z

This might be a good starting point if you want to build a DSL for them to use? http://www.multunus.com/blog/2016/11/building-sql-like-dsl-clojure-part-1/

2020-10-04T04:50:09.488300Z

I don't necessarily know everything Clojure stores at run time that might be used to recover that relationship, but from a few minutes of looking in the Namespace.java source file within Clojure's implementation, it isn't obvious there is anything.

2020-10-04T04:51:06.488500Z

You can look at the list of all namespaces that are currently loaded, but without aliases, I can't think of any way to know if A requires B, or B requires A, or neither requires the other.

2020-10-04T04:52:09.488700Z

Out of curiosity, why do you want to try to build up an ns form from the run-time state of a Clojure JVM process?

jamesleonis 2020-10-04T05:10:58.488900Z

I'm on a lark where I build up a program purely from a REPL session. Ideally I would be able to query the REPL and output a file to "save" a session. I'm exploring more REPL-driven development ideas.

2020-10-04T05:48:48.489100Z

Note that the source code of Clojure functions is not saved anywhere when entered into a REPL, unless you write code yourself that saves the input text somewhere.

2020-10-04T05:51:05.489300Z

A straightforward technique would be to save all text entered into the REPL into a file, and then later load that file into a new Clojure JVM. That can fail in various ways, e.g. if in the original REPL session you were opening network connections, reading files from the file system (and later you tried loading that text on a different system that did not have those files), etc.

ido 2020-10-04T08:06:17.490700Z

hey clojurians. could you explain to me this?

=> (def data (vec (map inc (range 100000))))
=> (def xf (comp (map inc)(filter even?) (map #(* 2 %))))
=> (quick-bench (->> data (map inc)(filter even?) (map #(* 2 %))))
Execution time mean : 23.365075 ns
=> (quick-bench (into [] xf data))
Execution time mean : 6.275398 ms

ido 2020-10-04T08:09:58.491600Z

how come the transducer version is slower than the simple composition ->> version?

ep 2020-10-04T08:11:46.491700Z

i think because the first one is only returning LazySeq and the second one evaluates all

ep 2020-10-04T08:12:02.491900Z

(type (->> data (map inc) (filter even?) (map #(* 2 %))))
=> clojure.lang.LazySeq
(type (into [] xf data))
=> clojure.lang.PersistentVector

ido 2020-10-04T08:15:13.492100Z

oh missing a vec at the end 🙂

ido 2020-10-04T08:15:27.492300Z

(quick-bench (->> data (map inc)(filter even?) (map #(* 2 %)) vec))

Chris K 2020-10-04T08:24:43.493700Z

Just found this answer on stack overflow of how I can make a gui app using clojure but I don't know how to develop using this way... can someone reference me to a resource or things I should research and learn about?

Nobody yet suggested it, so I will: Browser as UI platform. You could write your app in Clojure, including an HTTP server and then develop the UI using anything from HTML to hiccup, ClojureScript and any of the billions of JS libaries you need. If you wanted consistent browser behaviour and "desktop app look'n'feel" you could bundle chrome with your app.

This seems to be how Light Table is distributed.

p-himik 2020-10-04T09:07:19.494100Z

They're talking about this: https://www.electronjs.org/

Chris K 2020-10-04T12:03:21.494700Z

thanks so I can use hiccup here?

p-himik 2020-10-04T12:15:58.494900Z

You can use HTML and JS there. But CLJS can be converted to JS, just like Hiccup can be converted to HTML.

p-himik 2020-10-04T12:16:20.495100Z

There are projects that bring Electron closer to CLJS.

littleli 2020-10-04T12:33:52.495300Z

It is not the only way. You can develop UI apps with OpenJFX. There is even a channel for it here #cljfx

Chris K 2020-10-04T12:39:04.495500Z

@ales.najmann cljfx didn't work too well for me so I wanted to try out the one from this stack overflow.

Chris K 2020-10-04T12:39:31.495700Z

@p-himik Do you know any resources to get me started working?

p-himik 2020-10-04T12:52:55.495900Z

Sorry, I don't.

phronmophobic 2020-10-04T16:38:39.497400Z

@sunchaesk, what kind of GUI app are you trying to make?

zilti 2020-10-04T20:17:54.497600Z

I can only second cljfx, it works really well, the only thing that's a bit cumbersome is to add support for new GUI elements from libraries

dominicm 2020-10-04T21:21:07.497800Z

Curious, is anyone aware of a java/clojure task/job queue with a dashboard available? I'm struggling, which surprises me given the java ecosystem. Maybe I'm not using the right term. I can find examples for ruby, php, nodejs quite easily.