#clojure logs

2014-07-24

00:10deadghostI just updated my emacs packages
00:10deadghostand might've broken my clojure-mode
00:10deadghosthttp://i.imgur.com/Ue9xWJn.png
00:11deadghostnot sure if the orange namespaces are intentional
00:12wildnuxI tried (slurp "/proc/acpi/bbswitch")
00:12wildnuxbut it threw:
00:12wildnuxIOException Invalid argument java.io.FileInputStream.available (FileInputStream.java:-2)
00:13wildnuxis there a simple way to do 'cat' in repl?
00:16wildnuxcan anyone tell me why it does not work but this works: (slurp (java.io.FileReader. "/proc/acpi/bbswitch"))
00:18deadghostwildnux, there's (:out (clojure.java.shell/sh "cat" "/path/to/file"))
00:18wildnuxdeadghost: nice
00:19ttasteriscotry (slurp (java.io.FileInputStream. "/proc/acpi/bbswitch"))
00:28wildnuxwhat is the naming convention for clojure for two word file name? fooBar.clj, foobar.clj, foo_bar.clj or foo-bar.clj ?
00:28arrdemfoo-bar isn't valid
00:28arrdemfair warning
00:28arrdemfoo-bar as a namespace maps to foo_bar.clj
00:28arrdemcommon and poorly documented pitfall
00:29wildnuxarrdem: so how should we name multiword clojure source file?
00:29arrdemfoo/bar.clj is ideal, foo_bar if you must, alternatively choos a better foo
00:29arrdemwildnux: in Clojure multiword source files are almost unheard of
00:30deadghostthe more you know~~
00:31deadghostseriously http://i.imgur.com/Ue9xWJn.png is that orange ns stuff intentional in emacs clojure-mode?
00:31wildnuxarrdem: i need to up my naming creativity :D
00:31deadghostbecause it's bugging the hell out of me
00:31arrdemwildnux: creative naming is very important to us. please also don't have a top level package. Don't be that guy.
00:31arrdem[clj-my-lib "0.1.0"] gtfo
00:31arrdem[com.foo/shit "0.1.0"] better
00:32wildnuxarrdem: but that comes from namespace right? not the file name..
00:32arrdemalso please don't use clj-* it's a wasteland of poor naming although there is some good stuff in there
00:32arrdemwildnux: that's the lein/maven groupid not the package.
00:33arrdemwildnux: remember namespaces map to files 1:1 (if you're going to support require)
00:34wildnuxarrdem: ah! I see, i will go through some existing projects to see how they do it :)
00:34wildnuxgood night for now :) thank you
00:34arrdemnp
02:41SagiCZgood morning
02:43tufthello
02:43SagiCZ How can i design a function with state?
02:45augustlSagiCZ: not sure if there's a generic answer to that, other than "use an atom, a ref, or something else" :)
02:45SagiCZaugustl: cant expect a better answer to such a vague question.. thank you though
02:45pyrtsaBy constructing a closure if you really need one. E.g. (let [state (atom {})] (defn stateful [k v] (swap! assoc state k v)))
02:46SagiCZi read that object is a poor man's closure, but at least i understand how object works
02:47pyrtsaClosures aren't really mutable. When mutability is what you want, you'll need to use what augustl suggested as the closed-over variables of the closure.
02:48SagiCZpyrtsa: I would like to avoid refs because they are evil right? I might have to analyze my problem deeper though. Maybe it really isnt possible to solve it without states
02:49pyrtsaI tend to avoid refs because I can often manage with (a very few) atoms as the application state. But I keep them detached from the functions (and explicitly pass them as arguments).
02:50SagiCZatoms are better than refs?
02:50pyrtsaIn other words, functions with state aren't my thing.
02:50SagiCZwhat if you have creatures living in some world, interacting with it, and you need to store their history, experience, fitness.. ?
02:50pyrtsaAtoms are simpler. You'd need refs if you need to coordinate transactions of multiple values. Multiple atoms work independently from each other.
02:51SagiCZpyrtsa: coordinate as in concurrently coordinate?
02:51pyrtsaI'd have one atom that's the world's state (possibly with its history).
02:51SagiCZpyrtsa: and an atom can be anything right? map, seq, seq of maps?
02:51pyrtsaCoordinate as in do things transactionally.
02:51pyrtsaYeah, an atom may contain any single value that you can then replace transactionally.
02:52SagiCZso in the "world state atom" you would have a map of all the creatures with their data as keys?
02:52pyrtsaSomething like that, yes.
02:52SagiCZsounds reasonable.. i will read up on atoms and refs
02:53SagiCZand is there any reason why most of the functions that deal with atoms have exclamation marks in them? swap!!! ?
02:53SagiCZ(doc swap!)
02:53clojureboteval service is offline
02:54steffenUsing Compojure, I started my webserver locally with (run-server #'app {:port (Integer. 5000) :join? false}). Now it runs. But how do I restart it? how can I interrupt it?
02:54steffeni used the repl^^ btw
02:55pyrtsaSagiCZ: Because they do side effects (I think).
02:55SagiCZpyrtsa: i see
03:01justin_smithsteffen: run-server should return a handle you can use to stop said server
03:03steffenjustin_smith: thank you, I'll try that
03:13__daniel__(defn safemap [f x] (if (seq? x) (map f x) (f x))) <-- is there a core function that does this, or something more idiomatic?
03:14AimHereThat function looks like a category mistake
03:14__daniel__i need to map over edn responses, which could be a sequence or a single map
03:14__daniel__and assoc/dissoc some values etc
03:15__daniel__AimHere: please do teach
03:16AimHereSilly joke. Category mistake is an old joke about items being treated in one category when they belong in another one. Your function seems to apply both to sequences of stuff, and to the stuff itself
03:17AimHereErm, not an old joke, some old logical philosopher's idea
03:17__daniel__I've just thought that perhaps i could declare a function with multiple arity and type hints? would that be better?
03:18nobodyzzzmaybe some flatten tricks is suitable here?
03:19pyrtsaIsn't flatten very much a category mistake as well? :)
03:19AimHereYou could multimethod it, particularly if you end up with more types of stuff to handle
03:19__daniel__the seq in question will actually be a monger find-maps query result, and the non-seq a single monger entry (map)
03:19nobodyzzzpyrtsa, but no if involved =))
03:20pyrtsaI tend to need (apply concat xs) much more than (flatten xs).
03:20pyrtsanobodyzzz: There very much is an if inside flatten.
03:21nobodyzzznope, http://grimoire.arrdem.com/1.6.0/clojure.core/flatten/ =)
03:21__daniel__can someone give an example of how flatten could help here. my seq is only one level deep
03:21nobodyzzz(map f (flatten (list x)))
03:22__daniel__nobodyzzz: but wouldnt that return a list with a map in it for the non-seq case?
03:22__daniel__i want it to return the map
03:22pyrtsanobodyzzz: I stand corrected. (Though `(filter (complement sequential?) ...)` could count as one.)
03:23__daniel__so i'd still need an if to call first on it or something
03:24nobodyzzz__daniel__, my code is equivalent of your safemap function
03:24__daniel__,(map inc '(1))
03:24clojureboteval service is offline
03:25__daniel__would return (1)
03:25nobodyzzz(2)
03:25__daniel__sorry
03:25__daniel__yes
03:25__daniel__:)
03:25__daniel__my safemap would return (inc 1) i.e. 2
03:25__daniel__wouldnt it?
03:25nobodyzzzyeap, my fault
03:26AimHereWouldn't it be worse if your sequence was something like '(1 (2 3))? safemap would run f on 1, then '(2 3)' whereas the flatteny thing would run it on 1, then 2, then 3
03:27__daniel__AimHere: i think the only two cases im looking at is a sequence of maps, and a single map
03:27AimHereI'm not sure what the problem is with the original, to be honest
03:27justin_smith~flatten
03:28AimHereUsing flatten at all, is generally unidiomatic in clojure!
03:28justin_smithappears factoids are offline too
03:28justin_smithAimHere: right, because it usually indicates a design mistake
03:28justin_smith(if not creating one)
03:28__daniel__it works, just checking its not a strange way of doing it
03:29__daniel__just wondering now why monger returns a seq and not a vector of results
03:29__daniel__maybe i have to order it first, and itll put it into a vector?
03:29__daniel__are mongo queries not ordered?
03:29__daniel__so seq? may have to become vector?
03:31justin_smith__daniel__: what about coll?
03:31justin_smithoh, coll? returns true for hash-maps too
03:31__daniel__and sets, not that that is an issue
03:31__daniel__i could use coll
03:31justin_smith(complement map?)
03:31__daniel__oh wait, no
03:32__daniel__sorry :)
03:32justin_smith&(map (complement map?) [[] '() {}])
03:32lazybot⇒ (true true false)
03:33Glenjaminthe caller of this function should always know if it has a seq or a single item
03:34__daniel__Glenjamin: it does, but how would that help? two functions?
03:34Glenjaminjust implement the single item conversion
03:34Glenjaminthen if you have a seq, do (map f coll)
03:34__daniel__that means repeating the if multiple times, instead of once
03:34__daniel__this is called all over the place
03:34Glenjaminno, because you don't need the if anymore
03:35Glenjaminyour function alrready knows what it has
03:35__daniel__Glenjamin: but how do i decide whether to map or not?
03:35Glenjaminif you're calling find-maps, you know you have a seq so you need to map
03:36Glenjaminunless you have a function which returns either a collection or a single, which is very rare
03:36justin_smithGlenjamin: he mentioned monger, sometimes returning a map, sometimes a seq of maps
03:36Glenjamin(map make-thing (find-maps db coll))
03:36justin_smithGlenjamin: which makes me think monger is a mess
03:36__daniel__actually Glenjamin is right
03:37Glenjamin(make-thing (find-one db coll))
03:37__daniel__find-maps would always return a seq i think
03:37__daniel__i knew there was something stupid with this function :)
03:37__daniel__category error indeed
03:40justin_smithOK, I was going on "i need to map over edn responses, which could be a sequence or a single map"
03:41Glenjaminsounds like you need some out-of-band schema information :p
03:41__daniel__justin_smith: for some reason i completely overlooked that they are not mixed in the same calling function
03:42__daniel__different endpoints
03:42justin_smithOK
03:42Glenjaminit happens quite a lot, off-by-one on the function extraction :)
03:43__daniel__is there a way of mapping over a hashmaps values and calling a function if they are of certain type?
03:44__daniel__i have to convert all instances of ObjectId. to str before sending the response, at the moment i have two clumsy ifs
03:44__daniel__checking if two keys are present, if they are, do an assoc with str
03:45Glenjaminis the key always _id ?
03:45swiHello :) Seems like i not clear understand the clojure program typical flow and think in imperative way. Can someone in pair of words say what clojure typical workflow must be? I.e. program that get from some "input" then process data and then put results to some "output"?
03:45__daniel__Glenjamin: one is, the other is user_id
03:45Glenjaminah, right
03:46Glenjaminyou can use reduce-kv walk map key/vals without having to re-create it
03:48justin_smith&(into {} (map (fn [[k v]] [k (if (even? v) (inc v) v)]) {:a 0 :b 1 :c 2 :d 3 :e 4}))
03:48lazybot⇒ {:a 1, :c 3, :b 1, :d 3, :e 5}
03:49justin_smithswi: often there are multiple stages, and in each one you read the previous stage, and create a new one - each of these is immutible and created without modifying the previous
03:49justin_smithand each "stage" will be represented by the apropriate datastructure
03:50mpenetprismatic schema question: anyone knows how to validate a set with optional values ? ex: can be #{:a :b} or just #{:a} etc
03:50mpenetwithout listing all the combos
03:51justin_smithswi: often I think in terms of plumbing - knowing a specific transformation I need, then building the pipes to get the input structure it needs, and to connect it to the input the next stage needs
03:51__daniel__justin_smith: thanks, thats nice
03:51swijustin_smith: and what about functions? Is it common to write something like (func1 (func2(func3....))) at maximum or beat all things at posibly smaller ones and catch results in def ?
03:51instilledanybody knows how to attach sources in clojure eclipse project (counterclockwise) to dependencies? i'm running 0.26.0.STABLE001.
03:52justin_smithswi: after about three levels of nesting, you turn (f (g (h x))) into (-> x h g f)
03:52impermanswi: it's different - from functional ( http://my.safaribooksonline.com/book/programming/clojure/9781430272311/controlling-program-flow/functional_programming_techniques ) to reactive ( http://blog.paralleluniverse.co/2014/02/20/reactive/ )
03:52justin_smithbut that's a rule of thumb
03:52justin_smithswi: also, using def should not be part of your algorithm, ever
03:52justin_smithdef is for globals, let is for local bindings that may change on each call
03:53Glenjaminat the edge of your system, you need to take input and send output, but inside you can just thread values through functions
03:54justin_smithGlenjamin: I think I may use the terms input and output idiosyncratically, but I think of functions all having N inputs and 1 output (plumbing metaphor I mentioned earlier)
03:54mpenetok it was #{(s/enum :a :b :c) ...
03:54Glenjaminyeah, i was attempting to refer to system IO specifically
03:55swiimperman: thanks for link
03:55Glenjamina good clojure program only deals with external IO at the edges, i would say
03:56justin_smithGlenjamin: most of the time system IO is implicit at one end or the other of my task (whether that's ring taking requests and making them arguments, and taking return values and making them responses, or the repl) - I rarely find myself thinking about those boundary layers of my system
03:56swijustin_smith: my imperative mind refuse to take it like 'How? We must put input results to some buffer, then take from it in loop and proceed and make new data we want and place it in new buffer" :)
03:57justin_smithGlenjamin: right, i/o is state, and we know it adds sanity to localize state to one part of our code
03:57justin_smithswi: if you go through http://clojure.org/cheatsheet almost everything on that page takes input data, does some transformation, and returns new data
03:59justin_smiththe buffering / storage issues are taken care of implicitly (and have nice features like structural sharing and laziness that are already implemented at a language level)
04:00justin_smithswi: mind you, this leads to a language that is very liberal with memory usage - you'll never want to use clojure in an embedded system. But if RAM is cheap, given clojure, you get a lot of sanity at a low price.
04:01swijustin_smith: yes. i understand all of this pretty functions separated, but then begin to write some simple program and find myself out situation where in -main i have call only one function, and that function calls inside for another (or two) and that functions calls etc. Is it allways like this ? I mean that on program entry point one function, that became a big tree of func.calls ?
04:01justin_smithwell, normal code uses let for intermediate values
04:01justin_smithbut yeah, deep call trees are pretty normal in clojure
04:02justin_smith(that's part of why our stack traces are notoriously insane also)
04:02swiand let just a...em local var inside function ?
04:02mpenetswi: it's true for any language, when it's not functions its, objects/methods etc
04:02mpenetjust easier to follow when it's a simple abstraction
04:02justin_smithmpenet: but we nest function calls deeper before you hit the metal, compared to the level of object nesting in sane OO code for example
04:02hcumberdaleswi: local const :)
04:03mpenetjustin_smith: arguable, OO can often being quite deep too
04:04swimpenet: well, i mean in imperative code i often use var1 = func1(); var2 = func2(var1) and so on :)
04:04hcumberdaleI can't imagine that call hierarchies are deeper than in "real OOP"
04:04mpenetswi: you can do that in clojure
04:04justin_smithswi: (let [a (f1) b (f2 a z) c (f3 a b) ...] result)
04:05swidamn.. i was sure i missed something with this let :)
04:06__daniel__regarding the announcement of transit the other day, can anyone tell me if this is intended to replace application/edn when communicating between front and backend clj/cljs ?
04:06__daniel__i understand it's more for communicating with other languages, clojure/clojurescript being seen as more or less the same
04:07swibtw, is http://clojurekoans.com/ a good ?
04:07Glenjaminyeah, koans are pretty good, as is 4clojure
04:08swithanks a lot for answers, a little hard to turn mind from declarative way :) But it's fun
04:09swis/declarative/imperative/
04:09justin_smithswi: on the contrary, clojure is very much declarative
04:10swijustin_smith: i mean go from c/python to FP, sorry :)
04:11justin_smithright, those are not declarative languages at all
04:12swiwell, python have only a little of fp elements like map filter and lambda that i like so try to catch a true functinal language :)
04:12justin_smithhttp://en.wikipedia.org/wiki/Declarative_programming
04:13swijustin_smith: i correct myself a bit higher
04:13justin_smithyeah
04:14justin_smithsorry, I actually think the declarative language thing is interesting, and like having an excuse to call attention to it
04:16swijustin_smith: it's very interesting, even i never will be use i.e. clojure on my work, it's a good way to train brain, learn new ways in programming and just have fun :)
04:17__daniel__swi: why would you never use it at work?
04:18pro_1swi: there are many other ways to train brain
04:19swi__daniel__: i mean 'if' :) Right know as a real try of language i trying to rewrite one of my script that fetch quotes from yahoo :)
04:19swipro_1: sure, but i want somethng pratical thing too :)
04:20pro_1Try Calculus, swi
04:20__daniel__pro_1: when has calculus last come in handy for you?
04:21swi+1
04:21pro_1When I calculated when our school will reach certain population
04:22pro_1Calculus is everywhere in Economics, physics
04:23__daniel__that involved extrapolating a line/curve? solving a quadratic equation?
04:23__daniel__calculus is everywhere in economics and physics, i rarely find myself needing it in programming
04:24justin_smith__daniel__: try DSP
04:24__daniel__i suppose if you are modelling economics or game physics, then you would
04:24__daniel__justin_smith: sure, there are plenty of uses for calculus
04:25justin_smithit's a basis for a bunch of stuff related to compression, frequency domain transformations, even crypto
04:25hyPiRion__daniel__: You may need it to show certain data structure properties too, actually
04:25__daniel__it depends what you're doing though, i spend a lot of my time moving coloured boxes around a screen
04:25hyPiRionnot that many people do it, but there's certainly some strange use cases lying around
04:25pro_1I was telling ways to train brain
04:26__daniel__i studied physics at university, unfortunately very little of it has been practical
04:26engblomCalculus is very useful tool in many situations where "normal" people find a problem unsolvable unless you do a brute force. Think about dropping a loop in a program and instead just get the right answer directly.
04:26pro_1When you work as physicist, you might require programming too.
04:26__daniel__it comes down to my career choices
04:27engblomEspecially when it is about finding the optimal value satisfying some requirements calculus is very important.
04:27pro_1engblom: surely you don't mean calculus is for *normal* people
04:27mpenet"might", very often it's limited to mathematica/mathlab
04:28hyPiRionpro_1: "normal"
04:28engblomSure you could loop over all values and store them in a list and then search that list for the optimal, but that means a huge performance lost
04:28engblompro_1: I think all normal people should know some calculus.
04:29__daniel__im just saying that unless you're working in science, it may not be as practical as other things
04:30__daniel__including computer science, a lot of programmers end up moving coloured boxes around a browser like i do
04:30pro_1Daniel_ unless you are into programming job/study it isn't too practical too
04:30pro_1Heh
04:31swiapart computer science there is computer engeenering :)
04:32__daniel__anyway, calculus is definitely worth learning, mosaic theory and all that
04:32__daniel__any knowledge is good knowledge
04:33swicertainly
04:33__daniel__http://en.wikipedia.org/wiki/Mosaic_theory_(investments)
04:34pro_1When you are learning more and more interdisciplinary; you gonna come up with something good in research
04:34__daniel__indeed
04:35swihm, how can i remove old clojure that lein download ?
04:36justin_smithswi: are you concerned about disk usage?
04:36justin_smithanyway, all the jars lein gets are cached under $HOME/.m2/
04:36swijustin_smith: dont like trash :)
04:36__daniel__lein clean?
04:37justin_smithno, that just cleans your current repo of compilation artifacts
04:37__daniel__or does that do something else
04:37__daniel__i see
04:37justin_smithyou can remov ~/.m2/repository/ or some set of directories under that tree
04:38justin_smithunless you used lein install, lein will automatically download things to refill it
04:38justin_smithso it's a tradeoff of disk usage vs. network bandwidth usage
04:38swijustin_smith: i see. a lot of jars there. It's from maven afaiu ?
04:39justin_smithswi: it's from wherever people declared their deps to be from. maven central, or clojars are the two huge ones
04:39swii have unlim network, but limited hdd :) only 10g is free and a lot of music must be ripped from my new CD :)
04:39justin_smithwhen you run lein, it tells you where it is downloading from
04:39swijustin_smith: btw, where lein repos specified ? i mean defaults
04:39justin_smithlein has some default config, but it all depends on project.clj
04:40swi~/.leain/project.clj i wrote my own and there only cider
04:40justin_smithswi: I mean the project.clj in each project that gets run
04:40swiwait
04:41justin_smithdo you mean ~/.lein/profiles.clj? that is just something that modifies your project's effective project.clj :)
04:42swii mean when run lein search outside any of lein project it' load a lot of indexes, hell, allmost burn my cpu while do this :) And big ones where maven, not clojars
04:43justin_smithyeah, if you run lein outside of a project directory, the behavior will be specified by the defaults plus ~/.lein/profiles.clj
04:44swiand that defaults hidden somewhere?
04:46justin_smithhttps://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/project.clj#L190
04:46justin_smithhere, I think
04:47justin_smithoh, oops "TODO move :repositories here in 3.0"
04:47justin_smithanyway, it should be somewhere near there in the source tree
04:48hyPiRionswi: what version of Lein are you running? Latest ones have a progress bar for `lein search` (it's quite time consuming first time you run it)
04:48swijustin_smith: https://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/project.clj#L279
04:48justin_smiththere we go
04:48justin_smithmaven and clojars
04:48justin_smithas we said before
04:48swijustin_smith: find it, thanks :) src is the best docs :)
04:49swihyPiRion: Leiningen 2.4.2
04:49swihyPiRion: yes, second search was very fast :)
04:49hyPiRionright, then you should have some download/progress bar on lein search
04:49hyPiRionyay!
04:50swiyes, but it' was scary how java eat all cpu :)
04:50justin_smithswi: well, I'd blame clojure more than java there
04:51hyPiRionI'd blame the work to be done, which is not insignificant. Most of lein search is just calls to java libs.
04:52hyPiRionJust related to the fact that there are a lot of libraries out there
04:52swiat first i was shocked - it's just download damn indexes, why so heavy ?
04:53mpenetfirst run is slow
04:53mpenetit dls + builds a lucene index
04:53mpenetthen it should be fine I think
04:53swiso the build, not just download. than ok
04:54mpenetwell indexing is not slow, it's mostly the downloading I'd guess
04:55swihow the hell downloading can eat 100% of 2 cpu cores?
04:55mpenetI have no clue, didn't read the source, but my bet it's not a single file
04:55insamniacwhat is your download client?
04:56insamniaclein?
04:56hyPiRionit's a single file afaik
04:56mpenetah well :]
04:57insamniacplanned obsolescence. get moar cores.
05:13swiinsamniac: i think 4 cores is fair enough for downloading allmost everything :) thay can just use curl i.e. to download file :)
05:14justin_smithI really doubt lein would be using curl
05:14visofhelo
05:15visofhere is my code https://www.refheap.com/88544 and when i'm doing curl -X POST -H "Content-Type: application/json" -d '{"hello" "Visof"}' localhost:3000 i got nothing
05:16justin_smiththat's not valid json
05:16visofbut when i change the routes to (POST "/" {body :body} (slurp body)) i got it works
05:17visofjustin_smith: what do you mean?
05:17hyPiRionvisof: '{"hello" "Visof"}' → '{"hello": "Visof"}'
05:18justin_smithhttp://jsonlint.com/ try validating it here
05:18justin_smithnot to say that is guaranteed to be your problem, it was just the first thing I noticed
05:19visofhyPiRion: justin_smith i changed it to the valid json but with the same problem i got nothing
05:20Glenjaminvisof: do you have a ring middleware that parses json in your middlewre stack?
05:27sveriHi, how can convert a string "C" to the char representation in clojure?
05:30vijaykiran&&(first "C")
05:30lazybotjava.lang.RuntimeException: Unable to resolve symbol: & in this context
05:30vijaykiran,(first "C")
05:30clojureboteval service is offline
05:31vijaykiran##(first "C")
05:31lazybot⇒ \C
05:31vijaykiransveri: kind of a hack ^
05:31hyPiRion&(first "X")
05:31lazybot⇒ \X
05:31hyPiRion,'foo
05:32clojureboteval service is offline
05:32sverithank you
05:44visofGlenjamin: no
05:44Glenjaminthen that's your issue :)
05:45visofGlenjamin: so i need to handle the body as json when parse to the handler?
05:50visofGlenjamin: have you checked my code? https://www.refheap.com/88544
05:51augustlrefheap the slow..
05:53Glenjaminhttps://github.com/ring-clojure/ring-json
07:34__daniel__"Currently at 1.6.0; top analysts expect this to be followed by newer versions with still higher numbers" :)
07:41michaelr525hey
07:42__daniel__hey
07:56boxedyogthos: isn’t travis supposed to run on PRs?
07:56boxedthat way I would have avoided this embarrassment :P
07:57yogthosboxed: it did, but I figured maybe it was getting confused since the pr itself looked ok
07:58yogthosboxed: in any case no worries, everything is looking good now
07:58boxedoh.. hmm.. but it didn’t post in the PR?
07:59yogthosboxed: it ended up failing here https://travis-ci.org/yogthos/Selmer/builds/30740182
07:59yogthosboxed: I guess I should've put more trust in it :)
07:59boxedanyway, cool that you accepted it! I think this little trivial lib could really help make sure docs are correct
08:00boxedheh
08:00yogthosboxed: I definitely find keeping tests in docs up to date a pain, this very much helps
08:00yogthosboxed: going to be even more useful for my clj-pdf docs :)
08:00boxedI added a funny little hack to support your examples too: (def … :…) :P
08:01boxedyogthos: aha, let me give that a shot!
08:02yogthosboxed: I noticed that worked, I didn't expect it to, that's a nice touch
08:02boxedhmm.. no assertions in the clj-pdf readme though… so midje-readme can only check that the code runs
08:02boxedyea I thought so… hoped people wouldn’t get upset about it :P I think it really helps because you see that a lot in example code
08:02yogthosboxed: I find that's usually the biggest source of problems, you forget a paren or something
08:03boxedyea
08:03boxedI really should get back to my project about validating indents vs paren in clojure some day… but getting my first child next week so the chances of that are pretty slim
08:04yogthosboxed: oh well congrats :)
08:04boxedthanks :P
08:05boxedthis little two weeks vacation before has really allowed me to jump into clojure which has been fun
08:05yogthosglad to hear it, and thanks for making the lib :)
08:06boxedglad someone uses something I made :P
08:06yogthos:)
08:06boxedstill think instar is a potentially more useful lib :P
08:08yogthosyeah those kinds of transforms do come up often ;)
08:08CookedGr1phonIs there a way to output EDN which will guarantee its round-trippability?
08:09CookedGr1phonI don't want to find out at read time that somebody's outputted something which doesn't have an appropriate parallel in edn/read-string
08:11boxedCookedGr1phon: the brute force approach would be to try to read it with read-string at write time :P
08:11CookedGr1phonhrmmmmm
08:12boxedKISS and all that :P
08:12__daniel__is that even possible? what might not be round-trippable?
08:13CookedGr1phontrying the round trip is unacceptable
08:14CookedGr1phonand __daniel__, more or less any java object which sneaks in
08:14boxedCookedGr1phon: unacceptable why?
08:14CookedGr1phonperformance
08:15boxedyou’ve already tried it?
08:15CookedGr1phonthe old adage of not optimising until you've profiled doesn't really count when it comes to blindly doing more than twice the work you need to in your inner loop
08:16CookedGr1phonI'm logging every event which goes through my system and want to guarantee that it's replayable for debugging/testing in the future
08:17boxedwell you do need to walk the entire syntax in order to guarantee it’s ok.. any other thing would just be a better-than-nothing guess no?
08:18CookedGr1phonwell what I'm hoping for is some implementation of pr-str which has an option to fail if it can't serialize rather than fall back
08:18boxedah
08:18__daniel__CookedGr1phon: ofc, actually i had a similar issue yesterday with mongo ObjectId.
08:18swiAm i understand right: loop and recur allmost allways goes in pair ?
08:19CookedGr1phonswi: loops tend to have recurs, but you can recur in functions too
08:20swiCookedGr1phon: em... can you give a simple example of recur using without loop ?
08:20hyPiRionswi: any (semantically sensible) loop has at least one recur.
08:21hcumberdaleDoes anybody know if loom (graph framework for clojure) contains any kind of cycle detection?
08:22hyPiRionswi: ##(let [my-non-neg-even? (fn [n] (cond (zero? n) true (pos? n) (recur (- n 2)) (neg? n) false))] (map my-non-neg-even? [1, 4, 5, 10, 80]))
08:22lazybot⇒ (false true false true true)
08:22swii.e. https://www.refheap.com/88547 why this comes to stackoverflow ?
08:23CookedGr1phonswi: because every time you enter teh next getsum, you're adding a stack frame and never returning
08:23CookedGr1phonso instead of calling getsum from within getsum, call recur
08:24swiCookedGr1phon: then i get "Can only recur from tail position"
08:24jcromartieswi: you need to define getsum with two arities
08:24pyrtsaOr rather either (reduce + l) or (apply + l)
08:25pyrtsaswi: If you want to keep it recursive, you should guard the recursion with an (if ...) or (when ...).
08:25hyPiRionjcromartie: you can't recur on different arities, btw.
08:25jcromartienot across arities
08:25hyPiRionright
08:27jcromartieswi: https://www.refheap.com/88548
08:27jcromartieI assume this is an exercise in learning recursion and not trying to write a sum function :)
08:28boxedyogthos: well I’m finding a few problems in clj-pfd… and a bug in midje-readme so this seems worthwhile :P
08:28jcromartie(def sum (partial apply +))
08:28yogthosboxed: most excellent :)
08:28swijcromartie: right, i'm trying to get to recursion idea
08:28jcromartieyeah
08:28jcromartiewell that's a noble cause
08:28yogthosboxed: and I gotta jet here, looking forward to a pr in the near future :)
08:28swican't catch it perfectly
08:29jcromartieClojure does it a little differently because "recur" is explicit, whereas in languages like Scheme the tail call optimization is automatic
08:29boxedyogthos: shouldn’t be long, I’m at line 912 now :P
08:29yogthosboxed: awesome
08:29swijcromartie: hm, so in scheme my definition will be all right ?
08:29jcromartiewell it's still not tail position
08:30jcromartieyou need an accumulator to make it tail recursive
08:30jcromartiethat's what my 2-arity version does
08:30swijcromartie: and loop i.e. allow me to write without two arity
08:31jcromartiesure, because you just localize the accumulator to the loop
08:31swiso it' just a form of tco, one or another?
08:32jcromartieyeah, but it's your responsibility to use "recur" properly
08:33jcromartieTCO would really imply that it's automatic
08:33jcromartieI think you can say Clojure does not have TCO
08:34swijcromartie: i think i understand better now. Thank you for explanation :)
08:36hyPiRionjcromartie: Well, TCL has the tailcall command (like recur), and TCL is considered to have TCO.
08:37hyPiRionClojure certainly optimised away the tail call when you use recur – the difference is that you must explicitly say so in constrast to Scheme
08:39boxedanother way of putting it is that loop-recur is just a fancy goto :P
08:40hyPiRionheh, yeah
08:42swihm, seems like scheme only one that have auto-tco ? :)
08:51mpenetnot really, on top of my head: lua and haskell both do it
08:52hyPiRionocaml, C, C++, etc.
09:00simon_Hello. New to clojure, does anyone know of any library where (= (some-lib "http://domain.com&quot; "/a/path") (some-live "http://domain.com/&quot; "a/path") (some-lib "http://domain.com/&quot; "/a/path")) ?
09:01jcromartiestr
09:01jcromartieoh wait
09:01jcromartieI see :)
09:01swi:)
09:01jcromartiejava.net.URL
09:01simon_Cool, cheers, Ill check it out.
09:02hyPiRionoh wait wait wait
09:03Glenjaminis URL the one that makes external http calls in its hashCode method?
09:03deathknightHave there been any new guides on making a web app with oauth2 within the past two months?
09:03hyPiRionGlenjamin: yes, things may be equal or not depending of whether you have internet connectivity
09:03rweirhaha no way
09:04Glenjaminit normalises the IP address by resolving DNS iirc
09:04jcromartiedeathknight: I use OAuth2 in my Compojure web app
09:04jcromartiejava.net.URI is more general purpose
09:04deathknightjcromartie: did you follow a guide or tutorial to help you? I'd really like to wrap my head around this. I have made oauth2 calls from the command line and copying+pasting info to/from the browser
09:06jcromartieyeah just a minute, have to go do something
09:06deathknightgrazi
09:06jcromartiewould be happy to share code etc
09:06deathknight:D
09:07jcromartienow I might say: just use Friend
09:07jcromartiebut I can at least show you what I have here
09:07jcromartieI didn't use friend
09:07deathknightawesome
09:11mthvedtdeathknight: i’ve been cooking up this library, https://github.com/mthvedt/qarth
09:11mthvedttake a look and tell me if it’s useful
09:12deathknightlooking!
09:12deathknightcan this be used with facebook graph api? sorry that I'm such a noob
09:13mthvedtdeathknight: you can use it to grab oauth authorizations for graph
09:13mthvedtthere aren’t any graph-specific methods or fns
09:13deathknight:D
09:15deathknightthis looks inredible
09:16deathknightincredible*
09:16mthvedtdeathknight: thanks
09:16mthvedti’m trying to deploy the latest snapshot but something broke in my conf, give me a few minutes before trying it out :(
09:16deathknight:)
09:17deathknightI'm trying to run one of your examples, but lein complains that example is not a task
09:19mthvedtdeathknight: you’re in the same directory as qarth project.clj? and it’s not working?
09:21deathknightwoa, interesting. it worked with qarth but it didnt work for clj-facebook-graph
09:26boxedmthvedt: I like the new readme!
09:26mthvedtboxed: thanks! your feedback was very valuable
09:26boxedoh, and the thank you note at the bottom was nice too :P
09:27boxedI was a bit worried my mail sounded a bit too harsh there :P
09:27deathknightwhen trying to run an example, i get "Could not find artifact org.scribe:scribe:jar:1.3.6 in clojars (https://clojars.org/repo/)&quot;
09:30mthvedtshouldn’t lein be pulling that from maven?
09:30deathknightcouldnt get it from maven either
09:31deathknightalso, is my syntax correct here? "$ lein example friend", because that threw "Exception in thread "main" java.io.FileNotFoundException: Could not locate friend__init.class or friend.clj"
09:31mthvedtdeathknight: scribe 1.3.6 is not in releases :( fixing
09:32deathknight:D
09:32mthvedtalso, lein example qarth.examples.friend is correct. will add to the readme
09:33deathknightnice! thank you
09:33deathknightthat helps so much
09:33deathknightsorry for throwing my pre-coffee brain that's in a complete fog
09:33deathknightat you
09:34mthvedtno problem… usability is very important in a library
09:34deathknightclj-facebook-graph has an example.clj file in ~/project-directory/tests/clj-facebook-graph/example.clj...what is the lein command to run that file?
09:34deathknighti've been stumped for 3 days ~_~
09:35mthvedtprobably something along the lines of lein run -m
09:36mthvedthm, it doesn’t have a main
09:36mthvedti think it’s meant to be run from the REPL
09:37deathknightwould I do (use 'clj-facebook-graph.example) ?
09:37mthvedtprobably
09:37deathknight$ lein example qarth.examples.friend threw this: http://pastebin.com/B33YPEaF
09:40mthvedtdeathknight: you need to put some keys in test-resources/keys.edn. i think i mentinoed that in the readme
09:40deathknightshit man I apologize
09:40mthvedti didn’t really want to distribute my own oauth keys with qarth :P
09:40deathknight:D
09:44jcromartieputting OAuth keys in a JAR resource is a bad idae
09:44jcromartieidea
09:44jcromartieit should be configured from outside of whatever you deploy
09:45jcromartiei.e. via environment variables or a config file in /etc/
09:45jcromartieof course you can always put the config directory on the classpath when you run it
09:45mthvedtjcromartie: the keys are not in jar resources
09:46jcromartieoh I see
09:46jcromartietest-resources
09:46jcromartie:P
09:51deathknightstill can't load keys.edn no matter the values i fill it with
09:52deathknightooooh
09:52deathknightok, so its searching for test-resources/keys.edn
09:52deathknightbut the file that exists is test-resources/keys-example.dn :)
09:52deathknight.edn*
09:54mthvedti should probably change that to keys.edn. the minor problem is that git won’t let you ignore tracked files, risking people commiting their keys accidentally.
09:54mthvedtyou can configure ignoring tracked files on a per-clone basis
09:55swihmmm... how can i make recur call from anon-function ?
09:55Glenjaminmthvedt: if these are test fixtures, could the test runner generate them if missing?
09:55swiand anon-function does not have any argument
09:56clgvswi: with "recur" as usual
09:56justin_smithswi: how would you plan on making recur terminate if there is not argument that changes?
09:57justin_smith*is no
09:57mthvedtglenjamin: well, i think you need valid oauth keys for facebook, github, &c
09:57mthvedtwhich one would want to keep to one’s self
09:57Glenjaminoh right
09:57Glenjamini see
09:57Glenjamini assumed that this was for some sort of server :)
09:58swijustin_smith: well, i mean not using recur but make recursion function.
09:58swilazy function.. without end :)
09:58mthvedtgpg-agent has stopped working after i put in the wrong password :(
09:59jcromartieI have to say I really don't like it when libraries require me to have certain files in the filesystem or on the classpath
09:59jcromartieI'd rather be able to configure it from any source
09:59mthvedtjcromartie: these are purely for testing
09:59Glenjamini tend to use env vars: FACEBOOK_AUTH_SECRET for eg
09:59justin_smith&(take 4 (repeatedly #(+ (rand) (rand)))) ; swi - is this what you have in mind?
09:59lazybot⇒ (1.115337555838034 1.4810516083741536 0.5165425022186816 0.48732042702698797)
09:59mthvedtqarth makes no assumptions about where the files are, just the test examples load that one file
10:01swijustin_smith: yep. and seems i figure out. I need to write not #(...) but (fn somename .... ), right ? so that i can call function by it's name inside
10:02justin_smithright, but unless you are producing a lazy sequence (as repeatedly does) you will usually want some argument that controls the recursion
10:03swijustin_smith: i'm using lazy-cat there :)
10:03justin_smithwell there you go, cool
10:04justin_smithbut calling repeatedly on a function of no args is preferable to doing a manual recursion and lazy-cat with no args
10:05clgvswi: calling by name will eat up your stack which is sometimes not preferred (overflow). hence just use "recur"
10:05justin_smithclgv: not with lazy-cat
10:06clgvjustin_smith: lazy-cat? where?
10:06clgvjustin_smith: oh that last post
10:06clgvjustin_smith: well it's actually no recursion then ;)
10:07swidamn :( not working
10:08swi(fn foo [] ...) is right for empty argument function ?
10:09hyPiRionyes
10:09clgvswi: you'll probably get to your goal faster if you describe your problem and provide some input output examples
10:10hyPiRionBut calling (fn foo [] ...) only makes sense if you use global mutable state
10:10deathknightmthvedt: upon running an example, I get this: http://pastebin.com/U7cGB1Ma. it hangs there and the server doesnt start up
10:10hyPiRionusing, rather
10:10simon_Pardon my ignorance, but is there any easy way to do something like for k, v in {"a": "b", "1": "2"}.iteritems(): [k,v] (python, returns two lists ['a', 'b'] and ['1', '2'])
10:11clgvsimon_: `for` or `reduce-kv`
10:11swiclgv: well, i need to make function returning first N fibonacci numbers :) i know how defn such a functionm but i must put in as anon-function
10:12justin_smithswi: then, each iteration should take the previous two numbers as an argument
10:12clgvswi: then you need at least a parameter "n" right? ;)
10:12justin_smithswi: in fp, you really want all your state to be in the function args
10:12mthvedtdeathknight: it’s worrisome that the server doesn’t start. i’m not sure what’s up with the slf4j error, but that just has to do with logging and it won’t stop the server from starting
10:13simon_Cheers clgv
10:13deathknightis it because I switched the scribe dependency to [clj-scribe "0.3.1"]?
10:15swijustin_smith: clgv yeees... i think i understand where i was wrong :)
10:15mthvedtgpg-agent has stopped working completely after i put in the wrong passphrase too many times, because it thinks ctrl-c is an attempt to put in a passphrase
10:16mthvedti have no idea how to fix whatever happened
10:16deathknightlol
10:21clgvmthvedt: kill gpg-agent and restart it?
10:33deathknightmthvedt: just recloned the project. when running $ lein example qarth.examples.friend_multi, I get "Exception in thread "main" java.lang.Exception: Cannot find anything to run for: [..]/friend_multi"
10:35mthvedtdeathknight: try lein example qarth.examples.friend-multi
10:35mthvedtremember that clojure switches _ and -
10:36deathknightoo
10:36deathknightdanke mucho
10:37deathknightsweet jinglies it works
10:38mthvedtdeathknight: huzzah!
10:52arrdemtrptcolin: ping
10:52arrdem'mornin all btw
10:53trptcolinarrdem: sup :)
10:53trptcolinthat was fast
10:53arrdemtrptcolin: IRC driven F/OSS dev ftw
10:53swi&((fn [a] (take a ((fn f [x] (lazy-cat x (map + (rest (f x)) (f x)))) [1 1]))) 10 )
10:53lazybot⇒ (1 1 2 3 5 8 13 21 34 55)
10:53swifuuuuuh
10:53arrdemtrptcolin: TL;DR _DASH_ is a workaround for Jekyll insanity
10:54jcromartieanybody seen cgrand?
10:54jcromartiehttp://enlive.cgrand.net/syntax.html
10:54arrdemtrptcolin: Jekyll claims that /-foo/ isn't a valid dir for whatever reason, so I just went ahead and munged it.
10:54justin_smithswi: cool, now do it with memoize :)
10:55trptcolinarrdem: yeah, sorry, i’m not too worried about that part - mainly about (a) text-only (no html - which afaik may exist somewhere i don’t know about) and (b) doing search without a js runtime
10:56trptcolindumb client (`slurp`) can just do a GET
10:56arrdemtrptcolin: so... getting examples as text only is something I have zero support for ATM. There's a branch, I think it's feature/ssg or something, in which I'm experimenting with reworking Grimoire around a trivial Ring/Compojure server rather than Jekyll.
10:57trptcolingotcha. but that’s something you’re open to doing?
10:57trptcolinor having someone else do?
10:58arrdemdue to summer classes I don't have a ton of time ATM, so Grimoire is gonna languish until I no longer feel bad about neglecting my GSoC project, but yeah transitioning to a "real" server and offering a text API is something I'm open too.
10:58trptcolini don’t have the bandwidth to take it on right now but might be able to find someone to lean on around my work :)
10:58swijustin_smith: :`( memoize? i'm allmost break my head writing this.. what is memoize ?
10:58trptcolinarrdem: awesome
10:58arrdemhttp://grimoire.arrdem.com/1.6.0/clojure.core/memoize
10:59rkneufeldHey arrdem: Have you ever heard of Dash.app on Mac? I was thinking about what it might be like to generate a docset from grimoire to have on my machine.
10:59swiarrdem: justin_smith em... i can't use def or defn :)
10:59arrdemtrptcolin: the one thing I'm trying to do in that experimental branch is FS as a DB. I really really want to keep the existing "contribute via github" model because I don't like working with real databases and having to add worthwhile auth and appropriate editing pages is just gonna be a boatload of overhead.
10:59justin_smithswi: you can memoize an fn
11:00trptcolinarrdem: cool. i’ll probably wire up whichever of grimoire & clojuredocs has a text-only API first to REPLy
11:01arrdemtrptcolin: clojuredocs already has a not crap text API. that's actually how I got almost all my examples :P
11:01trptcolinoh?
11:01justin_smith&(map (memoize (fn [x] (do (println "element" x) x))) [:a :a :b :b :b :a]) swi
11:01lazybot⇒ (element :aelement :b:a :a :b :b :b :a)
11:01clgv$seen cgrand
11:01lazybotcgrand was last seen quitting 4 weeks ago.
11:01Glenjaminrkneufeld: it should be trivial to make a dash docset from grimoire
11:01arrdemtrptcolin: http://api.clojuredocs.org/
11:01Glenjamini've been meaning to try, but haven't yet
11:02arrdemrkneufeld: have you read my blog post about the "augmented documentation" strategy I'm taking with Grimoire?
11:02rkneufeldGlenjamin: no promises, but I'm going to take a look at the format some time today
11:02trptcolinoh you mean json?
11:02trptcolini mean pure text, dumped out as it will be printed
11:02rkneufeldarrdem: I've read some of your stuff, not sure if I hit that post though.
11:02swijustin_smith: eeemm.. is it fit here http://www.4clojure.com/problem/26#prob-title?
11:02Glenjaminhttp://kapeli.com/docsets#dashDocset seems to make it sound easy
11:02arrdemtrptcolin: the json API has the code examples string encoded.
11:02trptcolini know
11:02trptcolinbut dependencies
11:02arrdemah. gotcha.
11:03arrdemyeah that's something Grimoire's API is gonna try and do...
11:03arrdemboth be self-hosting bacause dogfooding and provide raw text
11:03arrdemstill trying to figure out highlighting.
11:03trptcolincool yeah, think netflix-style API where the server throws down exactly what clients need
11:04arrdemrkneufeld: if you want to try and take the Grimore generator and retarget it to build a Dash dataset I'm totally chill with that and I'll help such as I can, but right now screen scraping Grimore is more effort than it's worth and there's no API.
11:05rkneufeldarrdem: Will do.
11:05Glenjaminif i do it first i'll throw up a PR/issue saying what i did :)
11:06lduroshi, I'd like to know what's the current state of native android app development and whether it's viable to use clojure to write quality apps and whether there are production examples
11:06arrdemrkneufeld: I'm a little uncomfortable with this because I'm explicitly trying to host an uncondoned but useful superset of the official docs. see andyf's thalia. also type signatures and soforth.
11:06arrdemnot that I've had the time let alone codebase stability to start copy editing yet..
11:06ldurosthere's a page that dates back from 2011 talking about it: http://dev.clojure.org/display/design/Android+Support
11:06Glenjaminarrdem: uncomfortable with which bit?
11:07arrdemGlenjamin: being further officiated by virtue of being "the" Clojure dash documentation set :P
11:07rkneufeldarrdem: There actually is an official(?) one alreayd.
11:07Glenjaminthere's already "the" set in dash, which uses the clojure.github.io one
11:07rkneufeldBut Grimoire is far more useful to me
11:07arrdemokay. that's totally legit
11:08swijustin_smith: i will try next day :) thank a lot for help :)
11:18clgvarrdem: do you plan to write blog posts about the aot emitter while developing it?
11:19arrdemclgv: that's been on my todo list for a while... there'll definitely be a post, probably a paper and maybe a clojure/conj talk about it. right now just trying to get the damn thing working...
11:20clgvarrdem: good :) I just thought that maby experiences during development could also be informative for others ;)
11:20clgv*maybe
11:26clgvarrdem: do you know how complete tools.emitter.jvm is?
11:26arrdemclgv: tejvm will do everything except write init classes and classfiles.
11:29arrdemI have code to do the latter, the former is really a bug that needs to get fixed at some point.
11:42gill_anyone using loom?
11:42arrdemhave before, what's up?
11:42gill_how would I graph a sequence? all the examples are not in a seq
11:43arrdemwhat does that mean? are you asking if you can have an arbitrary sequence as the children of a DAG node?
11:43arrdems/DAG/DG/g
11:44gill_like (graph [1 2] [2 3] [0 1] [3 0]) is let's say the example. I want to do (graph ([1 2] [2 3]))
11:44gill_passing in a seq returns something I do not expect
11:45arrdem(graph '([1 2] [2 3])) should be (apply graph '([1 2] [2 3])) which is (graph [1 2] [2 3])
11:45gill_oh okay
11:45gill_that makes sense
11:45gill_it'd be more ideal to just have graph accept a seq, thanks :D
11:46arrdemeh... apply has no performance overhead in this case, so there's no reason to complicate the function logic and change the API to support it..
11:52ghadishaybanGot some much better invokedynamic performance last night
11:52arrdemRFC: api.grimoire.arrdem.com or grimoire.arrdem.com/api/?
11:52arrdemghadishayban: do you have official numbers yet? :P
11:53Glenjaminapi.
11:53ghadishaybanshould be able to release some stuff to play around with
11:53ghadishaybanby monday
11:53Glenjamini thought you were doing oxcart stuff :p
11:53arrdemsweet!
11:53teslanickapi.grimoire..
11:53ghadishaybanI'm avoiding claiming number
11:53ghadishaybans
11:53arrdemfair
11:54ghadishaybanbut obviously I won't release anything I believe is slower than -master
11:54ghadishaybanvars and keyword invokes are there already
11:54ghadishaybanfighting performance on proto invokes
11:55ghadishaybanit's pretty amazing, Rich put in two fast paths on the bytecode
11:55mthvedtdeathknight: have you been integrating qarth into the facebook thing you were working on?
11:56arrdemapi... it is
11:56deathknightI havent gotten to that yet mthvedt
11:56deathknightIm reviewing shell scripts for the first time >.<
11:56ghadishaybanthe obvious one is invoking the interface on a target object if it has one, and then falling back to looking up through the var+cache
11:58ghadishaybanbut there is a fastpath for objects whose class just got looked up
11:58mthvedtdeathknight: the examples work fine for you?
11:58ghadishaybani added both of those fastpaths, the MethodHandle combinators are pretty slick
11:58deathknighthavent been able to give it a real go yet mthvedt
11:58mthvedtok no
11:58mthvedtnp
11:58deathknighti'll be sure to be in contact when I do!!!
11:59deathknighti;d love to help out in any way to this awesome project
11:59mthvedtdeathknight: thanks
12:01mthvedtdebating whether to ANN...
12:01deathknightann?
12:01arrdem[ANN] my-osum-project 0.1.0
12:06mthvedti basically only had one user (two now), so i’m reluctant to release, but no other obvious way forward
12:06mthvedti’ll get a burrito then decide
12:09gzmaskhello everyone :) does any of you know a good static site generator?
12:10arrdemthere are a couple for Clojure... none that I can say I've used (yet) tho...
12:11arrdemrkneufeld: Glenjamin: et all, would user docs of other contrib libraries be something you'd like too see in the future?
12:11gzmaskI am on the verge of using a static generator or just use cljs :{
12:11technomancygzmask: static site generators don't really take advantage of the strengths of clojure
12:12gzmaskwhat's the best bet if I just want a quick way to make a github cv/blog?
12:13technomancyI have like a hundred lines of ruby for mine
12:13arrdemJekyll is good for a quick "close enough" one-off... that's what I use for my blog
12:14arrdemit works OK for minimal customization, but once you really want to do more than dated posts and a few hand coded static pages it breaks down pretty hard.
12:14technomancywhich is a great way to prevent yourself from wasting a lot of time on your blog
12:15TimMctechnomancy: Time much better spent on writing blogging software, yes.
12:16arrdemJekyll will give you syntax highlighting and some other stuff that you could otherwise waste a _lot_ of time getting working more or less out of the box. Jelly Bootstrap is also really nice and packages comments, analytics and some other good stuff as well as some reasonable community themes.
12:16gzmaskIt's very difficult for me to restrain from playing with blogging software too
12:17technomancysyntax highlighting is pretty easy if you blog from emacs
12:18technomancyM-x htmlize-region
12:18arrdemfair
12:19gzmaskis that if using Emacs might as well just write vanilla html? I am a vim user, but I tried Evil-mode and it's nice.
12:21technomancygzmask: yeah, I write in HTML with a splash of ruby to insert common headers/footers and generate listings. markdown is another popular choice
12:22gzmasksounds like you made yourself a generator ;)
12:23technomancyas long as it's under 200 lines I don't have a problem with ruby
12:25gzmaskI wish I can be as practical as you. I pretty much force myself to use clojure for everything these days. And I know this is not right.
12:26technomancywell I wrote this before Clojure was released
12:26technomancyhttp://p.hagelb.org/Rakefile.html
12:33gzmaskarrdem: is Jekyll-Bootstrap stand-alone or it requires jekyll?
12:34arrdemgzmask: it's a bunch of template files for Jekyll.
12:34Glenjaminarrdem: I think codox etc do a good job of third party libs
12:35GlenjaminAdding 3rd parties to grimoire would make them seem blessed in some way, and possibly add undesired maintenance overhead
12:35GlenjaminI think
12:35arrdemyeah. I'm willing to compete with Clojuredocs for documenting clojure/core since it's relatively inactive ATM, but I think that there's kinda no good reason to take on cross-clj.
12:40johnwalkercan you have an atom of sets in om?
12:40johnwalkeri know lists aren't allowed
12:40ambrosebsis there a consistent way to great a new instance of a deftype with the same fields as an old one?
12:40ambrosebsis there a consistent way to create a new instance of a deftype with the same fields as an old one?
12:41awwaiidjohnwalker: what do you mean lists aren't allowed?
12:41technomancyarrdem: would people set up their own grimoire instances for their own libs?
12:41clgvambrosebs: havent seen anything like it. is there a usecase for deftypes with only final field?
12:42awwaiidjohnwalker: (def x (atom '(a b c d))) works fine for me
12:42arrdemtechnomancy: https://github.com/arrdem/grimoire/issues/28
12:42johnwalkerawwaiid: in the context of om
12:42technomancyarrdem: dead link to crossclj
12:43awwaiidjohnwalker: ahhh
12:43arrdemtechnomancy: wha? where?
12:43arrdemoh. in the issue.
12:43Bronsaarrdem: it's .info
12:43arrdemBronsa: yeah just realized that.
12:43ambrosebsclgv: weighing up my options in proxying a deftype to validate it, where the fields themselves can't be immediately checked, like a function argument
12:44ambrosebsdeftypes are final, so proxying itself is out
12:44clgvoh ok
12:44arrdemfixed.
12:45clgvso you actually want a proxy with additional fields?
12:45ambrosebsI don't know if I want additional fields, I want the same fields but they should be wrapped in runtime checks
12:46ambrosebsit would be great if (instance? Foo x) was still preserved too
12:46ambrosebsbut deftype being final pretty much nullifies any chance of that, afaik
12:47clgvah ok. I thought that was a concret use case but you are probably working on that for core.typed?
12:47ambrosebsI really do want a proxy tho, since I also want to wrap its methods in checks :(
12:47ambrosebsright, the use case is using untyped code from typed code, and preserving type assumptions at runtime
12:48ambrosebsand then blaming the correct party when hell breaks loose
12:48ambrosebsTyped Racket basically redefines the struct I think
12:49clgvhumm well, it would be easy to accomplish with arbitrary class generation. we need that macro ;)
12:50clgvI have some use cases for that as well ;)
12:50ambrosebswhat do you mean?
12:51clgvI mean a macro like reify, deftype but which does allow you to create arbitray java classes (super classes if needed, interfaces, fields ...)
12:52clgvyour wrapper would be easily implemented with that
12:53ambrosebsgenclass?
12:53ambrosebsone issue is of course, if I redefine the deftype, all current instances are now outdated.
12:54clgvI thought you just define a wrapper?
12:54clgvwell another option would be the aspect oriented approach, where they modify the bytecode of the class
12:55clgve.g. what they do in AspectJ
12:55ambrosebsI want a wrapper with the same name and attributes.
12:55ambrosebseffectively
12:56ambrosebsyes perhaps that's my next bet
12:56clgvambrosebs: should be possible with the asm lib thats included in clojure
12:57ambrosebsoh? not familiar with either
12:57arrdemobjectweb's asm lib is how clojure does bytecode generation...
12:57ambrosebsyes I know that much, not any more tho
12:57ambrosebsthanks for the pointer
12:59ambrosebsI'm not sure what I want to actually achieve now..
13:00ambrosebsI guess I want to proxy a deftype, with the ability to override methods, and preserve (instance? Foo x)
13:01ambrosebsa subclass I guess
13:02clgvambrosebs: having to learn the asm lib will be a significant effort, I guess
13:02ambrosebsI'm sure
13:03ambrosebsbut I already agreed to give a conference talk on this..
13:03ambrosebsshit
13:03ambrosebs;)
13:03ambrosebsone way to motivate
13:03clgvyeah well, I know how that feels ;)
13:04clgvbest conferences are those that demand full papers since you can be sure you have the finished content when the slides need to be created ;)
13:07ambrosebsI'm planning to write a paper the conference after this, does that count?
13:07ambrosebsno time, should look at asm
13:09clgvI guess not ;)
13:11vermawhen I specify externs in cljsbuild configs the paths are relative to my project's root right?
13:18vermaoh, its a compiler parameter :P
13:25ghadishaybanwoo last known bug squashed on invokedynamic protocol calls...
13:26ghadishaybanI can successfully run & compile our largest app at work on invokedynamic
13:28clgvghadishayban: github link?
13:28clgvghadishayban: you mean using invokedynamic for clojure variables?
13:30ambrosebsghadishayban: congrats!
13:30tbaldridgenice!
13:30Bronsaghadishayban: sounds exciting
13:56SagiCZ1(doc def)
13:56clojureboteval service is offline
13:57arrdemhttp://grimoire.arrdem.com/1.6.0/clojure.repl/doc
13:58dmillettTry tracking accumulated file/line commits (churn) from the command line for a git repository? See 'git-commit-churn' (https://github.com/dmillett/bash-help)
14:01hiredmanI always forget clojurebot routes services through an openvpn that is vesa mounted on the back of one of my monitors
14:07dbaschafter a few months of nothing but clojure, coding in ruby feels like typing with my knuckles
14:07johnwalkerlol
14:09johnwalkerarrdem: i saw that grimoire got integrated into cider
14:09johnwalkeris there any way to get the examples in there also?
14:09arrdemjohnwalker: https://github.com/arrdem/grimoire/issues/53
14:09johnwalkernniiiiiiice
14:10johnwalker(inc arrdem)
14:10lazybot⇒ 34
14:22arrdemtrptcolin: are you trying to grab a header delimited, terminal appropriate string here?
14:23trptcolinyep
14:23arrdemherm. yeah as specified there's no way to do that in a single get.
14:24arrdem/$VERSION/$NAMESPACE/$SYMBOL/full or maybe /$VERSION/$NAMESPACE/$SYMBOL/index.txt
14:24trptcolinright i couldn’t tell if e.g. `/$VERSION/$NAMESPACE/$SYMBOL/` would use “Accept: text/plain” or if they’d actually be different URLs
14:25arrdemodds are I won't be arsed to build something sufficiently bright to check headers :P
14:25arrdemI think a different file is probably for the best...
14:25arrdemit'll just be a server-side concatination of all the other API resources anyway.
14:25trptcolini think the accept header idea is the “right” way to do it but i don’t personally care as long as there’s a way to (slurp URL_HERE) and get the info
14:26arrdemhum...
14:26arrdemlemme see if there's something I can do to nginx such that I can support the text/plain using only static files. If so I'll do that, otherwise I'll do a standalone file.
14:28trptcolinbbloom: really, pencils you have to sharpen?
14:29bbloomtrptcolin: many good ideas have been had during pencil sharping
14:29trptcolinalthough maybe that’s the trick to why CS was so awesome in the 60s & 70s
14:29trptcolin:)
14:29arrdemtrptcolin: looks like if you hit /foo/ with Type: text/plain, it'll hit index.txt rather than index.html.
14:30arrdemso yeah I'll just add that Type: text/plain shall work on the normal symbol root path, and if you ask for text/plain you'll get it.
14:52Ro_hello, is there an open source datomic clone?
14:52TimMcNo.
14:53TimMcI mean, there might be some other datalog type stuff out there, but you're not going to find Datomic-the-free-version.
14:54technomancyyou could write one
14:55Ro_:)
14:57Ro_technomancy, I am thinking about it :)
14:57technomancycool
14:58Ro_The only thing I need to know, what about patents, Do they have it on Datomic?
14:58bbloomRo_: shhh
14:58bbloomthe last thing you want to do is inquire about patents
14:59bbloomknowingly violating patents is worse
14:59mdrogalisLicensing battle: Part 2
14:59mdrogalistbaldridge: Please step into the ring. Ding Ding!
14:59technomancyRo_: rule one of software: it violates patents.
14:59technomancythere are no exceptions.
14:59tbaldridgemdrogalis: not going close to this discussion ;-)
15:00Ro_So you are saying it is kind of OK?
15:00justin_smithhttps://www.youtube.com/watch?v=AvDvTnTGjgQ
15:00mdrogalistbaldridge: Smart man :P
15:01technomancyhey, at least this time it's not idle complaining
15:01justin_smithm'kendiepoppetycorn
15:01tbaldridge(inc technomancy)
15:01lazybot⇒ 125
15:01tbaldridgeI'm interested in seeing where it would go just from a programmer standpoint.
15:02tbaldridgeI mean it only took Rich and Co about 2 years to write Datomic...
15:02pmonks(inc justin_smith) ; for swedish chef awesomesauce
15:02lazybot⇒ 52
15:02bbloomRo_: http://patents.stackexchange.com/questions/475/does-looking-at-prior-art-searches-pose-a-risk-for-engineers
15:02arrdem(inc justin_smith) bork bork bork bork
15:03arrdem(inc justin_smith) ; bork bork bork
15:03lazybot⇒ 53
15:03bbloomweee treble damages
15:03dbasch(dec patents)
15:03lazybot⇒ -2
15:03tbaldridgedbasch: you can't do that, dec is patented
15:04dbasch(inc sue-me)
15:04lazybot⇒ 1
15:04tbaldridgeanyone else remember this gem? https://www.techdirt.com/articles/20110102/15363912492/ibm-files-patent-patent-trolling-it-may-be-too-late.shtml
15:04justin_smithtechnomancy: "Third, sometimes parties are sued for inducing infringement -- i.e., encouraging someone else to infringe." uhoh
15:05dbaschsome country should sue the US for infringing their patent on patent laws
15:05arrdem"Cognitect vs. #Cloure et. all"
15:05justin_smithheh
15:06Ro_P.S. I am not from US ;)
15:07technomancyRo_: lucky you!
15:07dbaschRo_: oh, then you’re never going to get sued by a US company. US companies are extremely mindful of borders.
15:07arrdemlol
15:07Ro_So I am kind of "safe" :D
15:08aperiodicand there are certainly no trade agreements extending the domain of the US's patent & IP systems
15:08turbofailcareful, sarcasm is patented now too
15:08bbloomdbasch: maybe they don't have sarcasm in his country
15:09Ro_I know there was such a talk, but could you tell me once more: why Rich Hickey did not enforce Datomic opensource?
15:09TimMcWhat if their country has defined "patents" as "a type of fish"? That should protect them.
15:09dbaschbbloom: I just exported it then :)
15:10technomancyLet's weaponize sarcasm.
15:10SagiCZ1justin_smith: hey there
15:10justin_smithSagiCZ1: https://38.media.tumblr.com/cc047915ad3d725e2d96e09cc1f5433f/tumblr_n83ikzjgiV1qak4ico1_400.gif
15:10TimMcdbasch: *gasp* You're in contravention of the Export Administration Regulations!
15:10bbloomtechnomancy: https://www.youtube.com/watch?v=hsW9DO1k5-s
15:10dbaschTimMc: no, it’s only 32-bit sarcasm. I wouldn’t do 128-bit on irc.
15:10SagiCZ1justin_smith: ouch
15:10TimMcah, phew
15:10arrdemdbasch: dude utf8 supports multiword sarcasm
15:11Ro_Every time I come to Clojure channel I am glad that the Clojure community is so nice :)
15:11tbaldridgeRo_: I'm trying to find you a point in a talk where Rich answers that
15:11Ro_ok, thx
15:12arrdem#clojure is pretty good about grousing politely
15:12justin_smitharrdem: you take that back, jackass
15:12arrdem(dec justin_smith)
15:12lazybot⇒ 52
15:12arrdem(dec so)
15:12lazybot⇒ -32
15:13SagiCZ1justin_smith: I am originally java programmer and I have a problem expressing myself in functional language.. how do you go about preserving states when you need to? Example: Let's have a group of creatures who interact with their environment and save some data about it, or just save the history of their actions right? How would I save that and access? For now, each creature is represented by one function object i guess.. Can I avoid
15:13tbaldridgeRo_: http://youtu.be/FOQVWdG5e2s?t=38m38s
15:13technomancyone of these days so is going to change his nick and we're not going to notice; we'll just keep on dec-ing him out of tradition.
15:13technomancyhttp://p.hagelb.org/tradition.jpg
15:14justin_smithSagiCZ1: a common pattern is to make a function that takes "state" as its argument, then returns an updated version of the state. The hard part is not preserving the state (it is immutible after all), it is about propagating the updated one.
15:15SagiCZ1justin_smith: yeah, i guess what i meant by "preserving" should be called "updating" .. so passing it in and out.. interesting
15:15justin_smithSagiCZ1: also, pragmatically we have things like atoms and ref with safe update behaviors
15:16SagiCZ1justin_smith: and what is the communities stance on them? are they necessary evil for corner cases or normal part of everyday use?
15:16justin_smithbut that is needed only rarely (maybe in one place in a huge lib), mostly you can use function arguments / return values to propagate
15:16Ro_technomancy: Rich does answer the question :D
15:16SagiCZ1justin_smith: so that answers that
15:16justin_smithI am sure other developers here will weigh in on how often they use an atom or agent or whatever to coordinate state
15:16SagiCZ1feel free to chip in guys
15:17TimMcarrdem: So, you really find it so bad? For me it's only so-so.
15:17arrdemhar har har
15:17tbaldridgeatom almost all the time, I haven't used agents since core.async came out
15:17TimMc/nick har
15:17justin_smithSagiCZ1: another thing to consider is that if in some library you define an atom that holds library state, you are limiting the user to only one state for the library in their entire app - if it is an argument that is propagated, they can use the library in different places without interference
15:18tbaldridgebut yeah, arguments over atoms
15:18brunovSagiCZ1: for an illustration of what justin_smith just said, take a look at how Clara handles its session state in an immutable manner https://github.com/rbrush/clara-rules
15:18technomancyRo_: is it because his efforts to fund-raise through donations went badly?
15:18TimMcSagiCZ1: refs are amazing but basically no one uses them. :-)
15:18brunoveach function accepts a state object as first argument and returns a modified version
15:18TimMcThey're a gateway drug.
15:20arrdemis there a writeup somewhere of compojure's route formatting? I'm not seeing one right off.
15:20SagiCZ1justin_smith: remember how i talked about "creatures" lets say I each of them runs some calculations and I want each "creature" to have its own thread. Is it still achievable without refs, or I need them to collect the "creatures" data? I hope you its not too abstract.
15:20Ro_technomancy: Nope.
15:20justin_smithSagiCZ1: this sounds very similar to how agents work
15:21Ro_technomancy: Rich "I have a kind in college"
15:21justin_smithSagiCZ1: with an agent, you start it out with a value, then you send it functions that update that value
15:21Ro_:)
15:21SagiCZ1justin_smith: "agent" would be even more precise name for my creatures, because they would be trading agents.. so agents are a thing in clojure
15:22justin_smithSagiCZ1: but there are multiple ways to do this. Each creature could be a core.async go block that reads perterbations from a channel, and responds by sending messages to other creatures via channels
15:22TimMcSagiCZ1: Careful, "agent" is an overloaded word.
15:22justin_smithSagiCZ1: or all the creatures could be in a map, with another map describing their relationships or interactions
15:22SagiCZ1TimMc: Yes I realize that
15:22Ro_Do you know any papers on Datomic which could help me to clone the "stuff"?
15:23SagiCZ1justin_smith: one thing someone recommended earlier was to hold a map with the creatures as keys and their data as values and update that map somehow (it would be ref map)
15:23justin_smithSagiCZ1: with the map representation, you would have a state updater that walks through and propagates one "tick" of updates for all creatures
15:23justin_smithwould not have to be a ref map
15:23justin_smithit could be a function that takes the creature map as input, and returns an updated map
15:24katratxoRo_: http://tonsky.me/blog/unofficial-guide-to-datomic-internals/
15:24SagiCZ1justin_smith: and can multiple alter the same map at once? (if they are in different threads)
15:24justin_smiththe storage could be in a ref, could just be a question of passing the map back into the function again, could be persisted to a db or edn file...
15:24Ro_ty
15:25justin_smithSagiCZ1: the map is immutible, if you want parallel processing you could split up the processing per key in the updater function, or make it a reference type (atom, ref, datomic data, whatever) and then coordinate the updates
15:25justin_smitheven with a mutable reference type, the map inside is immutible, because maps just are
15:26SagiCZ1justin_smith: I see.. well I won't pretend to know exactly how to do that, but I am glad to hear that its very possible. I will learn more about clojure first though.
15:28bbloom,((fn [x] {:pre (pos? x)} x) -5) ; ouch
15:28clojurebot-5
15:28justin_smithSagiCZ1: one of Rich Hickey's clojure talks is about simulating a colony of ants via parallel updates
15:28bbloom,((fn [x] {:pre [(pos? x)]} x) -5)
15:28clojurebot#<AssertionError java.lang.AssertionError: Assert failed: (pos? x)>
15:28SagiCZ1justin_smith: yeah i was impressed by that
15:28bbloomi guess both pos? and x are true....
15:29justin_smithbbloom: yeah, that hit me a few times before I knew what I was doing
15:29SagiCZ1justin_smith: easy concurrency is why I chose clojure for my project over java
15:29schmeeheyo, I have a quick question about sockets
15:29schmeeI connect to a server and then spawn a thread with that socket to listens to messages from the server
15:29justin_smithbbloom: what would the patch do? complain if the pre arg is not a callable?
15:30PigDudemmm i'm getting chicken korma from the indian place by me while i work on some korma stuff
15:30schmeebut calling `read` on the reader just keeps spitting out nil, is there any way to make it block until it receives a message?
15:30bbloomjustin_smith: require the conditions be a vector
15:30justin_smithbbloom: cool
15:33hiredmanschmee: read on a Reader cannot return nil
15:33hiredmanhttp://docs.oracle.com/javase/7/docs/api/java/io/Reader.html#read%28%29
15:35hiredmanunless by read you mean clojure.core/read which works on pushbackreaders, and can return nil, and certainly does block
15:37schmeehiredman: strange... here's the function in question: https://gist.github.com/schmee/522e29e355428a627fe2
15:38hiredmanI would expect that to throw an exception
15:39schmeeI spawn the thread with `(doto (Thread. #(listen sock)) (.start))
15:39schmee`
15:39justin_smithyeah, read on an io/reader always fails when I do it (it is only thanks to my stupidity that I have tried it so often)
15:39hyPiRionschmee: you're using read, you want .read.
15:39hiredman,(doc read)
15:39clojurebot"([] [stream] [stream eof-error? eof-value] [stream eof-error? eof-value recursive?]); Reads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. stream defaults to the current value of *in*. Note that read can execute code (controlled by *read-eval*), and as such should be used only with trusted sources. For data structure interop use clojure.edn/read"
15:40hiredman^- takes a pushbackreader and reads a clojure form
15:40hiredmanschmee: depending on your setup stacktraces maybe being printed to random places where you might not be looking
15:41schmeehiredman: can I wrap it in a try catch or something?
15:41hiredmansure
15:42hiredmanconsider using a future instead of manually starting a thread
15:42bbloomjustin_smith: http://dev.clojure.org/jira/browse/CLJ-1473
15:43schmeehiredman: I will, I was going to ask here when I'm finished with code if it can be made more "clojure-y" :)
15:44schmeethanks everyone for the suggestions, I'll try them out!
15:44justin_smithbbloom: nice
15:47justin_smithschmee: regarding idiomatic clojure, instead of while / checking an atom, you could loop/recur with a check that looks for your termination condition
15:47justin_smithsince the atom is bound in that let block, you clearly are not using it to detect a condition coming from another thread
15:49schmeeI'll do that, thanks. I've just randomly copypasted the conditions in a lot of places since I don't need them atm, so it probably doesn't work the way it should :P
15:49pandeiroanyone have experience testing reactjs apps using clj-webdriver? i am new to selenium and not sure if DOM tests operate against a page's initial HTML or the actual DOM environment in memory
15:50gzmaskis there any interesting clojurescript eco-system news website out there?
15:50dbaschjustin_smith schmee: in that snippet there is no termination condition, the atom is completely unnecessary
15:51dbaschthe “running” binding, for that matter
15:51justin_smithdbasch: indeed, but I assumed in some future version there would be a termination condition
15:51schmeeyep
15:52justin_smithand I think conditional recur is more idiomatic than an atom as sentinel
15:52dbaschjustin_smith: of course
15:53mmitchel_is there a way to convert a record into a plain hash-map?
15:54hiredman(into {} ...)
15:54mmitchel_ahh perfect
15:54mmitchel_thanks hiredman
15:56mkrlearnerQuoting doesn't work for ^ symbol. Any specific reason for that?
15:56mkrlearneruser> '(1 2 3 a b c ^) RuntimeException Unmatched delimiter: ) clojure.lang.Util.runtimeException (Util.java:221)
15:56justin_smith^ is read time
15:57mkrlearnerI want a list of mathematical symbols like +, -, *, /, ^ (for power), and I am not able to make one :(
15:58tbaldridgemkrlearner: ^ is a special symbol that attaches metadata
15:58tbaldridge, (meta ^{:doc "foo"} {})
15:58clojurebot{:doc "foo"}
15:59justin_smith,(symbol "^") it's possible to put it in a symbol, but it's hacky and not very usable
15:59clojurebot^
15:59ZekkaHave you considered **?
15:59mkrlearnerI am changing it to ** right now.
15:59tbaldridgeor pow
16:00SagiCZ1tbaldridge: what are metadata for?
16:00tbaldridgeSagiCZ1: lots of stuff, for example line numbers and the like
16:00tbaldridge,(meta '(+ 1 2))
16:00clojurebotnil
16:00mkrlearnerYeah I get it. I thought quote would take lower precedence than metadata.
16:00tbaldridgeor not in that example
16:01tbaldridge,(meta #'conj)
16:01clojurebot{:ns #<Namespace clojure.core>, :name conj, :added "1.0", :file "clojure/core.clj", :static true, ...}
16:01tbaldridge,(keys (meta #'conj))
16:01clojurebot(:ns :name :added :file :static ...)
16:01justin_smithSagiCZ1: we use it to attach documentation to vars, to differentiate macros from functions, to mark the type as a guide to the compiler... all sorts of things
16:01tbaldridgebleh, nevermind, but lots of stuff in there
16:02mkrlearnermetadata is the only way to add additional info to a data-structure without compromising its equality semantics.
16:04SagiCZ1justin_smith: thanks :)
16:04SagiCZ1btw.. i wanted to register my nick to freenode.. it for some reason added "1" to it.. why?
16:09arrdemanyone care to recommend mustache or some other HTML string templating engine?
16:10arrdemtbaldridge: quiet you
16:10schmeeany way to reset the REPL without restarting it? to get rid of all the state
16:10tbaldridgearrdem: just start a emacs/vim war while your at it...
16:10tbaldridge:-D
16:10technomancywasn't templating the original bitemyapp rant topic before he learned haskell?
16:10TimMctbaldridge: Nonsense, it's ed vs. nano.
16:10arrdemtechnomancy: yep, and it was the last rant I got from him before we stopped hanging out.
16:11TimMctechnomancy: I used to rant about it too. Then I finally figured out how to use enlive.
16:11technomancyI've only used hiccup, and I love it, but I understand there are situations for which it's inappropriate
16:12arrdemI've just already got a boatload of liquid template files which are near mustache and I'd rather not retype all of them in hiccup which is otherwise my Clojure HTML preference.
16:12hyPiRiontechnomancy: I'm pretty sure he learned Haskell before that
16:12technomancywell, before haskell destroyed him anyway
16:12arrdemwell there's already a liquid implementation for Clojure...
16:12augustlis there a way to do int r; while ((r = doARead()) != 1) { thing.update(bfr, 0, r) } in clojure?
16:16hyPiRionaugustl: (loop [r (doARead)] (when (not= 1 r) (. thing (update bfr 0 r)) (recur (doARead)))) ?
16:16augustlit's a bit annoying to have to repeat the doARead :)
16:18hyPiRion(doseq [r (take-while (comp not neg?) (repeatedly #(doARead)))] (. thing (update bfr 0 r)))
16:18TimMcheh
16:20teslanickI wonder...
16:20teslanick,(apropos #".*")
16:20clojurebot(primitives-classnames +' decimal? restart-agent sort-by ...)
16:21teslanickAwesome! Just discovered apropos, didn't think clojurebot would let me use it for some reason.
16:26technomancythank goodness for *print-length*
16:27justin_smithteslanick: there is also (all-ns) and (ns-publics 'some-ns)
16:40arrdemtbaldridge: Grimoire had better count against my GSoC work :P
16:54vermaare the clojure stickers here [1] opaque? [1] http://clojure.org/swag
16:55vermaanyone have them?
16:55hiredmanthey are
16:57hiredman(assuming they are the same stickers they hand out at the conj)
16:57vermaaw man, I want the mac's apple light to go through the sticker, like translucent would be awesome
16:57technomancylein stickers are translucent
16:57technomancyjust sayin'
16:58vermatechnomancy, are there available somewhere? or where did you get them made?
16:59vermaoh accepted patch gets you a sticker :)
16:59technomancyverma: if you make a contribution to lein that's accepted, you can get a sticker.
16:59technomancyI forgot where I got them
16:59justin_smithtechnomancy: I know you don't mean it that way, but that just sounds so gradeschool condescending
17:00technomancyhah
17:00justin_smith"oh, a patch? for me? have a sticker" headpat
17:00llasramWell, maybe if the sticker were automatic
17:00hyPiRionjustin_smith: Would a golden star be better?
17:00augustlhyPiRion: ah, nice one (almost 1 hour ago)
17:00llasramBut since you then have to ask for the sticker... It's more like "Here's patch. So.... sticker? Eh?"
17:00ghadishaybanI love this UnwarrantedOptimismException http://hg.openjdk.java.net/jdk9/jdk9/nashorn/file/49d7a2a66ae6/src/jdk/nashorn/internal/runtime/UnwarrantedOptimismException.java
17:01technomancyllasram: so... require a mailing address before accepting any patches? =) where have I heard that before?
17:01llasramlol
17:02vermaI can get clojure stickers made right, no problems with that, I would think
17:02hiredmanthis channel is not really the place to ask
17:03TimMcverma: There is probably a trademark or copyright on that logo.
17:03hiredmanthere is
17:03vermaTimMc, hmmm
17:03llasramtradecopymarkright
17:03technomancypossibly even a patent
17:03arrdemthat Grimoire and a bunch of other Clojure resources infringe on..
17:05hiredmanбизнес methods for logo design
17:06TimMctechnomancy: "A method for combining yin-yang and lambda symbols."
17:14augustlI can't seem to figure out how to call http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#readAttributes%28java.nio.file.Path,%20java.lang.Class,%20java.nio.file.LinkOption...%29
17:15augustl(Files/readAttributes (.toPath pic-file) BasicFileAttributes) fails with java.lang.IllegalArgumentException: No matching method: readAttributes
17:15hiredman… means array
17:15Farewhat's the simplest way to test whether an object is a Java byte array [B ?
17:16augustlhiredman: so I need to pass an empty array?§
17:16hiredmanno
17:16hiredmanyes
17:16augustl:)
17:16hiredmanis what I meant
17:16hiredman:)
17:16trptcolinFare: (= (Class/forName "[B") …)
17:17FareI can (= (type x) (type (byte-array []))) but that's somewhat ugly
17:17Faretrptcolin, thanks
17:17Faresame thing, I suppose
17:17Fareyour being slightly cleaner
17:17justin_smith,(= "[B" (.getName (class (byte-array (map byte [0 1 2])))))
17:17clojurebottrue
17:18Farejustin_smith, I think that's slightly worse, actually
17:18augustlhiredman: (Files/readAttributes (.toPath pic-file) BasicFileAttributes (make-array LinkOption 0)) works wonders :)
17:19dbaschFare: a ref? that’s ugliest
17:19FareBTW, what does declare do? Apparently not enough for me, possibly because I'm passing the forward-referenced function as parameter while buidling a data structure
17:19Fare(the data structure being a monadic parser)
17:20Farein the end, I ended up coding my own variant of declare, that binds the ref to a function that consults the ref at a later time to the the actual value
17:21mthvedtFare: declare makes an unbound var
17:22FareOK
17:22mthvedtnot quite understanding why one would need an “earlier” late binding
17:23Fare(declare-forward f) (def g (wrap f)) (def f (wrap-differently g))
17:23dbaschFare: do you really mean ref or do you mean var?
17:23Faredbasch: I'm not sure
17:23dbaschFare: if you’re not sure, you probably mean var
17:23Fareprobably mean var
17:24Fareyes, I use var-get
17:24Fare(defmacro def-forward [& names] `(do ~@(map #(do `(defn ~% [~'σ] ((var-get #'~%) ~'σ))) names)))
17:24Fare(they are all functions of one argument)
17:25Fare(monadic parsers)
17:34hugodIn an om render function, can you render multiple nodes, or just a single node (with children)?
17:36mthvedtfare: you’re binding vars to fns that get themselves?
17:36mthvedthow does that work
17:36Faremthvedt, the function is defined later.
17:37Farethe early binding is to use the late binding
17:37mthvedtso you’re referencing the fn earlier, but calling it later?
17:37Fareyes
17:38danielcomptonso top level packages are frowned upon?
17:38justin_smithdanielcompton: yeah, definitely
17:38Faremaybe I could simplify in (declare f) (def f [n] (f n)) ? or would that be simplified in a recur?
17:41mthvedtfare: clojure looks up bindings each time a var is invoked
17:41mthvedtit relies on the JVM to optimize away most of the lookups
17:44Fareso, maybe `(do (declare ~f) (def ~f (fn [~'x#] (~f ~'x#)) ?
17:45mthvedti think that would work
17:45mthvedtyou don’t need to quote unquote the x#
17:45mthvedtin fact just make it a defn
17:46danielcomptonjustin_smith: ztellman gets to be the exception?
17:46ztellman_I get to be what?
17:46talios'lo danielcompton
17:46danielcomptontop level package
17:46bbloomFare: you know you can give functions names without def, right?
17:46danielcomptonpublisher
17:47hiredmandanielcompton: what do you mean by top level package?
17:47ztellman_oh, top-level packages are bad because they're not easily consumable by other stuff
17:47Farebbloom, and pass them as parameters to other functions?
17:47ztellman_though the new Clojure Java API stuff pretty much sidesteps that
17:47bbloomFare: yeah
17:47danielcomptonfrom http://i.imgur.com/Ue9xWJn.png
17:48bbloom,((fn add [x y] (if (zero? x) y (recur (dec x) (inc y)))) 5 10)
17:48clojurebot15
17:48danielcomptonarrdem commented about top level packages, I assumed he meant 'judo-notes.handler'
17:48danielcomptonIsn't that a top level package?
17:48technomancyno
17:48bbloom,((fn f [] f))
17:48clojurebot#<sandbox$eval51$f__52 sandbox$eval51$f__52@a0187c>
17:48bbloomFare: see?
17:48hiredmandanielcompton: please use a pastebin for sharing text instead of screenshots
17:49danielcomptonhiredman: I was copying a screenshot published last night in the #clojure channel
17:49hiredman:/
17:49bbloomwhat declare really does is it puts an "unbound" var entry in to the mutable namespace map... then when the compiler sees some symbol x, it first looks up x in locals, then if not found, looks it up in the namespace mappings
17:49bbloomin the former case, a vm stack operation is generated
17:49hiredmandanielcompton: I have no idea what he was refering to by top level package there
17:49bbloomin the latter, an invoke is generated to deref on the var
17:50mthvedtbbloom: i think he wants to have the var bound to a fn he can pass in to some parser combinators, and that fn looks up the “real” binding later
17:50Faremthvedt, yes
17:50danielcomptonztellman_: is lamina a top level package for example?
17:50ztellman_danielcompton: no
17:51bbloomFare: to what end? mutual recursion? or something else?
17:51ztellman_unless we're using a different definition
17:51Fareyes, my tweaked definition works.
17:51ztellman_it's lamina.core, lamina.executor, etc
17:51hiredmandanielcompton: I recommend not using the namespace part stuff like (judo-notes [model :as model]) and just do [judo-notes.model :as model], and use [] instead of () for requires
17:51ztellman_my primitive-math library, though, is just 'primitive-math'
17:51Fareyes, mutual recursion between two grammar non-terminals
17:51bbloomFare: and is each non-terminal defined as a top level?
17:51Fareeach non-terminal has a corresponding monadic parser
17:51Fareyes
17:51danielcomptonhiredman: it wasn't my code but thanks
17:52mthvedtbbloom: parser combinators are usually defined with higher-order fns
17:52mthvedtyou have fns that make fns that mutually recurse
17:52bbloommthvedt: right, but i'm not sure where he needs the mutual recursion
17:52hiredmandanielcompton: there is nothing that is called a "package" in clojure so when you say "top level package" everyone has to guess what you mean by package
17:52mthvedtit’s a general case for parser combinators
17:52hiredmandanielcompton: in this case ztellman is guessing you mean namespaces
17:52ztellmanit's what namespaces are called in Java
17:52hiredmantoplevel is also a problem, because there is no explicit hierarchy in clojure namespaces
17:53bbloomFare: is your grammar open for extension? or closed?
17:53mthvedta parser generator that can’t conveniently mutually recurse would be kind of gimped
17:53bbloomFare: ie is the set of non-terminals known and finite?
17:53hiredmaner
17:53Fareclosed for now, but I'm wondering about the best way to make it extensible later
17:53hiredmanimplicit I guess
17:53bbloomso if it's closed, you can just use letfn
17:53hiredmananyway, they are non-hierarchical
17:53bbloombut you won't get any vars for use from the outside
17:54FareI can't use letfn when most definitions are not (defn foo [x] ...) but (def foo (&combine bar baz))
17:54hiredmanztellman: it is a similar construct in java, common lisp also has a similar kind of thing called a package
17:54bbloomFare: ah ok, yeah, there's no general letrec construct
17:54danielcomptonhiredman: I'm referring to arrdem's comment in http://logs.lazybot.org/irc.freenode.net/%23clojure/2014-07-23.txt at 22:28:22
17:54danielcomptonI was reading through the logs this morning and was trying to understand what he eant by that
17:55hiredmandanielcompton: he is talking about maven depedency coordinates
17:55FareI suppose I could eta-convert to avoid some of that... but that's about the same result, isn't it? This way I only eta-convert 9 forward-referenced functions.
17:55hiredmandanielcompton: which are totally different from clojure namespaces
17:55Farebut yeah, to make it extensible, I might need to eta-convert everything, at which point a simple a simple (declare ...) would be enough
17:55bbloomFare: you just need to forward declare one function from every mutually recursive group
17:56hiredmandanielcompton: and are not packages either, the coordinates are made up of a [group-id/artifact-id version-string]
17:56bbloomFare: do you want an extensible set of non-terminals, or do you want an individual non-terminal to be extensible?
17:56bbloomie add an alternative to some production
17:56hiredmanin lein/clojure it is pretty common to use the same thing for both group-id and artifact-id so lein shortens that to just [artifact-id version-string]
17:56mthvedti like the general solution—it is simple and avoids annoying refactoring later
17:57Farebbloom, yup, I only have 9 forward references out of ~79 named non-terminals
17:57danielcomptonhiredman: thanks. Next question, is it ok to write projects without a fully qualified namespace, e.g. rummy instead of net.danielcompton/rummy
17:57danielcomptonhiredman: *?
17:57hiredmanthat is not a namespace
17:58danielcomptonsorry, I mean project naming
17:58hiredmansure
17:58FareI think that for now I'm considering leaving the grammar not extensible, and have the same extension points as macropy
17:58bbloomFare: you can "extend" a previous var something like this: (def foo (...)) .... (def foo (add-alternative @#'foo bar))
17:58hiredmanI assume you are talking about what you pass to lein new when creating a project
17:59Fare(though with a different ast structure: the official python ast looks really really misdesigned)
17:59bbloomFare: the @#' is just (deref (var ...))
17:59bbloomwhich lets you capture the old value
17:59hiredmanlein new foo/bar will create a new project with the group-id foo and the artifact-id bar, and will generate a namespace foo.bar in the file src/foo/bar.clj
18:00hiredmanlein new foo will create a new project with the group-id foo and the artifact-id foo, and will generate a namespace foo.core in the file src/foo/core.clj
18:00mthvedtfare: curious, what are you building? are you using a library?
18:00bbloomFare: but if it were me, i may consider not defining non-terminals as vars, but rather as keywords
18:00Farebbloom, yes, but currently I need to recompile the entire grammar every time I do a change, because the uses of a non-terminal in a combinator defining another non-terminal are eagerly bound.
18:00hiredmannow generally it is frowned on the have single segment namespaces like (ns foo) which is what everyone assumed you were asking about when you asked about top level packages
18:00Faremthvedt, I've made very light use of algo.monads
18:01hiredman~namespaces
18:01clojurebotnamespaces are (more or less, Chouser) java packages. they look like foo.bar; and corresponde to a directory foo/ containg a file bar.clj in your classpath. the namespace declaration in bar.clj would like like (ns foo.bar). Do not try to use single segment namespaces. a single segment namespace is a namespace without a period in it
18:01Farebut ended up only using variants of the state monad, with my own extensions
18:01technomancydanielcompton: don't use common nouns for unqualified project names
18:01bbloomFare: you can simply write #'foo to get late binding... vars are callable!
18:01bbloom,(defn foo [] :old)
18:02clojurebot#'sandbox/foo
18:02hiredmanI have bought domains on impluse because it seemed like they would be a cool group-id for a project
18:02danielcomptontechnomancy: that's what I was trying to work out. So something like lamina would be ok, but light would be frowned upon?
18:02bbloom,(def a (comp vector foo))
18:02clojurebot#'sandbox/a
18:02bbloom,(def b (comp vector #'foo))
18:02clojurebot#'sandbox/b
18:02bbloom,(a)
18:02clojurebot[:old]
18:02bbloom,(b)
18:02clojurebot[:old]
18:02bbloom,(defn foo [] :new)
18:02clojurebot#'sandbox/foo
18:02technomancydanielcompton: right; you're just trying to avoid something that someone else is likely to use as a name
18:02bbloom,(a)
18:02clojurebot[:old]
18:02bbloom,(b)
18:02clojurebot[:new]
18:02bbloomFare: ^^
18:03danielcomptontechnomancy: and when in doubt, fully qualify?
18:03technomancysure
18:03bbloomFare: alternatively, you could define only a single var which contains a data restructure representing the entire grammar, then use keywords as identities instead of symbols/vars
18:04bbloomso (&compose :foo :bar) instead of (&compose #'foo #'bar)
18:04bbloomthe evaluator would just do a lookup for the production lazily
18:05Farebbloom: I would need to eta-convert all my non-terminal combinations, but that's doable
18:05hiredmanhttps://github.com/hiredman/raft/blob/master/project.clj has a sweet group-id
18:05mthvedtbbloom: that’s basically what i did for https://github.com/mthvedt/clearley
18:05mthvedtit’s kind of heavyweight however
18:05Fareyes, I could make my combinators explicitly late-bind...
18:06mthvedtactually, i lied
18:06mthvedtthat’s not really what i did
18:06mthvedtnevermind
18:10gf3getting this error on the default hello world generate by dnolen_'s mie, any ideas? → https://www.refheap.com/3d45d51132c42c4c6761f1f66
18:11dnolen_gf3: you need to be on JDK7 at least
18:11gf3dnolen_: ahh ok thx
18:12Fareso... is there an existing clojure project that would accept silly contributions such as a python parser? I'm having a hard time convincing my boss to convince my VP to underwrite a new project release just for that
18:13technomancyFare: I can create a dummy project and accept pull requests if you like =)
18:13Faretechnomancy, that might help :-/
18:13Farea bit borderline, though
18:14technomancyreally what you need to do is create a web service that can do this for you
18:14Fare:-)
18:14Faredoes anyone here see a use for a python parser?
18:15danielcomptonFare: I was wanting to call python libraries from Clojure
18:16Faredanielcompton, not the same, unless you also reimplement enough of python...
18:16danielcomptonFare: that way madness lies
18:16Fareif you want a full python, you're better off calling jython
18:16Fareon the other hand, if you, like me, are implementing a python dialect...
18:21Fare(inc bbloom)
18:21lazybot⇒ 38
18:22{blake}I'm getting an error trying to use cljs. I type "lein cljsbuild once" and get "java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Associative".
18:22{blake}clojurescript 2268, lein-cljsbuild 1.0.03
18:22{blake}(I sorta figure it's a version error but I can't see it. That's the latest everything.)
18:24imperman{blake}: What about :plugins [[lein-cljsbuild "1.0.3"]] in project?
18:24Fare(defmacro def-forward [& names] `(do ~@(map #(do `(do (declare ~%) (def ~% #'~%))) names)))
18:24imperman{blake}: https://github.com/emezeske/lein-cljsbuild
18:24{blake}Yep. (copying and pasting: :plugins [[lein-cljsbuild "1.0.3"]]
18:25imperman{blake}: also The lein-cljsbuild plugin works with Leiningen version 2.1.2 or higher.
18:25{blake}It's lein 2.3.4.
18:25imperman{balke}: hmm...
18:25{blake}imperman, Yeah, I went there first. But I've obviously missed something. (I've never had a problem with it before.)
18:26FareI'm not sure I understand what #' does anymore... oh, it's just like calling a symbol in CL... it's actually calling a symbol in clojure.
18:27Fareduh
18:27mthvedtfare: not quite, #’ gets the var bound to a symbol
18:27mthvedtclojure bindings go symbol -> var -> value
18:27{blake}Huh, the example in cjlsbuild works, with no clojure/clojurescript dependency.
18:28imperman{blake}: What about this: In addition, you should add an explicit ClojureScript dependency to your project, like this:
18:28imperman:dependencies [[org.clojure/clojurescript "0.0-XXXX"]]
18:28impermanlein-cljsbuild will add a dependency to your project if it doesn't already contain one, but that functionality will not remain for long. The latest version of lein-cljsbuild currently requires a minimum of ClojureScript 0.0-2197.?
18:28mthvedti don’t think common lisp has that
18:28imperman{blake}: I don't know exactly. Only try to understand :)
18:29Fareoh, #'foo is a var, not a symbol
18:29ttasterisco#'foo is the same as (var foo)
18:30{blake}OK, I found it.
18:30Fareso, vars are callable, and calling them do a late binding
18:30{blake}I was using an example that had ":cljsbuild {:builds []})" in it. And that don't work no more.
18:30Farethe symbol is not callable, but the var is.
18:30{blake}Thanks, imperman!
18:30{blake}(inc imperman)
18:30lazybot⇒ 1
18:31imperman{blake}: Oh, good :)
18:31Faremucho cleaner than whatever I was doing.
18:31FareI'm glad I asked.
18:46Fareworth removing a dependency
19:00Fareok, is it worth creating a library for that ~120 line parser combinator thingie?
19:02ttasteriscohm, does Korma not have a way to set the isolation level of a transaction?
19:04FareKorma? As in Chicken Korma?
19:09ttasteriscoFare: yes
19:09ttasteriscowith hash brownies
19:19Fare#(brownies)
19:24mthvedt,(.hashCode “brownies")
19:24clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading string>
19:24eredi think it put smart quotes on there
19:24ered,(.hashCode "brownies")
19:24clojurebot384041441
19:24eredyeah
19:26mthvedt,(.hashCode "brownies")
19:26clojurebot384041441
19:26mthvedtstupid os x
19:31danielcomptonIs there a more elegant way of writing https://gist.github.com/danielcompton/df8f59e49626d8ce5d73#file-jmx-queries-clj-L9-L11 ?
19:32danielcomptonI want to test if attr = a certain value, returning a different value if true and attr if false
19:33justin_smith,(replace {["*"] :new-value} [["*"]])
19:33clojurebot[:new-value]
19:33justin_smithit's a bit hacky because replace only works on collections - wait...
19:34justin_smith,(get {["*"] :new-value} ["*"] ["*"])
19:34clojurebot:new-value
19:34justin_smithdunno if that is any clearer (you would use attr for the last two values in that form of course)
19:48ziltiIs it the case that it's impossible to launch a Clojure application without reflection?
19:49justin_smithzilti: I don't know, but out of curiosity, why would launching one require reflection? reflection used in the clojure compiler?
19:50ziltijustin_smith: I'm creating a WebStart application and wanted to make it unsigned. But despite getting no reflection warnings during compilation (and I have :gen-class set, too) I get an error on launch because of reflection
19:52justin_smithhttp://icyrock.com/blog/2012/04/clojure-seesaw-and-java-web-start-with-leiningen/ this mention that seesaw reflects
19:52justin_smith*mentions
19:53ziltiI'm not using seesaw, I'm using JavaFX. And as I said, I don't get any reflection warnings, not even in any libraries
19:54justin_smithOK - I wouldn't be too surprised if clojure does some reflection that isn't caught by warn-on-reflection, but as you see I am no expert in this. Interesting though.
19:54TEttingerzilti, check for primitive math
19:54TEttinger$google ztellman primitive math
19:54lazybot[ztellman/primitive-math · GitHub] https://github.com/ztellman/primitive-math
19:55TEttingerUnfortunately, while Clojure will warn you when reflection is required to invoke a function, it will not warn you when reflection is required to perform math
19:55ziltiTEttinger: Thanks, I'll try that
19:56TEttingerprimitive-math won't fix it automatically, it will throw a lot of warnings at compile time when it finds reflection on math so you can fix them
19:57TEttingerthe number is usually very high at first, the warning count
19:57TEttingerit goes down quickly the more you fix
19:59danielcomptonjustin_smith: thanks, that's helpful, though it also looks a bit weird
20:04ziltijustin_smith: Ugh. It seems core.async uses libs which use reflection at two points. Bad luck for me.
20:05justin_smithzilti: may be worth a github issue
20:05justin_smith(or whatever they use to track bugs / feature requests)
20:06ziltijustin_smith: Jup. Gonna make that Clojure JIRA smoke.
20:07zilticore.memoize and data.priority_map use reflection and both are used by core.async
20:07TEttingercore.memoize probably needs it
20:08zilti"Reflection warning, clojure/core/memoize.clj:72:23 - reference to field cache can't be resolved." sounds more like a bug.
20:08TEttingerno, that one is just a reflection warning -- it can't tell the type of cache
20:09TEttingerhow would it, anyway? memoize is kinda beyond my grasp
20:09ziltiYes, I had these in my code too, in my case they were fixed by simple type hints
20:10justin_smithTEttinger: it should suffice to have a typehint in the right place that the argument implements the apropriate memoization protocol
20:10justin_smithTEttinger: it is already implemented in terms of protocols, so the hinting should be strightforward
20:10TEttingerzilti, yeah, JIRA it is then. if it is in memoize.clj you should be able to patch it locally and install it in your maven repo
20:12pandeiroshould the [:repl-options :init-ns] be automatically loaded on `lein repl`? my repl is starting at the ns, but w/o any of its vars -- is that the normal behavior?
20:28blur3dpandeiro: you can try using the user namespace, as it automatically loads in lein repl (I haven’t actually tested this tho)
20:29fifosineI don't understand the function definition of get at http://clojuredocs.org/clojure_core/clojure.core/get
20:29fifosineIt looks like it just calls itself?
20:30pandeiroblur3d: thanks turns out i had mismatching ns/filepath issues (i really need to write the emacs function that automates this..)
20:30justin_smithfifosine: where is the definition you are referring to?
20:30ziltififosine: Look at the "inline" part
20:30hiredman,(macroexpand '(clojure.lang.RT/get {} 1))
20:30clojurebot(. clojure.lang.RT get {} 1)
20:30hiredmanhttp://clojure.org/java_interop#Java%20Interop-The%20Dot%20special%20form
20:31blur3djustin_smith: I came across this today https://freeboard.io/ - it’s similar to the dashboard I am working on and it’s also open-source. But not clojurescript alas… still some ideas tho
20:32fifosinezilti: I'm confused, what's the difference between inline and the actual code?
20:32hiredmanthe day has come when those have arrived who have never use the . and new special forms directly
20:32justin_smithblur3d: it's never been easier to become a supervillian
20:32hiredmanfifosine: see my link
20:32blur3djustin_smith: https://www.geckoboard.com/ is more of what I am after… but the key difference is I want it to be dynamic at runtime - aka. it creates itself based on data
20:33blur3djustin_smith: yeah.. I think thats the best part of html… viewable source
20:34ziltififosine: Well, it's some fancy macro-stuff-callable-as-function. But I just noticed afterwards that it says the same as the actual code.
20:35fifosinehiredman: How would I go about extending the hashmap data structure in order to override the way get works?
20:35hiredmanfifosine: you mean change the exist hashmap? you can't, you have to build a new hashmap type
20:35justin_smith,(macroexpand '(. clojure.lang.RT (get {} 1))) hiredman: but this is what we see on clojuredocs, and that is a tricker syntax
20:35clojurebot(. clojure.lang.RT (get {} 1))
20:36hiredmanjustin_smith: the page I linked to explains *all* the interop syntax
20:36fifosinehiredman: That's what I mean, how would I go about building a new hashmap type?
20:36hiredman,(supers (class (hash-map))
20:36clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
20:36hiredman,(supers (class (hash-map)))
20:36clojurebot#{clojure.lang.AFn clojure.lang.Associative java.lang.Runnable clojure.lang.APersistentMap clojure.lang.IMeta ...}
20:36justin_smithhiredman: right, just pointing out (you had pasted a more intuitive syntax in your macroexpand above)
20:36hiredmanyou make something that implmenets all of that
20:37hiredmandepending on what you actually want you can pick and choose some smaller set of interfaces to implement
20:37fifosinehiredman: Ok, is implementing those interfaces sufficient for a data structure comprable of a hashmap?
20:38hiredmanyou can support get by implementing ILookup
20:38hiredmanfifosine: what do you mean comparable?
20:38fifosineDoes a hashmap have any functionality that is not defined in any one of those interfaces?
20:40fifosinehiredman: Is there no way to, the way we can override in Java, override the get method of a hashmap in clojure? Implementing all those interfaces would be more work than would make it worth
20:40hiredmanIPersistentMap is the main map interface, clojure map literals actually start out as array maps and if they get large enough that got swapped for hashmaps transparently becuase of that interface
20:41hiredmanfifosine: sure, I'd suggest not creating a new map type
20:41hiredmanwhy do you want to?
20:42fifosineI want a map where every key *and its reverse* map to a value
20:42hiredmanso, like, two maps?
20:42fifosineRight, but half the size
20:42nathan7well, you can have that
20:42nathan7O(n) lookups in one direction, O(1) in the other
20:42hiredmanI really doubt that
20:43hiredman(the half the size bit)
20:43nathan7you just need to sacrifice time for space
20:43fifosinehiredman: What is it that you doubt?
20:43nathan7It's a space vs time tradeoff.
20:44fifosinenathan7: I agree, but wouldn't it require overwriting the get method in hashmap so that we can call reverse?
20:44nathan7fifosine: Write yourself a wrapper that implements the right interface that tacks onto a normal hashmap
20:44hiredmanfifosine: that won't work anway
20:44fifosineWhat do you mean by "tacks"? Is that different from extends?
20:44fifosinehiredman: Why?
20:45nathan7fifosine: so you have two IMap objects — one is the one storing stuff, the other is a wrapper for the former
20:45hiredmanfifosine: I guess it could
20:45nathan7to tack onto, to stick onto
20:45hiredmanfifosine: why not just write a my-reverse-get-function ?
20:45nathan7hiredman: well, you could provide that as a my-reverse-map object
20:46fifosinehiredman: Because it needs to be generalized for all map-types.
20:46nathan7(reify IMap …)
20:46hiredman(if (contains? m k) (get m k) (get m (reverse k)))
20:46nathan7IPersistentMap, even
20:46hiredmanworks on any IPersistentMap, and any java.util.Map I suspect
20:46nathan7wait
20:46fifosinenathan7: What are you listing? Interfaces to implement?
20:47nathan7well, it's IPersistentMap I guess
20:47nathan7I think I misunderstood your requirements though
20:47fifosine,(supers (class (hash-map)))
20:47clojurebot#{java.lang.Runnable clojure.lang.IMeta clojure.lang.Associative clojure.lang.Counted clojure.lang.IPersistentCollection ...}
20:47nathan7fifosine: I was assuming you meant something that does key->value and value->key lookup
20:47fifosineno
20:47nathan7you want key->value and (reverse key)->value, in one object
20:47hiredman,(defn magic-get [m k] (if (contains? m k) (get m k) (get m (reverse k))))
20:47clojurebot#'sandbox/magic-get
20:47fifosineyes, but we shouldn't have to store (reverse key)
20:48hiredman,(magic-get {"foo" "bar"} "foo")
20:48clojurebot"bar"
20:48hiredman,(magic-get {"foo" "bar"} "oof")
20:48clojurebotnil
20:48hiredmanoh
20:48fifosinelool
20:48hiredmanstr reverse of course
20:48hiredman,(defn magic-get [m k] (if (contains? m k) (get m k) (get m (apply str (reverse k)))))
20:48clojurebot#'sandbox/magic-get
20:48hiredmanstr reverse of course
20:48hiredman,(magic-get {"foo" "bar"} "oof")
20:48clojurebot"bar"
20:48hiredman,(magic-get (doto (java.util.Map.) (.add "foo" "bar")) "oof")
20:48clojurebot#<CompilerException java.lang.IllegalArgumentException: No matching ctor found for interface java.util.Map, compiling:(NO_SOURCE_PATH:0:0)>
20:48hiredman,(magic-get (doto (java.util.HashMap.) (.add "foo" "bar")) "oof")
20:49clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: add for class java.util.HashMap>
20:49hiredman,(magic-get (doto (java.util.HashMap.) (.put "foo" "bar")) "oof")
20:49clojurebot"bar"
20:49hiredmangah
20:49hiredmanso I guess I haven't used java.util.Maps in a while
20:49fifosinehiredman: Nonetheless, I don't want to have to use magic-get
20:52nathan7fifosine: then reify!
20:52fifosinenathan7: What do I reify? hashmap? Or its interfaces?
20:53nathan7fifosine: ILookup
20:53nathan7fifosine: at the very least
20:53fifosinenathan7: So I have to reimplement all un-edited hashmap methods?
20:53nathan7fifosine: Yes.
20:53fifosinethat's crazy
20:54nathan7well, you can forward many of them to your actual hashmap
20:54nathan7that backs it
20:54fifosineah ok, guess that's true
20:54fifosinestill would extend not help?
20:54fifosinehttp://clojuredocs.org/clojure_core/clojure.core/extend
20:54nathan7how would it
20:54nathan7what are you going to extend
20:55nathan7for one, none of these things are protocols
20:55nathan7they're interfaces
20:55nathan7extend works with protocols
20:55fifosinePersistentHashmap?
20:55nathan7is that a protocol now?
20:55fifosineIdk, I'm guessing
20:56nathan7it can't be
20:56nathan7because of how things are implemented
20:56fifosineWhat is it then?
20:56nathan7It's nonexistent
20:56nathan7IPersistentHashMap is a Java interface
20:57fifosinehttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/PersistentHashMap.java
20:57nathan7oh, yes, that's a class
20:57nathan7implementing the actual thing
20:57fifosineCan I not extend that?
20:57nathan7but that's not what you want
20:57fifosineno?
20:57clojurebotno is tufflax: there was a question somewhere in there, the answer
20:57nathan7fifosine: extend the class with what protocol?
20:57nathan7fifosine: extend allows you to extend a class with a protocol.
20:57fifosineugh, I must be terribly confused
20:57nathan7fifosine: You could define a MagicGet protocol.
20:57nathan7fifosine: MagicGettable, whatever
20:58nathan7fifosine: and have a magic-get protocol method
20:58nathan7fifosine: get, however, operates on things implementing ILookup
20:58nathan7fifosine: and assoc operates on things implementing Associative (also an interface, despite lack of I)
20:59nathan7fifosine: just ILookup and Associative are probably all you want to implement
21:00fifosineI'd hate to have a map that's not fully a map though
21:00nathan7Then implement IPersistentMap
21:00nathan7which means implementing Iterable, Associative and Counted
21:01nathan7I'm bloody tempted to write your thing for you just so you'd understand
21:03fifosinenathan7: I'm reading this http://tech.puredanger.com/2011/08/12/subclassing-in-clojure/
21:03nathan7heck, here we go
21:03fifosineLooking like gen-class will do it
21:08fifosinenathan7: Yea, gen-class with :exposes-methods
21:12nathan7fifosine: http://sprunge.us/NBYU
21:12nathan7fifosine: this is a start
21:14nathan7fifosine: #{empty without containsKey assoc assocEx seq entryAt equiv valAt count cons forEach iterator spliterator}
21:14nathan7fifosine: the methods you'd have to implement
21:14nathan7fifosine: could even have implemented valAt in terms of entryAt
21:35ziltiHuh? Lein uberjar puts libraries from others than just the default profile into the jar?
21:36fifosine(defn my-map [](proxy [clojure.lang.PersistentHashMap] [nil 0 nil false nil]
21:36fifosine #_=> (valAt [key] 1)))
21:37fifosinemi scuse
21:42ziltiOk I've got the exact error because of the reflection now: https://www.refheap.com/88562 What can I do about that?
21:44TEttingerthat does not appear to be a reflection error at first glance
21:44TEttingerit looks like you're reading a local file when you do not have permission from the OS/user
21:45ziltiTEttinger: The .jar doesn't read any files at all, so that can't be it
21:46TEttingerso you're just trying to do webstart and it isn't working?
21:46TEttingeror something else?
21:46ziltiTEttinger: Exactly
21:46TEttingerI wasn't aware that webstart was different from normal desktop java
21:47ziltiTEttinger: Well it runs unsigned applications in the sandbox, so there's that
21:48fifosineAnyone know why this returns nil? https://www.refheap.com/88564
21:57ttasteriscofifosine: because it can't find any key in the map?
21:57ttasteriscoyou're trying to find a key named (2 1) ?
21:58nathan7fifosine: the reverse* fn in my code
21:58nathan7fifosine: read it.
21:58nathan7fifosine: (defn reverse* [x] (into (empty x) (reverse x)))
21:58nathan7fifosine: you want it to be the same collection type
21:59nathan7fifosine: (reverse [1 2 3]) is the *seq* (1 2 3)
21:59nathan7err
21:59nathan7(3 2 1)
21:59nathan7what you want is (reverse* [1 2 3]), giving you [3 2 1], a *vector*
21:59fifosineIf you look at the link, the key is a list
21:59fifosineand I ask for the reverse of the list
22:00ttasteriscowhat does (println (assoc (rev-key-map) key "nice")) show?
22:01fifosine"nice"
22:02fifosine,(defn rev-key-map []
22:02fifosine (proxy [clojure.lang.PersistentHashMap] [nil 0 nil false nil]
22:02fifosine (valAt [key]
22:02fifosine (or (proxy-super valAt key)
22:02fifosine (proxy-super valAt (reverse key))))))
22:02clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
22:02fifosinew/e
22:02fifosinettasterisco: {#<core$key clojure.core$key@24ff5d3f> nice}
22:03fifosine,(defn rev-key-map [] (proxy [clojure.lang.PersistentHashMap] [nil 0 nil false nil] (valAt [key] (or (proxy-super valAt key) (proxy-super valAt (reverse key))))))
22:03clojurebot#'sandbox/rev-key-map
22:04fifosine,(let [key (list 1 2)] (get (assoc (rev-key-map) key "nice") key))
22:04clojurebot"nice"
22:04fifosinebut
22:04fifosine,(let [key (list 1 2)] (get (assoc (rev-key-map) key "nice") (reverse key)))
22:04clojurebotnil
22:04ttasterisco[19:00] <fifosine> ttasterisco: {#<core$key clojure.core$key@24ff5d3f> nice}
22:05ttasteriscothat's not "nice"
22:05ttasteriscothat's a map with a key and nice
22:05gfredericks,(type (rev-key-map))
22:05clojurebotsandbox.proxy$clojure.lang.PersistentHashMap$ff19274a
22:05ttasterisco,(let [key (list 1 2)] (println (keys (assoc (rev-key-map) key "nice"))))
22:05clojurebot((1 2))\n
22:05gfredericks,(type (assoc (rev-key-map) 1 2))
22:05clojurebotclojure.lang.PersistentHashMap
22:05ttasteriscothat's the key in the map
22:05gfredericksttasterisco: ^ it reverts to a regular map after assoc
22:06fifosineAh-ha!
22:06fifosineshit
22:06gfredericksztellman has a lib for making custom map types without too much trouble
22:07ttasterisco,(doc transient)
22:07clojurebot"([coll]); Returns a new, transient version of the collection, in constant time."
22:14gfredericks,(doc var)
22:14clojurebotGabh mo leithscéal?
22:14gfredericks,(doc comment)
22:14clojurebot"([& body]); Ignores body, yields nil"
22:14gfredericks,(comment doc)
22:14clojurebotnil
22:15danielszmulewicz'lein new app my-app' doesn't create a user.clj under a dev directory. I always thought it did. Did it change recently?
22:21technomancyno, it's never done that
22:21wildnuxhi, if i have a function (valid-arg? ) which takes a string and returns the string if it is valid else returns nil, what is the idomatic way of checking 3 arguments for a function? eg: (defn [f s t] (map valid-arg? [f s t]) gives (str1 str2 str3)
22:22wildnuxhow do i write (defn checkthree [f s t] ..) so that it returns (f s t) if all are valid else returns nil
22:25danielszmulewicztechnomancy: Oh, OK. I understand, I need to add the :dev profile in project.clj and create the file manually, right?
22:37fitzohTrying to figure out what I’m doing wrong inserting multiple values with jdbc. this works: (j/insert! db :table nil (first lines) (second lines))
22:37fitzohthis doesn’t: (apply #(j/insert! db :table nil %) lines))
22:37fitzohwhat am I missing?
22:42ttasteriscoyou're passing a collection to insert! in the 2nd case, while in the first case you're passing lines as separate args?
22:43trptcolinfitzoh: your anonymous fn only takes 1 arg but apply is making you pass more (assuming lines has > 1 element)
22:43fitzohI thought that the apply “unwrapped” the collections into multiple args
22:45trptcolinyou can delete the `#(` and the `)` and it should work
22:45ttasterisco,(doc apply)
22:45clojurebot"([f args] [f x args] [f x y args] [f x y z args] [f a b c d ...]); Applies fn f to the argument list formed by prepending intervening arguments to args."
22:46ttasteriscowhat trptcolin said
22:47fitzohah, makes sense
22:47fitzohthanks for the help
22:49trptcolinnp
23:40kelseygihi i am kind of stuck trying to create a predicate based on a vector of strings
23:40kelseygi(defn reply?
23:40kelseygi (some-fn (map (partial #(.startsWith %1 %2)) prefixes)))
23:40kelseygii'm getting Parameter declaration some-fn should be a vector
23:43ttasteriscoyou're missing a [] with the args after reply?
23:43kelseygisorry, prefixes refers to an arg
23:43kelseygier to a vector of strings
23:44ttasterisco(defn reply? [some-fn prefixes] (some-fn (map (partial #(.startsWith %1 %2)) prefixes))) ?
23:45ttasteriscowhy are you using partial with the anonymous function?
23:45ttasterisco,(defn reply? [some-fn prefixes] (some-fn (map #(.startsWith %1 %2) prefixes)))
23:45clojurebot#'sandbox/reply?
23:47ghadishaybancore.async "subway turnstile" https://gist.github.com/ghadishayban/7018dbc353216801b318
23:49ttasterisco,(defn reply? [some-fn pf1 pf2] (some-fn (map #(.startsWith %1 %2) pf1 pf2)))
23:49clojurebot#'sandbox/reply?
23:49ghadishaybani can't decide if metaphors help or hurt most of the time
23:50ttasterisco,(reply? vec ["aaa" "bbb" "ccc" "ddd"] ["ddd" "bbb" "ccc" "aaa"])
23:50clojurebot[false true true false]
23:50ghadishaybanthey probably help if it's in a description, but not symbol names
23:56literaterhaving what looks to be a dependency issue with lobos. new to clojure, unsure how to resolve. i'e had issues getting korma to work so i set org.clojure/java.jdbc to latest in my project.clj. now korma works but i get a "#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: *db* in this context, compiling:(lobos/connectivity/jdbc_2.clj:14:1)>"