Fork me on GitHub
#clojure
<
2015-11-05
>
seancorfield00:11:26

I think full recursion would require a huge amount of rework.

seancorfield00:11:30

Very unlikely I’ll ever get to that simple_smile

yogthos00:11:04

fair enough, I'll push it out then 😉

yogthos00:11:29

and it's up

Alex Miller (Clojure team)00:11:18

@alex.nixon: there is another ticket to flag the creation of a fixed buffer size 0 as an error so this wouldn't be possible to fall into

seancorfield00:11:55

A pleasure doing business with you @yogthos !!

alex.nixon00:11:22

alexmiller: thanks - the patch looks great! I left a Jira comment before you replied; if you have a sec would you mind weighing in on my last question? http://dev.clojure.org/jira/browse/ASYNC-140

pmooser00:11:41

The new core.async build appears to have introduced some errors involving code analysis. It falsely flags certain recurs as being in the tail position when they are not.

stopa00:11:17

@xeqi: re: prismatic/schema -> if we were using protocols, and that was the cause of the problem, do you know of a fix?

xeqi00:11:58

@stopachka: the question about protocols is because when you reload a protocol definition, clojure redefines the underlieing class. This means any old instance are not instances of the new protocol. I could see some interaction betwen schema nad clojure doing some psuedo-static thing underneath that requires reloading all usages.

xeqi00:11:34

@stopachka: I've moved to a reloadable workflow to help avoid when this could happen

Alex Miller (Clojure team)00:11:51

@pmooser: there is one ticket on this already but I'd be happy to have more examples as it is tricky

pmooser00:11:41

@alexmiller I'm a registered contributor but I don't think I have a jira account -- I'll try to sign up later when I get home, and I'll add additional examples because I have one or two slightly different ones (although they do all involve 'case'). Thanks!

Tim00:11:48

is there a blog post on how add-watch works?

stopa01:11:11

thanks @xeqi! Will start playing around with some potential solutions

xeqi01:11:38

is there a protocol I can use in c.j.jdbc to act like a db-spec? Wanting to use something like https://github.com/weavejester/duct-hikaricp-component without forcing other components to reach into the :spec key for their queries

lfn301:11:56

Hey does anyone have any experience with profiling clojure and can recommend any specific tooling? We’re considering using timbre or yourkit. Anyone got war stories?

xeqi02:11:52

ended up writing an adapter component that reached in hikaricp and stored its datasource in a :datasource key. Then jdbc could destructure it like a map

podviaznikov05:11:45

In case anyone is using jarkeeper and GitHub badges I added new badge to show number of artifact downloads from Clojars (maybe such already exists? wasn’t able to find). See example here https://jarkeeper.com/r0man/sablono and https://github.com/hashobject/perun

korjavin09:11:21

Is there a mooc course for closure noobs? Something on coursera for instance? I googled a lot but can't find anything.

pesterhazy09:11:20

@korjavin: only written material, as far as I know

mpenet09:11:03

podviaznikov: jarkeeper doesn't identify the project name correctly when there is another form before defproject in project.clj

nowprovision10:11:25

hmmm I was aware you could do stuff like (sys/getenv etc.. in project.clj I didnt know it supported additional forms

mpenet11:11:47

it's kinda usefull for version # sometimes, when a project has 10 dependencies from the same parent with the same # for instance

martinklepsch12:11:21

I’m having a bidi question… given the following routes, what would be a good way to implement this:

/DE/de/batterie ;; /country/lang/route
/DE/en/battery ;; /country/lang/route
The issue is that the route bit depends on the language which is part of the route. I thought tagged routes could help but that didn’t work and is probably also not what they’re intended for. Now my solution is to have separate routing trees and handlers (e.g. :en-battery and :de-battery) which will work but doesn’t feel particularly elegant. Any better ideas?

martinklepsch12:11:09

I guess that’s the point where writing functions that generate routes becomes useful, would like to make sure that “built-in” features have been exhausted though simple_smile

martinklepsch12:11:03

@lancefalcon: the question was particularly aimed at bidi https://github.com/juxt/bidi — while this kind of passing down of values would help I’m not sure if it’s possible in bidi

lancefalcon12:11:50

oh, right, sorry about that simple_smile

martinklepsch13:11:38

I came up with a solution to my bidi Q: basically I use a parameter segment for the i18n bit that I look up in a predefined map before calling bidi.bidi/path-for. Pretty simple actually simple_smile

pbostrom14:11:41

@lfn3: you might consider Java Flight Recorder if you're on jdk8, it's included just type jmc on the command line

grav15:11:46

I’d my team to get rid of the habit of creating functions that are just mappings over another function. But I cannot seem to find the right argument. Can anyone help me out? simple_smile Eg

(defn foos [xs y] 
  (map #(foo % y) xs))

mishok1315:11:47

this example doesn't make any sense

mishok1315:11:55

l is simply ignored?

mishok1315:11:04

oh, makes more sense now simple_smile

grav15:11:06

Just edited it 😉

mishok1315:11:21

well, it would be somewhat easier if foo expected 3 arguments instead of a 3-element vector

grav15:11:49

(five edits after)

mishok1315:11:23

I don't think there's a lot of utility in a one-liner like that

kosecki15:11:49

cant you have a "utility" fn that accepts foo as a parameter ?

grav15:11:51

nah, that’s what I’m thinking, but then a counter argument is that it’s called from multiple places.

mishok1315:11:19

(defn map-with
  [f xs & rest]
  (map #(apply f % rest) xs))

mishok1315:11:28

to make it a bit more generic

mishok1315:11:15

still, I think it's a matter of personal opinion, whether functions like that deserve to be simple_smile

kosecki15:11:39

looks good !

skottk15:11:45

Trying to use figwheel and duct. What am I missing? In https://github.com/weavejester/duct-figwheel-component, the provided code :

skottk15:11:10

(require '[duct.component.figwheel :as figwheel] '[com.stuartsierra.component :as component]) can’t find figwheel.

mishok1315:11:02

dependency didn't load, perhaps?

mishok1315:11:30

I'd try to restart REPL first

jstew15:11:54

It's only available in the dev profile when you're using duct, that could be your issue also.

skottk15:11:01

Thanks, but I’m still not getting it. I create a new duct project, I try the require, and figwheel can’t be found. I mean, I’m literally pasting in the text from the readme, and it doesn’t work. Trying lein with-profile project/dev, and nrepl-server can't found. I must be missing something about profiles, I guess.

mishok1315:11:53

@skottk: perhaps it will be easier if you create a gist with your project.clj and the console session history

jstew15:11:54

In a duct app, when you specify the figwheel option, that code goes into dev/user.clj. It does in mine at least. And that's where the nrepl code gets loaded as well.

jstew15:11:46

:project/dev should have "dev"` in the :source-paths

jstew15:11:36

I'm not sure I'm a huge fan of the duct-figwheel component though. I miss autoloading.

skottk15:11:35

I’m changing nothing from the default duct project, which includes duct-figwheel-component, and pasting in the how-to code from the readme.

jstew15:11:21

@skottk: What does your dev/user.clj look like?

mishok1315:11:53

maybe I'm missing something, but I don't see [duct/figwheel-component "0.3.0"] anywhere in that project.clj?

jstew16:11:43

true. and it's missing figwheel as well.

jstew16:11:17

They should both be in :project/dev :dependencies

jstew16:11:06

It looks like you generated your project without the +cljs option. Clojurescript is missing also.

skottk16:11:27

mishok13: Oh, FFS. 😞 Spent all this time trying to fix the a problem in a clean project, which I cleverly created with +figwheel — which doesn’t do anything — instead of +cljs. Thanks for your help, I’m being an idiot.

jfntn17:11:40

In core.async’s latest release, I can’t see how offer! and poll! differ from put! and pull!, can anyone give me a hint?

jfntn17:11:10

I meant take!, not pull!

jfntn18:11:37

@scgilardi: thanks I was reading that, and still confused...

scgilardi18:11:15

the key feature is they don't block. "try to put!, but if you can't just return a failure indication"

jfntn18:11:14

Hmm can’t you use put! in cljs outside of a go block? i.e. non-blocking?

scgilardi18:11:25

from the recent announcement on the mailing list, here's Rich explaining these features: I should have mentioned that promise-chan, offer!, and poll! were discussed by Rich at last year's Conj talk if anyone is interested in hearing him talk about these: https://youtu.be/4KqUvG8HPYo?t=52m6s

jfntn18:11:51

Oh cool, thanks for linking the relevant bit @scgilardi

scgilardi18:11:09

@jfntn: you're welcome

micahasmith18:11:27

anyone have any advice on how to approach the problem: - i want to only allow a single request at a time to flow through a function. so other function calls would block (or have a block-like experience) if another execution was in progress in the function.

micahasmith18:11:55

imperatively i would reach for a semaphore, but i’m wondering what the idiomatic clojure way would be

micahasmith18:11:27

i loosely remember that agents are serializable (ordered) — is that (or am i) correct? could i just push fns into an agent to achieve the desired response?

Alex Miller (Clojure team)18:11:24

agents apply one incoming function at a time to their state, but they are async which may or may not be good

micahasmith18:11:48

is order preserved

Alex Miller (Clojure team)19:11:16

order of arrival is preserved but that order may not be well-defined if events arrive from multiple threads

Alex Miller (Clojure team)19:11:34

from single thread though, you should see the same order

Alex Miller (Clojure team)19:11:46

some logging system use an agent to log messages for example

micahasmith19:11:09

most examples i’m seeing online with agents are logging or proxying to files

Chris O’Donnell19:11:10

not sure if this is idiomatic, but couldn't you put requests into a channel and have your function consume from it?

Alex Miller (Clojure team)19:11:27

or a Java concurrent queue

micahasmith19:11:15

whoa locking macro

micahasmith19:11:19

going to have to look that up

Alex Miller (Clojure team)19:11:33

just created a synchronized block effectively

micahasmith19:11:33

thx for giving me some options— going to investigate

Alex Miller (Clojure team)19:11:00

although if you're expecting contention, that might be a bad use case for a ref

martinklepsch19:11:53

Is there a name for a datastructure that behaves like a set but determines if two values x and y are equal by comparing the results of f(x) and f(y)?

lfn320:11:25

@pbostrom: thanks, wasn’t even aware there were baked in profiling tools.

nullptr20:11:39

martinklepsch: i’d call that a set with a custom comparer — don’t believe clj has that concept baked in, but have used it in other environments

Alex Miller (Clojure team)20:11:32

clojure has sorted sets with custom comparators

martinklepsch20:11:22

yeah I was just thinking that I could (ab)use sorted sets for this too

Alex Miller (Clojure team)20:11:48

the tricky bit in this is that you have to be very careful about declaring things equal only if they really are equal, because the set will remove all but one based on the results of f(x)

martinklepsch20:11:28

my data isn’t really sortable in any meaningful way though and making something sorted just to get set properties doesn’t feel right.

Alex Miller (Clojure team)20:11:47

you can thinking of sorting as just one way of detecting duplicates

Alex Miller (Clojure team)20:11:13

hashing is another (approximate) way - in a hash set, f is hash (kind of)

martinklepsch20:11:38

originally my data was a regular map {str map} but the keys of this map were derived from a key in the values map entries value

martinklepsch20:11:45

there was no need to access data by key though and having a map complicated handling of this data

martinklepsch20:11:07

I hope this gives a bit more context

Alex Miller (Clojure team)20:11:51

this is the kind of thing where you could create a deftype, that implements the key clojure interfaces for a set, and holds a normal set (or map) and applies f appropriately during insertion and lookup

martinklepsch20:11:04

yeah, I think this what I arrived at myself too. I tried looking up which interfaces I have to implement for that but wasn’t sure. Is https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IPersistentSet.java basically all I need?

Alex Miller (Clojure team)21:11:09

yeah (and super interfaces of course - IPersistentCollection and Seqable)

martinklepsch21:11:48

hah, this was super easy and fun, thanks @alexmiller simple_smile

jeff.terrell21:11:48

@martinklepsch: Did I hear something about a blog post? simple_smile

martinklepsch21:11:29

@jeff.terrell: about the stuff above?

jeff.terrell21:11:49

I mean, that's what I heard, yeah…

martinklepsch21:11:44

😄 I guess I could give it a try