#clojure log - Aug 02 2015

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

4:37 Pupeno: Would prismatic schema superset something like validateur?

5:24 pepijndevos: Can I do something like this? (peek #{1 2 3})

5:28 (rest (sorted-set 3 2 1 1)) works, but returns a seq.

5:34 (let [s (sorted-set 1 2 3 4 5)] (disj s (first s)))

6:22 kwladyka: is it possible to tell REPL to show data like #{{...} /newline {...}} instead of all in one line?

6:23 or println or anything :)

6:25 lumafi: clojure.pprint/pprint

6:27 kwladyka: thx

6:46 is a way to write it shorter? (one line?) https://www.refheap.com/40c1388aa2224d0496825e2a5

6:47 or more but using (->>) <- this one will be perfect

6:49 Pupeno: I’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]

6:49 and [:error, validation-errors]? a-la Erlang?

6:51 kwladyka: Pupeno, i have something like error message bag, but it is my preferential

6:51 Pupeno: kwladyka: what do you mean by error message bag?

6:52 kwladyka: so i have [{:message "foo"}{:message "bar"}{:message "bla" :additional-info-or-code 1234}]

6:52 and i have functions like add-error-message etc.

6:53 and i am operation on that, also with validation

6:53 Pupeno: Is a message your model is it metadata about your model?

6:53 kwladyka: oh, ofcourse on the and it looks like {:errors [{:message "foo"}{:message "bar"}{:message "bla" :additional-info-or-code 1234}]}

6:54 i am using this like normal data

6:54 to feedback for GUI

6:55 Pupeno: How does it look when there are no errors for you kwladyka?

6:56 kwladyka: could be {} or {:errors []}

6:56 if i want know if errors appear i am checking if :errors is empty?

6:56 *not empty

6:57 Pupeno: But what about the data the is returned by the API when it succeeds.

6:58 kwladyka: brutal true is i copy a little this conception http://laravel.com/docs/5.1/validation#working-with-error-messages

6:58 of working with messages

7:00 maybe 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

7:01 Pupeno: kwladyka: 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.

7:01 When 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.

7:05 kwladyka: i am not sure i understand but i just return {:errors [] :something-more? []} or right data

7:05 i have to go, sorry

7:06 Pupeno: So, 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:57 justin_smith: pepijndevos: if you want something like rest / disj you want pop not peek :)

11:59 pepijndevos: which of course does not work for sets, even sorted ones

13:54 gfredericks: Bronsa: what does cljs tools.reader do when it encounters ratios or large integers?

13:56 Bronsa: gfredericks: just js/parseInt

13:56 and cljs.core// to create a ratio

13:56 gfredericks: Bronsa: any interest in that being customizable? a similar mechanism to data readers?

13:57 Bronsa: don't think cljs has a ratio type?

13:57 gfredericks: certainly doesn't afaik

13:57 Bronsa: oh look there's even a comment

13:57 (/ (-> numerator js/parseInt) ;;; No ratio type in cljs

13:57 (-> denominator js/parseInt)))); So will convert to js/Number

13:57 gfredericks: yeah I was just reading that :)

13:58 so if this were customizable it'd apply to large integer, ratio, and bigdecimal syntaxes

13:58 Bronsa: gfredericks: how would that work?

13:58 gfredericks: Bronsa: like data readers, but would pass the string elements to whatever functions were setup

13:58 {:ratio (fn [numerator-str denominator-str] ...), ...}

13:59 you could hijack the existing data reader stuff if you wanted to use some magic symbols or keywords or something to have them under

13:59 does the cljs compiler use tools.reader or LispReader?

13:59 Bronsa: tools.reader

14:00 gfredericks: oh man so this would actually be usable in the core language if we did it

14:00 Bronsa: gfredericks: would simply making match-number a ^:dynamic var be enough?

14:00 kwladyka: is function like this in Clojure? I want conj only if condition is true

14:00 (defn foo [x y]

14:00 (if (condition)

14:00 (conj x y)

14:00 x))

14:01 gfredericks: kwladyka: cond-> is a nice way to do that by hand

14:01 (cond-> x (condition) (conj y))

14:01 Bronsa: gfredericks: he wants (condition) not (condition x)

14:01 gfredericks: Bronsa: yeah that's what that does

14:01 Bronsa: oh wait

14:02 uh

14:02 I guess I never used cond-> :)

14:02 gfredericks: Bronsa: yeah I think the dynamic var would give the same capabilities

14:03 Bronsa: 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:03 because the cljs compiler would still control the "how do I compile this jvm type to javascript" thing

14:06 kwladyka: gfredericks, i didnt use that function before, thx. I will ready about that.

14:06 gfredericks: np

14:15 kwladyka: gfredericks, any idea how can i use that here? https://www.refheap.com/72eaffe15ce641e8364ce86af

14:15 i jus want something in one line and be simple

14:15 but maybe it is not possible

14:16 gfredericks: kwladyka: you can't drop it in right there because you're in the middle of ->>, when you need ->

14:17 you can either have an outer -> or use plumbing.core/<-

14:17 or if all that is terribly confusing, you might stop using ->> for a bit

15:03 kwladyka: gfredericks, even with cond->> ?

15:04 i guess yes, it doesn't work :)

15:04 but maybe i have to split this into 2 functions

16:44 tmtwd: what is the right way to do this? http://pastebin.com/iM8JpSDR

16:45 http://pastebin.com/6LWemh7s where the sql def is like this

17:45 xificurC: why 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:45 is just noone using the templates and don't care or what is the reason for this

17:45 expez: Because you haven't submitted a pull-request ye!

17:45 +t

17:46 also, people are busy / overextended

17:47 xificurC: yeah but I can't be the only one usining e.g. leiningen. nrepl 0.2.6 is almost 1 year old now

17:48 expez: It's fixed on master

17:48 xificurC: 0.2.7 came in january. Don't tell me noone had the time to just bump the version in half a year

17:48 expez: it might not be as simple just bumping the version, though

17:49 xificurC: hm, lein release is 6 months old and >100 commits behind now

17:49 expez: lein is a pretty good example of a project in need of your help

17:49 those guys are buried in issues

17:50 xificurC: why is that

17:50 is lein buggy

17:51 expez: No, that's not what I meant, but it has a large scope and it's hard to get everything right

17:51 There's also nobody paid to work on it anymore

17:51 xificurC: technomancy only seems to be merging PRs by now

17:51 Leonidas: also, sometimes things in the background change and some edge-cases are broken

17:52 expez: was technomancy ever paid to work on it?

17:52 expez: Leonidas: I think so, as part of his job supporting clojure for Heroku.

17:52 If not his contribution is even more incredibible than it already is

17:52 Bronsa: xificurC: technomancy moved and is doing other stuff now

17:52 xificurC: Bronsa: moved in what sense

17:52 amalloy: yeah, he has mostly opted out of the internet

17:53 Bronsa: xificurC: http://technomancy.us/

17:53 xificurC: it's sad that today it sounds like you died when you do that

17:56 Bronsa: thanks, read that, understand completely

17:56 is the community still using lein in the large or is part of it moving to boot

17:57 expez: I'd be surprised if boot had more than 20%

17:57 Leonidas: xificurC: moved to thailand and makes keyboards now.

17:58 xificurC: Leonidas: yeah read it on his site as linked by Bronsa, but thanks

17:58 expez: 20% is more than what I expected

17:59 Bronsa: likely way less than that

18:00 xificurC: should I invest in learning it, as a kinda newcomer

18:01 or is lein more than enough and simpler

18:02 expez: stick with lein

18:03 more blogposts, more people to ask, works with all tooling and still 'just works'

18:04 xificurC: thanks

18:04 will hit the bed, thanks for your time guys, gn

18:04 ebzzry: why is the main function named -main?

18:12 justin_smith: ebzzry: because that's a convention

18:14 ebzzry: justin_smith: may you please point me, sir, to that list of conventions

18:16 expez: ebzzry: https://groups.google.com/forum/#!topic/clojure/rzvMp44ZN0I

18:17 justin_smith: ebzzry: it's a part of gen-class / aot. On a per-namespace basis, you can change the prefix, but the default prefix is -

18:17 ebzzry: java folks decided that the jvm convention would be that the method that gets run for a given class is the main method

18:19 ebzzry: justin_smith: ok

18:19 because the default prefix that clojure.core/gen-class looks for the prefix "-". ok.

20:05 arrdem: amalloy: have you rebased/merge with the new skummet build or shall I

23:33 TEttinger: gfredericks: I just had a thought regarding splittable RNGs

23:36 slester: I find that just being in this chatroom answers questions before I even have a chance to ask them.

23:37 TEttinger: say 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:38 calling 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:51 arrdem: slester: this chat room solves problems you don't understand yet with voodoo you have the tools to approach

23:51 *didn't know you had yet

Logging service provided by n01se.net