Fork me on GitHub
#clojure
<
2018-09-26
>
lvh18:09:29

I have a project where dependencies are ostensibly being included from ~/.lein/profiles.clj into releases and I can't for the life of me figure out why: https://github.com/cloverage/cloverage/issues/228#issuecomment-424810468

hiredman18:09:41

it looks like ultra adds itself as a project dep

jesse.wertheim18:09:12

I like ultra, but that is sneaky

andy.fingerhut19:09:53

Eastwood has some very recent un-released changes that I think also make it behave this way. I've created an issue at the following link in case folks want to add any comments to it: https://github.com/jonase/eastwood/issues/286

seancorfield19:09:55

@andy.fingerhut I'm curious: why would Eastwood do that? What does it gain by inserting itself like that?

andy.fingerhut19:09:38

All currently released versions of Eastwood do not do this.

seancorfield19:09:59

(and it seems like venantius/ultra crops up regularly enough that it pretty much needs to be an FAQ in the Clojure world about "why are my dependencies broken?" ๐Ÿ™‚ )

andy.fingerhut19:09:12

It was a recently committed change, not yet part of any release, that I believe has such a change.

andy.fingerhut19:09:16

I wasn't involved in the decision on this change, only some debugging of some earlier Eastwood changes that prevented 0.2.9 from actually being used, and these changes were made by the current Eastwood maintainer as part of the fixes for that issue.

seancorfield19:09:58

Ah, I see what it's doing now. Previously, it used to add itself as a dependency if it wasn't already specified (via add-if-missing from leinjacker). Now, it looks for a plugin dependency if present and uses that to add itself as a (dev) dependency. And it only seems to do it while Eastwood is running inside Leiningen (`eval-in-project`).

seancorfield19:09:53

So it doesn't look like the behavior has really changed -- it's just dropped support for Leiningen 1.x and relies on core Leiningen stuff in 2.x to run itself now?

seancorfield19:09:54

I think the difference with Ultra is that it injects itself into your deps in all situations?

andy.fingerhut19:09:57

I have not dug into how ultra modifies things, or these recent Eastwood changes, enough to understand them fully. I raised the issue because I was pattern matching on "ultra behavior X causes some people problems. Hmm, that sounds similar to a recent Eastwood change that maybe shouldn't be released if it would cause the same problems."

andy.fingerhut19:09:19

If you have more details that might help make good decisions there, and have the time and interest to share your knowledge, that would be great.

seancorfield19:09:55

The above is based on 1) just now reading the entire commit list for Eastwood since the last release and 2) repeated complaints from people who've tripped over Ultra's behavior when they're not aware they're explicitly "using" it for anything... so I'm not sure I'm any more qualified than the next person )

slipset19:09:40

@seancorfield your reading of the dependency injection code in Eastwood very much resembles the intent of it.

andy.fingerhut19:09:58

@slipset Sorry if I am raising alarms for no good reason. My recent comment above gives what could loosely be called my thinking process here.

slipset19:09:58

Basically, as far as I understand, if you have Eastwood only listed as a plug-in, lein needs it as a dep to actually run it.

slipset19:09:46

@andy.fingerhut no problem. Iโ€™m just grateful for more eyes on this.

mattly19:09:53

I have a problem I'm not really sure how to go about solving, maybe someone can point me in the right direction

mattly20:09:45

for any given (small) collection of numbers, let's say [0 5 5 4], I need to change any duplicates such that they are the nearest non-duplicate value, say, [0 5 6 4] for this

mattly20:09:01

though [0 5 3 4] would work just as well for my purposes

mattly20:09:49

the actual changed value and distance of the change isn't as important as the numbers being unique, though ideally there would be as little change to the numbers as possible

mattly20:09:53

hm, now that I've rubber ducked the problem I've got an idea

gleisonsilva20:09:14

anyone has experience with this library to serialize as avro format? https://github.com/damballa/abracad

gleisonsilva20:09:49

I need to be able to serialize a java.sql.Date field value to Avro, but I'm not succeeding with that.

gleisonsilva20:09:04

I've tried "extending" the types following the example, but I can't figure out how to do properly...

noisesmith20:09:39

specifically what kind of error?

gleisonsilva20:09:02

SchemaParseException "date" is not a defined name.

gleisonsilva20:09:31

This is my code:

gleisonsilva20:09:33

(extend-type java.sql.Date
  avro/AvroSerializable
  (schema-name [_] "resultset")
  (field-get [this field] (case field :date (.getTime this)))
  (field-list [this] #{:date}))

(defn ->java.sql.Date
  [d] (java.sql.Date. d))

gleisonsilva20:09:25

But, I'm pretty sure it is incorrect, but I can't figure out how to make it work having just the little example in the project's README

gleisonsilva20:09:59

I couldn't fully understand how to glue the pieces in the example.

noisesmith20:09:47

defn lets you make a function with . in the name, but it clojure's compiler will blow up if you ever try to write code that calls it

noisesmith20:09:24

also -> in the name isn't a syntax, it's a convention - ->foo is the name of something that creates a foo

noisesmith20:09:55

so you probably want ->Date - then a reader would correctly understand it's a function that exists to create a Date

noisesmith20:09:15

other than that the code is incomplete but looks fine so far

noisesmith20:09:52

(though resultset is a weird name for a schema for a date type)

gleisonsilva21:09:00

I think that is the issue. In the project's example, the schema is named "ip.address"

noisesmith21:09:21

it just has to match the symbol used defining the schema, right?

gleisonsilva21:09:25

I mean, when extending, it is named "ip.address"

gleisonsilva21:09:41

then, in schema definition, it appears as 'ip.address

gleisonsilva21:09:07

then, in binding the readers, it appears as 'ip/address

gleisonsilva21:09:28

i couldn't understand why this / instead of .

noisesmith21:09:52

well I promise clojure would explode if you try to compile code that calls a function defn'd as ->java.sql.Date - the var resolution would blow up looking for a class that doesn't exist

noisesmith21:09:12

the / is syntactically significant in symbols, it creates a namespace

gleisonsilva21:09:17

i've tried just ->Date already, but not works

gleisonsilva21:09:52

ok, but there is no need to "match" with the name given to the namespace?

noisesmith21:09:55

OK, you don't have any code defining the schema yet - I'm just pointing out errors

noisesmith21:09:27

I wouldn't expect any need to match namespaces, and I wouldn't expect it to use namespaced keywords in that context

gleisonsilva21:09:33

i'm a little bit confusing on the use of a "pure string" when extending the types (`"ip.address"`) and, later, using a symbol 'ip.address

gleisonsilva21:09:09

have you seen the example that i'm referring to?

gleisonsilva21:09:40

do you think it is correct?

gleisonsilva21:09:04

i mean... could that example be wrong?

noisesmith21:09:45

it could be, but I have no reason to think it would be

lilactown21:09:13

for databases (other than datomic), do the majority of people prefer to use something like hugsql or do they just use clojure.java.jdbc?

lilactown21:09:36

I know almost nothing about DBs and want to keep it pretty status quo for this project

nickmbailey21:09:34

i went with hugsql and donโ€™t really have any complaints

nickmbailey21:09:56

seems nicer than dealing with jdbc directly

jaihindh.reddy22:09:17

hugsql and honeysql seem to be the status quo.

seancorfield22:09:19

@lilactown At work we use clojure.java.jdbc for all the "day-to-day" SQL stuff and HoneySQL where we need programmatically composable queries. See this talk from a former colleague about how we use that https://www.youtube.com/watch?v=alkcjyhesjI

seancorfield22:09:03

My understanding is that HugSQL is great for fixed SQL queries where you want to keep your SQL in regular .sql files outside your Clojure code (I prefer to see my SQL inline).

seancorfield22:09:15

clojure.java.jdbc itself provides get-by-id, find-by-keys, insert! (a hashmap into a table), update!, and delete! -- all of which really need no SQL at all for basic CRUD operations.

idiomancy22:09:15

is there a single step method to get the unqualified part of a qualified keyword, such that (?fn :myapp.core/key) => :key?

idiomancy22:09:36

or need one parse it out

noisesmith22:09:00

(comp keyword name) is a function that does that

noisesmith22:09:17

just name if a string suffices

idiomancy22:09:34

oh, huh, I didn't realize name elided the namespace

lilactown23:09:33

yep - and you call the namespace function to just get the namespace portion ๐Ÿ˜‰

lilactown23:09:17

@seancorfield what do you think of walkable?