#clojure logs

2012-11-21

00:00flying_rhinoatom_: to me seven consequtive closed parens look psychotic.
00:03atom_flying_rhino: Perhaps. I'm likely not a very good source. I'm new to programming in general, I have seen both perspectives and I think it may be as much culture as it is structure.
00:03amalloy(inc atom_)
00:03lazybot⇒ 1
00:03flying_rhinoatom_: look this way: Thera aren't many lispers around. One of the reasons is that code looks weird. Making code looking less weird is imho the cheapest way to make lisp more approachable.
00:04atom_amalloy: Thanks! I guess I can now say I'm inc'd.
00:04eggheadheh that's like alman style braces for lisp
00:04eggheadwait what are these dangling -- oh
00:04amalloythere's no reason parens *have* to go the way they do. but everyone who's spent any amount of time writing lisp has agreed that's the way they should go. that's why the arguments about code formatting in lisp are between the experts and the newcomers, and not between experts and other experts like in C/java/etc
00:05flying_rhinoatom_: marketing is something I am ionterested in
00:05flying_rhino*interested
00:05augustlflying_rhino: I recommend "simple made easy" by Rich Hickey, he has a lot of great things to say about the importance of familiarity
00:06flying_rhinohope no one will get heart attack when they see my code.
00:07eggheadflying_rhino: your second example is inconsistent tho, why not finish the let statement on another line as well
00:07augustlflying_rhino: the tl;dr is that familiarity is relatively unimportant, and I tend to agree
00:08amalloyegghead: don't forget the ] from the start of the let-bindings. why is it trapped behind the later )?
00:08flying_rhinoamalloy: since it is [ it already stands out from (
00:09flying_rhinoamalloy: so no need for new line there
00:09amalloyflying_rhino: perhaps a useful criticism is that you're trying to make the parens stand out. they're supposed to fade into the background so you can pay attention to the important stuff, like actual code
00:09atom_flying_rhino: Well, Lisp is based off of Lambda Calc if I remember correctly. You could just as easily tie it to the degradation in mathematical rigor, especially the absence of proofs, in many high school and university mathematics. Thus, less familiarity with that structure and by happenstance less familiarity with the structure of Lisp.
00:10royaldarkthe stacked ) vs newline ) is one reason I think comparing lines of code for Cish languages vs Lisp-like languages is deceptive
00:10nilmethodany recommendations for whirlwind tours on clojure or resources for me to learn enough clojure to be dangerous in about 8 days?
00:10amalloyearly, early on, when you're struggling to see what's going on, it can be useful to have that extra emphasis so that you can make sense of anything at all. but long-term, it's bad for you
00:10nilmethod8 evenings, that is
00:11flying_rhinoatom_: comparison with math doesn't really work since lisp insists on prefix notation which is unusuall for math.
00:12flying_rhinoI compare it to XML and JSON
00:13mroweflying_rhino: that is an odd thing to do :)
00:13jkkramernilmethod: there are several good clojure books - clojure programming, joy of clojure, etc
00:13atom_flying_rhino: It's the structure I think you're concerned with here. The structure of a proof doesn't change much wether you're using prefix or standard notation.
00:13flying_rhinomrowe: that's my story and I am sticking to it. At bottom, LISP is programmable data.
00:14mroweer
00:15eggheadflying_rhino: xml and json are programmable data as well? I don't much see the similarity besides them being tree structures
00:15eggheadthat's like saying lisp is just like c because both have ASTs
00:15nilmethodjkkramer: i've got the pragmatic press book. may just plow through it
00:15flying_rhinoegghead: xml and json are representation of data. Lisp is just more executable :)
00:16jkkramernilmethod: also clojure.org, clojure-doc.org, 4clojure.com
00:17jkkramernilmethod: and rich hickey videos, for the big picture
00:18flying_rhinoamalloy: I am not trying to make parens to stand out. I am trying to make CODE stand out. In my example (* @x @y @z) is the place where stuff from let block comes together. It deserves it's own line.
00:18technomancynilmethod: try clojurebook.com
00:19flying_rhinoamalloy: it is also, incidentally function that returns value
00:20haruki_zaemonmrowe *waves*
00:21miclorbI think to close off all parens )...) or )<->). The ruby guys led the way http://d.hatena.ne.jp/ku-ma-me/20110718/p1
00:21haruki_zaemonmiclorb genius!
00:22miclorbI like the close parens - someone had the rule "more than 5 to close and you need to refactor" - which seems handy
00:22miclorbif it looks bad, need to rethink
00:25atom_flying_rhino: You mentioned marketing. Are you hoping to make functional more palpable by making it look more like OOP?
00:26flying_rhinoatom_: look just becuase we can't make everything more palpable doesn't mean we shouldn't try with some stuff. And clojure does have multimethods which should make OOP guys a little less grouchy.
00:27mroweflying_rhino: I still don't get why you're so keen to use clojure, then want to make it just like java/scala/etc.
00:28muhoowhen in rome
00:30flying_rhinomrowe: because (1) Functional programming is good for a lot of things. I would like more mutable state here and there but still prefer functional for a lot. (2) Macros and code as data philosophy rules (3) Scala syntax looks like crap. (4) using multicore more efficiently is something I like.
00:30eggheadclojure can look pretty ugly
00:30flying_rhinomrowe: do I need to go on?
00:31mroweflying_rhino: you can avoid mutable state and write functional code in java and scala
00:31clojurebotscala is https://twitter.com/#!/timbray/status/153996532952203264
00:31mroweflying_rhino: what about macros and "code as data" rules?
00:31Sgeoflying_rhino, if you want a language with Lisp macros and lots of mutable state, go with Common Lisp
00:31flying_rhinomrowe: makes easier to parse code and write your own tools if you are so inclined.
00:32mroweflying_rhino: you can write efficient parallelisable code in many languages
00:32SgeoCL is OO to a good extent
00:32eggheadlisp as a programming language for programming languages. mmm
00:32flying_rhinoSgeo: I doubt CL has immutable structures as sophisticated as clojure.
00:33SgeoI'm sure you could implement them.
00:33Sgeo^^a bit trollish
00:33eggheadlol
00:33Bergle_1thats like a bit pregnant ?
00:34flying_rhinoSgeo: I'm sure you guys could implement slightly more mutablility, huh?
00:34eggheadflying_rhino: but whyyy
00:34mroweflying_rhino: so can you. it's a lisp, after all :)
00:34Sgeoflying_rhino, we don't want to, but the tools are there for you to implement highly mutable data structures if you wish.
00:35SgeoOr just use the native Java data structures.
00:35flying_rhinoSgeo: I will, probably. Won't use them all or even most of the time, but they will be there. I would prefer someone else does it so it is more standardized.
00:36atom_flying_rhino: That sounds like feature creep that is unnecessary.
00:36SgeoThe native Java data structures are pretty "standard"
00:36eggheadHeh, reminds me of tao, don't swim against the river
00:36SgeoNot used all that often, but anyone who wants to use them would use them in the same way.
00:37eggheadflying_rhino: have you seen the hickey talks on 'place oriented programming' or encounted that term in something like SICP ?
00:37SgeoDoes place-oriented programming have anything to do with CL's setf?
00:38flying_rhinoSgeo: I guess java structures are the way to go then :) So we are all happy.
00:39eggheadSgeo: you tell me :)
00:39SgeoExcept for any other Clojure programmer who touches your code, who will curse you out for needless mutability.
00:39flying_rhinoSgeo: happy ending, end credit music plays etc etc...
00:39Sgeoegghead, I don't really know what "place-oriented programming" is
00:39eggheadflying_rhino: http://www.infoq.com/presentations/Value-Values
00:39eggheadSgeo: basically dealing with addresses of things instead of the values of things
00:40eggheadif you have a value you don't have to worry about it slipping out from under you, when you only have an address you can never be sure what will be there at any given time
00:41SgeoTcl's append is place-oriented
00:41SgeoSeriously, I think Tcl's great, except for all the mutability.
00:42SgeoAnd fun fact, Tcl values (aka strings) are immutable, but variables etc. are all highly mutable and often passed around like candy
00:44SgeoTcl arrays (basically hash maps) are not first-class things. Dictionaries are, but those were added in recently
00:44SgeoArrays in Tcl are just a collection of similarly named variables
00:44Sgeo:/
00:59augustlFYI, programmers of europe! http://techmeshconf.com/
00:59augustlseems like there are still tickets left. Very relevant for Clojure programmers
01:00atom_Is there a place where tickets are filed for bugs/patches etc. and marked with beginner tags for clojure?
01:01augustlatom_: afaik there's only the jira
01:01tpopedevn: I've been 80% through for about 2 weeks :/
01:03amalloyatom_: if you have submitted a contributor agreement (which you must, to be allowed to help), you can read andy fingerhut's weekly summaries on the clojure dev mailing list
01:04amalloyeg http://groups.google.com/group/clojure-dev/browse_thread/thread/d98c4c3841bfd4b2/1972bd1b90178008?q=#1972bd1b90178008 but i think you need to have a CA to even read it
01:05atom_amalloy: Thank you. I'll print it out and save it for when I feel like I could contribute back productively.
01:21flying_rhinoSgeo: what's basic difference of hash map and dictionary?
01:22lynaghk`ure
01:23lynaghk`dnolen: just pushed up a patch for the core.logic walk stuff. Right now it walks over map keys just for completeness, though unification won't work with lvars inside of a complex map key because of how that process works.
01:35Sgeoflying_rhino, in what language?
01:36flying_rhinoSgeo: is there a general difference?
01:36SgeoDifferent languages tend to use the same term to mean different things
01:37SgeoArray is a frequent offender, but there are others.
01:37Sgeo"Functor" is particularly bad
01:37Sgeo"hash" map does somewhat imply something about the internals of how it works
01:37SgeoThat it hashes the key
01:37SgeoAnd uses that for efficiency purposes.
01:41brainproxywhy is it I get cool insights about the time I really should go to bed ... and just must stay up coding lest I lose the spark? :p
01:43SgeoWhat is this "bed" of which you speak?
01:43brainproxyi dunno, it could be like (sqrt -1)
01:45brainproxySgeo: any good w/ call-cc?
01:45SgeoUm, I understand it at a basic level
01:46Madsybrainproxy: Some people are naturally more awake and creative at night
01:46MadsyWhich makes sense to me. It's perhaps dark outside, little background noise, no traffic and everything is calm
01:46brainproxyMadsy: yeah, I'm definitely one of those ... will often work until 4/5am in the morning
01:47MadsySeconded
01:47brainproxybut can create ... issues ... in a world where things need to get done during the day
01:47MadsyJust sleep a bit in the afternoon. That's what I do
01:48MadsyI often go to bed at 3 or 4 am. Then I sleep for 4 hours. After work I sleep for 2-3 hours, then I wake up at 6-7 pm and do chores.
01:48brainproxysometimes that helps, but after i hit my mid 30s I find I've pretty much got to get 8 hours of sleep
01:49MadsyYeah, age definitely plays a role.
01:50MadsyWhat was your question about call/cc ?
01:51brainproxyoh, it's just that protocol-monads needs call-cc implemented, but I don't understand the concept well enough to pull it off, though I've made progress w/ other parts of the library
01:51Madsycall/cc In Clojure?
01:52brainproxywell, something that works like it
01:52MadsyNot sure if that's possible. Afaik, Clojure doesn't support full continuations due to limitations with the JVM
01:52brainproxysee algo.monads, it has it
01:52MadsyMonads.. brr. The name scares me D:
01:52brainproxy:)
01:54amalloy$google swannodette delimc
01:54lazybot[swannodette/delimc · GitHub] https://github.com/swannodette/delimc
01:54amalloybrainproxy: ^
01:55Madsybrainproxy: I'm sure algo.monads managed to make an approximation
01:55MadsyBut proper call/cc lets you jump *anywhere*
01:55brainproxyamalloy: awesome, delim'd conts are, I've heard, "better" than call/cc
01:56brainproxysaw an interesting presentation on them a few months ago, but didn't know any Haskell at the time, so I was a bit lost
01:56amalloywell, they're a bit "weaker", in that there's some stuff you can't do. but in general the stuff you can't do is an unspeakably bad idea to do
01:56brainproxyi think there's a paper "call/cc considered harmful"
01:57brainproxyor something like that, which advocates for delim'd conts
01:57MadsyIt's "kind of" harmful
01:57SgeoAny monad-based Continuation system is going to be delimited continuations I think
01:57amalloy∀x∃p such that p is a paper titled "x considered harmful"
01:58brainproxyhehe
01:58SgeoI should also note that that delimc library is a bit broken in some ways
01:58SgeoFor starters, anything wishing to use it must use all the vars
01:58SgeoAnd there might be other flaws
01:58MadsyThe problem with call/cc is that it allows you to jump both forwards and backwards. It guarantees that optimization is close to impossible
01:58SgeoIt's a not thoroughly executed port of a Common Lisp library
01:59brainproxythe impl in algo.monads looks deceptively simple
01:59brainproxyjust a couple lines of code
01:59brainproxybuilding on top of its continuation monad impl, of course
02:04amalloySgeo: use all the vars?
02:05Sgeoamalloy, as in, (:use) in the ns macro or (use)
02:06SgeoOr... well, just the ones you intend to use, I guess. The problem is that it won't, say, see delimc.core/shift as shift, it will only see shift as shift
02:07amalloyi have to say, the macro forms there look a bit bonkers. but it's not totally unprecedented; reset introduces an anaphor named shift, in the same way that loop introduces one named recur, or try introduces one named catch
02:25alex_baranoskydoes anyone have experience with serving dynamically generated files (such as CSVs) from a Ring app?
02:27alex_baranoskyWE've been using the 'wrap-resource' ring middleware to server static files, but it looked like it wouldn't recognize something generated dynamically
02:34amalloyalex_baranosky: just find out the http headers you need to set, and set them, while making the :body be whatever you need. eg, 4clojure generates image files on the fly with {:response 200 :headers {"Content-Type" "image/png"} :body (...some input stream with the right bytes...)}
02:35amalloyto make the files "downloadable" you probably need to set content-disposition as well, or something
02:35alex_baranoskyamalloy: thanks , I'll look at that
02:35Apage43Content-Disposition: attachment would force a type that would normally be displayed to be downloaded
02:36Apage43if you need that sort of thing
02:36clojurebotmost horrible thing is http://tinyurl.com/b65o8e
02:42alex_baranoskyAPAge43: thanks looking into Content-Disposition: attachment
03:11alex_baranoskyamalloy & Apage43 - thanks guys that worked
03:22augustlhttp://pragprog.com/magazines/2011-07/growing-a-dsl-with-clojure could use some multimethods or protocols
03:25augustland there we go, reading the whole article before posting it is a good idea :)
04:36thorwil,(map #(identity %) [{:a 1 :b "bert"} {:a 3 :b "jim"}])
04:36clojurebot({:a 1, :b "bert"} {:a 3, :b "jim"})
04:37thorwil,(map #(cons % %) [{:a 1 :b "bert"} {:a 3 :b "jim"}])
04:37clojurebot(({:a 1, :b "bert"} [:a 1] [:b "bert"]) ({:a 3, :b "jim"} [:a 3] [:b "jim"]))
04:37thorwili do not understand at all what happens in the second case
04:38ucb,(doc cons)
04:38clojurebot"([x seq]); Returns a new seq where x is the first element and seq is the rest."
04:38ucb,(seq {:a 1})
04:38clojurebot([:a 1])
04:38ucbthorwil: ˆˆˆˆ
04:39ucb,(cons {:a 1 :b 2} {:a 1 :b 2})
04:39clojurebot({:a 1, :b 2} [:a 1] [:b 2])
04:39ucbcons takes the 2nd argument as a seq (my guess is that it even calls seq on it) and hence you end up with a seq of [k v] from your map
04:39ucb,(source cons)
04:39clojurebotSource not found
04:40ucb&(source cons)
04:40lazybot⇒ Source not found nil
04:40ucbpah
04:43thorwilhmm. i need something that allows me to assemble (:b %) and %
04:44Bergle_1I am looking at http://clojuredocs.org/clojure_core/clojure.core/spit - it has a type hint of #^java.io.Writer - what is the '#' ? I've just done a dozen plus searches in google but not finding any enlightenment
04:44thorwilah, seq or vec
04:55cemerickBergle_1: #^ was the original type-hint prefix.
04:55Bergle_1ahhhh.
04:55Bergle_1i couldnt find that :) thanks.
04:55Bergle_1i thought it might be the case.
04:56thorwil,(apply hash-map (mapcat #(vec [(:b %) %]) [{:a 1 :b "bert"} {:a 3 :b "jim"}]))
04:56clojurebot{"bert" {:a 1, :b "bert"}, "jim" {:a 3, :b "jim"}}
04:56thorwilis there a ncer way from the 2 maps to that result?
04:56thorwilnicer, even
05:03ucbthorwil: maybe this http://clojuredocs.org/clojure_core/clojure.set/index
05:06thorwilinteresting, but that seems to be a much more complex mechanism with some other goals
05:15ucbyou would end with a map where the keys are maps like {:b value}
05:16ucbit's not that much more different; but perhaps you don't need that complexity in the real code :)
05:17thorwilit must be string keys. not my choice :)
05:51borkdudehello guys (and maybe girls)
05:52borkdudethe last two years I have put two groups of students (2 to 4) on a "research" project involving clojure
05:52borkdudethe first was about the differences in OO and functional approach to a common/random application
05:52borkdudethe second focussed more on web frameworks
05:53borkdudebut this year I want to have a similar group at work. any nice ideas about what they could research? they don't know clojure yet, only Java
05:53borkdudeso in the first few weeks I'll teach them clojure, and then they can go into something specific
05:56thorwilborkdude: at work? shouldn't that suggest some specific areas of interest already?
05:56borkdudethorwil education
05:57thorwilah, parsed with wrong context
05:57borkdudethorwil my mistake
05:58thorwilnah, no worries anyway
05:59thorwilto just throw something out: database -> text reports. think stock market or sport reports
06:03borkdudemaybe I could let them investigate smth about clojurescript
06:03borkdudebecause I don't know much about it myself yet
06:03borkdudemaybe they could port some libs as an exercise
06:04thorwili think yesterday someone asked about a clojurescript version of trammel
06:09borkdudeif you have any good ideas, please e-mail them to (apply str (interleave ["michiel" "borkent" "hu" "nl"] ["." "@" "." ""]))
06:16degWhat are good packages for doing chart/plot style graphics in Clojure? I'm looking at incanter now; which others are good too?
06:29babilendeg: I've used incanter, but it has serious problems with its charts and I abandoned it. I am currently playing with https://github.com/quil/quil which is a different approach
06:30babilendeg: If you find something good that is more like mathplotlib (Python), matlab or ... let me know. Clojure seems to lack a good graphing library
06:33babilendeg: See http://tgk.github.com/2012/11/visualising-gcse-statistics-using-datomic-and-quil.html for an example -- It is still a bit too "manual" for my taste, but that might just be because I haven't mastered processing yet
06:34degthanks.
06:34degWhat problems did you find with incanter?
06:34degThe first issue I hit is that I need a way to replace the contents of a chart from time to time (like a dashboard display) and that appears to be non-trivial, at best.
06:38babilendeg: A common issue is, for example, that graphs are not labelled ... This has been discussed on the mailing list and the "solution" was to use the underlying API directly. https://groups.google.com/forum/?fromgroups=#!topic/incanter/g2k2M6JllYE
06:39babilendeg: I also have the impression that incanter is a bit, well, undermaintained.
06:41bordatouehas anyone figured out a way to work with local jar files using lein ver 2 , in version 1 it was easy as the local requirement could be added to lib directory .
06:42bordatouei don't wat the local jar to be installed , it should be just temporary
06:43degbabilen: thanks. I'll look at quil and see what else I can find.
06:45xeqibordatoue: while not recommended, you can abuse :resource-paths for that
06:45bordatouexeqi seriously, you are picking up on me
06:50bordatouexeqi thanks ,
07:07ChironHi, where can i find a sample profiles.clj file ?
07:07FoxboronChiron, 2 sec and ill pastebin mine :)
07:08andrewmcveigh|woChiron: https://github.com/technomancy/leiningen/blob/master/sample.project.clj
07:08Chironthat is project.clj sample
07:08FoxboronO.o didnt know about those
07:09Chironi'm talking about .lein/profiles.clj
07:09andrewmcveigh|woAh, sorry. Reading blindness.
07:09Chironno, thanks any way :)
07:10babilenChiron: https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md -- Not sure if there is a sample as it very much depends on what /you/ want :)
07:10babilen(lein2 btw)
07:11Chironprofiles.clj isn't available for lein 1.7 ?
07:11babilenChiron: No
07:11thorwilall my profiles.clj contains is: {:user {:plugins [[lein-immutant "0.12.0"]]}}
07:22Chironit is deprecated :)
07:22ChironPlease use ~/.lein/credentials.clj.gpg instead.
07:23josteinkif I define an object as a map of keywords and functions
07:23josteink (def foo { :test (fn [x] (+ 1 x)) })
07:23josteinkdo I have to go ((:test foo) 1) or is there a shorthand I can use?
07:23josteinka special form?
07:24bordatouei find this lein really painfull, is there any other command to get detailed help on localrepo, when i type lein help localrepo ==> work with local Maven repository, is that it
07:24bordatoueis it something to do with my version of lein
07:25bordatouewhich is leing lines.
07:25bordatoue ^E or * Search multiple files (pass thru END OF FILE).
07:26bordatouesorry, lein 2.0.0-preview10
07:27mishok13hey guys, how would you achieve the following in Clojure: given a list of indices and a vector, extract a seq that contains items referenced by those indices?
07:28mishok13e.g. indices = [1 3], vector = [42 :foo 12 :bar :baz], result -- [:foo :bar]
07:29pyrmishok13: (map (partial nth my-vector) my-indices)
07:30pyr,(map (partial nth [:a :b :c :d :e]) [1 3])
07:30clojurebot(:b :d)
07:30mishok13thanks, pyr
07:30mishok13I started looking into some and juxt for some reason
07:31josteinkpyr: oooh. nice "trick" :)
07:32xeqibordatoue: try `lein localrepo`
07:33bordatouexeqi: is that the recommended way to get help
07:34babilenIs anybody aware of how the PDFs of the clojure cheatsheet are generated? The current version is horribly aligned and just unusable and I wanted to see if I can improve it.
07:36josteinklink?
07:36clojurebotyour link is dead
07:36babilenAlso: is https://github.com/jafingerhut/clojure-cheatsheets/ the source for the cheat sheet linked on http://clojure.org/cheatsheet
07:36josteinkhorrible or not
07:36babilenheh
07:37josteinkive seen bigger marvels of design
07:37josteinkbut still contains quite a bit of compact information :)
07:37xeqibordatoue: depends on how the plugin implements it, in this case it looks like localrepo built its own help system
07:37xeqiwhich would have been needed until recently
07:38bordatouexeqi: thanks very much, how would you go about getting help on lein
07:40xeqibordatoue: combination of `lein help`, https://github.com/technomancy/leiningen/tree/master/doc , sample.project.clj, and asking here or #leiningen
07:40xeqidepending on what you need help with
07:44ambrosebsThat's weird. It seems doing a `lein install` on a git project with zero commits gives this error: /home/ambrose/Projects/lein-typed/.git/refs/heads/master (No such file or directory)
07:44bordatouexeqi: finding it quite hard to get a grip on lein, i don't know where to start from. What would be the recommened way to understand lein
07:45ambrosebsWhoops, wrong room
07:46bordatouexeqi: i have got a set of depencies on one project A, i would like to have the same set of depencies when i create the second project, is there any way i could do it with manually editing project.clj
07:47xeqibordatoue: https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md ?
07:47xeqibordatoue: with or without?
07:47bordatouewith
07:47xeqicopy the :dependencies in project A's project.clj to project B's
07:51bordatouexeqi: there any way a project.clj file to refer to another project.clj file
07:51xeqinothing builtin
07:53xeqiand no plugins that come to mind
07:53bordatouexeqi: just one more question if i specify a directory under "resource-path" will it add all the .jar files under that directory
07:53xeqithough I can imagine a way to do it.. though its not great
07:54xeqibordatoue: no
07:55bordatouexeqi: so its a vector of files that i want to add to the class path .
07:56xeqiits meant to be a directory the jvm can use to find resources; adding jars is just abuse that happens to work due to the way the resources are added to the classpath
07:56xeqi* directories
07:58bordatouexeqi: thanks very much for your time
08:51gauravaghow do I iterate over a map with key value?
08:54xumingmingv,(for [[k v] {:james :bond :jack :rose}] [k v])
08:54clojurebot([:james :bond] [:jack :rose])
10:02maleghastAfternoon
10:03jcrossley3maleghast: morning! :)
10:04xeqitoday
10:07jsabeaudryWhat is the correct way to do this: (defn foo [& [{:or {b 10 c 15} :as all}]] (list (:b all) (:c all)))
10:07dysingerhrm. I'm trying to get paredit to automatically hook in on nrepl in emacs. it's not working. anyone have tips for me?
10:08broquaintWhat have you got at the moment, dysinger?
10:09bordatoue\who bordatoue
10:11dysingerbroquaint: I have (add-hook 'nrepl-interaction-mode-hook 'paredit-mode) which I found on stackoverflow.
10:13broquaintYou may want nrepl-connected-hook instead there, dysinger.
10:14dysingerah - I'll try it
10:14broquaintWFM at least :)
10:17dysingerthat didn't work for me :(
10:24dysingerbroquaint: yes that did work. I was doing it wrong.
10:24dysingerthanks!
10:24dysingeractually I added the hook to nrepl-mode
10:24dysingerseems to work
10:25dysingerwhere as connected-mode didn't
10:26mmitchellI just installed leiningen 2 as lein2, created a new project, but "lein2 deps" doesn't seem to do anything at all?
10:27mmitchell"lein2 test" works, hmm
10:27babilenmmitchell: Have you actually added any dependencies for which something needs to be done?
10:27mmitchellbabilen: yes, a few of them
10:27xeqimmitchell: lein2 uses jars from your ~/.m2 cache
10:27xeqiif you have them there already it doesn't do anything
10:27mmitchellxeqi: so it doesn't put anything in your project's lib dir?
10:28babilenmmitchell: And have they already been downloaded? Dependencies are handled differently in leiningen2 in that it uses a central repo for all projects
10:28xeqialso, `lein deps` should get called automatically when needed, you shouldn't have to manually invoke it
10:28xeqimmitchell: correct
10:28babilenmmitchell: No, $proj/lib is not used anymore
10:28mmitchellahh nice. OK all is well then. I just launched the repl without problems
10:28mmitchellthanks!
10:29babilenmmitchell: Do you actually have a problem that is caused by missing dependencies or did you just expect lein2 to behave like lein1?
10:29mmitchellbabilen: i was expecting it to behave like v1
10:29RaynesBut then it wouldn't be lein 2!
10:30babilenack - well, there have been quite some changes. You might want to read https://github.com/technomancy/leiningen/wiki/Upgrading
10:30mmitchellRaynes: exactly!
10:31mmitchellbabilen: thanks, I'll check that out
10:32mmitchellI want to create a few tasks in my project. Is it possible to use code from my project in the tasks? Is there a wiki page somewhere for creating custom lein tasks?
10:34xeqimmitchell: lein2 keeps a good seperation between the project jvm and lein jvm
10:34xeqiusually tasks go in plugins, but if they *really really* are project specific https://github.com/technomancy/leiningen/blob/master/doc/PLUGINS.md#project-specific-tasks
10:35mmitchellxeqi: yeah, these are definitely project specific
10:45enigmetaIs there an easy way to flatten one "level" of a nested structure?
10:45enigmetaI have something like: [[[1 2] [3 4]] [[5 6] [7 8]]]
10:45enigmetaAnd I would like: [[1 2] [3 4] [5 6] [7 8]]
10:46tufflaxMaybe concat?
10:46tufflax,(apply concat [[[1 2] [3 4]] [[5 6] [7 8]]])
10:46clojurebot([1 2] [3 4] [5 6] [7 8])
10:47enigmetaThanks! (apply concat [...]) seems to work. I was looking for something called "combine".
10:47tufflaxHm, did you get that from another language or something?
10:48enigmetaNo, just guessing.
10:48tufflaxok :p
10:48jballancAnyone know if clojurebot or lazybot's source is available somewhere?
10:48tufflaxjballanc, i think they are, search github
10:49jballanchmm...there's a few forks looks like
10:52ChironHi, are Clojure functions serializable ?
10:54nDuffChiralSym: not out-of-the-box, but see https://github.com/technomancy/serializable-fn
10:54nDufferr
10:54nDuffChiron: ^^
10:55chronnojballanc: http://www.clojure-toolbox.com/ look under "IRC Bots"
10:55nDuff...or do you mean implementing Serializeable?
10:55ChironnDuff: thanks!
10:56Chironi mean implementing Serializable
10:58nDuff,(supers (class (fn [] 1)))
10:58clojurebot#{java.lang.Runnable clojure.lang.IObj clojure.lang.Fn clojure.lang.AFunction clojure.lang.AFn ...}
10:59nDuff...ahh, the bot doesn't print the whole thing -- but java.io.Serializable is there.
10:59Chironfirst time i know about supers
10:59Chironsuper!
10:59jweissis it possible to add an interface implementation to someone else's record type?
11:00jweissextend-type requires a protocol, not an interface
11:00jules2is there a way to get basic clojure out of clojurescript, with all macros expanded, stdlib imported, etc., but without any javascript bits?
11:02FoxboronIs there any great way on Windows to reduce Clojure startup time?
11:02FoxboronGoogling around but wanna see what people recommend ^^
11:03RaynesNot really.
11:03ambrosebsChiron: see also `bases` and `ancestors`
11:03RaynesThe JVM is slow to start up. Not really a way to mitigate it.
11:03Chironthat could be changed in JVM 9 ?
11:04RaynesI guess. Pigs could also grow wings eventually, given evolution.
11:04FoxboronI know drain stores the stuff in memory so the overall startup time is reduced by 1 sec, but its not available on windows :/
11:04Raynesdrain?
11:04FoxboronLemme find source :)
11:04RaynesYou mean drip?
11:05Foxboronwas it drip..? hmm
11:05RaynesIt doesn't work like that though.
11:05Foxboronah, drip.
11:05RaynesAll drip does is start a new jvm when you run a command, warming it up for your next command. It gives the appearance of fast startup time by having a JVM already running when you're ready to use it.
11:05noooooIf I have a list of 2-element vectors, is there a more idiomatic way of transforming them into a map then just reducing across the list?
11:05RaynesIt could also probably be ported to Windows if someone cared enough.
11:06FoxboronRaynes, i see. I'll try google some more.
11:06Chironambrosebs: thanks!
11:07ambrosebsChiron: np
11:08nDuff,(into {} [[:a :b] [:c :d] [:e :f]])
11:08clojurebot{:a :b, :c :d, :e :f}
11:08nDuffnooooo: ^^^
11:09scriptornDuff: what about it?
11:09nDuffscriptor: it's an answer to nooooo's question
11:09scriptorah, heh
11:10jsabeaudryIs there a lein-outdated that also checks plugins?
11:18PudgePacketwhere can i find info about string manipulation with clojure ?
11:20nDuffPudgePacket: http://clojure.github.com/clojure/clojure.string-api.html and http://docs.oracle.com/javase/6/docs/api/java/lang/String.html are the bulk of what there is.
11:20nDuffPudgePacket: Looking for anything particular?
11:21nDuffPudgePacket: ...well, you might also see the "strings" section on the cheatsheet at http://clojure.org/cheatsheet
11:22jweissis there a way to extend ILookup to other types so that when i do (:mykeyword theirtypeobj) i get my own behavior for the lookup?
11:29nDuffjweiss: Unfortunate that ILookup isn't a protocol -- that _would_ be shiny, but I don't think it's possible.
11:29jweissdarn, was hoping there was some avenue i was missing.
11:30jweissi wonder if there's any plan to make some of the internal interfaces into protocols?
11:36dnolenjweiss: a JVM backend for CLJS would be a good start ;)
11:37dnolenBronsa: have you considered putting Blind into contrib - it would be nice to have all the necessary pieces for bootstrapping in contrib.
11:43Bronsadnolen: honestly, I hadn't thought about it
11:45dnolenBronsa: I'd definitely +1 that. Would love to switch ClojureScript to use a pure Clojure reader that doesn't have to wait for modification to the Clojure one.
11:47Bronsadnolen: ok, i will check out what's the process to get it into contrib and do it in the next few days
11:47dnolenBronsa: sweet, not much beyond pinging the dev ML really. I'd get behind it and I'm sure all the folks doing tooling (LightTable) would too.
11:48Bronsawhat should the contrib name be then?
11:49dnolenBronsa: I'm sure that can get sorted on the ML - tools.reader ?
11:49Bronsammh, yeah
11:49scriptorcljs's reader isn't pure clojure already?
11:49abpneat :D
11:50dnolenscriptor: cljs reader just does EDN, we want a full Clojure source reader
11:51Bronsadnolen: the fact is, blind is currently an order of magnitude slower than clojure's reader
11:51scriptorah, all cljs is valid EDN, right?
11:51Bronsaand i suck at profiling.
11:51abpdnolen: Wouldn't it be much easier and more expandable to do closure style dead code elimination in clojure?
11:51dnolenBronsa: order of magnitude isn't a bad start - I'm sure we can optimize. Even then - I seriously doubt that time would dominate analysis, compilation etc.
11:52scriptorBronsa: your repo mentioned that it used to be faster?
11:52Bronsayeah
11:52scriptorany idea around when the slow-down started to happen?
11:52Bronsasadly, no
11:52dnolenabp: I have no idea - never looked at tree-shaking. But yes, it would be nice to have some system for compiler passes for pluggable optimizations.
11:52scriptorhmm
11:53scriptorI guess theoretically it's possible to take a repo and go through it from the first commit, all the while running benchmarks, it'd be cool to automate that
11:53scriptorbe hell to do it manually
11:53Bronsascriptor: i was so dumb that i didn't use git.
11:53nDuffsounds like the kind of thing git bisect is good for.
11:53dnolenBronsa: fortunately it's not that much code
11:54Bronsaif i did, i would have already done that
11:55dnolenthe most loved CLJS commit yet http://github.com/clojure/clojurescript/commit/cd66e6b9e63ad5ef1896a9c7a117148beb04301d
11:57eggheadoh nice dnolen
11:58eggheadmight be time to give cljs another shot
11:58dnolenegghead: source map work is moving along - getting close
11:59eggheadlast time I tried I was turned off by having to marshall clj -> js/dom back and forth when using gclosure stuff
11:59eggheadis everyone just using jayq these days?
12:00eggheadI think I will pick up http://shop.oreilly.com/product/0636920025139.do
12:01dnolenegghead: I know that ibdknox has moved on to a much lighter weight solution - jQuery is dead weight.
12:01dnolenIMO
12:02eggheadya I didn't want to add it, especially since it can't eliminated by gclosures tree shaking, but last time I used cljs it was just so painful to have to write helper functions over around every dom interaction
12:03eggheadthat commit looks like it'd get rid of a lot of that boilerplate, however :)
12:04dysingerwhat's the point free version of haskell's flip in clojure again? I'm super rusty
12:06eggheaddysinger: flip reverses the argument order?
12:10technomancydysinger: you have to pull in useful for flip
12:10technomancyalso, hey
12:11eggheadtechnomancy: does useful have any documentation anywhere
12:12technomancynot sure
12:13eggheadat least it's got a full test suite :3
12:13RaynesIt has docstrings.
12:14RaynesWhether or not they're useful depends on whether or not amalloy_ or ninjudd was putting the function in there because they wanted to use it in two different projects without duplicating effort and get it all done in 5 seconds or if they honestly thought other people would use it.
12:16eggheadheh, thanks Raynes
12:16seangrove,(apply str (interleave ["a" "b" "c"] ["." "-" "."]))
12:16clojurebot"a.b-c."
12:16seangroveWow, cool stuff
12:17RaynesFar out and funky.
12:17egghead,(apply str (interpose ["a" "b" "c"] ", "))
12:17clojurebot",[\"a\" \"b\" \"c\"] "
12:17eggheadoops
12:17egghead:)
12:18Raynes&(clojure.string/join "," [\a \b \c])
12:18lazybot⇒ "a,b,c"
12:19eggheadhmm, kind of cool that interpose considered ", " as a list of chars
12:19RaynesWell, it is.
12:19RaynesIf you call seq on it.
12:19Raynes&(seq ",")
12:19lazybot⇒ (\,)
12:21eggheadaah, didn't know interpose was defined in terms of interleave either, neat
12:28kevincolyarI'm writing a simple ray tracer to learn clojure... what would you guys recommend I use to store screen of rays/pixels? A 2d vector of refs?
12:28abpIs there something like a unified "jump to line in file"-url invoker for existing editors and IDEs? With wich editors is this even possible?
12:29seangroveabp: you mean jump to line in either a fil or a url?
12:29seangrovefile*
12:29qerubabp: For the record, TextMate has txmt://open?url=…&line=…&column=…
12:29abpseangrove: No, communicating, please jump to line x in file y. To an editor, programmaticaly.
12:30abpqerub: Noted. Just in case I need to write that by myself. :x
12:34dnolenkevincolyar: I would just use Java arrays for a raytracer.
12:39kevincolyardnolen: I'm not worried about performance right now, just learning clojure.
12:41dnolenkevincolyar: I wouldn't use refs, probably one big vector of ints.
12:44kevincolyarI'm kind of stuck trying to figure out the best way to update the state of the screen when I cast each ray
12:45wingyi am converting a curl request to cljhttp code . is this correct https://www.refheap.com/paste/6892
12:45dnolenkevincolyar: you can treat the vector just like you would an array. (set-pixel vector-of-ints x y new-value)
12:45wingyim not sure about the attachment field
12:45abpHm, I can't use e* on lein repl with Clojure 1.5.0 Beta1?
12:45dnolenkevincolyar: use x and y to index into the array, and update it with assoc.
12:45dnolen,(assoc [0 1 2 3] 0 5)
12:45clojurebot[5 1 2 3]
12:47kevincolyardnolen: ahh, i thought could only use assoc with maps
12:49dakronewingy: no, you need to look into :form-params. you also have two basic-auth things when only one is needed
12:49kevincolyardnolen: wont that give me a new vector each time since it's immutable?
12:50kevincolyardnolen: seems like i could be updating the vector via a reference type
12:50wingydakrone: oh yeah i missed that i already added one basic auth
12:51ghadishaybananyone know what happened to fill-queue from old contrib?
12:52dnolenkevincolyar: if you want understand Clojure - this is what you want to do. you can probably construct your raytracer so that it doesn't need any real mutation at all.
12:52wingydakrone: seems that i need to use :multipart and not :form-params in this case since its sending files
12:52wingyhttps://github.com/dakrone/clj-http
12:53dnolenkevincolyar: that in fact should be constraint - can you construct the raytracer without using reference types.
12:53dnolen"should be the constraint"
12:54dakronewingy: it depends on what your server is expecting
12:54dakronecurl's -F is :form-params I beleiev
12:54dakrone*believe
12:54wingydakrone: ok
12:55kevincolyardnolen: cool, i'll give it a try. thanks for the help
13:03alexnixonkevincolyar: I wrote a raytracer in clojure on a hackday, it used a for comprehension over x and y values, and a function taking the pixel x y and returning a color
13:24kevincolyaralexnixon: it used a?
13:27lynaghkkevincolyar: I think he meant a "for comprehension". In Clojure for is a list comprehension that returns a value, not a control flow operator like in other langugaes
13:28lynaghk,(for [x (range 3) y [:a :b :c]] [x y])
13:28clojurebot([0 :a] [0 :b] [0 :c] [1 :a] [1 :b] ...)
13:28kevincolyarlynaghk: ah, ok
13:28dnolenlynaghk: thanks for patch - one unimportant enhancement would be to throw on the presence of lvars in map keys - but it's not critical.
13:30lynaghkdnolen: I did that initially, but I realized it would take quite a bit of change in the implementation and thought it'd be worth some discussion
13:31lynaghkdnolen: i.e., to support that you would need to seq over all of the keys of the target map and try to unify each one with the key-in-hand of the source map.
13:32dnolenlynaghk: like I said - would be nice - but not a priority.
13:32lynaghkdnolen: ah, sure. yeah, I'd wait til you get some feature requests about it before throwing unifier perf out the window =P
13:33lynaghkdnolen: thanks for the fast merge turnaround, btw.
13:34abpHey lynaghk, how can I render directed svg-graphs with c2?
13:34abplynaghk: Would that be hard? I have basically no expierience with writing visualization algorithms.
13:34lynaghkabp: there isn't a graph layout engine in c2, if that's what you're asking about. If you're using c2 on cljs you can just use the force-layout engine from d3
13:35lynaghkabp: though in that case you would need to use mutable javascript objects since D3's engine just has a tick routine and updates the x and y properties of graph objects.
13:35abplynaghk: Not cljs only.
13:36abplynaghk: And that's something I can't imagine to consider.
13:36lynaghkabp: graph layout is a very tricky problem; I'm not sure what's avaliable on the JVM side---you could probably do the layout calculations with graphviz
13:37lynaghkabp: A friend of mine at AT&T research also mentioned that there are some really good new algorithms based on shortest-path distances rather than the physics-y stuff
13:37abplynaghk: Yes, I render svg now using lacij, but that's just to inflexible. Undocumented wrapper of a bunch of java-libs. A big bunch actually.
13:37lynaghkabp: but yeah, if you can get a list of nodes and connections with x & y coordinates already you can use c2 to draw them in SVG no problem. Take a look at the c2 svg namespace for some arc generation stuff
13:39dnolenlynaghk: on thought about yesterday's conversation - perhaps it would be uniform to only have symbols or vectors of symbols on the left handside instead of fns as keys.
13:42lynaghkdnolen: I'm not sure you'd be able to support all possible constraints in that case
13:44lynaghkdnolen: say you have predA and predB that both constrain vars ?x and ?y. If you allow functions on the left you can say {predA [?x ?y], predB [?x ?y]}. If you don't allow functions on the left, how could you express it?
13:45lynaghkdnolen: {[?x ?y] #(and (predA %1 %2) (predB %1 %2))} ?
13:46dnolenlynaghk: yes
13:48lynaghkdnolen: I think each of the syntaxes we've discussed has some awkward situations. Making lvars or vectors of lvars the map keys seems as good as any to me.
13:49lynaghkdnolen: sugar-wise, maybe people will want to write {#{?x ?y ?z} numeric?} to mean that those three vars should all be numeric
13:49lynaghkdnolen: but that's just something nice to have instead of having to write {?x numeric?, ?y numeric?, ?z numeric?}
13:50lynaghkdnolen: the thing I do like about having functions as keys in the constraint map is that it makes it easier for people to add/remove classes of constraints.
13:50dnolenlynaghk: yes special handling of set keys would probably be ok. I just want what appears on the left hand side to be consistent - vars or collections of vars.
13:50lynaghkdnolen: in my use case I can imagine wanting to talk in terms of constraint predicates more often than talking in terms of individual variables or sets of variables.
13:52seangroveAre there any cljs interface libraries wrapping goog.ui.*?
13:52lynaghkdnolen: also, I tend to have a nicer handle on predicate fns (which are usually toplevel vars created by defn) than I have on lvars (which I don't usually have a reference to at all---they're created for me by prep)
13:53dnolenlynaghk: yeah I don't really see any expressiveness issues here - just going for consistency.
13:53dnolen{?x numeric?
13:53dnolener
13:54dnolen{'?x numeric? '[?x ?y] complex-constraint}
13:54lynaghkdnolen: yeah, I agree with you on consistency. Now it's just a question of whether we want to talk in terms of lvars or constraints
13:55lynaghkdnolen: this is something that folks can solve for themselves using clojure.set/map-invert, though.
13:56dnolenlynaghk: yep, it's also about making it simpler / cleaner to process.
13:58lynaghkdnolen: is one of these forms easier to handle internally?
13:58lynaghkdnolen: I'd have thought in either case you are just doing something like (doseq [[vars pred] constraint-map] ...)
14:03trinakriaHello
14:05dnolenlynaghk: no it's not a matter of easier to handle - it's about picking just one thing, also it's pattern everywhere in core.logic for vars to appear on the left hand side
14:05dnolenwhether in substititons or when calling bindings-map etc
14:05lynaghkdnolen: that's good enough for me, then; lvars or collections of lvars on the left, preds on the right
14:06dnolenlynaghk: I agree that at first glance constraints on left seem ok, but I think in the long run systemic consistency trumps conveniences.
14:07lynaghkdnolen: agreed; as I said, if it's a big enough problem consumers can manipulate the constraint maps themselves.
14:07lynaghkdnolen: good call on that vs. metadata.
14:07dnolenlynaghk: yes :)
14:12bbloomdnolen: how do you maintain the cljs version of core logic?
14:12bbloomdnolen: i want to release a lib for both clj and cljs, but i'm not super excited about the idea of copy pasting a whole file and then extracting the macros
14:13dnolenbbloom: copy & paste
14:14bbloomdnolen: :-(
14:14lynaghkbbloom: you can check out my cljx leiningen plugin. It's a hack, but so is every other solution to that problem.
14:14bbloomdnolen: I'm almost positive I could pull this off with make and sed ...
14:14dnolenbbloom: not much to be done until we get compiler support for feature expressions.
14:15bbloomdnolen: so i was following the feature expressions discussion
14:15bbloombut i wasn't sure why that couldn't be added as a macro
14:16SgeoI think nREPL might be a bit slow for me
14:16bbloomKevin Downey pointed on in that thread that common lisp's issues don't affect clj here
14:16SgeoSometimes if I leave it running for long then do something it takes a while
14:16seangrove<p class="integration_menu full_contact_integration_menu active" style="top: 54.80000305175781px; overflow: hidden;"><div class="link_list_menu">
14:16seangrove <h3>FullContact Profile</h3>
14:16seangrove <div>
14:16seangrove Social Profiles <small>(91% confidence)</small>
14:16seangrove <table class="zenbox-table">
14:16seangrove <tbody><tr>
14:16seangrove <td class="link-action">
14:16SgeoI tried (time (+ 1 1)) and it said it took 22 ms but it seemed on the order of seconds.
14:16seangrove <span class="social vimeo">
14:16SgeoSo what's going on
14:16seangrove <img src="https://www.zenboxapp.com/assets/service_icons/vimeo.png&quot;&gt;
14:16seangrove </span></td>
14:16seangrove <td>
14:16Sgeoseangrove, /flushq
14:16seangrove <a href="http://vimeo.com/user9118251&quot; target="_blank">user9118251</a>
14:16seangrove </td>
14:16seangrove </tr>
14:16SgeoThen use a pastebin
14:17seangrove <tr>
14:17seangrove <td class="link-action">
14:17seangrove <span class="social plancast">
14:17seangrove <img src="https://www.zenboxapp.com/assets/service_icons/plancast.png&quot;&gt;
14:17seangrove </span></td>
14:17seangrove <td>
14:17seangrove <a href="http://plancast.com/yayitswei&quot; target="_blank">yayitswei</a>
14:17Sgeo@ops
14:17Sgeo~ops
14:17clojurebotGabh mo leithscéal?
14:17seangrove </td>
14:17seangrove </tr>
14:17seangrove <tr>
14:17uvtcHow did all this html get in here? :)
14:17seangrove <td class="link-action">
14:17seangrove <span class="social facebook">
14:17seangrove <img src="https://www.zenboxapp.com/assets/service_icons/facebook.png&quot;&gt;
14:17seangrove </span></td>
14:17seangrove <td>
14:17seangrove <a href="http://facebook.com/yayitswei&quot; target="_blank">yayitswei</a>
14:17seangrove </td>
14:17seangrove </tr>
14:17nDuffSomeone mention when the flood is over so I can unignore. :)
14:17seangrove <tr>
14:17seangrove <td class="link-action">
14:18seangrove <span class="social gravatar">
14:18seangrove <img src="https://www.zenboxapp.com/assets/service_icons/gravatar.png&quot;&gt;
14:18seangrove </span></td>
14:18seangrove <td>
14:18seangrove <a href="http://gravatar.com/yayitswei&quot; target="_blank">yayitswei</a>
14:18seangrove </td>
14:18seangrove </tr>
14:18seangrove </tbody></table>
14:18seangrove </div>
14:18seangrove</div>
14:18seangroveahem...
14:18seangroveSorry about that... command-v right next to M-v
14:18mefistonDuff: flood complete
14:18seangroveJust meant to scroll up
14:18seangroveI pasted instead of hitting M-v (in erc)
14:18bbloomdnolen: lynaghk: https://www.refheap.com/paste/6896
14:18SgeoOh
14:19SgeoDoes ERC have an equivalent to XChat's flushq?
14:20dnolenbbloom: dunno just seems uglier than CL syntax for that.
14:20SgeoWho was Nosrat and why was e telling me not to say bullsh*t?
14:20bbloomdnolen: what does feature expressions buy us except for splice?
14:20SgeoOnly noticed it now
14:20SgeoName seems familiar
14:21dnolenbbloom: shipping one code base to multiple implementations of Clojure
14:22nDuffSgeo: a bot that said the same thing to everyone, and not just in this channel.
14:23Raynesseangrove: You are hereby exiled from all of Clojure. Begone.
14:23RaynesIf you're going to flood the channel, at least do it with Clojure and not HTML.
14:23hiredman`Kevin Downey is me, fyi
14:23seangroveI just see HTML as a subset of Clojure
14:23Apage43What about hiccup?
14:23bbloomlynaghk: I saw cljx, but I'm going to refrain from using it so that i don't need to manually change all that stuff when a real solution comes along :-P until then, i'll just ignore the jvm for this one task
14:25lynaghkbbloom: yeah, for sure. I wrote it to get some stuff out the door, but I'll be the happiest of anyone to tear that shit down once a real solution lands in core = )
14:26bbloomlynaghk: lots blocking a "real solution" sadly. from the simple (there needs to be a uniform way to raise an error) to the complex (macro system)
14:27hiredman`I would much rather "feature expressions" introduce a new special form or macro than make backwards incompatible changes to the reader
14:28SgeoOoh, feature expressions coming to Clojure soon?
14:28bbloomSgeo: no change on status, just discussion
14:34bbloomdnolen: i want to extend IMeta and IWithMeta to javascript functions. if I just do a simple aset/aget with a "__meta" string on the function, would that destroy perf? or be relatively harmless?
14:35dnolenbbloom: won't work because of advanced optimization, ohpauleez has a proper patch
14:35bbloomdnolen: although i think i might prefer to do a little wrapper object that implements IFn
14:36bbloomdnolen: ah. is there a ticket for it?
14:36dnolenbbloom: yes
14:36bbloomfunny how we all run into the same issues :-)
14:38hiredman`metadata on functions is kind of gross
14:38bbloomhiredman`: why?
14:38hiredman`there are identity issues
14:39bbloomi have a hash table of symbols to functions and a *small* percentage of functions are going to have some metadata on them
14:39hiredman`functions have identity equality, but at least with clojure functions implement the same metadata stuff as values
14:39bbloomi basically want to ask (-> f meta :some-flag) on dispatch
14:39hiredman`not the reference metdata stuff
14:40bbloomhiredman`: ah. yeah, dnolen mentioned ohpauleez' patch, which i found has this wrapper object: https://github.com/shoreleave/shoreleave-core/blob/master/src/shoreleave/efunction.cljs
14:40SgeoWhen they should be on functions
14:40bbloomhiredman`: seems to be lacking equality
14:41hiredman`yeah, you cannot do equality
14:41hiredman`because adding metadata returns a "new" wrapper function with the metadata
14:41hiredman`so, as I said, gross
14:41bbloomhiredman`: couldn't you just define equality on the wrapper and the built in and make them co-dependent? when comparing, just compare the unwrapped functions
14:41technomancythat's not metadata's fault
14:41bbloomhiredman`: doesn't seem to gross
14:41technomancyit's clojure's fault for doing a crappy job of equality
14:41bbloomtoo*
14:41SgeoIf you comp a bunch of functions, the result should have the same argslist as the first function to be applied.
14:42Sgeoarglists
14:42amalloySgeo: and indeed it does, in that neither of them have an arglist key
14:42bbloomamalloy: heh.
14:42amalloy(or, indeed, any metadata at all, on the function object)
14:43bbloomSgeo: consider type hints too. you'd want the arglist of first and the return type hint of the last. the comp function suddenly gets quite expensive and complex....
14:45SgeoI don't see a problem with comp doing that, but I guess it could be a PITA dealing with similar considerations for people writing their own functions?
14:46llasramTyped Clojure to the rescue?
14:46bbloomSgeo: the performance cost would add up. quick. and you'd have to either A) throw away unknown keys or B) have a mechanism for comping them
14:46bbloomB implying an *open* mechanism
14:46technomancyllasram: I don't want to have to annotate everything to get simple things like that
14:46bbloomseems absurdly complex and yes, llasram, get's into the typing world :-)
14:47bbloomdnolen: if i took a crack at a function wrapper object with meta and equality working correclty, would you take that patch? :-)
14:48llasramI really agree with technomancy, but it seems like a type system is the endgame. Otherwise every function-returning function is doing the same legwork to correctly generate and propogate metadata
14:48llasramOr just live without it :-)
14:48bbloomI'd argue that (let [f (fn)] (= f (with-meta f {:x 1}))) is bugged in clojure
14:48technomancyclojure just needs better inference built-in
14:51technomancybbloom: with serializable-fn you could theoretically have equivalence between two functions that do the same thing but have different argument names
14:51Sgeotechnomancy, um, not really?
14:51technomancythough of course true operational equivalence is undecidable
14:51technomancySgeo: ?
14:51Sgeotechnomancy, was thinking of operational equivalence
14:51bbloomtechnomancy: yeah, down that path lies dragons :-P i just want reference equality to work with-meta
14:56dnolenbbloom: I'm not in the least bit concerned about equality.
14:57dnolenbbloom: if the patch supports Clojure's behavior that's good enough for me.
14:57bbloomdnolen: ok, let me take a crack at it
14:58dnolenbbloom: or look at the ticket and just implement ohpauleez's code
14:58bbloomdnolen: yup, i see his code. was going to grab that and then extend-protocol to function & should be done
15:04bbloomdnolen: presumably fn? should work too
15:04dnolenbbloom: does it work in clojure>
15:05dnolen?
15:05bbloom#(fn? (with-meta (fn) {:x 1}))
15:05bbloom,(fn? (with-meta (fn) {:x 1}))
15:05clojurebottrue
15:05bbloomyup
15:06dnolenbbloom: you could make a marker protocol Fn, and change fn? to check that too
15:07bbloomdnolen: good idea
15:11bbloom,(let [f (fn)] (= (hash f) (hash (with-meta f {:x 1}))))
15:11clojurebotfalse
15:11bbloomdnolen: gonna ignore hashcode too then
15:18bbloomdnolen: core.cljs is kinda hard to navigate… kinda wished it was divided up and layered :-/
15:18abpPeriodically posting, just in case anybody likes to yell at me for it: https://gist.github.com/4115467
15:19dnolenbbloom: would require something like load which doesn't exist - even then not sure if it's worth it.
15:30bbloomdnolen: the file is large enough to slow down vim, presumably due to some slow parens/ident logic in vimclojure…. where's tpope when you need him? :-)
15:31dnolenbbloom: heh I don't have that problem
15:34dnolenjamii: looking forward to your presentation!
15:37bbloomdnolen: debugging advanced mode is still making me want to weep. we need source maps and we need them tied into the assert mechanism badly :-) gg get lunch before i do battle with single letter variable names
15:37dnolenbbloom: heh yep working on that right now
15:42jamiidnolen: :-S
15:52thorwil"Could not locate tlog/test/data/account__init.class or tlog/test/data/account.clj on classpath"
15:53thorwilhow's the stuff below "test" handled, different from "src"?
15:53defanew to emacs/nrepl… after adding deps to lein's project.clj, how to make them available inside emacs nrepl? Need to run "lein repl"? After connecting to the new nrepl evaluating expressions sometimes does not work and I have to restart emacs. Am I missing something essential here?
15:55thorwildefa: there are several ways to run an nrepl server
15:56thorwildefa: if evaluating an expression does not work, you should get an error message. you can close error buffers. no need to restart emacs
15:57thorwildefa: you repl session is in a namespace. starts in "user". you can do (in-ns project.your.ns) to switch into one o fthe namespaces defined in your clj files
15:58defathorwil: terhmial: "lein repo" emacs M-x nrepl … after adding a dependency to project.clj how do I make these symbols available in emacs nrepl?
15:58defathorwil: I ment "lein repl"
15:59Hodappthorwil: didn't know you were here, haven't seen you since #lad...
16:00thorwildoesn't "lein repl" start a server and client right there? haven't used it in a long time
16:00thorwilHodapp: heh, if i'm here, i'm also in #lad
16:00Hodapphaven't been in #lad in awhile
16:01thorwildefa: the repl works with namespaces just like in your clj files. besides the ns form, you can use "use" and "require"
16:02thorwilstill wondering how i get my test file unto the classpath
16:03defathorwil: it's not a namespace issue… thanks anyway.
16:04thorwildefa: there seems to be a misunderstanding
16:05defathorwil: never mind… I'll find out… something like: http://immutant.org/builds/LATEST/html-docs/interactive.html#sec-4
16:10llasramdefa: That's an immutant-specific feature. You can do it yourself piecemeal by pulling pomegranate into your dependencies, but AFAIK there isn't a general-purpose "reload by project.clj deps w/ restarting the REPL server" library
16:11xeqiritz has something similar
16:11xeqithey all suffer from possibly loading incompatible libraries
16:11thorwildefa: i assumed the case where the dependencies are actually in place. whenever i add a dependency here, i restart immutant, to be honest :/
16:12llasramOh yeah, that's right! I need to try that. I think it didn't stick because it blew up during hugod's Conj talk *sadface*
16:12defaxeqi: okay, thanks… good to know… so simply start "lein repl" again in reconnect in emacs?
16:13xeqiI use M-x nrepl-jack-in rather then `lein repl` and M-x nrepl, but either way works
16:13jcromartie~seen ignacy
16:13clojurebotexcusez-moi
16:14thorwilxeqi: nrepl-jack-in starts an nrepl server, right? if so, it's the wrong choice for immutant which provides ones
16:15xeqithorwil: I didn't think `lein repl` was a choice for using immutant anyways; though it started its own nrepl server
16:15xeqitcrawley: ^ ?
16:15hugodxeqi: ritz is supposed to check if any of the dependencies have been replaced, and create a new instance of the clojure runtime if so
16:16tcrawleyxeqi: correct. nrepl-jack-in/lein repl will not work with immutant, since you have to deploy to it with nrepl enabled for the app
16:16tcrawleyat that point, it starts an nrepl server for you
16:16thorwilxeqi, defa : yes, it's "lein immutant run" and just "nrepl" in emacs
16:16tcrawleyif you aren't in immutant, I recommend ritz
16:17Foxboronmmm, Going to buy 2 clojure books. The Joy of Clojure and Programming Clojure should be the two best for a beginner?
16:17xeqiI recommend http://www.clojurebook.com/
16:18UrthwhyteFoxboron: I really enjoyed Programming Clojure and am starting Joy this weekend
16:18Foxboronumm, yeah. I mixed Programming Clojure with Clojure Programming...
16:18Urthwhytethe former + my roommate had me up and running in a few days
16:18FoxboronLike srsly, why did they name those two books the same?
16:19cemerickWe unfortunately had no input on the name. :-(
16:19RaynesTheyd idn't.
16:19cemerickxeqi: and, thanks :-)
16:19technomancycould be worse; could be Programming Scala
16:19Raynescemerick: As if you don't pay him each time he says that.
16:20Foxborontechnomancy, what about programming php?
16:20cemerickxeqi: Your 25¢ is in the mail!
16:20SgeoI like what I've read of The Joy of Clojure
16:20xeqihurray!
16:20technomancyclojurebot: Programming Scala is <reply>wait, do you mean Programming Scala, Programming Scala, or Programming in Scala?
16:20clojurebotscala is val foo = bar ~-> 45 <~< "Fred" %% x
16:20technomancyaw come on
16:20technomancyclojurebot: Programming Scala |is| <reply>wait, do you mean Programming Scala, Programming Scala, or Programming in Scala?
16:20clojurebotflatten |is| rarely the right answer. What if your "base type" is a list
16:20brehautcemerick: the side effect of having no control on the name is that everyone refers to it by domain
16:20technomancyclojurebot: jerk
16:20clojurebotyou cut me deep, man.
16:21Urthwhytebrehaut: but there's no do before it
16:21SgeoWhat should I name a converter function?
16:21FoxboronIf there is any Sublime uesers here, i just updated my collection of snippets with new triggers. Should be easier to type them naow :3
16:21Sgeoflat-to-shaped, or shaped<-flat (the latter is a convention I saw somewhere, which makes sense I guess if you're nesting)
16:21cemerickbrehaut: Indeed; it should have just been titled "The Clojure Book", and everything would have worked out nicely.
16:22Sgeoor flat->shaped and just use -> for nesting?
16:23brehautUrthwhyte: err…?
16:25Urthwhytebrehaut: it was a joke - you said there was a side effect of naming it in that manner, so I was riffing on the need for a do for functions with side effects
16:25brehautUrthwhyte: ah. well thats wrong. you do not
16:26brehautUrthwhyte: you need a dosync to do STM transactional side effecting stuff, but any function can just go ahead and mutate anything anywhere
16:28amalloySgeo: flat->shaped is by far the more common if you're choosing from those three options
16:28brehaut,(repeatedly 5 #(rand-int 5)) ; Urthwhyte, side effects without do
16:28clojurebot(1 1 3 2 0)
16:28Sgeoamalloy, well, if there are other options for the name I'm open to them
16:28SgeoI'm not really restricted here, except ideally the name should be clear
16:28amalloyor you could just call it shaped, or something equally basic, if in context that still makes sense
16:29SgeoWell, there's no other conversions except shaped->flat, but I want to refer to the results as flat or shaped, so
16:29SgeoClearer to just use the longer name
16:30gfredericksbrehaut: how about (println "foo")?
16:30brehautgfredericks: well yes obviously that too
16:33technomancyeh; non-referentially-transparent functions aren't necessarily side-effecting
16:33bbloomdnolen: http://dev.clojure.org/jira/browse/CLJS-359
16:34gfrederickstechnomancy: I was just having a side-argument with him about that
16:34technomancyside-argument? are you in new zealand?
16:34gfredericksno; the internet has other communication channels
16:34technomancylies
16:34gfredericksbut now that you've taken my side I think that means I get 15 kiwi-points
16:35technomancyredeemable for delicious kiwi at any roadside stand?
16:35gfredericksnot sure yet
16:35brehautwait, you people eat kiwis‽
16:35gfredericksI love how much I have no idea if he's actually surprised
16:35technomancyoh did I say that out loud; oops
16:36brehautgfredericks: but they are endangered
16:36dnolenbbloom: I don't think we should use a Function type, just use reify for now.
16:36gfredericksthey make the bald-eagle tacos a little less bland
16:37bbloomdnolen: ok
16:40bbloomdnolen: hmm that makes me wish there was a way that extending a protocol to function would also affect the reified value
16:40bbloomdnolen: ie reify and delgate
16:40bbloomdnolen: but anyway, i can't just reify
16:40bbloomdnolen: because -with-meta needs to call Function.
16:42dnolenbbloom: you can make anon reify constructor fn
16:42dnolen(fn [f meta] (reify ...))
16:43bbloomdnolen: hm ok
16:43dnolenhmm actually you do want to share that, so you probably need to name it, still not a big deal
16:44dnolenoh take that back - I don't think you do
16:44dnolenyou only with need that in the IWithMeta case
16:44dnolenso yeah anon ctor fn will work
16:45bbloomdnolen: you need it in *two* IWithMeta cases
16:45dnolener ... it needs a local name - but you get the idea.
16:45bbloomdnolen: yeah
16:45bbloomdoing it
16:46bbloomdeeply indented reify looks ugly as sin, but it's ok :-P
16:47dnolenbbloom: also your fn? looks wrong, you need still need to call goog.isFunction as well
16:47bbloomdnolen: nope, tested that
16:47bbloomand looked at goog.isFunction
16:47bbloomdnolen: it's testing typeof x === 'function'
16:48bbloomthis will basically be testing x.prototype._some_magic_protocol_thing
16:48bbloomdnolen: note that I do (extend-type function Fn)
16:48dnolenbbloom: yeah you don't want to do that. do both tests - perf thing.
16:49dnolenthat will make testing regular JS fns crazy slow
16:49dnolentypeof x === 'function' is crap JS engines optimize
16:49dnolendon't want to lose that and go through all those tests in satisfies? for JS natives
16:49bbloomdnolen: is satisfies? really slow? i thought it was pretty fast !!x.protocol.y
16:49dnolenbbloom: we don't mess w/ natives
16:50bbloomdnolen: oh duh. the hash lookup
16:50bbloomof course
16:50bbloomyou're right
16:50dnolenbbloom: separate lookup after the optimized stuff fails
16:50bbloomdnolen: forgot :-)
16:50bbloomdnolen: sadly then, this will slow down fn? tests against primitives that aren't functions
16:50bbloomdnolen: so if you're doing fn? and expect it to *usually* return false, then that's slower
16:51dysingertechnomancy: remind me what the equiv of flip is in clojure again
16:51dysingerPrelude> let divBy3 = flip (/) 3
16:51dysingerPrelude> divBy3 12
16:51dysinger4.0
16:52bbloomdnolen: could do something like (or (goog/isFunction f) (and (not (primitive? f)) (satisfies? Fn f)) if we had a fast primitive? test
16:53dnolenbbloom: eh don't really think it's worth it, don't see how you can make primitive? any faster than satisfies?
16:54bbloomtypeof x != "object" ?
16:54dnolenbbloom: or much faster anyway.
16:54bbloomdnolen: ^^
16:55dnolenbbloom: typeof everything that is not native is "object", so how would that work?
16:56bbloomdnolen: assumption being if typeof anything is "object" then you need to run satisfies? to see if it's a function. but i won't pretend to have fully internalized the subtlies of javascript's odd typeof and instanceof and primitives and what not
16:58dnolenbbloom: I think goog.isFunction + satisfies? is good enough for now, just remember to hint the return value of goog.isFunction in the or.
16:58dnolen(or ^boolean (goog.isFunction f) (satisifes? Fn f))
16:58bbloomdnolen: got it
17:00dysingerI'm too rusty
17:01brehautdysinger: (/ 3) ?
17:03gfredericksclojure don't got no flip
17:03dysingerit needs a point free flip
17:03dysingeruser=> (def one-third (partial / 3))
17:03dysinger#'user/one-third
17:03dysingeruser=> (one-third 12)
17:03dysinger1/4
17:03dysingeruser=>
17:03dysingerwrong answer with that
17:03gfredericksI think flatland/useful has it
17:03dysingerk
17:04gfredericksdysinger: partial is just so much effort compared to haskell currying :/
17:04dysingerjust curious
17:04SgeoYou probably want (def one-third #(% / 3))
17:04SgeoAlthough that's not pointfree
17:05brehautyeah, if you need to reach for partial and flip in clojure #(…) is better
17:05dysingerI was trying to do cobbling together comp, partial & reverse
17:05dysingerbut yeah - I know I can do it with # & % but that's cheating
17:05gfredericksoh man guys we need to try to define flip point-free
17:05gfredericksjust to be obscene
17:05SgeoClojure doesn't even have $ you have to write #(%1 %2)
17:05brehautincidentally, haskell calls the partial application of infix operators 'sections' ;eg, (/), (/ 3) and (3 /) are sections of /
17:06SgeoOr #(apply %1 (rest %&)) or something depending on circumstances
17:08ChongLithere's a tradeoff here
17:08ChongLiHaskell functions are curried by default
17:08ChongLiwhereas Clojure functions have variable args
17:08ChongLiat least that's my understanding of it
17:10dnolenClojure functions also have the benefit of being backed by something malleable - they are not primitive.
17:11dnolencomparing Haskell fns & Clojure fns just doesn't make any sense
17:11ChongLiyeah, they are very different animals
17:11ChongLiand support different abstractions
17:11gfrederickswhat malleable thing are clojure fns backed by?
17:12dnolengfredericks: IFn
17:12ChongLiso to really compare them you need to make a judgment about which abstraction is important to you
17:12bbloomdnolen: duuurrrrr reify automatically adds meta support
17:13gfredericksyeah anytime I thought about trying to port parts of clojure.core to haskell the vararg thing came back making everything ugly
17:13gfredericksor impossible
17:13gfredericksyou just can't do apply in haskell
17:14dnolenlots of things are impossible like this "function": http://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic.clj#L3853
17:14ChongLior how about clojure's map?
17:14RaynesYou can, but for concrete numbers of args.
17:14ChongLiit's way more general than haskell's in some ways
17:15dnolenbbloom: ah right heh :)
17:15dnolenbbloom: so that patch is trivial :)
17:15bbloomdnolen: yes :-)
17:15bbloomdnolen: i was staring at the generated javascript… wondering "wtf is all this extra meta meta shit in here?"
17:15dnolenbbloom: haha
17:15gfredericksRaynes: that's what I mean by "can't" :)
17:16bbloomdnolen: oh this is much nicer :-)
17:20bbloomdnolen: updated http://dev.clojure.org/jira/browse/CLJS-359
17:20bbloomdnolen: hopefully that does the trick because id like to go back to making what i hope will become the jquery of clojurescript :-)
17:21gfrederickscljquery
17:22dnolenbbloom: I hope by that you mean, something everyone uses - and not actual analog of jQuery which a complected mess.
17:22bbloomdnolen: yeah, i mean the library that is so good and obviously the the right way to do it that everybody uses it
17:22bbloomdnolen: very clojury: data all the things!
17:23gfredericksdata the whole dom? webfui?
17:24bbloomgfredericks: the idea is to treat dom manipulations as little programs in postfix notation :-)
17:24gfredericksare you inventing the dom monad?
17:24bbloomgfredericks: not a monad, think factorcode.org
17:24dnolenboom, fns w/ metadata in CLJS now http://github.com/clojure/clojurescript/commit/6ce3b1cef3824fd36e75402f5a8ed5053252b15e, thanks bbloom
17:25bbloomdnolen: sweet thanks
17:25dnolenbbloom: pleasingly simple change.
17:26bbloomgfredericks: yeah, the idea is that stacks and trees like the dom play nice together. clojure is all about immutibility, but the dom is this big mutable mess. so the premise is to treat it like a remote service: you send it programs written in a notation similar to how you send printers postscript
17:27bbloomgfredericks: being a postfix notation means you can compose programs trivially via concatonation
17:27bbloomfactor is to forth as clojure is to common lisp
17:27bbloomentertainingly enough, factor started out as what is no called JFactor ;-)
17:28gfredericksbbloom: that is an intriguing approach
17:29bbloomgfredericks: here's a working example
17:29bbloom"root" get-element "div" tag "button" class "i am a button" text append
17:29bbloomclearly you'd format that with newlines, etc
17:29bbloombut that adds a button to the "root" element
17:30bbloomwith the right class, text, etc
17:30bbloomget-element pushes the element onto the stack
17:30bbloomall the jquery transformations can be implemented as applying a map function to a list of elements on the top of the stack
17:30bbloomso you don't even need to wrap each dom element in some kinda of monad thing
17:31brehaut…other than the list
17:31bbloombrehaut: well yeah, but this also works:
17:31bbloom".button" select
17:31bbloomwhich has stack effect ( selector -- elements )
17:32gfredericksas long as a list of elements is a different thing from a single element then I'm happy :)
17:32bbloomgfredericks: it will be, but all of the transformation operators will wrap and unwrap elements in lists as necessary
17:35bbloomthis brings up an interesting thought tho
17:36bbloomeh nevermind, i need to noodle to myself more first
17:38gfredericksis it roughly accurate to call jquery's approach "weak typing"?
17:38gfredericksat least at a high-level
17:39bbloomgfredericks: in what sense?
17:40gfrederickshmm
17:40gfredericksI recant everything
17:41hugodwow, core.logic has working inequalities - thanks dnolen!
17:41gfrederickseither dnolen is the man or that term is not very useful.
17:43bbloomhugod: w00t! somebody likes my 1 and only patch to core.logic! :-) (granted, dnolen did all the hard work to make that possible, i just added some inequality symbols to a map, heh)
17:43hugodbbloom: oh, didn't realise - thanks bbloom!
17:44bbloomhugod: heh, my pleasure, but really all dnolen on the meaty bits. core.logic is damn awesome
17:44gfredericksbbloom: I have one patch to core logic, and it made its way into dnolen's strange loop presentation; his commentary was "don't pay any attention to that part some guy added it" :D
17:44bbloomgfredericks: heh, what part was that?
17:45gfredericksoh um (run [a b c] ...)
17:45gfredericksmultiple query variables
17:46gfredericksI got real tired of (run [q] (fresh [a b c] (== q [a b c]) ...))
17:49dnolengfredericks: haha, oh right :) I didn't mean that patch wasn't useful of course - I've been thinking about a few more enhancements along those lines.
17:50dnolenhugod: yeah the finite domain stuff is more or less working but it'll be some time before it's efficient ... but I'm not going to let that hold up a release. I think as soon as I get lynaghk enhancements and I fix tabling - 0.8.0 will be wrapped up.
17:50gfredericksdnolen: it did make me wish I had factored the patch a bit better so it didn't get in your way :)
17:53hugoddnolen: I'm not too worried about efficency at the moment - look forward to a release ;)
17:53dnolenhugod: cool, not far off.
18:10RaynesFYI, I just broke the crap out of refheap. It'll be down for a minute while I sort it out.
18:11RaynesFixed.
18:11RaynesOkay, so.
18:11RaynesDear everybody and persons, I have finished moving refheap to compojure and have deployed it for a trial run before I release to my master branch.
18:12RaynesPlease report any issues promptly, and I will pretend to fix them immediately.
18:15Bronsadnolen: ping
18:15dnolenBronsa: pong
18:16Bronsai got blind to run 5x times slower than clojure LispReader
18:16Bronsathe bottleneck was my implementation of StringPushbackReader
18:17dnolenBronsa: nice
18:19Bronsadnolen: right now the bottleneck is satisfies?
18:19Bronsawithout calls from satisfies to attach line/column metadata, it runs as fast as LispReader
18:21dnolenBronsa: yes you don't want to use satisfies? it's slow as crap
18:21Bronsadnolen: should i use instance? instead?
18:21dnolenBronsa: use instance? to check the interface directly
18:21dnolenyes
18:22dnolenthe problem is that is satisfies? fails, it tries to walk the entire class hierarchy to find a type that satisfies the protocol :(
18:22Bronsayeah
18:22dnoleninheritance I mean
18:23dnolenbut that's SWEET
18:23dnolenfast as LispReader and in pure Clojure :)
18:23dnolengotta run that's good news
18:23Bronsa:)
18:26tomojsatisfies? is slow in cljs?
18:26tomojor jvm?
18:27SgeoBlah, how do I take a seq of characters and turn it into a string
18:27gfredericksapply str
18:27gfredericks,(->> "foo" seq (apply str))
18:27clojurebot"foo"
18:27SgeoHmm
18:28gfredericks,(str \a \space \+ \space \b)
18:28clojurebot"a + b"
18:30SgeoCould also do clojure.string/join I guess
19:04seancorfieldin the incanter docs it suggests (use '(incanter core stats charts)) as a way to pull in all the appropriate names for casual use... what would be the 'modern' equivalent with require and :refer :all ?
19:04Raynescallen: You might be particularly interested in my move of refheap to compojure, since you used it as something of a reference.
19:07tomoj(pprint #'AProtocolVar) prints endlessly
19:07tomojsince (= #'AProtocolVar (:var AProtocolVar))
19:09SgeoAnyone experienced with JNA and JNAerator here?
19:09SgeoI have a function that accepts a const char *
19:09gfrederickstomoj: I think of pretty printing as just for data
19:09SgeoJNAerator made a method that takes a String
19:10SgeoThe C function will make a copy of the C string that it's passed in, so I should free the memory that JNA used for its copy of the C string. How do I do that?
19:10SgeoOr will the memory not leak for some reason if I don't?
19:10tomojwas trying to pprint analyze's output
20:01FrozenlockWill the clojure-conj presentations be uploaded to blip.tv?
20:02ChongLiI sure hope so!
20:06wingycant wait for it
20:09FrozenlockWe want clojure-conj videos! When do we want them? Now!
20:12FrozenlockAny good struct/record/protocols introductions around? Something for children would be terrific!
20:12Frozenlock'cause for adult hurt ma brain
20:14ChongLihttp://oredev.org/2012/sessions/expressing-yourself-polymorphism-in-clojure
20:14ChongLithere you go :)
20:15ChongLiit doesn't cover structs, however, but they are deprecated afaik
20:15technomancyFrozenlock: use maps
20:15technomancyand defns
20:15FrozenlockChongLi: Thank you very much!
20:15ChongLiyeah listen to technomancy
20:15ChongLiuse maps
20:15eggheaduntil you don't need to :)
20:15ChongLiunless you need to do some polymorphic stuff
20:15eggheaduntil you can't*
20:16FrozenlockI agree that listening to technomancy is usually a smart thing to do :)
20:16ChongLiturning your data into records should be viewed as an optimization step
20:17ChongLiand so the rule of thumb against "premature optimization" applies
20:17FrozenlockI'm trying to make a clojure wrapper around a java library with maaaaaany classes, each with multiple methods and I still don't know where to begin.
20:17ChongLiunless of course you need to dispatch on the type
20:17technomancyprobably don't want to begin by repeating their mistakes =)
20:17ChongLiwhy are you wrapping a library?
20:18FrozenlockChongLi: I don't like it :P
20:18ChongLijust build a new, higher level library above it
20:18ChongLia wrapper (to me, anyway) implies a dumb repeating of work
20:32FrozenlockHmmm... is there a way to eval a function when retrieving a value in a map? {:a 1 :b 2 :c (get-some-value)}
20:32ChongLiFrozenlock: not sure what you mean
20:32clojurebotExcuse me?
20:32gfredericksFrozenlock: ditto
20:32FrozenlockThe value is time sensitive. I would like to 'look it up' only when necessary.
20:33ChongLiyou're associating :c with the value returned by applying (get-some-value)
20:33gfredericksyou could make the value an atom? or a function?
20:33brehautor a delay
20:33ChongLiyeah, a delayed function
20:34gfredericks,(let [m {:a (partial rand-int 15)}] [((:a m)) ((:a m))])
20:34clojurebot[9 11]
20:34brehaut,(let [m {:a (delay (rand-int))}] [(@(:a m) @(:a m)])
20:34clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: ]>
20:34loliveirais there any way to the macro ->> return nil if any part returns nil? (->> %2 :attrs :x:num utils/toDouble). For example, if :x:num return nil, toDouble should be never called.
20:35Frozenlock(let [m {:a (partial rand-int 15) :b 1 :c 3}] [((:a m)) ((:b m))])
20:35Frozenlock&(let [m {:a (partial rand-int 15) :b 1 :c 3}] [((:a m)) ((:b m))])
20:35lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
20:35brehaut,(let [m {:a (delay (rand-int 1))}] [@(:a m) @(:a m)])
20:35clojurebot[0 0]
20:36brehautdelay has slightly different semantics to just a fun; it caches the result i believe, rather than reevaluating
20:36Frozenlock:/
20:36ChongLiyou can write your own delay
20:37wingydo you add a doc-string to all your functions?
20:37gfredericksloliveira: I think what you want is called -?>>
20:37gfredericksand it might be in the incubator lib
20:37gfredericksloliveira: thought -?> would work just as well in your example
20:37brehautChongLi: but why would you? if you dont want delays semantics, then a function of no arguments probably does it just fine
20:38ChongLibrehaut: yeah
20:38ChongLidelay is just a macro that wraps a function of no arguments in a memoizer
20:38FrozenlockSuppose I've written my own delay function which re-evaluates each time. Is there a way to avoid the @ (or deref call)
20:39ChongLiand then force just calls that function on no arguments
20:39ChongLiyou can avoid deref
20:40FrozenlockI suppose what I want is a lazy map that re-evaluates each time...
20:40loliveiragfredericks: thank you!
20:45Sgeouser=> (clj-vp.attributes/produce-getset-map)
20:45SgeoCompilerException java.lang.IllegalArgumentException: Malformed member expressio
20:45Sgeon, expecting (. target member ...), compiling:(NO_SOURCE_PATH:1)
20:45SgeoSorry
20:45SgeoThat's... not really a helpful error message :(
20:48ChongLiwhat is clj-vp.attributes?
20:48ChongLithe . seems to be invoking java interop
20:49Sgeoclj-vp.attributes is the namespace of the code in question
20:49SgeoAnd there is a lot of Java interop involved
20:49ChongLiah
20:49ChongLican you require with :as
20:49ChongLito give a shorter name
20:49ChongLiso that it won't have a . in it?
20:50gfredericksSgeo: any chance the exception was from your previous command?
20:51SgeoSame error
20:52ChongLithen you'll have to work your way back through the stacktrace
20:53ChongLiyou have some malformed java interop expression
20:53SgeoBut... the stack trace gives little useful information
20:54SgeoLooking at the output of a function that the macro calls, where any errors are most likely
20:54Sgeo(It's horrific ugly and repetitive code)
20:55ChongLiproduce-getset-map is a macro?
20:55ChongLiexpand it
20:55SgeoI did
20:56ChongLiand...? I don't have enough information to help you
20:58wingyto mock or not to mock, that is the question
21:00gfrederickswingy: the revered hickey says something about your mock objects mocking you for needing them
21:00gfredericksso the answer is unquestionably "not to mock"
21:00xeqiexcept when you should mock
21:00wingygfredericks: is there a presentation about that?
21:00wingyit takes a lot of time to mock .. im mocking http request responses
21:02jamesmacaulayHi folks, I'm looking to package up my first clojure lib and I have zero Maven experience. Is there a good guide somewhere? I figure I should test locally first by packaging and including as a dependency of another project.clj, to make sure everything works before pushing to clojars or whatever. I found lein-localrepo, am I on the right track here?
21:02wingygfredericks: i mock for some reasons: 1. sometimes you can't automate eg. you need to manually interact with UI 2. sometimes you can't set up the correct testing env in the service you are using (eg. can't reset the state of the service)
21:02gfrederickswingy: maybe somewhere; I really don't know :/
21:02wingygfredericks: would be cool to hear what the legendary hickey says about testing/mocking
21:03gfrederickswingy: I think the OOP people have maybe a more specific definition of mocking than what you're using? but I couldn't say for sure
21:06amalloyyou don't need to mock http responses, if your business code doesn't make http requests of its own accord. it could, for example, return a function that expects a map representing an http response
21:06amalloyin prod you call that function with actual http responses, and in a test you call it with mock data
21:07amalloythat's a simplistic version, but you can elaborate as needed
21:08ChongLithings become a lot simpler when you try to put the bulk of your code in pure functions
21:08gfredericksusually
21:09gfredericksI imagine in extreme cases you might end up just reinventing the IO monad
21:12wingyamalloy: sounds advaned
21:12wingyadvanced
21:12wingybut some code has to do the http requests
21:13amalloyyou're mocking, man. attempting to redefine arbitrary pieces of your business code from outside is pretty "advanced" too
21:13wingyim wrapping the http api for a service
21:14wingyamalloy: so you are saying my api functions should not make the http requests themselves but be passed a response map?
21:15wingyhmm .. their job is to return the response map :)
21:16SgeoSorry, dealing with RL BS right now
21:17wingyif everyone was using datomic we would have it easier writing tests
21:17wingys
21:17wingyince
21:18wingysince there would be no changed state .. so you setup a database value and then you use that one to test against .. that db value will never change
21:19gfrederickswingy: I realized the other day that "database as a value" could make it a lot easier for a web server to be a pure function
21:19gfredericksat least for the read-only requests
21:20wingyyeah .. in -> out
21:22wingyreally cool if you think about it .. no side effects .. the same http request give exactly the same browser view
21:22FrozenlockChongLi: Thank you very much for the video, I'm really enjoying it!
21:22wingymaking it easier to catch bugs .. just give me the http request and i can produce the same view
21:23SgeoSpitting the pretty-printed macroexpansion to a file
21:23SgeoMaybe that will help me
21:23muhoo"Your mock object is mocking you.... for needing it" -- Rich Hickey
21:23SgeoAvoid losing my sanity
21:23ChongLiFrozenlock: that's good!
21:23ChongLiit's a nice presentation
21:23SgeoIs a macro that expands into 29kb of code a bad idea
21:23Sgeo>.>
21:23ChongLiwow
21:23gfredericksprobably
21:24ChongLiSgeo: perhaps you want to step through evaluation a bit
21:24gfredericksare you expanding to (def one 1) (def two 2) (def three 3) ...?
21:24Sgeogfredericks, I'm expanding into a map of maps of functions
21:25wingyi so want to watch that presentation https://twitter.com/ybits/status/173225782678794241
21:26ChongLiwingy: haha
21:26gfredericksSgeo: what fer?
21:26SgeoThis is what I'm expanding into https://www.refheap.com/paste/bca9e92373ae550f90e473e9c
21:27gfredericksSgeo: one thing to keep in mind is that each of those fn's is a separate class on the jvm
21:28gfredericksSgeo: is there any reason you can't create this at runtime with a regular function?
21:28SgeoWould it be better to use Java reflection to try to do (. vp.VPLibrary$VPFloatProperty x) where x is supplied at runtime?
21:28SgeoBecause I have no idea how to do that
21:29Kowboyso, all Clojure functions implement java.lang.Runnable, right? Isn't that only useful if the fn has no args?
21:29ChongLijust call class on the object
21:29ChongLiand dispatch on the result
21:29gfredericksSgeo: ah ha so it's that you have a big pile of instance methods you want to call?
21:29ChongLi(to do reflection)
21:29ChongLior write a protocol for that matter
21:29Sgeogfredericks, well, they're static
21:29gfredericksKowboy: probably so
21:30gfredericksSgeo: ah ha
21:30SgeoWait, no
21:31Sgeovp_float is a method on a thing that always stays the same, which is why I have call-vp
21:31Kowboyseems like most fns would simply throw ArrityException if you passed them to a thread
21:31amalloySgeo: what is clj-vp.private/call-vp?
21:31Kowboyunless I'm missing something, it simply seems like a shortcut for creating a Runnable when that is actually what you want
21:32Sgeoamalloy, very trivial macro
21:32amalloyKowboy: yes
21:32Sgeohttps://www.refheap.com/paste/f9d6cf4df13fdb64d671332e2
21:33Sgeo...I'm not supposed to be using call-vp here at all.
21:33SgeoIt's fine for the set but not for the get
21:34SgeoBut I don't see how that mistake would cause this error, hmm
21:35ChongLiyou said all those were static methods?
21:37Sgeo.vp_float is not static, it's called on +INSTANCE+
21:37ChongLioh
21:37Sgeovp.VPLibrary$VPFloatProperty/VP_OBJECT_X for example, though, is a static field
21:42ChongLiwhere are you getting the keys (such as :avatar-name) to look up in this map?
21:42wingyhttp://www.exampler.com/blog/2011/09/29/my-clojure-problem says rich hickey is not fond about tdd .. what does he suggest?
21:43ChongLithis seems like protocols or multimethods would solve this issue
21:43SgeoObtained via reflection on vp.VPLibrary$VPStringProperty and massaged to be a keyword
21:43SgeoMaybe I'm doing the . form wrong
21:44SgeoApparently not
21:44amalloySgeo: tbh your code looks good to me
21:44xeqijamesmacaulay: https://github.com/technomancy/leiningen/blob/master/doc/DEPLOY.md or https://github.com/clojuredocs/cds/blob/master/articles/ecosystem/libraries_authoring.md
21:44amalloyhave you tried macroexpanding one of the clj-vp.private/call-vp forms?
21:45jamesmacaulayxeqi: thanks!
21:45ChongLior how about macroexpand-all on the entire thing?
21:46ChongLiand then just testing one of the resulting expressions a bit in the repl
21:47amalloyChongLi: no good, because macroexpansion is what's throwing the exception
21:47amalloy&(macroexpand-1 '(.foo))
21:47lazybotjava.lang.IllegalArgumentException: Malformed member expression, expecting (.member target ...)
21:47ChongLioh
21:48SgeoI just wish it says what it saw
21:49SgeoThat would be nice
21:49ChongLihmmm
21:51ChongLiwhat does throw-rc do?
21:51SgeoIt's a function, if the result is not 0, throws an exception based on it
21:52SgeoErm, if its argument
21:53ChongLiwhat if you get rid of call-vp so it's just (.vp_string ...)
21:53ChongLijust for testing
21:53ChongLithen we'll know if it's call-vp causing the failure to expand
21:54wingy"These are the facts as I know them: Rick doesn’t practice TDD (in fact he finds it a “waste of time”), but several other clojure/core contributors actually do. "
21:54wingyi don't get how he test that his code works without testing :)
21:54ChongLithat doesn't mean he does no testing
21:55ChongLijust that he doesn't write tests first
21:55gfredericksclojure has tests
21:55Kowboyone thing I like about TDD is that it puts you immediately in the seat of the person that is using the public api of your library
21:56wingyto TDD or not to TDD, that is the question
21:56ChongLiKowboy: on the other hand, it forces you to make decisions before you might feel ready to do so
21:57bbloomis there some way to use clojure.walk/prewalk but cull a branch of the walk?
21:57wingybut shouldn't we design before implement
21:57SgeoGot rid of call-vp
21:57Kowboytrue
21:57Kowboythere are good things about top-down and bottom-up
21:57wingyhow can you build Eiffel tower without a blueprint
21:57Kowboystarting small, you get nice, reusable chunks of coide
21:57ChongLiwingy: according to Gerald Jay Sussman; no
21:58wingyso perhaps if you can't make design calls then you have to study design first
21:58Kowboybut how to compose them together to build a nice api for the user can be tricky
21:59Sgeohttps://www.refheap.com/paste/769824be706624249f57b547c
21:59KowboyI think starting top down, with your public functions defined at a high-level, and working tests, you can then break up these functions as you go and be confident that you haven't changed the behavior
21:59Kowboyso both ways have benefits
22:00ChongLiSgeo: ok, does this still fail?
22:00SgeoYes
22:00SgeoI'm going to comment out this macro and do the reflection thing
22:01Kowboywingy: that's not very agile. I mean, some design is required, but only as much as is necessary to solve today's problem
22:01wingyhere he explains what he means http://www.codequarterly.com/2011/rich-hickey/ but it seems that he is against testing overall
22:01ChongLiSgeo: macros are very tricky to get right in situations like this
22:02ChongLiwingy: no, he's against writing a lot of tests
22:02wingyok
22:02wingysounds fair
22:02ChongLiI don't think he has any problem with writing some regression tests
22:02wingyim not very fond of writing a lot of tests myself
22:03ChongLithat's totally different from designing your entire system by writing all of the tests
22:03ChongLibefore writing any code
22:03wingyyeah
22:03ChongLia lot of what I see in TDD could be called pathological testing
22:03ChongLitesting of things which are obvious
22:04wingyyeah i have seen that a lot
22:04ChongLiwhich is silly, because real problems are usually not so obvious
22:04wingyyepp
22:04KowboyChongLi, I think that is more white box testing
22:04ChongLiif you write pure functions you can avoid a lot of test-writing
22:04ChongLiby using generative testing
22:05Kowboypossibly, but you have boundary conditions in pure functions as well
22:07ChongLia particularly good generative testing framework can really help you with the corner cases
22:07wingyChongLi: http://stackoverflow.com/questions/562845/what-is-a-generative-unit-test-framework
22:07ChongLiyeah I know
22:08ChongLiquickcheck et al
22:08wingyhave a look at the first test .. so it's just asserting that the sum is a integer?
22:08wingyhow can i be sure that the integer returned is the sum of the values
22:08ChongLiwingy: subtraction
22:08ChongLiyou simultaneously test addition and subtraction
22:09wingycool :)
22:09ChongLithat leaves only the case where they're both broken in such a way as to give false negatives
22:09wingyso that example was a pretty bad one
22:09ChongLithis is usually tests like this work
22:10ChongLianother example is reversing a list
22:10Kowboyso, at what point do you recommend writing your tests?
22:10ChongLiif you reverse a list twice you should get back the same list
22:10Kowboyafter a feature is "complete"? After a bug has been discovered?
22:10gfredericksare there any common clojurescript templates for lein-newnew?
22:10ChongLiafter a bug has been discovered = regression testing
22:11wingybut you get false positive if the fn is not doing anything at all
22:11ChongLiwingy: sure, but that's only one test
22:11ChongLianother test is to reverse a list and check if the last element has become the first
22:12Kowboyso, I don't see TDD and generative testing being mutually exclusive
22:12ChongLicombine those two tests and you start to get a pretty good picture
22:12ChongLiKowboy: they're orthogonal
22:12ChongLiTDD is a development methodology
22:12ChongLigenerative testing is just a framework
22:13ChongLiTDD says you're only allowed to write code in order to satisfy a test
22:13Kowboyso what I'm trying to get out of you is, what is a reasonable alternative, well-defined methodology for writing tests
22:14Kowboywell, I guess that's the extreme definition
22:14wingythen i guess im doing TDD
22:14KowboyI guess I'm more TFD
22:14wingyi write test for all public fns
22:14wingyKowboy: TFD?
22:15Kowboytest first
22:15Kowboysubtly different
22:15wingywhats that about .. sounds the same
22:15Kowboystrict TDD, as ChongLi points out, says that you only write code to satisfy a test
22:15tomojhttps://www.refheap.com/paste/e2cffd71eaa8fee108469f1a6 doesn't clojure.tools.macro make an effort for this not to happen?
22:16wingyso TDD :)
22:17Kowboylol, honestly I sometimes write tests first, other times I play with the code a bit until I know what it is I really want to do, then I write the test
22:18Kowboystill, you can test your code at the REPL, or you can save those tests in a file that can be executed many times for ever and ever, amen
22:19Kowboyproject automation is not made obsolete by functional programming
22:19ChongLiKowboy: sure, that's fine
22:19ChongLibut that's not what Rich is against
22:19tomojit seems like symbol-macrolet respects let*, but macrolet doesn't?
22:19Kowboynon-trivial functions have a tree of dependencies on other functions
22:20Kowboysome of those may be in 3rd party libraries you do not control, or they may be maintained by other people on your team who do stupid things like change the behavior
22:20Kowboywithout telling you
22:21KowboyI think if you are Rich Hickey, and you've written your own language, you've earned the right to write code without tests.
22:21Kowboybut for us mere mortals who work on teams with other mere mortals, tests save lives
22:21ChongLiagain, that's not what Rich is against
22:22ChongLihe is not against writing tests; he just doesn't do TDD
22:23KowboyChongLi, should tests only be written as a response to a defect?
22:23Kowboyif not, what is the discipline?
22:23Kowboywhat (and when) do you test?
22:23ChongLiyou write tests according to what you anticipate will fail
22:24ChongLibut you don't have to do TDD
22:24Kowboymost software developers, in my opinion, are terrible at anticipating what their code will do
22:24ChongLiit's silly, though
22:25ChongLiif you can't anticipate what will fail, how can you write a test?
22:25Kowboyif you don't test, how do you know your software is correct?
22:25ChongLiyou prove it correct
22:26Kowboymaybe that works if you live in a bubble of really awesome developers
22:26ChongLitesting doesn't tell you your code is correct
22:26ChongLiit only tells you whether the tests pass/fail
22:27Kowboythat is true
22:27ChongLiit's like a virus scanner
22:27wingywhat is like a virus scanner? i disconnected
22:27ChongLiwingy: writing tests
22:28KowboyChongLi, what are your thoughts on code coverage?
22:28Kowboyassuming we are not doing TDD
22:28Kowboybecause I think there is something very valuable with having good code coverage
22:29ChongLisure, though I think 100% code coverage is pathological
22:29KowboyIn many cases I have had a developer tell me that they would have checked in a terrible bug if my unit test hadn't been there
22:29ChongLiwhat language are they writing in?
22:29ChongLijust curious
22:30KowboyI just think that having a formal discipline for testing is a good thing, even if it isn't TDD
22:30Kowboybut if it isn't formal, then it becomes easy to "do it later"
22:30Kowboyand then later never happens
22:31Kowboythat would be Java in my case, and I get that FP is a different animal
22:31wingyi test all public functions
22:31ChongLiyeah, I think a lot of the testing you do in Java comes as a result of shortcomings in the language
22:31Kowboybut I don't think writing tests, even first, is a bad habbit
22:31Kowboysure, but it's all executable code
22:32Kowboyits just that in Java, much of our testing is devoted to changes in state
22:32wingyif you think about it it's just telling that certain inputs generate certain outputs
22:32wingyif i don't have a test for a fn .. i don't get how i would know that it works
22:32Kowboywhat I really would rather focus on is testing the behavior
22:33wingyi can manually test it in the repl or in app .. but that is unsaved testing
22:33KowboyI think TDD ought to be much easier in Clojure
22:33Kowboybecause you don't have to worry as much (not at all in most cases) about state changes
22:34Kowboywingy, well, not totally true. Have you heard of Session?
22:34wingyhave a link?
22:35Kowboyit's like a persistent repl
22:35Kowboysaves the inputs and outputs
22:35Kowboyyou can go to any of the lines that were saved and re-run them
22:36KowboyKovas Boguta presented on this at the Clojure/conj
22:36wingyi thought about skipping the mocking and use live responses from other services .. advantages: 1. don't need mock data 2. if api changes my tests fail and i can update the code
22:36Kowboyhttps://github.com/kovasb/session
22:36wingyany inputs/feedback on ditching mocking and use live responses from services?
22:37Kowboysearch google for Kovas Boguta session
22:37xeqiwingy: so you have to have internet access to run the tests?
22:37Kowboysome presentations on youtube and such
22:37wingyxeqi: yeah but that is reasaonble
22:38Kowboywingy: depends on how frequently you run the tests
22:38Kowboyalso, are all the service calls read-only
22:38Kowboybecause you can't control the initial state of an external syste,
22:38wingynope .. some are write .. which means i have to be able to reset the service state
22:39Kowboyok, so this works in this particular case
22:39wingyeg. create -> read -> update -> delete
22:39KowboyI'm not sure that automated testing for external services is always a worth-while exercise, though
22:39wingyall services should imo have a RESET api so we can reset the state
22:40Kowboybut testing the layer immediately beneath that is a good place to start
22:40Kowboywell, that's certainly not practical in many cases
22:40wingyKowboy: nah .. they should have a testing account like Braintree payment
22:41wingyfor testing only
22:41Kowboy*should*
22:41wingyin that case you can make charges etc
22:41wingyor .. i just do mocking and can test whatever i want :)
22:43Kowboyagain, external services to me represent the "edge" of a program, where you may have to deal with some mutable state. Just beneath that we should have a functional core which we want to be solid.
22:43Kowboyso not sure whether that's a part of the system I want to test, although it may end up being the most volatile part of the system
22:44KowboyI don't know... it's a case-by-case thing
22:50wingyperhaps that problem is not in our end .. its in those services
22:57Kowboyright, but all we can gain from that is how our code *might* behave under external failure conditions
22:57KowboyI think that's the worst part of mocking
22:58Kowboyyou can't really know how the external system might fail
22:58Kowboymaybe some common cases, like 404's or what not
22:58wingyso perhaps the question is not how will it look like if it fails, but what does it look like when we get what we need
22:59KowboyChongLi, you still here?
22:59wingyif it fails we debug .. perhaps the server is down, or they are having a bug etc .. but that won't help our app, we just show "something went wrong, we will fix it ASAP" .. and we debug it
23:00KowboyI'd be interested to know what (if anything) generative testing can do for us if our inputs are nested data structures (like maps of maps)
23:00wingyso all my tests are just testing that one scenario my app wants, not all the scenarios that are not wanted since that can be infinite
23:04ChongLiKowboy: it sounds like you may need some data abstraction
23:05ChongLidoing a lot of complex destructuring is a code smell
23:11Kowboywell, what if you are consuming XML or JSON from a service?
23:13Kowboyif you use cheshire you can get it as a nested Clojure data structure. What is the general approach for extracting data from a nested data structure?
23:13ChongLido you expect the data to take on some specific form or is it totally arbitrary?
23:15ChongLiif the data is in a predictable shape, you can build abstractions out of it
23:16ChongLiotherwise you're sort of stuck with this blob
23:17SgeoDoes into force sequences?
23:17amalloySgeo: into is (reduce conj)
23:18KowboyI'm not sure what "build abstractions out of it" means exactly
23:18Kowboyit is a predictable shape
23:19ChongLiyou design your project as a bunch of layers of abstraction
23:19ChongLiat the bottom you are dealing with the concrete data
23:19ChongLiit's entirely dependent on what you're doing, exactly
23:20Kowboysay we are transforming a JSON document into some cononical data format
23:21Kowboyin some cases, there may be a straight 1-to-1 key mapping, but some parts might be flattened or "normalized" in the canonical format
23:21ChongLiright
23:22FrozenlockAh damnit... I tried to make my own protocol for a custom hash-map. Then I added a new record with 'get'.... and overwritten the default get function -_-
23:23KowboyI feel this is one of those common and practical "recipes" that you don't get simply by learning the language
23:24FrozenlockIs protocol and record the right way if I want my own hash-map datatype with a special get function?
23:25ChongLithat seems odd
23:25ChongLiwhy would you do that?
23:26FrozenlockTo solve my everlasting problem of course! :) I want a map that updates itself on lookup. http://stackoverflow.com/questions/4568875/overloading-a-clojure-hash-map-in-an-stm-transaction seems to want something similar.
23:27ChongLiupdates itself on lookup?
23:27ChongLiwhy?
23:27clojurebotwhy is the ram gone is <reply>I blame UTF-16. http://www.tumblr.com/tagged/but-why-is-the-ram-gone
23:28SgeoIs Java reflection slow?
23:28SgeoBecause I'm considering creating closures in order to avoid repeatedly performing reflection
23:28ChongLiSgeo: yep
23:28RaynesIt depends on how fast it turns around and sees itself.
23:28amalloyphenomenally slow, yes
23:28ChongLithere's a reason *warn-on-reflection* exists
23:28SgeoWell, I need to use some reflection to maintain my sanity
23:28FrozenlockChongLi: I want to link it with an outside value, for example a stock price.
23:29SgeoI could try to get that huge macro working again
23:29ChongLiFrozenlock: so you want an object?
23:29SgeoSo, making closures is worth it here?
23:29SgeoThis way, all reflection should occur when the library is loaded
23:30FrozenlockChongLi: I honestly don't know how I could call it...
23:32ChongLiSgeo: I'm still unsure what this is all doing
23:32ChongLiyou're interop'ing with an existing java codebase?
23:32SgeoExisting C API
23:32ChongLiohh
23:32FrozenlockI think I'm getting near a solution... http://stackoverflow.com/a/5586959/1642155
23:33SgeoMade Java stuff for it with JNAerator
23:33ChongLiFrozenlock: why does this have to be a map?
23:34ChongLiSgeo: a generated java wrapper?
23:34SgeoYes
23:34ChongLino wonder it's so hard to work with
23:34ChongLihaha
23:34ChongLiFrozenlock: listen to Stuart Sierra
23:35ChongLiClojure prefers pure data structures over objects that combine data and behavior. You can get the behavior you want by accessing your data structure through a function:
23:35FrozenlockChongLi: I have multiple values, only some of them need to have this behavior. Seemed like an easy way to handle it. {:a 1 :b 2 :c (update-value-on-lookup)}
23:38FrozenlockLike using my-own-get-fn? But then I won't be able to do assoc and merge and all the other sweet map functions.
23:39ChongLiyeah, which is why you shouldn't make some weird variant of a map with custom methods
23:40ChongLi(defn a [] {:a 1 :b 2 :c (rand-int 100)})
23:40ChongLinow just do (a)
23:40ChongLiyou'll get a different one each time
23:41FrozenlockSure. (defn a [] {:a 1 :b 200ms-fn :c 300ms-fn :d 10m-ram}). Now if I do (a) only to get :b, I'll be very sorry.
23:43amalloydo you need any features other than lazy computation of values?
23:44ChongLiwould a lazy-seq vector instead of a map work?
23:44FrozenlockIt needs to update every time. Unless I'm mistaken, all lazy-x in clj keep their value once realized.
23:45amalloyso it's a map that's in fact not a value at all?
23:46ChongLiyeah this shouldn't be a map
23:46ChongLior any clojure collection
23:46amalloyie, you give it to someone, and they use it for a while, and it mutates out from under them? that's a fine thing to do in some cases, i suppose, but i would recommend against making it act like a map
23:46ChongLiit should be a java object
23:48ChongLihow about a protocol which you simply reify when you need to?
23:48FrozenlockA custom datatype that uses the same map functions is bad?
23:49ChongLiwell what you're creating is not really a map
23:49ChongLia map is a value
23:49ChongLiyou're creating a computational object that has state
23:52FrozenlockI don't get the distinction. It sill has a key-'value' form. Inside I intend to store a function. To this point it's still a map. Difference is with the lookup function; instead of returning the function, evaluate it.
23:55FrozenlockI'm also very new to defprotocol/deftype/reify... like I said earlier, I ended up overwritting my get function.
23:55ChongLihttps://www.refheap.com/paste/6911
23:56ChongLihere's an example
23:56FrozenlockSo what you propose might be the right way, I'm just not there yet.
23:56ChongLia is an object
23:56ChongLiit has 2 methods: stock-price and random-stuff
23:56ChongListock-price takes 1000ms to run and returns 20
23:56ChongLirandom-stuff returns a random-int up to 100 every time it is invoked
23:59ChongLito use it you do this
23:59ChongLi(.stock-price a)
23:59FrozenlockOk, so (stock-price a) ---> 20
23:59ChongLiyeah
23:59ChongLinote that if you call it again
23:59ChongLiit'll take the same amount of time
23:59ChongLiit is re-computing the value