#clojure logs

2014-01-31

00:00carkthen you have to make sure your interpretation is the same than the one from browsers
00:00carkthat's a lot of work
00:01seangroveOh, I'm saying anything is better than nothing
00:01carkmight be easier to provide a servie that would validate with tagsoup =P
00:01carkservice
00:04seangrovecark: Ah, very clever actually. I suppose we could round-trip it to the server and use hickory there
00:05seangroveBit of a shame compared to doing it client-side, but could be a good stopgap
00:05carkbut then you have to make sure that only your app uses the service
00:06seangroveYeup
00:08eyepatchWhy is Haskell better than Clojure?
00:08eyepatchnvm, just had to.
00:08eyepatchWhy does http://ideone.com/mveUBD run 200x slower than http://ideone.com/CU5l4O
00:09eyepatchI tried to make them almost as identical as I could.
00:09eyepatchThough there were a few adjustments.
00:11carkyou would need to use primitive ints all over, and i don't know if this is still the case, maybe declare your functions as static
00:11eyepatch?
00:11carkadd type hints to the functions too
00:12carkoptimizing this kind of stuff is kind of a black art
00:12cark(to me)
00:13carkbuit you should be able to get at least to about half as fast
00:13carkbut*
00:13eyepatchblack art as in evil or as in mysterious?
00:13carkmysterious
00:13carkto me !
00:14eyepatchI should see if I can write less iterative version with type hints.
00:14eyepatchI wasn't really aware of them.
00:14carkstart by adding (int value) everywhere you loop with this value and it comes from outside the function
00:15carkshould already shave a lot
00:15cark(if my understanding is current)
00:15carki know they made a lot of optimizations behind my back
00:15carksneaky aintainers
00:15carkmaintainers
00:16eyepatchThis might sound weird, but do you have a good resource on type hints handy?
00:17carknope, i'm not too interested in that kind of stuff ...doing mainly business stuff here ...network is the bottle neck for me
00:19eyepatchfinally, found something on Clojure.org
00:26devneyepatch: anything in particular you are trying to figure out?
00:27eyepatchI've just never dealt with type hints.
00:27eyepatchBut I'm headed to bed, so maybe tomorrow.
00:44quizdrit looks like let allows multiple bindings but if-let only allows a single binding, is that right?
00:46RaynesYes.
00:49quizdris there an elegant way to bind the if-let in two different ways, depending on the outcome of the binding test?
00:49quizdrit looks like the if-let just simply fails or offers a then, but no other binding alternative should the test fail
00:51quizdrI guess I should think of if-let as a variation of if, not a variation of let
01:09quizdrdoes anyone use simple macros for logging or is it a bad idea? for example I just hacked up these half dozen lines: https://gist.github.com/quizdr/8727342
01:12carkquizdr: i thuink it's completely valid
01:12quizdrthanks, i'm new and don't want to "abuse" macros and get into bad habits.
01:40seangrov`How can we check if something is a sequence? I always blank on this...
01:40seangrov`Ah, coll?
01:40ddellacostaseq?
01:41ddellacosta,(doc seq?)
01:41clojurebot"([x]); Return true if x implements ISeq"
01:41cark,(seq? [])
01:41clojurebotfalse
01:41cark,(sequantial? [])
01:41clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: sequantial? in this context, compiling:(NO_SOURCE_PATH:0:0)>
01:41cark,(sequential? [])
01:41clojurebottrue
01:41ddellacosta,(seq? (seq []))
01:41clojurebotfalse
01:41ddellacostahuh
01:41ddellacostaduh, empty
01:41ddellacosta,(seq? (seq [1]))
01:41clojurebottrue
01:41ddellacostaright
01:42ddellacostaseangrov`, cark: what is the difference between Sequential and ISeq?
01:42carkwell
01:43cark,(seq? [1 2])
01:43clojurebotfalse
01:43carkbut it can be sequed
01:43ddellacostacark: ?
01:43carkseq works with it
01:44ddellacostacark: seq works with what?
01:44carkwith a vector
01:44carkwith any Sequential
01:44ddellacostahttps://groups.google.com/d/msg/clojure/K4Ss-eJyBLE/Ycm85a0PfUwJ
01:45ddellacostacark: right, but you're just defining things through tautologies now
01:45carkaccording to your link, my understanding is wrong
01:46cark(sequable? [])
01:46cark,(sequable? [])
01:46clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: sequable? in this context, compiling:(NO_SOURCE_PATH:0:0)>
01:46cark=/
01:46cark,clojure.core.incubator/sequable? [])
01:46clojurebot#<CompilerException java.lang.ClassNotFoundException: clojure.core.incubator, compiling:(NO_SOURCE_PATH:0:0)>
01:47cark,(clojure.core.incubator/sequable? [])
01:47clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.core.incubator>
01:47cark,(require 'clojure.core.incubator)
01:47clojurebot#<FileNotFoundException java.io.FileNotFoundException: Could not locate clojure/core/incubator__init.class or clojure/core/incubator.clj on classpath: >
01:47cark=/
01:47carkahwell i guive up !
01:47carkanyways i was wrong !
01:47cark,(sequential? {})
01:47clojurebotfalse
01:48carkthere is the proof
01:48quizdri thought sequential just meant the collection is ordered. but doesn't mean the sequence API is available on that collection (though seq is implicityly called in most of the sequence APIs to first turn the collection into a seq)
01:48carkthat's apparently what it is
01:49quizdra vector is not a sequence, but you can call sequence apis on it as they will first call seq on it
01:49ddellacostaquizdr: yeah, that is what the link above suggests.
01:49quizdr,(seq? [1 2])
01:49clojurebotfalse
01:49cark,(col? [])
01:49clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: col? in this context, compiling:(NO_SOURCE_PATH:0:0)>
01:49ddellacosta,(sequential? [1 2])
01:49quizdr,(sequential? [1 2])
01:49clojurebottrue
01:49clojurebottrue
01:49cark,(coll? [])
01:49clojurebottrue
01:49cark,(coll? {})
01:49clojurebottrue
01:49ddellacostabut it is sequential, right. Well, a bit of Clojure 101 for me out of the way...haha
01:49carknow the hard one
01:49cark,(coll? "")
01:49clojurebotfalse
01:49carkhahaaa !
01:49cark,(seq "hello")
01:49quizdr,(seq? "abc")
01:49clojurebot(\h \e \l \l \o)
01:49clojurebotfalse
01:50quizdr,(sequential? "abc")
01:50clojurebotfalse
01:50quizdr,(coll? "abc")
01:50clojurebotfalse
01:50quizdr,(coll? (seq "abc"))
01:50clojurebottrue
01:50quizdr,(sequential? (seq "abc"))
01:50clojurebottrue
01:50quizdrok that's enough of that
01:51carkso yeah, the incubator seqable? function would be usefull
01:55quizdri'm curious about the memory limitations of something like this for a factoria: #(reduce * (range 1 (inc %))) it takes up O(n) memory ,right?
01:56quizdror because range is lazy and there is no head retention, the memory is in constant space?
01:56carkshould be garbage collected, but anyways that's a non issue, the result would eat up memory faster than the original sequence
01:57quizdrah, true, true...
02:16cgagls
02:16lazybotbin boot media opt proc srv
02:17cgagclear
02:18cgagdisrard that i'm an idiot, friggin irssi
02:20mercwithamouth=P
03:27fredyrmorning
03:31mercwithamouthmorning
03:42elsenhello!
03:46elsenwhat's your plan for this beautiful friday dear clojurists?
03:48ddellacostaelsen: well, it's still Thursday here, and I'm still finishing up my work day. But thank you for asking. :-)
03:48ddellacostaelsen: excuse me, it's Friday night. Guess it's been a long week... :-p
03:49deadghostelsen, try to finally, finally finish my derp simple note site
03:50elsendeadghost: that's sounds like a nice plan
03:50elsenwhat's special about it?!
03:51deadghostit's special because it's written by a special person
03:51deadghostin a special language
03:51deadghostsuper special
03:51deadghostI'm pretty much testing clojure waters
03:52deadghostright now it looks good to write my next major project in clojure
03:52deadghostidk about cljs
03:52ddellacostadeadghost: do it. and CLJS is awesome
03:53elsenand it'll make your js so special!
03:54deadghostI have to say
03:54deadghostafter 3 months of CL and clojure
03:54deadghostand writing some js yesterday
03:55deadghostI got very confused
03:55deadghostmy brain has to think about not wrapping everything in parentheses
03:58elsenloosing the prefix notation is the worse
03:58deadghostso elsen what are you doing
03:59deadghostI'm also thinking about ditching html
04:00deadghostand just use enlive + enlive hiccup helpers
04:00elsenhiccups looks really cool
04:00elsenbut I wonder if it's a good long term choice
04:01elsenif you want to work with a designer later, jinja-like templating would be more natural
04:01piranhait's a hard question, but from my experience writing it in medium-sized app (~2k sloc) it's quite convenient
04:01piranhaexcept for designers, of course :)
04:02deadghostehh I've done stuff with a designer
04:02deadghostand I really question the benefit of keeping things in html for designer's sake
04:02elsenpiranha: what would you use for large-sized app?
04:02elsen(just curiosity)
04:03piranhaelsen: well right now we're using React with CoffeeScript and our app is quite hard to comprehend for markup guys
04:03elsendeadghost: really?!
04:03piranhaso I guess hiccup wouldn't do much more harm there...
04:04deadghostelsen, I mean is it really much harder to understand
04:04deadghostdesigners can just run the website
04:04deadghostand see the html
04:04piranhadon't think so as well, if a guy can find his way through coffeescript/react, then hiccup will be a minor thing. If he can't, then sure, just look at resulting HTML in your browser
04:04deadghostidk do designers typically touch code much?
04:05deadghostwould imagine it'd be designer + frontend guy
04:05deadghostat least that's how it ended up being when I did stuff
04:05piranhawell I'm not really talking about designers, but more markup coders
04:05piranhadesigner here has no idea about HTML code :)
04:06elsenyea, I'mmore thinking of the guy who does the frontend, css, html, etc
04:06deadghostwell if you mark up coder is front end in general
04:06deadghostif he can handle js
04:06deadghostthen it shouldn't be an issue
04:06deadghostit's not rocket science
04:07elsenI'd think that'd create more friction
04:07elsenis it worth the gain?
04:08deadghostin having the front end guy deal with hiccup?
04:08elsenyup
04:08deadghostwell I'll say it depends on who you have on frontend
04:09deadghosthttp://beta.deadgho.st/
04:09deadghostpw: goalrocket
04:09deadghostlike the guy that front-ended that
04:09deadghostI trust won't have an issue with hiccup
04:09deadghostlike a day or less to figure out
04:10deadghostmore if you throw enlive into the mix
04:10deadghostbut I'd say two days tops
04:13elsenlovely
04:13deadghostelsen, we have no clients ;_;
04:14elsenwell
04:14elsenyou have no product
04:14elsen;)
04:14deadghostour product is we'll code stuff for money/food
04:16deadghosthttp://dreadfulfacts.com/
04:16deadghostwe also did that
04:17deadghostelsen, how do you get money
04:17deadghostI want money too
04:18elsen"You make as much impact on the world as a ping pong ball on a brick wall." <3
04:18elsenbig data in java
04:18elsenno clojure yet, but I'm slowly working on it
04:18elsendude, if I may, the first thing I was looking on your website is an address
04:19deadghostare you suggesting I list my home address?
04:19elsenA postal box?
04:24elsenIf I'm looking for a company to do my website, knowing that they're in the same city/country than me would be a decision point
04:25elsensee ddellacosta? He doesn't even know what time it is where he lives, that's not a good sign if I want to have a confcall with him ;)
04:25ddellacostahaha
04:25ddellacostaelsen: hey, come on, I get it right...most of the time. ;-)
04:26deadghostoriginal plan was to target locally
04:26deadghostscraped yellowpages for nearby businesses with no listed sites
04:26deadghostand sent mailings
04:26deadghostbut it doesn't help that this area is kinda poor
04:26deadghostmight have to shift strategies
04:26deadghostand visit businesses to see if they have anything I can solve with programming
04:27elsenno familly/friends businesses that'd like a website?
04:27deadghostnope
04:28elsenno local association? library? drug dealers?
04:28deadghostprobably will compile a list of nearby business parks this weekend
04:28deadghostand visit them next week for research
04:28deadghostthinking about volunteering sites for local museums
04:29deadghostand ask them to pay me in referrals
04:29deadghostbut I can see that very easily resulting in nothing
04:31deadghostelsen, I'm very curious what kind of site drug dealers would have
04:32deadghostwell I guess there's silk road
04:32deadghostwait is that still alive?
04:32elsenI'm almost certain I saw an article about a buy that bought drug.com
04:33elsenwith a fancy 90s website, like the one at the beginning of breaking bad
04:33deadghostI just went to drug.com
04:33deadghostand got some weird japanese medical company
04:36deadghostelsen, dumb thought
04:36deadghostI sell the data I scraped from yellowpages to web dev businesses
04:40elsenyea, datasets are trendy these days
04:42elsenmashape.com or a paid version of datahub.io?
04:43deadghostI was thinking of just hitting up web shops and going hey I'll sell you this list of 5000 businesses in a 100 mile radius of your location for $2000
05:08xificurCI'd need some pointers. Let's assume I have a csv file with data that has (unique-id, grouping, float-1, float-2) and another one with (grouping, sub-grouping, sub-group-percentage-1, sub-group-percentage-2). Now I need to take the first data and break each line into the group's number of subgroups and calculate their new floats based on the subgroups percentages. How would you solve this?
05:39quizdris there a way to quickly reset the repl so it has no memory of prior definitions?
05:42jowagquizdr: (ns user2) :)
05:42sobelhaha
05:46sobelsomeone mind telling me what i'm doing wrong? it's a short expression... http://pastie.org/private/rjp6fktjtzildaqndkfg
05:46jowagquizdr: more serious answer is (map #(ns-unmap *ns* %) (keys (ns-interns *ns*)))
05:46sobelthat is 'palindrome detector'
05:46quizdrjowag thanks i found a good utility here: http://stackoverflow.com/questions/3636364/can-i-clean-the-repl
05:48jowagquizdr: but generated classes are not removed (e.g. deftype, protocols), so it is not equal to the fresh repl
05:48quizdrgood to know
05:51quizdrsobel are you getting and error? i haven't run it but at first glance it seems to be ok
05:51jowagsobel: give me the example input to the function
05:51sobellet me augment that pastie
05:52sobelhttp://pastie.org/private/a9rfdkzntktkfpnoaghf6g
05:52jowagsobel: but probably the error is in the (empty? (first fwd)), make it (empty? fwd)
05:52sobelOH
05:52sobeljowag: that now stands out like a sore thumb
05:53jowag:)
05:53sobelyeah, works now
05:54sobeli was just messy. i had a different implementation and that was actually part of it.
05:54sobel4clojure's tuts are great so far
05:56quizdrwhen i use (empty? fwd) in your function, i don't get errors, but the test still seems to fail
05:56quizdri.e. with (yourfunction [1 2 3 4 5 6]) returns false
05:56sobelthat is accurate
05:56sobela palindrome is the same seq forward as backward
05:56quizdroh, right
05:56quizdrnevermind
05:57quizdri agree 4clojure is an awesome learning tool. you comparing yoru answers to others, also playing the "code golf" ?
05:59quizdri think there is a more elgant solution, perhaps this hint might help:
05:59quizdr,(map = [1 2 3 4] [1 1 1 1])
05:59clojurebot(true false false false)
06:00quizdrand then....
06:00quizdr,(every? true? (map = [1 2 3 4] [1 1 1 1]))
06:00clojurebotfalse
06:00jowag,(#(every? true? (map = (seq %) (rseq %))) [1 2 3 2 1])
06:00clojurebottrue
06:01quizdrthe great service of 4 clojure is in learning to take a 5-line function and turn it into a 1-line expression.
06:05locks,(reduce 'and (map = [1 2 3 4] [1 1 1 1]))
06:05clojurebotfalse
06:05sobeli've been writing map and filter exprs in python a while. i didn't know it was FP.
06:05locksboo
06:06lockssobel: but the data structure are mutable, right?
06:06llasramlocks: That's the symbol `and` I'm afraid, not the macro. Also -- is a macro, so can't pass as a function
06:06locksoh
06:06locksroger that
06:07sobelmostly i'm using the 4clojure tuts to just get a series of increasingly complex tasks. will work on style and such later, after i get enough syntax and idiom pounded into my head
06:07jowag,(#(= (seq %) (rseq %)) [1 2 3 2 1])
06:07clojurebottrue
06:07sobellocks: i didn't mean to say python is FP
06:08lockssobel: was just curious, because ruby has all the Enumerable stuff, but you can mutate the data meanwhile, which can be problematic
06:09sobeleff ruby
06:09sobeli'm probably poisoned for life on ruby by rubyists
06:09jowag,(#(= % (rseq %)) [1 2 3 2 1])
06:09clojurebottrue
06:10locks:C
06:10sm0kewhen will core.async come out of alpha?
06:10sm0kethey have some complex semantic versioning for sure
06:10sobelso, who makes clojure? i have not looked into the project at all
06:11clgvsm0ke: no they dont. tbaldrige said replied to my similar question that he'd consider it out of alpha
06:11quizdrjowag specializes in the line that just keeps getting shorter
06:12sm0keclgv: what does that mean? is it going to be named like this always?
06:12clgvsm0ke: he said it is stable enough for production if I remember correctly. and then a discussion about semantics and versions started-...
06:12jowagthey made a breaking change to the API few days ago, so I would consider it still in alpha
06:13clgvjowag: well even for compliance with semantic version you can introduce breaking changes in minor version increments as long as there is a zero in front
06:14locksfor compliance with semantic version, < 1.0 you can do whatever you like, since it doesn't matter
06:14lockswhich means it's alpha
06:14jowagwell but Clojure does not follow semantic versioning
06:15clgvwell most core libraries use stable 0.x.y releases
06:15clgvI dont get the "eternal" alpha neither ;)
06:16locksyou get to "I warned you", I guess
06:17arcatani guess core.async is out of alpha, but not out of beta :P
06:17locksthat's the same
06:18clgvI feel better as well when using a lib where the developers are confident enough to do a "stable" release ;)
06:19locksruby and especially node suffers from the same syndrome
06:19lockshttp://rake.rubyforge.org/doc/release_notes/rake-10_0_0_rdoc.html
06:20lockshttps://rubygems.org/gems/pg/versions
06:20lockssurely they could 1.0 by now
06:43mklappst_Hey. I just put this together to generate a random color in clojure: https://gist.github.com/mklappstuhl/8730542
06:44mklappst_Curious if it can/should be done differently
06:46xificurCmklappst_: out of curiosity, why are you using keywords instead of characters? Since you are building a string from them in the end anyway
06:48lockshttps://www.irccloud.com/pastebin/li7RYZnH
06:50xificurCyeah like locks wrote or just (apply str \# (take 6 ...))
06:51locks^
06:51wei__,(format "%x" (rand-int 16rFFFFFF))
06:51clojurebot"dc6c71"
06:51wei__,(format "%x" (rand-int 16rFFFFFF))
06:51clojurebot"2d00a1"
06:51locksjust got schooled.
06:51xificurCheh
06:52xificurCand locks, using shuffle isnt the best idea, you wouldnt get all the possible colors from that
06:52jowagwei__: probably won't work in CLJS
06:53locksxificurC: right, I derped that one hard
06:54mklappst_locks: xificurC, regarding shuffle... should it still be (repeatedly 6 #(rand-nth c)) then?
06:55wei__jowag: hmm, you're right
06:55xificurCbtw, what library would you suggest using for one-pc data management? I'd like something where I can do the typical SQL stuff but also some simple mathematical relations
06:56locksmklappst_: yup
06:56mklappst_xificurC: whats one-pc
06:56xificurCmklappst_: yes I'd go more in https://www.refheap.com/30343
06:57xificurCmklappst_: I mean I want to crunch a lot of data but dont need the option of distributing
06:58mklappst_ah
06:59sobelok, i need a sql library. i don't want orm, i will write my own queries... suggestions?
07:00sobels/sql/jdbc
07:00mklappst_thanks for your input guys. updated the gist with all the different variants https://gist.github.com/mklappstuhl/8730542
07:00lockssobel: http://sqlkorma.com/
07:00mklappst_s/guys/people
07:01wei__jowag: this should work in cljs: (.toString (rand-int 16rFFFFFF) 16
07:01wei__)
07:02sobellocks: i don't want a DSL in front of sql, i rather provide my own queres
07:02sobelSQL is already a DSL
07:02sobeli find it wrong-headed to invent DSL on top of DSL :)
07:02lockswell…
07:02mklappst_wei__: cool, that works
07:03sobelthat i can see, korma does that
07:03sobel"Take the pain out of relations"
07:03sobel...what pain?
07:03locksI think you answered yourself then, JDBC :P
07:03sobelthere's no thinner wrapper than korma?
07:05mklappst_Now that I have a random color I want to use the same color twice in a form so I have to "save it" and can't just call the function again... what do I need to look for?
07:06locksa let, probably
07:06sobelis clojure.java.jdbc a ..standard namespace? i don't even know how to ask this question in clojur-ese
07:06sobeldo i need to add a lein dep?
07:07CookedGryphonsobel: yes, see https://github.com/clojure/java.jdbc
07:07CookedGryphonyou'll need to add [org.clojure/java.jdbc "0.3.3"]
07:08sobelCookedGryphon: thx
07:24mklappst_locks: really, let would be enough? I thought that would only bind the var to the function and not its result, good to know
07:41RickInAtlantadoes anyone know of an example edn file I could look at? I am trying to understand if a file is just a bunch of vectors and maps printed out, or if there are def statements.
07:43kzarRickInAtlanta: Well in Javascript say `var a = [1,2,3];` would define a to be the vector 1,2,3 but in JSON you would probably do something like "[1,2,3]" or "{a: [1,2,3]}". I think it's the same idea with edn vs clojure
07:43kzarThe only confusion is that clojure itself is made up of edn
07:44kzarso `(def a [1,2,3])` is itself edn but it also defined a to be the vector 1,2,3. I'm guessing in a .edn file you'd again have "[1,2,3]". That said I'm probably not best person to ask
07:44RickInAtlantakzar: that does make sense
07:44andyfRickInAtlanta: Not all edn files will look the same visually, but here is one that is a single Clojure map: https://github.com/jonase/eastwood/blob/master/resource/jvm-method-info.edn
07:45andyfRickInAtlanta: Can you search for def in the file you are looking at?
07:46RickInAtlantaandyf: I want to use it in my own projects, but I figure if it is a standard format, I should try to use it in a standard way (if there is one)
07:46RickInAtlantathanks for the sample
07:47andyfRickInAtlanta: An edn file typically is just one or more vectors/maps/sets printed out, often nested within each other. You can quickly try reading it in using clojure.edn/read or read-string
07:47andyfWell, quickly if it isn't too large :-)
07:50RickInAtlantaIf I understand, if I were defining a backup folder in a .clj file I might have (def backup-folder "c:\\bak") In edn I would probably have {:backup-folder "c:\\bak"}, putting the description in the data structure.
07:51andyfyes
07:51RickInAtlantathanks
07:52andyfproject.clj files in Leiningen are usually also edn format (except for a few I have seen that are actually executable code, too)
07:52RickInAtlanta(inc andyf)
07:52lazybot⇒ 2
07:52RickInAtlanta(inc kzar)
07:52lazybot⇒ 1
07:52kzarheh ty
07:52kzar,`(inc kzar)
07:52clojurebot(clojure.core/inc sandbox/kzar)
07:59jowaglocks: xificurC: the distribution of shuffle vs random-int for two component color http://twitpic.com/dtyilz/full
08:01xificurCjowag: nice
08:01jowagthe code https://gist.github.com/wagjo/8731671
08:04meingbgWhat triggers the execution of top-level forms in clojure?
08:05jowagmeingbg: if they are part of .clj file, then they are evaluated when the file is loaded
08:06meingbgjowag: And if a namespace is :require d, does that mean the file is loaded?
08:06jowagmeingbg: this happens e.g. when you call (require 'foo.bar)
08:06meingbgjowag: ok, well that's what I thought, but it doesn't seem to work.
08:06jowagmeingbg: yes but only if it has not been loaded yet. In other words, it gets evaluated once
08:07jowagmeingbg: if you want to force reload, use this (:require [foo.bar] :reload-all)
08:09andyfjowag: Is there a :reload and a :reload-all that do something different there?
08:09clojurebotCool story bro.
08:09jowagmeingbg: but be aware that top level forms are evaluated also in other cases. For example in AOT compilation or when you use core.typed, the namespaces are reevaluated
08:10jowagmeingbg: so it is advised against doing side effects in top-level forms
08:12meingbgjowag: Well, I have res.clj which alters *data-readers*, then core.clj which requires res and thereafter needs the data readers in order to be parsed. However, after requiring res.clj, *data-readers* remains unchanged.
08:12jowagmeingbg: reload-all reloads also all libs (another name for .clj file which has (ns) as first top level form) that are referenced from the library you are reloading :)
08:12jowagmeingbg: see http://clojuredocs.org/clojure_core/1.2.0/clojure.core/require
08:13andyfjowag: Thanks, yeah, I see now. I had used :reload before but not :reload-all
08:15meingbgjowag: Does it work differently with nREPL? Or what may be the issue in my case?
08:15xificurCanyone using korma or suggeting an alternative?
08:16jowagmeingbg: how do you alter it, set! or alter-var-root ?
08:16meingbgjowag: var-set
08:17ziltiI just noticed something while loading 48k rows out of a database. The actual loading out of the database into a datastructure takes 2.4s with SQLKorma. But assigning it to a variable afterwards takes another whopping 300ms. What's going on there?
08:18jowagmeingbg: var-set is thread local, maybe alter-var-root will help
08:18meingbgjowag: I'll try.
08:19jowagmeingbg: anyway, the correct way is to put custom data readers into data_readers.clj
08:19jowagsee http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/*data-readers*
08:19meingbgjowag: Yup, know about that.
08:20meingbgjowag: It just puzzled me.
08:20meingbgjowag: Would data_readers.clj in a library make the readers work in any project using that library? Or is it project-local?
08:21scape_anyone use .ready method on a bufferedreader of an inputstreamreader for a socket? it always seems to return false for me
08:23meingbgjowag: And alter-var-root doesn't work, btw. It seems as if *data-readers* is thread-locally bound, so alter-var-root doesn't have any effect at all
08:23jowagmeingbg: it will work but there may be clashes if two dependencies both define data_readers.clj, of user will have its own data_readers.clj.
08:23jowagmeingbg: so normally libraries should not have a custom data_readers.clj
08:25meingbgjowag: Right. In this case though, that is the very purpose of the library.
08:26jowagmeingbg: are you testing it in the repl? try testing it outside IDE
08:26meingbgjowag: ok.
08:26scape_oh i misunderstood ready method incorrectly :-\
08:29meingbgjowag: lein compile works just fine, but lein run complains about missing reader function.
08:36meingbgjowag: For some reason I don't like the project global data_readers.clj. The behaviour of the reader is defined by the active namespace, and one global variable *data-readers*. It's a bit inconsistent.
08:43ziltiI just noticed something while loading 48k rows out of a database. The actual loading out of the database into a datastructure takes 2.4s with SQLKorma. But assigning it to a variable afterwards takes another whopping 300ms. What does Clojure do that it takes that long?
08:45TimMczilti: How are you determining that?
08:49ziltiTimMc: With the "time" macro. (time (def result (k/select whatever))) vs (time (k/select whatever))
09:01sobelok, i got this back from my postgres database.. it's the right value so i'm more or less happy so far, but.. is this a Date object or what?
09:01sobel(#inst "2009-03-26T21:31:28.122222000-00:00")
09:01sobel,(#inst "2009-03-26T21:31:28.122222000-00:00")
09:01clojurebot#<SecurityException java.lang.SecurityException: denied>
09:02mdrogalissobel: That's a tagged literal.
09:02mdrogalis,(type #inst "2009-03-26T21:31:28.122222000-00:00")
09:02llasramzilti: criterium or it didn't happen
09:02clojurebot#<SecurityException java.lang.SecurityException: denied>
09:02mdrogalisHmph.
09:02sobeli'll type it on my end
09:03locksjowag: that's a really cool visualization, thanks :) I derped because shuffle won't repeat elements *shakes head*
09:04ziltillasram: What "criterium"?
09:07mdrogaliszilti: It's a benchmarking library.
09:08ziltimdrogalis: Is "time" so utterly unreliable even though I can perfectly reproduce the result give or take a few ms?
09:08llasramOn the JVM, yes
09:08llasramWell, JIT makes it worse anyway
09:09ziltiI tested while on the REPL, both thingies alternating. One, then the other, then the first again, the second again. Same results
09:12xificurC_how do you connect to an odbc in korma?
09:12llasramzilti: Cool, but that doesn't tell anything about the distribution of results or the significance of the overhead. Unless you're using criterium or a process similar to what it encapsulates, then you're just reporting anecdotes
09:13ziltillasram: I could also use a stopwatch. 300ms is something I should be able to catch with it.
09:13TimMczilti: I'm going to guess that laziness is involved.
09:14TimMcSomehow.
09:14TimMcTry (time (def result 5))
09:14llasramMy guess is that their measurement process isn't accounting for the variability in the I/O
09:15scape_xificurC_: preface it with odbc
09:15xificurC_scape_: managed already thanks
09:15ziltiTimMc: Gives 0.064 ms
09:16TimMcYep, needs more criterium.
09:16mercwithamouthhmm i'm debating on getting the little schemer...is it all it's cracked up to be as far as getting a better grasp on lisp?
09:17ziltimercwithamouth: "Little Schemer" is really the beginner's book but it's very nice and well done.
09:17mercwithamouthalright...i'l pick it up. that sounds like what i need
09:19mercwithamouththat and sicp
09:21mdrogaliszilti: So the JVM is pretty magical. After you run your program long enough, it's going to start changing it significantly if it can.
09:21ziltiWell I'm letting criterium run now
09:23xificurC_anyone ran korma against a csv via odbc? :)
09:24TimMczilti: Go make yourself some coffee
09:25ziltiTimMc: Oh nice. I got an OutOfMemoryError.
09:25mdrogalisHeh.
09:25ziltiSo, no criterium for this.
09:27mdrogalisThat probably just means there's an underlying problem. Criterium shouldn't be accuring memory.
09:27mdrogalisaccruing*
09:27mdrogalisOr larger amounts of it from run to run, I mean.
09:39sobelxificurC: why via odbc? i thought there was a csv driver
09:40xificurCsobel: is there?
09:40scape_http://korma.github.io/Korma/korma.db.html
09:41scape_I do not think so
09:41xificurCscape_: been there, dont see csv
09:42xificurCI do have a csv connection or what to call it working on odbc though, but not through korma
09:43sobelhttp://sourceforge.net/p/csvjdbc/code/ci/master/tree/
09:44sobeli guess it's not in clojars
09:44xificurCI didnt do much, (defdb db (odbc {:dsn "csv"})) - that threw no error. Then (defentity brands-list) - the name of the csv file I want to query, no error here too. Then (select brands-list) - hangs
09:46scape_defentity wouldn't throw an error, to my knowledge
09:46xificurCscape_: well yeah the worst part is I get no errors but the process just hangs
09:47scape_perhaps try on a small csv a raw statement that selects all?
09:47xificurCI tried following the example from github but it all seems too magical. Creating a db with defdb but never calling it again, then creating an entity and not even telling where to look for it
09:47xificurCscape_: I tried just that, its a 16KB file
09:48scape_korma assumes the last defdb to be the db of choice for all subsequent function calls, unless overridden
09:48xificurCok
09:48xificurCi still cant debug what went wrong though
09:49scape_not sure this would work with csv or whatnot, but: https://gist.github.com/viperscape/6135158
09:49scape_it builds defentities for all tables in the db
09:49scape_that gist relies on info schema, not sure if odbc has that
09:50sobeldo you have another way to query through that odbc connection?
09:51sobeli would try to divide the problem space up at this point
09:52xificurCscape_: that threw a "CompilerException java.sql.SQLException: Connections could not be acquired from the underlying database!, compiling:(form-init6077136520192018995.clj:2:1) "
09:54xificurCsobel: this is the first time im trying :S I have a normal db I could try connecting to but its down right now
09:54sobeld'oh
09:54scape_yea i don't know if odbc supports info schema, my guess is no and korma expects mysql or mssql and is complaining about that
09:55sobelhonestly, clojure.java.jdbc returns nice structures. what was the basic problem?
09:55xificurCall i'd like to be able to do is connect to a csv or xls file as to a database and use sql on it freely
09:56sobeli understand some languages made resultset mapping a hassle, but clojure seems have it made fairly convenient to me
09:57sobelin hindsight, my initial take on ORMs was right for me. they are a needless complexity.
09:58scape_korma wraps things well, very clojure friendly but at a loss of some things
09:59xificurCim fine with java jdbc if it works
09:59sobelthat's fine and good, but it crosses a line of responsibility i don't like being crossed
10:00scape_yea i learned update in korma returns nil, regardless
10:01xificurCany suggestions then how to get sql working on an excel file or csv (without setting my hair on fire)?
10:01sobeli have the same argument against 'migrations' in ruby. a DSL on top of a DSL, or meant to abstract over several DSL that differ for very good reasons, is a leaky abstraction and it has led to tears
10:01sobelxificurC: google docs
10:02xificurCsobel: in clojure please :) Excel VBA supports SQL as well if I want to go back to the metal
10:02sobelheh, VBA as 'metal'
10:02scape_I bet. I ran a query in korma and got back like 1200 rows, but the same query in mssql directly returned 1600+; never could figure it out
10:02xificurCsobel: well it certainly isnt a tool, just the ingredients :)
10:03sobelimport the csv into a real database (i like postgresql) and hit it with jdbc from there
10:03xificurCthat sounds reasonable
10:03sobelxificurC: au contraire, they have relational tools. you might be surprised what you can do with docs these days.
10:04sobelfor example, you can make a timer call a function that scrapes a URL and loads it into your spreadsheet. then you can use that in relational queries.
10:04sobelwhat they have done with data tools is...sick
10:05sobeli just wish i could get that kind of service in a private/local cloud system. i know their platform is entirey too big to distribute like that, though.
10:12RickInAtlantai just googled "clojure defrecord" now I am looking at an add that asks if my deftypes are a litle flabby!
10:12scape_lol
10:13gfredericksads aren't even being written by humans anymore are they
10:13gfredericksare people running genetic algorithms or something?
10:14gfrederickseventually they will stumble onto a phrase so potent nobody will be able to resist clicking
10:14edbondwhere do you see those ads? I don't see any ads at google
10:14RickInAtlantano, I think this was, it offers to help me lose hundreds of lines from my codebase overnight. It links to a github project called potemkin
10:15RickInAtlantaedbond: at the bottom of the results page
10:16gfredericksor is this just ztellman trolling by buying his own ads
10:16edbondRickInAtlanta, I see only related searches :(
10:17dsrxWhy won't Clojure programmers shut up about how great their data structures are? Because they're not mutable!
10:17gfredericks~rimshot
10:17clojurebotBadum, *tish*
10:17scape_nice
10:18RickInAtlantagfredericks: who was it the other day that had an ad "Rich Hickey hates him. Improve your clojure performance with this one weird trick."
10:18gfredericksyou can't shut the clojure programmer up, you have to make a new clojure programmer that is shut up
10:18gfredericksRickInAtlanta: I dunno anymore; I feel like I keep hearing about variants
10:18gfredericksI first saw such a thing on ztellman's twitter
10:19RickInAtlantaOk, so it was the same guy. :)
10:19gfredericksI'm gonna go with the theory that he's creating them
10:20mmitchellIs there a core fn for mapping over the values of a hash-map and returns a new *hash-map*? Looking for something more concise than reduce and for/into
10:20gfredericksmmitchell: not in core; people make it for util libs all the time
10:20mmitchellgfredericks: ok thanks
10:21gfredericksI think some people have the opinion that if you're trying to change everything in a map at once then maybe you shouldn't use a map; that might be the motivation for clojure.core not having anything built in
10:21gfredericksI still want to do it all the time though :)
10:21john2xhi.. i'm trying out Friend, but it's core.cache dependency is overriding lib-noir's. `lein deps :tree` suggests I do `[lib-noir "0.7.9" :exclusions [org.clojure/core.cache]]`, so I do that, but now I get `No such var: clojure.core.cache/through`. Do I have no choice but to keep on drilling fixing the dependencies?
10:21mmitchellright :)
10:21xificurCsobel: vba is a bad place to work at, no matter what it ca ndo
10:25sobelClojure programmers never die, but the world changes namespaces
10:26sobeli hope i memed that up right
10:27dsrxbetter answer: Because they're mutable and persistent
10:27dsrxs/mutable/not mutable/
10:29john2xah should've known explicitly adding [org.clojure/core.cache] overrides all other libraries' dependencies..
10:41mmitchellis there an emacs more for re-formatted a clojure comment block? By re-format I mean tuck long lines down to the next etc.?
10:42arcatanwhatever is usualyl bound to M-q
10:43mmitchellarcatan: that works for indenting, but not for code comments that start with ";;"
10:44mmitchellI should have said "clojure comment lines" not "block" sorry
10:44arcatanhmmh, works for me
10:44mmitchelloh dang, really? hmm
10:44arcatanweird.
11:05nkozathere is a way to temporary disable the execution of an atom watchers?
11:05nkoza(without doing remove-watch / add-watch for every watcher)
11:13edbondnkoza, add another atom (paused) and check if it true in watch function
11:14nkozaedbond: good idea, it's a common idiom?
11:16edbondI think so, working code that solves the problem is pretty common idiom imo
11:16juxovechi there, how can I create function which inserts 2 nodes into vector directly while creating vector (I am in Hiccup template [:table (myfn)] and need myfn to create two [:tr][:tr]
11:18edbondjuxovec, I would use (apply vector :table (myfn))
11:18xificurCsobel: you told me to get postgre and import csv, how should I do that :)
11:18edbondwhere (defn myfn [] [[:tr] [:tr]])
11:21juxovecedbond: I am looking for more general solution, my markup is in [:div [:div.inner (table-default (for [project projects] ...here comes fn1... ...here comes fn2...))]] - but (for) doesn't have larger arity, so I put fn1, fn2 to [fn1 fn2] which isn't working at all
11:23juxovecthe only workaround I found is putting it into multiple [:tbody] elements which is valid, but isn't general solution of my problem
11:25edbondjuxovec, I don't know better way, I just use apply
11:26DerGuteMoritzjuxovec: IIRC you can just return (list [:tr ...] [:tr ...]) and hiccup will do the right thing
11:26DerGuteMoritzi.e. lists are spliced
11:27juxovecDerGuteMoritz: great! It solves my problem, thanks a lot!
11:28DerGuteMoritzjuxovec: yw!
11:31edbondnice, I'm curious sablono can do the same
11:58stompyjAre there any good books/screencasts on functional/integration testing using midje or clojure.test? I'm making very slow progress and would happily pay to speed things up.
12:18technomancystompyj: for how larger-scale integration tests might look you might take a peek at https://github.com/xeqi/kerodon/
12:18technomancyeven if you're not doing a web app it's a neat example
12:18technomancythe clojars test suite uses it
12:19stompyjtechnomancy: awesome. thanks! I feel pretty good about most things in clojure, but the one area that still gives me the "YOU'RE DOING IT WRONG" spidey sense is writing "complex" integration tests
12:20technomancystompyj: kerodon's use of -> is really neat for flow-driven tests
12:20stompyjyeah, this looks pretty clean
12:21technomancyeven though the state of the app itself is changing, the session itself from the perspective of the test is functional
12:40seangrov`I'd like to make a map that can remember what it was originally instantiated with and tell me what keys have changed on it over its life time
12:40seangrov`Should I use defrecord?
12:41technomancyI'd use a map with metadata
12:41technomancybut that's just me
12:42seangrov`technomancy: Ah, interesting, looks like meta survives assoc/etc.
12:42seangrov`I would have thought it would be cleared out, since we have a "new" map with every operation
12:43technomancythere are a few operations that will unexpectedly discard it
12:43seangrov`Alright, that seems nice enough, thanks technomancy
12:43hyPiRionseangrov`: Do you need to do rather complex lookups/changes based upon history? I'd just recommend to think a bit about the design before implementing anything.
12:43technomancybut that's a big part of what profile merging uses in leiningen
12:43seangrov`hyPiRion: No, just trying to track dirty fields in maps so we don't replace the entire row with Korma
12:44hyPiRionoh, alright. Good, because it's hard to get right
13:00shipkissHello, I am new to Clojure in general and recently installed LightTable to give it a go. I am on a Windows box, and am able to run simple commands in the InstREPL that comes with LightTable w/o issue. I have a project.clj file that I am trying to load, and I am receiving the following stack exception:
13:00shipkissError loading lighttable.nrepl.handler: Could not locate cljs/env__init.class or cljs/env.clj on classpath:
13:00shipkissException in thread "main" java.lang.RuntimeException: Unable to resolve var: lighttable.nrepl.handler/lighttable-ops in this context, compiling:(C:\Users\shipkiss\AppData\Local\Temp\form-init5817764817166730124.clj:1:5281)
13:00shipkissI have the full stack trace available, and was wondering if anyone had seen anything like this before?
13:03hyPiRionshipkiss: That is an exception Leiningen is throwing, although I'm unfamiliar with LightTable code
13:04dabdwhat happened to the -?>> macro that was in clojure.contrib.core?
13:05shipkisshyPiRion: So most likely an issue in the registered dependencies for the project? Prior to the exception, there is a warning message indicating "possible confusion dependencies found"
13:05shipkiss*confusing
13:05bbloom(doc some->) ; dabd
13:05clojurebot"([expr & forms]); When expr is not nil, threads it into the first form (via ->), and when that result is not nil, through the next etc"
13:06dabdfound it in clojure.core.incubator
13:06dabdoh nice thanks
13:06hyPiRionshipkiss: That may actually be it, yes. Based on that, I'd guess two dependencies depend on some other dependency, and it uses a version incompatible with one of the other deps
13:06dabdi liked the shorter name -?>>
13:07seangrov`technomancy: Pretty brilliant approach, lovely use of metadta
13:07hyPiRionshipkiss: If I were you, I'd report it to the lighttable github repo to get help for that
13:07technomancyseangrov`: cool; hope it works out well for you
13:07seangrov`technomancy: Worse case (if the metadata is stripped) it should fall back to its current behavior. Could be annoying, but not too bad.
13:08scape_in core.async thread returns a channel, how would the thread that spun off (if looping) be able to write to that channel? same with a go block; or should i create a chan specifically for this?
13:08technomancyaha, even better
13:08seangrov`Is there a list of functions that strip metadata?
13:08shipkisshyPiRion: Thanks for the lead. This particular project lives on github also, so ill make sure I am using the latest code and then go back to lighttable if I still have issues.
13:09stuartsierrascape_: The channel returned by `thread` or `go` receives the return value of the body.
13:09technomancyseangrov`: you could write something to doseq over (ns-publics 'clojure.core) pretty quickly =)
13:09seangrov`$seen ddellacosta
13:09lazybotddellacosta was last seen quitting 1 hour and 9 minutes ago.
13:09hyPiRionshipkiss: good! Well, good luck sorting it out, hopefully it's not too time consuming
13:09scape_stuartsierra: so if looping let's say in a thread, the channel is empty until the loop ultimately closes?
13:10stuartsierrascape_: yes
13:10scape_okay thanks
13:44aaelonyyogthos: really liking your markdown-clj library. Two questions I haven't seen in the docs: 1. Does it support adding CSS to to the html markup it produces? and 2. are html tables supported?
13:46sandbagstechnomancy: any idea why clojars might be telling me "Invalid PGP public key"? I've generated and exported the key and I'm including the ---BEGIN ---END bookends
13:47aperiodicfireplace users: is there any way to get the value of an evaluation back in to my vim buffer easily? sometimes i want to be able to look at it while typing new things
13:47sandbagsi'm using gpg from homebrew
13:47sandbagssays gpg v1.4.16
13:48sandbagsthe pgp.com keyserver didn't barf on it so i'm a bit stumped about why clojars thinks it's invalid
13:48sandbagsplease anyone else feel free to chip in, i only targeted technomancy because he seemed to be in charge
13:49technomancysandbags: hmm... I wouldn't worry about what clojars says; the signature stuff is a bit half-baked right now unfortunately
13:50sandbagstechnomancy: so just leave the key out?
13:50technomancysandbags: if you want to confirm that you've published signed artifacts correctly, I think `lein deps :verify` would be more reliable
13:50sandbagsok, thanks
13:50technomancyyeah... we should probably disable that section in clojars until we get the chance to do it right
13:59steckerhalterhow do I make one vector from a list that contains several vectors?
14:00fortruceflatten
14:00llasramI'm thinking of mucking with clojure.lang.EdnReader's reader-macro dispatch table to allow #'namespaced/vars to read back as resolving the var. Level of evil?
14:00aperiodicsteckerhalter: 1) flatten, but preferably 2) make the vector the right way in the first place, with e.g. mapcat
14:00hyPiRionsteckerhalter: (reduce into [] list-of-vectors)
14:01steckerhalteraperiodic: ah yes, mapcat works perfectly. thanks
14:17gfrederickswhat's the preferred way to create a small IPersistentMap in the clojure java code?
14:17gfredericksthe easiest seems to be PersistentHashMap.create(k,v, ...)
14:17gfredericksbut presumably we like array-maps for small maps
14:18gfredericksand there is not an analogous method
14:19llasramgfredericks: I just happen to be looking right now at a direct call to the PersistentArrayMap constructor. Var.java, line 77
14:19llasramSeems to be comparably easy
14:20gfredericksah with the array syntax
14:20gfredericksmay as well
14:20gfredericksllasram: thanks
14:20llasramnp
14:21llasramgfredericks: I think I remember a while ago you were trying to figure out some way of round-tripping Var's through reader or EDN serialization
14:22llasramgfredericks: Did you ever get a solution you were satisfied with?
14:23yogthosaaelony: you can mix in html tags freely, they just get ignored by the parser
14:25drorbemetHi, how can I get a lazy seq of chars from a java.io.BufferedReader of a text file with very long lines?
14:27gfredericksllasram: I think so
14:27gfrederickslet me dig that up
14:27drorbemetI am at this point, getting some lines
14:27drorbemetwith-open [rdr (bz2-reader bz2file)] (print (take 20 (line-seq rdr))))
14:27aaelonyyogthos: that's cool. I can always make a second pass to add css and table conversions. pretty cool...
14:27llasramdrorbemet: If you really want just a sequence of chars, you can just wrap it in a lazy seq which calls the 0-argument `.read` repeatedly
14:27yogthosaaelony: it does allow adding custom transformers as well, don't know if that would help
14:27ztellmandrorbemet: you just want characters?
14:27gfredericksllasram: https://github.com/fredericksgary/lib-7607/blob/master/src/com/gfredericks/lib_7607/serialization.clj#L82
14:28llasramOh, the random numbers
14:28drorbemetztellman: yes but lazy , the file is several gb large
14:29ztellman(take-while #(not= (int %) -1) (repeatedly #(.read reader)))
14:29ztellmanroughly
14:29TimMczilti: Did you ever figure out the SQL timing thing?
14:29drorbemetztellman: llasram: thanks I try again
14:29aaelonyyogthos: cool, let me wrap my head around custom transformers... I just need to add something simple like <link type="text/css" rel="stylesheet" href="/css/mou.css"> and then also add table,th,td,tr etc.. tables
14:29aaelonytable tags
14:30yogthosaaelony: are you trying to inject those based on markup or are they static?
14:31aaelonyyogthos: I think the output will be static, kind of like ipython notebooks..
14:31llasramgfredericks: Oh, so you create a new type (which just happens to also have base-name `Var`)? How do things get wrapped in that type in the first place?
14:31aaelonyyogthos: something like a chronicle of what was done, how it happened, how to reproduce, etc..
14:32yogthosaaelony: why not just put the tags inline with the text passed to the parser?
14:33aaelonyyogthos: could do that..
14:33aaelonyyogthos: it deviates a bit from the readability when writing it but would work.
14:34yogthosaaelony: right, the other option is to make a new transformer and define a tag for css links for example
14:34yogthosaaelony: they're pretty simple, each transformer takes a map representing the current parser state and the line text
14:35yogthosaaelony: then does something to the text and returns a new state/text
14:35aaelonyyogthos: that's the best solution, depending on if I can sneek some time to write it :)
14:36aaelonyyogthos: this is it, right? https://github.com/yogthos/markdown-clj/blob/master/src/markdown/transformers.clj
14:36llasramOh, duh -- I can just vendor a copy of EdnReader in which I (safely!) add a var-resolving dispatch for #'
14:36llasramEveryone wins
14:37yogthosaaelony: yup that's how the built in ones work
14:37drorbemetztellman: I got a solution (take 20 (map char (repeatedly #(.read reader))))
14:37aaelonyyogthos: ok, just need to figure out how it works... ;)
14:37ztellmandrorbemet: that's going to be infinite, it returns -1 when it's empty
14:37yogthosaaelony: but you can initialize with additional ones doing (markdown/md-to-html-string "#foo" :custom-transformers [capitalize])
14:37yogthosaaelony: or (markdown/md-to-html-string "#foo" :replacement-transformers [capitalize])
14:37ztellmanyou need to add a take-while clause
14:38yogthosaaelony: it's half way through the docs ;)
14:38aaelonyyogthos: what's good example of this in that file?
14:38drorbemetztellman: that't fine for me, I just need the head of a large file
14:38ztellmanok
14:38yogthosaaelony: the one in the docs is the simplest example: (defn capitalize [text state] [(.toUpperCase text) state])
14:39ztellmanPSA that for general lazy consumption of bytes/characters, https://github.com/ztellman/byte-streams does all that and more!
14:39drorbemetztellman: but I'll keep your solution for reference, don't worry :-)
14:39aaelonyyogthos: saw that, didn't click though initially
14:39aaelonyyogthos: getting it now...
14:39yogthosaaelony: the simple transformers are good too https://github.com/yogthos/markdown-clj/blob/master/src/markdown/transformers.clj#L115
14:40yogthosaaelony: you just call the separator and pass whatever separator you defined
14:40aaelonyyogthos: very nice, thanks. If I come up with something decent I'll send it back for inclusion
14:41yogthosaaelony: sounds great :)
14:41aaelonyyogthos: super :)
14:41hiredmanztellman: needs more reducers
14:41ztellmanhiredman: it's true, who needs laziness when you have THE POWER OF FORK-JOIN
14:41drorbemetztellman: you are right it's better to make it complete right away
14:41drorbemet(take 20 (take-while #(not= (int %) -1) (map char (repeatedly #(.read rdr)))))
14:42ztellman,(char -1)
14:42clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Value out of range for char: -1>
14:42ztellmandrorbemet you need to do the -1 check before mapping char over it
14:42drorbemetztellman: oh right
14:42hiredmanztellman: oh, no, not fold, just reducers let the producer control resource life time, where lazy seqs don't
14:43ztellmanhiredman I'm imaginging some sort of rich hickey as lion-o from thundercats picture right now
14:43llasram(inc hiredman)
14:43lazybot⇒ 35
14:43hiredmanztellman: he has the hair for it
14:43ztellmanhiredman: I create closeable seqs
14:43llasramhiredman: You may appreciate https://github.com/ring-clojure/ring/pull/115
14:43drorbemetztellman: should have listened ;-)
14:43hiredmanztellman: sure, but the consumer still has to use with-open
14:44BSfanI am having an issue with my browser opening up tabs on its own. I have run scan. Is there any way to fix this without reformating? more info here http://pastebin.com/Xfi1BTCq
14:44hiredmanztellman: I did a write up http://ce2144dc-f7c9-4f54-8fb6-7321a4c318db.s3.amazonaws.com/reducers.html
14:44ztellmanhmm, interesting
14:46llasramI wish rhickey had done them as a separate library though. As part of core, some of the missteps are probably frozen for a long time :-/
14:49ztellmanhiredman: I don't see any reason not to add this sort of resource handling into byte-streams, thanks for the idea
14:50hiredman:)
15:05sverihi, i am trying out datomic and i wonder if i need to define a schema before i can do inserts?
15:06stuartsierrasveri: You need to define some attributes, yes.
15:06sverihm, is there an example that does not define a schema but attributes?
15:07stuartsierrasveri: A Datomic schema IS attributes.
15:07sveristuartsierra: ah, i see, thats a pity
15:07sveriand i can change that schema every time?
15:07sveriI thought its like a document storage with no explicit schema
15:08dnolensveri: it is not
15:08stuartsierrasveri: No, Datomic is not a document store.
15:08shaungilchristthankfully
15:08sveriok, but i can adopt the schema every time?
15:08stuartsierraDatomic stores tuples of entity-attribute-value-transaction where the attribute must be created in advance.
15:09stuartsierraI'm afraid I don't understand what you mean by "adopt the schema every time."
15:09sveristuartsierra: add some attributes to an existing schema
15:09hiredmansveri: an entity in datomic is not a document, an entity
15:09stuartsierrasveri: Yes, you can add attributes at any time.
15:10hiredmandoes not have to comform to a schema
15:10hiredmanattributes about an entity do
15:10sveriok, thank you all very much, i guess that helps me for now :-)
15:10sveriseems like a lot people here have used that already
15:15hiredmanllasram: that is a neat pr
15:16stompyj$seen stompyj
15:16lazybotstompyj was last seen talking on #clojure 20 milliseconds ago.
15:17stompyj^nailed it
15:17llasramhiredman: Glad you like it. Switching to an internal ring-servlet release w/ that applied fixed several resource leaks in ring apps we have
15:18bbloomstompyj: lol i think that you just discovered lazybot's latency metric
15:18bbloom$seen bbloom
15:18lazybotbbloom was last seen talking on #clojure 27 milliseconds ago.
15:18bbloom$seen bbloom
15:18lazybotbbloom was last seen talking on #clojure 30 milliseconds ago.
15:18bbloom$seen bbloom
15:18lazybotbbloom was last seen talking on #clojure 30 milliseconds ago.
15:18stompyjhahah
15:18bbloomlazybot: ping
15:18lazybotbbloom: Ping completed in 0 seconds.
15:18bbloom:-)
15:19hiredmanllasram: the fact that it won't work on a collection of bytearrays makes me sad, but the old way wouldn't either
15:19hiredmanstrings are of the devil
15:21llasramhiredman: Yeah -- I figured that was an orthogonal issue, to be solved at some point, but not all at once
15:23BSfanv
15:23BSfanI am having an issue with my browser opening up tabs on its own. I have run scan. Is there any way to fix this without reformating? more info here http://pastebin.com/Xfi1BTCq
15:32edbondBSfan, you are talking in wrong channel. Install clojure first
15:34edbondBSfan, certanly not #clojure stuff
15:34hyPiRionBSfan: I wish anyone here could help you, but unfortunately this is the channel for the Clojure programming language, so it seems unlikely
15:37fowlslegsI have a sequence and I would like to all elements that are not integers in (range 65 91). How can I do this?
15:37fowlslegsto remove*
15:37edbond,(doc filter)
15:37clojurebot"([pred coll]); Returns a lazy sequence of the items in coll for which (pred item) returns true. pred must be free of side-effects."
15:38fowlslegsI looked at filter and remove and thought about putting an anonymous fn as the [pred], but wasn't sure how?
15:39edbond,(filter (set (range 65 91)) [61 100 99 88 65])
15:39clojurebot(88 65)
15:39dsrx,(filter #(> % 5) (range 10))
15:39clojurebot(6 7 8 9)
15:39fowlslegsSomething like (filter #(=any (range 65 91) list)
15:39hyPiRionfowlslegs: (remove (set (range 65 91)) list)
15:39fowlslegsOkay thanks
15:40llasramYou people are being way too literal -- numbers!
15:40hyPiRionfor this particular instance though, you could do (remove #(<= 65 % 90) list)
15:40dsrxfowlslegs: the insight with those answers is that you can use a set as a function
15:40llasramhyPiRion: Finally, some sanity!
15:40dsrx,(#{1 2 3 4} 10)
15:40clojurebotnil
15:40dsrx,(#{1 2 3 4} 3)
15:40clojurebot3
15:41hyPiRionllasram: I'm usually a poor variant of a hindley-milner which generalises too much
15:41dsrxumm
15:41dsrx,(remove #(<= 65 90) [66, 66.1, 91])
15:41clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox/eval146/fn--147>
15:42dsrx,(remove #(<= 65 % 90) [66, 66.1, 91])
15:42clojurebot(91)
15:42dsrx,(remove #(<= 65 % 90) [66, 66.1, 91, 91.1])
15:42clojurebot(91 91.1)
15:42dsrxdoes not remove all elements that are not integers in (range 65 91)
15:42hyPiRiondsrx: oh, it does that, and more
15:43dobry-denThere's something to say about premature optimization. But there's also something to say about "I'll just hack this inefficient mudball of a function together for now so I can resume working on this other part of the code. Surely I'll remember that this is a fatal bottleneck."
15:43dsrxhyPiRion: 91.1 is not an integer in (range 65 91)
15:43bbloomdobry-den: that's why man invented the XXX comment marker
15:43scape_typecast it
15:43bbloomdobry-den: just throw a XXX in there
15:44bbloomwhenever anything goes wildly wrong, the first thing i do is grep for XXX to make sure i didn't warn myself about this
15:44dobry-den"but surely i'll remember!"
15:44hyPiRiondsrx: yeah, I see I read the question in the opposite order.
15:44bbloomdobry-den: yeah, you never remember :-)
15:44bbloomi don't use comments as documentations, i use them as "notes to future self"
15:45dobry-denlesson learned though. just distinctly remember my confidence as i considered leaving myself a FIXME comment
15:45bbloom;; XXX This is O(N^3) time and will surely blow up on non-toy datasets
15:45bbloom;; XXX oh god. make it stop
15:46bbloomyeah, ego can prevent you from admitting stupidity when writing code
15:46dobry-denmaybe i'll even make a (xxx) function that launches a JPanel when (= :staging env)
15:46bbloombut a carefully worded comment can side step that by making you look like a guy who gets shit done and cuts corners appropriately and lucidly to make forward progress
15:55KrajsnickWhen I use a library in my project, say for example enlive. I look up the version on clojars and add it to my lein project.clj. How do I know what namespace to require? Do I need to consult the enlive source?
15:55hiredmanor docs
15:56fortruceshould be: net.cgrand.enlive-html
15:56stuartsierraKrajsnick: docs or source, yes. There is no fixed relationship between the name of a Leiningen/Maven dependency and the Clojure namespaces it contains.
15:56KrajsnickI see, thanks :)
15:57turbofailideally every project README would have an example namespace import
15:57turbofailsadly this is not always the case
15:57KrajsnickI would like to try Light Table, however will it use my existing lein's Clojure? Because Light Table docs says their internal doc will download a clojure first time?
15:58dnolenKrajsnick: it will use your existing lein
15:58KrajsnickSweet! :)
16:01OscarZon documentation.. I really liked the docs on Welle, a Riak Clojure library: http://clojureriak.info/articles/connecting.html
16:01OscarZdidnt take long to try it
16:09dacci should try light table again -- has it progressed much since summer?
16:12BobSchackdacc It's improved an incredible amount since summer
16:12BobSchackIt's now open source in fact
16:19fowlslegs,(-> "rhesus macaque" .toUpperCase (map int))
16:19clojurebot#<ExceptionInfo clojure.lang.ExceptionInfo: Don't know how to create ISeq from: clojure.core$int {:instance #<core$int clojure.core$int@1fa4175>}>
16:19fowlslegs,(map int (.toUpperCase "rhesus macaque"))
16:19clojurebot(82 72 69 83 85 ...)
16:19fowlslegsCan someone show me the correct way to use ->
16:20llasramfowlslegs: The argument order for the threaded functions is the problem. Check -> vs ->>
16:20fortruce-> inserts as the second item in the form
16:20fortruce,(->> "rhesus macaque" .toUpperCase (map int))
16:20clojurebot(82 72 69 83 85 ...)
16:20fortruce->> inserts as the last
16:21shep-werk,(clojure.walk/macroexpand-all '(-> "rhesus macaque" .toUpperCase (map int)))
16:21clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.walk>
16:21shep-werkbooo
16:22shep-werk=> (map (. "rhesus macaque" toUpperCase) int)
16:32edbondfowlslegs, http://blog.fogus.me/2009/09/04/understanding-the-clojure-macro/
16:33edbondfowlslegs, and from comments there: https://en.wikibooks.org/wiki/Clojure_Programming/Examples/API_Examples/Macros
16:46jonathanj(. "xxx" toUpperCase) is pretty weird to read ;)
16:46jonathanjat least, i wasn't expecting that but it makes sense
16:47stuartsierra,(.toUpperCase "xyz") ; is more common
16:47clojurebot"XYZ"
16:47`cbp,(clojure.string/to-upper "xyz")
16:47clojurebot#<CompilerException java.lang.RuntimeException: No such var: clojure.string/to-upper, compiling:(NO_SOURCE_PATH:0:0)>
16:47`cbpwait it's upper-case
16:55jonathanjfrom a REPL can i print the source code of a macro?
16:56llasram,(clojure.repl/source clojure.repl/source)
16:56clojurebotSource not found\n
16:56llasrampfft
16:56llasramDespite what clojurebot would have you believe, yes
16:56jonathanjuser=> (source .)
16:56jonathanjSource not found
16:56llasramOh, `.` is a special form, not a macro
16:56jonathanjah
16:57jonathanjand ` too?
16:57`cbpyou can (doc .)
16:57llasramjonathanj: ` is reader syntax
16:57`cbp,(doc .)
16:57clojurebotIt's greek to me.
16:57`cbpgdammit
16:57llasram(doc .)
16:57clojurebotGabh mo leithscéal?
16:57llasramOh come on
16:57`cbp##(doc .)
16:57lazybot⇒ "Special: .; The instance member form works for both fields and methods.\n They all expand into calls to the dot operator at macroexpansion time."
16:57llasramPull yourself together, clojurebot!
16:59stompyjhahahahahahah
17:02teslanicknice
17:24seangrov`Hrm, how do I throw an error from cljs?
17:25seangrov`I see, just throw, I guess
17:25seangrov`That kills the cljs repl though
17:25bbloomseangrov`: what did you try to throw?
17:25bbloom(throw (Error. "whatever"))
17:26bbloomthe repl might only catch Error instead of :default, since that feature didn't exist
17:27bbloomseangrov`: hm, the std repl works. what repl are you using?
17:28bbloomseems the browser repl only catches Error
17:29bbloomdnolen: i'll send a patch your way ^^
17:29dnolenbbloom: cool thanks
17:30seangrov`bbloom: I'm actually testing out airbrake so we can store a user's entire state history on an error
17:31sdegutis,(throw (Error. "whatever"))
17:31clojurebot#<Error java.lang.Error: whatever>
17:31seangrov`Then with their api + webhooks, it'll ping us with the history and error, we'll consume it and generate a test
17:33bbloomdnolen: https://gist.github.com/brandonbloom/8744556
17:33bbloomseangrov`: that patch ^^ should help your browser repl :-)
17:39seangrov`bbloom: Good stuff, thank you :)
17:40seangrov`bbloom: Good luck on the JIRA journey
17:40bbloomseangrov`: no jira journey for cljs. i just pester dnolen here
17:40bbloom:-)
17:40seangrov`Hard to resist, yeah
17:41seangrov`Hopefully should have some cool stuff to show with errors + om in a week or two
17:41bbloomcool
17:41seangrov`Going to try to take some of the wind out of dnolen's sails
17:42dnolenseangrov`: ha, sounds cool
17:49jonathanjhow does one get a cljs repl?
17:50dnolenjonathanj: lein cljsbuild has some REPL support
17:50ivanjonathanj: https://github.com/ludios/py2clj-cheatsheet#get-a-clojurescript-repl-managed-by-austin
17:50ivanI didn't know that!
17:50jonathanjlein --help doesn't list cljsbuild, did i miss something?
17:51llasramjonathanj: It's a plugin
17:51KrajsnickIm going through this little webscrape tut. However date-parser and parse-money confuses me. They are used in the scrape-table fn. Though it explains nowhere how to define those, or am I missing something?
17:51Krajsnickhttp://blog.safaribooksonline.com/2013/09/09/scraping-html-table-data-in-clojure-for-profit/
18:31aperiodicdoes anyone have any idea how to test jvm shutdown hooks?
18:31aperiodicshort of shelling out to another JVM in a subprocess
18:34seangrov`Hrm, core.async makes catching errors with try/catch tough.
18:34technomancytry/catch is essentially dynamic extent
19:05quizdrquestion: are the resources available on the JVM and thus to Clojure usually the same as those on the PC on which they run?
19:07technomancyquizdr: are you asking if there is any overhead from the OS and other programs running on a PC?
19:08yuri_niyazovHi there. How would I use java static methods as values?
19:08yuri_niyazovIOW, I want to be able to do
19:08quizdrwell, more if the JVM automatically limits the resources that are available
19:08yuri_niyazov#{Math/ceil Math/floor}
19:08yuri_niyazovso that they are in a set
19:08yuri_niyazovand then test whether a value being passed in is in a test
19:09yuri_niyazovI know that this is doable with a clojure-level FN
19:09quizdrtechnomancy that is that custom VMs can be configured to only use a certain limit of PC resources, and am wondering if the JVM does this as well
19:11aperiodicnah, by default the JVM takes all the OS will give it
19:11technomancyquizdr: the default max heap size is based on the total amount of ram; I don't remember exactly how it's calculated but it's easy to look up
19:11technomancywhether the amount of CPU is limited depends on how you set up your thread pools
19:11quizdrtechnomancy and I assume if you run the JVM on an 8-core machine, for example, then all 8 cores would be available to clojure code (assuming of course you are explicitly using threads in some fashion)
19:12quizdrahh you answered me already
19:14yuri_niyazovAlternatively - is there a way to curry Java methods?
19:16rhg135i was wondering if there is a good clj-aware profiler, currently looking at visualvm
19:16noonianyou could wrap java methods in clojure fn's
19:17devntechnomancy: is there any chance whatsoever of heroku ever allowing people to specify what kind of app /should/ be detected by Heroku?
19:17devni just had to drop an index.php file into my repo and create an .htaccess file to serve some static assets. what the?
19:18technomancydevn: you mean when you push a fresh new app that doesn't match any of the existing buildpacks?
19:18devnlike if i have a project.clj and a Gemfile
19:18devnsuddenly it's a ruby project
19:18technomancydevn: echo "web: python -m SimpleHTTPServer $PORT" > Procfile
19:18devntechnomancy: is that for static assets?
19:18technomancyright
19:19technomancydevn: anyway, there's no way to change the default detect order without breaking thousands of existing apps, sadly
19:19devnwow dude. is that not documented? or did i just not find it?
19:19devnbecause that's way better than having a 0byte index.php and .htaccess which essentially turns off PHP
19:20technomancyit's documented that you can put arbitrary commands in your procfile, sure =)
19:20technomancyand it's documented that python ships with an HTTP server
19:20technomancyI don't know if we explicitly put two and two together for you =)
19:20technomancydevn: so what I would like to do is have the BUILDPACK_URL detected upon first push
19:20devntechnomancy: thinking outside of the box is hard when the box you're deploying to seems to understand what you want before you ask for it
19:20technomancythen if you want to change it after that, it's up to you
19:21devntechnomancy: that's helpful. thanks.
19:21technomancybut I'm not on the build team any more, so I don't know how likely that is to happen
19:25devntechnomancy: i always feel bad that i bring up my heroku issues with you. i know you aren't paid to do support on IRC. you're my main vent though. I think sometimes heroku pays for itself over the long term, and then other times I am literally at my wits end with the inability to have control over the environment without handrolling a bunch of stuff.
19:25devnlike the fact that the index.php hack is documented should be alarming
19:25technomancydevn: yeah, that's super crappy
19:26devni mean, why can't i just said: "hi. i have static html files. serve them."
19:26technomancyI waste enough time on IRC that actually answering heroku questions in here is probably a thing I should be doing
19:26devnthat seems like the simplest thing possible
19:26technomancyeh
19:26technomancyif you want to pay a bunch extra for something S3 does for nothing, that's cool
19:26technomancybut it's not exactly our core competency
19:27devnsure, but it doesn't need to be. it's literally the simplest thing you could do with heroku, no?
19:27technomancyheroku is for running code
19:27technomancy`heroku run bash` is the simplest thing you can do with heroku
19:28devnfor the sake of argument though, people are trying to use heroku to serve a simple static site. maybe it's early in their projects' lifecycle and they just want a dead simple splash page.
19:28devnand in order to do that, you need a config.ru, index.php, or a python server, etc.
19:29technomancyI think that has more to do with the problem of heroku being viewed as "a free place to put my stuff" than anything else
19:29devnif people are trying to do it, they may as well let it happen in a way that doesn't suck
19:29technomancyoh, ok. so that is something which is really crappy: the inline buildpack isn't the default
19:29technomancyI complained about that a lot when I was on the build team but always got a lot of pushback
19:30devnwhat's the concern?
19:30technomancyusing this makes things a lot simpler: https://github.com/kr/heroku-buildpack-inline
19:30meingbgSo this is weird. Apparently clojure.core/= can return true for values that are not equal, and that will result in different result if used in computation.
19:31technomancydevn: no one wants to touch the default set of buildpacks because it's this silly thing that's grown as a series of historical accidents
19:31devnmeingbg: example?
19:31technomancymeingbg: sad but true
19:31technomancymeingbg: arguably laziness would be much more annoying without that property
19:31devntechnomancy: ah, yeah i guess i can see that
19:31technomancybut it is a trade-off of correctness vs convenience
19:31meingbgdevn: (let [a (seq [1 2 3]) b '(1 2 3)] (list (= a b) (list? a) (list? b)))
19:31devni haven't ever dealt with = being a problem
19:32devn,(let [a (seq [1 2 3]) b '(1 2 3)] (list (= a b) (list? a) (list? b)))
19:32clojurebot(true false true)
19:32technomancyclojure.core/= will also compare two mutable hashmaps as equal =(
19:32devnugh
19:32technomancyterribly terrible
19:32devnis this at all changed by the new hashing stuff?
19:32devnnevermind, no, of course not.
19:33devntechnomancy: btw, the reason all of this came about, was that I was trying to find the simplest way to deploy a hoplon app
19:33technomancydevn: personally I think it's crazy not to use the inline buildpack if you have a chmoded bin/compile and none of the other buildpacks match, but not everyone agrees
19:33technomancys/chmoded/executable/
19:34devntechnomancy: i just want a way to opt out of magic
19:35noonianmeingbg: i prefer that behavior, since many core fns turn things into lazy seqs
19:35devnlike an obvious, simple way to ask politely for no magic
19:35technomancydevn: setting BUILDPACK_URL to the inline buildpack is your best bet for that
19:35devnword. thanks.
19:35technomancydevn: then your build behaviour is delegated entirely to bin/compile
19:35technomancyas it should be
19:35noonian,(let [a (seq [1 2 3]) b '(1 2 3)] (list (= a b) (seq? a) (seq? b)))
19:35clojurebot(true true true)
19:35noonian,(let [a (seq [1 2 3]) b '(1 2 3)] (list (= a b) (seqable? a) (seqable? b)))
19:35clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: seqable? in this context, compiling:(NO_SOURCE_PATH:0:0)>
19:36noonian,(let [a (seq [1 2 3]) b '(1 2 3)] (list (= a b) (sequential? a) (sequential? b)))
19:36clojurebot(true true true)
19:36meingbgnoonian: I'm fine with equality functioning that way, as long as you make the list? predicate return the same thing.
19:37devn,(class (seq [1 2 3]))
19:37technomancylist? is the worst predicate
19:37clojurebotclojure.lang.PersistentVector$ChunkedSeq
19:37noonianbut the list? predicate is about type, whereas = is about semantic equality in clojure
19:37meingbgnoonian: devn: If two things are equal and immutable, then applying the same functional function to them both should give equal result.
19:37devn,(class '(1 2 3))
19:37clojurebotclojure.lang.PersistentList
19:37technomancyit's just junk. never use it.
19:37devn(inc technomancy)
19:37lazybot⇒ 96
19:37devnnot that (class (seq [1 2 3])) is still persistentvector$chunkedseq
19:37devnnote*
19:38devnmeingbg: i am not saying you're wrong. i think it's a bit weird, but since you can see above they actually are of a different type, list? is being truthful
19:39devn(seq [1 2 3]) is not a list
19:39noonian,(for [c [[1 2 3] '(1 2 3)]] (map #(conj % 4) c))
19:39clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IPersistentCollection>
19:40devn,(class (into '() (seq [1 2 3])))
19:40clojurebotclojure.lang.PersistentList
19:40stcredzeroquestion: how do I get (debug-repl) to work in a live server, like iPython or irb?
19:40devn,(into '() (seq [1 2 3]))
19:40clojurebot(3 2 1)
19:40noonian,(for [c [[1 2 3] '(1 2 3)]] (map #(conj % 4) c))
19:40clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IPersistentCollection>
19:41noonian,(for [c [[1 2 3] '(1 2 3)]] (conj c 4))
19:41clojurebot([1 2 3 4] (4 1 2 3))
19:41nooniandoh
19:41meingbgdevn: Yup. I get why the functions act that way, I just feel that list? and = should live on different abstraction levels with a steel door between them. Like, not exposing list? to clojure.
19:42technomancymeingbg: dropping list? would be great, but it wouldn't actually help here
19:43technomancysince vectors and lists behave differently with get, conj, assoc, etc
19:45meingbgtechnomancy: Is (seq [1 2 3]) still a vector? It prints like a list.
19:45technomancyit's not a vector
19:46devn,(conj (seq [1 2 3]) 1)
19:46clojurebot(1 1 2 3)
19:46devn,(class (conj (seq [1 2 3]) 1))
19:46clojurebotclojure.lang.Cons
19:46yuri_niyazovHi there. Would appreciate a bit of help. What is the clojure idiomatic way to unit test floating point equality (or to be more precise, floating point nearness)
19:46devn,(class (seq [1 2 3]))
19:46clojurebotclojure.lang.PersistentVector$ChunkedSeq
19:46meingbgtechnomancy: So your point is that we need list? to tell lists from vectors?
19:47TEttingeryuri_niyazov, good question... I mean you could use with-precision for BigDecimals, but not floats or doubles (I think)
19:48devnwe need list? to know when something is *precisely* a list.
19:48technomancymeingbg: no, the point is lists and vectors behave very differently, and comparing them as = is just a concession to convenience in order to make you not go crazy with all the pervasive laziness clojure has
19:48technomancywe don't need list? at all in application code
19:48devnneed is a strong word, but in the above cases, list? does say when something is 100%, all the way down, a list
19:49TEttingerI think the simplest way might be (defn near [f1 f2] (== (long (* 1000000 f1)) (long (* 1000000 f2))))
19:49technomancythe only purpose of list? is to complect seq? and counted?
19:49technomancyif you care about countedness, use counted?
19:50devnmeingbg: it's like a marker interface that got behavior
19:50devntechnomancy is right
19:51turbofailyeah i don't think i've ever used `list?'
19:51devnit's a little funny that list is not used at all in clojure.core
19:51devni should pull up codeq and import the top 100 github clojure repos
19:51devnand see if anyone uses it
19:52technomancylist? snuck in inside a patch with a bunch of actually-useful predicates
19:52devntechnomancy: like ifn? and so on?
19:52technomancysomething like that
19:52devnyeah, i mean, it's asking about whether it implements X i guess
19:53devnlike you said: counted?
19:53devnCountable, Seqable, etc.
19:54Bronsaoh boy. http://dev.clojure.org/jira/browse/CLJ-1302 I wouldn't have expected this
19:55BronsaI guess this means I will no longer have any use for zipmap and use reduce-kv instead
19:56devnBronsa: you relied on the order of (keys m) and (vals m)?
19:56devnMaps have bitten me enough on order that I basically don't trust a map at all. they are "objects" in a lot of ways to me.
19:57devnand by bitten i mean, i've found myself in situations where i suddenly wanted/needed order
19:57devnbut it was too late, so i decided to represent my data some other way rather than relying on any of map's behavior
19:57Bronsadevn: I thought I could rely on keys and vals ordering being consistent with each other
19:58technomancyBronsa: pretty sure stu has said multiple times that you can rely on that consistency
19:59meingbgtechnomancy: devn: Well I guess what I'm saying is that equality means, among other things, that performing equal operations on equal operands results in equal results. It's great to have laziness built-in or added to a language, and fine if you choose to expose or hide it in terms of equality... but if you choose to hide it, I don't see how it's fine to expose it through other functions, it destroys the sanity of equality.
19:59Bronsaso now I have to change https://github.com/clojure/tools.analyzer/blob/master/src/main/clojure/clojure/tools/analyzer.clj#L152-L153
19:59technomancymeingbg: I agree FWIW
19:59nooniancan just write your own keys and vals that has that contract using (for [[k v] m] ...) if you are worried about it
19:59RaynesBronsa: Nothing is real, everything is permitted.
19:59technomancymeingbg: rich disagrees though, which is what matters
19:59technomancyor at least, he disagreed five years ago
20:00technomancywhat he thinks now is immaterial; he can't cahnge it
20:00seangrov`technomancy: How can I start an nrepl server in my code so I can later connect via `lein repl :connect` or M-x cider?
20:00meingbgtechnomancy: Well, the least one could do is to put big warning flags in the docstring of list? et al.
20:00technomancyseangrov`: I don't know off the top of my head, but it's in the nrepl readme
20:00noonianmeingbg: = is about equality partitions and things, usually clojure programmers want '(1 2 3) and [1 2 3] to be equal for value checks, there are other comparing functions like identical? if you don't want that sort of equality
20:00technomancymeingbg: list? is completely immaterial
20:00seangrov`technomancy: Ah, good point, I'll check it out
20:00technomancyhas absolutely nothing to do with equality
20:01technomancy,(let [x (java.util.HashMap.) y (java.util.HashMap.)] (= x y)) ; much worse
20:02clojurebottrue
20:03meingbgnoonian: That makes the water somewhat clearer.
20:04meingbgtechnomancy: noonian: Well I guess clojures equality concept simply isn't what I supposed it was.
20:04noonianyeah, it's definitely something you need to read the docs about
20:04meingbg,(= '(1 2 3) [1 2 3])
20:04clojurebottrue
20:04meingbg...and they don't even print the same.
20:04technomancymeingbg: rich has said clojure.core/= implements egal, but that's not quite true
20:05noonianmost of the clojure books do a pretty good job going over it in the beginning i think
20:05technomancynoonian: is it documented?
20:05technomancyI thought the Joy of Clojure was the first place the term "equality partitions" appeared
20:05noonianyeah, idk if it's in the official documentation
20:06nooniani probably read it in the Joy of Clojure and assumed it was an official language term
20:08devnboolean equality is also a thing
20:08devnor rather, casting to bool
20:08devnit seems related to this conversation
20:09dsrxcast everything to void
20:09technomancydevn: yeah but that's less contentious because everyone agrees it's a nightmare =)
20:09devn:)
20:09devni gotta run all
20:09devni wish you the best of clojuring
20:09devncheers
20:10technomancymeingbg: FWIW leaking equality between Java collections and the vector/seq thing are the only places clojure diverges from egal afaik
20:11meingbgtechnomancy: ok, thanks.
20:12Raynestechnomancy: Heh, I'm pretty sure Stu has actually said that in talks and such.
20:13technomancy¯\_(ツ)_/¯
20:13Rayneslol
20:23Bronsaseangrov`: you know, you could use erc.. https://github.com/Bronsa/.emacs.d/blob/master/abbrevs#L4-L9
20:34_ericis there any general consensus as to what library/framework to use for making a web app?
20:34rhg135ring+compojure
20:35_ericcool
20:36_ericI was having trouble seeing if there was something compelling for using something like luminus or pedistal, but so far I've found ring is pretty greateven without compojure for just non HTML stuff
20:36_ericas I tried to do some HTML, I wasn't sure if I needed much more
20:39RaynesLuminous is a template for a ring+compojure app with lots of good defaults.
20:40RaynesIf you want that, that's there. If you're happy with what you've got...
20:40Raynes:D
20:40_eric(I appologize for asking terribly ignorant questions... feeling out a new world is awkward)
20:41RaynesI didn't see any.
20:42_erictharks for the info, I'll see how much trouble I get into with luminus
20:59seangrov`Is there no edn reader for clojurescript, just cljs.reader?
21:01seangrov`Uhg, and a string that reads fine both with the clojure reader and clojure edn reader fails to read with the clojurescript reader
21:02Bronsaseangrov`: which one?
21:03seangrov`Bronsa: Which string?
21:03Bronsaseangrov`: cljs.reader should just be edn + quote, deref & regex
21:03Bronsaseangrov`: yes
21:03seangrov`Bronsa: I'm going to see if I can figure out what part of the string is causing the failing in the cljs repl
21:03seangrov`Don't suppose there's a verbose option that tells me what it's reading, is there?
21:04Bronsadon't think so
21:05Bronsaseangrov`: well if it's failing to read on the repl than the reader there is tools.reader :/
21:07seangrov`Bronsa: No, it's failing to read on page load
21:07Bronsaah ok
21:08seangrov`It's a string in source code I'm reading
21:08Bronsanot a tools.reader bug, I'm relieved
21:10seangrov`Bronsa: Don't be too relieved yet ;)
21:10seangrov`Well, assuming cljs.reader is the same as tools.reader
21:10BronsaI didn't write it.
21:13seangrov`Hrm, I wonder if it's because of keywords like :2
21:13seangrov`and :2013-11-2
21:13seangrov`Would be very unpleasant to be bit by that
21:14Bronsaseangrov`: well, those are invalid keywords
21:15seangrov`Bronsa: Wasn't that only recently decided?
21:15seangrov`Yup, found the bug for it
21:15seangrov`http://dev.clojure.org/jira/browse/CLJS-677
21:16seangrov`Well, maybe I need to port clojure.tools.reader.impl.commons/parse-symbol , whatever that entails
21:16Bronsawell, the documentation explicitely states that keywors like symbols cannot start with non-numeric characters
21:16Bronsakeywords*
21:17seangrov`heh, cannot start with* numberic characters?
21:17seangrov`numeric*
21:17Bronsa.. yeah that
21:17hiredmanBronsa: that changed though, as per the link in the ticket
21:17seangrov`Bronsa: Well, that JIRA ticket disagrees more or less
21:18hiredmanthere was some discussion on the mailing list recently about it
21:18hiredmanhttp://dev.clojure.org/jira/browse/CLJ-1286
21:18Bronsahiredman: seangrov` the ticket hasn't been accepted yet though
21:20hiredmanBronsa: the patch was already applied, then reverted
21:20hiredmanhttps://github.com/clojure/clojure/commit/249479ecebcb0cfca9e6a1d528e3d7f0b3ca7dc6
21:22hiredmananyway, I'd rather we didn't allow keywords that started with numbers
21:22hiredmanbut the clojure ml is on a roll ignoring my preferences :)
21:24Bronsahiredman: I'm not saying the reader spec cannot/should not be changed, only that until the spec explicitely states that keywords should not start with numbers, it's not a bug
21:24noonianenlive and things already uses keywords starting with #'s
21:25BronsaI've been bitten a good amount of times by people (ab)using undefined behaviour (myself included) while writing cinc, I won't encourage relying on anything that's not explicitely documented.
21:26hiredmanBronsa: well, isn't that like 50% of clojure?
21:26Bronsayes. that's what pisses me off the most.
21:26hiredman:)
21:27seangrov`What's the argument against keywords starting with numbers?
21:27hiredmanthe-mostly-inaccurate-and-unofficial-clojure-spec.com
21:27seangrov`Well, I mean, from the spec's point of view
21:28Bronsaseangrov`: technically in the clojure impl keywords are backed by symols
21:28seangrov`I've got to figure out what to do about this problem now, I can't totally reshape the data at this point...
21:28Bronsasymbols
21:28Bronsa,(.sym :1)
21:28clojurebot1
21:28Bronsathere, now you have an invalid symbol.
21:28seangrov`,'1
21:28clojurebot1
21:28Bronsa,(class (.sym :1))
21:28clojurebotclojure.lang.Symbol
21:29hiredmanseangrov`: ' doesn't make it a symbol
21:29Bronsaseangrov`: but.. that's admittedly just an implementation detail.
21:29seangrov`hiredman: Yeah, sorry
21:29seangrov`,(symbol 1)
21:29clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String>
21:29Bronsa,(symbol "1
21:29Bronsa(defn parse-symbol [^String token]
21:29Bronsa (when-not (or (identical? "" token)
21:29Bronsa (not= -1 (.indexOf token "::")))
21:29Bronsa (let [ns-idx (.indexOf token "/")]
21:29Bronsa (if-let [ns (and (pos? ns-idx)
21:29clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
21:29Bronsa (subs token 0 ns-idx))]
21:29Bronsa (let [ns-idx (inc ns-idx)]
21:29Bronsa (when-not (== ns-idx (count token))
21:29Bronsa (let [sym (subs token ns-idx)]
21:29Bronsa (when (and (not (numeric? (nth sym 0)))
21:29Bronsa (not (identical? "" sym))
21:29hiredmanaccording to http://clojure.org/reader you can't put . in keywords
21:30hiredman"They cannot contain '.' or name classes."
21:31Bronsadamn. did I spam much?
21:32seangrov`But outside of implementation, is there a reason to disallow it? hiredman you said you'd prefer it not be allowed
21:32BronsaI'm sorry, I accidentally shift-ins'ed
21:33hiredmanseangrov`: they are just weird
21:34hiredmanseangrov`: generally the reasons for accepting them are things like, oh well, java.jdbc unconditionally turns map keys in to keywords
21:34technomancyI think there's value in keeping keywords conceptually close to symbols
21:34hiredmanwhich, well, you also get it creating keywords like :foo(1)
21:35hiredman:COUNT(foo) I guess
21:35hiredmanwhich, well, obviously not going to be a legal keyword, so maybe java.jdbc just shouldn't be keywording everything
21:35hiredmanjust because it is a key in a map, doesn't mean it needs to be a keyword
21:37hiredmanbasically, I like it the way it is, and all arguments for changing it seem to come from what in my opinion are bad models
21:37seangrov`hiredman: Ah, that made me realize that it's cljs-ajax that's turning the numbers into keywords
21:37bbloomBronsa: despite all the awesome work you do, you are not forgiven for accidentally spamming. turn in your badge and gun
21:41seangrov`,(keyword "4")
21:41Bronsabbloom: I still don't understand how I missed ) for ins
21:41clojurebot:4
21:41seangrov`So that should be invalid?
21:41Bronsa,(keyword "]")
21:41clojurebot:]
21:41bbloomseangrov`: garbage in garbage out
21:41Bronsathere's no validation on symbol/keyword seangrov`
21:42technomancyseangrov`: undefined behaviour, isn't the same as invalid
21:42bbloomBronsa: i haven't had an ins key in a long time, so i don't even remember where it is on the keyboard
21:42hyPiRion,(keyword "-)")
21:42clojurebot:-)
21:42seangrov`Well, I guess this is part of the problem: (js->clj (js-obj "4" "example") :keywordize-keys true)
21:42technomancy,(symbol "o hai") ; <- obviously nonsense
21:42clojureboto hai
21:42bbloom(inc hyPiRion)
21:42lazybot⇒ 33
21:42seangrov`=> {:4 "example"}
21:42bbloomseangrov`: js->clj is a clearly bad idea
21:42Bronsabbloom: in my keyword it's just above backspace. which means 2 keys to the left of ) and one above.
21:43technomancyBronsa: using erc?
21:43bbloomseangrov`: as is clj->js
21:43seangrov`bbloom: We consume json feeds :P
21:43Bronsatechnomancy: yes, with erc-flood-protect set to nil for some reason unkown.
21:43technomancyBronsa: there's a better way to do it in 24.4
21:43technomancy(setq erc-accidental-paste-threshold-seconds 0.5)
21:44Bronsaawesome, thanks
21:44technomancyerc-flood-protect just turns off trickling so freenode will boot you; this actually stops it before it's sent
21:44technomancy(24.4 is not released yet, but whatever)
21:44bbloomseangrov`: a better idea is something like ruby's HashWithIndifferentAccess
21:44technomancy~guards
21:44clojurebotSEIZE HIM!
21:45bbloomseangrov`: rather than *converting* you just wrap it in an adaptor that implements the protocols, backed by a raw json object
21:45bbloomseangrov`: if you discard all aliases of the mutable JSON crap as soon as you get it, then that's as good as immutable :-)
21:46bbloomseangrov`: bonus: no O(N) cost :-)
21:52seangrov`Wooo, replay actually worke
21:52seangrov`worked*
21:52seangrov`I had to hand-mangle the edn to get the replay data from airbrake in the right state, but now I can figure out how to smooth it out
21:53bbloomseangrov`: with react/om/whatever?
21:53bbloomfuck yeah functional programming? :-P
21:56seangrov`bbloom: Yeup
21:57seangrov`Om/react => post error to airbrake with history of messages => webhook hits our site with the error and history payload => generate data to feed to a test replay with the shell of an automated test
21:57bbloomnice
21:58seangrov`Runs completely independently of any server too as a side effect
21:58seangrov`Basically re-inventing a substandard pedestal here
22:10espeedHi - trying to deploy a pedestal service as a war in a Jetty container, and I'm getting this exception: "java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil"
22:10espeed Here's the full error from the log: https://gist.github.com/espeed/8747309
22:11espeedThis is my first attempt to run any Clojure app in a container (up to this point I've always as standalone on Heroku)
22:11hiredmanespeed: somewhere you are using io/resource to load something is not in the jar
22:11hiredman(disclaimer I haven't looked at the log)
22:12hiredmanor war, whatever
22:15espeedhiredman: thanks -- io/resource is used in one place to read files located in resources/pages.
22:15espeedresources is included in my project.clj here: :resource-paths ["config", "resources"]
22:27john2xwow I'm having a *really* bad time with dependencies
22:28espeedhiredman: I checked the war file, and the resources dir isn't in there
22:30akurilinSo I have a let in a defmacro and I'm getting the complaint that you can't let a qualified name. Is that an indication that I have to gensym it?
22:30eggheadakurilin: #binding instead of binding
22:30eggheadbut ya, basically
22:31john2xeverything was fine just a few days ago.
22:31eggheadbasically you have to use #binding so the compiler can create a funny gensym name like 'foo_a_2345' for #binding
22:32akurilinegghead: Hm I'm getting "no reader function for tag bla"
22:33eggheadi'm sorry, I mean binding#, i derped it
22:33egghead(let [#foo ...] (use #foo))
22:33eggheadagain.. that's backward...
22:33egghead:|
22:33eggheadakurilin: obviously i'm a little slow today...
22:35akurilinegghead: no worries, appreciate the help :)
22:36ddellacostais the only mechanism for type dispatch in Clojure a multi-method?
22:36ddellacostaexcluding anything to do with Java inter-op
22:37carkprotocols
22:37carkthey're for single dispatch
22:39ddellacostacark: right, okay
22:40carkthen you have maps !
22:40cark{:add-item #(...) :cook-it #(...)}
22:41ddellacostacark: the thing is, I want something that falls through to a parent if the child implementation doesn't exist, and I'm not sure how to do this other than multi-methods (in which case it's not parent/child so much as existing/non-existing types)
22:41carkyou're not really looking for dispatch, but for inheritance then
22:42carklook at hierarchies
22:42ddellacostacark: well, but multi-methods could do it. I just was hoping for something that basically let me define a standard interface like a protocol, but would fall through to a standard implementation if it exists
22:42eggheadcouldn't you do that with extend-protocol ?
22:42eggheadsomething like prototype chains in js
22:42carki think you can do that with mutli-method and hierachies
22:43cark,(derive ::cube ::shape)
22:43clojurebotnil
22:43cark,(parents ::shape)
22:43eggheadright, like if you define color-code over ::color and then define color-code over ::red
22:43clojurebotnil
22:43carkhum
22:43cark,(parents ::cube)
22:43clojurebot#{:sandbox/shape}
22:43ddellacostaegghead: that's what I thought, but I"m having trouble figuring out the right pattern. defprotocol and then deftype + extend-type?
22:44ddellacostacark: okay, thanks, let me dig into that. I've barely used the hierarchy capabilities of clojure
22:44john2xcan someone help me figure out this stacktrace? I've updated my deps already. I've individually tried out selmer and cheshire, and they work on their own. https://www.refheap.com/30806 I'm starting to really hate how clojure reports dependency issues
22:45carkjust define your mutlimethod dispatch function to take advantage of that and you're golden
22:45Bronsacark: multimethods already use isa?
22:46ddellacostajohn2x: need to see the code that produces this. Yeah, the stack traces are a sore spot for Clojure, but once you get used to them they are not a problem.
22:46carkBronsa: do they ? I don't think so
22:46ddellacostacark: so, right, back to multimethods...haha
22:46Bronsacark: they do
22:47carkhum... multimethods they just call the dispatch function and return what it returns ...that's basically it
22:47john2xddellacosta: hold on, let me set up a gist.
22:47Bronsanope cark
22:48Bronsacark: http://sprunge.us/ONRi
22:48ddellacostajohn2x: I see that you're getting that when trying to start up a repl, that's a pain. Well, you may want to try commenting out the code that is causing this to track it down. For example, I see selmer- and cheshire-related errors, and seems to be in the gasto.views (I assume that's your code), so maybe try commenting that out to get going.
22:49carkBronsa: ohhh ok, didn't get it that way
22:49carkso there is nothing to it, ddellacosta has his solution right there
22:49john2xddellacosta: yes. gasto.views is generated by Luminus. ok, let me try that out.
22:49ddellacostacark, Bronsa: thanks! That's helpful.
22:50carkBronsa: and thinking back, i might have circumvented this easy solution a couple of times ... thanks !
22:53Bronsacark: ddellacosta also isa? works recursively on vectors so you can do things like http://sprunge.us/JLFP which is extremely convenient
22:56ddellacostaBronsa: nice
22:56carkand i could call "super" by doing (x ::bar) ...so that's the full thing right there
23:11john2xddellacosta: ok, I removed all uses of selmer in my code. noir still uses cheshire, but I can't edit that directly. updated the stack trace: https://www.refheap.com/30806
23:12john2xwhy is it having trouble compiling cheshire? I've checked cheshire's code and ran its tests, and parse-strict is there clear as day
23:12akurilinRandom question: there's no nice way of mocking a macro for testing purposes, eh?
23:12john2xhow do I purge my libraries?
23:12john2xmaybe it's conflicting versions?
23:12ddellacostajohn2x: no idea if this is it, but you could try running lein reps :tree and see if things are pulling in conflicting versions
23:12ddellacostajohn2x: yep, what I was thinking
23:13ddellacostaakurilin: depending on what you're doing, you could use with-redefs perhaps?
23:13akurilinddellacosta: can you with redefs macros? I already use those plenty.
23:13akurilinddellacosta: some code I have is relying on the last value returned from c.j.j's (db-transaction)
23:14ddellacostaakurilin: ah, yeah, I don't know the answer to that.
23:14akurilinI guess one can mock the fn called within it
23:14akurilintoo much of a clusterfrack though. Sounds like this is going to go into integration tests.
23:15ddellacostaakurilin: I know it's easy to say, but I find that if my mocking gets too hairy, I've probably got some mis-structuring going on.
23:15akurilinddellacosta: I can believe that.
23:16akurilinsome people just have a policy not to waste time on mocking on the more complex scenarios like calling API routes
23:16john2xddellacosta: here's the tree https://www.refheap.com/30812.. it doesn't report any issues with selmer or cheshire
23:16akurilintoo much interal magic / reliance on SQL or what not
23:16akurilinOr maybe an indication of insufficient decoupling
23:16akurilinor separation of concerns
23:16akurilinor layering
23:19akurilinHammock time!
23:19ddellacostaakurilin: there ya go. ;-)
23:19ddellacostajohn2x: yeah, I really don't know, I'm sorry. :-( This is definitely one are that is frustrating when debugging Clojure. I would probably end up trying to find a point where things were working and track-forward from there.
23:22john2xddellacosta: also, I should mention that I only get this issue when I upgrade lib-noir to "0.8.0". am I not allowed to change versions ever? :P and I'm pretty sure the changes were pretty minor (I requested the changes, but the author probably updated the deps while at it)
23:24john2xgonna try start a new project from scratch and just copy my progress.. lol.
23:27ddellacostajohn2x: sorry I don't have any better suggestions. :-(
23:28coventryIf you have a version of lib-noir it works with, you could bisect to find the breaking commit.
23:34john2xddellacosta: no problem thanks for the help :)
23:35john2xcoventry: gonna try that. good reason to learn how bisect works.
23:41akurilinSanity checK: is there no ns :require exclusion?
23:41akurilinDo I have to rely on :use to get exclusion?
23:41akurilinAs oppose to some kind of (:require :refer :all :except [bla]) ?