Fork me on GitHub
#clojure
<
2016-05-13
>
jstokes00:05:12

anyone else having troubles retrieving deps from clojars? im unable to start up a repl until i comment out cider-nrepl snapshot version, and changing the version makes lein repl hang at “Retrieving cider/cider-nrepl/0.12.0/cider-nrepl-0.12.0.pom from clojars” ...

jstokes00:05:22

maybe i messed something else up here

jstokes00:05:16

status page looks fine

risto01:05:58

Where did pmap go?

seancorfield01:05:30

@juhoteperi: For when you wake up… simple_smile java.jdbc 0.6.1 should be out and fixes the PostgreSQL insert! transaction issue. Also all the tests are fixed for PostgreSQL now and I’ll continue testing against it in future (via Docker). Thank you for catching those issues! /cc @hiredman

wei02:05:55

is there a file-backed version of core.cache?

leov06:05:22

cross-clj is giving timeouts

leov06:05:29

not sure who's the maintainer

stunami07:05:43

Random noob question here, and I appreciate what Im doing is a bit odd, but trying to get a better understanding of collections and conj, and I cant for the life of me understand this one.

stunami07:05:48

(conj #{10 1} :sss 6676) => #{1 :sss 6676 10} (conj #{10 2} :sss 6676) => #{:sss 2 6676 10}

bikeshedr07:05:54

stunami: you are adding values to a set, sets aren't ordered

bikeshedr07:05:13

does that help?

stunami07:05:41

@bikeshedr: ah, so in terms of the behavior of conj, thats mean unlike vector's or lists, i can never be sure where my value ends up

stunami07:05:00

@bikeshedr: Its just interesting that :sss is consistently first if, in #{10 x} , x is 2 or 3, and consistently second if x is 0 or 1

bikeshedr07:05:18

stunami: if order is important, and you have values of different types, you can use sorted-set-by

bikeshedr07:05:02

wait, my coffee hasn't kicked in yet, gotta google

stunami07:05:47

@bikeshedr: Yeah, I'm actually trying to work on problem https://www.4clojure.com/problem/65 and so far, I'm generally able to identify what the collection is by a conj, (map being the exception I catch), but Im a bit stuck on this set behaviour.

stunami07:05:02

Apologies, jumping offline for a bit

Alex Miller (Clojure team)07:05:11

the print order is ultimately based on how the objects hash

stunami10:05:51

@alexmiller: would you be able to expand on that, why would these hash differently?

mateus.henrique.brum10:05:00

hello, how to create a function to accept seq or value

mateus.henrique.brum10:05:32

eg: (defn a [x] (...) [xs] (...))

stunami11:05:23

@mbrum, noob, but sounds like you'd want to just create your function for a value, and then map a sequence to it.

stunami11:05:33

or you could use cond and seq?

stunami11:05:27

saying that, a function will "accept a seq or val" regardless, its what you're doing with it that may/may not work.

Alex Miller (Clojure team)12:05:06

@stunami: try (map hash (range 12)) to get an idea

plexus12:05:05

(taking conversation from #C03RZGPG1 here)

plexus12:05:15

@danipov that's understandable. All I can say is wait and see, maybe start with monthly and switch to yearly when you feel I have earned your trust

plexus12:05:30

I do plan to post quite regularly, I just don't want to stick a number on it yet. People have burned out before on this kind of stuff, I want to find a rhythm that I can sustain over the long term

plexus12:05:54

the second luminus episode should be up towards the end of next week

mateus.henrique.brum12:05:10

@stunami: function overload like this

danipov12:05:39

@plexus: still considering it tho 😉 great material so far!

mateus.henrique.brum12:05:48

(defn a [x] .......

mateus.henrique.brum12:05:10

[x & rest :as all] ...

mateus.henrique.brum12:05:46

it is a correct dialect for function overload with single argument ou seq ????

manutter5112:05:14

@mbrun close, you want each arity+body wrapped in parens (defn a ([x] ,,,,) ([x & more] ,,,,)). Also I don’t think the :as all syntax works for argument destructuring in a function definition

danipov13:05:20

@mbrum: I actually recommend you to buy "Clojure for the Brave and True", really good read! In the meantime: http://www.braveclojure.com/do-things/

mpenet13:05:44

hmm I am not sure [x] [x & more] will work

mpenet13:05:57

since both can match (foo x) in theory

mpenet13:05:10

[x] [x y & more] would work

lewix13:05:37

@stunami

(fn [coll]
  (let [empty-coll (empty coll)]
    (cond 
      (= empty-coll {}) :map    
      (and (= (empty coll) ()) (= (last (conj coll 0 10)) 10)) :vector
      (and (= (empty coll) ()) (= (first (conj coll 0 10)) 10)) :list
      (= empty-coll #{}) :set)
  ))
;;I'm sure there are better solutions

manutter5113:05:26

@mpenet: It actually seems to work in my repl

mpenet13:05:07

you're right! dunno why i had that impression, maybe it once was like I mentioned, not sure

manutter5113:05:05

I’m pretty sure I’ve seen that before in an earlier version of clojure, I’d guess someone just added a special case for “prefer single arity version when 1 arg present"

lewix13:05:09

@alexmiller: Can you expand on that - the print order is ultimately based on how the object hash

Alex Miller (Clojure team)13:05:30

the printer works by walking through the internal data structure, which is a tree organized according to hash (because it's a hash array mapped trie)

Alex Miller (Clojure team)13:05:15

you should never rely on that order being anything in particular because hash functions in both Java and Clojure can and have changed over versions

Alex Miller (Clojure team)13:05:43

sorted-set is one option if you need that and external data structures like https://github.com/amalloy/ordered can give you sets that maintain insertion order if desired

lewix15:05:16

@alexmiller: I didn't get the link with @stunami question. I might have missed something I guess

Alex Miller (Clojure team)15:05:35

well maybe I misunderstood the question :)

Alex Miller (Clojure team)15:05:19

I took it as asking - why does hashing imply a different print (/ sequence) order than insertion order

Alex Miller (Clojure team)15:05:48

if you interpreted it differently, happy to answer something else if you can elaborate

lewix16:05:16

@alexmiller: I see. thanks,

lewix16:05:27

@alexmiller: By the way, how does my solution look like?

Alex Miller (Clojure team)16:05:57

@lewix why don't you just use list? vector? map? etc?

lewix17:05:57

@alejandro: as per @stunami link we cannot use list? vector? or map? etc https://www.4clojure.com/problem/65.

base69817:05:50

Anyone use lein deploy? Anyone know how to deploy an uberjar with it? It's just compiling my java classes in the project and raw .clj files. lein uberjar builds the jar properly

brian_mingus17:05:46

(def spy #(do (clojure.pprint/pprint %) %))

hiredman18:05:09

base698: it isn't for deploying uberjars, it is for deploying jars that can be depended on via maven, which come with their dependency information so maven can fetch other deps

hiredman18:05:12

deploy in this case is using the same verb as maven for an action that is more like "publish this library" than "deploy this app"

base69818:05:43

@hiredman The app I have serves two functions, one as a library for another java app and two as a separate app that can be run with java -jar. I guess just make a separate process for that? I had one but when I got lein deploy to work I thought it could do both

hiredman18:05:08

I should say, technically, there is nothing stopping you from deploying an uberjar to a mven repo, or actually any file containing anything, but I would not recommend it

hiredman18:05:37

although, I think there are some deployment pipelines, maybe something netflix open sourced, that do that

base69818:05:55

cool, thanks

ag18:05:45

someone please help me. I’m trying to parse transit message on the server side, it says the type of (:body req) is org.httpkit.BytesInputStream I need to parse it and can’t find a way

hiredman18:05:54

the example in the readme shows parsing of transit from an inputstream

ag18:05:35

nvmd I think I made it work

vmarcinko19:05:02

btw, is there anywehre some todo list for future versions of Clojure? And Rich being chief inventor, I somehow never hear any plans of his that he maybe has in mind for the language?

Alex Miller (Clojure team)19:05:03

plenty of other pages in that wiki describing various things but those are things we've talked about recently, some of which will be in the next release

vmarcinko19:05:11

@alexmiller: BTW, not that I consider it important at all, but has Rich mentioned to oyu guys that are close to him about having any plans about making CinC in any forseeable future?

Alex Miller (Clojure team)19:05:26

a) it's a lot more work, even beyond all that great stuff people have built like tools.analyzer, tools.reader, etc b) likely to be slower than Clojure in Java c) of questionable importance

Alex Miller (Clojure team)19:05:30

ClojureScript is probably a cleaner implementation and self-hosting if someone wants to port to something, but both impls unabashedly embrace their host

Alex Miller (Clojure team)19:05:01

the core team is not seeking more platforms :)

vmarcinko19:05:41

k, understood

Alex Miller (Clojure team)19:05:51

Rich has has interesting ideas about alternate implementations for the Compiler, but not for the purposes of CinC

zane19:05:30

I wonder if Clojure instants will ever be java.time.Instants rather than java.util.Dates.

Alex Miller (Clojure team)19:05:19

they can be now if you do the work to make them so

Alex Miller (Clojure team)19:05:35

the data readers are an open system

Alex Miller (Clojure team)19:05:51

or they can be JodaTime instances

zane19:05:53

I am partial to ZaneDates.

zane19:05:10

I just meant by default.

Alex Miller (Clojure team)20:05:11

well, not till java 8 is the min jdk :)

base69820:05:08

@hiredman also, the jar lein deploy made didn't have compiled clojure, just the .clj files themselves is that normal?

hiredman20:05:45

and it is the best

hiredman20:05:52

never aot libraries

base69820:05:11

cool, thanks

thug.nasty21:05:48

if an api requires a sessions key, what would be the best way to hold onto it (and potentially update it) in clojure?

thug.nasty21:05:56

is this where I should use atom?

val_waeselynck21:05:41

@thug.nasty you mean on the server side? Definitely not in an atom (process scoped global state!)

thug.nasty21:05:55

val_waeselynck: yes, server side

val_waeselynck21:05:24

Use a session store, Ring-session has several implementations for those

val_waeselynck21:05:35

including e.g Redis

thug.nasty21:05:30

i’ll look into that. thanks 🙂

bja21:05:15

please no AOT libraries in jars. Don't be like storm-core. 😞