#clojure logs

2015-08-02

04:37PupenoWould prismatic schema superset something like validateur?
05:24pepijndevosCan I do something like this? (peek #{1 2 3})
05:28pepijndevos(rest (sorted-set 3 2 1 1)) works, but returns a seq.
05:34pepijndevos(let [s (sorted-set 1 2 3 4 5)] (disj s (first s)))
06:22kwladykais it possible to tell REPL to show data like #{{...} /newline {...}} instead of all in one line?
06:23kwladykaor println or anything :)
06:25lumaficlojure.pprint/pprint
06:27kwladykathx
06:46kwladykais a way to write it shorter? (one line?) https://www.refheap.com/40c1388aa2224d0496825e2a5
06:47kwladykaor more but using (->>) <- this one will be perfect
06:49PupenoI’m using validateur to validate user input. So I have a function called user/create that might create a user (and return it) or return a list of validation errors. Both a success returning a user and errors are maps, so they are impossible to distinguish without looking into the map itself. What’s the appropriate way to handle this so that callers now what happened? Should I tag the output, like [:success, user-map]
06:49Pupeno and [:error, validation-errors]? a-la Erlang?
06:51kwladykaPupeno, i have something like error message bag, but it is my preferential
06:51Pupenokwladyka: what do you mean by error message bag?
06:52kwladykaso i have [{:message "foo"}{:message "bar"}{:message "bla" :additional-info-or-code 1234}]
06:52kwladykaand i have functions like add-error-message etc.
06:53kwladykaand i am operation on that, also with validation
06:53PupenoIs a message your model is it metadata about your model?
06:53kwladykaoh, ofcourse on the and it looks like {:errors [{:message "foo"}{:message "bar"}{:message "bla" :additional-info-or-code 1234}]}
06:54kwladykai am using this like normal data
06:54kwladykato feedback for GUI
06:55PupenoHow does it look when there are no errors for you kwladyka?
06:56kwladykacould be {} or {:errors []}
06:56kwladykaif i want know if errors appear i am checking if :errors is empty?
06:56kwladyka*not empty
06:57PupenoBut what about the data the is returned by the API when it succeeds.
06:58kwladykabrutal true is i copy a little this conception http://laravel.com/docs/5.1/validation#working-with-error-messages
06:58kwladykaof working with messages
07:00kwladykamaybe some similar library exist for Clojure, as i was looking a few months ago i didn't find but maybe i did't look carefully
07:01Pupenokwladyka: that seems to deal with errors and only errors. validateur does that for me. That's not my question, my question is one level up the hierarchy, when you are dealing with either data or errors.
07:01PupenoWhen I call create-user I either get a (created) user back or a bunch of errors, dealing with the errors is done, my question is how to deal with users or errors.
07:05kwladykai am not sure i understand but i just return {:errors [] :something-more? []} or right data
07:05kwladykai have to go, sorry
07:06PupenoSo, the presence of the key :errors identify that an error happened and the absent that it didn't. That means that for example, you can't have data that has the key :errors and you can't have data that is not a map.
11:57justin_smithpepijndevos: if you want something like rest / disj you want pop not peek :)
11:59justin_smithpepijndevos: which of course does not work for sets, even sorted ones
13:54gfredericksBronsa: what does cljs tools.reader do when it encounters ratios or large integers?
13:56Bronsagfredericks: just js/parseInt
13:56Bronsaand cljs.core// to create a ratio
13:56gfredericksBronsa: any interest in that being customizable? a similar mechanism to data readers?
13:57Bronsadon't think cljs has a ratio type?
13:57gfrederickscertainly doesn't afaik
13:57Bronsaoh look there's even a comment
13:57Bronsa (/ (-> numerator js/parseInt) ;;; No ratio type in cljs
13:57Bronsa (-> denominator js/parseInt)))); So will convert to js/Number
13:57gfredericksyeah I was just reading that :)
13:58gfredericksso if this were customizable it'd apply to large integer, ratio, and bigdecimal syntaxes
13:58Bronsagfredericks: how would that work?
13:58gfredericksBronsa: like data readers, but would pass the string elements to whatever functions were setup
13:58gfredericks{:ratio (fn [numerator-str denominator-str] ...), ...}
13:59gfredericksyou could hijack the existing data reader stuff if you wanted to use some magic symbols or keywords or something to have them under
13:59gfredericksdoes the cljs compiler use tools.reader or LispReader?
13:59Bronsatools.reader
14:00gfredericksoh man so this would actually be usable in the core language if we did it
14:00Bronsagfredericks: would simply making match-number a ^:dynamic var be enough?
14:00kwladykais function like this in Clojure? I want conj only if condition is true
14:00kwladyka(defn foo [x y]
14:00kwladyka (if (condition)
14:00kwladyka (conj x y)
14:00kwladyka x))
14:01gfrederickskwladyka: cond-> is a nice way to do that by hand
14:01gfredericks(cond-> x (condition) (conj y))
14:01Bronsagfredericks: he wants (condition) not (condition x)
14:01gfredericksBronsa: yeah that's what that does
14:01Bronsaoh wait
14:02Bronsauh
14:02BronsaI guess I never used cond-> :)
14:02gfredericksBronsa: yeah I think the dynamic var would give the same capabilities
14:03gfredericksBronsa: oh wait cljs uses the *clj* half of tools.reader doesn't it; so the "would make this work for the core language" thing isn't actually true
14:03gfredericksbecause the cljs compiler would still control the "how do I compile this jvm type to javascript" thing
14:06kwladykagfredericks, i didnt use that function before, thx. I will ready about that.
14:06gfredericksnp
14:15kwladykagfredericks, any idea how can i use that here? https://www.refheap.com/72eaffe15ce641e8364ce86af
14:15kwladykai jus want something in one line and be simple
14:15kwladykabut maybe it is not possible
14:16gfrederickskwladyka: you can't drop it in right there because you're in the middle of ->>, when you need ->
14:17gfredericksyou can either have an outer -> or use plumbing.core/<-
14:17gfredericksor if all that is terribly confusing, you might stop using ->> for a bit
15:03kwladykagfredericks, even with cond->> ?
15:04kwladykai guess yes, it doesn't work :)
15:04kwladykabut maybe i have to split this into 2 functions
16:44tmtwdwhat is the right way to do this? http://pastebin.com/iM8JpSDR
16:45tmtwdhttp://pastebin.com/6LWemh7s where the sql def is like this
17:45xificurCwhy are so many things lagging in releases? Leiningen uses clojure 1.6.0 and nrepl 0.2.6. `lein new compojure hello-world' uses old deps and plugins. I noticed this with other templates too
17:45xificurCis just noone using the templates and don't care or what is the reason for this
17:45expezBecause you haven't submitted a pull-request ye!
17:45expez+t
17:46expezalso, people are busy / overextended
17:47xificurCyeah but I can't be the only one usining e.g. leiningen. nrepl 0.2.6 is almost 1 year old now
17:48expezIt's fixed on master
17:48xificurC0.2.7 came in january. Don't tell me noone had the time to just bump the version in half a year
17:48expezit might not be as simple just bumping the version, though
17:49xificurChm, lein release is 6 months old and >100 commits behind now
17:49expezlein is a pretty good example of a project in need of your help
17:49expezthose guys are buried in issues
17:50xificurCwhy is that
17:50xificurCis lein buggy
17:51expezNo, that's not what I meant, but it has a large scope and it's hard to get everything right
17:51expezThere's also nobody paid to work on it anymore
17:51xificurCtechnomancy only seems to be merging PRs by now
17:51Leonidasalso, sometimes things in the background change and some edge-cases are broken
17:52Leonidasexpez: was technomancy ever paid to work on it?
17:52expezLeonidas: I think so, as part of his job supporting clojure for Heroku.
17:52expezIf not his contribution is even more incredibible than it already is
17:52BronsaxificurC: technomancy moved and is doing other stuff now
17:52xificurCBronsa: moved in what sense
17:52amalloyyeah, he has mostly opted out of the internet
17:53BronsaxificurC: http://technomancy.us/
17:53xificurCit's sad that today it sounds like you died when you do that
17:56xificurCBronsa: thanks, read that, understand completely
17:56xificurCis the community still using lein in the large or is part of it moving to boot
17:57expezI'd be surprised if boot had more than 20%
17:57LeonidasxificurC: moved to thailand and makes keyboards now.
17:58xificurCLeonidas: yeah read it on his site as linked by Bronsa, but thanks
17:58xificurCexpez: 20% is more than what I expected
17:59Bronsalikely way less than that
18:00xificurCshould I invest in learning it, as a kinda newcomer
18:01xificurCor is lein more than enough and simpler
18:02expezstick with lein
18:03expezmore blogposts, more people to ask, works with all tooling and still 'just works'
18:04xificurCthanks
18:04xificurCwill hit the bed, thanks for your time guys, gn
18:04ebzzrywhy is the main function named -main?
18:12justin_smithebzzry: because that's a convention
18:14ebzzryjustin_smith: may you please point me, sir, to that list of conventions
18:16expezebzzry: https://groups.google.com/forum/#!topic/clojure/rzvMp44ZN0I
18:17justin_smithebzzry: it's a part of gen-class / aot. On a per-namespace basis, you can change the prefix, but the default prefix is -
18:17justin_smithebzzry: java folks decided that the jvm convention would be that the method that gets run for a given class is the main method
18:19ebzzryjustin_smith: ok
18:19ebzzrybecause the default prefix that clojure.core/gen-class looks for the prefix "-". ok.
20:05arrdemamalloy: have you rebased/merge with the new skummet build or shall I
23:33TEttingergfredericks: I just had a thought regarding splittable RNGs
23:36slesterI find that just being in this chatroom answers questions before I even have a chance to ask them.
23:37TEttingersay you create a new splittable rng, let's call it srng, with a seed, 1337 . this could just create a normal, non-splittable random number generator as a member of srng that produces seeds for other normal random number generators. then since we need a generator, we get the first number from the member seed generator with seed 1337, and use that as a seed for the first split-off generator.
23:38TEttingercalling split uses the original seed generator to generate a new seed, creates a new either non-splittable random number generator and stores it internally, or creates a new splittable generator with the new seed
23:51arrdemslester: this chat room solves problems you don't understand yet with voodoo you have the tools to approach
23:51arrdem*didn't know you had yet