#clojure logs

2014-04-04

02:18haoleif I have a function that returns other functions, what is a good word to give it a "type"? generator? factory?
02:18haoleI don't know what to call my "foo" function generator :D
02:18haolewhat suffix to use or something like that
02:18arrdemhaole: partial? :P
02:19arrdemhaole: or you could just leave a comment with a type signature of the retuned function... :P
02:19haolearrdem: partial is perfect... forgot about it :)
02:19haolethanks
02:45haoleclojure is really impressive, btw... I've managed to implement a proof of concept of something that was entirely theorical so far in 50 lines of clojure, and the previous attempts of doing it were using thousands of lines of (badly written) Java
02:45haole\o/
02:46ssafejavayeah, clojure is a fun language, hard to believe it sits on the jvm sometimes
02:46TEttingerhaole, proof of what concept, I wonder?
02:49haoleTEttinger, adaptative automatons
02:49TEttingerlike cellular automatons?
02:49haolethere are implementations, but none of them of a second degree adaptative automaton, which is what I was talking about
02:49haoleno... from computer science
02:49haolesorry
02:49haoleautomata
02:49haolelol
02:50haoleweird plural from latin
02:50haoleand I'm sleepy :)
02:50TEttingeryep I have no idea what those are
02:50haoleTEttinger: do you know state machines?
02:52haoleTEttinger: think state machines that can add/remove states/transitions on every transition activation
02:52TEttingeryeah, just scanned the wikipedia article on automata theory :)
02:52TEttingeroooh
02:52haoleit's supposed to be useful for AI
02:52haolethat's what my group is studying right now
02:52TEttingerso sorta non-finite FSMs?
02:53haoleyeah, but you have a finite set of "adaptative" rules
02:53haoleit's not complete chaos :D
02:53haolerule = what adds/removes stuff on a transition
02:53TEttingersure
02:54TEttingerthat can't be purely theoretical can it? I guess the second degree is that part?
02:59TEttingerwell that's great that you wrote an order of magnitude less code and got a better result!
03:00TEttingeroh he quit
03:03arrdemthoughts on these last two fns? I'm trying to decide if I'm doing something evil here or not...
03:03arrdemhttps://github.com/arrdem/geri/blob/master/src/geri/aspects.clj#L98
03:03arrdemthis sort of multiple inheritance is nice... but it leaves a bad taste in the mouth.
03:09amalloyarrdem: i mean, while i won't comment on levels of evil because i can't figure out what this is intended to do, that macro should just be a function
03:10amalloyextend is a function, not a macro, and you're evaluating all of your args exactly once in an ordinary context. you're not using any features of macros
03:11amalloyoh, but you have this fnmap thing, i guess
03:11arrdemyeah but fnmap is also just normal eval with no need for syntax gen
03:12arrdemamalloy: the idea here is that if I use defaspect above, it kicks out a protocol which is nice to work with.
03:13arrdemI'd like to be able to do inheritance by composition, so this function turned macro is just a tool for being able to wrap the implementation of a aspect with a partial evaluation to extract a member field.
03:14arrdemso really it's just shorthand for punting the implementation to the appropriate member.
03:14arrdemwhich already has one, presumably.
03:30ddellacostawhen the channel that a mult was created from is closed, does that close all the taps and wipe out the mult?
03:31Viestihum, any recomendations for doing authentication with ring (found cemerick's friend)?
03:33ddellacostaI would start with Friend, in my opinion there's not much else out there unless you want to wrap up some Java solutions (Shiro, for example)
03:42Viestiddellacosta: thanks
03:43ddellacostaViesti: sure thing
05:14tuftis there an alternative to (into {}) for constructing a map without specifying concrete type?
05:25clgvtuft: what do you mean by "without specifying concrete type"?
05:42xsynmorning
05:42xsyn(just)
05:48ddellacostaxsyn: morning, or, evening from Asia. ;-)
06:54kras:key is a keyword, what is this ::my_key
06:55noidi_a namespaced keyword
06:55krasdoes it belong to the current namespace?
06:55noidiyes
06:56noidiit gets expanded to :my.namespace/my_key
06:56kras(equal *ns*/:my_key ::my_key)
06:57noidiand if you have other.namespace aliased as o, you ::o/key is expanded to :other.namespace/key
06:57krasthanks noidi
07:26djpowellSo... om. If I want to pass a value down to a sub component I can either use init-state or grafts?
07:27djpowellAre grafts more suited to values? But I can't use grafts with build-all?
07:30djpowellOr should I be using :opts
07:35ambrosebsanyone used tools.analyzer to scan inside jar files? It seems to completely ignore .clj files in jars.
07:36ambrosebstrying to figure out how to get a list of directories inside a given jar
07:45Bronsaambrosebs: use io/resource
07:45Bronsaclojure.tools.emitter.jvm> (clojure.java.io/resource "clojure/core.clj")
07:45Bronsa#<URL jar:file:/home/bronsa/.m2/repository/org/clojure/clojure/1.6.0/clojure-1.6.0.jar!/clojure/core.clj>
07:47ambrosebsBronsa: I was using clojure.tools.namespace.dir/scan which needs a sequence of directories to scan.
07:48ambrosebsapparently it's foiled by jars
07:50Bronsaambrosebs: dunno, it works in eastwood, let me look at how Andy implemented this
07:52Bronsamh nevermind, clojure namespaces don't run through tools.namespace
07:55ambrosebsBronsa: there's something weird going on with resolving classes after analysing them in core.typed https://groups.google.com/d/msg/clojure-core-typed/Y9TpTeexarg/D4dRJjcvmjMJ
07:55ambrosebsI think this is similar to something I mentioned to you before
07:55ambrosebsHaven't looked further
07:57ambrosebsprobably some weird classloader issue
07:57Bronsadefinitely a classloader issue
07:58BronsaI'll try to see if I can reproduce a minimal case
07:58ambrosebsthanks!
08:04Bronsaambrosebs: I think I see where the problem is
08:04Bronsahttps://github.com/clojure/core.typed/blob/master/src/main/clojure/clojure/core/typed/check.clj#L4995-L4997
08:05Bronsaambrosebs: that Class refers to a stub class used by tools.analyzer.jvm to reflect on it
08:06Bronsaafter the evaluation, that class is overridden in the classloader by the compiled one
08:06Bronsaso clojure.reflect/reflect complains that it cannot find it on the classpath because it's been replaced with the new one
08:07ambrosebsBronsa: so I should always get a new one before reflecting?
08:07Bronsayeah
08:08ambrosebscool. Rushed through :deftype*, didn't really understand what was happening.
08:08Bronsaambrosebs: I'm not 100% sure that this is what's causing the exception Sean is having but it would make sense
08:08Bronsayou can see from the stacktrace that's choking on clojure.core.typed.check/deftype-method-members
08:10ambrosebsBronsa: so class-name is always a class?
08:10Bronsayes
08:11irctcI'm new to this. Can I ask literally anything here?
08:11Bronsaambrosebs: https://github.com/clojure/tools.analyzer.jvm/blob/master/src/main/clojure/clojure/tools/analyzer/jvm.clj#L328 just added a comment :P
08:13ambrosebsBronsa: is :name the full class name?
08:13irctcI have a question, can I get help here?
08:13yotsovirctc: I am new here as well, but from what I have seen, any clojure-related questions are just fine here, so just go ahead :)
08:13Bronsaambrosebs: no, just call (.getName ^Class class-name)
08:13irctcI am trying to deploy a webapp to heroku, but I don't know why it won't deploy. I think it might have something to do with the database connection settings
08:14ambrosebsBronsa: so (-> class-name u/Class->symbol u/symbol->Class) is pretty much what I want?
08:14Bronsaambrosebs: yeah, that should do it I think
08:14ambrosebscool
08:15Bronsaambrosebs: in some future t.a.j release I might stop generating stub deftype classes and just add a hook in the reflector
08:15irctcI get this error: 2014-04-04T11:49:42.457401+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico
08:15Bronsadoing this would mean having to make all :class fields symbols, like clojure.reflector does though
08:16pyrhi guys, running into something that's a bit more of a java issue but I thought I might ask
08:17pyri have to read in double data from a bytestring that is serialized in C by just writing out the address space for the double
08:17yotsovirctc: have you added a favicon to your webapp? does heroku expect you to have one?
08:18pyrso I have two questions: 1. are double stored the same way in memory on the JVM and in C, 2. is there a way for me to read in a bytestring or byte-array to a double ?
08:19irctc I don't know what a favicon is. What is it? and how do you do that signal when you respond to me?
08:19clgvpyr: there is a distinction between primitive doubles and double objects on the JVM
08:19pyrclgv: so primitive doubles will be similar to C doubles and double objects will be something else entirely I suppose
08:19clgvpyr: yes
08:20clgvpyr: java.nio has so called Buffers where you can easily switch from byte to double
08:20yotsovirctc: http://en.wikipedia.org/wiki/Favicon regarding second question, depends on your irc client, in my case I just doubleclick on your name
08:21pyrclgv: ok, will look into this, thank you
08:21pyrclgv: ok, got it, if storage is the same, this will be a breeze, cheers
08:23irctcokay you are helping me out. So it is crashing on the get for a favicon, which is a little 16X16 graphic that I am supposed to provide on that request?
08:23irctcwtf haha
08:24irctcI've deployed other apps on heroku and never had this problem
08:27yotsovirctc: surprising indeed, it might be some other problem in disguise. Such as, your webapp might be crashing on any request, and the favicon request might happen to be the first one incoming. Hard to tell
08:29PeakCodeI believe the app is already crashed when the request for /favicon.ico comes in.
08:30falsettoI'm trying to recall a tool I saw about a year ago that's probably most similar to make. It allows one to write a script to transform data through a discrete number of steps and is implemented in Clojure. Anyone know what I'm talking about?
08:30yotsovfalsetto: Storm ?
08:31yotsovfalsetto: sorry, that's not similar to make
08:31falsettoThanks though :)
08:31falsettoI remember what the page looked like and everything. Dammit. Should have used Delicious :(
08:33falsettoFound it! Yay :) https://github.com/Factual/drake
09:14AeroNotixlong shot but is anyone using authorize.net?
09:59oinksofti'm using leiningen w/ checkouts. I can require the checkout out project, but I get "could not find artifact foo:projname:jar:VERSION in clojars". the project is checkout out to ./checkouts/projname. the dependency is [foo/projname "SOMEVERSION"]
10:00oinksoftbut if I comment out the dependency line, i can run `lein repl` and require things from the checkout out library
10:04jph-i wonder if there's like a message-queuing system, but just for one app's consumption... ala sqlite
10:04jph-likewise an sqlite-like redis
10:05mdrogalisjph-: Redis isn't exactly a queueing system.
10:05jph-mdrogalis, no, but i also look at things like sidekiq that kinda do what i'm looking into
10:05jph-and that uses redis as backend
10:06jph-it was more about having something redis-like that wasn't a full-blown network service
10:06jph-ie how sqlite isn't a full blown database server
10:06mdrogalisjph-: You can always run a lightweight queue
10:06mdrogalisGot'cha.
10:06jph-im beginning to discover that queuing is a big topic area
10:06jph-heh
10:06jph-i started with core.async and lamina and then started looking further afield
10:07jph-the rabbitmqs, the sidekiqs
10:07jph-looking at how this stuff is done in different places
10:07jph-ie if i want to look inside a queue, persist a queue, modify a queue
10:07mdrogalisjph-: Maybe https://github.com/Factual/durable-queue ?
10:07jph-oh that looks lovely
10:08jph-i shall star it right away
10:08jph-this is kind of where clojure-toolbox lies to me... or rather, if i dont see it on the toolbox, i assume something like it doesnt exist
10:09jph-i was beginning to consider things like sqlite or in-memory datomic for something queuey
10:09jph-this looks really nice, thank you
10:09jph-(inc mdrogalis)
10:09lazybot⇒ 4
10:09mdrogalisAnytime
10:10mdrogalisAww yeah up to 4 :P
10:11jph-this is for queuing trading api requests
10:11jph-so something reliable is necessary
10:12mdrogalisjph-: Reliable as in highly available? Strongly consistent?
10:12mdrogalisI can help you pick something if you're clear about your reqs.
10:12jph-if you throw 100 API requests at it, and any fail, you know which failed and can do something about them
10:13rootexcouchdb
10:13jph-and if you throw 1000 and something changes, you can flush the queue, or otherwise halt processing
10:13jph-hrmm
10:13jph-i've done some work with couchdb but i havent thought about it in that context
10:14mpenetjph-: durable-queue from factual comes to mind
10:14jph-mpenet, you were pipped to the finish line, already recommended :)
10:14mpenetah :)
10:15jph-what's the idiomatic way of specifying configuration options to a clojure library you're using?
10:15mdrogalisjph-: HornetQ supports transactions.
10:15mdrogalisMight be worth looking at.
10:15jph-mdrogalis, i'll have a look
10:17jph-durable-queue looks like a lightweight sidekiq/resque in a library
10:17jph-in other words, rather neat
10:22mdrogalisI feel like being able to performance tune one strong queuing system and one database for write throughput are hella valuable skills.
10:22mdrogalisIt's just nice to have that immediately sometimes.
10:34jph-hrmm
10:54oskarthI'm having issues with clj-http and java / Startcom ssl cert leading to a "unable to find valid certification path" error when calling an external API. 1. Would this be solved using http-kit? (others have hinted at this) 2. Is there something else I can do?
10:55dakroneoskarth: can you gist a full stacktrace?
10:55oskarthdakrone: can I pm link to you?
10:56dakroneoskarth: sure
10:56jcromartieoskarth: you need to add the cert to a truststore
10:58jph-oskarth, i had exactly the same issue
10:58jph-from memory it was a oracle java7 issue
10:59oskarthjph-: so it was on the java installation level? using openjdk
11:00jph-yep, i think i have some bookmarks from last time
11:00oskarthI found this thinghttp://www.ailis.de/~k/uploads/scripts/import-startssl
11:00oskarthhttp://www.ailis.de/~k/uploads/scripts/import-startssl *
11:00oskarthwas it somethign like this that you did?
11:01insamniacyou should be able to use keytool to import the cert, and pass the truststore location as a java option
11:01jph-oskarth, yes that exact script
11:01jph-also https://stackoverflow.com/questions/4302686/import-startcom-ca-certificates-in-windows-jre
11:01oskarthokay cool, I'll give it a shot. Thanks all :)
11:01insamniacoh i see, that's what that script does!
11:02jph-i encountered it trying to get jitsi (jabber client) to talk to servers using startcom certs
11:02oskarthdoes anyone have any good resources for grokking SSL? I really don't have a good mental picture of it all and what is causing what and where
11:02jph-you shouldnt have to, that's the problem
11:03jph-it's incredibly complex and libraries should do the work for you
11:03oskarthright, guess java is failing in that regard? :p
11:03jph-your problem is due to one cert provider not getting their CA added to java cert store
11:03jph-no, the cert provider
11:03jph-same problem happened recently with a godaddy CA
11:03oskarthoh. Is this specific to my "cert tree" and not a general problem?
11:03ddellacostaoskarth: https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet
11:04oskarthI don't understand who's vetting who and why really, like where does this Startcom business come in
11:04oskarthddellacosta: thanks
11:04jph-oskarth, this is due to something missing in your cert store, that the provider should have ensured was present
11:04oskarthjph who's the provider?
11:05jph-oskarth, startcom
11:05jph-since they didnt get their CA certs into the cert store, your apps dont trust them
11:05oskarthI see, so I can blame then then!
11:05jph-yes
11:05jph-its the same as encountering a self-signed SSL cert in the wild
11:05jcromartiein Ruby, you would just ignore all SSL errors :)
11:06jcromartiehttps://crypto.stanford.edu/~dabo/pubs/abstracts/ssl-client-bugs.html
11:06jph-well with http-kit i use insecure? false
11:06jph-so i dont get that choice
11:08jph-after looking at durable queue i kind of want a durable-queue-like backed lamina
11:08jph-heh
11:08jph-or persistent lamina channels
11:22mpenetprobably easy to do, aleph a someting a bit similar with redis
11:23lgs32acemerick: Do you have a hint what the reason could be when emacs suddenly decides to shiver while I am running a piggieback session? company-complete was disabled
11:24cemericklgs32a: "shiver"?
11:24mpenetjph-: https://github.com/ztellman/aleph/blob/master/src/aleph/redis.clj#L115-L134
11:25mpenetone way though
11:25jph-mpenet, i was just chatting with someone about the async lamina queue i was testing
11:25jph-https://gist.github.com/jphackworth/9976671
11:25jph-https://gist.github.com/jphackworth/9976727
11:26lgs32acemerick: emacs starts using the cpu around 30%, jvm around 10% without any particular reason, emacs mode line starts slightly shivering, only workaround is to restart the cider session
11:26jph-doesn't do the persistent stuff, or retries, but the client can find out the result of their queued job
11:26cemerickhuh
11:26cemericklgs32a: never seen that
11:26lgs32areall?
11:26cemericklgs32a: AFAICT, eldoc sometimes causes bad things to happen on a ClojureScript session, but I've never seen "shivering"
11:27lgs32ai have eldoc disabled as well
11:27lgs32ai had the problem with older emacs/nrepl combinations as well
11:31cemericklgs32a: perhaps some other modes conflicting / causing problems. Yours is the first report I've heard.
11:32lgs32acemerick: I'd love to debug. can you give me a hint where I can log all ops that are received by piggieback?
11:33cemericklgs32a: it'd require a top-level middleware that dumps requests and responses somewhere. I've actually written it 10 different times, but never kept it around. :-/
11:35jph-mpenet, i havent tried aleph before, but i like the look of that redis/aleph combo
11:36lgs32acemerick: thanks, I'll try something like that.
12:38pdkwhat's the verdict on clojure cookbook
12:38bjorkintoshcook it first.
12:44bbloommeanwhile, in #ruby, there is a guy who consistently tries to write "bbl" but accidentally writes "bbloom: ", so when I come back to my desk, I get to see the ongoing conversation about people who can't find a bug bug in production, but everybody assumes it's related to the fact that he's monkey patching the date time class
12:45ambrosebshaha
12:46justin_smiththe foolishness of trying to tab-complete a tla
12:47justin_smithbbloom: it had not occured to me before that your nick could be parsed as "be back later, out of memory"
12:47bbloomjustin_smith: haha, awesome
12:48justin_smithI guess bbloom would be an apropriate acronym for ruby users "shit, better start quitting random apps, memory is gone again"
12:49technomancyjustin_smith: that's big talk for someone whose runtime uses utf-16 =P
12:49bbloomambrosebs: try to type check this, punk! https://github.com/marcel/aws-s3/pull/14
12:50ambrosebs:)
12:50TimMctechnomancy: OH SNAP
12:50bbloomambrosebs: wow, that was 4 years ago... time flies when you're const_missing
12:50justin_smithtechnomancy: yeah, but the jvm has an arbitrary upper limit that makes it crash, which is like much better, right?
12:51TimMchttp://static.fjcdn.com/gifs/Guuurl_a72cd9_2202093.gif
12:51technomancyriiiiight
12:51technomancyhttp://p.hagelb.org/ram-gone.png
12:58mikerod,(instance? String)
12:58clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/instance?>
12:59mikerodweird. the repl is letting me do that and returning nil
12:59ambrosebsmikerod: which version of clojure are you on?
12:59mikerodI must have something messed up..
12:59mikerod {:major 1, :minor 5, :incremental 1, :qualifier nil}
12:59mikerod,*clojure-version*
13:00clojurebot{:major 1, :minor 6, :incremental 0, :qualifier nil}
13:00ambrosebsmikerod: I seem to remember this issue. Something to do with inlining.
13:00mikerodambrosebs: it gave me a sneaky bug
13:00mikerodnot sure if it existed outside the repl env though
13:00bbloommikerod: try (apply instance? String [])
13:00pyrtsamikerod: My Clojure 1.5.1 REPL returns false. Wow, didn't know of that bug.
13:01mikerodbbloom: I get: ArityException Wrong number of args (1) passed to: core$instance-QMARK- clojure.lang.AFn.throwArity (AFn.java:437)
13:01TravisDtechnomancy: That is my favourite picture of yours
13:01mikerodpyrtsa: it snuck up on me
13:01bbloomthis is what happens when inlining is hacked by hand rather than properly integrated with the compiler... which is what happens when you write your compiler in java and then invent clojure, making you never want to write java again
13:01mikerodI had an `(if (instance SomeClass) "then part" "else part")`
13:01mikerodI always got the "else part" and I didn't realize my arity issue
13:02mikerodbbloom: hah, so this is a known issue addressed in 1.6?
13:03mikerodwhat is the scope of the issue too? I'd be interested to read up on it, but I guess I could just go trace through it and see if I can understand it. :)
13:03seangrovednolen_: Just got a request in #sfcljs to create an Om users group
13:03bbloommikerod: seems so based on what we're seeing & what ambrosebs said
13:03ambrosebsprobably http://dev.clojure.org/jira/browse/CLJ-1171
13:03seangrovednolen_: Time for you to pare Om down into something that doesn't require a users group ;)
13:04mikerodambrosebs: oh nice
13:04mikerodso this may just relate specifically to instance? perhaps; that's a bit better.
13:04pyrtsamikerod: Another funny little thing is that instance? and isa? have their arguments in different order: (instance? Object "") vs (isa? String Object)... :)
13:05ambrosebsmikerod: correct
13:05mikerodpyrtsa: I agree, that confuses me
13:05mikerodjust have to look at the signature closely
13:05mikerodambrosebs: thanks for the link/info
13:05TimMcnigh unto PHP-like
13:05bbloom(doc isa?)
13:05clojurebot"([child parent] [h child parent]); Returns true if (= child parent), or child is directly or indirectly derived from parent, either via a Java type inheritance relationship or a relationship established via derive. h must be a hierarchy obtained from make-hierarchy, if not supplied defaults to the global hierarchy"
13:06bbloomweird. isa? seems backwards to me
13:06technomancybbloom: srsly
13:06pyrtsabbloom: Compared to, say the comparison operators?
13:06TimMcNo, that one makes sense to me.
13:06pyrtsaI think isa? makes sense indeed.
13:06bbloompyrtsa: < makes perfect sense if you just read it as if it were spelled "asc"
13:06TimMc(< a b) is a < b; (isa? a b) is a isa? b
13:06pyrtsaWhat TimMc said.
13:07technomancywhen most people use "X is a Y" in english, they're actually talking about instance?, not isa?.
13:07justin_smithwe just need a prefix-verb-only natural language and these things will all be cleared up
13:07TimMc&(isa? () [])
13:07lazybot⇒ true
13:07technomancyisa? actually tells you "all Xes are Ys", which is just messed up
13:07pyrtsa,(-> String (isa? Object))
13:07clojurebottrue
13:07bbloomTimMc: no, it should read this way: (isa? a b); ((partial isa? a) b)
13:08TimMcyeah, yeah
13:08stainto me, living in UK ,"isa" is a tax-free savings account
13:08bbloomtechnomancy: isa? also depends on hierarchies, which don't have an interface or protocol
13:08stainor something JarJar Binks would say
13:09bbloomi assume hierarchies are from the same era as clojure.zip, where rich was exploring how far and in what direction to push the data + metadata - types approach
13:10justin_smithHeirarchies just seem like a weird useless corner of the language to me. This is probably ignorance. I think this is related to me not grokking friend also.
13:10bbloomdoes friend use hierarchies?
13:11justin_smithI think so, but I could be wrong about that too for all I know
13:11stain(dear-sir-would-you-mind-checking-for-me-if-this-type-might-possibly-be-a-specialization-of-this-other-type? java.util.HashMap java.util.Map)
13:11pyrtsaI'm just happy that (core.typed'less) Clojure usually avoids the further complications the inheritance-based type system brings, which are covariance and contravariance.
13:11arrdemstain: plz no
13:11arrdemstain: y u do dis
13:12gtrakjustin_smith: I went a couple years without ever writing a multimethod, either.
13:12justin_smithbbloom: https://github.com/cemerick/friend#hierarchical-roles-ht-derive-isa-et-al
13:12justin_smithyeah, it uses heirarchies
13:12justin_smithwhich I think is related to me just not getting it
13:12bbloomheh
13:13ambrosebsI had fun with hierarchies as my first exposure to Clojure http://clojure-doc.org/articles/tutorials/growing_a_dsl_with_clojure.html
13:13gtrakjustin_smith: but multimethods use the hierarchies
13:13stainwe face the same challenge in the world of ontologies.. people mix up Classes and Instances all the time. I've seen people define ontologies with say :StianSoilandReyes rdfs:subClassOf foaf:Person, [ a owl:Restriction; owl:onProperty "foaf:name" owl:value "Stian Soiland-Reyes" ] .
13:13stainintead of just: :StianSoilandReyes a foaf:Person ; foaf:name "Stian Soiland-Reyes"
13:14stainfirst case would be good if there were many clones of me (and they all had the same name!)
13:14ambrosebswhen I wrote that, technomancy said "why doesn't this guy just admit he's writing a compiler". Cos I had no idea.
13:14bbloomambrosebs: i want predicate dispatch so bad
13:14justin_smithgtrak: yeah, I have done very little with defmulti; it could very well be that clojure heirarchies will be a a revelation that vastly improves my code when I grok the situation
13:14arrdemambrosebs: :D
13:14gtrakit hasn't been that way for me, but it's been convenient occasionally.
13:14gtrakthe 'clojure-in-action' book tries to use them extensively for domain modeling.
13:15gtrakbut I didn't really 'get it'
13:15justin_smithgtrak: cool, I may have to check that out and see what I am missing
13:15ambrosebsbbloom: I always forget what predicate dispatch is.
13:15justin_smiththe anarchists of #clojure
13:16gtrakjustin_smith: I wasn't impressed with it, I just noticed it cared a lot about the hierarchies :-)
13:16bbloomambrosebs: think multimethods, but instead of a hierarchy, methods are matched by arbitrary predicates
13:16bbloommathematica has one of the least-bad predicate dispatch systems out there, give it a try
13:16ambrosebsbbloom: yes I will
13:17bbloomusually, predicate dispatch systems are tied to the pattern systems too
13:19stainfor instance imagine you have different kinds of memberships and subscriptions to a service (e.g. Spotify). You can have :free :premium and :professional - both :premium and :professional specialize :paid Then you can have :ondemand :monthly and :yearly and create the actual plans as say [:free :monthlyPremium :yearlyPremium :monthlyProfessional :yearlyProfessional]
13:20stainbut now in your "can you play this silly song" code all over the place you don't need to code in all of those, you just check against the higher levels of the hierarchy
13:21stainso you have a hierarchy, here of subscription types, but it could be anything like your status or ranking (think Stack Overflow badges), regions and cities, languages and formats..
13:21justin_smithstain: fair enough. Though my first instinct with something like that would to make sets of keywords and test membership of the sets.
13:21justin_smithwhich for all I know is what derive based heirarchies are doing under the hood
13:21stainso quite powerful and useful to adapt without having to build big object structures like in Java, because really you don't have any further data or methods to attach to those
13:22stainyes.. that is why you tend to use the ::private keywords so that you don't inadvertedly mix in a different hierarchy
13:22arrdemfunction from a finite list to its infinite repetition... gah.
13:22justin_smith:semi/private
13:23stainbut the confusion arrises because of the innovation of using this also to check Java subclasses.. which have a split between classes and instances
13:24arrdemthere we go. clojure.core/cycle.
13:24justin_smithstain: from a rudimentary category theory perspective I envision the classes as having the heirarchy, and the checks are all based on a mapping of instance to class
13:24justin_smiththough that is likely simpler than the semantics of isa? instance? etc. etc.
13:25bbloomjustin_smith: what? you haven't upgraded your brain to homotopic spaces yet? c'mon now
13:25justin_smithbbloom: I tried but it turns out my brain is not smooth and I nearly burst a vessel
13:26arrdem(inc justin_smith)
13:26lazybot⇒ 31
13:26ptcekI am trying to use bidi (for bidirectional routing) and got stucked. I create a ring handler from the routes, my routes contain resources (handlers) and my resources need routes to get urls to other resources == circular dependency... Any suggestion how to approach this differently?
13:28sritchieptcek: I know, so annoying
13:28ptcek(circular dependency in namespaces, as I want resources and routes to be in separate namespaces)
13:28sritchieptcek: the circular dep thing is becoming a real problem
13:29arrdemif only we had a real compiler that wasn't order sensitive.. oh did I say that out loud?
13:29jcromartieshot fired!
13:29rasmustofired shot!
13:29rootexis defrecord and deftype pervasive in clojure code?
13:30jcromartierootex: I would say no
13:30justin_smitharrdem: as long as the repl has time machine so the interactive version has the same semantics as the version loaded from a file
13:30hiredmanrootex: it really depends
13:30tuft,(map Integer/parseInt ["1" "2"])
13:30clojurebot#<CompilerException java.lang.RuntimeException: Unable to find static field: parseInt in class java.lang.Integer, compiling:(NO_SOURCE_PATH:0:0)>
13:30tufthmm
13:30tuft,(Integer/parseInt "2")
13:30clojurebot2
13:31cbpWhenever you have a circular dep you can usually solve it by adding a 3rd namespace
13:31justin_smithtuft: that is not a function so it is not first class
13:31rasmusto,(map #(Integer/parseInt %) ["1" "2"])
13:31clojurebot(1 2)
13:31justin_smithtuft: you can put it in a #() though
13:31hiredmanrootex: at the single project level, some projects use them a lot, others not at all, so it is kind of a mix
13:31justin_smithlike rasmusto did
13:32jcromartierootex: yeah they tend not to be exposed at the boundaries
13:32justin_smithrootex: I use them (and reify) when I want protocols
13:32jcromartierootex: protocols on the other hand
13:34rootexok, procotols do really get used much?
13:34justin_smiththey are very useful, for example if you have code that should be specialized by an end user
13:35ptcekcbp: can you be a bit more specific?
13:35rootexjustin_smith: to expose APIs?
13:35technomancyrootex: protocols are fast, but they are not nearly as flexible as multimethods, and they introduce difficult-to-debug problems around reloading.
13:35sritchiecbp: yeah, but that can be a serious pain in the ass
13:36sritchiecpb: for example, I have a user that can use coupons, and coupons that can list all of their users
13:36sritchiecbp: sure, I can make a third namespace for user/coupon interactions,
13:36sritchiecbp: but then I have a namespace for every edge...
13:36sritchieand it just gets uncomfortable
13:36justin_smithrootex: pretty much yeah - you write your code to the protocol, and the user provides something implementing that protocol
13:37justin_smithor some lib is implemented around a protocol, and you define something implementing it, etc.
13:37rootexjustin_smith: like java interfaces?
13:37cbpptcek: if ns `a` requires ns `b` and viceversa. put the functions that cause the circular dependency in an ns `c`
13:37rootextechnomancy: what do you mean by reloading?
13:37justin_smithrootex: yeah, that's pretty much what protocols are actually
13:38justin_smithand that's the one case where I end up using defrecord or reify
13:38cbpptcek: sometimes that requires you to actually extract and write those functions
13:39cbpsritchie: Yes I guess it can be a pain although I'm not very convinced that if circular deps were allowed that the result would be well designed code
13:39justin_smithsritchie: conversations converging, if you have protocol namespaces defining coupon and user, then the implementations fleshing out those protocols can use each other via the protocols, it can work very nicely
13:39technomancyrootex: just recompiling during development.
13:39tuftjustin_smith: ok thanks
13:39sritchiejustin_smith: I ended up doing that for the data structure definitions
13:39sritchiejustin_smith: and extracted data schemas to cljx, actually
13:40tuftjustin_smith: still feels strange that it's not a function when you can call it like one
13:40justin_smithsritchie: yeah that's pretty much how I would do it
13:41justin_smithtuft: yeah, that is a little awkward, but there are lots of things like that in clojure - keywords, maps, vectors, symbols, methods - all can be called as if functions
13:41sritchietuft: it is a function, really - it just looks up the type of the first argument and picks an implementation
13:41sritchieimagine a function with a big hashmap of type -> another function
13:41rootextechnomancy: so you would avoid protocols for multimethods whenever you can?
13:42rootexDoes Joy of Clojure book touches these topics deeply, like when to use them or best cases for them? (macros, datatypes/protocols, multimethods)
13:43technomancyrootex: well, in general the need for user-defined polymorphism in clojure is very rare to begin with, but yeah, I have never written any code where the extra overhead of multimethods was an actual problem in practice.
13:43bbloomtechnomancy: you keep making that claim, yet all my programs are loaded with polymorphism...
13:44llasramditto
13:44tuftjustin_smith: seems like those examples behave like functions in this context, though. e.g.
13:44tuft,(map :hi [{:hi 2} {:hi 3}])
13:44clojurebot(2 3)
13:44llasramI do generally prefer multimethods, but I use protocols pretty freely too because of the ability to `reify` them
13:44arrdemI'm writing an AI that does some major dispatching via multimethods.. I'll let you know in a few weeks if it's too slow :P
13:44tuftjustin_smith: well, that one does anyway =)
13:44gtrakdoes pulling functions out of hash-maps count as polymorphism?
13:44bbloomarrdem: generally, the slow part of multimethods is 1) the lack of call site caching and 2) the isa mechanism
13:45tuftsritchie: makes sense for resolution of java overloads. still don't see why that couldn't be a regular function value, though -- compiler details?
13:45arrdemgtrak: I'd say so...
13:45arrdemgtrak: barely
13:45sritchietuft: yup, prob
13:45gtrakheh, it's so vague to me.
13:45bbloomarrdem: i've considered extending my dispatch-map library to support explicit call site caches. ie you'd create a "call-cache" and then it would implement IFn
13:45gtrakpolymorphism...
13:45gtraka particular arrangement of branch instructions.
13:46arrdemgtrak: it's totally unstructured polymorphism, but under the hood it's what we all rely on the hardware to do to actually _implement_ polymorphism.
13:46arrdemso...
13:46arrdemI guess it counts.
13:46arrdemarrays of function pointers FTW...
13:46gtrakin that case, I have a lot of 'if' statements, my code has so much polymorphism :-)
13:47cbppft polymorphism is just a way to reduce my 300 line functions into 20 line chunks
13:47gtrakand the bytecode implements IFn.. that's polymorphic too!
13:47gtrakI guess we're just talking about it as an intentional construct
13:49seangrovecemerick: I tried playing around with double-check in cljs last week, was a bit painful (the readme example had the wrong namespace, etc.), curious if any of the recent cljs releases have made it a bit smoother?
13:49justin_smithcbp: and if I recall you are quite fond of the 300 line version
13:50cbpjustin_smith: =P just too lazy to break it down
13:50cemerickseangrove: I haven't given the docs a buff yet, so that's no different. What were your other issues?
13:51arrdemcbp: when you write it, be a good chap and throw it in the clj-refactor lib plz
13:52rootexdo guys feel less productive on a laptop than on a desktop computer? ;)
13:52cbpall i do on my desktop is play video games so i guess not
13:52technomancyas long as I have a mechanical keyboard I'm happy
13:52justin_smithrootex: is that an emacs dig?
13:52rasmustowho doesn't have a compute farm?
13:53gtrakrootex: I overclocked my desktop to 4.4GHz, but I haven't really used it in months.
13:53cemerickseangrove: going offline now, please do file any issues you hit; the cljs releases shouldn't affect anything
13:53gtrakhaven't played games in a while either
13:53gtrakbut it has the potential to run faster than a laptop for a lower price, which saves time, that's for sure.
13:54rasmustohttp://upload.wikimedia.org/wikipedia/commons/thumb/8/8c/Beowulf.jpg/449px-Beowulf.jpg
13:54TimMcgtrak: That's pretty fast.
13:54gtrakTimMc: it's hard to notice the difference really, except when it isn't.
13:54technomancyyou can always SSH into more CPU and disk space. you can't SSH into a better keyboard and display.
13:54rasmustocat /proc/cpuinfo | grep processor | wc -l => 64
13:55gtrakSSD makes the biggest difference by far.
13:55gtrakplus just having enough memory
13:55TimMcgtrak: The last time I heard of something running that fast, it was cooked with liquid nitrogen. https://www.youtube.com/watch?v=ZF8S3Nn7mTQ
13:55TimMc*cooled ha
13:55gtrakTimMc: ha, the core i5's are pretty sweet
13:55gtrakmaybe it's at 4.2, I don't remember really, but around there.
13:56arrdemapparently multimethods are recursive datastructures... 0/5 would not pprint again
13:56TimMcThe LN2 is actually at 5 GHz.
13:56rootexjustin_smith: :)
13:56rootextechnomancy: true
13:57gtrakyea, I used to be into all that before I became a real programmer :-). Now I don't have patience for it anymore.
13:57gtrakI just do the quick wins.
13:57rootexI guess the laptop strains more the back and the neck but haven't really feel any symptons yet :)
13:58rootexgtrak: no even for setting up your linux distro? ;)
13:58gtrakrootex: yup, used to run arch, now I can't stand tweaking stuff anymore :-)
13:58rasmustoarch is ez pz
13:58gtrakit is.
13:58gtrakbut, I have more than one computer.
13:59arrdemarch iz osum
13:59rootexyeah, arch is a bit high maintenance
13:59gtrakand I'd forget to look at relnotes for breaking changes
14:00rasmustoI did have a few pacman -Syu's that broke grub, but that's all fixed now :D
14:00arrdemrasmusto: my hat's off to you... I like having an Arch that marginally works :P
14:00yedi_how would you count the occurrences of a word in a string?
14:00TimMcrasmusto: That combination of words makes me nervous.
14:00BronsaI don't bother with updating my Arch anymore
14:00gtrakyedi_: split, frequencies
14:00TimMclength of re-seq?
14:01Bronsait works fine now, I'm not going to do anything to make that change.
14:01rasmustoyou have every right to feel nervous
14:01TimMcgtrak: I think frequencies is not what you want.
14:01rasmustoarch is so much easier than gentoo prefix, though. So I feel pretty comfortable
14:01justin_smithrootex: my laptop strains my back because it is monstrously huge. But I like having 32 gigs of ram and 8 cpus so I won't complain
14:01justin_smith(plus big screen and keyboard)
14:02arrdemI'd do my inc counter thing to count members of the arch master race... but lazybot kills it every time :c
14:02yedi_gtrak: well more like the occurences of "\n" in a string like "\n\nand\n\n\n\nsome\nwords\n"
14:03gtrakyedi_: ah, first thing I'd try would be (count (filter
14:03gtrakunless there's some built-in string method that's faster.
14:04justin_smith,(get (frequencies "hello\nworld\n\n!!!\n") \newline) ; yedi_
14:04clojurebot4
14:05TimMcyedi_: So... character, not word?
14:05rasmusto(doc frequencies)
14:05clojurebot"([coll]); Returns a map from distinct items in coll to the number of times they appear."
14:06justin_smithre-matches is likely better if it is not a single char
14:06yedi_yea the \newline character, i think i was getting confused by the representation of it within a string
14:08gtrak,(count (filter (partial = \newline) "hello\nworld\n\n!!!\n"))
14:08clojurebot4
14:08justin_smith,(re-seq #"\n" "hello\nworld\n\n!!!\n") ; the more general case
14:08clojurebot("\n" "\n" "\n" "\n")
14:09justin_smith,(count (re-seq #"\n" "hello\nworld\n\n!!!\n")) ; the more general case*
14:09clojurebot4
14:09rasmusto,(count (filter #{\newline} "hello\nworld\n\n!!!\n"))
14:09clojurebot4
14:10justin_smithrasmusto: yeah that one is better than frequencies for the single character case
14:10rasmustois it essentially the same as (partial = \newline)?
14:10tuftwhat's the most straight forward way to filter nils? is it really (filter (comp not nil?) foo)?
14:11rasmusto(remove nil? foo)
14:11justin_smithrasmusto: yeah, though a little slower iirc
14:11AimHereFor 1.6, isn't (not (nil?)) now 'some?'
14:11justin_smithtuft: there is also (complement nil?)
14:12rasmusto(filter some? foo) is confusing to me
14:12justin_smithAimHere: how does that behave for false?
14:12AimHereI think the whole purpose of it is to behave differently from false and nil
14:12AimHereOtherwise (filter identity foo) would be fine
14:12justin_smith,(filter some? [false false false])
14:12clojurebot(false false false)
14:12justin_smithcool
14:12AimHere,(filter some? [false nil '()])
14:12clojurebot(false ())
14:13rasmustosome? messes me up because I associate it with some, which consumes a colleciton
14:13rasmustocollection*
14:13tuftah some? is nice
14:13tuftfits with some-> and some->>
14:13justin_smith(some? :pig)
14:13rasmusto,(some some? [true false nil])
14:13clojurebottrue
14:15danneuCan anyone recommend a simple/minimal crossplat html5 audio library?
14:16justin_smithdanneu: what do you need beyond the spec?
14:20michaniskindanneu: https://github.com/mathias/hum
14:21cbprasmusto: hehe so terse and pithy!
14:22rasmustoconcise, meaningful and sexpual
14:22bbloom,(assoc {})
14:22clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/assoc>
14:22gtrakrasmusto: my first reaction is 'ew gross'
14:22bbloombah!
14:22rasmusto,(>)
14:23clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/>>
14:23bbloom,(apply assoc {} []) ; burns me every time
14:23clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core/assoc>
14:23vermajust wondering if people here do this differently? -> (if (empty? p) "default-val" p)
14:23rasmusto,(apply < [])
14:23clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: core/<>
14:23amalloybbloom: yes, one of several functions that are dangerous to call apply on for no good reason
14:24rasmustoverma: what are you expecting p to be when its not empty?
14:24bbloomamalloy: surely somebody must have submitted a patch for this....
14:24rasmustobbloom: I think I was reading the PR about < and > yesterday
14:24bbloomrasmusto: < and > are a little more questionable
14:25rasmusto(doc <)
14:25clojurebot"([x] [x y] [x y & more]); Returns non-nil if nums are in monotonically increasing order, otherwise false."
14:25justin_smith,(< Double/NaN)
14:25clojurebottrue
14:25justin_smithlol
14:25bbloomis no-args monotonically increasing?
14:25rasmustoits undef, return a nil maybe? hmm
14:25vermarasmusto: (let [first-part (if (empty? p) "." p)] ...) basically I want a default value of "." for p if its empty
14:27amalloybbloom: as much as one arg is
14:27rasmustoverma: yea, I mean that should work. But turning an empty p into a "." seems a little roundabout. I guess it depends on what you're doing with p afterwards
14:27amalloy(ie, yes, obviously so: for all i,j, xs[i] < xs[j])
14:27amalloyer
14:27amalloyfor all i xs[i] < xs[i+1]
14:27rasmustothere exists i,j xs[i] > xs[j] would be false, yea?
14:28bbloomamalloy: yeah, i think this is like that 0^0 thing that was just going around
14:28bbloom0^0 is 1... why? b/c math.
14:28amalloybbloom: except 0^0 is undefined, isn't it?
14:28rasmustonopes
14:28gfredericksno
14:28vermarasmusto: https://gist.github.com/verma/9980396
14:28amalloywelp, guess it's been too long since math class
14:28bbloomamalloy: http://www.askamathematician.com/2010/12/q-what-does-00-zero-raised-to-the-zeroth-power-equal-why-do-mathematicians-and-high-school-teachers-disagree/
14:28gfredericks,(apply * (repeat 0 0)) ; also in clojure
14:28clojurebot1
14:28rasmustoamalloy: no, math class told you wrong
14:28amalloyrasmusto: right, because that's almost the negation of my for-all
14:28bbloomgfredericks: heh, clever
14:29gfredericksthere are some fundamental definitions that use similar concepts. I think the standard series definition of e starts with 0! = 1
14:29gfredericks,(apply * (range 1 1))
14:29clojurebot1
14:30rasmustoverma: I'd personally use (= p "") instead of (empty? p), since you're explicitly looking for strings
14:30DaReaper5Anyone familiar with clj-xpath? How do i check if a node exists?
14:31bbloomamalloy: anyway, i think we discussed this before
14:31stormeis there anything in clojure similar to the .inspect method in ruby?
14:31vermarasmusto: sounds good :)
14:31bbloomamalloy: in short, somebody needs to corner alex/rich and push these things through
14:32DaReaper5Co-worker (who is unavailable) said to do "xmlexists( '/parent_node/the_node' passing parent_node) " but I am not sure how to translate this into somthing usable
14:32gtrakstorme: what are you trying to inspect?
14:32bbloomstorme: you want prn-str
14:32bbloomstorme: alternatively, prn to just print it directly
14:33bbloomstorme: double alternatively, use clojure.core/pprint or fipp.edn/pprint
14:33tos97/7
14:34stormegtrak bbloom: I'm trying to look at a clojure.lang.IteratorSeq
14:34bbloomstorme: and what's the problem?
14:34justin_smithstorme: maybe you want clojure.repl/source ?
14:35bbloomjustin_smith: not for a java class
14:35DaReaper5Anyone familiar with clj-xpath?
14:35justin_smithoh yeah, oops
14:35gtrakhttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IteratorSeq.java
14:36gtrakif you want the actual values in the class, that's harder :-)
14:36gtrakthe object, rather, but usually I'll try 'bean' and see what happens, not relevant in this case.
14:38justin_smithgtrak: there is always clojure.reflect if you want to really get into the rabbithole
14:38gtrakyes, yes there is :-)
14:38stormeI'm using yokogiri to scrape, and I want the contents in div that I am targeting
14:38gtrakI made a type-checking new+ with clojure.reflect once :-)
14:39storme(#<HtmlDivision HtmlDivision[<div class="grid_11">]>)
14:39stormeis what I'm being returned
14:39gtrakhttps://github.com/gtrak/interop/blob/master/src/interop/core.clj#L70
14:39gtrakhaven't used it for anything, but it was fun.
14:43DaReaper5Anyone familiar with clj-xpath? How do i check if a node exists?
14:43DaReaper5(last time)
14:47vermacan a keyword have spaces??
14:47lazybotverma: What are you, crazy? Of course not!
14:47gtrakverma: yes and it shouldn't
14:47verma,(keyword "hello world")
14:47clojurebot:hello world
14:47vermadafuq :(
14:47gtrakkeywords should just round-trip through the reader at dev-time :-).
14:48gtraki guess it'll never happen
14:48verma,(= (keyword "hello world") (keyword "hello world"))
14:48clojurebottrue
14:49verma,{ (keyword "hello world" 10 }
14:49clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: }>
14:49verma,{ (keyword "hello world") 10 }
14:49clojurebot{:hello world 10}
14:50verma,((keyword "hello world") { (keyword "hello world") 10 })
14:50clojurebot10
14:50gtrak,(keyword "")
14:50clojurebot:
14:50vermaoh shit :)
14:50gtrakit's a fun game
14:50vermaso wow keywords
14:51gtrak,(= (keyword "s/b") :s/b)
14:51clojurebottrue
14:51gtrak,(= (keyword nil "s/b") :s/b)
14:51clojurebotfalse
14:51gtrak,(keyword nil "s/b")
14:51clojurebot:s/b
14:52jcromartiewat
14:52jcromartie,(namespace (keyword nil "foo/bar"))
14:52clojurebotnil
14:52jcromartieyou filthy liar
14:52verma(clojure-version)
14:52verma,(clojure-version)
14:52clojurebot"1.6.0"
14:55michaniskin,(symbol "123")
14:55clojurebot123
14:55michaniskin,(symbol "1 2 3")
14:55clojurebot1 2 3
15:04vermadoing map over a hash-map converts the hash-map into a list, is there a way to apply a function just to the keys of a map and get a map back? or do I have to do it manually?
15:05akhudekverma: manually or via a function for that that someone already wrote
15:05akhudekverma: e.g. prismatic’s plumbing library has a map-vals function, but not a map-keys
15:05technomancyit is a strange omission from clojure.core
15:06vermaTIL about plumbing, nice! :)
15:07justin_smithverma: I always end up just filling in the blanks in (into {} (fn [[k v]] .. [k' v']) {...})
15:08vermajustin_smith, nice! didn't know about into either :)
15:10justin_smith,(into {} (map (fn [[k v]] [(str k k) (* v 2)]) {"a" 0 "b" 1 "c" 2 "d" 3}))
15:10clojurebot{"dd" 6, "aa" 0, "bb" 2, "cc" 4}
15:10justin_smithI missed the call to map in my previous example btw
15:14vermajustin_smith, yeah I figured that, thanks
15:17amalloyjustin_smith: into/for is generally more readable than into/map
15:17justin_smithamalloy: yeah, fair enough
15:18vermawasn't too hard once I learnt about into: https://gist.github.com/verma/9981313
15:18vermafor, huh, never even used it ever :)
15:19justin_smith,(into {} (for [[k v] {"a" 0 "b" 1 "c" 2 "d" 3}] [(str k k) (* v 2)])) ; yeah, much clearer
15:19clojurebot{"dd" 6, "aa" 0, "bb" 2, "cc" 4}
15:19vermanice
15:23vermawith for: https://gist.github.com/verma/9981313
15:23vermathanks guys, learning something new everyday
15:25justin_smithverma: that was just the first version again
15:27vermaI added a comment to it
15:27vermaoh
15:27vermanow I did, sorry
15:55sveriHi, I am currently playing around with OM and I wonder if its possible to call a javascript function which creates its own dom (I am looking to call canvasjs like this: http://canvasjs.com/docs/charts/chart-types/html5-line-chart/) The examples I saw only draw text into the dom, so is this even possible?
15:58dnolen_sveri: you cannot construct your own DOM, however you can target the DOM React created via refs which usually good enough for many JS libs
15:59sveridnolen_: Ok, so I get that I cannot do it, but I dont understand your proposed solution I am afraid
15:59sveridnolen_: if you have an example I would happily go through it
16:01sveridnolen_: btw. OMs concepts are awesome and nice you gave that talk at the clojure conf, it convinced a friend of mine to try it out :-)
16:02se_I'm trying to stub a function from a different ns using provided in midje, but it seems I'm not able to override external functions. Any tips on this? example: (fact "foo uses bar" (foo) => "blah" (provided (bar) => "blah")) .. (defn foo [] (bar)) .. where bar is required from another ns
16:08justin_smithse_: I don't know midge, but is this something with-redefs would help with?
16:08justin_smith,(doc with-redefs)
16:08clojurebot"([bindings & body]); binding => var-symbol temp-value-expr Temporarily redefines Vars while executing the body. The temp-value-exprs will be evaluated and each resulting value will replace in parallel the root value of its Var. After the body is executed, the root values of all the Vars will be set back to their old values. These temporary changes will be visible in all threads. Useful for mockin...
16:08se_justin_smith: i believe provided uses with-redefs under the hood, but i will look into that, thanks
16:09justin_smithse_: it could be you need to require the ns with an alias and use the ns alias, or use the full ns name
16:10justin_smithotherwise it likely wants to create bar in the current ns
16:10se_justin_smith: good point, ill give that a try
16:10dnolen_sveri: this is an Om thing, it's a React thing. I don't have an example handy. But read up on React refs and look around for React examples that need to interop with mutable JS libraries and you'll see what I mean. Om approach looks almost exactly the same.
16:10dnolen_"this is not an Om thing" I mean.
16:11sveridnolen_: I think I get it, thank you very much :-)
16:11justin_smithse_: also if that is the issue, it is just more evidence that :use is evil and :require should be used instead
16:38ghadishaybanAre there any examples of inline caches in the clojurescript compiler?
16:38blake__Given a function "fn example[x y] (if (= x y) y (example x (rand-int (inc x))))", how do I make this return all the values of y instead of just the final one?
16:39blake__I know I could pass a seq along and add to it with each iteration but I think that's the long way 'round?
16:40amalloyblake__: just cons a value onto the recursive call: (cons y (example ...))
16:40amalloyand then the base case needs to be (list y) instead of just y
16:41blake__Riight. Still struggling with that one. I don't need to pass the list because I'm building it...
16:42blake__amalloy, thanks!
16:43amalloyblake__: try thinking of it this way: imagine that your example function already does what you want: it returns a list of all the values of y. now, how can you use that to return one more value? easy: you cons onto it. and then all that remains is to make the base case work: if there's only one "final" value, how do you return a list of it?
16:44blake__*nod* Yeah...the whole "call this trusting that it will eventually do what you want" thing is a trip.
16:45gunsrecursion fairy
16:45amalloyi woulc appreciate a recursion fairy
16:45blake__heh
16:46blake__You leave a pair of blank parentheses under your pillow and in the morning, it's replaced with a realized function!
16:46justin_smithcollects stack frames from under your pillow and leaves behind optimized tail calls
16:46rasmustohah
16:46rasmustotcooth fairy
16:46justin_smithouch
16:46justin_smith((juxt inc dec) rasmusto)
16:47rasmustoyeah, I deserved that
16:47llasram(inc rasmusto)
16:47lazybot⇒ 5
16:48llasramI wish to do my part to encourage such behavior :-)
16:59justin_smithor perhaps it goes around putting pillows under peoples pillows
17:03TimMcI like that.
17:04blake__(but only if they look)
17:05arrdemI've never been graced with a visit from the tcooth fairy.. I spend my weekends hunting the eater of socks T_T
17:07arrdemhttp://en.wikipedia.org/wiki/Discworld_gods#Other_personifications
17:07rasmusto,:Glingleglingleglingle
17:07clojurebot:Glingleglingleglingle
17:08justin_smithI can reliably find the Oh God of hangovers if I go looking
17:08arrdemI went looking for him once... the next day he came calling and I haven't searched again.
17:27cYmen_I was just reading this https://github.com/magomimmo/modern-cljs/blob/master/doc/tutorial-04.md
17:27cYmen_Does anybody know why one would make an ajax call to validate the user input before registering the user?
17:27cYmen_It seems like it could simply be done with a single call.
17:28justin_smithcYmen_: to avoid having to navigate back to the same page, and instead let them know they need to change something before leaving the page?
17:29justin_smithbeing taken back to refill a form because one field was bad is really annoying
17:30cYmen_uh yeah but why not just do it all in javascript?
17:30cYmen_you know make a call that tries to register and then redirect the user if it was successful
17:35coventry`Is there a way for a leiningen project to access its own project.clj map?
17:38technomancycoventry`: you need a plugin; the design of lein is that projects shouldn't know when they're running under it vs independently
17:39hyPiRioncoventry`: https://www.youtube.com/watch?v=uXebQ7RkhKs#t=1051
17:39justin_smithcoventry`: and also, based on my experiences with similar lines of thought, consider what your app should do if run from an uberjar
17:39hyPiRionIt's possible to use :injections to do that.
17:41technomancyyeah, better to add in what you actually care about (via injections or the classpath) than expose the whole map
17:43coventry`Thanks, guys. injections looks like a good way to do it, and only sending the info I need makes a lot of sense, too.
17:46aedonwhen I run lein repl, what should I expect my current directory (clojure.java.io/resource ".") to be? is there a way to set it via project.clj?
17:47coventry`Also, this is only for dev config, so it shouldn't be too hard to make it compatible with uberjarring.
17:47hyPiRionaedon: it should be the root directory
17:47justin_smithaedon: I don't think the JVM supports setting the current directory
17:47justin_smithdefinitely not portably
17:47aedonhyPiRion: root = dir with project.clj? I'm finding that it's my src/ directory instead
17:47justin_smithaedon: better to have a distinctive path in the classpath to the resource you need
17:48justin_smithaedon: io/resource does not find things relative to current dir, but relative to classpath. That's the point of io/resource
17:50aedonjustin_smith: hrrrm, interesting. ok makes sense. so the classpath from a standard project.clj standpoint is going to be :source-paths + jars required by dependencies?
17:50justin_smithplus resource-paths
17:51aedonahhh. there's what i'm missing, I assume. thanks
17:51hyPiRionaedon: yeah, it should be where the project.clj
17:51technomancythere's (System/getProperty "user.dir") but that's totally different
17:51lemonodoraedon: for those times you actually do want to access an in-project file as opposed to a resource (e.g. tests on code that is meant to access files), i found the easiest thing was to do (io/file (io/resource "test.data.foo)) or whatever
17:51lemonodorbut maybe there’s a better way
17:52lemonodor(where io=clojure.java.io)
17:52antonvhi, how do you develop with multi-file projects, where files require each other
17:53antonvwhen I open one of the files and do cider-jack-in (cider is a emacs client for nrepl)
17:53aedonThanks, all of you. God, I love what I'm reading about om and FRP and core.async, but god it's still 'exciting' to setup an environment to develop in.
17:54antonvwhen I execute (ns ... (require my.other.file) ) in one of the files which requires another, clojure throws java.io.FileNotFoundException
17:55antonvbecause my.other.file is not compiled I think
17:55antonvhow to make it aware that the file can be loaded from source in my project directory?
17:56antonvis there are way to ask leingen to load all my files?
17:56justin_smithantonv: if the ns is in the classpath there is likely some other problem
17:56antonvor setup clojure to load the sources?
17:56justin_smithrequire should cause recursive loading as far as possible
17:57antonvjustin_smith: even if the file is not compiled? I mean will it load .clj file?
17:57coventry`Does the snippet from xeqi's talk, `[(spit "resources/project.clj" ~(prn-str project))], require any further configuration to make it work? I'm getting "Unable to resolve symbol: project" from it.
17:57justin_smithalso I assume that is (:require ...) and not (require )
17:57justin_smithantonv: .clj files are found and compiled
17:57justin_smithantonv: clojure always compiles as part of loading
17:57antonvjustin_smith: right, thanks
17:58antonvI will investigate wheterh cider-jack-in includes my project source directory into classpath
17:58amalloyjustin_smith: (require) works fine in ns forms; (:require) is just conventional
17:59justin_smithantonv: make sure that if your ns has a - in it that becomes a _ in the file name, and that the directory structure follows the ns structure
17:59justin_smithamalloy: oh, I had no idea, thanks
17:59amalloyantonv: paste a real stacktrace to gist.github.com, or refheap.com or something - the problem is too vague, as you can see by justin_smith listing all the things that can ever go wrong in a namespace
18:00justin_smithamalloy: I thought I was mentioning the most common ones
18:00amalloymaybe. but my point is if he told you what's actually wrong you could just mention the actual problem
18:01justin_smithof course
18:01antonvjustin_smith: yes, thanks, my namspace is test-db, it has -
18:02justin_smithcommon culprit, changing it to _ should fix the issue
18:02justin_smith(in the file name that is)
18:03hyPiRion,(munge "test-db")
18:03clojurebot"test_db"
18:05justin_smith&(munge "☃🐈❄☺")
18:05lazybot⇒ "☃🐈❄☺"
18:06antonvjustin_smith: now everything works OK, thanks again
18:06justin_smithnp, glad I could help
18:07AmandaCIs there any minimal lein templates for a cljs project?
18:07AmandaCI mean, it’s somewhat trivial to convert a normal Clojure one, but I’d rather let a machine do that for me. :p
18:07TimMcjustin_smith: Fun fact: JVM don't care.
18:08TimMcUnicode snowman is a pefectly valid classname.
18:08justin_smithawesome to know
18:08coventry`"lein new om-starter myproject"
18:08coventry`Well, that's for om, not just for cljs.
18:08justin_smith&(munge " ; does this mean EOF is also a valid class name?
18:08lazybot⇒ ""
18:09coventry`Should work fine if you just ignore the om stuff though, I guess...
18:10AmandaCHrm, I guess I can make this project an experiment into playing with om also. :p
18:11justin_smith&(Character/isJavaIdentifierStart \)
18:11lazybot⇒ false
18:11justin_smith&(Character/isJavaIdentifierStart \☃)
18:11lazybot⇒ false
18:11coventry`The first part of dnolen's om tutorial is very good. (The rest probably is, too, I just haven't read it yet.)
18:13amalloy,(defprotocol ☃ (❄ [this]))
18:13clojurebot?
18:13amalloysilly clojurebot doesn't seem to have his character encoding right?
18:14justin_smithyeah, that's why I switch to lazybot for anything unicode related
18:14xperaamalloy: have you tried -Dfile.encoding=UTF-8
18:14amalloyhuh? i'm just talking about clojurebot. i can't change his startup parameters
18:15xperaamalloy: oh, I didn't know who controls him/her/it
18:16TimMcjustin_smith: Now, whether *Java* allows arbitrary unicode is another matter.
18:17justin_smithoh right, so that method is a different story
18:21justin_smith&(let [ 12
18:21lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
18:22justin_smithhey no fair
18:22justin_smith,(let [ 12
18:22clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
18:22justin_smithwtf, works in my repl
18:22cbpwat
18:22justin_smith,(let [ 12
18:22clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
18:22xperajustin_smith: yeah, because it waits for moer
18:22justin_smithit is eating
18:23justin_smithoh, I see - I had a ^C in there, which it seems that erc refuses to send
18:23justin_smiththough
18:24amalloythere's a ^C for you
18:25justin_smith,(let [  12
18:25clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
18:25justin_smith&(let [  12
18:25lazybotjava.lang.RuntimeException: EOF while reading, starting at line 1
18:25rasmustoclojurebot is a space case
18:25justin_smiththat one displays right, and works in my repl, but it seems IRC messes with it
18:29gunsTimMc: Java supports unicode identifiers
18:30justin_smithguns: in that case what is up with Character/isJavaIdentifierStart - it just doesn't like some unicode at the start of the identifiers?
18:30gunsjustin_smith: hmmm, let's see
18:31amalloyjustin_smith: identifiers start with [a-zA-Z0-9_$], as i recall
18:32gunsjustin_smith: it supports all Unicode _letters_
18:32amalloywell, the javadoc claims they can start with anything that's alphabetic
18:32guns,(Character/isJavaIdentifierStart \α)
18:32clojurebottrue
18:38justin_smith&((juxt count rand-nth)(filter #(Character/isJavaIdentifierStart %) (map char (range 32767))))
18:39AmandaCcoventry`: got a link for that tutorial? Google’s being a bit unhelpful. :p
18:39lazybotExecution Timed Out!
18:39justin_smithlocally that returnd [25454 \㒈]
18:39justin_smithso most of unicode in the 0 to 32767 range at least
18:40abpAmandaC: https://github.com/swannodette/om/wiki
18:41AmandaCah
18:41AmandaCthanks
18:42justin_smithfor the full range of char, 48529/65535
18:47xpera,(->> 100000 range (mapcat #(range % (+ % 5))) distinct count time)
18:47clojurebot"Elapsed time: 1082.362801 msecs"\n100004
18:48xpera,(->> 1000000 range (mapcat #(range % (+ % 5))) distinct count time)
18:48clojurebotExecution Timed Out
18:48xpera,(->> 10000 range (mapcat #(range % (+ % 5))) distinct count time)
18:48clojurebot"Elapsed time: 67.691173 msecs"\n10004
18:49xperawas curious about how distinct performs. seems roughly linear in my REPL
18:50xperaany tips on how to see how memory (or objects) are created? in the REPL, maybe? or do I have to do a full profiler?
18:50xpera^how many^ / size
18:51cbpuse something like criterium for benching
18:51xperacbp: yeah, it is great for execution time. i was wondering about memory usage.
18:51cbpjconsole
18:51xperathings like set/union
18:52justin_smithxpera: jvisualvm makes it easy to look at heap usage, and what object types are using heapspace
18:52xperacbp, justin_smith thanks
18:53justin_smithincluding snapshotting, histograms, etc. with graphing. I hear yourkit is good too but jvisualvm comes with the jdk and suffices for me
18:53justin_smithit should be in the same bin directory java is in if you have the jdk
18:54xperajustin_smith: surprisingly, it just worked to incant its name
18:54justin_smithcool deal
18:55justin_smith
18:58arrdemjustin_smith: you have way to much fun using glyphs in channel
18:58cbpi need to copy and paste them outside of emacs heheh
18:58justin_smithI can't help it, I'm easily amused by unicode
18:58justin_smithcbp: M-x describe-char
18:59amalloyjustin_smith: don't forget, 'a' is unicode too :P.
18:59arrdemI just enjoy being able to do eˣponₑnTΣ and general latex :D
19:01justin_smith⏰ gtg
19:02cbpgdammit
19:03cYmen_lein cljsbuild complains about unknown build identifier
19:03cYmen_I am pretty sure I added that identifier, what could I have done wrong?
19:04cbppaste project.clj + command? =P
19:05cYmen_ugh nevermind
19:05cYmen_my map was so messed up it is surprising one of the builds worked
19:20xeqicoventry`: you have to put that in a task or middleware or such, someplace the project gets passed to
19:21xeqicoventry`: but I think this has already been packaged into a plugin somewhere
19:21xperaany recommendations for good screencasts or walkthroughs for using the profiling tools in clojure?
19:35amalloyxpera: the profiling tools in clojure are just the java profiling tools. there's not really anything specific to clojure
19:36xperaamalloy: ok, i was just hoping to see a recommended order: start the profiler? then sample? then filter to your app's namespace. I was stumbling around.
19:37xperavarious questions like that... and how long should instrumentation take... what happens when it seems to hang? etc.
20:03yediin om: i have a list of elements somewhere in my appstate, i'm mapping an om/build call, however the component i'm mapping doesn't get a cursor like i'd expect. it just gets the actual element
20:04yediis there a way to map across a list somewhere in the app state and have (map) pass in cursors instead of the actual data?
20:05yedinot sure if that makes sense...
20:05yedii have this line: (map (partial om/build combo-view) (get-in data [:analysis]))
20:05yediand (combo-view) seems to not be getting a cursor
20:27abpyedi: I think you don't need map, just om/build-all, what's in :analysis, a collection of primitives?
20:27yediyea a collection of maps
20:28yedithat will get updated in the subcomponent
20:28abpyedi: Oh that's strange then.
20:28yediyea the type of data is ending up as: cljs.core/PersistentHashMap
20:35yediabp: same issue with om/build-all just btdubs
20:37abpyedi: Yeah, was just a tip to drop some code. Primitive js values can't be cursors, I think, can't help further.
20:37yediok thanks
20:37abpthat's why I asked about :analysis
20:40yediyea -- (map type (get-in @app-state [:analysis :analysis])) returns a list of cljs.core/PersistentHashMap
20:41yedidunno if that's expected behavior or what
20:41abpyedi: if you deref the cursor I'd think so
20:43yedioh right
20:44yediom converts your app-state atom into a cursor when used inside an om rendering loop?
20:46abpyedi: I think more like you give the atom to root and om provides you cursors into it, but they're derefable just like the atom
20:48abpyedi: and converts an initial app-state into an atom if you don't provide one
20:48yedi(print (type data)) ; (print (type (get-in data [:analysis])))
20:48yediso i put these lines at the top of the problematic component
20:48yediand got:
20:49yediom.core/MapCursor
20:49yedicljs.core/List
20:49yedii guess get-in on a cursor might not return a cursor?
20:50abpyedi: that would be strange since i guess cursors just implements Associative protocols
20:51yedithat's what i thought and is how i've been using it thus far so im also confused
20:51abpyedi: seems like map-cursor implements no get-in
20:51yedii just tried (:analysis data) and it's stil just return List as the type
20:52yedis/return/returning
20:52abpyedi: ah and it doesn't need to.. sorry I'm quite tired
20:54abpyedi: can you paste the code on refheap.com or as a gist?
20:55yedihttps://gist.github.com/yedi/9985991
20:57abpyedi: try printing in render
20:59yediprinting in render shows the same results
20:59abpyedi: then I can't see enough from that code, app-state and how it get's to there is most likely what's wrong
21:02ddellacostayedi: get-in should work fine on a cursor
21:03abpddellacosta: yeah I wrote faster then realizing that it's implemented on associative ;)
21:03ddellacostaabp: yep
21:04abpddellacosta: mostly rubber ducking here
21:05yediddellacosta: yea so i don't really understand what my issue is
21:05yedii wonder if there are any gotchas for how you construct or update app-state that might result in odd cursor issues
21:06ddellacostayedi: well, one thing I was doing wrong at one point was inserting lazy seqs.
21:07abpddellacosta: Heh, that's subtle.
21:07ddellacostaabp: yeah, I didn't pick it up until dnolen clued me in on the list
21:09yediddellacosta: interesting, i'lll look into that
21:10ddellacostayedi: and there are in fact gotchas when constructing your data structure--cursors are going to be "flat" (won't generate cursors recursively) if they are sets, for example
21:10ddellacostayedi: just a limitation of how much has been implemented so far.
21:12ddellacostayedi: your list may be the problem here, try passing in a vector instead. I don't believe you can get an IndexedCursor from a list.
21:12yediddellacosta: thanks, will see if that works
21:18abpddellacosta: I should read the source instead of just glancing into it sparingly.
21:18ddellacostaabp: believe me, I've been ducking in and out of it without really digging into it up until now
21:19ddellacostaabp: I only really read through sections when I'm absolutely stumped
21:19ddellacostaabp: but gotta do the same
21:26abpddellacosta: Well, I didn't know about the data restrictions imposed by cursors but planning on doing a project with om soon.
21:27abpSo really understanding what I get into seems appropriate.
21:28ddellacostaabp: yeah, I've realized recently you really do have to understand how it works past a certain point
21:31abpddellacosta: Yeah and react as well as writing much more things to get a feeling for architecture.
21:55`szxdoes anyone have any suggestions/ideas on how to implement tweens in clojure?
21:56`szxi'm working on a little game and i have a nested world atom, which i update-in on every frame
21:57`szxi guess i could centralize tweens, keep a list of the paths i'm tweening and update them on every frame as well
21:57`szxnot sure if that's the best way to go about it though
22:05FrozenlockI'm having some troubles with lein-droid. I get stuck at "Installing APK..." on my device. Any advice?
22:18`szxFrozenlock: i've never used lein-droid but to the best of my knowledge once it gets to that stage it's adb's territory
22:18`szxso sounds like an android issue rather than a lein-droid/clojure issue
22:21Frozenlock`szx: makes sense, I'll check for problems on the android side. Thanks
22:45FrozenlockWoohoo, success!
22:45FrozenlockRepl running on an Android device :-)
22:57amalloy`szx: the only meaning i know for the word "tween" is http://www.qwantz.com/index.php?comic=230 - others may have similar experience, in which case you can get a better answer by explaining what you really mean
22:59`szxhaha, got it
23:00`szx$google tweening
23:00lazybot[Inbetweening - Wikipedia, the free encyclopedia] http://en.wikipedia.org/wiki/Inbetweening
23:00`szxthat would probably do a better job of explaining it than me
23:01`szxi'm basically looking for a way to gradually change values over time
23:01`szxsuppose i have a circle with radius 5, i might want to interpolate that radius to 10 over 500ms
23:03`szxthe way it's usually done is your "tween manager" keeps a list of references/pointers to every variable that needs tweening. on every frame you would call update on it and it would go through the list and mutate values directly
23:04`szxobviously not how you would want to do it in clojure
23:14amalloy`szx: i don't have a lot of experience in that area, but you could have something like: (defn tween [from to, start-time duration] (fn [current-time] (...do math on all those things...))). then when you want to start tweening you create this tween function, and call it with the current time to find out what the intermediate value should be
23:15`szxamalloy: interesting
23:15amalloythere's some not-insignificant bookkeeping work to, to make these things cohabitate with ordinary values and not confuse the types
23:15amalloybut it seems like a viable approach
23:15`szxamalloy: so you're saying you would assoc this fn to the :radius etc
23:16amalloyright
23:16`szxmakes sense, and i guess my non-tweening values could be (constantly val)?
23:17`szxi guess that wouldn't take an argument
23:18`szxanyway, i'll give it a try
23:18`szxthanks