#clojure logs

2014-09-15

01:06danielcomptonOur long national nightmare is finally over https://github.com/technomancy/leiningen/issues/1629
01:30jarodzzhi, guys
01:30jarodzzanyone has experience to add clojure into exisitng java project?
01:48seancorfieldjarodzz we run Clojure embedded inside a Java runtime, an app running on Tomcat... what's your question?
02:12kenrestivoi just realized my (--> love for the threading operator) is a legacy | of | being |a | unix | shell | guy
02:43augustlkenrestivo: i/o for the win
02:46kenrestivohas anyone tried to create a standalone windows/mac executable from a clojure program? i looked at the .iss file of leiningen-win-installer for ideas, and it looks intimidating.
02:46kenrestivoalso, just dealing with the oracle dependency as a separate install step might stop users from bothering.
02:47kenrestivolike, zoinks scoob: https://bitbucket.org/djpowell/leiningen-win-installer/src/9c971dd33439/leiningen-installer.iss?at=bitbucket-master
02:49amalloykenrestivo: the oracle dependency? you're worried about users who don't have java installed?
02:49kenrestivoyes.
02:50amalloywell, good luck. no clever ideas from me
02:52kenrestivohaha, no prob. this may be an app i have to write in C and wxwindows or similar. but it'd sure be nicer to write in clojure/seesaw instead.
03:00papachanhi there
03:01seancorfieldevenin' papachan
03:01augustlkenrestivo: you can redistribute openjdk afaik
03:01augustlnot sure how well that works in practice
03:01papachani am trying to make an assoc inside a function but i still cannot find a way out
03:02kenrestivoaugustl: oh cool, thanks. should work fine actually. but there would still need to be all that hairy .iss checking to see if there's a working vm there already first.
03:03augustlyou can of course also ignore that and always use your bundled openjdk runtime :)
03:03papachanhttps://code.stypi.com/papachan/test.clj
03:03augustlpapachan: what's the code?
03:03papachanaugustl, i just paste it
03:04augustlpapachan: there's no call to "assoc" there
03:04papachanauguts no, because nothing works were working
03:04papachanso i print the same local hasmap
03:04seancorfieldthat code prints results - it doesn't return anything
03:05augustlpapachan: what do you want/expect that code to do that it doesn't do now?
03:05papachanyeah
03:05papachanthis code print the two lines there is in comment
03:06papachanfor example it iterate over a hashmap
03:06papachanand put it in another hashmap structure
03:06papachani need to merge each result into a new hashmap
03:06seancorfieldpapachan I think you're looking for the merge function?
03:06papachani have tried womething
03:09papachanas i understand clojure way, it always return the merge result of each row, not the sum of all
03:10papachanm is a local hashmap so its stay immutable, my merge work for one row, but do not merge all the resulds
03:10seancorfieldah, so you want reduce
03:10seancorfieldreduce is the clojure way of looping of things to make a new thing
03:12seancorfieldthe local m map would be the initial map you start with, and params would be the collection you reduce
03:13seancorfieldand then you'd define a function to merge in each part of the collection to that initial map
03:13papachani have tried something like this
03:15papachan(reduce (fn [m [k v]] (assoc m k v)) y x)
03:21papachanseancorfield yes i understand that way, but i cannot change the map structure with reduce and assoc, i havent find the way
03:21papachani have tried with (reduce #(assoc % (keyword (str %2)) %2) y x)
03:23seancorfieldpapachan https://www.refheap.com/90268
03:23olliveraGiven the Authentication example below, how can I assign "conn" to a global var. I tried def, but (mg/authenticate db u p) returns a boolean.
03:23olliverahttp://clojuremongodb.info/articles/connecting.html
03:24podviaznikovHi, I'm trying to scrape cyrillic web page with enlive. Parsing seems to work but I can't see readable text in the console(both lighttable and REPL). Does anyone know if it's some issue with console or I need to specify encoding before enlive html parsing?
03:27papachanseancorfield it works. really cool.
03:29zotdoes clj have a way to print out structures in a way that they can be pasted back into the repl (a la python's %r format)?
03:30amalloyzot: that's the default print format. just put a ' in before you paste, to quote the data structure
03:33zotok, then what i'm printing must not be pure map/vector/string :/
03:34zotamalloy: tnx :)
04:06kenrestivoso if i wanted to, say, emit liquidsoap from clojure, is this still the best general approach to take? http://clojure-doc.org/articles/tutorials/growing_a_dsl_with_clojure.html
04:07kenrestivo(liquidsoap is itself a dsl, kind of ruby-like syntax, which was written in ocaml)
04:08clgvkenrestivo: you want general advice on best practices to create a DSL with clojure?
04:08kenrestivothat'd be a good start, yes
04:08kenrestivoi've seen lots of stuff in the past, i just don't know what's the current best thinking on the topic
04:09clgvwell, usually you start writing functions that do what you want. when you encounter cases in your DSL where you need specifiy evaluation semantics you introduce a macro for that
04:09clgvspecification can be done in pure clojure data (maps, vectors, sets)
04:10kenrestivook, that's generally what i've seen. i didn't know if there was any spiffy new way to do it nowadays, like "you'd use tools.analyze.foo" or similar
04:10kenrestivodoing it with simple functions and macros is just fine with me, if that's still the recommended way
04:11clgvno, the tools.analyzer stuff is mainly for wrinting clojure(script) compilers - though it can be used in tangantial topics as code analysis etc
04:11clgv*writing
04:14clgvkenrestivo: usually it hurts to do too much special. for example I used a special registry for a DSL just too switch back to clojure namespaces some months later
04:15kenrestivook, thanks
05:12zotok, just found out the hard way that creating a java buf'd file writer in a let does *not* get it nicely flushed/closed. is there a graceful to handle this? the let stmt handles input from both stdin or from the command line, and uses bind, which makes with-open impractical. ideas? (code snippet coming...)
05:14zothttps://gist.github.com/anonymous/e381f4df594421cbbf75 — without the .flush call, my result doesn't make it out :/
05:15Bronsazot: use with-open to automatically close the buffer
05:15amalloyzot: what makes you think with-open is impractical? it is easy to apply here
05:15zotnaivety, clearly :)
05:16amalloy(with-open [out (...)] (binding [*out* out] ...))
05:16zotbut then it will close my stdout after the stmt, correct?
05:17amalloyno?
05:17clojurebotno is tufflax: there was a question somewhere in there, the answer
05:17zotin my head the jvm would have done a nice garbage collection-y thing on the object at the end, which would include flushing the buffers.
05:18zotamalloy: the descr from with-open suggests otherwise — "and a finally clause that calls (.close name) on each name in reverse order"
05:18amalloyzot: a correctly-written program can never depend on garbage collection for its correctness
05:18zotperhaps i misread it?
05:18amalloyindeed, it will close out, the temporary thing you created
05:18amalloybut not the stdout for your process
05:20zotif stdout is specified as the output, then it would also get closed; it probably doesn't matter here, but i dislike closing stdout, since i will almost certainly later put print stmts, etc., there, and forget that it's dead :/
05:21amalloyhuh? you are totally focused on imaginary side effects of a thing that is not happening
05:23zothttps://gist.github.com/anonymous/346827c515696975e94a - for me, only "line 1" is printed, presumably due to stdout now being closed
05:24amalloyyes, good lord, don't write that
05:24amalloynobody said to write that
05:24zotbut that's my "imaginary" case
05:24zotin the let stmt of my code, out can be *out* as well.
05:25zothence my side effect
05:25amalloyi see. that was an easy-to-miss subtlety
05:26amalloythen you will need to flush, or use println, which flushes
05:26zotnow that we've got that out of the way … any great ideas? :)
05:27zotyeah, i figured out what the problem was when i used println, but prefer to be explicit with flush since it's required.
05:27zotbut technically the file still isn't closed, so the argument about relying on GC side effects still carries some philosophical weight
05:29amalloyyeah, if you want to have different behavior for the stdout vs file cases, you will have to do more than just bind *out*
06:35lazylambdaguys, I have a question
06:36lazylambdalet forms in clojure aren't lambdas like scheme and common lisp, right?
06:37clgvno, they are not. are they in CL?
06:38clgvbut maybe you interpret your question differently. can you be more specific?
06:38lazylambdayea, (let ((a 1) (b 2)) (+ a b)) is just syntactic sugar for ((lambda (a b) (+ a b)) 1 2)
06:38lazylambdain scheme and common lisp
06:39lazylambdain clojure, the semantics are different
06:40clgvno in clojure it would look like the following java snippet: final long a = 1; final long b = 2; return a + b;
06:40lazylambdaexactly
06:40lazylambdaI was just making sure
06:40clgvwhen you use a java decompiler you'll see that pattern
06:41lazylambdaI was just going through SICP with clojure, and the clojure let was behaving differently than in scheme and CL
06:42clgvthere is another distinction clojure's `let` is more like `let*` in CL
06:43lazylambdayou are correct, that didn't hit me
06:45Bronsalazylambda: I don't think any cl/scheme impl actually implements let in terms of lambda
06:46bjaBronsa, chicken scheme might, but how it implements it and what happens after compilation don't seem to bear any resemblance to each other
06:46lazylambda@Bronse it does, you'll find that explained in SICP and in Paul Graham's Ansi common lisp..it makes sense if you translate one into the other
06:47lazylambda@Bronsa it does, you'll find that explained in SICP and in Paul Graham's Ansi common lisp..it makes sense if you translate one into the other
06:48lazylambdaBronsa: I suppose implementations are free to do what they want though, but semantically they are both equivalent
06:48Bronsalazylambda: no, all they say is that (let ((a 1)) a) is equivalent to ((lambda (a) a) 1), but in reality they are not implemented in terms of one another
06:50clgvBronsa: that's what I suspected
06:59lazylambdaBronsa: I think you're right, I just looked it up
07:06lazylambdaI am new to clojure, folks. What open source projects would you recommend for a new comer?
07:09rweirto learn idiomatic clojure form?
07:12hyPiRionI would say that playing around with whatever you're interested in is good
07:12hyPiRionBut 4clojure is generally nice to do to learn clojure
07:13clgvlazylambda: yeah try out 4clojrue
07:13mskoudCan i get a list of fields from a record? (like python's dir function)
07:14lazylambdathanks, I already started solving some problems on 4clojure.
07:14lazylambdaI am also working on this bug in refheap
07:15hyPiRionlazylambda: ah, nice
07:15lazylambdaI'd like to get into core.logic as well, but I want to finish reading the reasoned schemer first
07:16rweirmskoud, (keys)
07:16lazylambdaAre there any open source AI projects done in clojure?
07:16mskoudah : (map #(.getName %) (.getFields Site))
07:17mskoudok. keys is nice if i have an instance.
07:18corecode_lazylambda: i think the term AI is not used anymore
07:18corecode_now it's machine learning, etc.
07:21tachibanait's beatiful ;]
07:22lazylambdacorecode_: lame :P.. I am more interested in rule based systems, but yea, machine learning is the hot thing today
07:22tachibanar u the lamda that is truly lazy??
07:24clgvcorecode_: it's just not "cool" anymore - but it is still used and distinct from machine learning ;)
07:25clgvtachibana: yeah you have to call him to get an answer ;)
07:25lazylambdaI think symbolic AI is more interesting than the statistical stuff
07:26hyPiRionlazylambda: I think there's some work with core.logic out there
07:26tachibanastumped me with that one
07:27tachibanawho's core
07:27tachibanadifferent times call for different measures
07:30lazylambdahyPiRion: Nice, I'll look out for that. Thanks.
07:30daniel___anyone got a thinkpad E540 and can vouch for it?
07:32clgvdaniel___: you need someone you can sue if it ends up being crap? :P
07:32daniel___yeah clgv
07:33hyPiRionlazylambda: I wanted to work on the core.logic version of https://github.com/webyrd/relational-parsing-with-derivatives – but I didn't get time. It's not AI, but it's certainly useful core.logic material
07:33daniel___pls provide your address and contact details
07:33clgvgood look searching ;)
07:33clgv*luck
07:33hyPiRionI know there's other stuff out there, but unfortunately I'm not that into the core.logic work yet
07:33daniel___im not american, dont just sue people willy nilly
07:39CookedGryphonWhich of the automatic test refreshing lein plugins actually works for normal clojure.test?
07:40CookedGryphonMidje doesn't show me the output of my non-midje tests, just says pass or fail, test-refresh fails, quickie always says everything passed, I've tried a few others too
07:42clgvCookedGryphon: isn't there "lein autotest"?
07:48CookedGryphonclgv: link? the lein-autotest I found on github looks old (last updated 4 years ago and still using lein 1)
07:48lazylambdahyPiRion: Nice, I'll check that out
07:48CookedGryphonclgv: and doesn't seem to run anything...
07:52CookedGryphonand cider-test-mode doesn't work, borks out with a syntax error...
07:52clgvCookedGryphon: damn ok, I just remembered that one
07:52CookedGryphonI think I'm stuck going back to the terminal manually
07:53clgvdoesnt expectations have an autorunner?
07:53CookedGryphonwell yeah, but I'm not using the expectations test framework
07:54clgvCookedGryphon: I thought it might integrate with deftest - but I am not sure, you'd have to check
07:55CookedGryphonIt probably does, but it still feels like overkill to pull in an entirely different test framework...
07:55CookedGryphonsurely there must be a plain clojure.test autorunner which works
07:55clgvCookedGryphon: otherwise you could steal from the other autorunners to write one for deftest
07:57clgvCookedGryphon: according to the readme lein midje should run clojure.test tests
07:59CookedGryphonyeah, it does
07:59CookedGryphonbut it was losing the output of my test.check and just showing me pass/fail status
07:59CookedGryphonwhich isn't useful for actually fixing the test
07:59clgvhwat output? error messages on failure?
07:59CookedGryphon*but* I've just realised taht it was printing it, just elsewhere
08:00CookedGryphonyeah, the actual information about what failed and how
08:00clgvprobably the reporting part does not integrate well`
08:00CookedGryphonyeah, but i've just realised if I'm only dealing with one failing test at a time, the output is manageable
08:01CookedGryphonso I'm happy enough for now
08:01clgvbut there is definitely room for improvement
08:14agarmanhttps://github.com/CareLogistics/somni <- it's yet another Ring routing lib.
08:17clgvthose grow like grass lately ;)
08:27agarmanyeah
08:28agarmanit's unfortunate. as hard as we tried, compojure, bidi, gudu, liberator all left us writing code we didnt' like
08:34zotis there a psuedo-standard place for test fixtures/inputs? foo/test/resources?
08:35clgvzot: "project-root/test" is the convention in lein, but you can change it in the project.clj
08:36clgvah you meant input data
08:36zotmy code is in there; but one of my tests is more end-to-end-ish and needs external inputs
08:36zotbeat me to it
08:36hyPiRiondev-resources
08:36clgvexactly ^^
08:37clgvI wouldnt mix code and resources in general
09:00stompyjbbloom: there?
09:42CookedGryphonyou know how most things in clojure are easily printable? Why oh why do exceptions not list locals?! I have an exception here saying I passed the wrong thing, chances are if I saw what that one thing was I'd twig immediately what I've mixed up
09:42CookedGryphonbut as it is I need to reconstruct the situation leading up to this call in the repl now
09:42justin_smithCookedGryphon: there are tools that let you investigate locals when stack traces happen
09:43CookedGryphonyeah, but I don't want to faff about with custom tooling
09:44CookedGryphon60% of the time, just having a few locals printed in the stack trace, limited to 20 chars or so, would be enough to tell me exactly what the issue is
09:44justin_smithHow would it know which stack frame to show locals for?
09:45CookedGryphonthe one that exploded, the top one
09:45CookedGryphonif you're writing semi-reasonable clojure code, everything you're interested in will be closed into that frame
09:45justin_smiththen you'll get some locals inside clojure.core
09:45justin_smith(with most stack traces I see at least)
09:46CookedGryphonno you wouldn't
09:46justin_smiththe top frame, when I see exceptions, is usually quite a few levels of indirection away from any code I wrote
09:47CookedGryphonyeah, but the value that caused it to explode is still there
09:48justin_smithand it is usually nil
09:48CookedGryphonfor example if you passed 2 into something which tried to use it as a seq
09:48CookedGryphonthat's different
09:48CookedGryphonnil is teh one case where it already gives you the value you passed in
09:48CookedGryphonand it's highly useful
09:48CookedGryphonimagine if instead of saying can't do anything with nil, it just said "There's a problem with the value you gave me"
09:48CookedGryphonbecause that's the situation we have with every value other than nil
09:49bbloomstompyj: what's up?
10:04boodlehi, I'm looking to change a vector as follows.. (looking for elegence): https://www.refheap.com/90271
10:10cityspiritboodle: try (mapcat identity coll)
10:13sveriHi, I am using midje to count function calls with the provided function, now, I have a case where one function argument is a vector of elements and I want to make sure that function is called with the right number of elements in that factor like this: (provided (func-call arg1 [elem1 elem2]) => anything :times 1). Is it possible to apply some predicates or something like this? (provided (func-call arg1 [(> % 1)]) => anything :times 1)
10:14boodlecityspirit: brilliant! Thank you (off to study mapcat!)
10:14tim_sveri: if your functions are pure, then why do you need to count how many times they are invoked?
10:14clgvboodle: or easier (apply concat coll)
10:14boodleclgv: I figured there was an 'apply' way of doing it
10:15clgvboodle: mapcat does not makes sense since only the "cat" referring to "conact" is used ;)
10:15clgv*concat
10:15tbaldridgeseveri: the much better approach (IMO) is to mock out your side-effecting modules, then test the inputs and outputs to the system. Put an atom in the mocks if needed to validate that they are called with the correct data
10:15sveritbaldridge: Basically I want to test if the right calls to the right functions are made, and sometimes not all functions are pure, I guess
10:16TimMcboodle: By any chance are you generating these vectors from a for macro?
10:16tbaldridgesveri: IMO the way midje encourages you to (provided...) calls is an abomination. That's not the way it should be done </rant>
10:16boodleTimMc: honeysql, so I believe yes.. for where stmts
10:17tbaldridgesveri: one way (the way I prefer) to look at testing is this: What happens inside my code is of no concern of the tests. As long as the right value is returned and the right side-effects happen, the code is correct.
10:18TimMcSo, instead of (apply concat (for [v (thing)] ...)), what you can do is (for [v (thing), x ...] x)
10:18boodleTimMc: excellent, ty!
10:18tbaldridgeso test the outputs and mock the side-effects, and you're set. Otherwise if you change the internals of your code, you'll have to update all the tests that make incorrect assumptions as to how the code under test is constructed.
10:18TimMcand check out the other bindings and control options in the for macro
10:20boodleTimMC, sure, I always think (unfortunately) in terms of 'map' first rather than things like 'for' for generating seqs/colls
10:21sveritbaldridge: this sounds like a valid statement, however, I just have a method that has two side effects (first: write incoming data into database, second grab some changed database data and schedule some events. Then, what would the output of such a function be? How do I test that this function successfully calls the two sideeffecting functions with the correct arguemnts?
10:23clgvsveri: do you mock the database with an sqlite database or similar?
10:23svericlgv: I use datomic and it's in memory database functionality
10:23clgvah ok
10:23tbaldridgesveri: then you're set! just create the DB at the start of the test, run your code, then run a query against the DB.
10:24justin_smithsveri: when possible, it helps to separate logic from side effects - make stateless functions that do all the logic, and then make the part that does side effects a simple conjoining of the logic plus the side effecting code
10:26sveritbaldridge: well, for the first case (writing data to database) that is ok and I have tests for this, but the seconde one is harder, hm, the longer I think about it, the original problem I had was indeed a type problem, I passed a string instead of a UUID, and that lead to the error that no runtime exception was thrown, but even, no data in database was found
10:27sveriMaybe it's better to do a type assertion on params in that case
10:27justin_smithsveri: I think prismatic/schema may help here too
10:28sverijustin_smith: Yea, I finally have a reason to look deeper at it
10:28sverithanks everybody for taking time to listening :-)
10:28tbaldridgesveri: are you sure the Datomic error wasn't swallowed by something? I've had Datomic throw type errors many times.
10:29sveritbaldridge: Well, not 100%, but I think so, I never saw any error, neither during manual tests nor during automated testsin this case
10:49tbaldridgesveri: btw, you have an even better way of testing if you're using Datomic. Have your function return pure data, don't call transact inside the function at all
10:54jtacketthey has anyone done any clojure work with voice to text
10:54jtackettor speech recognition
10:54zotcan you run lein on another directly (ie, from a make system, i can do "cd ../foo; lein run …" but wondered if i can do it without the cd indirection
10:55mdrogalisjtackett: Sounds like a good place to shell out to Java libs. But I haven't, no.
10:55zots/another/another directory/
10:55jtackettmdrogalis: I think you’re probably right, just hoping there is a clojure library/wrapper for it
10:56justin_smithzot: if you have an uberjar, you can run java from anywhere and point the classpath to the uberjar
10:56zotjustin_smith: that way i knew, but was curious about it from a 'live' dir, without having to gen
10:56mdrogalisjtackett: Definitely :)
11:17Jaood_b
11:18jlongsterhey guys, transducers provide a way to to make a custom data type that is reducible and automatically get all the transforms. but I don't see a protocol for constructing my custom data type. does it need to implement `conj` somehow?
11:19jlongsteror are you supposed to just natively take an transducer and my data type runs it and returns a collection of the same type as itself?
11:22lvhjlongster: CollFold, CollReduce
11:22lvhjlongster: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/protocols.clj#L13
11:22jlongsterlvh: `reduce` only implements how to take apart the data and iterate over it. it doesn't care about how you piece it back together into a specific type
11:22lvhyou get Iterable for free though
11:23jlongsterthe function I pass to `reduce` will manually create something like a vector using `conj`
11:24lvhjlongster: ehh? that sounds different from what you were just saying about creating a custom reducible datatype
11:25jlongsterlvh: I said I understand that part of it. I don't understand the other end. You can `into` to "run" a transducer and create a new type, but it uses `conj` so can only create native data types
11:25jlongsterif I create a new data type, what is the pattern for providing something like `into`?
11:30lvhjlongster: Okay, so, to be clear: you're not interested in getting your data structure to be foldable/reducable, you're interested in getting into to dump items into your data structure?
11:31jlongsterlvh: yes! and full disclosure, I'm just studying and am not trying to do something specific.
11:32dnolen_jlongster: this is why transduce takes a transformer `xform` and `f`, `f` builds the next result
11:32lvhjlongster: So, "conjable" is IPersistentCollection
11:32dnolen_it's also why transduce really requires an initial value, `f` must produce it or you must give `init`
11:33lvhbut dnolen_'s answer is the enlightening one here, I presume :)
11:33jlongsterdnolen_: yeah, I didn't know if there was a way to have the simplicity of `into`. if I want to just `map` over my structure and not think about reduce
11:33dnolen_jlongster: transducers have nothing to do w/ conj, you can use map/filter now to build arrays if you like in CLJS
11:33jlongsterlvh: what's `conjable`?
11:34jlongsterdnolen_: oh yeah, I realize that. I was just looking to see if there was a way to do something like `into` (which assumes how it's reduced and put back to together)
11:34dnolen_jlongster: into is just really just `f` = `conj` and `init` = empty data structure
11:34dnolen_transduce with those arguments supplied
11:35dnolen_not exactly much more verbose
11:35dnolen_especially if `f` can supply init
11:36jlongsterdnolen_: well, (transduce (map inc) conj [] [1 2 3 4)) is more verbose than (map inc [1 2 3 4]). now assume I'm not working with a vector, but with a custom type
11:37dnolen_well first off (map inc [1 2 3 4]) doesn't even do what you want :)
11:37dnolen_(vec (map inc [1 2 3 4]))
11:37dnolen_or (into [] (map inc [1 2 3 4]))
11:38dnolen_that's what you're comparing transduce to
11:38jlongsterdnolen_: still writing clojure abstractly (haven't written much real code), sorry :)
11:38justin_smith$source mapv
11:39jlongsterdnolen_: I see. map returns a lazy-seq when the collection is there
11:39dnolen_jlongster: yep
11:39dnolen_jlongster: but, as you probably already know, into is now defined in terms of transduce now
11:40jlongsteryeah! but I'd like that short form to also because to create custom data types somehow
11:40jlongsterso I'm working on transducers.js. It's pretty awesome. I get everything but this is the last piece
11:41dnolen_jlongster: there's not really any good way to magically do that at least in a dynamically typed context, not w/o a the collection supplying an answer to something like empty
11:41dnolen_note all of this is really orthogonal to transducers
11:41SagiCZ1~?
11:41dnolen_since transducers are designed specifically to not have to deal w/ collections
11:41clojurebotexcusez-moi
11:41dnolen_otherwise the core.async transducer stuff would not work
11:41jlongsterdnolen_: yeah, this has nothing to do with transducers. I'm trying to figure out what convenience functions to provide for stitching values back together
11:41jlongsterthat's all
11:43jlongsteryou wouldn't normally use `transduce`, but rather `into` because it's shorter
11:43dnolen_jlongster: but you're not really asking about `into` right?
11:45jlongsterdnolen_: I guess not exactly. I know how it works, but you can't use it if using custom data types. If I'm using immutable-js with transducers, I'd rather not always have to use `transduce`
11:45jlongsterbut maybe I should try that first
11:45dnolen_jlongster: in ClojureScript this is non-problem because of protocols
11:45dnolen_jlongster: you can make a custom data type implement ICollection, IEmptyable - done
11:46jlongsteroooooh there it is. That means you implement `conj` for your structure. yep
11:46jlongsterexactly what I was looking for
11:47jlongsteryeah protocols are awesome, I hate JS's lack of interfaces
11:48jlongsterdnolen_: btw my transducer.js already beats lodash is many benchmarks, haha
11:48jlongster*in many
11:48dnolen_jlongster: nice not suprising. I expect transducer to crush anything that people have yet tried in JS
11:49jlongsterdnolen_: it's absolutely ridiculous. great performance and one single API works with everything. you guys are smart.
11:50tbaldridgejlongster: Rich is the smart one, we are simply his oracles here on earth.
11:51jlongstertbaldridge: haha
11:51mdrogalisBig red, run. :|
11:56stompyjdoes @aphyr ever hang out here?
11:56justin_smithstompyj: he is very active on twitter
11:58stompyjjustin_smith: thx, I’ll ping him on there
12:01perplexahi, when i have a map like { :kw1 { :kw2 { :kw3 "somevar" } } }, what is the preferred way to access "somevar"? i think i've seen something more elegant than (:kw3 (:kw2 (:kw1 {...}))) but can't remember anymore
12:01jbaiterwho would have thought that aphyr is into bondage...
12:02mdrogalisjbaiter: That awkward moment when an industry leading database thinker posts bdsm pictures to Twitter.
12:02mdrogalisperplexa: get-in
12:02perplexaah yeah thx!
12:03mdrogalisNp!
12:04raspasovperplexa: also (-> my-map :kw1 :kw2 :kw3)
12:04raspasovaka thread-first macro
12:09perplexaraspasov: get-in is the preferred way, isn't it?
12:11raspasovit might be, someone with more experience might want to chime in - the thread-first macro basically does a macro re-write of pretty much exactly what you posted (:kw3 (:kw2 (:kw1 {...})))
12:12perplexathanks :)
12:12raspasovnp :)
12:12noonianget-in is nicer when you have a collection of nested maps like that since you can do (map (partial get-in [:k1 :k2 :k3]) my-maps)
12:13raspasovas long as your keys are keywords, I believe both offer safety guarantees in the sense it won't throw exception of a key is missing and return nil instead
12:13raspasovif a key*
12:14nooniandoh my example was wrong heh, can't use partial like that since it expects the map as the first arg :P
12:16justin_smith(map (comp :kw3 :kw2 :kw1) c)
12:19raspasovjustin_smith: nice :)
12:27justin_smith,(letfn [(rot [f & args] (apply f (last args) (butlast args)))] (map (partial rot get-in [:a :b :c]) [{:a {:b {:c 0}}} {:a {:b {:c 2}}}]))
12:27clojurebot(0 2)
12:27TimMc$seen aphyr
12:28justin_smithTimMc: lazybot is still out
12:28TimMc:-(
12:32arrdemcbp: o/
12:33cbparrdem: sup
12:42hoverbearAnyone ever had this issue before with clj-http? Cannot cast DefaultHttpClient to CloseableHttpClient https://gist.githubusercontent.com/Hoverbear/f9715961a5cd8ea19cdb/raw/150944c1efeaee72231595fa353313cffd5d5800/gistfile1.clj
12:47perplexaraspasov: so, the thread first macro fails for (-> config :kw1 (keyword "kw2") :kw3), whereas get-in works :)
12:48perplexasurprisingly works, though when i assign (keyword "kw2") to another variable first, though.
12:48perplexaat least to me that's surprising :P
12:48perplexaotherwise i get: ClassCastException clojure.lang.PersistentArrayMap cannot be cast to java.lang.String clojure.core/keyword (core.clj:575)
12:49quilewell, isn’t the problem that (keyword "kw2") is being rewritten by the macro?
12:49justin_smithperplexa: ((keyword "kw2")) would also work
12:50perplexaindeed it does
12:50justin_smithperplexa: welcome to the weird side of macros
12:50perplexahaha
12:50justin_smith(it gets much weirder)
12:50perplexayeah i've seem some of them ;x
12:51perplexaclojure must be the most unintuitive thing to learn \o/
12:51perplexait's fun tho
12:51justin_smithperplexa: the number of rules and special cases to remember is actually fairly low, it's just not the same rules and special cases all the "normal" languages have is all
12:52perplexasometimes i end up catching myself writing something like x * y and then wonder why it doesn't work :D
12:53perplexamoments of epic facepalm
12:53SagiCZ1perplexa: happens to me all the time
12:53arrdem$google expresso
12:54cbp~lazybot
12:54clojurebotlazybot is echo ~lazybot
12:54justin_smith$google where is ma lazybot, bring back ma lazybot dammit
12:54arrdemexpresso's good for when you need infix math... but it's definitely not as nice as I'd like
12:54SagiCZ1perplexa: but what gets me everytime are the idiotic nonsensical exceptions.. for example Class not found when you pass int instead of double into some Math function.. i HATE that
12:54arrdemRaynes: UR BOT IZ TRASH AND U R 2
12:54SagiCZ1,(Math/sqrt 5)
12:54clojurebot2.23606797749979
12:54RaynesI don't think anyone ever just says "lazybot is down" anymore.
12:54SagiCZ1,(Math/sqrt (int 5))
12:54clojurebot2.23606797749979
12:54SagiCZ1damn it
12:55perplexa:D
12:55arrdemRaynes: but that's no fun...
12:55SagiCZ1perplexa: ok i guess it just doesnt work in my project xD
12:55SagiCZ1,(Math/sqrt 5 5)
12:55clojurebot#<CompilerException java.lang.IllegalArgumentException: No matching method: sqrt, compiling:(NO_SOURCE_PATH:0:0)>
12:56SagiCZ1that kinda makes sense.. ok i will shut up now
12:56perplexasoooo, which do i want? (-> config :aggregations ((keyword aggregation)) :sink-schema) vs (get-in config [:aggregations (keyword aggregation) :sink-schema])
12:56perplexathey're both kinda nice :P
12:57cbpi think the latter is easier to understand
12:57perplexaso i go with the former? :D
12:57justin_smith((comp :sink-schema (keyword aggregation) :aggregations) config)
12:57noonianperplexa: i like the latter, agree with cbp
12:57perplexame too, actually.
12:57perplexaalso need to look up what comp does :P
12:58noonianstands for compose
12:58cbpmakes you an egghead
12:58TimMcRaynes: What, you don't have a paging alert on lazybot's status?
12:58noonian((comp f g) 7) == f(g(7)) in math syntax
12:59justin_smithI like comp because it returns a function, so you can easily bind it to a more meaningful name and call that
12:59noonianyeah, i like using it like that, same with partial
12:59justin_smith(let [get-schema (comp :sink-schema (keyword aggregation) :aggregations)] (map get-schema configs))
12:59noonianand it makes your programs 'cuter'
13:00justin_smithnoonian: yeah, gotta keep up with the kawaii metrics
13:01TimMchiredman: Moving `lein compile` from encrypted disk fs to a ramfs took real/user timing from ~70/30 to ~15/30. So that seems confirmed.
13:01noonianjustin_smith: always introducing me to new memes :P
13:02perplexathx justin_smith / noonian
13:02perplexalearned something new again today
13:02perplexacomp is damn mind twisting, tho
13:03arrdemeh? the only remotely odd thing about comp is its argument order...
13:03perplexawell it's reversed ;p
13:03arrdemright that's what's confusing about it :P
13:05justin_smithnoonian: thanks to this exchange, my usage of comp will now be accompanied by the mental image shrieking teenage japanese cartoons with heart bubbles and eyes larger than their cranial capacity
13:09dmitrygusevjust knew there's Clojure Russia community on G+, please join: https://plus.google.com/u/0/communities/114227952963737516047
13:09perplexathanks for all the advice, guys
13:51Grazzy_Hola!
13:53shoepieGrazzy_: sup
13:54Grazzy_shoepie: looking for new interesting chans
13:55justin_smithGrazzy_: if you want to learn more about the Clojure programming language, this is a very interesting chan
13:55Grazzy_I want to learn as much as possible
13:55Grazzy_I was told to come here
13:55Grazzy_Can you tell me a bit about it?
13:57justin_smithIt's a langauge in the lisp-1 family that stresses immutibility and tractible concurrency
13:58xemdetiaGrazzy_, have you seen all the Rich videos?
13:58xemdetiait answers a lot of the why
13:59Grazzy_nope
13:59noonianyeah, i would highly recommend the 2008 video introducing clojure from infoq
13:59noonianGrazzy_: http://www.infoq.com/presentations/hickey-clojure
14:00noonianand just be prepared for things to be very different from what you are used to at first if you have never seen a lisp before or done functional programming
14:00Grazzy_noonian: Thanks
14:00nooniannp
14:00xemdetiaIf anything it should make you more intrigued :)
14:00Grazzy_Oh now i get it
14:01Grazzy_I messed around with it a while back
14:01Grazzy_Lisp is great
14:01Grazzy_So hard though
14:01Grazzy_Whats the application of this language in the bigger picture?
14:02justin_smithGrazzy_: easy to use concurrency
14:02justin_smith(with performance)
14:02noonianfor me it has become my goto language for anything that doesn't need to startup fast or run on embedded devices
14:02tbaldridgeGrazzy_: assuming you mean "what can Clojure be used for", pretty much anything. Perhaps except shell scripting.
14:02Grazzy_Nice
14:03Grazzy_Ill look into it
14:03Grazzy_This looks great
14:03Bronsatools.analyzer now has a pass scheduler :) https://github.com/clojure/tools.analyzer.jvm/commit/4183ba79ef47ba57de3af46aac1d318fa1a0cd8a
14:03xemdetiaYeah the only thing I would mention that you may not have come across Grazzy_ is lein
14:04Grazzy_How big the community and support structure i.e stack over flow and fourm posts
14:05tuftGrazzy_: not too big and not too small in my experience
14:05noonianin my subjective opinion, there is a very active, helpful, and enthusiastic community
14:05justin_smiththis channel and stackoverflow are pretty active
14:06Grazzy_Yuh yuh
14:06Grazzy_im pumped
14:08Grazzy_clear
14:08Grazzy_Man this is great. Lisp that i dont understand mixed with something i know
14:08Grazzy_:D
14:09Grazzy_How many of these mixed breed languages are out there
14:09tuftGrazzy_: yes, it's an excellent gateway lisp =)
14:11xemdetiaGrazzy_, I would look at some of the other languages that cropped up on the JVM
14:11Grazzy_Ok
14:11Grazzy_Im so glad i started using IRC
14:12xemdetiaIt's mostly the fact that you can write in a new and interesting language and still have access to what you need from JVM which makes languages like clojure more practical then it otherwise would be
14:12Grazzy_I wish i was born 10 years earlyer and lived in the prime of the internet growth and culture
14:12xemdetiaGrazzy_, IRC existed more than 10 years ago :)
14:12Grazzy_Yea
14:13Grazzy_But 10 years is what i wanted
14:13Grazzy_*want
14:13tbaldridgeGrazzy_: but yes, there are other languages that mix a OOP platform with some other language. F# and Factor are two others that come to mind. But Clojure is probably the best :-P
14:13Grazzy_sweet
14:14noonianClojure was the answer to my quest for a practical lisp
14:14xemdetiaand Grazzy_ I wouldn't worry about when you got started- what's interesting now is interesting because it solves problems of the time
14:14xemdetiajust make cool stuff
14:14Grazzy_For sure! i love the technology that am able to grow up on. There is so much interesting things to learn
14:15Grazzy_There is so much i have no idea what my technological passion truly is
14:18tuftGrazzy_: the good pockets of irc are much the same as a decade ago =)
14:18tufts/as a/as/
14:21ToxicFrogRe: practical lisp: similarly for me, Clojure is the only lisp I've actually gotten real-world work done in.
14:21ToxicFrogI liked Scheme but I never really did anything with it.
14:23xemdetiascheme is fun, and gambit is very slick but the fact that normally with a lisp or scheme you had to build your entire library base from scratch make them nonstarters
14:24noonianplus they all support different libs and module systems so it is hard to write portable code
14:31yocapybarahi guys, I'm in cider, and I find I'm looking for a command to evaluate everything in my buffer, but in the REPL buffer so I can then mess around with the code. Am I really looking for a wrong thing? I keep finding I have to copy or C-c M-p each form into the repl, so I wonder if I'm just plain doing things oddly
14:31ToxicFrogxemdetia, noonian: yeah, that was kind of my impression, and well if I want a lightweight language with no library support I already have Lua for that~
14:43technomancyToxicFrog: Scheme is way older than Lua
14:43nooniani still use scheme when i want a repl that loads quickly for small computations
14:43ToxicFrogtechnomancy: yes, but I learned Lua first
14:44xemdetiaembedding Lua is still much nicer then scheme
14:44xemdetiatinyscheme isn't awful
14:44xemdetiajust Lua is easier
14:44technomancyToxicFrog: oh, I read that as "we already have lua" like as a civilization or something
14:45ToxicFrogYeah, no, it was that I personally knew Lua well before I looked at Scheme
14:56snrmwghello, does anyone have good ideas for CRUD method names? i thought about something like api namesapces, each domain goes in a namespace, but function names like 'read', 'load' (and i think 'update' at clojure 1.7) are already defined in clojure.core. method names like 'my.api.domain/read-domain' look somehow redundant to me.
14:57noonianyou can tell clojure to not refer to the core functions you want to define yourself if you want
14:58noonianin your ns form (:refer-clojure :exclude [read load])
14:58nooniani'm still experimenting myself with good api ns organization
14:59snrmwgcool. didn't know that feature, i will give it a try.
14:59snrmwgis it also possible to refer the core functions with an alias? just in case i would need one of them?
15:00xemdetiaYou should be able to import it directly again, right?
15:00xemdetiaor the longname
15:01xemdetia(these are guesses)
15:01snrmwgok, just never thought about importing something from core :) but why not, it's just a namespace as any other
15:02yogsotothHi! I am trying to use friend interactive-form, while the demo works the same workflows doesn't set any cookie. How could I start to debug this?
15:03sritchieyogsototh: do you have session middleware in place?
15:03sritchieyogsototh: it’s the session middleawre that sets the cookie, not friend
15:03yogsotothok thanks!
15:06yogsotothsritchie: thanks! It works. I didn't know how I could discovered this myself.
15:07sritchieI think he mentions it on the README
15:07sritchieit’s pretty buried though:
15:07sritchiehttps://github.com/cemerick/friend#authentication
15:07sritchiesee “Note that Friend itself"...
16:20kschraderanybody know how to jump to test definitions in the new version of Cider? it used to be C-c C-t, but now that says "No test report buffer"
16:20AeroNotixkschrader: never update CIDER if you can help it
16:21kschraderyeah, too late for that...
16:21AeroNotixkschrader: if you just upgraded "just because" then I'd advise you to downgrade if you have real work to do
16:21AeroNotixit's so broken on their latest release that it's horrible
16:21AeroNotixyour .emacs.d should be in VCS
16:21AeroNotixif not, time to start :)
16:21kschraderyeah, it is, I was just hoping for an answer :)
16:22justin_smithkschrader: every command is available by name via M-x, and if it has a keyboard shortcut, emacs will show you the shortcut in the minibuffer after running the command
16:23justin_smithit should be called something like cider-jump-to-definition
16:24justin_smithI think the canonical keybinding has always been M-.
16:25kschraderyeah, that's not what I'm looking for
16:25maravillaskschrader: C-c C-j, I believe
16:25maravillasif you're looking to jump from foo.clj to foo_test.clj, e.g.
16:25justin_smithkschrader: ahh, sorry, I missed the word "test" in your question, sorry
16:26kschradermaravillas: That's what I'm trying to find
16:26kschraderbut it doesn't seem to work anymore
16:26stompyjthe first rule of CIDER club is never update CIDER
16:26maravillasM-x clj-jump-to-other-file ?
16:26kenrestivofirst rule of cider club is use nrepl.el :-P
16:26kenrestivoi've been avoiding cider for years, so far so good.
16:27kschraderah, it's M-x clojure-jump-to-test now
16:27stompyj(inc kenrestivo)
16:27lazybot⇒ 1
16:27stompyjI’m on the cursive clojure train
16:40jlongsterhow do I install Clojure 1.7 with lein?
16:43technomancyjlongster: just edit project.clj
16:44jlongstertechnomancy: I tried that, but got https://gist.github.com/jlongster/4524b4552a1f98aac516
16:44technomancyoh, sorry... you mean the snapshot?
16:45jlongsteryeah
16:45gphilipparthi, how do I add a map to a vector ? For example I have {:a :b :c :c},, how do I get [{:a :b :c :d}] (conj and into won't) ?
16:46technomancyjlongster: it's in the sonatype snapshots repository
16:46seancorfieldjlongster: "1.7.0-alpha2" or "1.7.0-master-SNAPSHOT" (for the latter you'll need to add the sonatype snapshots repo)
16:46seancorfieldyou can use the alpha from maven without adding extra repos tho'
16:46jlongsteroh, thanks
16:46seancorfieldwe're running alpha2 in production...
16:47snrmwggphilippart: (conj [] {:a :b :c :c})
16:49gphilipparthm, yeah right.
16:51noonian,(into [] [{:a :b :c :c}])
16:51clojurebot[{:c :c, :a :b}]
16:52noonian,(vector {:a :b :c :c})
16:52clojurebot[{:c :c, :a :b}]
16:53justin_smith,,(assoc-in (vector {:a :b :c :c}) [0 :c] :d) ; pedantic
16:53clojurebot[{:c :d, :a :b}]
16:54noonian:D
16:54gphilippartthe issue I'm facing is when using clj-http.client/get, sometime it returns a vector of maps, and sometimes it returns just a map. I'd like to add both these types of results into a vector and return it with one expr. Is it possible ?
16:55justin_smithwow, I didn't think client/get was so fucked up as to randomly return different datatypes
16:56noonian,(let [get-result [{:status 200}]] (if (vector? get-result) get-result (vector get-result)))
16:56clojurebot[{:status 200}]
16:56nooniani just had this problem in python
16:56dakronegphilippart: get should never return a vector of maps, it should always be just a map, do you have code that backs up what you're seeing?
16:56gphilippartit doesn't do that randomly, I'm calling github's various api. /users will yield a vector of maps. /users/rhickey will yield a single map.
16:56dakroneahh yea, that's not clj-http, it's github's API
16:56noonianxmltodict uses lists if there are more than one child nodes and a single one otherwise, really annoying imo
16:57justin_smithgphilippart: so if you know what shape the data has by endpoint, why not have a different adaptor function as needed for each endpoint?
16:57noonian^ this
16:58justin_smithphew, good to know client/get is vindicated, I did think it was better than that
16:59gphilippartI'd like a function that gets any resource. It recurses on the 'next' link in the header ( https://developer.github.com/guides/traversing-with-pagination/).
17:01CisZZZaHello
17:03danielcomptongphilippart: not sure if you've seen https://github.com/Raynes/tentacles? I haven't checked to see if it keeps the shape the same or not
17:46seangrove$seen bbloom
17:46lazybotbbloom was last seen talking on #clojure 3 days ago.
17:52justin_smithseangrove: in this case it wouldbe more appropriate to ask bbloom how recently he saw lazybot - he was around earlier today
18:03seangrovejustin_smith: I guess lazybot isn't quite as perceptive as one might hope...
18:11amalloyis there some issue with lazybot's $seen?
18:16justin_smithlazybot has not been online consistently
18:16justin_smithhe had a bunch of downtime this weekend
18:19amalloylazybot: you're fired
18:26noonianlazybot should pull and parse rayne's logs on startup and backfill his or her or it's $seen data
18:26amalloynoonian: lazybot produces Raynes's logs. unless you mean the ones on his pc?
18:26noonianoh lol
18:27nooniani didn't know that
18:27amalloylazybot lives on the server Raynes and i run, and produces the logs at logs.lazybot.org
18:27RaynesI can assure you, the logs on my machine are far worse than lazybot's.
18:27RaynesEspecially given that I'm pretty sure I don't log.
18:27Raynes:p
18:27amalloyyeah, i would have guessed that too
18:28RaynesBut yeah, lazybot has been going down a ton in the last week or so.
18:28tac_,conj
18:28clojurebot#<core$conj clojure.core$conj@15d87c>
18:28nooniannaughty bot
18:28tac_Can you get a docstring from a function name?
18:29nooniantac_: you can get the meta data off the function's var
18:29amalloyfrom a function *name*? yes, just call doc. from the function itself, no
18:29tac_,doc "conj"
18:29clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0:0)>
18:29tac_,(doc "conj")
18:29clojurebot#<CompilerException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.Symbol, compiling:(NO_SOURCE_FILE:0:0)>
18:29noonian,(doc conj)
18:29clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
18:30tac_,doc
18:30clojurebot#<CompilerException java.lang.RuntimeException: Can't take value of a macro: #'clojure.repl/doc, compiling:(NO_SOURCE_PATH:0:0)>
18:30tac_hmm
18:31noonian,(-> 'clojure.core/conj find-var meta :doc)
18:31clojurebot"conj[oin]. Returns a new collection with the xs\n 'added'. (conj nil item) returns (item). The 'addition' may\n happen at different 'places' depending on the concrete type."
18:31noonian,(doc doc)
18:31clojurebot"([name]); Prints documentation for a var or special form given its name"
18:31noonian,(source doc)
18:31clojurebotSource not found\n
18:31noonian,(macroexpand '(doc doc))
18:31clojurebot"([name]); Prints documentation for a var or special form given its name"
18:31tac_,(source conj)
18:31clojurebotSource not found\n
18:32noonian,(macroexpand-1 '(doc doc))
18:32clojurebot"([name]); Prints documentation for a var or special form given its name"
18:33noonianhmm, i wonder why clojurebot does that, I get this in the repl
18:33noonian((var clojure.repl/print-doc) (clojure.core/meta (var doc)))
18:34noonian,*clojure-version*
18:34clojurebot{:interim true, :major 1, :minor 7, :incremental 0, :qualifier "master"}
18:35xemdetiaI'm just waiting for the day where I can do CI over IRC
18:35nooniani think that day has arrived
18:36noonianwe do ci over hipchat, i'm sure you could hook it up to irc without much trouble
18:37xemdetiaI was more talking about me personally
18:37Bronsa,(class @@#'doc)
18:37clojurebotclojure.core$eval445$fn__446$my_doc__447
18:37Bronsanoncom: ^ that's why
18:38Bronsaclojuredoc redefines clojure.repl/doc
18:38noonianah
18:38Bronsa,@#'doc
18:38clojurebot#'clojure.core/my-doc
18:38noonianBronsa: i'm sure noncom was interested also :P
18:39Bronsathis is probably better
18:39Bronsanoonian: ops
18:40tac_,(doc reduce)
18:40clojurebot"([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as well, and reduce returns the result of calling f with no arguments. If coll has only 1 item, it is returned and f is not called. If val i...
18:45shdDoes anyone know "gloss" library? https://github.com/ztellman/gloss Is it possible to read compiled frame size instead of entering it manually? Sorry for such a newbie question but i'm newbie indeed and i'm trying to learn by practice...
18:46shdi would figure it out myself but it's very hard for me to read this code yet
18:56noonianshd: i'd look at the wiki: https://github.com/ztellman/gloss/wiki/Introduction
18:56shdnoonian: of course read it, did you found answer to my question there? maybe i missed it..
18:56noonianimo manipulating raw bytes is not the easiest way to get a feel for a language unless its something a little closer to c :P
18:59shdnoonian: you might be right, but i'd like to use clojure in my hobby project and since it doesn't interface with C ABI that well i need to rewrite some basic stuff in it
19:00noonianshd: i'm not sure, but i think you need to call compile-frame to create a codec, and then should be able to call decode with that codec and your raw frame and it should decode it
19:00noonianraw frame meaning a byte stream
19:01shdnoonian: thanks, but i understand how to make a frames and decode them, it's just annoying to write [buf (byte-array 16) ...] manually, i don't really see this need
19:02noonianshd: i might be more help if i had a better understanding of what you are trying to do. Are you trying to serialize clojure data structures as bytes or read them back or both?
19:02tac_,(doc ->>)
19:02clojurebot"([x & forms]); Threads the expr through the forms. Inserts x as the last item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the last item in second form, etc."
19:03tac_does that just mean that (->> x f g) = (g (f x))?
19:04nooniantac_: yes, but it's a little more complicated when your fns take more than 1 arg
19:05shdnoonian: i'm trying to read binary TO clojure - basically parse a file
19:05noonian(->> x (f 8) g) = (g (f 8 x))
19:06noonianshd: right, so i guess i don't understand why you are creating a byte-array manually then, since you already have binary data to read
19:06shdwhen i define a frame i'm declaring arguments with their length as well, it's annoying having to type them in (byte-array count) again, i believe there is easy workaround for that
19:07shdnoonian: that would be great to read directly from buffer - i were not able to do it yet :P
19:07noonianshd: i probably can't be much help since I have zero experience reading binary formats in clojure
19:07shdnoonian: right, thanks for trying anyway
19:08noonianshd: np, don't give up on clojure even if you can't figure this thing out!
19:09justin_smithshd: looking at the docs, what about using "repeated"?
19:10shdjustin_smith: frames vary between each other, as i understand repeated is for same types of data
19:12shdi.e. byte + ushort = 3, then i read uint + uint = 8, every time i need to add this numbers in my head while i should be able to read them from frame definition i.e. sizeof()
19:13justin_smithshd: The author, ztellman, hangs out here, maybe he is around for answering questions
19:14shdjustin_smith: thanks, if i wont find any solution i'll be definitely haunting him :P
19:16amalloyi don't understand why you're adding these numbers together in your head either. you shouldn't need to know them at all
19:17tac_noonian: right.
19:19shdamalloy: do you mean i shouldn't read through the byte-array or i should read them from their definitions?
19:19shdnot really logical what i said, but i hope you grasp the point
19:20amalloyyou should define a single gloss frame that is capable of reading the entire thing from the buffer at once. don't make a million sub-frames and feed them sub-arrays or something weird like that
19:21shdamalloy: yes, i'm trying to reach that point, but it's easier to solve small problems than parse whole file at once
19:23shdamalloy: major problem is: i don't couldn't find a way to define struct{ int type_id, union{ string a, byte b, int c } }... actually union isn't correct too, because this attributes might not exist at all
19:23shdso i hoped to solve this problem in my own function
19:24justin_smithso there is no defined frame type, it's just free form tagged unions?
19:26shdjustin_smith: everything mixed with each-other, but you're right - not everything is known at the time i declare frames
19:27amalloyjustin_smith: the C tradition of the 70s: just write structs directly as binary
19:29Guest47278Perhaps a stupidly vague/broad question, guys. Does experience suggest that Clojure is a language that takes a *long* time to learn? Coming from, say, a Ruby background with rudimentary FP knowledge
19:29Guest47278I'm comparing primarily to Scala - which really seems to qualify, to me, as a language that takes a whole lotta time.
19:30justin_smithGuest47278: clojure is nowhere near the leage of scala or c++ in terms of complexity
19:34seancorfieldGuest47278: The real learning curve is the Functional Programming paradigm, not the language itself.
19:34Guest47278seancorfield: I certainly recognize that - but I also recognize that Scala is a highly complex language
19:34seancorfieldClojure is a pretty simple language, with a relatively small core library (compared to many other languages' libraries).
19:35Jaood_yeah, the core only has like 600 functions :P
19:35seancorfieldYes, there's a lot of syntax and semantics to learn in Scala - but you can plough on writing OOP code in Scala if that's your background, you're not "forced" to learn FP.
19:38seancorfieldJaood_: you think 600 is a lot? have you looked at the number of methods in Ruby 2 for example? :)
19:38numbertenis there a core function for changing the value of a key in a map?
19:38justin_smithnumberten: there is update-in
19:38amalloynumberten: are you looking for assoc?
19:39justin_smith,(update-in {:a 0 :b 1} [:a] inc)
19:39clojurebot{:b 1, :a 1}
19:39seancorfieldJaood_: I could about 1,700 functions here http://www.ruby-doc.org/core-2.1.2/
19:39numbertenthe value of a key
19:39seancorfields/could/count/
19:39akkadare there any primers for CL -> clojure?
19:39numberten(foo {:a 10} [:a :b]) => {:b 10}
19:39numbertensomething more like that
19:40numbertenspecifically for nested keys, so like assoc-in
19:40Guest47278seancorfield: Ruby 2 doesn't have that many methods, does it..? It's my dayjob, I never knew :)
19:40amalloynumberten: clojure.set/rename-keys
19:41amalloyGuest47278: in all the classes in all the standard lib? gotta be about a trillion
19:41justin_smithyeah, likely update-in plus rename-keys for the nested situation
19:41Guest47278amalloy: standard lib != core though
19:41seancorfieldGuest47278: I just looked it up out of curiosity... I'd say most languages have a lot more than 600 methods/functions in their core (language plus auto-imported classes)...
19:41numbertenalright
19:41numbertendidn't think to use update-in alongside rename-keys, thanks
19:42Guest47278Ruby's methods do seem to have a knack for being extremely powerful, even more so when put together, though
19:42Guest47278Referencing docs for ruby methods never seems a prohibitive deal
19:42seancorfieldGuest47278: indeed... and a lot of Ruby folks seem to love Clojure for its dynamic power too...
19:43Guest47278Partially due to its awesome docs, as well, I'm sure. It's amazing what the stylesheet on a language's docs do for the language.
19:43seancorfieldPersonally I don't like Ruby's syntax - but that sort of thing is very subjective.
19:43seancorfieldI love being able to get docs on functions in the REPL (since it's just metadata on the fn itself)
19:43justin_smithI tend to find many of the things that are considered "friendly" or "usable" in ruby-land to be annoying
19:44Guest47278justin_smith: example? (for my understanding)
19:45Guest47278seancorfield: it's possible to do that with Ruby too (Pry) - but I'm not here to evangelize ruby :)
19:45Guest47278In fact, i'm actually here to discover my exit strategy
19:45Jaood_seancorfield: that's not fair, some methods are inherited showing them more than once on the list (for each class), ruby also likes to give the same method multiple names :/
19:45justin_smithGuest47278: ubiquitous usage of ansi colors (often ignoring what I am actually doing with the tool's output)
19:46Guest47278justin_smith: hey that's not rubylang!
19:46justin_smithOK - sure
19:48Guest47278do you guys find clojures lack of types to be prohibitive?
19:49Guest47278the inability to create abstraction in the same way
19:49justin_smithwe have types, they are just late-bound
19:49justin_smith,(1 1) ; type error
19:49clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
19:49Guest47278justin_smith: can you create your own
19:49justin_smithyeah, deftype or defrecord are the easiest ways
19:50justin_smiththe main focus is developing against interfaces (for java interop) or protocols
19:51Guest47278justin_smith: is there a clear route on getting a firm grip on clojure in a short period of time?
19:51Guest47278justin_smith: i know in my lifetime, to learn what i've learned in the languages i know, they were extremely long and winding paths, stepping through many turds on the way
19:51justin_smithGuest47278: really depends on where the gaps in your experience are - do you have experience with coding with immutible data? lisp syntax?
19:51Guest47278I want something quick & direct now :)
19:52Jaood_Guest47278: get a book
19:52Guest47278justin_smith: immutable data, yes - lisp syntax, not a great deal. Although I've done Little Schemer, for instance.
19:52Guest47278(People definitely describe their degrees of experience with orders of magnitudes differences in optimism :)
19:53seancorfieldJaood_: my experience with Ruby is that it seems to like offering lots of different ways of doing the same thing - which expands the surface area of what you need to learn... but I think measuring the "size" of a language's function base is a bit pointless and misleading so I was merely reacting to the complaint that clojure.core is "big" (I don't consider it so).
19:53Guest47278Is there a "best" book on clojure?
19:53justin_smith~book
19:53seancorfieldGuest47278: you'll get different answers from different people
19:53clojurebotbook is books
19:53justin_smith~books
19:53clojurebotbooks is http://clojurebook.com/ http://joyofclojure.com/
19:54Guest47278The one thing I hate about whenever I revisit FP, is I find I'm reading the same crap about FP over and over again
19:54seancorfieldGuest47278: my preference/recommendation is the o'reilly book first and joy of clojure second
19:54seancorfieldso, yeah, same books justin_smith listed
19:54Guest47278awesome, thanks.
19:54justin_smithseancorfield: I credit whoever made the factoid
19:55Jaood_seancorfield: yeah, I was not being serious, you don't really need all that functions to start programming in clojure since most are just abstractions and can be easily be pick up with time
19:55justin_smithGuest47278: reading the same crap about FP because you forgot in the meantime, or because you can't find more advanced material?
19:56Guest47278justin_smith: more because I can't find the right stage. It either all seems too easy, or just way out of my league and mathematically crazy.
19:58justin_smithso maybe you are at the stage where what you want to learn is math?
20:00Guest47278justin_smith: well, I can't link any of this mathematical crap to practice, yet. So I wouldn't know where to start, or whether I'd want to
20:01Guest47278I think a gulf between basic FP and advanced FP concepts definitely exists and is wide
20:02justin_smithI think there is a big gap between knowing how closures and immutible data and tail recursion can be used to structure an app, and actually being able to build something in a mostly-functional programming style. And that is not a question of reading more about fp, or learning more math. It's a question of reading more real working code, and writing apps, and redesigning them. There is no substitute for practice.
20:03Guest47278justin_smith: I've totally found that to be the case. I've come to realise that I spent many years living a lie - learning a whole lot about theoreticals, when actually building stuff is king.
20:04justin_smitha bit of theory can save you from big mistakes (the kind of mistakes that waste cumulative years of your life) - but the answer to moving forward often isn't more theory
20:11Guest47278justin_smith: a lot of theory can also help tremendously with job interviews. I know of people that have talked their way into high positions - but become notorious for being actually incapable, besides good speech - once incumbent..
20:11Guest47278Too little, too late, of course!
20:11raspasovGuest47278: totally, building stuff == king for me as well; with just enough theory without getting bogged down by it
20:12raspasovyea, practical knowledge != good interview skills :)
20:15raspasovI would even argue that it's even more about how you structure your side-effects, I/O etc operations in your code that ultimately determines the amount of potential bugs your code has, and not strong/weak typing, etc; of course I have zero research to prove that :)
20:16Guest47278raspasov: I'd generally agree, although you could say that assertion is vague enough to be a truism
20:17Guest47278raspasov: I've seen functional people program in OO languages like Ruby, trying to do it in a functional way, ignoring OO principles. That ends up coming off worse though
20:17Guest47278even if, technically, you could say it has less side-effects etc.
20:17raspasov:)
20:18raspasovyea, but does one good example make it a truism? aka basic unit tests, or type checking?
20:18raspasovi.e. is the fact that object is of type X, actually make your program correct, is this a "good enough" check? I think it's "basic" check
20:19raspasovbasically, there's no substitute for thinking and reasoning about your program
20:19Guest47278I feel like there is a gap between static & dynamic analysis that needs bridging
20:19raspasova perfect checker would be an AI :D
20:19Guest47278^
20:19raspasovlol
20:20Guest47278A more feasible short-term bridge would be something that essentially animates a model of your code, based upon static analysis - allowing the human to dynamically analyse the code
20:20papachanseangrove thank you for your help last night, i have finally put in production my code
20:23raspasovthere's also this testing tool for Clojure if you haven't seen it https://github.com/clojure/test.check; a good video intro to the concept https://www.youtube.com/watch?v=JMhNINPo__g
20:31seangrovepapachan: Are you sure it was me?
20:32papachanseangrove oh sorry tab select you instead of seancorfield
20:33seancorfieldToo many Seans :)
20:33seangroveNo worries, wanted to make sure the right Sean got the thanks ;)
20:33seancorfieldI used to have IRC highlight "sean" but seangrove gets a lot more responses that I do so I took that off :)
20:34seancorfieldglad you got things working papachan - how much Clojure do you have in production now?
20:36papachanseancorfield not so much but my conversion from params to session cookie works finally
20:37seancorfieldCool...
20:37seancorfieldWell, I'm out of here for the day. May pop in later, but I have to be up at 5am to catch my flight to The Strange Loop. Hope to see some of you there?
20:39seangroveseancorfield: That's a conference I need to make time to go see next year - hope you enjoy it!
20:40seancorfieldThis will be my third year - it was awesome in 2011 & 2013 (I was in England in 2012, unfortunately).
20:40seancorfieldAnd I already have the dates in my calendar for 2015 :)
21:53andyfIs there 'standard' terminology to name the relationship between namespaces where one has a name that is an extension of another, e.g. namespace 'foo.bar.baz' is a ___ of namespace 'foo.bar'
21:54andyfAnd perhaps a related question, is there such a terminology for Java packages?
21:55GrazyHello all!
21:57amalloyandyf: in java i'd call it a subpackage. i don't know what it is in clojure
22:02justin_smithand in both java and clojure that concatenative nesting means something to a human reader, but really doesn't affect how the language does things (there aren't different rules for using foo.bar.baz from foo.bar as opposed to using foo.baz)
22:36TimMcjustin_smith: Java (and probably the JVM) has a notion of "sealed packages", which I assume refers to prefixes -- but I could easily be wrong on this, since I've never cared to look into it.
22:47justin_smithTimMc: that may be the case actually - it looks like subpackage inherit certain classloader settings of their parents too
22:47justin_smithbut in practice, these things don't effect my code much
23:06Jaood_mutual recursion apart, are forward declarations used much in the wild?
23:09justin_smithJaood_: I sometimes use them to make reading a namespace top to bottom make more sense
23:14Jaood_justin_smith: I see, haven't seen much code do that, I guess its a matter of taste then
23:14Jaood_justin_smith: the high-level functions are just mostly at the bottom
23:20justin_smithright, it was an aesthetic choice
23:34Jaood_b