#clojure logs

2012-09-15

00:00tomojupdated second gist with a better example
00:00tomoj(reduce-kv conj [] r) should not make sense, right?
00:00tomojoh well, it could
00:02tomojanyway, I again don't understand why rfn is there
00:02SgeoI am seriously going to cry
00:04tomojthe only purpose for rfn I can imagine is reduce-kv, but ([ret k v] (f1 ret (f k v))) seems to violate reduce-kv's contract
00:11SgeoSomeone please explain to me in understandable language why algo.monads doesn't use Leiningen
01:04SgeoUh
01:05SgeoDoes Enclojure not support Leiningen, nor Clojure past 1.2?
01:06RaynesEnclojure is the least maintained of the Clojure environments.
01:06RaynesI'd be surprised if it worked at all.
01:08Sgeo:(
01:08SgeoOk, so what's well-maintained that isn't Counterclockwise?
01:08SgeoI'm done fighting with Eclipse
01:08carkemacs =P
01:09RaynesLight table, but it's extremely new and missing things like one-off editing.
01:09Sgeoone-off editing
01:09Sgeo?
01:10RaynesAs in you can't just pick a file on the filesystem and edit it.
01:10carkmissing paredit too =(
01:10RaynesBut yeah, Emacs, Vim, Light table...
01:10amalloylight table is well maintained? i don't think "maintained" is a good word for that
01:10Raynescark: Yeah, I hope someone adds that to codemirror soon.
01:10Raynesamalloy: I'm pretty sure it qualifies.
01:11carki think lighttable isn't quite ready for prime-time
01:11RaynesIt isn't, but I'm not sure paredit is the reason.
01:11RaynesParedit is something that has generally nothing to do with light table.
01:12RaynesAs a matter of fact, nothing editor-related does. All of that needs to be done in codemirror itself which is a separate project by a different person.
01:12RaynesI wish he was more exuberant about that. LT isn't open source yet, so people don't think they can contribute when in fact they can contribute to one of the most important components right now.
01:13carkthe two big ones are counterclockwise and emacs, emacs is the best of the two imo, and the skills you get with emacs are good for lots of other languages
01:19Sgeocodemirror?
01:20SgeoThere exists a language called Smarty.
02:27salneed help on slime-ritz, installed a new emacs 24 with clojure, swank, slime
02:28salswank and clojure mode working, but slime doesn't start
02:36salanybody on github, with slime-ritz emacs setup, which i can look at, thx
04:21ro_sttechnomancy: how do i resolve "target/stale/dependencies (No such file or directory)" on lein2 preview10?
04:22sunkencityrylehwhat's this # character that's needed to get the metadata? (meta #'pr-str) why not good enough with just a quote?
04:23ro_stnm. i'm a dumbass. permissions
04:23tomoj&'#'pr-str
04:23lazybot⇒ (var pr-str)
04:24sunkencityrylehhm, so it's a var-quote
04:32philandstuffhello. I believe I've found a couple of bugs in PersistentQueue. I've emailed clojure-dev about them. I haven't had a response. Should I open JIRA tickets for them?
04:37tomojthe flowchart suggests that anyone can open an issue
04:38tomojthe text below seems to suggest that you get feedback on clojure-dev before doing so. confusing
04:59philandstufftomoj: yeah, that's how I feel
05:01philandstuffoh well, I've sent another email, trying to be clearer and asking direct questions about filing a bug
05:02philandstuffof course most of clojure/core will be asleep right now
05:02clj_newb_2345i know about code mirror2
05:02clj_newb_2345however, I'm curious -- is there any editor written in clojurescript?
05:05carka couple bugs in persistentqueue ?
05:12kralmorning
05:14philandstuffcark: yes. I brought them up on clojure-dev
05:14philandstuffI filed one as http://dev.clojure.org/jira/browse/CLJ-1059
05:16carkoh i see
05:17philandstuffthere's a couple others around PersistentQueue's hash fn, which doesn't match its = fn
05:18philandstuffnothing earth-shattering
05:18carkyou got me worried for a second =P
05:20dfdI'm wondering, is there anyone here living in Asia?
05:22luxbockI'm staying in Bangkok
05:22luxbockwhy?
05:22clojurebotluxbock: because you can't handle the truth!
05:22dfdhaha
05:22luxbock:D
05:23dfdluxbock: just curious. I live in Japan, and I would like to learn more about whether there is much of a Clojure community here, or anywhere else in this (large) region
05:23dfdI know there are some Japanese folks using Clojure, I'm also curious if they hang out on the English-speaking channel.
05:23dfdand of course anyone else.
05:23luxbockhmm, no clue
05:23dfd(in Asia)
05:24dfdyeah, just sorta throwing it out there. Anyways, enjoy Thailand. Love that place. ;-)
05:42votzIf I have a namespace without :gen-class, built and packed with leiningen's uberjar, how can one invoke a method, like foo, from the command line with java? java -cp test.jar [...]?
05:43votzAlong the lines of http://pastie.org/private/cdtvivjaqtu9zatlmhlha
06:09gfredericksvotz: from a jar you have to have a class to run; you can run clojure.main and get a repl...if there's a built in clojure way to call a specific jar I'd be interested
06:09gfrederickss/jar/var/
06:09ro_stanyone using datomic here can answer a stupid question for me?
06:10ro_sthow do i query out the timestamps for data?
06:13votzgfredericks: Once in the clojure.main REPL, what's the best way to invoke foo of (ns test.core)?
06:15votzThe namespace 'test' is not listed in (all-ns).
06:15tomojjava -cp test.jar clojure.main -e "(use 'test.core) (foo)"
06:15gfredericksyou'd have to require it first
06:15tomojI think
06:16gfredericksor use it as tomoj suggests with his commandline-args version I was asking for
06:16hiredmanhttps://gist.github.com/3422228
06:17votztomoj: Bingo. That appears to work.
06:19michaelr`hello
06:19votzThank you for your help and input gfredericks and tomoj.
06:26SgeoI guess I should try that instead of fighting with leiningen
06:26SgeoAre there any advantages to lein repl over using clojure.... hmm
06:26SgeoThat looks like it requires clojure directly in the cp?
06:27SgeoWhere does Leiningen install clojure.jar?
06:30gfredericksSgeo: I'd say not using lein is only worth it if you've made an uberjar
06:31Sgeogfredericks, how about testing modifications to a library that doesn't use Leiningen?
06:31SgeoOr how about playing with a .jar generated with JNAerator
06:32xeqiSgeo: leiningen uses clojure from your ~/.m2/repository
06:32gfrederickstry `lein classpath`?
06:33xeqias far as advantages, not having to manage the classpath yourself and manually download dependencies
06:36SgeoGUESS WHAT I JUST LEARNED
06:37SgeoTHERE IS A project.clj IN ALGO.MONADS
06:37SgeoOh, wait, n/m
06:50Sgeohttps://www.refheap.com/paste/5090
06:51scottjSgeo: Not sure if this is what you're wondering, but you can use algo.monads from a lein project, you just need to pull the version out of pom.xml and make sure you lein pulls from the repo algo.monads is deployed to
06:51Sgeo(Note that this doesn't use the publically available m-lift-fn, but one that's modified to be curried by default)
06:52SgeoI don't entirely understand why the first and second don't match, but the second and third matching is very good
06:52SgeoDoes this count as testing?
06:53SgeoGetting rid of the m-result makes the ( ) around individual items go away
06:54SgeoI think domonad is putting an implicit m-result there.
06:54SgeoWhich is completely and utterly inappropriate, I think
07:00Sgeo$mail jimduey I dare you to try to write m-join using domonad.
07:00lazybotMessage saved.
07:00Sgeo$mail jimduey Hint: domonad appears to include an m-result implicitly.
07:00lazybotMessage saved.
07:07philandstuffSgeo: I agree that the m-result is entirely inappropriate. Probably too late to remove, but you should be able to write your own domonad* which does what you want.
07:09dfdClojure folks, I'm a Perl and Ruby person from way back, so whenever I start thinking about manipulating strings I will do stuff like chain regexp expressions together. But I just wrote some Clojure that feels super-un-Clojure-like: https://gist.github.com/3727361
07:09dfdWhat is a idiomatic way to do this in Clojure?
07:09ro_sti'd start with the threading macro
07:10ro_sthttp://clojuredocs.org/clojure_core/clojure.core/-%3E
07:10dfdro_st: like, pass the results to successive clojure.string/replace calls? That would be nicer, yeah
07:10ro_stnothing wrong with regexen, imho
07:11SgeoAm I allowed to call the author of algo.monads incompetent?
07:12ro_stthis is nice and clear: https://www.refheap.com/paste/5091
07:12dfdro_st: thanks, that's really helpful. I'm still not used to thinking about -> automatically, but it is such a useful macro.
07:13ro_sti love how readable it makes a tangle
07:13ro_stand it reduces the amount of text through the auto arg passing
07:13dfdyeah, seriously.
07:13ro_stit reads -> about _this_: transform 1, then transform 2.
07:13dfdgood stuff. Thanks!
07:14ro_stcool
07:17philandstuffSgeo: if you want to make it better, submit patches
07:27Sgeohttps://github.com/Sgeo/algo.monads/commit/cd8cec109ed2df6fdf81a2566f944b1139f6a194
07:28ro_stSgeo: what is this wizardry?
07:28ro_stgo slow. i'm not a neckbeard.
07:28Sgeoro_st, do you know anything about monads?
07:29SgeoOh, the 15 new lines in the test are just a copy/paste of another test
07:30ro_sti know only that they're a functional pattern for injecting different kinds of work between the work passed to a monad
07:30ro_steg, nil checking or whatever
07:30ro_stnever used one. haven't tried yet
07:31ro_stwhat does the sequence monad do?
07:31SgeoThe sequence monad is sort of non-determinism
07:31ro_stactually, where would you use this stuff?
07:31Sgeo'(1 2 3 4 5) can be considered to represent either the value 1 or the value 2 or the value 3 or the value 4 or the value 5
07:32Sgeo(domonad sequence-m [a '(1 2 3 4 5) b '(2 3 4 5 6)] (+ a b))
07:32SgeoThat addition can be said to be adding, conceptually, the possibilities of a and the possibilities of b
07:33SgeoThe end result is a sequence that represents the addition of each possible a and b
07:33ro_stso, permutations
07:33SgeoYes.
07:33SgeoNote that this is specific to the sequence monad. Different monads can do different things, but can be generally manipulated with the same tools
07:34Sgeodomonad will work with other things too, for instance.
07:34ro_sti've heard of the error and maybe monads
07:34SgeoWhat m-lift and m-lift-fn do is take a monad-unaware function and convert it into one that takes monadic values
07:35Sgeo(m-lift-fn +) knows how to do the permutations thing, so to speak
07:36ro_stit wraps it in the right sort of machinery for domonad to work with
07:36Sgeo(Note that m-lift-fn does not exist in vanilla clojure.algo.monads, it's a function I wrote. c.a.m uses a macro m-lift instead)
07:36Sgeodomonad itself isn't the machinery
07:36SgeoIt's just a pretty way of writing code that uses this sort of thing
07:36ro_stah
07:37ro_stwhat need produced these monads?
07:37ro_stwhat field are they being used in?
07:37ro_sttrying to understand the why of it
07:37SgeoWell, Haskell uses them for I/O
07:37ro_stoh, right
07:37SgeoThey provide a way to describe things being done in a certain order
07:38SgeoThey're also convenient for doing state
07:38ro_stthat's right because haskell doesn't guarantee an execution order
07:39SgeoThe State monad wraps up the pattern of returning two values, one representing a global state, and feeding that global state into the next thing, in a convenient to use way
07:41SgeoThere's also a library using them to manage resources that should be closed in a timely fashion
07:41ro_sta with-open style thing
07:42SgeoI'm... not sure how to describe it. It's a bit more flexible than with-open
07:42ro_stthat's ok. don't hurt yourself trying. i'm merely curious
07:42SgeoI'd say it's more like a macro in which you could register actions to be done when the code in the macro is done executing
07:43SgeoSuch registered code will always be called exactly once.
07:43ro_stah, kinda like try's finally
07:43SgeoHmm. Yes, excpet without forcing them to be written in one part of the macro
07:44SgeoBut a major point is that, with all of these things, there are functions that apply to all of them
07:45Sgeom-lift-fn, m-join, there's a map-like function (although that's another thing I'm mad about. All monads support that, but there's more than just monads that support it)
07:45ro_stwhat does m-join do?
07:45ro_stdoes it relate to fork/join?
07:46SgeoIf you have a monadic value in a monadic value, it unwraps it one level
07:46ro_sti heard rhickey mention it in an interview
07:46Sgeo,(apply concat '((1 2 3) (4 5 6)))
07:46clojurebot(1 2 3 4 5 ...)
07:46ro_stoh right, so probably not
07:46SgeoSo, m-join for the sequence monad is apply concat
07:48SgeoIn fact, if you can define m-join, you have a monad.
07:48SgeoAlthough the typical definition of monads uses a bit more difficult way to define them
07:49ro_stso a monad is what to do with result from operation a when giving it to operation b
07:50SgeoIt's... not quite that simple
07:50SgeoI think
07:50ro_st-grin-
07:51SgeoThere are two operations you need to define (If you define them, m-join can be defined in terms of them, and if you define m-join, these can be defined in terms of m-join)
07:51Sgeom-bind and m-result
07:51Sgeom-result simply wraps up its argument in ... a monadic value, so to speak
07:51Sgeo,(list 5)
07:51clojurebot(5)
07:51Sgeom-result for the sequence monad might simply be list, for example.
07:52ro_stgotcha
07:53Sgeom-bind takes two arguments. A monadic value, such as, in the case of the sequence monad, a sequence. And a function, that takes an argument that isn't a monadic value, and gives a result that is
07:54Sgeo(Note that a function that doesn't know how to give a monadic value can easily be turned into one that does, by doing m-result on its result)
07:56SgeoFor example, the sequence monad's m-bind will takes the monadic value argument (a sequence), and run the function that it's given once for each value in the sequence. It will then take all the results, and concatenate them together
07:56ro_stah so bind is the workhorse
07:57SgeoYes
07:57ro_stresult prepares individual results for the workhorse to use for each cycle, and join prepares the final result for return to the caller
07:57ro_stlet me guess: it's not that simple? -grin-
07:59SgeoWell, you don't need to use result, although it's convenient (and it does need to be defined). And join is ... more of an alternative workhorse, that might be easier to define in some cases, and might be convenient to use in some cases
08:00ro_sti guess each monad has slightly different emphases
08:00ro_stputting the work in different places
08:00SgeoMore that they do different work
08:00SgeoDifferent definitions of m-bind and m-return
08:00ro_stcould you define a nothing monad that has all the parts but leave the inputs unaffected?
08:01SgeoYes
08:01Sgeom-bind would take an ordinary value and a function, and apply the function to the value
08:01Sgeom-return would just be identity
08:01ro_stoh i think i see: you could use different combinations of different binds and returns and joins?
08:02SgeoNo. bind and return are supposed to be defined in one way for one monad, and a different way for a different monad.
08:02SgeoAt least that's how it works in Haskell.
08:02ro_stok so the monad's definition is in the bind and the return
08:02Sgeoro_st, yes, exactly.
08:02ro_stgotcha
08:03ro_stvery interesting. it's on my list
08:03ro_stalong with several billion other things
08:03ro_st-sigh-
08:04SgeoHmm. Was I saying return or result? Because return is the Haskell term, but clojure.algo.monads says m-result
08:04ro_sti inferred that :-)
08:05ro_sttime to go. happy hacking, Sgeo
08:05SgeoThanks. Bye.
08:10Sgeo$mail jimduey I take back my challenge. It's possible, just not nice like in Haskell.
08:10lazybotMessage saved.
08:33kjellskiwhat is the best way to get the OOP nightmare out of my head? ^^ this seems to "block" my functional thinking a lot ...
08:33kjellskihammer?
08:34wmealing_ use a different editor
08:34wmealing_with a different color scheme
08:34wmealing_on a different computer
08:34wmealing_in a different room
08:34wmealing_worked for me
08:35wmealing_i intentionally work from the data structures backwards too
08:35wmealing_but i'm an average clojure programmer
08:35wmealing_not great by any means
08:38SgeoHaskell would give you a straightjacket
08:38kjellskiwmealing_: thanks, that is a great idea…
08:39wmealing_i found it worked.. i do my clojure outside, and my C in the office.
08:40wmealing_let me know how it goes for you
08:40kjellskiwmealing_: I'll let you know :) thanks
08:50antares_kjellski: I suggest that you model a few basic problems with protocols
08:52SgeoProtocols gross me out
08:52SgeoMultimethods seem more versitile
08:52SgeoAnd protocols vs multimethods is a leaky distinction
08:54kjellskiantares_: Sgeo: with enough time, I'll try both :)
08:54antares_kjellski: protocols will probably be very straightforward to you, then you can try more ad-hoc polymorphism with multimethods. As for managing state, see some game tutorials out there.
09:24mindbender1sophisticated type systems vs simpler type systems
09:25mindbender1clojure=*simpler* type system
10:12jro_if I want to define a configuration file, is following way dangerous somehow: (def properties (if (file-exists? properties-file) (eval (read-string (slurp properties-file))) default-properties))
10:17sunkencityrylehSo when I launch my project with "lein repl" and do macroexpand-1 on my macro I get this garbage printout "#<core$if_method$fn__304…" what am I doing wrong?
10:17sunkencityrylehuh, so I needed to quote it
10:18sunkencityrylehI
10:53gfrederickssunkencityryleh: yeah :) gotta return code, not functions
11:39casionwhere can I find information on writing performant clojure code?
11:42antares_casion: performance is very workload specific. Profile first. Java Performance book by Charlie Hunt is a great book on the subject.
11:43casionantares_: I have that on my reading list, however I was looking for more clojure specific topics
11:44antares_avoid reflection warnings, use protocols over multimethods where possible, use transients in critical places
11:44antares_there are no other hard and fast rules for Clojure
11:44dhofstetcasion: there is chapter about performance in "the joy of clojure"
11:44casiondhofstet: oh, I guess I haven't got there yet
11:46casionhmm, what would be an example of a time where you would use a multimethod over a protocol?
11:53antares_when you dispatch on the type of the first argument
11:53antares_protocols cannot do anything else
11:54antares_but they are more efficient, single dispatch vs double dispatch
11:54no7hingare there any benchmarks about this out there?
11:55no7hingon how much faster protocols really are? as in orders of magnitude(s)
12:12antares_no7hing: unlikely that it is orders of magnitude but in a tight loop 1 method invokation vs 2 matters. Plus multimethods are synchronized in 1.4.
12:15no7hingsynchronized e.g. when i add new methods to it?
12:18polycosm(In emacs) Hello, can someone explain to me how to import functions from an opened file to nrepl ? (C-c C-k does nothing).
12:19jam`(use 'your-ns)
12:20jam`or require or whatever
12:20antares_no7hing: as well as during dispatch, see https://github.com/clojure/clojure/commit/83ebf814d5d6663c49c1b2d0d076b57638bff673
12:20no7hingoh noes
12:20jam`or in-ns to your workspace
12:20no7hinga huge contention point just built up in front of me
12:20jam`I mean namespace
12:22jam`is there a function like split-by in the example? (split-by even? (range 10))
12:22jam`=> [(8 6 4 2 0) (9 7 5 3 1)]
12:23polycosmhmm jam` I'm trying but I can't seem to figure it out (about in-ns) how do you turn it on ?
12:23Scriptor,(doc group-by)
12:23clojurebot"([f coll]); Returns a map of the elements of coll keyed by the result of f on each element. The value at each key will be a vector of the corresponding elements, in the order they appeared in coll."
12:24Scriptorjam`: could probably just call vals on that ^
12:24jam`cheers Scriptor
12:25jam`polycosm: if you have, for example, "my-core" namespace file opened in emacs then you can do (in-ns 'my-core) in nrepl
12:26jam`polycosm: then after you do c-c c-k in that file the lastest compild version will be available in nrepl
12:26polycosmoh thank you very much
12:26jam`wlm
12:27jam`or if you're in another ns you can do (use 'my-core)
12:27jam`to import its functions into the ns you're playing with in nrepl
12:30polycosmmy repl doesn't know "use" though
12:31jam`hmm, strange
12:31jam`mine does:
12:31jam`user> use
12:31jam`#<core$use clojure.core$use@203da423>
12:32polycosmoh it's because I was in a ns I erased, my bad
12:32jam`ah, ok
12:46antares_no7hing: the RW lock implementation in master should be pretty good
12:47no7hingi already made a mental note to try it out ;)
12:47no7hingtrying to get https://github.com/davidsantiago/multifn-perf running, but no success
12:49no7hingin my scenario 16-32 threads would try to get to the multimethods
12:49no7hingwhich equals a bloody massacre
12:49no7hingto
13:40hfaafbhow should i find the largest item in a set that meets a certain condition
13:43hfaafbmax-key seems right...
14:10hyPiRionhfaafb: usually, (apply max-key ...) is the way to go
14:10hfaafbahh yeah just discovering that now ;)
14:13werbittHi, I'm trying to write a function that can take zero or more args but I'm having issues when I use it with zero args. Here's a gist: https://gist.github.com/3729077 . I appreciate any help.
14:22wjcHi
14:23wjcI'm trying to use fetch with noir
14:23wjcI added fetch "0.1.0-SNAPSHOT" to project.clj
14:24wjcwhen I try to use fetch's remotes, I get a js error: POST http://localhost:8080/pinotremotecall 404 (Not Found)
14:25megamind1Oh..
14:25wjcafter cloning fetch from github, I see no reference to pinot
14:25megamind1way many ppl than #Lisp
14:26wjcdo I have the right version? fetch 0.1.0-SNAPSHOT? there's only two other alpha versions after doing a lein searc
14:26wjc*search
14:28wjcwerbitt: your argument declarations are correct
14:29wjcbut at the end, you wrapped ms, a vector: (ms), so clojure tries to execute your vector
14:30werbittoh, i see, cool, thanks a lot
14:30wjcno problem
14:36megamind1anyone tried vsClojure extension ?
14:36xeqiwjc: I think -alpha2 is the latest
14:37wjcI tried it too, I still get the pinot error
14:38wjcI'm using noir 1.3.0-beta3, is that correct?
14:38xeqiI've gotten it to work with versions in https://github.com/xeqi/friend-fetch-example/blob/master/project.clj
14:39xeqiI don't know much about the difference in the noir betas
14:40xeqiwjc: just to make sure, you did remove the js file and recompile?
14:40wjcuh, good call
14:43wjcnope, same thing even with noir beta8
14:49XtremeHello
14:49wjcremoving .lein-cljsbuild-compiler-0 did the trick
14:51xeqistrange, but glad its working for you now
14:51Xtrememegamind1, ooh, lol
14:52wjcyup, thanks
14:52megamind1yeah, that's it. Xtreme
15:04Xtremeguys is there any ide for clojure?
15:04megamind1a lot out there
15:04hfaafbhow does #clojure feel about light table
15:04hfaafb(i'm new to the language and community)
15:05Xtrememegamind1, anyone whihc you prefer?
15:07megamind1since your work concern Java , I suggest netbean or eclipse for intelliJ
15:07megamind1maybe easily to dig in code
15:09megamind1Actually, I'm new to Clojure also. I'm just finding the most comfortable way to work with it :)
15:10xeqiin general the order of good clojure integration is emacs, eclipse w/ counterclockwise, vim w/ lein-tarsier, then a large gap before any others
15:11Xtremeand tutorials? nice set?
15:13polycosmXtreme, try 4clojure.com I'm learning clojure through it right now, I find it really good
15:13xeqiyeah, 4clojure.com has a good set of problems that get harder over time
15:13xeqiclojurebook.com is the recommended book if you like those
15:16akhudekxeqi: Intellij + La Clojure is also very nice.
15:16Sgeoo.O I learned something new today
15:17Sgeojimduey's deftype for a Maybe monadic value stores the value in a closure for deref, and nowhere else
15:18SgeoOh woah it's horribly broken
15:18SgeoThe person who I pointed to it was right, I was wrong
15:19xeqiakhudek: do you know if it can use a project.clj or nrepl?
15:19Sgeo$mail jimduey You got Maybe wrong about as badly as algo.monads does. In fact, I'm not sure if it's even a monad, the way you (and algo.monads) describe it.
15:19lazybotMessage saved.
15:20akhudekxeqi:
15:20akhudekit's not that good sadly
15:21akhudekthough there is a lein plugin for intellij that I don't use
15:32SgeoQuick question: If someone uses a symbol like ::blah, is that symbol considered private, in some sense?
15:33xeqinot really, its just a way to namespace and avoid collisions
15:33xeqi&::blah
15:33lazybot⇒ :clojure.core/blah
15:33xeqi&:blah
15:33lazybot⇒ :blah
15:33SgeoI'm wondering if I should consider ::nothing in my analysis of whether jimduey's maybe breaks the monad laws
15:34SgeoIf it's "private", so to speak, it would make sense if I didn't
15:34hyPiRionwell
15:34hyPiRion,::foo
15:34clojurebot:sandbox/foo
15:34Sgeo(If I do consider it, it's trivially broken)
15:34hyPiRion,(= ::foo :sandbox/foo)
15:34clojurebottrue
15:35SgeoSo to give his library a fighting chance at acceptability..
15:36Sgeoalgo.monads's maybe-m trivially breaks the monad laws.
15:36SgeoNext contestant.
15:45Sgeo$mail jimduey I take that back, I think yours works, as long as users cannot themselves construct ::nothing. algo.monads's maybe-m trivially breaks the monad laws, though
15:45lazybotMessage saved.
15:47mwcampbellI noticed that leiningen 2 places a file called "repl-port" in the current directory when I run "lein repl". Is this a feature? My guess is that it was a temporary thing for debugging that was mistakenly left in.
15:48hyPiRionmwcampbell: You're right.
15:48hyPiRionMan, they exist probably in every folder on my computer.
15:59technomancymwcampbell: it should be fixed in the latest version
16:01akhudekis anyone here familiar with shoreleave and it's csrf protection?
16:01akhudekit seems to look for the anti-forgery token in a cookie
16:01akhudekbut I don't see any corresponding server side functionality to actually set the cookie
16:04SgeoWheee http://dev.clojure.org/jira/browse/ALGOM-7
16:11megamindhey yo
16:12megamindCan Clojure on Emacs auto discover available methods/property in imported Java library ?
16:21akhudekoh, wow
16:21akhudekok that was really confusing
16:21akhudekshoreleave depends on a "fork" of ring-anti-forgery that does cookies
16:23akhudekyet it links to the main project
16:24akhudekor nevermind, it is just outdated and depends on an old anti-forgery
16:35augustlis it good or bad practice to have run-time type checks and throw exceptions if you pass, say, a vector instead of a map?
16:36akhudekaugustl: you should use pre and post conditions for that
16:36akhudekhttp://blog.fogus.me/2009/12/21/clojures-pre-and-post/
16:36augustlI see
16:37augustlgoing to make some functions that take specific Java types as arguments, makes sense to check for correct types I think.
16:37amalloyaugustl: meh. you can do that if you want. but having every function covered with typechecks is lame; i don't recommend doing it except for the outermost layer
16:38augustlamalloy: I'm only thinking of doing it for my public API
16:38akhudekamalloy: I take it there is a performance hit with these checks too
16:38amalloy*shrug* of course
16:38akhudekis there a way of disabling them, say when running in production?
16:39amalloybut so what? if typechecks are your bottleneck your program sucks
16:39TimMc...
16:39Sgeoamalloy, hey, did you see above ranting?
16:39augustlI'm making a ring middleware, so I'll only do the type checks when creating the handler function ;)
16:40akhudekamalloy: not always the case
16:40amalloySgeo: yes, but i'm not interested
16:41akhudekplus I use pre conditions for more then type checks at times
16:45megamindCan Clojure on Emacs auto discover available methods/property in imported Java library ? anyone ?
16:46hyPiRionmegamind: Er, I don't believe so. At least not yet.
16:47megamindthanks, just in-case that happen, I don't need to download Eclipse
16:52akhudeknice, you can disable pre and post via *assert*
16:57augustlakhudek: cool
16:58megamindIs there any extension that work well with Clojure CLR ?
16:58megamind* IDE extension
17:08sunkencityrylehI'm stuck at figuring out how I can get the metadata of a symbol that is passed into a function without having to write a macro.
17:09sunkencityryleh(defmacro arglist [action] `(-> ~action var meta :arglists first)) works but surely it should not need to be a macro?
17:12hyPiRionsunkencityryleh: use (meta (resolve symbol))
17:12sunkencityrylehhyPiRion: thanks
17:12hyPiRionit requires that the symbol exists within the namespace, though.
17:16amalloysunkencityryleh: if it's a function, then (f x) is not passing the symbol x into the function, it's passing the currently-bound value
17:16amalloyyou really cannot count on any metadata attached to a function
17:18sunkencityrylehhm ok
17:22sunkencityrylehI guess the macro way is the way to go then
17:22amalloymore likely you should just not do whatever you're trying to do
17:26sunkencityrylehprobably
17:29hyPiRion$findfn [0 1 2 3] [2 3 0 1]
17:29sunkencityrylehI'm trying to write a macro that I can use with compojure to (add-action foobar/show) that looks at foobar/show and sees that it takes the arguments param and user and generates (GET "/foobar" {param :param user :user} (foobar param user))
17:29lazybot[]
17:30hyPiRiondangit, is there any idiomatic way of rotating a seq?
17:30sunkencityrylehseems tedious to have to pull out the requests for each action I want to define
17:30sunkencityrylehpull out the arguments
17:30sunkencityrylehrouting for
17:30amalloy&(doc cycle)
17:30lazybot⇒ "([coll]); Returns a lazy (infinite!) sequence of repetitions of the items in coll."
17:31amalloy&(doc drop) ; hyPiRion
17:31lazybot⇒ "([n coll]); Returns a lazy sequence of all but the first n items in coll."
17:32hyPiRion,(take 4 (drop 2 (cycle [0 1 2 3])))
17:32clojurebot(2 3 0 1)
17:32hyPiRionoh well.
17:32hyPiRion,(let [[a b] (split-at 2 [0 1 2 3])] (concat b a)) ; was a bit tedious.
17:32clojurebot(2 3 0 1)
17:34no7hingif i want to make sure that certain keys are in a map argument, is pre the way to go?
17:34no7hing:pre
17:35no7hingif yes, is it possible to check for multiple of them? {:pre [(:id x) (:name x)]} seems verbose
17:36no7hingto sum it up ;) i'am looking for an idiomatic way to make sure i got all i expect before starting computations
17:36hyPiRionno7hing: I believe it is the way to go. You could use ##(every? #{:id :name} (keys {:id 1 :name "foo"}))
17:36lazybot⇒ true
17:36no7hinguh nice
17:36no7hingthanks
17:37SgeoIsn't there something in swiss-arrows?
17:37aperiodicno7hing: i'd do {:pre [(map (partial contains? x) [:id :name ...]]}
17:37no7hingi'am trying to not shoot myself - yet :D
17:38no7hingbut i had a look at the lib and was intrigued
17:38hyPiRionno7hing: aperiodic's solution is better than mine, performance-wise.
17:38akhudekhyPiRion: that will only check that every key is valid, not that every valid key is present
17:38aperiodicno7hing: note that (contains? x key) and (key x) will return different things depending on if x actually contains key, but maps it to a nil value, versus doesn't contain key at all
17:39aperiodicno7hing: also there should be an outer (every? identity ...) around the map form in what i suggested
17:39no7hing,(contains {:id 1} :id)
17:39clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: contains in this context, compiling:(NO_SOURCE_PATH:0)>
17:39no7hingwhoops
17:39aperiodic,(contains? {:id nil} :id)
17:39clojurebottrue
17:39no7hing,(contains? {:id 1} :id)
17:39clojurebottrue
17:40aperiodic,(boolean (:id {:id nil}))
17:40clojurebotfalse
17:40no7hingnever thought i'd say that, but i miss skype's correct feature
17:40hyPiRionaperiodic: Why not just ##(every? #(contains? {:id 1 :name "foo"} %) [:id :name])
17:40lazybot⇒ true
17:42no7hingi only need to check for the presence of keys
17:42amalloyhyPiRion: aperiodic's (map (partial contains?)) doesn't work anyway
17:43aperiodicdrat, what did i screw up?
17:43hyPiRionamalloy: he said that "there should be an outer (every? identity ...) around the map form"
17:44jkkramer(defn has-keys? [m & ks] (every? #(contains? m %) ks)) … {:pre [(has-keys? arg :a :b :c)]}
17:44hyPiRionyeah, that's sweet.
17:44amalloyoh, i missed that
17:45aperiodicyeah, defining a function makes the discussion around whether you like maps & partials or anon function literals moot
17:45aperiodic(inc jkkramer)
17:45lazybot⇒ 3
17:46SgeoI like partials
17:46Sgeo>.>
17:46SgeoMakes me miss Haskell a little less
17:46hfaafb,(require clojure.set/map-invert)
17:46clojurebot#<CompilerException java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.set, compiling:(NO_SOURCE_PATH:0)>
17:47hyPiRionI like them in the sense that they are "pure to the eye". But they're slow :(
17:47hyPiRion,(require 'clojure.set)
17:47clojurebotnil
17:47hfaafbahh so what is this apostrophe business
17:47hfaafbdon't evaluate me just yet?
17:48hyPiRionhfaafb: yeah, it's a quote, for "just quote me, don't evaluate me"
17:48SgeoIt's more "don't evaluate me" period
17:48Sgeo,(str '(1 2 3 4 5))
17:48clojurebot"(1 2 3 4 5)"
17:48Sgeo,(str (1 2 3 4 5))
17:48clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
17:48Sgeo,(str (quote (1 2 3 4 5))
17:48clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
17:49Sgeo,(str (quote (1 2 3 4 5)))
17:49clojurebot"(1 2 3 4 5)"
17:49Sgeo,('(1 2 3 4 5))
17:49clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn>
17:49Sgeo,(identity '(1 2 3 4 5))
17:49clojurebot(1 2 3 4 5)
17:50Sgeo,'(1 2 3 4 5)
17:50clojurebot(1 2 3 4 5)
17:50SgeoOh hey
17:50aperiodichyPiRion: are partials slower than an anonymous function wrapper, then?
17:51hyPiRion&(time (reduce #(+ %1 %2) 0 (range 10000000)))
17:51lazybot⇒ "Elapsed time: 2032.59323 msecs" 49999995000000
17:51hyPiRion&(time (reduce #(+ %1 %2) 0 (range 10000000)))
17:51lazybot⇒ "Elapsed time: 1986.303416 msecs" 49999995000000
17:51hyPiRion&(time (reduce #(+ %1 %2) 0 (range 10000000)))
17:51lazybot⇒ "Elapsed time: 1893.38111 msecs" 49999995000000
17:51hyPiRion&(time (reduce (partial +) 0 (range 10000000)))
17:51lazybotclojure.lang.ArityException: Wrong number of args (1) passed to: core$partial
17:51hyPiRionmeh.
17:51hyPiRion&(time (reduce (partial + 0) 0 (range 10000000)))
17:51lazybotExecution Timed Out!
17:52aperiodicapparently so
17:52SgeoI just realized that I don't like that you need to pass more args to partial like that
17:52Sgeo(partial +) makes perfect sense, it's just +. It might seem useless, and I assume that's why it doesn't exist, but if you're making a macro to generate code, do you really want to have to detect that sort of thing?
17:53casionwhy would partial be faster? that doesn't make sense to me at all
17:53aperiodici guess because more of the work for the anonymous function wrapper happens at compile time, whereas partial does it at runtime?
17:53RaynesGuys.
17:53xeqi%(time (apply + (range 10000000)))
17:53xeqi&(time (apply + (range 10000000)))
17:53RaynesPlease don't use lazybot or clojurebot for testing speeds.
17:53lazybot⇒ "Elapsed time: 2275.128327 msecs" 49999995000000
17:54RaynesIt does crazy shit like literally changing your code in order to sandbox it.
17:54RaynesIt is in no way accurately timeable.
17:55xeqiI've heard good things about https://github.com/hugoduncan/criterium for benchmarking
17:56SgeoI should probably do things like homework instead of hating Konrad Hinsen
17:56RaynesProbably.
17:57aperiodici can reproduce this particular result locally (partial seems to be about 3.5 times slower)
17:57RaynesSgeo: What kinda homework?
17:57aperiodiccasion: partial is slower, not faster
17:58SgeoSenior Project, describing why I'd be good at my role in the group
17:58casionaperiodic: I know. I'm saying it doesn't make sense to me to even think partial would be faster
17:58SgeoOverdue essay basically :/
17:58hyPiRionHeh, I'm writing a poker bot in Clojure now.
17:58RaynesSgeo: So highschool stuff?
17:58RaynesOr college stuff?
17:58SgeoRaynes, college
17:58SgeoI'm not in "Computer Science" though. I'm in "Computer Programming/Information Systems"
17:58Sgeo:/
17:59SgeoLast semester, assuming I don't fail Intro to Drawing
17:59RaynesI was curious because high school would have placed you near my age group. Though I guess college does too.
18:00aperiodiccasion: i didn't think the difference would be significant
18:00casioneveryone here seems to be young
18:00Raynescasion: Define 'young'.
18:00casionaperiodic: well, iirc partial uses apply.. and #() is a macro
18:00casionRaynes: < average age of ##c
18:00RaynesLots of late 20s-late 30s, I think.
18:00RaynesI'm an exception.
18:01hyPiRionHuh, I thought there were a lot of early 20s too.
18:01casionI just turned 30, but I'd figure I'm 'older' than most people my age
18:01casionseems like there's a lot of similar people here
18:01RaynesYou're only 12 years older than me.
18:01RaynesThat's only over a decade.
18:01amalloyaperiodic: the partial/lambda distinction is much more pronounced with + than with most functions
18:01amalloybecause (+ a b) can be inlined, but ((identity +) a b) can't
18:02casionfinished college when I was 19, already had been doing embedded for 2 years at that point
18:02amalloytry using, eg, (let [f +] #(f % %2)) as your function, and they'll be pretty close
18:02RaynesI'm not doing the college thing.
18:02casionRaynes: good, IMO it's a complete waste
18:02RaynesI'm doing the work thing right now.
18:02SgeoIs there a good reason that (partial +) doesn't work?
18:03casionthen again, I have music degrees… which are essentially worthless :|
18:03Rayneslol
18:03RaynesWhat are those for, exactly?
18:03casionone teaching, one performance
18:03RaynesWhat career choices do you have with music degrees?
18:03casionbegging on street corners.
18:03SgeoOr even (partial)
18:03RaynesHahaha
18:04mattmossI win? 40
18:04casionseriously, no one gives a flying fuck if you have a degree in any music related career except for teaching
18:04casionand teaching music at anything but graduate level is drepressing
18:04casionand I never made it that far anyway
18:05S11001001casion: partial is faster if you have like millions of them and not so much memory for all the classes that lambdas would require (i.e. partial has constant lambda-class cost :)
18:05SgeoIs the speed really relevant?
18:06SgeoIt's the concepts that it expresses that are important, I think
18:06aperiodicSgeo: probably not :)
18:06S11001001I don't care, but someone asked
18:06aperiodicbut hey, it's interesting
18:06hyPiRionSgeo: Oh God, no. If it were, then you're using the wrong language.
18:06casionS11001001: wouldn't partial be slower for anything > 3 args though?
18:06S11001001I like partial because it's pretty, and don't care about whatever cost from losing specialization of what have you
18:07S11001001premature optimization &c
18:07S11001001I'm a lisper, I don't care about consing
18:07hyPiRioncasion: I envy musicians who program a lot. Most of them seem to excel at programming.
18:08S11001001anyway a sufficiently sophisticated compiler can optimize out a (concat ...) in the last arg position of apply :)
18:08SgeoI hate partial because it requires two arguments, and that's a stupid thing to need to check for in a macro that emits a partial
18:08casionhyPiRion: at imperitive programming maybe :)
18:08Sgeo*at least two arguments
18:08BronsaSgeo: that's no longer true :)
18:08BronsaClojure 1.5.0-master-SNAPSHOT
18:08Bronsauser=> (partial +)
18:08Bronsa#<core$_PLUS_ clojure.core$_PLUS_@31818dbc>
18:08SgeoBronsa, awesome!
18:08SgeoWhat about (partial)? I can think of a meaning for that
18:09hyPiRioncasion: http://clojure-log.n01se.net/date/2008-03-26.html#22:29
18:09BronsaSgeo: what should that return?
18:09Bronsaa 0 arity function that does what?
18:09Sgeo(partial) would be a function that takes a function and other arguments and applys function to the arguments
18:09Sgeo((partial) + 1 2)
18:10hyPiRionwell, that's clutter though.
18:10casionhyPiRion: I wonder how far he's got… that will have a lot of difficulties with that model unless he's oversampling somewhere
18:10hyPiRion((partial) + 1 2) would be just (+ 1 2)
18:11Apage43I think that was the idea, that you could move that first ) anywhere and get the same answer.
18:12aperiodicok, the anonymous function literal is faster because it knows more about its arguments than whatever comes out of partial
18:12aperiodicthat makes sense to me
18:12aperiodicSgeo: the empty partial is identity, then?
18:13Sgeoaperiodic, I think that would only work if .. it were curried?
18:14Sgeo,(identity + 1 2)
18:14clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core$identity>
18:14Sgeo,((partial identity +) 1 2)
18:14clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core$identity>
18:14SgeoUm, wtf am I thinking
18:14Apage43not identity, (fn [& args] (eval args))
18:15casionhyPiRion: you wouldn't happen to know if he spoke of this more?
18:15hyPiRion,((fn [& [a & r]] (apply a r)) + 1 2)
18:15clojurebot3
18:16aperiodicSgeo: ah, right, there's an invocation in there i wasn't accounting for
18:16hyPiRioncasion: I'm afraid not. But I know that he has an interest in audio.
18:17casionI really want to know how/if he handled the decay rate of the ion channels in the basilar membrane
18:18octagonhi, all. is there an existing function equivalent to (fn [x y] (fn [& args] (apply x args) (apply y args)))?
18:19amalloy&(doc juxt)
18:19lazybot⇒ "([f] [f g] [f g h] [f g h & fs]); Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]"
18:19hyPiRionoctagon: would you be interested in the value x returns as well?
18:20octagonno, just the value of (apply y args) is needed
18:20Apage43,((juxt list +) 1 2 3)
18:20clojurebot[(1 2 3) 6]
18:20octagoni am "funrolling" a sequence of functions all of the same arity
18:20casionhyPiRion: you have me google stalking him now :D
18:20Sgeofunrolling?
18:20octagon(reduce squash fns)
18:20hyPiRioncasion: haha
18:20octagonwhere squash is my function above
18:24gfredericksa lot of the built-in HOFs won't work since you're using side-effects
18:24gfredericksor like juxt they will do a bit of extra work
18:25xeqi&((comp second (juxt list +)) 1 2 3)
18:25lazybot⇒ 6
18:30hyPiRion&((comp second (juxt println +)) 1 2 3)
18:30lazybot⇒ 1 2 3 6
18:33Sgeojuxt reminds me of something I saw in Haskell that's... related to arrows somehow
18:33SgeoI don't entirely understand Haskell arrows though
18:33amalloySgeo: &&&, iirc
18:33amalloyor ***? i forget
18:34casionthanks to sgeo, I've learned more about haskell in here than in #haskell ;)
18:34Sgeoo.O
18:35casionhalf-joking :)
18:35mpanwhat's the name-registration bot, again?
18:35amalloyyeah, juxt is &&&
18:35Sgeompan, NickServ
18:35mpanthanks
18:36SgeoYou're welcome
18:36xeqiI always think of ***, which appears at https://github.com/flatland/useful/blob/develop/src/useful/fn.clj#L94
18:36xeqiah, misread above
18:38SgeoI can't imagine when to-fn would be useful
18:38SgeoErm, as-fn
18:39S11001001Sgeo: duck-typing
18:41amalloyS11001001: i'd describe it more as "weak typing". ninjudd is a much bigger fan than i am of APIs like "pass a function, but if it's not a function we'll make it one for you"
18:42mpanhow does the "make it one for you" work?
18:42amalloy&(let [x 5, f (constantly x)] (f 'sdafjksde))
18:42lazybot⇒ 5
18:43mpanoh, like assume if they give you val they want fn-that-gives-val?
18:43TimMcanti-trampoline
18:43TimMc:-P
18:45hyPiRionI have had use for something similar - except that x is lazily evaluated.
18:47jasonjckn hi
18:51mpanhi
18:54gfredericksamalloy: you don't like those APIs because of ambiguous cases like vector/set/map/keyword?
18:54hiredmanI may have found the perfect use for the stm
18:54amalloythat's one problem
18:55Raynesamalloy: I'm on your side regarding APIs like that.
18:55hiredmanI model each pin on my beaglebone as a ref, then I can transactionally set them high or low (with a watcher that does the actual io)
18:56amalloybut i just don't like the looseness. it makes it hard to tell what's going on when you read a call to such an API. you can see (f x y), know the behavior of f, and have no idea what x and y are without further poking around in the local scope
18:56gfredericksamalloy: Raynes: I am on both of your sides regarding APIs like that
18:56RaynesI know you are, baby.
18:56SgeoIf you want to give a function a function that will always return a value, just do it in the call yourself
18:56gfredericksamalloy: it feels a lot like rails :)
18:57amalloynice, hiredman. although, why not a single ref holding all of them? that would work, but i guess require a smarter watcher?
18:58hiredmanamalloy: finer grained transactions of course... because I am flipping those pins high and low like crazy
18:59hiredmanit's a little arm board like a rasberrypi
18:59mpanare you using... a serial port?
19:00hiredmangpio pins on the board, I am using them to control dc motors
19:01axle_512Style question… I am thinking of using clojure protocols for a data access layer (to MySQL.) My thinking is that if I switch databases, I can swap out the implementations. Is this a good practice/style in clojure?
19:01arohneraxle_512: completely unrelated to the protocols question, IMO, you can't treat DBs as interchangeable
19:02arohnerbut yes, protocols would work there
19:03axle_512arohner: thanks!
19:04mpancould you treat a subset of their functionality as interchangeable, though?
19:05mpanone that would be enough to be useful
19:05arohnermpan: not really. select count(*) from table; is O(1) in mysql and O(n) or O(logn) in postgres. Also their syntax for a lot of things are different
19:06SgeoWhat is clojure-slim?
19:06arohnerso then you either have to treat the queries as strings, which aren't interchangable, or write an ORM that abstracts across them (thousands of LoC, and a giant effort to do properly)
19:06SgeoI noticed it in the download
19:07SgeoOn a public channel
19:08aperiodichiredman: are you running clojure on the beagleboard?
19:08xeqiSgeo: don't do it
19:08Sgeoxeqi, the bot itself runs a sandboxed Linux environment
19:08SgeoI think that environment is versioned? I'm not sure, I didn't make it
19:09mpaneventually someone will try to consume an entire infinite sequence by accident
19:09xeqi"by accident"
19:09mpanhey, I did it by accident locally
19:09RaynesSgeo: selinux?
19:09SgeoI think it's UMLbox
19:09RaynesI'm working on a selinux-sandbox-for-language-eval-as-a-service project with a friend.
19:10SgeoAnd the first result for UMLbox is in fact by the person who made the bot, and UMLbox apparently
19:10mpanis it like process-per-request?
19:11SgeoRequests all take place in the same environment, I think, but if someone screws it up, the bot operator can revert it
19:11mpanneeding human intervention sounds tricky
19:11SgeoThere's maybe two channels where it's running
19:12SgeoIncidentally, is there a .gz version of the Clojure distribution/
19:13xeqiis there a way to limit the number of Threads the jvm can start?
19:14mpanwell you could have the operating system enforce it
19:14mpanbut that doesn't sound like a nice answer
19:14mpantrying to see if the security api lets you
19:17mpanI thought it was possible with the security manager but I can't find it
19:19xeqiI haven't seen anything either :/
19:20mpanyou could conditionally forbid everything in the java api that would create a thread
19:20mpanthat sounds hard though
19:20mpanbut I recall hearing someone had done it before for clojure
19:21xeqiheh, I tried to convince someone of blocking some of it
19:25axle_512arohner: more what I was thinking was something like a protocol for dealing with users. Create user, list users, get details for individual user, and delete user. Then the SQL specific details for each database would live behind those functions.
19:25arohnerah, data access layer. Much more manageable.
19:25augustlis there a way to make a jar that somehow makes its "resources" available directly in the file system as opposed to packaged inside a jar? Need to shell out to python, so the files python calls needs to be in the "normal" fs.
19:25axle_512arohner: And still a good use for protocols? Or is there a better way?
19:26hiredmanaperiodic: yes
19:26hiredmanaperiodic: with the oracle arm jvm
19:26arohneraxle_512: protocols dispatch on the class of the first argument, and are built for speed
19:26xeqiaxle_512: namespaces?
19:27hiredmanI've got a little rover I am building on what is left of a $20 rc car
19:27arohneraxle_512: normal fns might get you a long way
19:28mindbender1"I don't want to die in a language I can't understand" -- Richard P. Gabriel
19:29axle_512arohner: thanks, makes sense.
19:30axle_512xeqi: thanks, let me think on that too.
19:34axle_512xeqi: I think what you mean is to just use a different namespace per impl… all with the same function signatures. Then I can swap them out interchangably. (Without need for protocols?)
19:36xeqiaxle_512: yep, and if you alias (require '[blah.postgres :as db]) and use them db/save-user then all you have to change is the use line
19:36xeqiassuming your not changing them at runtime
19:36xeqithen namespaces wouldn't be easy, if workable
19:39axle_512xeqi: appreciate it!
19:55abcneverHi I'm new to clojure and I'm kind of confused by square brackets in clojure. I have googled it but I'm still not sure what exactly is square brackets used for. Is it vector?
19:56hiredman,(vector? [])
19:56clojurebottrue
19:56abcneveroh that's neat 0.0
19:57abcneverThanks!
20:17augustlI need to invoke a python script that uses code in the resources/ of my jar. But that only works when working with the checked out code.. When I package the jar, the resources/ aren't directly in the file system, so the python script doesn't find them
20:17augustlany suggestions?
20:20mpanextract to a temporary dir on path at runtime? that sounds messy but it would do it
20:20amalloydon't distribute a jar, get a smarter python program...
20:20Apage43http://docs.python.org/library/zipimport.html
20:21Apage43rather, the functionality is build in, so you should just be able to add "file.jar/resources" onto your python import path
20:22Apage43it may actually be looking for the ".zip" extension though, which could be problematic
20:34augustlmpan: hmm toat could work
20:34augustlamalloy: for some reason, building Google Closure requires both python and java
20:35augustlApage43: I'll investigate
20:35jrajav"For some reason"? They're fracking Google :P
20:35augustls/toat/that
20:35jrajavIt's not code until Python or Java is in there somewhere
20:35augustlwould be nice if they could pick just one..
20:36ivanGoogle Closure is 4 or 5 different tools
20:36augustlwould still be nice if the dependency script from the library was java, though
21:04clj_newb_2345what is the correct way to change a javascript object to a clojurescript object?
21:07akhudekclj_newb_2345: js->clj
21:07akhudekI think.
21:07clj_newb_2345ah; for some reason, I wa susing js->cljs
21:07clj_newb_2345*using*
21:07SgeoHow common is do-template/
21:07Sgeo*Commonly used
21:13amalloySgeo: ~never
21:13Sgeoo.O but it looks useful for various things
21:14tomojwhy does clojurescript have ASeq?
21:15tomojseq is identity on ASeqs, but this seems to mean that every ASeq should be an ISeq
21:15tomojwhich appears to be the case in core
21:17tomojjvm translation artifact?
21:30SgeoIs jayfield someone who comes here?
21:31Sgeohttp://blog.jayfields.com/2011/01/clojure-using-java-inner-classes.html 403's for me
21:32amalloytomoj: i don't think think so. it looks like dnolen added it in 653a26e3, though i can't immediately see why
21:35tomojstrange
21:35tomoj"wip", but it still doesn't appear to be used
21:35tomojexcept for seq
21:36unlinkHow do I map over the values of a hash map in Clojure? Looking for something equivalent to (fn [f xs] (into {} (for [[k v] xs] [k (f v)])))
21:38howard_guo, (let [a 1] a)
21:38clojurebot1
21:39howard_guo, (def foo (Thread/sleep 100))
21:39Sgeo, (let [+ -] (+ 1 1))
21:39clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
21:39clojurebot0
21:39SgeoHmm, there's a funny example of Haskell code but I don't think I can re-create it in Clojure
21:40howard_guoC:
21:40SgeoWell, I can, but it wouldn't be as amusing
21:40Sgeolet 2 + 2 = 5 in 2 + 2 results in 5 in Haskell
21:40tomojhuh, why didn't that get inlined?
21:40ludstonCould do (loop [keys data map] (if (empty? keys) map (recur (rest keys) (rest data) (assoc map (first keys) (first data)))))
21:40unlinkSomething like the Functor instance on Map in Haskell :-)
21:40ludstonNot very efficient though
21:41tomojunlink: well in 1.5 maps are Foldable
21:41tomojbut http://dev.clojure.org/jira/browse/CLJ-1049
21:41tomojand you can't use the result it like a map without reducing it into a new map anyway
21:42SgeoFunctor needs to be separate from other concepts
21:42SgeoSeriously
21:42SgeoThis is absurd
21:42howard_guo,(import 'sun.misc.Unsafe)
21:42clojurebotsun.misc.Unsafe
21:42howard_guoeh?!
21:44SgeoI doubt you'll be able to use it
21:44amalloySgeo: i've noticed all the clojure libraries are absurd. save your breath and write better ones
21:44Sgeo,sun.misc.Unsafe
21:44clojurebotsun.misc.Unsafe
21:45howard_guo,(do (import 'sun.misc.Unsafe) (sun.misc.Unsafe/getUnsafe))
21:45clojurebot#<CompilerException java.lang.RuntimeException: java.lang.NoSuchFieldException: getUnsafe, compiling:(NO_SOURCE_PATH:0)>
21:45howard_guo:(
21:47howard_guo,(prn 1)
21:47clojurebot1
21:47howard_guo,(prn (System/getProperty("java.version")))
21:47clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
21:47howard_guo....
21:47howard_guo,(prn (System/getProperty "java.version"))
21:47clojurebot#<SecurityException java.lang.SecurityException: denied>
21:47howard_guohahaha...
21:49howard_guo,(import 'java.beans.Expression)
21:49clojurebotjava.beans.Expression
21:50tomojmaybe try hacking lazybot in PM?
21:50howard_guono intention of hacking, just having some fun
21:54howard_guo,(do (import 'java.beans.Expression) (.getValue (Expression. System "getProperty" (into-array String ["java.version"]))))
21:54clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.InternalError: bouncer cannot be found>
21:55gfrederickshoward_guo: but your fun is noisy
21:55gfredericksyou can use a private message to cavort with the bots
21:55howard_guook
21:55howard_guosorry
21:55gfredericksno worries; I've done it too often myself
21:55howard_guowhat is a java bouncer?
21:58tomojbtw if you manage to find a hole, that's good and should be reported to clojail
21:58howard_guoyeah... im not a bad guy
21:58tomojie hacking encouraged, it makes the jail better
21:59ludstonDon't worry howard_guo, *I* think you're a bad guy.
21:59howard_guo^^
22:01xeqiI think lazybots pretty secure now, though there are ways to crash it
22:01howard_guothis morning I was debugging my network application, it uses linked blocking queue to process incomming requests
22:01tomojI wonder if binding is only outlawed because push-thread-bindings is dangerous?
22:01howard_guoand I then noticed , for some reason, the requests get lost after few thousands of them
22:01howard_guoso I spent few hours to debug that, no progress
22:01howard_guoand then I came here...
22:02amalloytomoj: yes
22:05howard_guomy Clojure networked application needs a queue to sequentially process incoming requests, is it better to use linked blocking queue or build a queue using Clojure's concurrent mechanism?
22:05howard_guoI don't need many functions, just an add and a remove
22:07xeqi(doc pop)
22:07clojurebot"([coll]); For a list or queue, returns a new list/queue without the first item, for a vector, returns a new vector without the last item. If the collection is empty, throws an exception. Note - not the same as next/butlast."
22:07howard_guoum...
22:08howard_guoI thought about building the queue using clojure's functions
22:08howard_guobut then realized, if 1000+ requests are queued, each time an entry is popped from the queue, the queue needs to be copied, popped and then assigned back to the atom?
22:09ludstonHave you considered using JMS?
22:10howard_guono I have not
22:10howard_guoI will check it out
22:11howard_guobut linked blocking queue shouldn't break after just a few thousands of queued things right?
22:11ludstonI'm not sure about any clojure interfaces for it. It's "Java Messaging System" and it's pretty much just consists of a queue sevlet thingy that you can push and pull messages from.
22:11amalloyclojure's immutable data structures are much more efficient than just copying the whole thing
22:11howard_guothank you
22:12amalloyconj and pop are both O(1) on a queue
22:12howard_guocool
22:12howard_guomy clojure network app, reads messages from sockets, put them into a linked blocking queue
22:12howard_guothen another thread, takes entries from the queue and process them
22:12tomojconj is O(log_32 n), pop is O(1)?
22:13howard_guoI started a client, and in a (doseq [I (range 10000)] loop, it sends those messages through socket
22:13howard_guoand I noticed that server app's linked blocking queue no longer returns when "take" is called. after around 3000 messages are queued
22:13howard_guoreally weird
22:14tomojI guess pop is O(log_32 n) as well
22:14amalloytomoj: did you watch spiewak's talk at the second conj, about the implementation of functional queues?
22:14tomojno
22:14tomojis it amortize O(1)?
22:14akhudektomoj: log_32 n is really small
22:14amalloyyes
22:15amalloypop is, anyway
22:15tomojcool
22:15amalloyconj is log32
22:15howard_guoconj to vector is log32?
22:15howard_guois conj to list O(1)?
22:16amalloybut i still prefer to call that O(1) anyway
22:17tomojI'm still confused about that
22:17akhudek,(/ (Math/log 1000000) (Math/log 32))
22:17clojurebot3.986313713864835
22:18amalloytomoj: you know the formal definition of big-O?
22:18tomoj,(/ (Math/log 1000000) (Math/log 2) 5)
22:18clojurebot3.986313713864835
22:18tomojyeah
22:19SgeoI'd imagine conj to a list os O(1)
22:19howard_guohope so...
22:20tomojseems like any argument for using "O(1)" for O(log_32 n) would not be hard to apply to O(log_2 n)
22:20SgeoA list is just a value and another list, prepending to it shouldn't matter how much other stuff is in the list
22:20howard_guo:)
22:20amalloytomoj: sure, that's a fair objection
22:20SgeoWhy not just say that conj to vector is O(log n) but that it's fairly small
22:20tomojexcept the magnitudes of "too big to care" is different?
22:21amalloybut if you put log32 in between 1 and log2, it's a lot closer to 1 than to log2
22:22amalloysome of it is also just convenience. it's easier to characterize the running time of some larger algorithm if you pretend insertions to vectors are constant time, instead of pedantically carrying along the log32 through the whole analysis
22:24tomojok
22:25tomojbut what confuses me is that it is acceptable to drop it
22:25tomojor s/that/whether/
22:25SgeoMathematically, no.
22:25SgeoBut what amalloy is trying to get at is that in practical usage, the amount of time is going to be small even with large vectors
22:26SgeoIt doesn't mean that it becomes O(1), because it doesn't
22:26SgeoBut it does mean that when trying to choose an algorithm, O(log_32 n) might be as negligable as O(1) is, I think
22:26howard_guoyou'll probably need Google scale challenges to notice that difference :D
22:27tomojand the reason we don't say binary search is "practically O(1)" is because trees big enough were the difference is noticeable are common?
22:27tomojs/were/where/
22:27amalloytomoj: i think so
22:27SgeoI would say that it's wrong to say that it's O(1), just say that it's as negligable as O(1)
22:28SgeoIt's O(log n) with a very small I'm not sure the word
22:29tomojso if some years from now, datasets 5x bigger than what we have now are common, will we have to increase the arity of our tries?
22:29tomojwait, that 5x seems wrong
22:30tomojis it actually 32^5 :O
22:30metellusone thing to keep in mind in all of this is that O(1) does not guarantee fast and O(log n) doesn't necessarily mean slow
22:30metellusin practical cases, coefficients do matter
22:31metellusand when the JVM is concerned, log_32 (n) never goes above something like 7
22:31amalloytomoj: something like that. i'd say more like 2^32
22:31amalloybecause that's when we'll finally need to use a long rather than an int for an array index
22:34tomojso at n=4.789e52 log_32 never gives above 35, which is where log_2 is now
22:34tomojwhich is more than the number of stars in the observable universe
22:35tomojbased on that I'm going to pretend to myself that I'm not confused anymore :)
22:44howard_guoIf you have some spare time to spend, please take a look at this issue in my Clojure network application:
22:45howard_guohttps://github.com/HouzuoGuo/Aurinko/issues/12
22:45howard_guoI have tried very hard but still cannot figure out why LinkedBlockingQueue fails me
22:45Hodappdid my eyes just observe... Counterclockwise hot-swapping my code in as I evaluate it?
22:45howard_guowow really it does that?
22:46Hodappwell, now that I think of it, I suppose with Quil it makes more sense because I was redefining the 'draw' function, which it calls every frame
22:46amalloytomoj: number of stars in the observable universe seems *way* smaller than that, isn't it?
22:47Hodappbut even so, I am surprised that the updated 'draw' is what's used in all other places then
22:47howard_guowow that is really handy
22:47HodappI certainly could not do this with Processing
22:47akhudekamalloy: "The observable universe contains between 10^22 and 10^24 stars…"
22:48amalloyright. 10^52 sounds more like the number of electrons in the observable universe, not stars
22:48tomojwiki says number of atoms is very roughly 10^80
22:49akhudekI can see the blog post now "Clojure for universe-scale processing"
22:49howard_guohahahaha
22:49howard_guo"Clojure has solved the universe"
22:50SgeoIf I have some program that's written in Java, and, say, it's a chat program, I should be able to, with a Java decompiler and Clojure, make bots to connect to it?
22:50Sgeo(Java decompiler just to know what classes and functions to use, I'm aware Clojure doesn't need source code)
22:51howard_guodecompiled clojure code is quite... ugly
22:57ivanhoward_guo: do you... reload your code after ~1000 offers?
22:57howard_guoreload my code?
22:57howard_guosorry I don't get it
22:57ivannot knowing anything, the only thing I suspected was offering to a new/wrong LinkedBlockingQueue
22:57howard_guooh..
22:58howard_guothanks for that, I'll check it anyway
23:01Hodappaaaaand I crashed Eclipse
23:01SgeoI've had a long-standing complaint about Clojars
23:01SgeoI should just try to put a web app on Heroku or something to solve it
23:02SgeoAlthough.... hmm, the possibility of malicious jars... I don't know how to fix that
23:02Hodappall I want to do is (1) stop the Clojure application I just started and (2) restart it without everything exploding
23:02howard_guoand boom
23:02Sgeo(I just want a tool to browse the source of uploaded jars)
23:09SgeoAlthough, do lein jars and uberjars precompile all the .clj? If so, then my idea is sort of useless
23:13Hodappjeebus, even without getting the hang of Clojure yet completely, I am finding it rather awesome that I can swap in new function definitions while the damn code is running
23:14ivanSgeo: I just track down everyone's git repos and use my hacky build system to build everything
23:14ivanall 242 of them
23:14SgeoI meant more in terms of reading the source to get an understanding of what it does
23:14xeqiSgeo: out of curiousity.. whats your complaint?
23:14ivanClojure libraries are almost always .clj source in the jar
23:15Sgeoxeqi, that it's not convenient to browse the source of a library on Clojars right on the site
23:15RaynesSgeo: Clojure code is very rarely aot'd at all.
23:16uvtcSgeo, I think the tool to browse a jar's source code is github. :) That is to say, the canonical clojars page for a given library should almost always contain a link to the lib's github page, and you can browse the code there.
23:16ivanbut what if the jar code does not match the VCS code!
23:16RaynesYou can just download the jar and open it up in emacs.
23:17uvtcJust FYI, all jars are directly available at http://clojars.org/repo/ .
23:20ivansomeone ought to write a tool to verify that everyone's releases correspond to a git commit
23:21ivanand then read every line of code
23:21uvtcxeqi: Clojars feature request: On a given library's Clojars page, also provide a direct link to the jar somewhere on the page.
23:21ivancouple days ago I found a unit test downloading an unsigned clojure.jar over HTTP
23:21Sgeoivan, o.O wtf
23:22SgeoIs there a process for getting malicious stuff removed from clojars?
23:22Raynesuvtc: I'm against that.
23:22Raynesuvtc: It'll encourage new people to try to download and 'install' the jar.
23:22RaynesThe way it is now, they're forced to read about Leiningen. Pretty much, anyways.
23:23ivanI wanted that feature at some point, then just used rsync to get all of clojars
23:23RaynesSgeo: Well, the first step is for people to not download malicious stuff.
23:23tomojto get all the docs and source metadata, wouldn't you need to actually load the code? so LXC per artifact?
23:24RaynesSgeo: clojars will require jar signing and such for the main maven repo soon.
23:24RaynesSo that might help.
23:24uvtcRaynes: Ah. Ok. Well, anyway, easy enough to grab the jar from /repo/group-id/artifact-id too.
23:24RaynesI imagine that if you found something malicious, you could get it removed by asking technomancy.
23:25xeqiSgeo: https://github.com/ato/clojars-web/wiki/Contact
23:26uvtcOne person's malicious is another person's delicious.
23:26uvtcWait, I didn't say that.
23:27uvtcSee, as soon as I see Raynes here I start using all by late-night humor.
23:28uvtcSpeaking of Raynes, if anyone's interested, I've been experimenting with htmlizing and colorizing the IRC logs that he collects. I've started putting them at http://www.unexpected-vortices.com/clojure/irc-logs/index.html .
23:28uvtc(just the ones for #clojure)
23:29aperiodicoh rad, you did the monospacing for the evaluation requests!
23:29aperiodic(inc uvtc) <3
23:29aperiodicugh
23:29aperiodic(inc uvtc)
23:29uvtcUh oh.
23:29lazybot⇒ 1
23:29ivan"SANBOX DENIED"?
23:30aperiodichmm
23:30aperiodic(inc aperiodic) ; garbage
23:30lazybotYou can't adjust your own karma.
23:30uvtc(inc aperiodic) ; hi!
23:30lazybot⇒ 1
23:31aperiodicoh, all bot messages are monospaced
23:31aperiodicgood enough
23:31uvtcaperiodic: Yes. I think that was requested yesterday.
23:31aperiodicwell, it would be cool if the input was too
23:31aperiodicis this in a real repo yet?
23:31uvtcI tried having all the comments be the same default color, but I just liked reading them in color better.
23:31uvtcSo, alas, can't make everyone happy.
23:32uvtcaperiodic: Ah, right. I need to create a github repo for the project.
23:32aperiodicyou could just use lazybot & clojure as dependencies, and hook into however they find the forms to evaluate
23:33uvtcI don't yet know why http://www.unexpected-vortices.com/clojure/irc-logs/2012/09-15.html#06:35:17 isn't rendering the last character correctly (in my browser).
23:33uvtcaperiodic: I think maybe that's a little fancier than what I've done so far.
23:37Hodapphrmmm, mixing Clojure with a very-stateful-API is kind of weird
23:38aperiodicuvtc: are you putting it in a repo now? ;)
23:39uvtcYes, just need to fill in the README.md ... just a few moments.
23:39aperiodicexcellent!
23:46uvtcaperiodic: https://github.com/uvtc/colorize-irc-logs
23:47aperiodic(inc uvtc)
23:47lazybot⇒ 2
23:48uvtcOooh! I'm moving up in the world. :D
23:48aperiodicyup; at the conj, we'll all line up by lazybot karma before every meal
23:57Sgeo(karma sgeo)
23:58aperiodic$karma Sgea
23:58lazybotSgea has karma 0.
23:58aperiodic$karma Sgeo
23:58lazybotSgeo has karma 0.
23:58aperiodici can type