#clojure logs

2014-06-09

00:01technomancydanielcompton: weird, on some machines there is very little difference. thanks for the input.
00:02technomancyseems like this will have to delay the release further =(
00:04danielcomptontechnomancy some faster, some slower, some the same?
00:04technomancyno, some a handful of ms slower, some ~500ms slower
00:04technomancynone faster
00:04technomancybut I wouldn't block a release over <10ms
00:06danielcomptonIsn't https://www.refheap.com/86389 faster on the new version?
00:07technomancyoh crap, yeah
00:08technomancydidn't notice that
00:10technomancydanielcompton: can you move ~/.lein/profiles.clj out of the way and try again?
00:12technomancyoh, I see what the difference is
00:12technomancy2.2.0 -> 2.4.0 is slower but 2.3.4 -> 2.4.0 isn't
00:13technomancyexcept for cbp
00:13technomancyhe somehow has outrageously fast 2.3.4 invocations??
00:13lazybottechnomancy: Uh, no. Why would you even ask?
00:13danielcomptontechnomancy https://www.refheap.com/86390
00:14technomancycurious
00:14technomancyhttp://p.hagelb.org/mystery.gif
00:15technomancycbp: teach me your secrets
00:15hellofunkcan anyone enlighten me on the difference between (take! ...) and (go (<! ...)) -- both are async takes; assuming you don't have a complex go body that requires continued "parking," is there a difference between these?
00:18technomancydanielcompton: is your `lein` command a symlink to a git checkout of lein?
00:19danielcomptonI'm using homebrew, it looks like that I think
00:21danielcomptonMy /usr/local/bin is a symlink to /usr/local/Cellar/leiningen/2.3.4/bin/lein
00:21danielcomptonMy /usr/local/bin/lein is a symlink to /usr/local/Cellar/leiningen/2.3.4/bin/lein
00:21danielcomptonand that is a git repo
00:21technomancyoh gotcha. would it be too much trouble to try against a manual lein install?
00:22justin_smithI don't think homebrew for lein is a loss, using straight lein is actually simpler and easier to manage versions / upgrade
00:22justin_smith*homebrew for lein is a loss, that is
00:26danielcomptontechnomancy not at all, I'll do that now
00:29danielcomptonjustin_smith how is it any different using homebrew? It means I have a consistent way of upgrading packages
00:30justin_smithbut lein handles upgrades and versions better than homebrew does - thus homebrew introduces an abstraction layer that in this case improves nothing in its indirection
00:31justin_smithsame problem (if not worse) using the linux apt package for lein
00:33cbptechnomancy: dat ssd man
00:34technomancythis wouldn't be the first time homebrew screwed up their lein packaging
00:34technomancywouldn't be the second either
00:34hellofunkthree times is a charm
00:36technomancyjustin_smith: if it's coming from apt then at least there's a single file on my system I can add it to so that I can bootstrap a fresh machine to have everything I need on it (assuming a relatively recent version)
00:37technomancybut with brew you can't even do that
00:38justin_smithso how is the nixos project coming along anyway? I wonder
00:38justin_smithhttp://nixos.org/
00:39benkayin the context of compojure routes, how does one set up a destructuring bind for params while preserving the URL param? (GET "/thinger/:stuff" [{params :params} stuff :as req]) isn't working for me
00:40justin_smiththat :as clause is misplaced
00:40justin_smithit uses standard destructuring syntax
00:41justin_smith,(let [stuff {:a 0 :b 1 :params "ok"} {params :params :as req} stuff] params)
00:42clojurebot"ok"
00:42justin_smithif something works in a let destructure, it should work in a compojure destructure, and visa versa
00:43benkaydestructuring is not my strong point. thanks for the tips.
00:43justin_smithbenkay: I never made sense of it until I experimented for a while with let in the repl
01:09danielcomptontechnomancy here's my results with a manual lein install https://www.refheap.com/86391
01:14ddellacostadid we figure out a way to test code involving core.async?
01:15danielcomptonddellacosta yes but it requires Rich Hickey's toenails and eye of newt
01:15ddellacostadanielcompton: damn, that shit is pricey too
01:16ddellacostaI guess I can probably expense it though
01:17danielcomptonddellacosta stranger things have been put on a company card
01:17ddellacostadanielcompton: not sure I want to know...
01:17Hodappo_O
01:18ddellacostahuh, I guess one approach is to mock the receiving channel
01:18ddellacostabut does that mean I have to have a test in a go block? blech
01:18ddellacosta"integration tests: yer doing it wrong." *sigh*
01:19danielcomptonddellacosta yo dawg
01:19danielcomptonhttps://groups.google.com/d/msg/clojurescript/OlyylM4LMEk/u3LLyBLLQmQJ
01:20ddellacostaokay, so apparently it's hard in CLJS although I know clojurescript.test supports it now, but apparently using <!! provides an answer? Thanks for the clue danielcompton
01:20danielcomptonddellacosta how do you verb yourself in IRC?
01:21ddellacostadanielcompton: oh, you mean the "ddellacosta goes off to investigate thing?" just type /me and then the thing you want to say
01:22tolstoyI fell for that once.
01:22ddellacostatolstoy: now I'm scared, what does that do?
01:22tolstoyOne Windows (I think), it closes the app.
01:22ddellacostatolstoy: ah, okay
01:23ddellacostahttp://knowyourmeme.com/memes/alt-f4
01:23ddellacostagotcha
01:23ddellacostamean
01:23tolstoyHah! Wow.
01:23ddellacostaI know, it's amazing what folks will do
01:23danielcomptonWhat are peoples thoughts on (= nil nil) being true
01:24danielcomptonComing from a SQL background where that isn't the case it caught me out a few times
01:24ddellacostadanielcompton: well, it makes sense, why? I mean, nil is equal to nil
01:25danielcomptonddellacosta I guess nil could also mean undefined so two undefined values compared should = ?
01:26danielcomptonddellacosta I think I like it still, though I do ponder it every now and then
01:26ddellacostadanielcompton: well, except it is explicitly not undefined in Clojure, it's nil (is I guess what I would respond with)
01:26ddellacostaheh
01:27danielcomptonddellacosta: you're right, that's why it makes sense
01:27ddellacostadanielcompton: for me this is meaningful useful when I'm using it with multi-methods or protocols, for example--I can define behavior based on nil
01:27ddellacosta*meaningfully useful
01:27ddellacostaye good olde nil object pattern
01:28ddellacostaer, null rather
01:55justin_smiththe sooner everyone upgrades from nil to proper option types the better
01:56danielcomptonjustin_smith how do you do that in Clojure?
01:56danielcompton*with Clojure
01:58justin_smithwith static typing :P
02:00danielcomptonjustin_smith typed clojure?
02:01justin_smithmaybe one can do option types with core.typed, I haven't used it actually
02:02justin_smithI've just been learning some stronger typed languages lately, and enjoy the absence of unexpected nil values (instead getting an error for non-exhaustive value matching)
02:07ddellacostajustin_smith: agreed that ADTs are the way to go here
02:08ddellacostajustin_smith: a Null Object is kind of a poor imitation of doing it properly w/ADTs
02:08justin_smiththat is one way to look at it, yeah
02:09justin_smithdo adts predate null in plt history?
02:11ddellacostajustin_smith: I can't answer that, good question. I suspect not
02:12ddellacostaambrosebs: do ADTs predate null in PLT history? I figure you may know. ;-)
02:12ddellacostad'oh, not around perhaps
02:15dbaschI believe pointers are from the 60s and ADTs were formalized in the 70s
02:16justin_smithahh and pointers in practice pretty directly lead to a nil / null value
02:16ddellacostaright, makes sense
02:16justin_smithadts are from simula67, according to this paper http://www.cs.utexas.edu/users/wcook/papers/OOPvsADT/CookOOPvsADT90.pdf
02:17ddellacostawas just going to ask, thanks
02:17ddellacostahuh, so ADTs are *post* OOP? interesting
02:17justin_smithwell, that description makes them sound parallel
02:17ddellacostaah
02:17justin_smith(the description in that paper)
02:18ddellacostajustin_smith: right, gotcha. Very interesting, sounds like it's been an ongoing dialogue between the two "camps" if they can be described as such
02:19ddellacostavery nice, thanks for that paper
02:19justin_smithnp
02:20ddellacostaI guess the lesson is that these things rarely spring fully formed from someone's mind; they are the result of ongoing discussion and attempts at implementations along the way, as well as new theoretical frameworks that come about
02:20dbaschin the late 90s I was a TA for Jeannette Wing, who liked to rant about how Java was all wrong regarding types
02:21ddellacostaah, CMU bigshot!
02:21ddellacostadbasch: wow, that must have been super educational
02:21dbaschyes, she was very sharp
02:21ddellacostadbasch: huh, she's partially responsible for Liskov substitution principle, didn't realize that
02:22justin_smithI've been learning ats, which is ml-derived and has a type system that a) only exists at compile time, reverting to an untyped runtime fully compatible with c in the compiled code and b) generalizes typing to verification arbitrary static properties (ie. guarantees that the code cannot write off the end of a given array)
02:22ddellacostajustin_smith: so it's kind of like a type-safe C pre-processor?
02:23justin_smithddellacosta: exactly, while also extending what "type-safe" can mean via proof constructing in the typechecker
02:23ddellacostainteresting, will check it out
02:23justin_smithalso it is weird and kind of a pain in the ass and very experimental :)
02:23justin_smithit has its ups and downs to be sure :)
02:23ddellacostahaha...fun. :-)
02:24ddellacostadbasch: curious what she said about Java though, although I already had a strong intuition that Java's typing was pretty crap
02:24justin_smiththe author have very odd naming conventions - ie. a second order function has the type "-<cloref1> a" which is just stupid naming
02:25ddellacostajustin_smith: wat
02:25justin_smithyeah, I know
02:25justin_smithoh, sorry, that's a closed over function, my bad
02:25justin_smithbut still, the name doesn't help me remember which is which :)
02:26ddellacostajustin_smith: yeah, it's really not clear what's going on there regardless
02:26justin_smithbut on the other hand, ml syntax and semantics compiling to raw c, which is kind of awesome
02:27dbaschddellacosta: obviously she didn’t like the fact that the Liskov substitution principle didn’t hold in Java
02:27justin_smithand not your typical "my compiler generates a tangle of convoluted inefficient c", but actual like n gc or type tags or size field on the array c code
02:27ddellacostadbasch: ah, haha
02:29justin_smithreading about liskov substitution, it seems like hoare logic (from which that is derived) also informs the kind of theorem proving type system ats uses
02:30justin_smithmany times ats types will actually look like an argument, plus a type, plus arbitrary pre-conditions like you would see in a clojure :pre block
02:32hellofunkpilates? good for the muscles
02:35justin_smithI read "java concurrency in practice" recently, and one thing I noticed was how often they talked about things that must be invariant but could not be expressed directly in the language
02:35justin_smithwhich smells funny, to be sure
02:37gwsif i'd like to call a method in one namespace on something created via deftype in another namespace, is the idiomatic way to do that just dot-notation?\
02:39justin_smithgws: yeah, and use import in the other namespace
02:40justin_smithgws: the exception being if you implement a protocol, then you should use require to bring the protocol functions into scope, and use those
02:40justin_smithbut for regular methods just use dot notation
02:43gwsjustin_smith: ah, thanks! i am implementing a protocol, actually... though simply requiring the type's constructor (e.g. ->MyType) without the imports (which works). when i try to require the protocol functions into scope, i get "no such var"
02:43gwshowever dot-notation works
02:44justin_smithhow are you doing the require?
02:45gws[myns.mail :as mail] in an ns form, then mail/mymethod - is it necessary to :refer?
02:46justin_smithno, that should all work
02:47justin_smithmyns.mail is where you define the protocol, correct?
02:47gwsalright, thanks. let me check again. if i can't make it work, i'll reduce it and put the code up somewhere
02:47justin_smiththe protocol functions need to be pulled in from the ns that defines the protocol, not the one where you define the type implementing the protocol
02:48gwsthis is code that I haven't refactored properly so they are not yet separate namespaces. is that my problem?
02:49gwsin other words, deftype and defprotocol are in the same ns
02:49justin_smithnope, that would even prvent this problem
02:50justin_smithone moment, let me try to find a place on github in one of my projects that demonstrates this stuff
02:51gwssorry i missed it - yes, myns.mail is where both defprotocol and deftype are
02:52justin_smithhttps://github.com/caribou/caribou-c3p0-plugin/blob/master/src/caribou/plugin/c3p0.clj here is an ns implementing a protocol (using a defrecord)
02:52justin_smithhttps://github.com/caribou/caribou-plugin/blob/master/src/caribou/plugin/protocol.clj here is where the protocol and the convenience function that implements it for that record are defined
02:53justin_smithboth quite small namespaces, so it should be pretty straightforward to see what is being done
02:53ddellacostaa macro that defines helper functions and an instance of a type in a namespace: ugly? Is there a better strategy for configuring a set of easy-of-use helper functions?
02:53ddellacosta*ease-of-use
02:54justin_smithddellacosta: the annoying part is when I try and use that namespace, and look for the definitions of said instance and convenience functions
02:55ddellacostajustin_smith: yeah, that's my reservation too. But I should be more clear--this would be something the user of the lib would call in their own application
02:55ddellacostajustin_smith: so they'd do something in my.ns like (init-lib! arg1 arg2 arg3 arg4)
02:55ddellacostajustin_smith: and then they'd be able to call my.ns/helper1, my.ns/helper2
02:55justin_smithhmm
02:56justin_smithseems like it is just passing the buck, because their code ends of having said problem
02:56ddellacostajustin_smith: to give a bit more explanation, what I'm trying to avoid is that the user calls the lower-level fns every time with four args
02:56ddellacostatwo or three of which may never change during the lifetime of that lib user's application
02:57ddellacostajustin_smith: it's passing the buck in one sense, but it's also try to avoid them typing redundant crap all the time
02:57ddellacostajustin_smith: I'm just really not sure how to structure this so that the user can set up these defaults in a clean way, and have them available consistently
02:57justin_smithwhat about making the functions so that they return the params as an options map, such that they can be chained?
02:58ddellacostajustin_smith: sorry, I don't follow--how would that avoid having the user have to call the functions with those args every time?
02:59justin_smithoh, I misunderstood, sorry
02:59justin_smithI thought you meant multiple functions taking the same args
02:59justin_smithbut you mean multiple calls with the same args
02:59ddellacostajustin_smith: oh, yeah, exactly
03:00amalloyddellacosta: instead of passing the same four args to N functions, they could pass one map to the N functions, i think is what justin_smith was suggesting
03:00justin_smithwell, then in that case you can have them use a configuration map - see how the connection data is in a map as the first arg to just about every clojure.java.jdbc function
03:00justin_smithyeah, pretty much
03:00ddellacostaamalloy, justin_smith: yeah, maybe a config/option map is really the right way to do this
03:01ddellacostait seems a bit uglier, but I'm wary of macro magic
03:01justin_smithan options map is easy for a user to wrap if they find it cumbersome
03:01justin_smithby defining a partial for example
03:02ddellacostajustin_smith: yeah
03:02justin_smithbut better that than scratch my head over where something is even defined, IMHO
03:02ddellacostaagreed
03:02ddellacostaokay, thanks!
03:09gwsjustin_smith: thanks for the code. i reduced it to an example which is very similar to mine, and it does work as I expected - so I've got bigger problems
03:09gwshttp://pastebin.com/e1Npfhtt
03:09gwsjustin_smith: i'll dig in to this, but good to know it works as I originally thought :)
03:10justin_smithso is the pasted one the one that works?
03:10gwsyep
03:11gwswhich is how i expect it to work
03:15gwsi think your point about needing to pull in the ns in which the protocol is originally defined was my problem
03:15gwsI've got a second deftype in there which implements a protocol from a different ns
03:15gwsugh
03:15gwsso that's the issue
03:15gwsgot it now, thanks
03:16justin_smithnp
03:24dfg888selling intim
03:41allenj12has anyone compared hoplon vs reagent vs om?
03:46allenj12it seems hoplon is much more mature than om
03:46allenj12and reagent to for that matter
03:46michaniskinallenj12: i can answer any questions you have about hoplon
03:48allenj12michaniskin: ok well let me put it like this i was going through the om tutorials, and to be honest they kinda sucked it was hard to tell what om was doing alot of the time. i guess my questons are is hoplon mature? does hoplon have better docs than om? and is hoplon easy?
03:49allenj12michaniskin: like literally oms advance tutorial was a blank page, it was quite sad
03:49michaniskinallenj12: you should look at http://hoplon.io/#/getting-started/
03:50michaniskinthat will give you an idea of what it's like
03:50allenj12michaniskin: just am now it looks way better already, im assuming its more popular than om?
03:50michaniskini don't know if it's exactly "easy", but i think it's pretty simple
03:51michaniskinthere aren't a lot of things to know about it, really, but it is kind of weird
03:51michaniskinonce you get over how weird it is i think it's pretty straightforward
03:52michaniskini think it's a lot less popular, but it's hard to tell
03:53allenj12michaniskin: o really? im assuming you prefer it tho? and theres good reason to?
03:53justin_smithallenj12: om is a specific lib for optimizing re-rendering of dynamic changes to pages, I think it can be used inside hoplon even
03:53michaniskini'm one of the guys working on it :)
03:53kzarallenj12: There definitely was quite a bit of coverage of Om on hacker news a while back and I've heard less hype about hoplon. But more hype does not better technology make. (I regretfully still haven't tried either in earnest.)
03:53kzarI think both are worth giving a try
03:53justin_smithallenj12: you will probably figure things out faster if you start without om and then start using it if you need its features
03:54michaniskinallenj12: you might want to look at the demos: https://github.com/tailrecursion/hoplon-demos
03:54allenj12hmm alright it seems so far html files arent rly used here? interesting
03:54michaniskinwe're adding things all the time (whenever i do something new for work and i can open source it i throw up a demo there)
03:55allenj12michaniskin: oo cool
03:55michaniskinallenj12: we have a contrib library now, with some libraries you can use: https://github.com/tailrecursion/hoplon/tree/master/contrib
04:00allenj12michaniskin: boot development dosnt work for me, is there a way to fix that?
04:00michaniskinallenj12: what happens? exception?
04:01allenj12no its just not a command...
04:01kzarIs there a good static site generator like Jekyll written in Clojure?
04:01allenj12michaniskin: does it matter im in windows now?
04:02michaniskinallenj12: ah, windows. did you try this: https://github.com/tailrecursion/boot#windows ?
04:03michaniskinwe need to work on windows support for boot, it's on the list
04:03allenj12michaniskin: hate windows :p cant wait till i re image my slackware, yea im trying it now
04:04michaniskinallenj12: you may need to do `java -jar boot.jar ...`
04:04michaniskinit's executable in unix or if you have cygwin
04:04michaniskinare you using cygwin?
04:06allenj12michaniskin: its pretty much a fresh windows now. had to re image
04:07allenj12michaniskin: i think its working tho :p
04:08michaniskinallenj12: awesome
04:11allenj12michaniskin: dam how long is it suppose to take tho
04:13michaniskinallenj12: how long to do what? it should take maybe 20 sec to compile the first time
04:13allenj12michaniskin: im at 5 min
04:13michaniskinthen after that if you're using the watch task it'll be fast
04:14michaniskindo you see like a stopwatch with elapsed time ticking?
04:14allenj12michaniskin: well its just printing the time like ever so sub seconds
04:15michaniskini think it's done :)
04:15michaniskinwhen it finishes compiling it prints the elapsed time since the last compile
04:15michaniskini sometimes don't trust it that it really recompiled my application, so i like being able to see when the last time it compiled was
04:15allenj12michaniskin: oooo hahahha im silly :)
04:16michaniskinbelt and suspenders
04:16michaniskinlol
04:16allenj12so the last thing i should see before all those prints is compiling clojurescript....
04:16michaniskinright
04:17allenj12gotcha
04:17michaniskinif you are using the local jetty server you will see some stuff about it starting that
04:28allenj12michaniskin: do you know how to add highlighting to lighttable for hoplon? i tried http://stackoverflow.com/questions/21793023/clojure-how-to-associate-hl-files-to-clojure-syntax-highlighting-in-light-tabl and a solution on the group but neither worked for me
04:29michaniskinallenj12: hm, i dunno, i think that worked for me, but it was a little while ago
04:30allenj12michaniskin: hmm alright
05:13allenj12michaniskin: hey i just wanted to let you know the tutorial was great! im pretty brand new to web dev (mostly just an ai guy) and this actually taught me alot other libraries didnt but had included.
05:14michaniskinallenj12: thanks :) what kind of ai?
05:15allenj12michaniskin: well im doing my masters in cognitive science right now and do alot of social modeling using cognitive architectures, in almost all other times when im not working on that, im doing machine learning of some kind. i also hope to move into the field of AGI and research generalizid systems
05:16allenj12machuga: althought AGI is kinda a joke right now :)
05:18allenj12btw out of curiosity no one here would happen to be a lawyer right?
05:23mi6x3mallenj12: do you need one?
05:24allenj12mi6x3m: well eventually i just have some questions about what defines gambling. its related to what im working on right now and picking up web dev :)
05:24allenj12mi6x3m: i did some research and i think im in the clear but i just wanted to make sure
05:25michaniskinallenj12: that sounds exciting and mysterious
05:25mi6x3mallenj12: which jurisdiction?
05:26allenj12new jersey.
05:27allenj12michaniskin: haha i yea im pretty much chose the path of acadamia forever, so i wanted to start this company while i did my masters etc... im pretty excited for it :)
05:28mi6x3mallenj12: oh, that's quite far
05:28allenj12mi6x3m: far from where?
05:28mi6x3meurope
05:28allenj12mi6x3m: o lol
05:28mi6x3maren't there some official guidelines of what to be aware?
05:29allenj12mi6x3m: ehh i mean we would just kinda be in a grey area it seems, its hard to tell from what we read so far
05:52mping_hi
06:11ddellacostamping_: hi
06:16mping_can you guys help me out? I'm trying to debug a ring app with cursive clojure
06:16mping_(ddellacosta: it's funny I'm using your lib for oauth2)
06:17cflemingmping_: what's happening?
06:17mping_I would like to debug a running ring app with step by step debugging (a la java et al)
06:17cflemingOk
06:17mping_I'm still quite new in clojure land
06:17mping_I configured ring to start an nrepl server
06:17cflemingNo worries :-)
06:17ddellacostamping_: cool. :-)
06:18mping_and I've managed to connect cursive clojure to it
06:18mping_I'd like to set up a breakpoint in the ide
06:18mping_and hit an url, and debug from there
06:18mping_but I guess that's not the way things work hehehe
06:18cflemingHehe
06:19cflemingSo you're starting the REPL outside of Cursive, and then connecting to it using a remote run configuration for your REPL?
06:19mping_yep
06:19mping_i've got this in a lein profile:
06:19mping_:dropbox {:ring {:handler friend-oauth2-examples.dropbox-handler/app :nrepl {:start? true :port 3333}}}
06:20cflemingOk, so Cursive normally assumes that you're starting the REPL within Cursive itself, then if you start it in a debug config it can start the JVM in debug mode
06:20cflemingTo debug the JVM you need some system properties at startup
06:20cflemingSo you should be able to add those properties manually and connect a remote debugger to it
06:20cflemingTry this:
06:21cflemingRun->Edit configurations
06:21cflemingCreate a Remote debug configuration
06:22mping_ok
06:22cflemingUnder Command line arguments for running remote JVM it gives you some system properties to copy and paste
06:22cflemingYou'll need to add those to lein, so the JVM gets started in debuggee mode
06:22cflemingThe next step is to cross your fingers :-)
06:22mping_*fingers crossed*
06:23mping_duh! I tried this before but tried to connect as lein remote app
06:23mping_its working :)
06:23cflemingNice :-)
06:23mping_thanks!
06:23cflemingThe debugger is still a little flakey from time to time
06:24cflemingI need to fix it up
06:24cfleming(Cursive dev here, BTW)
06:25mping_hey, since you are a cursive dev: what's with the backspace key? it doesn't normally delete things...
06:25john2xdoes (.method instance "foo") return the instance if the method returns void?
06:25cflemingThat'll be the structural editing (like paredit) mode.
06:25mping_I must have configured it badly. it seems like I'm using vim or something
06:25mping_aah....
06:25danielcomptoncfleming is the debugger specific to cursive or can it be used elsewhere too?
06:26cflemingmping_: check https://cursiveclojure.com/userguide/paredit.html
06:26cflemingYou can turn it off if it annoys you, but it's worth getting used to it
06:26cflemingdanielcompton: it's mostly just the built-in IntelliJ debugger.
06:26danielcomptoncfleming I suspected as much
06:27cflemingIt has some customisations for Cursive, but not many at the moment. I'm planning to add a lot more.
06:27cflemingInstead of the Java-style expression evaluation I'm going to add a debug REPL
06:28danielcomptoncfleming: so you could pause and expect the environment at any point?
06:28danielcomptoncfleming: and execute arbitrary clojure code?
06:29cflemingYeah
06:29cflemingYou can already do that, but the evaluation is flakey right now
06:29cflemingI need to fix the symbol resolution there.
06:30cflemingI'm still not sure how customisable the debugger is, I think it's pretty flexible.
06:30cflemingCurrently you can't access closed-over locals, which is a pain
06:31cflemingFor some reason the debugger is incredibly slow with Clojure too, I don't know why
06:31danielcomptoncfleming, that's where it would be most handy too
06:32cflemingdanielcompton: yeah, it's still really useful though. I couldn't get through the day without it.
06:32cflemingSince I'm essentially working with a huge ball of someone else's code.
06:33danielcomptoncfleming do you use tools.trace?
06:33danielcomptoncfleming: I tend to use that for my debugging/reasoning about a program most of the time
06:33cflemingdanielcompton: No, I haven't.
06:34danielcomptoncfleming: but I haven't learnt how to use the debugger so I don't know what I'm missing on that side
06:34cflemingMy problem is generally that the code that I don't understand isn't mine, and is Java
06:34cfleming(the IntelliJ platform)
06:36danielcomptoncfleming mmm, I'll bet your java interop skills are pretty good!
06:37danielcomptoncfleming: how much of cursive is clojure vs java code (that you've written)?
06:37cflemingdanielcompton: Yeah, sadly
06:37cflemingdanielcompton: nearly all of what I write is Clojure now, unless I'm taking + customising code from IntelliJ
06:38cflemingdanielcompton: but Clojure's interop is lacking some features I need, so I still write a lot of Java shims then call into Clojure
06:39danielcomptonhahaha I just wrote defn- main, instead of defn -main
06:39danielcomptonthat was a headscratcher
06:39danielcomptoncfleming: did you come from a java background?
06:40cflemingdanielcompton: Yeah, I worked with Java (and IntelliJ) for about 10 years or so
06:41danielcomptoncfleming were you developing plugins for intellij or using it as your IDE?
06:41cflemingdanielcompton: using it as my IDE, and I wrote a few small plugins
06:41cflemingdanielcompton: I started one for Scheme, and a few smaller things
06:42danielcomptoncfleming neat!
06:44mping_do you guys recommend any ring app for me to study? I've dabbled in clj but still don't have a solid idea on how things should look
06:44mping_things like validation, etc
06:47mi6x3mis there a variant of defmulti allowing you to specify multiple dispatch values?
06:50cflemingmping_: No sorry, I've never done any web dev in Clojure. I think clojars might be open source.
06:50cflemingmi6x3m: I've never tried it, but I think you could dispatch on a vector of values
06:52kzar:o just had a phone interview for a clojure job *waits of an email*!
06:53mi6x3mkzar: grats :)
06:53kzarfor*
06:53kzarThank
06:53mi6x3mwhat kid of job / location / specifics?
06:53kzarmi6x3m: Arg can't type this morning, I meant to say "Thanks, but let's see!"
06:54kzarFeel shy to talk specifics to be honest
06:55kzarHas anyone used the stasis static site generator library here? (Is it any good?)
06:57mi6x3mis there a clojure function consuming arguments and doing nothing?
06:58kzarmi6x3m: identity?
06:58kzar,(identity 2)
06:58clojurebot2
06:58mi6x3m,(identity 2 3 4)
06:58clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core/identity>
06:58mi6x3mnope
06:58kzar,(apply identity [2 3 4])
06:58clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core/identity>
06:59kzarwhoops sorry, dumb idea
06:59CookedGryphon,((constantly nil) 1 2 3)
06:59clojurebotnil
06:59kzarmi6x3m: When you say "doing nothing" do you mean returning what you've passed in as a sequence?
06:59mi6x3mno, returning nil
06:59kzaroh
07:00mi6x3mjust a black hole for stuff
07:00mi6x3mtnx CookedGryphon
07:00kzarmi6x3m: Something like (fn [& args]) ?
07:01kzar,((fn [& args]) 1 2 3 4)
07:01clojurebotnil
07:01mi6x3myes
07:01kzar(May I ask, why yo would want such a thing?)
07:01kzaryou*
07:02mi6x3mI am writing a library extending seesaw with some exotic components
07:02mi6x3mso I need all types of weird gizmos :)
07:02kzarOK
07:02kzarsay no more heh
07:05gfredericksmi6x3m: (constantly nil)
07:06gfredericksunless by "consuming arguments" you mean something related to laziness
07:06mi6x3mgfredericks: yes this is what I was needing :)
07:06mi6x3mcfleming: so about this vector thing for multimethods
07:07mi6x3m(defmethod mymethod [[dispatcher-1] [dispatcher-2]] ....
07:07mi6x3mi was imagining something like that
07:09cflemingI think you can only have one dispatcher, but it can be (fn [x] [(dispatcher-1 x) (dispatcher-2 x)])
07:10cflemingAgain, I think - I've never tried this
07:10cflemingDon't see why it wouldn't work though.
07:10mi6x3mah
07:10mi6x3ma function dispatcher
07:10mi6x3mi see
07:11cflemingSorry, I meant that would have to be the dispatcher function that you would use with defmulti
07:11mi6x3myeah, I understand
07:11cflemingIn fact, the example here is what you want, right? http://clojuredocs.org/clojure_core/clojure.core/defmethod
07:12cflemingI guess it does work :-)
08:45jcidahohi - some macro magic needed. Is it possible to get the name of a surrounding fn?
08:51TimMcjcidaho: Hmm, I remember a conversation about this last week.
08:51Bronsajcidaho http://sprunge.us/RgMd
08:52jcidahonice :-) Good hackery, thanks
08:52Bronsajcidaho needles to say, don't use this in Real Code™
08:52jcidahoyeah right ;-)
08:53mi6x3mhey, what is a way to stop the namespace expansion in syntax quote?
08:53mi6x3mfor instance to avoid arguments being expanded
08:53mi6x3mor is it safe to expand arguments?
08:53Bronsa'`~'a
08:53Bronsa,`~'a
08:53clojurebota
08:54Bronsami6x3m: though you porbably want to use the auto-gensym feature
08:54Bronsa,`(do a# a#)
08:54clojurebot(do a__49__auto__ a__49__auto__)
08:56mi6x3mBronsa: here's my code for clarity http://pastebin.com/zdpGC5Me
08:57mi6x3mit generates a native java Adapter instance from a set of requested events
08:57Bronsami6x3m: yeah, relace ~' with e#
08:57mi6x3mevent-fn should have ~' though, no?
08:57mi6x3monly e should be #
08:58Bronsami6x3m: it looks like event-fn should be unquoted though, I don't see how that'd work otherwise
08:59TimMcBronsa: Man, where were you last week? THat's a much better solution. (The thisName thing.)
09:04no7hingdoes anybody know of a vector math library for clojurescript ?
09:06mi6x3mBronsa: yeah well technically 'e' doesn't need the gensym, but it doesn't hurt having it
09:06mi6x3msince e is an indepedent parameter name, but i see your point
09:06mi6x3mthanks works nicely :)
09:11BronsaTimMc: it will work only for (fn name [] ..) though, I don't think it will for (defn name [] ..)
09:11Bronsaeven though there should be a way to make that work too
09:13TimMcBronsa: I don't see why it wouldn't work.
09:13BronsaTimMc: defn expands to (def x (fn [] ..))
09:14TimMcHuh, I would have expected it to fill in the function name.
09:16Bronsalooks like if you want it to work with defn yoo you have to use .name and do some unmunging
09:16hyPiRionTimMc: That would've destroyed all the (alter-var-root #'foo memoize) calls out there
09:18hyPiRion,(defn fib [n] (if (< n 2) 1 (+ (fib (- n 1)) (fib (- n 2)))))
09:18clojurebot#'sandbox/fib
09:18hyPiRion,(alter-var-root #'fib memoize)
09:18clojurebot#<core$memoize$fn__5097 clojure.core$memoize$fn__5097@1ab7a89>
09:18hyPiRion,(fib 70)
09:18clojurebot308061521170129
09:23TimMchyPiRion: Ah, interesting point!
09:27hyPiRionyeah, I found it out when I tried to memoize a recursive anonymous function =(
09:30roppongininjaHello! Can someone help me me out?
09:30roppongininja(ns miw-projekt-2.core
09:30roppongininja (:require [clojure.java.io :as io]))
09:30roppongininja(def data-file (io/file
09:30roppongininja (io/resource
09:30roppongininja "dane1.txt")))
09:30roppongininja(defn -main []
09:30roppongininja (println (slurp data-file)))
09:30roppongininjaException in thread "main" java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil
09:32bcarrellyou don't need io/file, io/resource gives you an instance of java.io.File, which you can slurp
09:35roppongininjaI still get Exception in thread "main" java.lang.IllegalArgumentException: No implementation of method: :make-reader of protocol: #'clojure.java.io/IOFactory found for class: nil
09:37Glenjaminwhat does (io/resource "dane1.txt") give you?
09:39TimMcroppongininja: Please use a pastebin next time you want to share code. (e.g. refheap.com)
09:41mdrogalisTimMc: I kind of wish we had one named ParenBin
09:43TimMcmdrogalis: Buy the domain and fork refheap. :-P
09:45mdrogalisTimMc: ParenPool. Oh, I'm full of it today.
10:28ddellacostacan someone tell me what is going on here?
10:28ddellacosta,(map repeat (repeat 3) [1 2])
10:28clojurebot((1 1 1) (2 2 2))
10:29ddellacostaif map applies f (repeat in this case) to each value of each collection in turn, what is it taking from the infinite sequence produced by (repeat 3) ?
10:29ddellacostaand how does that produce two instances of the values from the last collection [1 2] ?
10:33roppongininjadoes anyone here have a few minutes (more like 10-20) for a total noob?
10:34ddellacostaroppongininja: if you have some questions just put 'em out there
10:34ddellacostaare you actually in Roppongi, btw?
10:34roppongininjanope
10:34roppongininjaunfortunately no
10:35roppongininjaare you? ;)
10:35ddellacostaroppongininja: coincidentally, I may go there tomorrow to work. :-)
10:35ddellacostaroppongininja: this is an awesome workspace, on the 49th floor of Mori tower: http://www.academyhills.com
10:35ddellacostaroppongininja: but I digress
10:35roppongininjaddellacosta: nice man! I'm happy for you.
10:35ddellacostaroppongininja: what was your question?
10:36ddellacostaroppongininja: yeah, I have no complaints. :-)
10:36roppongininjaWould you mind talking via private messages because those are some real dumb ass questions
10:36ddellacostaroppongininja: well, that's totally cool but you shouldn't feel embarrassed, and others may benefit from your questions
10:36roppongininjathat I have for you :P
10:36ddellacostabut sure. :-)
10:36mping_roppongininja: that way the rest of us won't learn
10:37ddellacostaroppongininja: see, what did I say? ^
10:37ddellacosta;-)
10:37mping_ddellacosta: any suggestion on how to use multiple oauth2 providers with friend-oauth2?
10:37roppongininjamping_: I assure you that you won't learn anything from me!
10:37ddellacostamping_: er, I'm working on it. :-(
10:37mping_eheheh :)
10:37ddellacostamping_: so unfortunately not as of yet...
10:38roppongininjaI was given this assignment "For the data in the file it daneXX.txt 1 Suggest a linear parametric model and then specify the parameters of the model using the least squares method."
10:38roppongininjaI know how to do it in java, but I want to learn clojure so I thought that I'll just do it in clojure
10:38ddellacostaroppongininja: dude, I thought you were going to ask a Clojure question...haha
10:38mping_haha
10:38mping_ddellacosta: oh well, I may give this a go: https://github.com/oauth-io/oauthd
10:39mping_keep up the good work though
10:39roppongininjaI basiclly skimmed a book on clojure in 3-4 hours and now have little to no idea how to start actually xD
10:39ddellacostamping_: let me know how it goes!
10:39ddellacostamping_: I need to make this work with multiple providers...*sigh*...soon
10:40ddellacostaroppongininja: well, unfortunately my math is a bit crap so I may not be able to help too much with the specifics
10:40roppongininjaI know the math
10:41ddellacostaroppongininja: so, that's good. Then I guess the question is, what is the first thing you know you need to do?
10:41roppongininjawow sorry freenode kicked me out for some reason
10:41ddellacostad'oh, dunno if you saw my last message:
10:41ddellacosta"so, that's good. Then I guess the question is, what is the first thing you know you need to do?"
10:42roppongininjaanyway I know the math and I have already implemented this program in java, now I just want to translate it to clojure (thats not required by my course) in hopes of learning something
10:42roppongininjamaybe not something, but clojure :D
10:42ddellacostaroppongininja: oh, okay. So, are you familiar at all with Java interop stuff? http://clojure.org/java_interop
10:43ddellacostaroppongininja: one approach I can suggest would be to do the "naive" translation from Java to Clojure using interop
10:43ddellacostaroppongininja: and then you can throw it in a gist/refheap or what not and let folks on IRC take a look
10:43roppongininjaddellacosta: familiar is not the right word, but I have skimmed through that
10:44roppongininjaddellacosta: I don't want to translate anything from java and I want to use as little java as possible
10:44ddellacostaroppongininja: I mean, unfortunately I think it's actually rather hard to learn Clojure the way you're proposing--it's actually easier to start out by writing "Clojure-esque" Clojure, if you know what I mean
10:44ddellacostaroppongininja: yeah, I think that's probably a good idea
10:44ddellacostaroppongininja: are you using a lot of 3rd-party libs in your Java code?
10:45roppongininjaddellacosta: the idea is not to do this assignment but to actualy learn something by doing it, because I just can't stand reading books, even on my ADD medication
10:45ddellacostaha
10:46ddellacostaso, re: 3rd-party libs ^ ?
10:46roppongininjaddellacosta: I am not using any
10:46ddellacostaroppongininja: okay, that should make it simpler. Do you want to put the Java in a gist or something so we can take a look?
10:47roppongininjaddellacosta: sure I can but I don't want you to write a solution if you know what I mean :P I'm not asking for doing my homework
10:47ddellacostaroppongininja: no, not at all! It's more that, I'm having a hard time figuring out how to suggest you should try things in Clojure without having a sense of what you're working on
10:48ddellacostaroppongininja: I mean, I can give you some general tips, like--think about the data structures you're using and restructure them as Clojure immutable data structures. That's probably the big one.
10:49roppongininjaddellacosta: ok just a second I'm changing the variable names to english :P
10:49ddellacostaahaha, okay
10:49ddellacostawhat language were they in originally, if you don't mind me asking?
10:50roppongininjapolish
10:50roppongininjaaka russian with latin letters
10:51ddellacostaroppongininja: haha, okay. Yeah, I would have been useless with that. :-)
10:52gavilancomun,(map #(list %1 %2) (repeat 3) [1 2])
10:52clojurebot((3 1) (3 2))
10:53ddellacostagavilancomun: is that based on what I posted above, perchance?
10:53gavilancomunsure
10:53ddellacostagavilancomun: do you know what is going on with the (repeat 3) there? I'm a bit stumped
10:54gavilancomunmap is taking the first element of each coll, then the second of each coll
10:55gavilancomunThose pairs are then fed to the first repeat in your example
10:55ddellacostaoh, I see, in that case repeat is just producing an infinite sequence of 3s, huh
10:55ddellacostaI guess then what I don't understand is what the first repeat is doing here:
10:55ddellacosta,(map repeat (repeat 2) [1 2 3])
10:55clojurebot((1 1) (2 2) (3 3))
10:55gavilancomunYes, the (repeat 3) is lazy, so as there are only 2 elements in the vector [1 2] it only contributes two 3s
10:56ddellacostagavilancomun: ah, so, I guess the infinite sequence of 2s that (repeat 2) produces becomes the first argument to repeat, which generates a partial, which then gets applied to the values in the [1 2 3] ?
10:57gavilancomun,(doc map)
10:57clojurebot"([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & ...]); Returns a lazy sequence consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remaining items in other colls are ignored. Function f should accept number-of-colls arguments."
10:58gavilancomunNot sure you need to involve the notion of a partial...
10:59gavilancomun,(map #(list %1 %2) (repeat 2) [1 2 3])
10:59clojurebot((2 1) (2 2) (2 3))
11:00gavilancomunmap makes the pairs which then get fed to repeat
11:01ddellacostagavilancomun: right, I see, I was misreading it. Thanks!
11:01gavilancomunnp :-)
11:02gavilancomun,(map list (repeat 2) [1 2 3])
11:02clojurebot((2 1) (2 2) (2 3))
11:02gavilancomunThere you go, no need for the %
11:37agarmananyone have an opinion on congomongo v. monger?
11:41roppongininjawhy does clojure.java.io/reader work and (:require clojure.java.io)) with just reader doesnt
11:42cbp`roppongininja: those are two different things. Can you explain better what's not working?
11:43roppongininjasomething like this works http://pastebin.com/qUmgkWsG
11:44justin_smithroppongininja: require does not bring symbols into scope, use or :as do
11:44roppongininjasomething like this doesnt
11:44roppongininjahttp://pastebin.com/fcYinAGp
11:44roppongininja(sorry for flooding : /)
11:44justin_smith(:require [clojure.java.io :as io]) ... (io/reader ...)
11:45cbp`roppongininja: the first one working is a fluke
11:46cbp`roppongininja: you want what justin_smith wrote or (:require [clojure.java.io :refer [reader]])
11:49roppongininjaOk thanks guys :)
11:52justin_smithcsound devs are working on Clojure integration http://csound.github.io/site/news/2014/06/09/score_library_clojure.html
11:59deathknightIs there a zero-to-hero guide regarding clj-http (or its alternatives) and making API calls with google apps?
12:02roppongininjaI have a file, which in each line has 2 doubles (2 values). How do I read that file and write first values in each line into one map and second values in each line into another map?
12:03cbp`roppongininja: how big is the file?
12:03roppongininjasmall
12:04roppongininja4kb
12:04deathknightI'm interested in the answer to this also *_*
12:06dbaschroppongininja: what are the keys and values of each map?
12:07roppongininjait should be the row number (line number) but insted of a map you can use a list as well
12:07roppongininjaif that'll be easier
12:08dbasch1) slurp the file (because it’s small)
12:08dbasch2) split it by \n
12:09dbasch3) map split by space to each line
12:09dbaschthat will give you a 2 x n matrix of strings representing doubles
12:10CookedGryphonor get an io/reader on the file and use line-seq rather than slurp and split by \n
12:10dbaschyes, it makes no difference for a 4k file though
12:11dbaschthen you can do apply map vector to the result, and now you have an n x 2 matrix
12:11justin_smithhttps://www.refheap.com/86402 alternately, line-seq
12:12dbaschjustin_smith: faster to write than to explain :P
12:13dbaschalthough that’s not what he wanted
12:13deathknightI can't wait until that refheap is like english
12:14justin_smithhttps://www.refheap.com/86402 updated to key in the maps by line number
12:15justin_smithdbasch: I think that's what he wanted now, I just went ahead before the spec was fully described knowing it would be easy to adapt
12:28roppongininjahow do I split a string containing two doubles into two doubles? :)))
12:29gfredericksthe haxy way is
12:29gfredericks,(def s "3.14 6.28")
12:29clojurebot#'sandbox/s
12:29justin_smithroppongininja: see my paste, it is in there (map (partial read-string) ...
12:29gfredericks,(read-string (str \[ s \]))
12:29clojurebot[3.14 6.28]
12:30justin_smith,(map (comp (partial map read-string) #(string/split % #" ")) "1 2")
12:30clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: string, compiling:(NO_SOURCE_PATH:0:0)>
12:30justin_smith,(map (comp (partial map read-string) #(clojure.string/split % #" ")) "1 2")
12:30clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.CharSequence>
12:30justin_smithergh
12:30dbaschroppongininja: https://www.refheap.com/86405
12:30justin_smith,((comp (partial map read-string) #(clojure.string/split % #" ")) "1 2")
12:30clojurebot(1 2)
12:30justin_smiththere we go
12:31mindbender11justin_smith: those are not doubles
12:35dbaschhttps://www.refheap.com/86406
12:36justin_smithmindbender11: fair point
12:36justin_smith,((comp (partial map read-string) #(clojure.string/split % #" ")) "1e0 2e0")
12:36clojurebot(1.0 2.0)
12:36mindbender11,((comp (partial map read-string) #(clojure.string/split % #" ")) "1.0 2.0")
12:36clojurebot(1.0 2.0)
12:37dbaschI’m sure it could be prettier, but my paste does what roppongininja asked
12:38justin_smithdbasch: definitely prettier than the piece of shit I pasted :)
12:40dbaschjustin_smith: still my last line is pretty ugly
12:57TimMcjustin_smith: Now do that to "NaN Infinity"
12:58justin_smith,((comp (partial map read-string) #(clojure.string/split % #" ")) "NaN Infinity")
12:58clojurebot(NaN Infinity)
12:58justin_smithOK
12:58justin_smiththat's cheating, those are symbols :)
12:58TimMc&(-> "NaN" read-string class)
12:58lazybot⇒ clojure.lang.Symbol
12:59TimMc&(-> "NaN" (Double/parseDouble) class)
12:59lazybot⇒ java.lang.Double
12:59justin_smithright
12:59justin_smithif you really know it is all doubles parseDouble is clearly better
13:00TimMcThat means EDN is not good for round-tripping floats. :-(
13:01BronsaTimMc: just use tools.reader and that should work :D
13:06ticking_am I missing something or is there no good way to get a predicate matching element from a sequence and have the item and rest of the sequence returned?
13:06cieloesazulhi, how can I run all of the tests in the clojure repo?
13:06justin_smith,(group-by even? (range 10)) ticking_:
13:06clojurebot{true [0 2 4 6 8], false [1 3 5 7 9]}
13:07justin_smithcieloesazul: if it is set up properly, lein test should do it
13:08justin_smith,(group-by #(= % 1) (range 5)) ticking_: if you only expect one match, it would look like this
13:08clojurebot{false [0 2 3 4], true [1]}
13:09ticking_justin_smith: yeah but I want only one element aka `some` like behaviour similar to ,(let [{t true f false} (group-by even? (range 10))] [(first t) (concat (rest t) f))
13:10ticking_sorry, ,(let [{t true f false} (group-by even? (range 10))] [(first t) (concat (rest t) f)])
13:11tbaldridgecool news - https://twitter.com/richhickey/status/476048628289925121
13:11Bronsawooo!
13:12cieloesazuljustin_smith: to be clear, I'm asking about the clojure source code, not a lein project. btw, I tried lein test and it complained there was no project.clj.
13:12justin_smith,((juxt #(first (filter even? %)) identity) (range 4))
13:12clojurebot[0 (0 1 2 3)]
13:12ticking_,(let [{t true f false} (group-by even? (range 10))] [(first t) (concat (rest t) f)])
13:12clojurebot[0 (2 4 6 8 1 ...)]
13:12justin_smithcieloesazul: then you need to set up your classpath properly, load all the namespaces manually, and then call clojure.test/run-tests
13:12ticking_tbaldridge: wow awesome
13:12justin_smithcieloesazul: setting up a lein project is easier
13:14ticking_cieloesazul: clojure without lein = madness unless you have a really really really good reason
13:14justin_smithtbaldridge: wow, that is huge
13:14bbloomtbaldridge: haha awesome
13:17ticking_am I the only one for whom the name field does not work -.-
13:18hyPiRionoh man, awesome that you now can sign the CA online
13:18RaynesYou can?
13:18RaynesDear God
13:18RaynesThe 21st century
13:18RaynesFeels good
13:19cieloesazulticking_: looks like you have to fill in the signature first and it autofills the name
13:20bbloomi like the official legal term "Rich Hickey Contributor Agreement"
13:20ticking_cieloesazul: seems so, feels still broken to me ^^
13:20bbloomlike we're contributing to the six million dollar man or something
13:21justin_smithhe should offer hickey-bonds
13:21danneui've been using the RHCA on my own projects
13:22pjstadigthe RHCA is just the Sun CA with some names changed
13:22danneuit's a nice rate limiter for the hordes of contributers my projects attract
13:22pjstadig(which was the intent with the Sun CA)
13:29cieloesazulticking_, justin_smith, I should have looked at the dev.clojure.org site before asking. I did `mvn test` and it worked. thanks
13:29justin_smithcieloesazul: do you have a pom.xml then?
13:29silasdavisI'm using a zipper, I need an efficient way to go from a zipper location of a node (say loc(node)) to (loc(child)) given that I have the child
13:30silasdavisI could (-> node-loc zip/down zip/right ...)
13:30silasdaviswhere zip/right gets me to the appropriate child
13:33cieloesazuljustin_smith: yes. it's the clojure language source code from github. it contains a pom.xlm file
13:33justin_smithahh, OK
14:27amalloyticking_: i think you want drop-while: (let [[first-matching & more] (drop-while (complement pred) coll)] ...)
14:30amalloyreading the scrollback more carefully, it looks like you don't want to drop the non-matching items, but rather surgically remove the first matching item from the middle of the sequence and keep all the rest? that's not a very good access pattern for sequences; maybe you can use a set or a multimap or something that supports efficient removal from the midd
14:30ticking_amalloy: not quite, other should contain everything that came before the match as well but you just gave me an idea
14:33ticking_amalloy: yeah, that is the thing I'm looking for, you're probably right as for the access pattern :)
14:34ticking_I thought I could do this with split-with but that wouldn't work either
14:40dbaschticking_: why won’t split-with work?
14:43ticking_dbasch: you would need to inverse the predicate for the take and drop wait a sec I'll write it down
14:45ticking_dbasch: hm yeah I think you're right
14:46silasdavisis this a strange/bad thing to do: https://www.refheap.com/86413
14:47silasdavisas in I just want to use Java's binary search, but have it compare using a particular function, but Java comparator expects a comparator to act between the same type
14:47silasdavisI'm assuming that java.util.Collections/binarySearch is a fair bit faster than a pure clojure implementation
14:48ticking_dbasch: yeah you are right :) , I got mixed up in the negation
14:48ticking_,(let [coll (range 5) pred #(= 2 %) [t d] (split-with (complement pred) coll) other (concat t (rest d)) match (first d)] [match other ])
14:48clojurebot[2 (0 1 3 4)]
14:49llasramsilasdavis: That is totally the way to go
14:50S11001001silasdavis: there exists a type containing all values
14:52amalloysilasdavis: you might also benefit from putting this into a sorted data structure to begin with, instead of doing binary search on a vector
14:53silasdavisI'd put in in a BST
14:53silasdavisbut i'm using it with a zipper
14:53silasdavisand I have written a down function that zips down to the nth child
14:54silasdavisand that implementation wants a vector or equivalent
14:54silasdavisactually I'd use a sorted-map
14:54ticking_amalloy: I just realized that "have you tried a different datastructure" is clojures equivalent to "have you tried to turn it off and on again" ^^ thanks for the reminder :D
14:55justin_smithsilasdavis: what about something like a sorted-set or sorted-set-by that maintains its own tree and sorts on insertion?
14:55p_lticking_: well... it *IS* the basic thing to consider, IMO :P
14:55silasdavisperhaps I should reverse a bit: from a node in zipper, I need to jump to a child of that zipper without scanning all the children
14:55silasdavisand get the child loc
14:56silasdavisI need a way of looking up the child quickly by a key, which is easy enough, but then I need a way to jump directly to the appropriate child
14:56ticking_p_l: yeah I completely agree, clojures seq concept is bot a gift and a curse, because most operations will leave you with it, and one is tempted to keep using it
14:56amalloyhave you uh...considered whether you need a zipper? it's vanishingly rare to have a good reason to use zippers
14:56silasdavisI was able to modify zip/down to jump to the nth child
14:57silasdaviswell it makes my implementation of trie fairly nice
14:57justin_smith(inc amalloy) - unless this is just a "how do I use a zipper" exercise
14:57amalloythe fact that you're modifying zip/down to go to some nth child, rather than the first one, screams that you don't really want zippers
14:57p_lticking_: One thing I was taught in general is that one should always first look at data, then at algorithm, then think about implementation :P
14:58silasdavishm
14:58amalloyyou certainly don't need zippers to implement a prefix trie. they'll just get in the way
14:58amalloynested maps, update-in, get-in, are all you need
14:58ticking_p_l: yeah, but you don't really want `into`s all over the place either
15:00ticking_p_l: I feel that clojure.core shouldn't contain all the seq stuff, there should be clojure.core clojure.seq and clojure.reducers, so that you don'h, always go to seqs as the default
15:00ticking_p_l with reducers the `into`s wouldn't be that bad
15:01ticking_p_l: well everything is a seq
15:02ticking_p_l: ah no keywords arent ^^
15:02justin_smith,(seq? 'everything)
15:02clojurebotfalse
15:02justin_smith:)
15:02ticking_touche
15:02ticking_^^
15:02p_lticking_: a friend of mine had "lisp" class in uni. We told him to bring a banner saying "you're wrong" :D
15:03ticking_lol
15:03justin_smith,(map seq? [:everything 'everything "everything" ::everything])
15:03clojurebot(false false false false)
15:04ticking_,(seq "everything")
15:04clojurebot(\e \v \e \r \y ...)
15:04ticking_though ^^
15:04silasdavisamalloy, hm yeah I might have a rethink, thanks
15:04justin_smith,,(map (comp seq? seq name) ["everything" :everything ::everything 'everything])
15:05clojurebot(true true true true)
15:05ticking_justin_smith: yeah I feared that name gets called automatically on keywords and symbols ^^
15:05ticking_thus my inital statement ^^
15:08amalloyi don't think it conveys anything to put ^^ after every sentence ^^
15:11exobyteAny resources for Java programmers leanring Clojure other than Rich Kickey's videos?
15:11technomancyamalloy: I know, right. (PLEASE RT)
15:11SegFaultAXexobyte: http://www.clojurebook.com/ and Joy of Clojure are excellent.
15:12ticking_amalloy technomancy: doesn't harm either, and it has proven to lessen the cance of the convesation partner feeling offended (some sentences sound harsher without facial expression) by a significant margin
15:12SegFaultAXAnd they're agnostic of your background.
15:12SegFaultAXexobyte: My advice to you is to learn Clojure /the Clojure Way/, as opposed to trying to fit Clojure into your existing Java mental model.
15:13exobyteSegFaultAX: fair enough
15:13numbertenis there a strict version of repeatedly?
15:14justin_smithexobyte: my small nugget of wisdom: information hiding doesn't buy you much when everything is immutible, the "final" status of the datastructures is usually all the encapsulation you need
15:14SegFaultAXnumberten: (repeatedly n fn)
15:14amalloySegFaultAX: he said strict
15:14amalloynumberten: no
15:14exobyteSegFaultAX: I also know C, JS, and python; my issue, and this was with learning python, is lots of resources spend too much time trying to teach me to program.
15:14numbertenalright thanks
15:15amalloygenerally "the strict version of X" is not included, because you can easily make anything strict if you want, with doall or dorun or whatever
15:15justin_smithexobyte: joy of clojure if anything assumes you are too competent, it is not a book that talks down to the reader or assumes you are not a programmer
15:15exobytejustin_smith: well that's amost like my java code!
15:15justin_smithexobyte: well that's a great start then :)
15:15justin_smithclojure just makes that approach easier, more default
15:15SegFaultAXBut doall on repeatedly without a size is a bad idea.
15:15exobytejustin_smith: I'd rather have *too* competent.
15:16justin_smithexobyte: many clojure newcomers find joy of clojure baffling, but it is a good book, and if you don't want your hands held do check it out
15:16SegFaultAXexobyte: In some sense you're going to have to re-learn how to program. Or at least, you're going to have to re-learn certains ways of modeling problems in your head.
15:16exobytejustin_smith: the author of a python book I read said he never found regexes or composite dict keys to be worth learning. cringes.
15:16justin_smithwow
15:16SegFaultAXexobyte: :( What book was this?
15:17gtrakno composite keys, omfg.
15:17justin_smithexobyte: python culture can be pretty aggressively mediocre sometimes
15:17exobyteSegFaultAX: checking... Idomatic Python, was really good, though
15:17numbertenamalloy: if i understand correctly, the only difference between dorun and doall is that the former doesn't retain the head?
15:18SegFaultAXHow good can it be if the author doesn't see value in something as basic as composite dict keys?
15:18gtrakadmittedly, I'm pretty bad at regexes, saying they aren't worth learning is like saying compilers shouldn't exist.
15:18exobyteSegFaultAX: "Learning to Program Using Python." I should have paid more attention to the title
15:18mdeboardeveryone's so crusty in here today
15:18cbp`hrm sorted-set doesn't print in sorted order in clojurescript
15:18mdeboardgrizzled vets everywhere
15:19danielcomptoncbp` in clojurescript set sorts you
15:19justin_smithcbp`: wow, that is weird
15:19justin_smithsounds like a bug
15:20cbp`,(sorted-set 6 92 1 2 3 4 5 1 0 2 39 4)
15:20clojurebot#{0 1 2 3 4 ...}
15:20exobytejustin_smith: I saw that mediocrity at a former job, too. a lead dev on a major website didn't like decorators because he couldn't figure out the stact traces.
15:20cbp`#{0 1 39 4 92 6 3 2 5} in cljs
15:20SegFaultAXexobyte: ... what does that have to do with decorators?
15:21justin_smithSegFaultAX: decorators can lead to stack traces that don't look like your code, I guess
15:21justin_smithnot nearly as bad as what laziness does to stack traces though...
15:21exobyteSegFaultAX: it was like he said "decorators are too hard"
15:22SegFaultAXjustin_smith: Decorators are just syntactic sugar. @foo def bar(): ... == def bar(): ... bar = foo(bar)
15:22justin_smithsee also the official reasons for not supporting the elimination of the GIL back when that was done, and for not having real lambdas
15:22exobytejustin_smith: it's too hard(tm)
15:23SegFaultAXRemoving the GIL /is/ too hard, though.
15:23technomancyticking: oh, I read it as "see the above line"
15:23exobytejustin_smith: coming from java, python's VM is a joke.
15:23exobyteSegFaultAX: when you don't have a proper concurrency or memory model, yes.
15:23SegFaultAXConsidering just about every library (including the standard library) is not built to be thread-safe, the rammifications of removing the GIL would be dire.
15:23justin_smithSegFaultAX: they did it once, and nobody supported that branch of the code
15:23justin_smithwell yeah, there is that
15:24SegFaultAXjustin_smith: It has been done mulitple times by multiple people.
15:24justin_smithbut hell, they can't even update libs to version 3
15:24justin_smithSegFaultAX: interesting, I had no idea
15:24SegFaultAXYea, much less make them thread safe.
15:24SegFaultAXjustin_smith: If you're interested in learning more about the Python GIL: https://www.youtube.com/watch?v=Obt-vMVdM8s
15:25justin_smithI think with its culture, python is stuck with "intuitive" as a hard constraint, which pretty much rules out doing concurrency right
15:25exobyteWhat was funny was because of the GIL, we couldn't run the webapp as a single process, so the local in-memory cache got cloned.
15:25cbp`guido is still crusty about being forced to put lispy things inside python
15:25justin_smithcool, thanks SegFaultAX
15:26SegFaultAXjustin_smith: Great talk in general, even if you never use Python IRL.
15:26cbp`like anonymous functions
15:26SegFaultAXcbp`: And map, filter, reduce.
15:26amalloyit's funny because of all the things that are in python *anyway* that were pioneered by lisp
15:27exobyteamalloy: all the cool parts that people like
15:27justin_smithSegFaultAX: clearly because these fp concepts are not accessible
15:27exobyteamalloy: the class system was bolted on
15:27justin_smithnot *intuitive*
15:27SegFaultAXIf we played "remove all the things lisp invented from Python", Python would cease to exist as a language.
15:28SegFaultAXjustin_smith: I think GvR drinks from the same koolaid bowl as the Pike et al.
15:28SegFaultAX(The golang team, that is)
15:28exobytePython people do love Go
15:29cbp`It's nice that it makes async things possible i guess
15:29SegFaultAXWell I just mean in terms of language design. Pervasive mutability, imperativeness, etc.
15:29SegFaultAXI'm not making a value judgement about whether that's good or bad. Just pointing out that the languages are similar in that respect.
15:32SegFaultAXIf and when Go ever gets parametric polymorphism, I'll give it a more serious look.
15:33SegFaultAXBut for me personally, for the style of programming I enjoy doing and the types of applications I tend to write, lack of PP and other FP-enabling tools makes it a non-starter.
15:33justin_smithI have hella respect for pike, he is a very smart man, even if he is often wrong
15:33amalloycbp`: are you sure about that sorted-set? the sorted-set code looked fine to me in cljs source, so i tried running your example, and it prints ordered for me with latest cljs
15:35amalloyoh, actually, i bet i'm not in a cljs repl. it's been ages since i tried to use that project
15:36amalloyokay, whew. even in a cljs repl: https://www.refheap.com/86415
15:37cbp`amalloy: I guess I should update first..
15:40amalloyjesus, does repljs still require you to type :cljs/quit to quit? i'm certain i sent a patch that lets C-d exit
15:40deathknight:O
15:41amalloyhttp://dev.clojure.org/jira/browse/CLJS-167
15:43weiis there a way to write a middleware handler that knows whether its inner routes matched or not?
15:44weiuse case: I must return 401 for routes that matched, but nil otherwise so the matcher can fall through
15:46justin_smith(fn [handler] (fn [request] (if (should-401 request) (assoc request :status 401) (handler request)))) something like this, if you want to short circuit all previous handlers to be preempted
15:47cbp`amalloy: no clue https://www.refheap.com/86416
15:47cbp`going out to eat for an hour though
16:40expezAny good places to read about error handling in clojure?
16:40joegallowell, what do you want to know?
16:40joegalloand how well do you already understand java exceptions?
16:40expezI write Java profesionally :(
16:41expezJava forces you to think about every exception, so the first question is how do I even find out what can go wrong when I'm calling a clojure function?
16:41bbloomexpez: javadoc
16:41joegalloah, simple
16:41joegalloanything can go wrong
16:42expezReading through source of the entire stack beneath me doesn't seem like a good idea
16:42joegallobasically forget about checked exceptions, they're all just runtime exceptions now
16:42stuartsierraAs some well-known JVM designer once put it, checked exceptions are a fiction of javac.
16:42joegallostuartsierra: well quoted
16:43TimMcAnd they're typed wrong.
16:43TimMcThey're not even a *consistent* fiction.
16:43TimMchttp://james-iry.blogspot.com/2010/08/on-removing-java-checked-exceptions-by.html
16:44expezThe clojure books I've read only deal with exceptions in terms of java interop, but I'm sure some of the clojure functions people write can fail too :)
16:44justin_smithexpez: many things in clojure are very easy going, and just return nil. If you want to enforce some invarients check out :pre and :post conditions
16:44bbloomTimMc: the clojure internals call that "sneaky throw"
16:44TimMcexpez: You get (try ... (catch ...)) and so forth if you need it.
16:45TimMcAnd slingshot can be a nice library to use if you want a bunch of exception types without creating classes for all of them.
16:45bbloomexpez: if you're calling java code that expects you to catch exceptions, that sucks... but it works the same as in java
16:45technomancyexpez: the only clojure-specific thing about exceptions is ex-info/ex-data
16:45bbloomexpez: otherwise, just avoid throwing/catching exceptions unless you expect to crash
16:46bbloomby that i mean, crashing is a fine thing to do if you get an unexpected exception
16:46expezabsolutely
16:48expezHas anyone written a library for modularizing a system into components that can crash on their own and then be restarted?
16:48gfredericksjava.lang.JVMNotAvailableException
16:48sjlexpez: if you want a common-lisp-condition-system-like lib check out http://docs.caudate.me/ribol/
16:49gfredericksexpez: I've played around with different approaches to stapling that kind of stuff onto stuartsierra/component, but I didn't feel good about any of them
16:49TimMcgfredericks: You twerp, you made me go look that up.
16:49gfredericks(inc java.lang.JVMNotAvailableException)
16:49lazybot⇒ 1
16:49bbloomall: please don't suggest random libs to new comers who have foundational questions
16:50gfredericksI am a newcomer to this conversation and don't know who is a newcomer :P
16:50stuartsierrabbloom: amen
16:50expezgfredericks: in terms of building it on top of component or the actual approach of restartable / isolated components?
16:50gfredericksexpez: the former I think
16:51TimMcbbloom: Probably a good idea if those situations can be identified.
16:51gfrederickscoordinating failure in general has been hard; erlang has this nice feature of forcing a group of processes to crash together
16:51expezmhmm
16:52stuartsierraI've been thinking about ways to make 'component' support error handling and restarts. But it's very hard.
16:52bbloomexpez: the short answer is: avoid exceptions unless java forces them on you. then pretend it's just like java. get a baseline of experience w/ clojure
16:52gfredericksstuartsierra: I've ended up implementing error channels and similar things a few times
16:52gfredericksfor batch jobs: a promise that gets delivered with nil on success or a throwable on error
16:53expezbbloom: thanks, that sounds like good advice. Errors and function composition go poorly together :p
17:26Glenjamini've been playing around with a component-like system that attempts to minimise closures - in theory this would make it more resiliant to errors
17:28Glenjaminalthough that wasnt my goal when building it
17:28bbloomGlenjamin: by minimize closures, you mean avoids capturing mutable state in closures?
17:28Glenjaminor any state really, yeah
17:29bbloomwell i guess there really isn't any other kind of state, besides mutable
17:29Glenjamini was annoying at having to rebuild all app state when changing a function
17:29Glenjamin*annoyed even
17:29Glenjaminespecially when my app took ~10s to load up its state
17:29Glenjaminso i'm trying to use vars in a way that doesn't break tools.namespace/refresh
17:30Glenjaminwhich basically means my ring handler is a very small clojure that calls find-var
17:31Glenjaminclosure even
17:31Glenjaminit's really hard to type closure in this channel
17:38justin_smithGlenjamin: isn't this what passing #'handler to ring already does?
17:38Glenjaminyes, but i had an additional constraint
17:39justin_smithoh, ok
17:39Glenjaminin order to inject the other bits of my system into the ring handler without clojures
17:39Glenjamini'm assoc-ing them into the request map
17:39Glenjamini expected #'handler to work, but for some reason it can be broken with tools.namespace/refresh
17:39Glenjaminso i do (find-var 'handler) instead
17:40Glenjaminwhere handler is in another namespace
17:40Glenjaminthis is still fairly trial and error, i intend to poke into what clojure is actually doing under the hood and maybe write this up as a blog post
17:41justin_smithI wonder what the cases are for using find-var vs. resolve
17:41Glenjaminit seems like a var can end up pointing at the old value when tools.namespace destroys and rebuilds a namespace
17:41amalloyGlenjamin: i bet t.n/refresh doesn't just re-def the vars; it deletes the namespace wholesale and starts over
17:41Glenjaminit does, yes
17:41Glenjamin,(doc resolve)
17:41clojurebot"([sym] [env sym]); same as (ns-resolve *ns* symbol) or (ns-resolve *ns* &env symbol)"
17:42amalloyright, so naturally the old var still exists, and a new one with the same name is created
17:42amalloyvars aren't interned by name like keywords are
17:43amalloyso ring still has a handle on the old var, which is pointing to the same function it always did
17:43Glenjaminhrm, seems like (ns-resolve) should do roughly the same thing as (find-var)
17:43Glenjaminsounds right amalloy
17:43justin_smithGlenjamin: yeah, they seem similar, which makes me wonder what would indicate one vs. the other is appropriate
17:43amalloyi don't understand your point re ns-resolve vs find-var
17:44Glenjaminfrom my limited understanding, they seem to do the same thing
17:45justin_smithGlenjamin: well, one difference is resolve does not require that its arg be fully qualified
17:52justin_smith,(/ 2) TIL
17:52clojurebot1/2
17:53justin_smithhandy
18:00Raynesmdeboard: We both use rdio <3
18:00RaynesWe're rdibros
18:03mdeboardRaynes: lol
18:25danielcomptonAny spotifriends out there?
18:54caternWhat is the idiomatic way to iterate through a sequence with a function, passing a state variable along?
18:55technomancycatern: reduce?
18:55caternAhhh right yes
18:57justin_smithpedantically it's not state and its not a variable - its an argument to a function that gets a new binding on each iteration
18:57justin_smith(unless you also make it be an atom or something)
18:59technomancyhm; I don't see how it's not state
18:59justin_smithit's a local, non-mutable, non-shared, per-execution state I guess
19:00justin_smithbut one usually doesn't describe eg, the value of x inside (fn [x y] (+ x y)) as being a state or a variable
19:00justin_smithit's a binding
19:00technomancyit seems to match the mathematical definition of a variable
19:01justin_smithyeah, but that's kind of overloaded with some other implications in programming
19:01technomancyI just take it as a given that the other definitions don't apply because they can't apply.
19:02amalloywait, when did (str (range)) change to be non-terminating? it used to just return "clojure.lang.LazySeq@1234567" or similar
19:02turbofailhow could (str ...) return a lazy sequence?
19:03turbofailoh nm
19:03justin_smithturbofail: the string form of a lazy sequence was just an opaque object, and did not realize or reveal the contents
19:03Bronsa,(str (range 10))
19:03clojurebot"clojure.lang.LazySeq@9ebadac6"
19:03amalloybut now the way it tries to hash the collection apparently involves realizing all its elements
19:04justin_smith,(str (range))
19:04clojurebot#<OutOfMemoryError java.lang.OutOfMemoryError: Java heap space>
19:04justin_smithyeah, that seems like a regression
19:04amalloyi think this was actually in like 1.4 or 1.5. it's not super-recent
19:05Bronsaamalloy: just checked with 1.3.0, same behaviour
19:05amalloy1.2?
19:05Bronsaditto for 1.2
19:05amalloyman, i don't wanna be crazy. i'm sure this wasn't always the case
19:05amalloybut 1.2 is when i started
19:06Bronsaamalloy: looks LazySeq's hashCode always depended on the realized seq
19:09amalloywould it be crazy to reimplement toString on LazySeq to be like: {return "clojure.lang.LazySeq@" + System.identityHashCode(this);} ?
19:09amalloyso that you can at least print the damn things
19:10technomancyamalloy: right, I always assumed the "clojure.lang.LazySeq@9ebadac6" representation was specifically there to allow them to be str'd without realizing them
19:10Bronsasame here
19:11amalloystuart s noticed this three years ago, and nobody cared: https://groups.google.com/forum/#!topic/clojure-dev/F68GRPrbfWo
19:18amalloyanyway, i re-realized this because i ran into a scala collection that has a non-terminating toString, and i wanted to herald clojure's moral superiority, because i know (str (range)) doesn't suck. but it turns out i was wrong
19:23{blake}OK, I've forgotten how to do this: "(defn myproc [parm & more] ... (myproc (first more) (rest more))..." The "rest more" creates a list but so does the & in the parm list. How do I stuff the remaining params back into the proc without ending up with a nested list?
19:24turbofailapply
19:25turbofail(apply myproc (first more) (rest more))
19:25{blake}turbofail, Yeah, I was trying to figure out how to fit apply in there.
19:25amalloy(apply myproc more)
19:25{blake}turbofail, OK, so I was thinking of trying to de-listify rather than ... lemme see if I got that...
19:26turbofailyeah actually amalloy's version is equivalent
19:26amalloyalthough, really, consider making myproc just take a list of params, instead of &args params
19:27{blake}amalloy, OK...but let's say--oh, that makes sense yeah. And if it's not "(first more)" but "(someothervaluederivedfromfirstmore)", I could put that into the list...
19:27{blake}For the purposes of this exercise, I have discrete items, not a list.
19:28skinkittenis there a shorter/simpler way of doing this? http://cryptb.in/zkEf#afb8d04ad2702274261bd938ca252d99
19:29justin_smithfor the impl? (repeat 1)
19:29justin_smith,(repeat 1)
19:29clojurebot(1 1 1 1 1 ...)
19:30{blake}(because I remembered amalloy recommending using lists as parameters from last week.)
19:32skinkittenjustin_smith, nice. thank you.
19:42skinkittenjustin_smith, how about this? http://goo.gl/JS5Dxh
19:42mdeboardWhat is the proper syntax for `require` in the repl?
19:43mdeboardIs there any reason to not just use `use`?
19:44AWizzArdmdeboard: (require 'com.example.ns)
19:44justin_smithmdeboard: use leads to harder to refactor code, but in a repl there is often reason to just do use
19:44AWizzArdOr (require '[com.example.ns :as exns])
19:44Raynesmdeboard: (require '[foo.bar :refer [things]]); (require 'foo.bar); (require '[foo.bar :as barness])
19:44justin_smithor (require '[com.example.ns :as ex])
19:44Raynesmdeboard: There is every reason to not use `use`.
19:45mdeboardwhat about :refer :all
19:45Raynesrequire is now a superset of `use`'s functionality.
19:45technomancyRaynes: eh; even in the repl?
19:45mdeboardWhen I try to use that I get an error, e.g. (require '(foo.bar :refer :all))
19:45AWizzArdInnocent question, storm of answers (:
19:45RaynesYou should almost never use that anyways.
19:45Raynestechnomancy: Yes, even in the repl.
19:45Raynes:refer :all
19:45technomancyI still use `use` in the repl because it's short
19:45RaynesThere is not one single good reason to use that god forsaken function.
19:45mdeboardit's shorter
19:45RaynesThat's not a reason.
19:45mdeboardthat's a good reason
19:45technomancyno one has to know
19:46mdeboardI put on my wizard robe and hat
19:46RaynesI pick up my rifle.
19:46RaynesI see where this is going.
19:46amalloy(use 'require)
19:48AWizzArdI think we now have a clear winner.
19:48AWizzArdamalloy: can you also require use?
19:48amalloyyou can, but it's not required
19:49technomancygranted the only thing I use is clojure.pprint
19:49technomancybecause I know exactly what's going to happen
19:50justin_smithwhat about clojure.repl?
19:50technomancypersonally I would never do that
19:52technomancybut if you're not an emacs user it might make sense
19:53amalloyclojure.reflect is about as reasonable as clojure.pprint, probably
19:54technomancybasically any time I do a use, it's because nrepl-discover doesn't work yet.
19:56BronsaI still (use 'clojure.repl) from slime because I never remember how to do apropos otherwise
19:57AWizzArdBest way to get (into (sorted-map-by-val) some-map)?
19:58AWizzArd{:b 2, :c 3, :a 1} ==> {:a 1, :b 2, :c 3}
19:58AWizzArd{:b 2, :a 3, :c 1} ==> {:c 1, :b 2, :a 3}
19:59AWizzArdNot really possible I guess.
20:01amalloymaps sorted by value are not really a thing. you don't address what to do in the case of value collisions, for exampl
20:02amalloybut for many cases where you think you want a map sorted by value, a priority queue can suffice
20:02metellus,(= {:a 1 :b 2} {:b 2 :a 1}) ;; there's also the fact that this is true
20:02clojurebottrue
20:02metellusyou could go from a map to a seq sorted by keys within the map
20:02Bronsaisn't that like a priority map?
20:03Bronsahttps://github.com/clojure/data.priority-map
20:03AWizzArdamalloy: I just wanted this for testing purposes. My classifier outputs a map with tons of classes and without sorting it’s not possible to visually match the winner. I’ll go with (sort-by val #(compare %2 %1) (classify …)) now.
20:04AWizzArdBronsa: looks good.
20:13ShayanjmWhat do you guys think of the clojure for the brave and true book?
20:17caterni read it to learn clojure! very recently! it was pretty good I think
20:17caternbut I already knew Lisp from SICP
20:18caternalso, I thought it needed an appropriate soundtrack with that kind of title, so I listened to https://www.youtube.com/watch?v=atM3ZhF8MVs all throughout
20:18Shayanjmhaha cool :) This is my first venture into any functional programming so I figured I'd litmus test some opinions.
20:20AWizzArd,(key "foo")
20:20clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to java.util.Map$Entry>
20:22AWizzArdcatern: I will follow that youtube link now but surely hope it’s not the 10-hour version of the Nyan cat!
20:33justin_smithskinkitten: another thing I noticed as I was closing that tab just now: if you bind the lazy sequence in a def, that holds onto the head and it can't be collected unless you clear the var. If you instead call (repeatedly 1) at the place in code where you need the sequence, the values are not bound or held so they can be cleaned up immediately
20:34justin_smithskinkitten: IOW don't bind to the head of a lazy sequence if it is that cheap to generate
20:38skinkittenjustin_smith, how about this (def ones (repeat 1))
20:39caternAWizzArd: no, much more appropriate, don't you think?
20:39caternnow I listen to it often when I clojore-code
20:39caternit puts me in the mindset of the parenkin - Lispborn!
20:40skinkittenjustin_smith, what's "clear the var"?
20:41AWizzArdcatern: yes is good. I typically listen to brown noise: http://simplynoise.com/
20:42justin_smithskinkitten: the problem is that if someone uses 1000000 values from 1s, then that var now holds that long a sequence
20:43justin_smithskinkitten: if, instead, you just use (repeat 1) inside any call where you need (1 1 1 1 ...) then you never need more than chunksize to exist at any time, and they can be garbage collected
20:43justin_smithclearing the var would be reassigning it so the previous value can be reclaimed
20:44turbofailthough for this particular example it doesn't really matter
20:44skinkittenjustin_smith, wow yeah. totally makes sense.
20:44skinkittenthanks
20:44turbofailbut if you were doing say (reduce + (take 10000000 ones)) then you'd probably want to do as he says
20:45justin_smithturbofail: yeah, it's the general principle of the thing
20:46justin_smithany unbounded lazy seq tied to a var should be treated as a potential memory leak (see also line-seq from some reader, etc.)
20:46skinkittenjustin_smith, (take 10 (repeat 1)) returns '(1 1 1 1...) ? I might have read you incorrectly, I had imagined it would just return 1
20:47justin_smith,(take 10 (repeat 1))
20:47clojurebot(1 1 1 1 1 ...)
20:49skinkitten,(take 10 1)
20:49clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
20:49nullptr`,(take 10 [1])
20:49clojurebot(1)
20:50amalloyjustin_smith: chunksize? i don't see how that's relevant to the discussion
20:51amalloyrepeat isn't chunked, after all. but even if it were, introducing chunking is just a distraction to someone who's just learning how to deal with lazy sequences. (to be honest, it's a distraction to almost anyone, since chunking so rarely matters)
20:51justin_smithamalloy: with some other lazy sequences, I imagine that would be a lower bound on how much would be realized at a time, even if you did not hold onto the head
20:52justin_smithamalloy: fair point
20:53amalloyjustin_smith: chunk size can vary across seqs, actually. for example, filter preserves chunkiness, but produces chunks of varying size according to your predicate
20:53amalloyif the incoming sequence has a chunk size of 32, and only 5 elements of that chunk pass your predicate, then the chunk that comes out will have a chunk size of 5
20:56skinkittenin racket I made it this way (define ones (lambda () (cons 1 ones))). Whats the direct translation of that in clojure?
20:57hiredmanskinkitten: well it looks like user error
20:57gratimax(repeat 1)
20:57hiredmanskinkitten: what are you trying to create with that?
20:58amalloyhiredman: i mean, you can cons a number onto a lambda, and that's not a totally crazy way to represent lazy sequences in racket
20:58hiredmanamalloy: right, but it doesn't seem likely to be what he meant to do
20:58hiredmanwhich is why I asked
20:59skinkittenwell before reading streams in clojure docs, I use to call that function a stream but I'm unsure of naming it that, here is the output from racket '(1 . #<procedure:ones>)
20:59hiredmanseqs
21:00hiredmanstreams in clojure are a historical expirement that never made it in to the language
21:00hiredmanskinkitten: right, so it creates a pair of a 1 and a function that returns a pair …
21:01hiredmanskinkitten: is your intent to use that to represent what is logically an infinite list of 1?
21:01skinkittenhipsterslapfight, yes
21:01gratimaxlike I said, (repeat 1)
21:01gratimax,(take 5 (repeat 1))
21:01clojurebot(1 1 1 1 1)
21:01amalloyhahaha. a new nickname for hiredman
21:01gratimax,(take 10 (repeat 1))
21:01clojurebot(1 1 1 1 1 ...)
21:02hiredman:|
21:02skinkitten,(take-nth 10 (repeat 1))
21:02clojurebot(1 1 1 1 1 ...)
21:02skinkitten,(last (take 10 (repeat 1)))
21:02clojurebot1
21:03gratimax(repeat 1) is just an infinite list, done with lazy-seq
21:03gratimaxit behaves like a list
21:04gratimaxa more transparent translation of your code would be something like (def ones (cons 1 (lazy-seq ones)))
21:04justin_smithskinkitten: so the point I was trying to make above, is if you had (def ones (repeat 1)) then somewhere else did (last ones), you would not only waste a bunch of CPU cycles, you would also run out of heap space. If instead of (last ones) they did (last (repeat 1)) you only waste CPU and don't fill up the heap because the elements can be reclaimed as they are used
21:06allenj12anyone here familirar with hoplon?
21:07amalloy~anyone
21:07clojurebotanyone is anybody
21:07hiredman~laugh
21:07clojurebotha ha
21:07cbp(inc clojurebot)
21:07amalloyhiredman: is it possible to nuke these definitions that get in the way of useful canned responses?
21:08mynomotoallenj12: people gather on #hoplon to talk about hoplon...
21:08amalloyiirc "forget anyone |is| anybody" doesn't help, because he's inferring it from some other stupid path
21:08allenj12mynomoto: o kk thanks
21:08dbasch~everybody
21:08clojureboteverybody looks good in a sheinhardt
21:09hiredmanamalloy: I just have to remember to look in to next time I crack the database open
21:10skinkitten,(last (repeat 10 1))
21:10clojurebot1
21:10skinkittenjustin_smith, is that space/cycle saving way to call it?
21:11justin_smiththe trick is not binding the head of the sequence
21:11skinkittenso without (def ones (repeat 1)) ???
21:11justin_smithright, just use (repeat 1) in place where you need the sequence
21:12justin_smithand as others have noted, this likely isn't a big deal here, but it is good to be in the habit of not binding the head of indeterminate lazy things
21:13skinkittenjustin_smith, what about here? http://goo.gl/JS5Dxh
21:13skinkittenit isn't infinite. so thats ok?
21:14mdeboardIf (use) is so freaking terrible then why is the syntax of require so inconsistent in the repl?
21:14mdeboardfook the king
21:15amalloyinconsistent in the repl? how is it any different from in ns, or from use? the only difference is that in ns it doesn't want a quote
21:15mdeboardIf I want to refer all symbols from clojure.core.match namespace, how would I do that in the repl?
21:16mdeboardI've been trying variations on (require '[clojure.core.match :refer :all])
21:16justin_smithskinkitten: that is hypothetically unbounded, but if you know you are only using only the first N you have the excuse that the elements have some computational cost you are minimizing
21:16amalloywhat you just typed. right there. that's hwo you do it
21:18mdeboardSure now it works.
21:19skinkittenjustin_smith, thanks
21:20skinkittenI'm going to redact the factorial implementation
21:22amalloyi just noticed something interesting about treating Iterable objects as if they were seqs: one more element than necessary is requested from the iterator. https://www.refheap.com/86424
21:24justin_smithskinkitten: one option for factorial would be to make a function using iterate, perhaps memoizing it
21:25justin_smithamalloy: will a memoized function have the same heap usage issues as a lazy seq with the head held onto, or is it able to drop memoizations after a certain memory pressure?
21:25dbaschamalloy: that’s probably because hasNext needs to know
21:27amalloyjustin_smith: just read the source for memoize. i'm pretty sure you're experienced enough to answer that question with just a quick scan
21:27amalloydbasch: i actually am not quite sure what's going on. it turns out that (.next (.iterator (tricky))) also throws
21:28justin_smithOK yeah, it will actually be more expensive memory wise than just binding the lazy seq would be (but faster for grabbing a specific result)
21:29dbaschamalloy: (.hasNext (.iterator (tricky))) returns true
21:29amalloyyeah
21:30dbaschso probably .next makes it so that (.hasNext (.next …)) needs to be evaluated
21:32Bronsajustin_smith: core.memoize offers some smarter implementations
21:32amalloyit shouldn't, in theory though, right? if you can call first, you ought to be able to call next
21:32mdeboardWhat is meant by a "transient set" as opposed to a "new set" in the docs for disj/disj!
21:32amalloyor rather, .next
21:33justin_smithBronsa: yeah, that's probably what I was thinking of
21:36amalloybut that's more a question of how LazySeq/iterator is implemented, whereas i was hoping to find something out about how iterating over other iterable works
21:40dbaschamalloy: next “Returns the next element in the list and advances the cursor position.”
21:41amalloydbasch: okay, but the cursor could be pointing at (lazy-seq (throw (Exception.))) without exploding until you actually call .next or .hasNext
21:42dbaschamalloy: yes, in theory it should
21:42amalloybut in reality, what happens is lazy-seq delegates to (.seq this) for most of its methods
22:19DomKMDoes Leiningen try to compile my-project.main even if a :main key isn't specified in project.clj?
22:21DomKMI'm getting FileNotFoundExceptions when trying to compile cljx because it is trying to compile a main namespace first, which requires the generated clj namespace.
22:45Shayanjmweird
22:45ShayanjmI'm using Lighttable and working through the brave clojure book
22:46ShayanjmI'm at the part where it discusses multiple namespaces & refer
22:46ShayanjmI passed :only into my refer, but for some reason I'm able to access other vars from inside a different namespace in my repl
22:46Shayanjmany ideas why?
22:49pcnShayanjm: http://clojuredocs.org/clojure_core/clojure.core/refer refer doesn't prevent you from explicitly naming variables in other namespaes.
22:50pcnIt only prevents all of the names from an required namespace from being bound in the current ns. Does that answer your question?
22:50ShayanjmI'm not sure if I understand correctly - I'm a bit new to clojure sorry haha bare with me
22:51ShayanjmSo if I have ns1 and ns2, ns1 has thing1 and thing2 defined
22:51Shayanjmi switch in to ns2, and do something like
22:51Shayanjm(clojure.core/refer 'ns1 :only ['thing1])
22:52Shayanjmintuitively - I would think that clojure only referred thing1 out of the entire ns1, therefore thing2 should be inaccessible from ns2, right?
22:52Shayanjmthis also seems to be the behavior that the book depicts, though doesn't seem to be the case when I run it in my own REPL
23:00dbaschShayanjm: refer just created a mapping for thing1, which you can see in (ns-map ‘ns2)
23:00dbaschShayanjm: but you can still use ns1/thing2
23:01Shayanjmdbasch: my point is that it thing1 and thing2 are both usable from ns2
23:01Shayanjmso it looks like both got a mapping
23:01caternYes, they should be even if you didn't refer them
23:02ShayanjmWhy's that? I thought thing1 and thing2 are stuck in their ns until I refer them?
23:03Shayanjmand if I explicitly only refer thing1, thing2 should still be stuck in its ns (still usable via ns1/thing2, but not as thing2 from ns2)
23:03caternYes, but you're addressing them by a full namespace path thing
23:03caternOh
23:03Shayanjmnope
23:03caternMisunderstood you then
23:04ShayanjmSorry haha - let me try to be clearer
23:04Shayanjmns1 contains: thing1, thing2. I switched in to ns2, refered -only- thing1
23:04Shayanjmwhen i call thing1 from ns2, works as expected
23:04Shayanjmbut then I realize I can also call thing2 from ns2 as is, without using the full namespace path
23:04Shayanjmeven though I only referred thing1
23:04caternHave you tried restarting your repl and getting the issue down to a few commands?
23:05Shayanjmyup. Granted, I've been working within the lighttable repl
23:05Shayanjmlet me try with lein repl
23:07Shayanjmah, works in lein repl
23:07Shayanjmweird
23:07Shayanjmso must be a lighttable bug
23:08pcnThat makes sense. That would be a good bug to fil.
23:09Shayanjmhttp://puu.sh/9mOvq/4e0d594002.png
23:11amalloyShayanjm: are you sure ns2 doesn't already have namespace mappings in it, eg from requiring a .clj file? if this works for two namespaces that didn't exist previously, that would indeed be a bug in light table
23:11Shayanjmamalloy: this is a clean instaREPL in light table & I created (and checked) both namespaces in the repl itself
23:12Shayanjmgranted I'm also really really new to Clojure, so I'm not sure if I just did something stupid or if this is actually a bug
23:12Shayanjmeither way I'll open up an issue w/ lighttable and see if it gets sorted, or if I get flamed for being a noob ;)
23:14amalloyShayanjm: i'd recommend (a) using refheap.com instead of a screenshot, and (b) including some evidence that the namespaces are clean before you started doing stuff (eg, above all of this other stuff, going into ns2 and showing that evaluating thing2 leads to an exception)
23:14Shayanjmgotcha.
23:25Shayanjmamalloy: https://github.com/LightTable/LightTable/issues/1520
23:25ShayanjmI started just copying the commands to refheap, but I realized that I could illustrate the inconsistencies easier (IMO) via screenshots
23:25Shayanjmbut its only a grand total of maybe 4 commands, so easy to replicate even without copy-pastable code.
23:27caternIs light table not using JVM backed Clojure or something?
23:28Shayanjmnot a clue tbh
23:32lockslight table is clojurescript
23:34locksbut it should be using regular clojure for the eval, i think
23:38PigDudewhat's the name of a binding like [arg] as opposed to a let-style binding [name val]?
23:38PigDudefor documentation purpose?
23:39PigDudefor creating a macro like (with-some-resource [some-name] BODY...)
23:39andyfIn defn and defmacro, such things are sometimes called the argument vector or arg vector
23:40PigDudei don't see them used much elsewhere
23:40andyfNot sure if that applies as well to your example.
23:40PigDudeyea, definitely
23:40andyfWhere does the value for some-name come from in your example?
23:41PigDudenot from the code user
23:41PigDude(value supplied by library)
23:41andyfCould there be more than one in the vector?
23:41PigDudeno, never
23:41andyfThen why a vector?
23:41PigDudeas the macro's semantics are for selecting one thing at a time (looping)
23:42PigDudei have a funky test suite right now and i wanted to run the same tests over different inputs
23:43PigDudeso i was using a macro for a convenient way to define these tests, which are automatically tested against several implementations
23:43andyfand some-name will occur one or more times in BODY?
23:44PigDudecome to think of it, it wouldn't, i just was hoping to come up with something cleaner than what i have now: a macro that creates a 'deftest' which runs the body over different implementations
23:44PigDudeit does this using (binding), and an agreement that test utility functions use the bound name
23:45PigDudeugly. Ugly!
23:45PigDudeat least they are effective tests
23:48PigDudeif anyone has ideas for improving my tests, i greatly appreciate it, because this organization is not ideal
23:49andyfJust looking for anything similar in clojure.core -- haven't found anything quite like it, especially if the name is not used for anything.
23:49PigDudeyea, it was a stupid idea, sorry :)
23:49andyfYou can do loops inside of a deftest, if you think that would help.
23:50justin_smithPigDude: any function can call test/is, and if that function is called in a deftest during test time, the is call does the right thing
23:50andyfe.g. (doseq [f [fn1 fn2 fn3 ...] (test f here))
23:50justin_smithPigDude: so you don't need macros for this, you can just define some functions and call them in your tests
23:51PigDudedon' you lose locality on test failure then
23:51PigDudelike you do in most languages when composing tests w/o macros
23:51justin_smithPigDude: nope, it tells you which test failed
23:51justin_smithand the line number points the the function, called in that test
23:51PigDudehm OK, will give that a try, thanks justin_smith !
23:53PigDudewish i could find more on testing w/ clojure tools, some stuff i see jumps right into generative testing/property-based stuff
23:54justin_smithPigDude: for me, the big revelation was that if your code is functional, all you need to do is check inputs and outputs
23:55justin_smithno need for mocking, scaffolding, yadda yadda
23:55justin_smithbecause you know that stuff won't affect what the function actually does
23:56PigDudeyou know the only reason i do (binding) in these tests is because use-fixtures has no way to send parameters to the test? or am i missing something?
23:56PigDudei mean the nuts & bolts, having worked in erlang a lot i know how to write decent tests, but erlang has very good test tools and i miss them
23:57PigDudecommon test, stuff like that?
23:57PigDudei find in-depth material on property-based testing, and shallow material on ordinary unit testing :( no big deal, but i'm happy for suggestions
23:59PigDudenot being able to access "fixture" data except via dynamic variables is by far my biggest pain point in clojure right now