#clojure logs

2016-03-15

00:08mmerceri was banned in #haskell but not in here. if that doesn't prove that clojure is superior I don't know what does
00:19ben_vulpespatience is next to godliness or what was it
00:23tolstoyShould it be possible to (using component) do something like (merge (system/map :some thing) {:other thing} {:still-other thing})?
00:26tolstoyHm. Seems to return a SystemMap, so that's a yes, I guess.
01:19pmbauer_somebody please ban mmercer; those comments are inappropriate, sexist, unprofessional and do not represent the Clojure community
01:20tolstoyDoesn't seem to be an op.
01:20rhg135I'd hope not
01:21rhg135I think they just don't idle as op
01:23tolstoyPlus it's late. I wonder how they'd get notified?
01:24rhg135PushX?
01:25tolstoyI think puredanger is one. amolloy another?
01:25tolstoyOr, amalloy.
01:26rhg135Yeah
01:26rhg135I don't think amalloy sleeps anyway
01:44whunixHi, what's a good tutorial for beginners?
01:44whunixI am going to read about Racket HTDP book and then move on to Clojure from that
01:44whunixwhat book would be appropriate to read after that?
01:45whunixin terms of Clojure
01:45faxmodemwhunix: clojure from the ground up
01:45faxmodemits online from aphyr
01:45tolstoyJust listened to a podcast with the author of: http://www.braveclojure.com. He said he approached it as he learned it being a Ruby programmer.
01:45faxmodemthen maybe clojure for the brave and true
01:46whunixfaxmodem, where's the book? Can't find it :(
01:47tolstoyhttps://aphyr.com/posts/301-clojure-from-the-ground-up-welcome
01:48whunixtolstoy, is that all?
01:48tolstoyThere's a link at the bottom to the next chapter.
01:49tolstoySummary: https://aphyr.com/tags/Clojure-from-the-ground-up
01:51whunixisn't it better to just jump into Braveclojure?
01:52tolstoySure. I think it depends on your familiarity with functional programming, or Lisp, etc, etc, or your general programming experience. Might start with one of the books. Clojure Programming, or what have you.
02:49irctcIn http-kit I want to defer the answer of http request, like return a future or something, what is the idiomatic way to do that?
03:04Empperiso you mean when using http-kit client and you make a request and want to get the response via defer?
03:04Empperiit's built in http-kit client http://www.http-kit.org/client.html#sync
03:05Empperiif you are talking about having http-kit as a server and calling it from browser with clojurescript then the short answer is "you don't"
03:05Empperithe long answer is "use core.async" although that too won't be synchronous
03:05clojurebotIk begrijp
03:06Empperibut close at least
03:06Empperiand wtf clojurebot
03:06Empperiyou messing with me? lol
03:24amalloy~the long answer
03:24clojurebotthe long answer is "use core.async" although that too won't be synchronous
03:28Empperilol
03:34opqdonut:D
05:15CStormso anyone have a read/video for me who are looking to get insight in different database options?
05:15CStormreading "mongodb sucks" is getting old, so trying to get a more insight in alternatives.
05:16CStormor atleast to why mongodb sucks ;)
05:21Empperimongodb doesn't have relations in any way and it doesn't have transactions and it doesn't have any support for schemas
05:21Empperithat enough for you why mongodb sucks? :)
05:21prohobomongodb sucks
05:21Empperibut in truth mongodb doesn't suck
05:22Empperibut it sucks as a general purpose database
05:22prohoboits webscale
05:22Empperifor specific use case scenarios mongo is awesome
05:23CStormwhat db should i read up on as a general purpose database?
05:23CStormspecific for clojure
05:23prohoboCStorm: postgres prolly
05:23ridcully_CStorm: postgres
05:23CStormhaha
05:23CStorm:D
05:23prohobo:|
05:23CStormgoodie, thanks guys.
05:24Empperiyeah, postgres is a great choice for a lot of stuff
05:24CStormbeing at ios and osx for 6-7 years and shifting to clojure has it ups and downs :)
05:24CStormone of them being a mess to figure out the whole db mess.
05:25Empperiyou've never used databases?
05:25Empperiyou're up for a rough ride my friend :)
05:25CStormused coredata for ios
05:25CStormbut else no
05:26CStormmight be rough but looking forward to it :)
05:26CStormgotta start somewere right
05:26prohobowhats so rough about using dbs
05:27Empperiwell for starters, you have learn a new language: SQL
05:27Empperiand to understand how relational databases work
05:28Empperialso there's transactions and transaction isolation levels
05:28Empperithere is a reason why there are people whose sole purpose is to do stuff with relational databases :)
05:28Empperisame thing goes for other types of databases
05:29Empperinot that it won't be a truly enlightening journey to learn all that stuff but it's going to be a rough ride and there's tons of new stuff to learn
05:30CStormwell what kinda programmer would i be if i just would say "ugh im already behind the wagon i dont wanna learn it"
05:30CStormim looking forward to it, no matter how "rough" it will be :)
05:31i-blisCStorm: if you're looking for a good read on DBs, give "seven databases in seven weeks" a shot; it gives a nice overview on what you get with the different paradigms out there
05:31CStormthank you i-blis, will look that up right away
05:32EmpperiCStorm: indeed, that's the right attitude :)
05:35prohobonot a CS major?
05:36ridcully_knowing SQL and what comes with it is IMHO a valuabe skill for a developer. but maybe i am just old
05:37ridcully_also starting with it on most OS is just a `sqlite3` call away
05:49CStormI bought the book now i-blis– looking forward to it.
05:53i-blisCStorm: hope you will enjoy it as I did (despite being a long time SQL user, I enjoyed even the chapter on PostgreSQL)
05:57hyPiRionI think sqlite3 is easier to get started with, but Postgres is really good once you've managed to get it up and running. That isn't always as straightforward as one would like though.
06:13Empperiridcully_: no, you are not just old. You are correct
06:14Empperithat's especially true with Clojure and other languages with powerful set operations
06:15prohobobut you are also old
06:18Empperiit's all relative :)
06:18Empperi34 years old
06:18EmpperiI personally think I'm still young and in the beginning of my career
06:21hyPiRionYeah, 34 is not much.
07:14keksi_I have a problem modifying my data so I can handle it. I want to modify the structure from the from.clj to to.clj kind of data: https://gist.github.com/Keksike/77477abf2bfcbd5754ee , what should I do?
07:14keksi_I dont think cheshire had a proper function for this one
07:17faxmodemI'm playing with overtone/at-at
07:18faxmodemwhen I'm running a function using (at/every 10000 #(myfunc a b c)) it doesn't behave the same as if run as (myfunc a b c)
07:18ridcully_keksi_: pass true as second argument to parse-string. then you get keywords
07:19keksi_ridcully_: I tried that too, but it got rid of the [ & ]
07:19faxmodeme.g. the side effects of myfunc are not observed when running it inside an every block
07:20keksi_ridcully_: (and it put it in parantheses instead)
07:21ridcully_yes. its a list then instead of a vector.
07:22keksi_how do I convert it to a vector?
07:23ridcully_,(vector '({:a :b}{:c :d}))
07:23clojurebot[({:a :b} {:c :d})]
07:24ridcully_DOH
07:24ridcully_s/vector/vec/
07:24keksi_wow, thanks :)
07:25faxmodemor into
07:25keksi_which is preferred?
07:25faxmodemgood question :)
07:25faxmodemin terms of readability I'd vote for vec
07:26ridcully_in terms of me remembering vector and vec i vote into ;)
07:27faxmodem:-D
08:18kungiIs there a difference between (vec) and (into [])
08:31hyPiRionkungi: not semantically
08:32hyPiRionBut vec is likely more performant.
08:33MJB47iirc it isnt
08:33MJB47but i might be remembering wrong
08:34MJB47it was tested by someone here a few weeks back
08:37Empperikinda surprised if vec isn't faster
08:37Empperiit uses PersistentVector.create() under the hood
08:37Empperiwhile into uses transducers and conj
08:44MJB47http://insideclojure.org/images/20150107/numbers.png
08:44MJB47from http://insideclojure.org/2015/01/07/vec-perf/
10:22digiorgiHi, i'm trying to use clojure with maven, to get a good integration with other ides clojure + java. But when i'm starting CIDER on emacs, connecting from maven i get errors.
10:22digiorgiWARNING: The following required nREPL ops are not supported:
10:22digiorgi apropos classpath complete eldoc format-code format-edn info inspect-pop inspect-push inspect-refresh macroexpand ns-list ns-vars ns-path refresh resource stacktrace toggle-trace-var toggle-trace-ns undef
10:22digiorgi Please, install (or update) cider-nrepl 0.12.0-SNAPSHOT and restart CIDER
10:22digiorgibut i have installed the required version
10:33justin_smithis the cider-nrepl middleware properly loaded? I thought that it wouldn't work without lein.
10:34justin_smithwell I guess boot maybe uses it too somehow? anyway, you'll need to do something to make it run properly in maven, it won't be automatic.
10:52X-warriorhow would you guys represent your own tree structure? a map of maps?
10:52justin_smiththat or a deftype
10:54X-warriorI was doing an exercise for an interview and represented the tree as a deftype. Today I received their answer saying that my code is too much OO and they wanted more functional programming
10:54justin_smithinteresting - did you use mutable fields?
10:55X-warriorjustin_smith: yes I did
10:55justin_smithaha, yeah, I might use deftype, but I would not use mutable fields unless absolutely neccessary
10:56X-warriorwell, you have 1 node with one child... you add a new node, how can you add it without using mutable fields?
10:57justin_smiththe same way you do with any other immutable data type - you have an operation that returns a new instance containing the new node
10:57X-warriorI guess my problem was that I created some deftype methods to add new node/retrieve specific node and others
10:57justin_smitheg (cons 1 ()) returns '(1) but () is not altered
10:58justin_smithX-warrior: you can still have methods to insert and retrieve - it's just a different style when working with immutable data
10:59justin_smithwhere of course insert returns a new tree (that can implicitly share structure with the original, since they are immutable, depending on implementation), and the retrieval would work the same as before
11:04X-warriorjustin_smith: do you mind to take a look at the code to point some improvements that I could do, so it became more functional instead of OO ?
11:04X-warriorbesides the mutable fields
11:05X-warriornow that I already failed at the test and spent so much time doing it, I would like to get better at this
11:06justin_smithX-warrior: I can take a look later, but really the mutable fields thing is what will make the biggest difference (I say without even seeing the code)
11:07Glenjaminwhat was the exercise brief?
11:09X-warriorGlenjamin: I had to do a reward system where a customer wins points for invitee from invitee on a 0.5^k
11:10X-warriorso direct invitee will give me 1 points, 0.5, 0.25...
11:11ystaelyou had to implement a pyramid scheme kickback mechanic as an interview question? o_O
11:11justin_smithjust watch, they'll use his code to implement uber but for amway
11:11X-warriorystael: well, it wasn't an interview question... it was one part of the hiring process
11:12Glenjaminhrm, my instinct is to record the parent of each customer with something like {:parent <parent-id>}
11:12Glenjaminand then when adding a new customer, traverse the graph and add points
11:12X-warriorhttps://bitbucket.org/matheusbrat/clojure/overview
11:13Glenjamini guess something like {<id> { :parent <id>, :points n, :id <id> }, ...}
11:13justin_smithX-warrior: one issue with using a deftype with mutable fields, is that one assumes you will be using this structure in a webapp or some other process that handles concurrent clients, and mutable fields don't tend to handle concurrent update very well. This is kind of why we use immutable data structures with containers like atoms / agents / refs
11:14justin_smithotherwise you end up needing to mess with locking and such
11:14X-warriorGlenjamin: that seems as a nice approach
11:16X-warriorjustin_smith: got it
11:27ilevdHi, clojurebot
11:27ilevd,(print "Hi!")
11:28clojurebotHi!
11:39ilevdAsk, please
11:41cortexman_what's the deal with paredit not allowing you to insert the parens that will fix the mismatch?
11:42ilevdI don't know
11:43MJB47speaking of paredit
11:44MJB47(f| (f2 v)) -> (f2 v)
11:44MJB47whats the command called?
11:44MJB47| being point
11:44lumaraise
11:44MJB47ty
11:56justin_smithcortexman_: I've found paredit handles missing ) that you insert by hand nicely, but not other kinds of closing delimiters, which makes me think it's a bug
11:56justin_smithcortexman_: the easiest thing is to turn off paredit, fix the matching, then turn it back on again.
11:57justin_smithcortexman_: but you can also use commands like kill and yank without being affected by paredit, so that's another approach
11:57cortexman_got some good tips from #lisp. i.e., to fix ((( ))) to ((( ])), stick the cursor in the space in the middle, M-z ) C-q ] M-z is zap-to-char and C-q is quoted-insert
11:58justin_smithahh, nice
11:58justin_smithso yeah, zap-to-char and quoted-insert must also be outside paredit, like kill-region and yank are
11:58cortexman_yeah
11:59cortexman_i think it's fewer keystrokes this way, maybe.
11:59justin_smithalso in evil mode, r is not effected by paredit, so you can insert spaces and use r to change each one to the right kind of delimiter
11:59cortexman_i have been thinking about switching to evil mode, but have not taken the dive
12:00justin_smithI switched, and I liked it so much that I eventually started using vim
12:00justin_smithhaha
12:00cortexman_lol.
12:00cortexman_this is a good reason to use emacs: https://github.com/RallySoftware/rally-emacs
12:01justin_smithin terms of being able to extend it to make apps, emacs is at least as good as the browser (though not nearly as pervasively deployed)
12:05justin_smithwooh, this guy used my webapp to help write this article! http://www.vox.com/2016/3/15/11225128/donald-trump-gullible-internet
12:05justin_smith(webapp is full stack clojure/cljs)
12:06justin_smithdirect link to the part that came from our app http://www.getlittlebird.com/blog/data-62-of-the-people-donald-trump-rted-this-week-follow-multiple-white-supremacist-accounts
12:27TimMcFun!
12:31justin_smithAs compared to what my prior work has been used for, it's definitely gratifying to see the product of my sweat used that way.
12:32TimMcTo the extent to which I can get excited about anything with "social media" in the title, this is neat. :-P
12:32justin_smithheh, it's a fun app to work on
12:33TimMc(my social media strategy is the LeechBlock browser add-on)
12:59sfz-XD
13:43tolstoyI use Control-Q (quote) and Control-W (delete) to repair par-edit stuff.
14:09ben_vulpesdoes anyone know where the datomic provisioning clojure lives, if it's even available to the public?
14:13amalloyisn't life a lot easier if you just don't break paredit stuff? how does everyone end up with so many unbalanced expressions?
14:17TimMcamalloy: It sometimes happens. I have no idea how.
14:17TimMcParedit does have at least one bug around comments, though.
14:36sdegutisWelcome.
14:51sdegutisWelcome to #clojure.
14:53TimMcanything is possible at #clojure
14:53TimMcthe only limit is yourself
14:55rcg,(/ 1 0)
14:55clojurebot#error {\n :cause "Divide by zero"\n :via\n [{:type java.lang.ArithmeticException\n :message "Divide by zero"\n :at [clojure.lang.Numbers divide "Numbers.java" 158]}]\n :trace\n [[clojure.lang.Numbers divide "Numbers.java" 158]\n [clojure.lang.Numbers divide "Numbers.java" 3808]\n [sandbox$eval25 invokeStatic "NO_SOURCE_FILE" 0]\n [sandbox$eval25 invoke "NO_SOURCE_FILE" -1]\n [clojure.lang...
14:55rcgor the laws of mathematics...
14:55rcgscnr
14:56sdegutisYou can do /anything/ at #clojure.
14:57TimMcrcg: http://zombo.com/
14:57sdegutisAnything at all.
14:58sdegutisThis is #clojure, and welcome, to you, who have come to #clojure!
14:59sdegutisThe infinite is possible at #clojure. The unattainable is unknown at #clojure.
14:59tolstoyparedit rarely breaks for me, but sometimes I inadvertently cut/paste something wrong from a non-Emacs buffer.
14:59sdegutisOh man. This site takes me back.
14:59sdegutistolstoy: that's what undo-tree is for
14:59tolstoyMissing Plug-in?
14:59sdegutisbecause Emacs without undo-tree is literally just pure unadulterated insanity.
15:00rcgTimMc, sorry, due to lack of plugins, i cannot watch that, even got my linux box from the shelf to check. but according to the wikipedia article it sounds quite entertaining :)
15:02mavbozoyou can get "anything" from infinity at #clojure
15:02mavbozo,(get Double/POSITIVE_INFINITY get "anything")
15:02clojurebot"anything"
15:06sdegutismavbozo: bravissimo
15:07sdegutisTIL you can intensify Italian words like "bravo" by adding "issim" after the final consonant
15:07sdegutisAlso pianissimo means "very quiet"
15:07sdegutiser, very soft
15:17mavbozosdegutis: grazie infinite!
15:22sdegutisToday my job is to normalize internal data using a sequence of regex-based migrations.
15:23sdegutisWhat can go wrong?
15:23ystaelsdegutis: where are you located, roughly? i want to know whether i need to get a car and start driving
15:23sdegutis:D
15:37X-warriorjustin_smith: I changed my solution to use a map as proposed. Did you have time to take a look on the previous version?
15:59mavbozo,(:a.b.c/foo {:a.b.c/foo :bar})
15:59clojurebot:bar
16:00mavbozois it okay to have keyword which has '.' in its namespace part?
16:01mavbozobut this http://clojure.org/reference/reader#_literals says keywords cannot contain '.'
16:02hiredmanit is refering to the name part
16:03hiredmankeywords and symbols have name and namespace parts
16:05hiredmanthe set of allowed characters for symbols and namespaces on th reader page don't match the characters the reader actually accepts, and are just for symbols and keywords created via the reader
16:06mavbozogot it. thanks hiredman
16:10hiredman,:foo.bar
16:10clojurebot:foo.bar
16:10hiredman,*clojure-version*
16:10clojurebot{:major 1, :minor 8, :incremental 0, :qualifier nil}
16:34TimMc,(keyword ":")
16:34clojurebot::
16:46sdegutisDoes something like distinct-by make sense?
16:47sdegutisSo that (distinct-by first [0 :a] [0 :b] [1 :c]) would -- oh wait
16:47sdegutisHmm. Guess I need to transform my data.
17:29sdegutisBye.
17:38sdegutisWhat's an agreeable way to tell if any item in a collection satisfies a given predicate?
17:38sdegutisSomething like (any? coll f)
17:39cflemingsdegutis: (some f coll)
17:39sdegutisHmm, strange name.
17:39sdegutisThanks Colin.
17:39sdegutisI had a feeling that was the function, but it seemed like maybe I was going insane.
17:39justin_smith,(some nil? [false nil true])
17:40clojurebottrue
17:40sdegutisThanks Justin.
17:40justin_smithheh, just reminding myself how it behaved
17:41sdegutisHmm. Interesting.
17:42sdegutisOur data is just so... actually, no, there aren't words to describe it.
17:48sdegutiscfleming: so how's your IDE going?
17:49cflemingsdegutis: It's going really well.
17:49cflemingLots of free non-commercial licences gone out, but lots of people paying for it too.
17:50cflemingSo it's definitely looking sustainable at this point, assuming a reasonable number of people renew and some growth in the community.
17:50sdegutiscfleming: So has it become a full time gig now?
17:50cflemingYeah, it has been for a while now.
17:50sdegutisSweet.
17:50sdegutisI like your icons of companies who use it on your home page. That's a clever idea.
17:51cflemingI'm just getting back to development in the last couple of weeks after the support spike after releasing.
17:51sdegutisYikes, that sounds like it was really boring.
17:51cflemingThanks! I think a lot of companies do that for their products. Lots of companies don't allow use of their logo, sadly.
17:52cflemingYeah, that and licensing, EULAs, payment systems, etc etc - I haven't done much real work since October/November.
17:54ben_vulpes'real work' heh
17:54cflemingYeah, none of the rest feels like real work, it's all necessary though.
18:09cortexmani'm trying to figure out how to link my cljs buffer with my ClojureScript REPL in emacs
18:13cortexmansupposedly it's C-c M-J (capital J) but it doesn't seem to hook up correctly
18:15sdegutiscfleming: I hear ya, I'm only recently getting back into being really productive.
18:23rhg135productivity is a lie
19:19Kamuelarhg135: lol
20:02sdegutisSo I guess ->> can't see on the inside of #() special forms.
20:02sdegutis,((->> [1 2 3] (map inc) #(apply +)))
20:03clojurebot#error {\n :cause "Wrong number of args (1) passed to: core/apply"\n :via\n [{:type clojure.lang.ArityException\n :message "Wrong number of args (1) passed to: core/apply"\n :at [clojure.lang.AFn throwArity "AFn.java" 429]}]\n :trace\n [[clojure.lang.AFn throwArity "AFn.java" 429]\n [clojure.lang.RestFn invoke "RestFn.java" 412]\n [sandbox$eval25$fn__26 invoke "NO_SOURCE_FILE" 0]\n [sandbox...
20:04sdegutisEver notice that?
20:07justin_smith,(macroexpand '((->> [1 2 3] (map inc) #(apply +))))
20:07clojurebot((->> [1 2 3] (map inc) (fn* [] (apply +))))
20:09justin_smith,(macroexpand '(->> [1 2 3] (map inc) #(apply +))) ; sdegutis - this makes it pretty clear what happens
20:09clojurebot(fn* [] (apply +) (map inc [1 2 3]))
20:25rhg135,'#()
20:25clojurebot(fn* [] ())
20:29TimMc,(-> foo #(inc 5) ())
20:29clojurebot#error {\n :cause "Can't call nil, form: (nil (fn* foo [] (inc 5)))"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.IllegalArgumentException: Can't call nil, form: (nil (fn* foo [] (inc 5))), compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyzeSeq "Compiler.java" 6875]}\n {:type java.lang.IllegalArgumentException\n :message "Can't call nil, fo...
20:29TimMcmmm, right
20:29TimMcalso, interesting
20:30TimMc,(macroexpand-1 '(-> 4 ()))
20:30clojurebot(nil 4)
20:33rhg135What?
20:33clojurebotWhat is sampling a random integers betwen 2, 12 s..t. P(X = i) = (7-|i-7|)/36
20:34rhg135Right?
20:39justin_smithwhat a card
20:41rhg135I know. clojurebot is so funny and smart and cool
20:42justin_smithI just wish clojurebot would stop stealing my girl.
20:43TimMcrhg135: The macro sees a list and does (cons (first list-form) (cons inserted-form (rest list-form))) or something
20:43TimMcwhich is (cons nil (cons 4 ())) in this case
20:43rhg135Ah
20:44rhg135justin_smith: who is your girl?
20:44TimMchttps://github.com/clojure/clojure/blob/clojure-1.7.0/src/clj/clojure/core.clj#L1564 yep, except it's using unquote-splicing
20:45justin_smithrhg135: sadly "my girl" is a rhetorical phrase used for comical effect
20:47rhg135Ah, those love triangles
23:48sdegutisHi.
23:48sdegutisI forgot why I opened IRC, but here I am.