Fork me on GitHub
#clojure
<
2018-02-20
>
qqq00:02:26

is there a builtin for (vec (mapcat ... )) ?

arrdem00:02:13

but you could use the transducer form of mapcat to produce a vector directly

noisesmith01:02:56

(into [] (mapcat f) ...) for the two arg case I guess

arrdem01:02:20

@radomski what are you trying to do here? transduce as a construct isn't intended for producing side-effects like this. doseq or something else would be more idiomatic.

noisesmith01:02:04

you could just use run! if you want to execute some code for everything in a coll

noisesmith01:02:26

(run! prn (get-agencies db))

Ryan Radomski01:02:57

This isn't the core part of my app. I was just curious because I was printing stuff to see what was going on with my transducers

noisesmith01:02:41

I guess there's always (comp txf (partial map #(doto % println))) or whatever

souenzzo02:02:45

nice use of doto macro Much better then my #(do (prn %) %)

noisesmith01:02:57

that returns a new transducer, that does what txf does but also prints

Vincent Cantin07:02:18

Why some parts of the docs are pointing to the source code and other don't? What can we do as contributors to make it link to the source code everywhere? - source code: https://clojuredocs.org/clojure.core/tree-seq - no source code: https://clojuredocs.org/clojure.walk/walk

andy.fingerhut07:02:37

Not sure. That is probably best filed as an issue for the ClojureDocs site developers.

andy.fingerhut08:02:23

The home page has a "open a ticket" link near the bottom left.

andy.fingerhut08:02:48

The Clojure Grimoire is another site that may have more easily available source code excerpts: https://www.conj.io

andy.fingerhut08:02:08

There is also (source clojure.walk/walk) at a Clojure REPL.

Olical09:02:20

Would anyone with some experience of the new CLI and deps system be able to cast their eye over this "Hello, World!"? I was mainly wondering if I actually require a Makefile like that to make it easier to use. I saw some documentation saying I could put the -m argument in deps.edn, but then couldn't actually get it to work at all. Just trying to do the simplest possible thing but in the idiomatic way right now.

Olical09:02:25

> airplane cockpits

Olical09:02:51

Hah, I've never seen that before but I know what you mean.

Olical09:02:44

Thanks for the link, your post the other day is what reminded me that I wanted to try a project without lein, I should've checked your post again really.

Olical09:02:07

Ah, and you're using the test runner. I was considering that, but ended up taking the simplest possible approach for now since I felt I didn't need any filtering of tests etc (yet). I am slightly worried about what I'll do when I reach the point where I want ClojureScript stuff though...

Olical09:02:46

Also not sure how I'll package it up and publish it to clojars, maybe I should just keep plodding along and write up what I find for newcomers.

roklenarcic09:02:41

I'm using HugSQL and there's a pattern that keeps coming up that I can't solve without lots of embedded clojure code in my queries. Partial update. Let's say I have 7 columns, but my parameter map only has 4 of them. I want to update only 4 of them. How would you achieve that in hugsql?

roklenarcic10:02:07

Exactly, that's how I solved it. But I'm disappointed that there's no other solution than writing clojure code into every update and select filter and I have to

/* :require [clojure.string :as string]
            [hugsql.parameters :refer [identifier-param-quote]] */
in every query to bring join into scope.

roklenarcic10:02:10

also lacks support for namespaced param keys 😞

xtreak2911:02:23

Ok. I have used Honey SQL and found the below to be nice for updates :

(-> (helpers/update :films)
    (sset {:kind "dramatic"
           :watched true})
    (where [:= :kind "drama"])
    sql/format)
=> ["UPDATE films SET kind = ?, watched = TRUE WHERE kind = ?" "dramatic" "drama"]

josh_tackett15:02:46

Hey anyone know if I can run 2 different processes within the same project on a server? In other words, run both lein run for a long running engine, and also lein ring server-headless for an API

delaguardo16:02:38

lein run | tee engine.log & lein ring server-headless | tee server.log as an example. But for production you might want something more controlable)

noisesmith16:02:58

if possible, avoid lein on servers, it simplifies things a lot. You can use lein uberjar or lein ring uberjar as apropriate to make a standalone jar. There are multiple advantages, including the fact that you don’t need to worry about dep resolution and jar caching on your server, leiningen defaults provide arguments that are not apropriate for a server process, and if you have a staging environment, you can easily ensure that the same jar that passed staging tests gets run on production

noisesmith16:02:36

also, you don’t need aot or gen-class to create or run an uberjar, there’s always the option of java -cp my-uber.jar clojure.main -m my.ns

noisesmith16:02:43

as far as the question, I’d suggest using separate log files for each process, and there’s nothing about lein or java that prevents running many processes from one lein project

josh_tackett17:02:06

@U04V4KLKC @U051SS2EU Thanks guys. I'm going to go with 2 tmux sessions to more easily control the processes separately

souenzzo16:02:25

(pos-int? 1E10) ;; => false is it a bug or a feature?

noisesmith16:02:40

it’s not an integral type

noisesmith16:02:38

I think you want a different function if you want to know if you have a number with no trailing fractional amount

noisesmith16:02:46

penguin.babysit-test=> (doc pos-int?)
-------------------------
clojure.core/pos-int?
([x])
  Return true if x is a positive fixed precision integer
nil
- yes, it’s fixed precision only, so it is meant to return false for numeric types that are floating point

souenzzo16:02:17

Oh, ok. E will always be floaty. There is a short way to represente "huge" integers?

souenzzo16:02:29

(long 1E10) will do for now

Olical16:02:08

deps.edn question: Is anyone using it and deploying to Clojars? Or is everyone intending on using git shas? Related: Can you use git tags?

noisesmith16:02:13

sha only is supported, someone might make a tool to deploy to clojars but the original intention with deps.edn was to make something simpler, in other words, not make a build and deployment tool, just a dep resolver

noisesmith16:02:31

there is a tool to get an sha from a tag iirc

noisesmith16:02:33

@olical I’d be cautious about making deps in terms of tags - it’s easy to move a tag to a different commit, and github recycles usernames of deleted users

noisesmith16:02:03

between those two things you have a huge security problem

Olical16:02:50

That all makes sense, thanks. Mainly just curious about the tag part since I can't find much documentation on the subject. Wasn't sure if the goal was to have everyone sharing dependencies solely through git or if publishing jars somewhere is still a normal thing, there just isn't a built in way of doing it.

Olical16:02:46

All projects I've seen using deps.edn don't seem to be publishing their jars anywhere, was wondering if that's supposed to be like that long term.

noisesmith16:02:52

at least at one point deps.edn was explicitly not a competitor to lein or boot; it could be the community likes it enough to build the other things around it you’d need to replace lein or boot though

noisesmith16:02:29

at this point I think it’s too early to say what kind of ecosystem will build around it - as the tool wasn’t even meant to be part of a deployment / build ecosystem

noisesmith16:02:14

if deps.edn git support leads to a whole world of clojure projects that don’t have deployed jars, that would make me very sad personally

Olical16:02:33

Same, actually.

noisesmith16:02:45

jars are lighter weight for caching, more straightforward for reproducibility

noisesmith16:02:04

I’d assume the core cognitect folks are using maven actually - it’s what clojure itself uses

noisesmith16:02:19

they were never fans of the more elaborate tooling adopted by the community

Olical16:02:54

I mean, in transcriptor, there's no scripts or tooling at all. Does he just type out the full command to build and deploy it every time orrrr?...

Olical16:02:17

I'm interested in these non-lein flows right now 😅

dominicm16:02:05

I've got a build pipeline which works sans-lein. But I haven't tried it for a library yet.

chris16:02:17

if we step away from jars and towards git that would be very bad for the community

noisesmith16:02:31

since it’s on maven, I’d assume he used the mvn command line to build and deploy transcriptor - it’s odd that there’s not pom.xml in the repo though

chris16:02:46

go basically started that way and are trying to backport some sense of versions into the community

chris16:02:58

... it is not going well and I deal with it every day at work

noisesmith16:02:19

go uses tags too, which has led to problems (that’s why I know about that security problem with github recycling usernames btw - it’s a bug that hit go)

Olical16:02:26

Yeah, I didn't enjoy that part from my foray into Go. Well, I didn't enjoy much of my foray into Go...

Olical16:02:00

https://github.com/robert-stuttaford/bridge is a really good example of how you can plug a lot of these little tools together

Olical17:02:16

Maybe I'll just stick to lein for now, I just wanted to explore this world and found myself coming up with waaaaay more questions than actual solutions.

Olical17:02:30

Ah nice. Looks neat.

dominicm17:02:42

@U050AFD41 I think t.d.a does a much better job of this, by using sha pinning.

chris17:02:22

you can do that in go too, but that doesn't solve any of the other issues unfortunately

chris17:02:45

what if the repo changes hands

chris17:02:53

what if the user deletes their account on github

chris17:02:06

what if that username is recycled

chris17:02:21

it just solves the issue of tags being malleable

noisesmith17:02:27

with a recycled username, clashing an sha is still hard

chris17:02:43

oh yeah for sure, but then your stuff likely won't build

noisesmith17:02:47

it’s proven possible, but at least for now it is a huge amount of work

chris17:02:09

whereas if it's a jar it will still build even if the person deleted the repo so long as the jar is still on clojars or central or something

noisesmith17:02:15

regarding the cognitect transcriptor repo, I downloaded out of curiosity and there’s definitely a pom - my assumption is the pom was not checked into git either intentionally or accidentally

chris17:02:38

we are ascribing an absolutely unreasonable amount of power to github

dominicm17:02:48

> whereas if it's a jar it will still build even if the person deleted the repo so long as the jar is still on clojars or central or something So, maven has tighter guarantees here, I grant that. But because of the cache in ~/.gitlibs it's quite easy to mirror the git repo yourself.

noisesmith17:02:49

(I mean, not just an auto-generated just-enough-to-make-maven-happy pom, but an actual pom with license metadata and a git tag etc.)

dominicm17:02:10

And by that I mean, it's easy to recover something that's moved.

noisesmith17:02:45

@U09LZR36F right but there are existing tools and workflows to mirror all build deps or keep a custom cache with maven - that tooling doesn’t exist yet for git and might not ever

noisesmith17:02:20

not to mention relative disk space and file system usage of git repos vs. jars

noisesmith17:02:45

I can serve jars from s3, I can’t do that with git deps

dominicm17:02:29

Agree there's a gap right now. But I don't think the security concern of git dependencies holds up. I think the recoverability is weaker, but not necessarily outside of the realms of possibility. Caching is a place where there's a gap, and it'll be interesting to see how urgently it needs filling. Shaded jars are very popular now, which doesn't let you do caching per-dependency.

dominicm17:02:07

Git is inferior to maven in many ways, no disagreement from me there. But I don't think it's that bad.

juhoteperi17:02:20

GitHub tries to detect and reject SHA-1 collision attacks: https://github.com/blog/2338-sha-1-collision-detection-on-github-com

tbaldridge17:02:24

I thought from Rich's "Spec-ulation" keynote that it's pretty clear he wants to see a move away from deployed artifacts of any kind. At least that was my take-away from the talk.

dominicm17:02:33

@U07TDTQNL I don't recall much of a why from that. Is it buried in there? Do you remember what it was?

noisesmith17:02:06

I’ll have to watch that talk but I’m suspicious

tbaldridge17:02:15

The idea that artifacts are collections given arbitrary names. "I don't create a new version of my family when I put on a hat". That instead we should grow our codebases by adding new functions, not new collections of functions.

tbaldridge17:02:51

looking up another part of the talk ...

noisesmith17:02:45

I think the lyrics to “Papa Was A Rolling Stone” woudl disagree here, but I look forward to watching the talk and hearing the whole argument

ghadi17:02:36

i heard the same thing. why deploy an artifact when git is already content addressable

dominicm19:02:01

So, from listening to that I'm hearing more along the lines of "git has the properties we want, and your code is already there, why don't we just use that?" There's an argument to say that list is incomplete. One of my concerns is over naming. Short names are very popular in the clojure community, and that's going to cause collisions without a central registry.

Alex Miller (Clojure team)19:02:55

our recommendation on that is to either use a name you control (via dns, trademark, etc) or to combine an entity that conveys identity with your user identity in the project qualifier

Alex Miller (Clojure team)19:02:20

such if I create a “ring” project, then refer to the lib as github-puredanger/ring where github is the “identity host” and puredanger is the identity on that host. The combination of the two provides a globally non-colliding name.

Alex Miller (Clojure team)19:02:14

the fact that the clojure community uses short, non controlled names for qualification has never been a good idea

Alex Miller (Clojure team)19:02:37

which is why maven central doesn’t allow such things

dominicm19:02:05

https://github.com/juxt/ see every repo here for an example of such things 😂

Alex Miller (Clojure team)19:02:48

All of those would be fine if you referred to them as juxt/aero or whatever

dominicm19:02:10

But the clojars name is aero, not juxt/aero. But yes, we could change that.

dominicm19:02:34

We really should have done namespacing on the refs in aero from day #1 as well, and never did. Which is a bit of a frustration to me. Still figuring out how to cleanly exchange our way out of that without causing massive pain.

dominicm19:02:04

@U064X3EF3 I'm curious as to why this doesn't extend to namespaces? e.g. Why isn't it org.clojure.core? Seems that puredanger/ring would have ring/core.clj still, and that would still cause issues.

Alex Miller (Clojure team)20:02:45

it does extend to namespaces

Alex Miller (Clojure team)20:02:08

in the case of clojure, that’s a trademarked unique name, so the org is unnecessary

Alex Miller (Clojure team)20:02:52

and in the puredanger/ring example I would expect at least puredanger.ring namespace (or even something more like github-puredanger.ring) if it wasn’t puredanger but “jeff” or something

Alex Miller (Clojure team)20:02:14

in this case, http://puredanger.com is actually a domain I own, so :)

dominicm20:02:04

Makes sense. Cool 🙂 I suppose this gets harder if you consider that other juxt's may exist.

Alex Miller (Clojure team)20:02:52

yes, and that’s where the original sun guidelines recommend the full reverse dns, like pro.juxt

Alex Miller (Clojure team)20:02:14

that was for package names, but it’s reasonable advice for artifacts too

Alex Miller (Clojure team)20:02:21

like org.clojure/clojure

dominicm20:02:22

I always use io.dominic for that reason.

dominicm20:02:41

Someone should write all this down 😄

Alex Miller (Clojure team)21:02:04

yeah, I have a todo for it :)

Drew Verlee17:02:00

Anyone know any good resources on modeling a game using FSM?

sggdfgf18:02:36

what is the modern way to render web on server side?

sggdfgf18:02:10

is the ring and compujure still in fasion ? 🙂

noisesmith18:02:22

ring definitely - there's a few alternatives to compojure worth looking at, the most popular full featured template is probably luminus (it's used in the "web development with clojure" book which is likely the authority on the subject)

mike_ananev21:02:38

is there any updates about results of clojure annual survey 2017?

Alex Miller (Clojure team)21:02:49

no, sorry - pto from several of us has delayed progress on posting the results