Fork me on GitHub
#clojure
<
2020-02-17
>
gibb05:02:33

Is there anything like Phoenix Liveview in Clojure yet?

vemv10:02:14

While technically possible of course, it'd surprise me if there was an ambitious impl in Clojure I think Liveview assumes/promotes a tight integration between frontend and backend; you can do that in Rails or Phoenix (which dominate their respective languages), but not so much in Clojure where there's no dominant framework (or technique, approach, libraries, etc)

dmarjenburgh08:02:14

@uliashkevich That looks really interesting. Is it an IntelliJ plugin that requires Cursive?

Nico08:02:43

is there a go-to library for creating graph visualisations in clojure? I've found a few (dorothy, rhizome) that are unmaintained, and the graph data libraries (loom, ubergraph) seem to support creating visualisations but I can't see how to add friendly labels on nodes rather than having the keywords on them, label edges etc)

dominicm08:02:40

Dorothy works perfectly.

Jacques09:02:14

more general & not specific for graph vis. but Quil is basically a clojure wrapper for processing http://www.quil.info/

maxp08:02:20

hot to specify project github url in Clojars?

maxp08:02:15

... ok it was just a typo 🙂 tags <url> and <scm><url> in pom.xml - that was the answer.

teodorlu09:02:51

Hey! Does anyone know of a way to search the archives over at https://clojurians-log.clojureverse.org ?

teodorlu09:02:24

I did a site: google search, but it doesn't match recent additions.

sogaiu12:02:45

i also used site: at various search engines. perhaps you are already aware of this, but for some of the channels, recent content can be searched via zulipchat.

👍 4
Nico11:02:08

if I have lists that can be in the form ((:a :b :c) (:d :e :f) (:g :h :i)) or (((:a :b :c) (:d :e :f)) (:g :h :i)), how do I get them all into the first form?

Nico11:02:24

(although the extra nesting can be anywhere in the list, not just on the first two elements)

Nico11:02:37

basically, I want to flatten, but keep the lists at the lowest level instead of getting (:a :b :c :d :e :f)

teodorlu12:02:10

apply concat might be helpful

(apply concat
         '(((:a :b :c) (:d :e :f)) ((:g :h :i))))
  ;; => ((:a ::c) (:d :e :f) (:g :h :i))

teodorlu12:02:12

But it sounds like your problem might not be well specified. Is there any reason you've got such differences in your input format? If you want to cover loads of different cases, you're treading territory closer to parsers.

Nico12:02:17

oh, it's becuase I'm writing something hacky, honestly. I did it with (partition 3 (flatten list)) (as they're always 3 elements)

flowthing12:02:55

This is possibly more of a JVM thing than a Clojure thing, but maybe someone knows the answer... Given a deps.edn like this:

{:paths ["resources"]}
If I start a Clojure REPL when resources doesn’t exist, then create resources/test.txt and try to get a hold of it with ( "test.txt"), I get nil. However, if I restart the REPL and run ( "test.txt"), I get the resource. It appears that resources must exist before I start the REPL, but test.txt doesn't. That is, if resources already exists, I can create test.txt after starting the REPL and successfully get a hold of it. Does anyone know if there's some way to avoid having to create the resources directory prior to starting a REPL?

teodorlu12:02:31

@flowthing create resources/.gitkeep and track in VCS?

flowthing12:02:20

That's a good idea, I didn't know about .gitkeep. Thanks!

👍 4
teodorlu12:02:04

It's nothing special about the file name, just a convention. Git doesn't track folders, only files. And the dot makes it hidden 🙂

flowthing12:02:26

Ah, I see. Anyway, that should work, as long as nobody deletes the directory (in my actual case, it's not actually the resources directory I'm working with, it's a more transient thing).

👍 4
teodorlu12:02:46

Then Git creates the resources folder on git clone

Setzer2213:02:11

Is there a way to require some namespaces globally for a project? It'd be nice to have some commonly used helper fn/macros available everywhere in my project without manually requiring them in every new namespace

kwladyka13:02:32

~/.lein/profiles.clj for lein or ~/.clojure/deps.edn for deps.edn to set global configurations

👍 4
manutter5114:02:08

I would hate to have to maintain code that didn’t have all its dependencies listed in the :requires portion of the ns declaration.

👆 12
p-himik15:02:20

Unless it's not a dependency but something like https://github.com/dgrnbrg/spyscope

grounded_sage15:02:32

What is the difference between having a transducer placed on a channel or using the transducer when you take from the channel?

markmarkmark15:02:46

transducers placed on the channel are run when the value is put into the channel

markmarkmark15:02:33

one thing to watch out for is transducers that can produce nil since nil isn't allowed on channels.

👍 4
markmarkmark15:02:48

if you're using a filtering transducer on a buffered channel, you can avoid filling the buffer with stuff that will be filtered out, since they are dropped before being put into the buffer

Alex Miller (Clojure team)15:02:50

transducers placed on the channel may be run when the value is put into the channel, or may be run when consumed

👍 4
grounded_sage15:02:54

Ok it looks like I want to use pipeline I’m doing reads from S3 as part of my transducer. So do I want pipeline-blocking?

Alex Miller (Clojure team)15:02:08

depends how you're doing the s3 reads - either pipeline-blocking or I believe aws-api allows you to be async, in which case you could probably use pipeline-async

grounded_sage15:02:12

I’m recursively fetching from S3 to process >400,000 json files. Since it only returns 1000 objects at a time I was planning on putting each 1000 onto a channel. From which I would have parallel processing done with a transducer and then all collected at the end (from the out channel?) for the final collection.

mauricio.szabo17:02:20

Hi, a simple question: how much work is to port Clojure to another runtime, for example, to generate Ruby code / bytecode (or something like this)? Where do I even start? It could be a "very simple, very slow" port in the beginning, I'm just trying to see if it's worth the effort, or if it's better to go to a "clojure-like language"

didibus06:02:20

Implementing the special forms gives you a lot. But, if you look at Clojure core, you'll see that one of the special form is the interop one. And then you'll see that a lot of the core library uses interop. And that some things are fully exposed as Java, like the persistent data-structures.

didibus06:02:09

Those are the parts that take some time to rebuild. Either you'd need to re-implement a lot of it in pure Clojure (which I think ClojureScript did a bit of), or you'd need to figure out how to expose the same functionality using the new runtime. And some runtimes might not offer as much, so it could be more or less work

didibus06:02:22

But its doable

didibus06:02:32

Just time consuming

mauricio.szabo14:02:39

I'm thinking about implementing a "Clojure in Clojure" for now: to port most things to Clojure as possible, then check what's the minimum necessary to implement on the "host language"

didibus17:02:48

That be nice. I think nornally its IO and system calls that absolutely need to be implemented in host language or using the special form interop

Nelson17:02:21

I’m very new to this language, but from the little I read I think you would need to implement all of clojure’s special forms. AFAIU the rest of the clojure language is built on top of those special forms.

gerred17:02:43

there's a couple examples of this.

gerred17:02:50

joker, lumo, planck.

borkdude19:02:27

lumo and planck are simply REPLs which give access to self-hosted ClojureScript

gerred17:02:44

actually, that's a bad example. joker's an interpreter

gerred17:02:48

it's not directly writing out Go MIR assembly

gerred17:02:27

but the steps would be largely similar, instead you'd convert to Go ASM instructions and potentially use the toolchain in that example.

gerred17:02:03

no matter what though, you're going to need all of the parts of a compiler. https://compilerbook.com/ and https://interpreterbook.com are great approachable resources to learn these topics. 🙂

bronsa17:02:14

it's not just about the special forms, clojure embraces the host platform and interops with it for a lot of its stdlib

👍 12
gerred17:02:41

yep. interacting with the linker in those runtimes is a big step.

gerred17:02:03

there's some other resources with https://github.com/bytecodealliance/ as well that you might find valuable in this approach. they're writing a lot of the lifting power for writing compilers and interpreters for WebAssembly and WASI.

gerred17:02:13

so there's a lot of these plumbing tools if you want to practice by going to that particular platform.

gerred17:02:16

as @bronsa mentioned though, potentially way more work being native to that platform and it's tooling than writing a standalone compiler/interpreter/linker/etc. 🙂

zilti18:02:04

I was also thinking about poking around trying to make an implementation in Truffle

jeroenvandijk19:02:56

Would be interesting to do voor Sci. I heard that it could theoretically reach the speed of normal Clojure via Truffle

jeroenvandijk19:02:04

I'm also wondering if it would help create native libraries. Right now you preferably compile everything together to make the code loading fast enough

Eduardo Mata19:02:59

Is this a proper way to convert time for Central Time? using java-time https://github.com/dm3/clojure.java-time

(as-> time t
    (time/local-date-time "yyyy-MM-dd HH:mm:ss" t)
    (time/zoned-date-time t "US/Central")
    (time/with-zone-same-instant t "UTC")
    (time/format (time/formatter :iso-offset-date-time) t))

Ada Des Etages22:02:35

Not sure if a library would be overkill, but I've been having a good experience with https://juxt.pro/tick/docs/index.html for time stuff.

Eduardo Mata19:02:22

An example is, I have a dataset where the records have a created-time somewhere in Mountain Time in Colorado. I have to convert the created Time to US/Central, however, I saw this approach to apply zone same instant to UTC