Fork me on GitHub
#clojure
<
2017-04-26
>
sineer01:04:57

I'd like to know why the conn in {conn :conn {:keys [id]}... isn't placed inside the :keys [id] vector instead? In the following code: (helpers/defhandler todo-delete [{conn :conn {:keys [id]} :path-params :as req}] ...

sineer01:04:45

In the next handler it is placed inside the :keys vector like so: (helpers/defbefore todo-delete-all [{{:keys [conn db]} :request :as context}] ... I am wondering what's the difference ?

danielblack01:04:07

Question: Is there a alternative keyboard layout that clojurians use?

sineer01:04:43

@danielblack Why would you want a different keyboard layout? You can use whatever layout you like.

jeff.terrell01:04:58

@danielblack - I like Colemak, but my choice isn't related (in any direct way) to my choice of Clojure.

josh.freckleton03:04:16

lein uberjar works locally, but not from within a Dockerfile, Could not find artifact ...... in clojars ...., I'd like it to pull in deps from a checkouts link For some reason when I run lein uberjar from within a Dockerfile, it only looks for repos online and won't use anything I have locally. That means it's slow to build, since it must retrieve every repo every time (and slow to debug) And it won't grab my local-only deps... any suggestions?

danielcompton03:04:11

When you say "pull in deps from a checkouts link" are you lein installing them first?

josh.freckleton03:04:28

yes indeed, and I can see the correct version sitting in ~/.m2

danielcompton03:04:47

have you run -v "$HOME"/.m2:/root/.m2?

danielcompton03:04:01

to mount your local m2 into the Docker's m2?

josh.freckleton03:04:19

ah, no, is that a docker command?

josh.freckleton03:04:34

(i'm new to docker)

danielcompton03:04:08

have a look at that run command

josh.freckleton03:04:33

checking it out now, it looks promising thanks!

josh.freckleton03:04:52

(ps, thats amazing how you can always debug other peoples problems from afar)

isankhairul06:04:07

@not-raspberry @ska thanks for reply my question

dominicm13:04:51

@sophiago meta-merge does this

sophiago13:04:09

@stuartsierra I'm confused. This was committed in 1.3?

Lambda/Sierra13:04:29

@sophiago It was a piece of old "clojure-contrib" that was not included in the migration.

Lambda/Sierra13:04:42

It's been copied in various "utility" libraries since.

Alex Miller (Clojure team)13:04:50

Rich weighed in his opinions there, but no one has ever taken the next steps with it

spei13:04:23

it says that it's in other libraries?

sophiago13:04:33

It's a bit confusing what "vague semantics" means wrt to this.

Alex Miller (Clojure team)13:04:08

translating Rich-speak, it means there is no description of what “deep” merge actually means

Alex Miller (Clojure team)13:04:57

the fact that there are variants is itself instructive - typically the variations are specifically around the points of ambiguity

sophiago13:04:30

I can understand to some degree. I'm thinking of numerous edge cases in how this would work myself.

sophiago13:04:48

i.e. how does it behave when keys don't match?

Alex Miller (Clojure team)13:04:51

merge docstring says more, most importantly that it is conj-based.

Alex Miller (Clojure team)13:04:14

conj is not a deep operation

Alex Miller (Clojure team)13:04:34

so I think the question is, what does deep-merge mean in that context?

sophiago13:04:14

I suppose "recursive" would be more descriptive.

mpenet13:04:24

it could/should be named differently (not mentioning "merge")

Alex Miller (Clojure team)14:04:05

I think that’s a fruitful thing to talk about :)

Alex Miller (Clojure team)14:04:06

lots of edge cases around absent/nil/empty colls

Alex Miller (Clojure team)14:04:44

having some example use cases helps with this

Alex Miller (Clojure team)14:04:48

ticket has none of this

sophiago14:04:54

Welp, I suppose I'll see how much I end up needing to use it and whether I have any more thoughts that warrant putting together a version for a JIRA ticket. There are many edge cases in something like this. I was thinking it could be handled well similar to the specter library, but I was told it's not designed for working with multiple data structures. So adding this function to core would imply taking some stance on how it should behave and communicating that well.

Alex Miller (Clojure team)14:04:02

or in Rich-speak, “solution thinking” - here’s some code, please add it rather than “problem-oriented thinking” that starts from a good description of the problem and consideration of alternatives

sophiago14:04:09

Right. That's why I liked specter's approach: it comprehensively addresses a structural problem Clojure has working with recursive data structures. But the solution there is quite heavy for anything I'd want to implement.

sophiago15:04:59

How would I quote the reference of an argument? So in other words: (defn foo [x] (print 'x)) (foo bar) => x whereas I want (defn foo [x] (print 'x)) (foo bar) => bar

bronsa15:04:12

use a macro

bronsa15:04:17

functions can't do that

sophiago15:04:40

Do I still want to be quoting the argument, though?

sophiago15:04:16

Ok, I think I got it. Thanks!

matan17:04:54

might someone possibly remind me, why can we drop the org or com prefixes from our package names these days?

matan17:04:12

I see the practice very prevalent in the clojure community I think

matan17:04:45

or why java guys still use them 🙂

jeremyraines17:04:11

Regarding clojure.core.reducers, I’m curious why, given an expensive function f-heavy, you get a speedup with (pmap f-heavy coll) but not with (fold reducing-fn-that-calls-f-heavy coll)? Assume coll is big enough that fold should chunk/parallelize it

hiredman17:04:00

I never see that style used in professional clojure projects, but I still use it for my personal projects. Most professional projects are for businesses with a name that works well enough for avoiding collisions, but just using my name for personal projects seems weird.

matan17:04:18

@hiredman not sure which of the styles you are referring to

hiredman17:04:12

the reverse domain name style is the one I use for personal projects, but don't see used in projects that I get paid to work on

matan17:04:35

ahh.. just curious then, why do you use it at all? habit?

hiredman17:04:46

because I want some prefix that precludes collisions of names, and domain names sort of do that because there can be only one owner of a domain at a time

matan17:04:02

Yes, I see

hiredman17:04:04

something like a tag uri would be better, of course

matan17:04:22

how is that?

hiredman17:04:04

well, I may not always and forever own a domain, so ideally names would refer to a domain for the time period in which it is mine

hiredman17:04:17

but that is really off in to the weeds

hiredman17:04:49

a lot of opensource stuff in clojure land eschews domain name package names

matan17:04:39

a lot of stuff in clojure makes it a point to eschew other stuff

matan17:04:53

and then later we re-introduce what is missing e.g. clojure.spec adding validations for function inputs. Sometimes it occurs to me that if the idea of type safety had been reduced to validations rather than tossed away, we might have had good validations api much, much earlier on

stephenmhopper17:04:22

Is anyone using some form of protobuf with Clojure these days? I’m trying to figure out which library to use. It seems like there’s a few different forks out there as well as a lein-protobuf plugin, but none of them seem to be working properly / maintained

zane18:04:38

I, too, am curious about this.

stephenmhopper18:04:57

Yeah, it looks like there’s a billion different forks of each project, so I’m not sure what’s going on here. It certainly seems like the original maintainers have moved on several times over

stephenmhopper18:04:09

Part of me wants to just fork the project and make it work for me

stephenmhopper18:04:34

The other part of me wants to just start from scratch and do it right, but that seems to be far more work than I’m interested in at the moment. What’s your situation?

zane18:04:54

The immediate need isn't there for me. I'm just trying to scope out potential options just in case.

matan18:04:39

Why not just use the original java libraries? it will also bypass any bugs introduced by clojure wrappers

j-po09:04:55

Or maybe the bugs will all be written by you as you write your own clojure wrapper...

nbardy18:04:36

Does anyone know of any languages provided a type system that can do something like spec does. i.e. Granularity, flexibility, and expressiveness using predicates.

Alex Miller (Clojure team)18:04:22

spec is inspired in part by Racket’s contract system

nbardy19:04:31

@alexmiller Sorry. I wasn't particularly clear. I was looking for something that does expressive types(contracts) at runtime.

nbardy19:04:45

compile time* not at runtime.

tbaldridge19:04:51

@nbardy compile-time and "predicates" are fairly hard to combine. Does long? unify with int? perhaps, but what about long? and customer-id?. Predicates are very open-ended and allow you to leverage a entire language. That doesn't fit very well with static analysis. About the best you can do is write specialized checks for "blessed" predicates

tbaldridge19:04:48

for example it would be possible to perform static analysis on s/keys but if someone wrote their own version of s/keys it'd be very hard to write a static analysis system that could pick up that m/my-keys could unify with a s/keys

Alex Miller (Clojure team)19:04:07

Dialyzer? I don't know enough about it

hiredman19:04:55

people have written spec inference things, which use static analysis to generate specs (rather than static analysis checking specs)

tbaldridge19:04:15

right, but I'd imagine even those fall apart with a sufficiently complex predicate.

ag22:04:21

if I want to zip with applying function to each element, how would I do this? e.g. have [1 2 3] want to zip into something that say multiples each key by 2: {1 2 2 4 3 6}

ag22:04:54

I can use reduce, maybe there’s nicer, elegant way? I think Haskell’s zipWith does something like that

seancorfield22:04:40

@ag (zipmap x (map (partial * 2) x))

tanzoniteblack22:04:37

^^^ in most cases I would probably still use reduce so that the program only walks the collection once (`map` will walk x once to apply partial, zipmap will walk that output along side x to create the final map). Probably a very very minor performance/memory performance between the two though

hiredman22:04:12

user=> (into {} (map (fn [i] [(* 2 i) i])) [1 2 3])
{2 1, 4 2, 6 3}
user=>

seancorfield23:04:08

As usual, I forget the transducer approach. Yeah, that would be better. Although [i (* 2 i)] was what @ag asked for.

bradford23:04:05

Hey fam. Is there a difference between returning like, HTML code vs. a jpg image in a Ring response? Do I need to set :body for HTML and :content for binary?