#clojure logs

2013-09-03

00:00xeqibenkay: either (partial < n) or #(< n %)
00:00benkay,(< 0 %) [1 2 3]
00:00clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: % in this context, compiling:(NO_SOURCE_PATH:0:0)>
00:00benkay,#(< 0 %) [1 2 3]
00:00clojurebot#<sandbox$eval57$fn__58 sandbox$eval57$fn__58@1e6a3b9>
00:00benkayi'll go play with that xeqi, thanks.
00:01xeqi,(every? #(< n %) [1 2 3])
00:01clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: n in this context, compiling:(NO_SOURCE_PATH:0:0)>
00:01benkay(in private, at the risk of making a bad joke)
00:01xeqi,(map #(< 2 %) [1 2 3])
00:01clojurebot(false false true)
00:01coventryxeqi: Right, that is what I meant. It's actually a (:require [clojure.tools.trace]) component of ns form which is failing, but (require 'clojure.tools.trace) is working at the repl. I think it's time for bed. Probably be clear in the morning...
00:04Ph_Dxeql: Lesson learned: typos kill. Finally found two letters switched in my database function. Bleh. Thanks for the help, anyway.
00:05xeqiPh_D: thats unfortunate
00:05xeqibut does that mean it works for you now?
00:10Ph_Dxeql: Yes! Everything's up and running. I did, however, have to use that strange nested mapping structure. Still unsure as to why.
00:25bjaAnyone else writing core.async stuff have a function or macro that takes a body/expression and returns a channel that is populated with the result of that body/expression?
00:26johnmn3just gotta say, if you use multiple desktops, for whatever reason, and you use chrome on them, the the CIRC extension IRC client is pretty awesome
00:27johnmn3I just opened it up in another computer and it has all my same settings.. didn't have to configure anything.
00:27johnmn3anyhow... anyone know if any good chat rooms to discuss digital audio theory?
00:30xeqibja: I believe `go` returns a channel with the result of the last expression of the body (if non-nil)
00:30benkayjohnmn3: been playing with Overtone?
00:30maacldnolen: Is there an obvious reason why I would get a rom ["src/cljs"]... WARNING: cljs.core.logic.macros/*occurs-check* not declared ^:dynamic when using run-nc. I amusing core.logic 0.8.4
00:31bjaxeqi: but why use easy-mode? also, thanks
00:31johnmn3benkay: no, but that might not be a bad idea... What I am trying to do is take an audio file and extract the entropy from it, for use as a source of randomness in encryption.
00:31johnmn3so that a user can use the microphone on their device for entropy.
00:32benkayuh, pardon me, but wat wat wat wat wat
00:32Raynesbenkay: http://31.media.tumblr.com/tumblr_lyp98aYfG21r6zvo6o1_400.png
00:33johnmn3but there are plenty of patches of non-randomness in an audio stream... so I am trying to think of a good algorithm to take out the non-randomness.
00:33benkayRaynes: http://blog.mkasprzyk.net/wp-content/uploads/2012/09/watman.jpg
00:33johnmn3perhaps a deflate...
00:34johnmn3lol
00:34Raynesbenkay: We find ourselves in a stalemate, sir.
00:34benkayjohnmn3: are you a crypto person to begin with?
00:34RaynesUntil next time!
00:34benkayo/ Raynes
00:34johnmn3benkay: uh, I understand the basics
00:35ddellacostasorry Ph_D, I got caught up in a meeting. But sounds like you have things worked out, so great!
00:35benkayi've always been gently dissuaded from doing crypto stuff by people i really respect
00:35johnmn3Not trying to reinvent the wheel here. I just need tons of randomness and the browser's random function ain't gonna cut it.
00:35benkayitb crypto? either this project is above my pay grade or above yours ;)
00:36benkayi kid, i kid
00:36benkaybut bad crypto kills
00:37benkayyou obviously are the only judge of how competent you are to write crypto stuff, but "the basics" does not make me comfortable.
00:38benkay(no intent to hurt your feelings or cast aspersions on your abilities)
00:38johnmn3well, random.org essentially does the same thing... using white noise from radio signals.
00:39benkaythere's a lot of hand waving in that word "essentially"
00:39johnmn3no offense taken... just trying to get an example implementation going first. then I can sort out the why-fors :)
00:39benkayjust out of curiosity, why not just pull random seeds from random.org?
00:40johnmn3because I need non-public random data :)
00:41callenjohnmn3: you realize microphones aren't good sources of entropy right?
00:41benkayi wash my hands of this
00:42johnmn3callen: no I did not realize that. Source?
00:42callenjohnmn3: learn to evaluate entropy sources, then test for yourself. Also account for the noise reduction performed in some cases.
00:43callenjohnmn3: you should just pull from urandom if you need entropy, you're not going to do better than kernel hackers.
00:43johnmn3browsers don't have uniform access to good sources like urandom
00:44johnmn3I intend on using this: http://www.fourmilab.ch/random/ to evaluate the randomness
00:45johnmn3one obvious approach is to truncate the bytes down to their least significant bits... where most of the noise is.
00:45johnmn3there are a few papers on it.. looking for them...
00:50Ph_DI've dug around some more in the Friend source code, but I'm wondering what the difference is between putting config params in the opposed to adding them in the 'authenticate' wrapper.
00:51coventryjohnmn3: There's this whole "don't do crypto in the browser" thing which may interest you. https://news.ycombinator.com/item?id=5787498
00:51Ph_Dddellacosta: No problem! Glad it's coming together.
00:52ddellacostaPh_D: what do you mean about putting config params in the "opposed?"
00:52ddellacostaPh_D: oh, I think you left out a word there
00:52callenddellacosta: accidentally a word?
00:52ddellacostacallen: smartass. ;-)
00:53Ph_Dddellacosta: Whoops. It's getting late. :p "in the" should be "as to"
00:53callenddellacosta: I acquired a futon and have a place now. it is a nice futon, found a very nice store in Japantown.
00:53Ph_DOr just "as". Ha, I need to call it a night soon.
00:53ddellacostaPh_D: "putting config params as opposed to adding them in the 'authenticate' wrapper?"
00:54ddellacostacallen: awesome! Is it the type you wanted? Forget what they're called. Something buton
00:54callenddellacosta: shikibuton, ie, the real thing, yes.
00:54ddellacostaPh_D: unfortunately, I still am not sure what you mean--what config params are you talking about?
00:54callenddellacosta: as opposed to the very poor foam filled things that are popular out here.
00:55Ph_Dddellacosta: Seriously can't words. I meant to say: "Putting config params in the workflows as opposed to adding them in the 'authenticate' wrapper"
00:55ddellacostacallen: ah, gotcha. Yeah, that's one of those Japanese words I just never bother to learn, as they just call them "futons" here…haha
00:55johnmn3coventry: yea, I know. This is just a proof of concept.. Eventually, I'd like to make it more secure by moving it to an offline extension, much like cryptocat.. and also smart-phone apps as well. But I think, for someone who is in a pinch, in an internet cafe somewhere, it might be useful to have a pure browser based version, no?
00:55callenddellacosta: the "shiki" part distinguishes the primary cotton-filled mattress part.
00:56benkaysomeone using an internet cafe box has already lost johnmn3
00:56ddellacostaPh_D: huh, didn't know you could put config vars in the authenticate wrappers, unless you are talking about roles
00:56benkaythey should be booting off of a usb drive at the very least
00:56benkayand even that's not great
00:56ddellacostaPh_D: but generally I've never done anything other than configure in workflow call when setting up routes.
00:57johnmn3benkay: depends on the circumstances
00:57ddellacostacallen: gotcha. Yeah, I have a western style bed so I don't think about it much...haha
00:57Ph_Dddellacosta: Ah, okay. I'm wondering if authenticate's config is treated as global.
00:57Ph_D"global"
01:00ddellacostaPh_D: oh, wait, you're talking about the authenticate call itself, which *is* where you configure stuff as far as I know. Sorry I misunderstood. Generally, you are not going to be editing workflow code itself. Does that answer your question?
01:02johnmn3benkay: I wonder if it'd be possible to... hmmm. to keep a javascript script on your thumb drive. When you go to the "zero knowledge" site, that purports to send safe javascript encryption libraries to the browser, it serves the page -- the user can then apply their js script to the page to get a sha256 of the full dump of the page. Then that hash is compared against a known good hash stored on the thumb drive. Is this method feas
01:02ddellacostaPh_D: authenticate just wraps up a ring handler, so it's global in the sense that, if it wraps up your top-level (bottom-level?) handler then everything is filtered through it.
01:04Ph_Dddellacosta: No worries! Yes, that's what I needed to know.
01:05ddellacostaPh_D: excellent. :-)
01:05benkayjohnmn3: why not VMs in the browser?
01:05johnmn3benkay: I suppose that's silly... if you have scripts on the thumb drive, you don't need to download scripts from the server... just use the app offline, except for the encrypted data sent over the wire to the server.
01:05benkayman i am going to bow out of this conversation again
01:06benkayif you think that this is a good idea and are willing to take responsibility for the lives that may come to depend on your imperfect crypto, go right ahead
01:06benkaybecause humans are dumb and take dependencies on dumb things
01:07benkayi am clearly not going to convince you of the folly of implementing your own in-the-browser crypto library
01:07benkayand am going to bow out
01:07benkayand write code.
01:08callenjohnmn3: you could end up endangering somebody.
01:08callenI don't really know how else to impress that upon you.
01:08technomancyoperations on large primes in a runtime without integers, huh? what could go wrong?
01:08benkayi don't know shit from shinola from sugar but i know not to roll my own crypto
01:09johnmn3I'm not rolling crypto
01:09johnmn3I'm just using one time pads and I need random data
01:09callen"just"
01:09brehauttechnomancy: you can enforce integers with weird unary operations
01:09johnmn3what just? it's a bitxor
01:10brehauttechnomancy: still a terrible idea
01:10callentechnomancy: in a runtime without reliable/verified access to urandom.
01:10callenbrehaut: relying on the good graces of the implementation at that point aren't you? Numbers are defined as IEEE 754 in the spec AFAIK.
01:11johnmn3well, I'm not doing any prime number crypto anyway
01:12brehautcallen: i understand that while thats 90% the case, theres some weird craziness on the edges
01:12brehautcallen: specifically regarding certain operations
01:13callenbrehaut: sigh. what a ghetto.
01:13callenAt least thinking JS is well designed is a good sniff test for programmer competence.
01:13callenwithout that, I'd just have to ask if they thought void*'ing all their "object oriented" code in C was a good idea.
01:13brehautcallen: indeed :/
01:14brehautcallen: reminds me, ive never understood why JS has a 'void' operator
01:14callenbrehaut: safe access to undefined value is the...practical reason.
01:15brehautcallen: then why is it a unary operator :P
01:15brehaut(rather than just a constant)
01:16callenbrehaut: so you can pass in arbitrary expressions.
01:16callenbrehaut: the original purpose was to enable bookmarklets.
01:16brehautah bookmarklets
01:16callenyeah. real elegant.
01:17futileGood morning.
01:17callenfutile: hi
01:17futilecallen: What are you up to?
01:18seabreOh JavaScript
01:18seabreThis is my favorite JS engine related bug: http://stackoverflow.com/questions/11833319/ie-error-2147024882/11909547#11909547
01:19callenfutile: scratching an itch.
01:19futilecallen: oh cool me too, what's yours?
01:19callenseabre: wow.
01:19callenfutile: wiki
01:19futilecallen: writing a wiki engine?
01:19callenfutile: ya
01:19futilein Clojure?
01:19callenI already have a CMS'ish.
01:19callenfutile: ya
01:19futilecallen: open source?
01:20callenit will be once I push.
01:20jack_rabbitMore code should be written in lisp.
01:20jack_rabbit:)
01:20futileseabre: wow
01:21futilejack_rabbit: ew no
01:21futilecallen: what's the niche?
01:21jack_rabbitfutile, eww what? You're on the clojure channel.
01:21futilejack_rabbit: oh. I guess I don't think Clojure when I hear "lisp"
01:21callenfutile: programming language knowledge accumulation and sourcing.
01:21futilecallen: ooh, *that* wiki
01:21jack_rabbitfutile, lol. Clojure is absolutely lisp.
01:21futilecallen: where will you host it?
01:21futilecallen: and what domain name do you have planned for it?
01:22futilejack_rabbit: yes but when people say "lisp" they usually mean another dialect
01:22futilejack_rabbit: (even in here)
01:22benkaycallen: will you share the cms?
01:22jack_rabbitI suppose.
01:22jack_rabbitfutile, I wish to rectify that error.
01:22callenbenkay: CMS is already on my github, the wiki is the new part.
01:22futilejack_rabbit: and besides the parentheses, I think Clojure has little in common with Scheme and CL
01:22jack_rabbitfutile, scheme is a lisp.
01:23callenjack_rabbit: it's not though.
01:23futilejack_rabbit: I stand by what I said.
01:23benkaycallen: whatchoo github?
01:23callenthe CMS is very micro though.
01:23jack_rabbitcallen, it is, though.
01:23callenbenkay: github.com/bitemyapp
01:23callenjack_rabbit: it's an offshoot.
01:23callenneed full macros to be a lisp.
01:23shaungilchristbah this is uppercase lowercase anarchism all over again
01:23benkaycallen: o right >.<
01:23futiletoo many definitions of "lisp"
01:23shaungilchristthere is lisp and there is LISP
01:23jack_rabbitcallen, I think that's an arbitrary distinction.
01:23futilemah head asplode
01:24futileshaungilchrist: oh come on
01:24jack_rabbitcallen, Also, I think clojure benefits from being considered a lisp.
01:24callenjack_rabbit: Clojure is a Lisp. Schemes are not.
01:24shaungilchristhahah what!?
01:24futilenow you're all just trolling
01:24jack_rabbitcallen, well I'd argue that, but that's a whole other argument.
01:24shaungilchristok I have to walk away from this one
01:24futilenone of these definitions are shared
01:24futile:D
01:24callenshaungilchrist: I've succeeded.
01:24TEttingerno no no
01:24TEttingerlisp is a speech impediment
01:25futiletrololololololololololo.com
01:25shaungilchristit's when all of your word are surrounded by parens
01:25callendidn't fogus make a lithp?
01:25jack_rabbitshaungilchrist, I think you're simplifying things just a bit.
01:25futileI think Clojure shares little in common with any other lisp. I still don't think of it as a lisp.
01:26jack_rabbitfutile, that's a shame.
01:26futileI barely create any macros of my own or use recursion, which are probably the two mainly spouted features of lisps.
01:26jack_rabbitfutile, because it derives much of it's being from existing lisps.
01:26brehautcallen: http://ecma-international.org/ecma-262/5.1/#sec-9.5 prepare to be sad
01:26futilejack_rabbit: derivation has little to do with actuation
01:26TEttingeryeah, clojure is a different kind of lisp, I would say, but still a lisp. there's that LISP-1 categorization, right?
01:26brehautcallen: you cant call ToInt32 directly, so you (n)|0
01:27benkaycallen: demonico?
01:27callenbrehaut: I know this because it's how that asm.js is implemented.
01:27futileTEttinger: true but Ruby is also a LISP-1
01:27brehautcallen: right. its using this horrible soup hidden in the spec
01:27jack_rabbitfutile, Well that's valid, but I'd say it's a poor argument.
01:27callenbrehaut: the "compiler" output of asm.js is literally nothing but integers because that's how it encodes the machine.
01:28jack_rabbitfutile, Either way, I wasn't attempting to argue.
01:28futile:)
01:28brehautcallen: yes
01:28callenbrehaut: I love that the ToInt32 function doesn't obey intent, that's nice.
01:28callenbenkay: demonico?
01:28brehautcallen: you had higher hopes for its definition than me
01:28jack_rabbitfutile, I was just trying to express that the things that Clojure and other lisps share are valuable and under-used.
01:28futileI've been drinking the same sugar free red bull for about 6 hours now, and finally finished it just before midnight (a few minutes ago).
01:28jack_rabbitfutile, And I wish more code were written in some lisp dialect.
01:28futileSo now I have to work on my crazy project all night.
01:29callenbrehaut: were I weaker man, JS would pierce my zen.
01:29callenI a*
01:29futilejack_rabbit: well I can't agree
01:29jack_rabbitfutile, why not?
01:29callenbenkay: what's demonico?
01:30benkaycallen: a mistake of a portmanteu
01:30benkaycallen: late night brainfog is setting in: what's the name of your clojure CMS?
01:30callenbenkay: Neubite
01:30jack_rabbitfutile, Just curious. Again, not trying to create an argument.
01:31benkaycallen: thanks.
01:31callenbenkay: it could be made fully general if one changed the landing page to a flatpage.
01:31callenit's very micro and minimal, doesn't do much.
01:31callenalso the persistence layer is trashed. the wiki is fixing that too.
01:31callentrash*
01:31futilejack_rabbit: well I don't think Scheme or Common Lisp are very good languages, and I think the lisp features they have don't help but actually cause more harm
01:31callentrash in this case means, "MongoDB"
01:31callenMongoDB == I don't care about my data.
01:32futilecallen: gonna use Datomic?
01:32callenfutile: I abuse the aspects of Lispy-ness that Clojure shares with those languages all the time.
01:32callenfutile: of course @ Datomic.
01:32callena wiki is historical. Datomic fits like a glove.
01:32callenI'm even going to do the diffing as a stored function in Datomic :P
01:33futilecallen: woo, that sounds fun
01:33jack_rabbitfutile, I see. That's clearly a matter of opinion, and I won't argue that. But as for the actual syntax that Clojure and other lisps share, don't you find value in that?
01:33benkaycallen: a client is open to reorganizing their stack (in parts and in toto) and i want to put clojure everywhere it makes sense. a cms would be awesome, but they're already happy with what they have so...*shrug*
01:33futilejack_rabbit: I like Clojure's syntax but I'm not a fan of CL's or Scheme's.
01:34futilejack_rabbit: I think Racket's syntax might be okay, since it's closest to Clojure.
01:34jack_rabbitfutile, but their syntax is very similar compared to those of many other languages. That's why they are lisps.
01:34futileThen again I've not seen or written very much CL so maybe it can emulate Clojure better than I know with custom readers.
01:34jack_rabbitfutile, CL can do pretty much anything, but that's beside the point.
01:35callenbenkay: well, I tend to do PRs/projects/ideas in response to materialized interest in things and needs.
01:35futilejack_rabbit: the parentheses are only half the battle. Then there's differentiation of sections, and using [] for param-lists and let-forms is super useful.
01:35callenbenkay: so if you've got an itch, discuss it in here.
01:35jack_rabbitfutile, you can do that easily in CL, and that's an implementation detail. As far as I'm concerned, the "parentheses" are the important detail.
01:36futilejack_rabbit: I rescind all my statements and opinions
01:36futileI've just remembered that they're vastly uninformed.
01:36jack_rabbitfutile, I'm sorry. I'm not trying to invalidate your opinions.
01:36futilejack_rabbit: you're not
01:36futileopinions are meant to be changed
01:36futileespecially as you get more information and more experience
01:36jack_rabbitCool!
01:37futilebut im not saying i agree with you yet
01:37jack_rabbitThat's fine.
01:37futileanyway, going to start parsing clojure now
01:38jack_rabbitfutile, have fun! I hope you take the time to learn some other lisps someday. They do have value, even if they're out of date.
01:38futileive spent a few weeks trying to learn scheme and a few days reading Practical Common Lisp
01:39futileand so far i cant see any benefit they have over Clojure.
01:39futilebut i found a lot of downsides
01:39brehautfast, native executables
01:39brehautfast particularly in the sense of start up time
01:39futileim not sure that's an upside anymore
01:40jack_rabbitfutile, I can agree with that, but there's also a lot of good in CL that Clojure doesn't have.
01:40callen"good"
01:40jack_rabbitcallen, I suppose that's an opinion as well.
01:40futilebrehaut: and im sure in the next 10 years there will be a better solution for that in plain Clojure
01:40futilejack_rabbit: CLOS?
01:41jack_rabbitfutile, I do like CLOS, but Clojure's relation to Java seems like a fine object implementation.
01:41brehautfutile: i'm not holding my breath. its been a problem with JVM languages for 15+ years, and clojure does a lot more at startup than most JVM languages
01:41futilejack_rabbit: I'd say there's [unnecessary and complex feature] in [other language] that Clojure doesn't have, and that's actually the point
01:42jack_rabbitfutile, that seems like a generalization to me. And generalizations seem to me to be a bad thing when instead of preventing you from avoiding bad things they prevent you from learning things.
01:42futilebrehaut: I could see ClojureScript getting a whole lot mature in the next 5 years, a new JS environment that competes with JVM, and a really nice system to tie them altogether seamlessly
01:42futile*lot more
01:42futilebrehaut: (and threading)
01:44jack_rabbitfutile, I'm certainly not suggesting that CL should be used instead of Clojure, or that one is a better language than another. I'm saying that the things they have in common are valuable, and I wish they were better taught and more used.
01:44futilejack_rabbit: I'm mainly thinking of things like Ruby's object system or CLOS or Haskell's super-strict type system or Go's type system
01:44jack_rabbitfutile, How about CL's error handling system?
01:44futileit's probably wonderful
01:44jack_rabbitfutile, rather its condition system.
01:44jack_rabbitfutile, it is. And it's worth learning IMO. Still this is tangential to my initial statement.
01:45callenI missed CL conditions until I started using robert.hooke and dire.
01:45callenthen I just...stopped caring.
01:45futilecallen: hooke looks like something that if I ever start using it, it would be a sign that I'm already doing terribly terribly wrong
01:46futilejust like monkey-patching in Ruby
01:46callenfutile: I reserve my greatest evils for libraries, if that comforts you at all.
01:46futilecallen: not one bit
01:46callenwell. die.
01:46futileeventually
01:46TEttingeroh, and on the VMs for functional languages front: F# now runs on LLVM
01:46callenTEttinger: still don't care to use ML-Windows.
01:46jack_rabbitI feel I've started a war.
01:47futilecallen: hooke looks like it would let me do this kind of thing in Clojure: https://github.com/sdegutis/zephyros/blob/master/libs/zephyros.rb#L195-L209
01:47TEttingercallen, oh yeah, I prefer Clojure too
01:47futileand I hate those lines of code very much
01:47callenTEttinger: I mean that I'd rather use OCaml.
01:47jack_rabbitcallen, lol
01:47futile... granted they've actually saved me a little work over the past few weeks
01:48TEttingerbut clojure would probably improve a bit on startup performance if it ran on LLVM, though that is a guess since AFAIK no one has tried yet. also it would be easier to call C and C++ libs
01:48futileAny alternatives to "ns-tracker"?
01:49seabreI could never get F# running in Linux, so I really never checked it out.
01:49futileTEttinger: yeah but what would that mean for GC?
01:49TEttingerfutile, LLVM has a GC, it's optional and controllable
01:49futileTEttinger: when something gives me I shouldn't free, how does the GC know not to free it, etc?
01:49futileTEttinger: but it would have to know all about the C libs I'm using and their memory rules
01:49seabreWith mono, which was/is supposedly able to run it.
01:50futileTEttinger: or I'd have to specify it my programs
01:50callenTEttinger: I would <3 a Clojure LLVM but a non-hosted Clojure would be a little...odd.
01:50TEttingeryeah C/++ stuff would probably need to be deallocated. it's a whole issue that java doesn't have
01:50futileAlso ns-tracker is taking up 100% cpu :(
01:51TEttingerseabre, oh yeah. F# used to be really hard to run on linux. mono 2.8 actually couldn't run it
01:51TEttingerand they claimed it had better support for F#...
01:52TEttingerI'd suggest making a newer better JVM, but if it got successful oracle would just sue whoever tried it into oblivion.
01:54futilecallen: I would imagine it would have C extensions just like Ruby.
01:55futileWhat the heck? Upgraded 'magit' the other day, and now it spins up another emacs process just to commit.
01:57benkaynot to digress, but how would i compare all of the elements in vector a to all of the elements of vector b?
01:57futilebenkay: =
01:57futile,(= [1 2 3] [1 2 3])
01:57clojurebottrue
01:57futilebenkay: or, what do you mean by "compare"?
01:57benkaynope, that's vector a to vector b ;)
01:58futile,(= [1 2 3] (conj [] 1 2 3))
01:58clojurebottrue
01:58futilebenkay: vector comparisons just compare each element
01:59benkayi'm searching for permutation comparisons
01:59TEttingerah, there we go. Clojure on LuaJIT (JIT specifically because they have added a bunch of interop features that make it really easy to call C). it's also a very good JIT compiler for a GC'ed dynamically-typed language. probably a lot of work on CLJS would apply too.
01:59futilebenkay: maybe http://clojuredocs.org/clojure_core/clojure.data/diff
01:59benkay(fn [1 2 3] [5 2 9]) either returning a comparison for each ([1 5] [1 2] [1 9])
02:00benkayor just returning t/f if all comparisons pass or something
02:00TEttinger,(for [a [1 2 3] b [1 1 1]] (= a b))
02:00clojurebot(true true true false false ...)
02:00benkay,(doc for)
02:00clojurebot"([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], ...
02:00benkaythanks TEttinger
02:01benkayyeah. perfect.
02:01benkaythanks again!
02:01TEttingerbenkay, np
02:01TEttingerfor is exceedingly useful, there's also doseq for the similar case where you don't want a sequence, and just want to, say, print something for each iteration
02:02fkeyIs there a built-in function like map, except that it doesn't keep track of results?
02:02TEttingerI think that's also doseq
02:02mihneadbI find myself using doseq pretty often for "real world" stuff, and it feels like writing imperative code
02:02mihneadb:(
02:03TEttinger##(doseq [a (range 1 10)] (println a "!!!"))
02:03lazybot⇒ 1 !!! 2 !!! 3 !!! 4 !!! 5 !!! 6 !!! 7 !!! 8 !!! 9 !!! nil
02:03fkeyoh, looks like my question got answered before asking haha
02:04fkeythanks
02:04TEttingernp fkey
02:04TEttingerthis really makes me realize how full-featured clojure's standard lib is
02:04seabreYou could do something like doseq with loop and recur
02:04seabrebut you're probably better off not.
02:05mihneadbof course, since it's already there :)
02:05mihneadbI actually did, before finding out about doseq
02:05mihneadbbut really doseq is for .. in
02:06TEttingerI need to get back to hiphip, the author wanted a pull request if I could solve the complicated macro macro thing
02:06rurumate_Can I use a clojure library, like math.combinatorics, in clojurescript? I get an error message "ReferenceError: combinatorics is not defined" in the running javascript..
02:07ddellacostabenkay, or use clojure.set
02:07ddellacostarurumate_: but it compiles?
02:08TEttingerrurumate_, that sounds like a dependency thing. it's weird if it's runtime though
02:08ddellacostaI guess that's a dumb question. But, more dumb questions: you are including the name space in your code?
02:08rurumate_ddellacosta: yes, but I have the code that uses the the combinatorics in a "shared" (.clj) file
02:08benkayi gather that let is not a recursion target?
02:08benkayis that correct?
02:09rurumate_nvm I'll make a refheap
02:10seabrebenkay: As far as I know it shouldn't be, why?
02:10TEttingerbenkay, fairly certain, yeah
02:10TEttingerI think I've used loops with let inside
02:12benkaythanks all. i'm asking questions that experimenting at the REPL could answer. time to stop coding and switch to reading :)
02:12rurumate_here's the two files: (first the .clj, then the .cljs that refers to it): https://www.refheap.com/18251
02:13seabreDoes recur even target anything other than loop?
02:14RaynesA function definition.
02:14TEttingerseabre, yes, I believe function dammit Raynes
02:14rurumate_btw this project will play wuerfel bohnanza if it goes well, see http://boardgamegeek.com/image/1210283/wurfel-bohnanza
02:15TEttingerrurumate_, excellent, I made a dice roller for Star Wars Edge of The Empire, rather than pay $5 for an android app to roll dice and do less than what my clojure app did
02:15seabreAh. I've only ever used recur with loop.
02:15rurumate_ok nice, was it in clojure or clojurescript?
02:16TEttingerrurumate_, clojure
02:16TEttinger##(reduce * (repeat 7 6))
02:16lazybot⇒ 279936
02:16rurumate_that's because you throw 7 6-sided dies..
02:17futileWhat's a good way to enumerate a UTF8-encoded string 1 char at a time, being able to peek ahead 1 char too?
02:18TEttingermap-indexed, futile?
02:18TEttingeralthough that will just use whatever string encoding clojure uses
02:20rurumate_so basically I want to call (shared/check-odds :red :red :red :green :green :orange) from the clojurescript and stick the result in the dom tree. But alas it crash!
02:20TEttingerrurumate_, if you want to know... the most effective my die roller got for more than like 4 dice was either by just treating a die as a fractional result of the symbol on the face (like the 12-sided die had one Triumph symbol, so it was worth 1 Triumph, but like 6 Advantage, and summing penalty dice and bonus dice gave the approximate average.).
02:21TEttingerthe least effective was rolling 10,000 dice
02:21TEttingerand finding the average
02:21rurumate_TEttinger: ok, but I'm thinking of listing all possible combinations for a given rule, and printing then color-coded..
02:22TEttingeroh ok
02:22rurumate_just because you can, in the browser!
02:22TEttingerso you aren't calculating worth, you need a lot of things to print out
02:25futileDoes (for) use codePointAt or charAt when given a string?
02:26TEttingerfutile, it should just give you chars. hang on let me find some contrived example
02:26futile,(for [a "hello™ n o"] a)
02:26clojurebot(\h \e \l \l \o ...)
02:27futile,(for [a "™test"] a)
02:27clojurebot(\? \t \e \s \t)
02:29TEttinger##(for [c "Molla ዶ/ር™tኣበ"] c)
02:29lazybot⇒ (\M \o \l \l \a \space \ዶ \/ \ር \™ \t \ኣ \በ)
02:29TEttingeryeah, it doesn't seen to preserve the weird change codepage characters
02:30TEttinger##(for [c "Molla ዶ/ር™tኣ הֲקוֹדֶበ"] c) ; let's try with RTL...
02:30lazybot⇒ (\M \o \l \l \a \space \ዶ \/ \ር \™ \t \ኣ \space \ה \ֲ \ק \ו \ֹ \ד \ֶ \በ)
02:30TEttingercombining diacritics are their own characters
02:41rurumateok, so when I do try to import math.combinatorics directly in the clsj, I get a compile time error that goog.require can't find that. Where can I see which libs are available cljs?
02:42rurumateI mean is there something analogous to clojars, for clojurescript?
02:44ddellacostarurumate: it is clojars. Is the lib in your project.clj? As a test, I just added it and put the namespace in a cljs file in my project, and it compiled fine
02:44ddellacostarurumate: let me actually try to run some code
02:45ddellacostarurumate: oh, no, you're right--get a runtime error.
02:45rurumateddellacosta: the project.clj has this line in dependencies: [org.clojure/math.combinatorics "0.0.4"]
02:45ddellacostarurumate: possible that it's not compatible w/clojurescript. let me take a look
02:47ddellacostarurumate: nothing in the source suggests it should be cljs specific, but there is no cljs version. As a test, you could try simply putting the file () in your directory, changing it to .cljs and seeing if that does it for you
02:48ddellacostadoh, meant to link to: https://github.com/clojure/math.combinatorics/blob/master/src/main/clojure/clojure/math/combinatorics.clj
02:48ddellacostalooks pretty much non-platform specific.
02:48rurumatehmm
02:49futileOh man I forgot that writing a parser is kinda hard.
02:49ddellacostaprobably just add a crossover section for the project and it would be done…without knowing
02:49ddellacosta(http://yogthos.net/blog/45)
02:50rurumateddellacosta: thanks. I'm off to my daytime job now, will try tonight
02:50ddellacostarurumate: good luck! have a good day. ;-)
02:52babu`In core clojure is there a way to check if a variable is unbound?
02:52futilebabu`: bound?
02:53futile,bound?
02:53clojurebot#<core$bound_QMARK_ clojure.core$bound_QMARK_@17281c0>
02:55babu`I am getting "ClassCastException clojure.lang.Var$Unbound cannot be cast to clojure.lang.Var"
02:56amalloybabu`: you want the var itself, not its current value. (bound? #'whatever)
02:56futileyeah that
02:56babu`ok thanks. bound? is a function that evaluates its args, right
02:57futilebabu`: yes, but it takes a var
02:57futilebabu`: compare these:
02:57futile,+
02:57clojurebot#<core$_PLUS_ clojure.core$_PLUS_@1007a>
02:57futile,#+
02:57clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
02:57futile,#'+
02:57clojurebot#'clojure.core/+
02:57futile,[(type +) (type #'+)]
02:57clojurebot[clojure.core$_PLUS_ clojure.lang.Var]
02:58babu`Thanks. I knew it was futile to ask a question like this!
02:58futile:P
02:58futilebabu`: it's hardly futile, you're learning aren't you?
02:58futile;)
02:59futileHow would you guys go about writing a recursive descent parser without using mutable state?
02:59babu`yes, but I could have looked it up.
03:00futileheh
03:00babu`Why is there a get-possibly-unbound-var in clojure.test?
03:07futilebabu`: they probably needed it
03:08futileAha, this is a neat alternative to read() and peek()
03:08futilehttps://www.refheap.com/18252
03:08babu`futile: how is it different from bound?
03:08futilebabu`: i dunno
03:09babu`(defn get-possibly-unbound-var
03:09babu` "Like var-get but returns nil if the var is unbound."
03:09babu` {:added "1.1"}
03:09babu` [v]
03:09babu` (try (var-get v)
03:09babu` (catch IllegalStateException e
03:09babu` nil)))
03:09futilewhoa
03:09futilebabu`: so basically it's like var-get but returns nil if the var is unbound
03:10babu`Written by none other than Hickey so there must be a reason
03:10babu`Isn't it expensive to trigger an exception and catch it?
03:11opqdonutI think on the jvm it's relatively fast
03:11babu`why can't you use the value of bound? and return null?
03:11opqdonutmaybe you should run a quick benchmark, (var-get bound-var) vs (get-possibly-unbound-var bound-var) vs (get-possibly-unbound-var unbound-var)
03:15amalloyfutile: functional parsers generally involve passing around the "remainder", ie what is left to parse
03:15futileamalloy: hmm interesting
03:16futileamalloy: I think the passing around the structure I'm currently building up and mutating it would be the harder thing
03:16amalloywell don't mutate it, silly
03:16futileamalloy: the only solution I can think of is some really ugly (possibly mutually) recursive functions with ugly param lists
03:16amalloythere is a lot of literature about doing it in haskell; google for "X parser combinators" and you'll learn some exciting stuff about parsers in language X
03:16futilecool, thanks
03:19dissipate_amalloy, which language is better for parsing, haskell or clojure?
03:19futileIs there a short-hand for (juxt first rest)?
03:19futile,((juxt first rest) [1 2 3])
03:19clojurebot[1 (2 3)]
03:22amalloysubjective and unanswerable, dissipate_
03:24dissipate_amalloy, :(
03:42futileI think I would never use peek.
03:42futile,(doc peek)
03:42clojurebot"([coll]); For a list or queue, same as first, for a vector, same as, but much more efficient than, last. If the collection is empty, returns nil."
03:48hyPiRionI think I would never use when-first
03:48dissipate_i want to create a searchable data structure that has functions that i can do a phrase based search on at run time. then, i want to try to call the function on some arguments, if that fails it tries the second hit in the search and so on, until one of the functions returned from the search is called with the arguments without failing.
03:48futile,(doc when-first)
03:48clojurebot"([bindings & body]); bindings => x xs Roughly the same as (when (seq xs) (let [x (first xs)] body)) but xs is evaluated only once"
03:49futilewat
03:49dissipate_my goal here is to be able to call functions that i can't remember the exact name. the ultimate in lazy programming.
03:53ordnungswidrigdissipate_: how is "fail" defined? throwing an exception?
03:53dissipate_ordnungswidrig, correct
03:53futileWow, 2005 was so long ago.
03:54dissipate_ordnungswidrig, i don't care about IDE searches for function names either. that takes too long IMO. i just want to type in a search phrase and some arguments.
03:55dissipate_that search phrase might match keywords in a function's comments/documentation
03:59dissipate_ordnungswidrig, imagine how fast you could code if you didn't even have to remember function names. just put a search phrase in quotes with some arguments, e.g. ["finds nth fibonacci number" 10]
03:59ordnungswidrigdissipate_: fast like going full speed in the city?
04:00dissipate_ordnungswidrig, yep
04:00ordnungswidrigdissipate_: that's rather not what I do
04:00dissipate_ordnungswidrig, you don't like this idea?
04:01ordnungswidrigdissipate_: no, but here for you problem of application until no error:
04:01ordnungswidrig(some #(try (apply % ["1.0"]) (catch Exception e nil)) [#(Integer/parseInt %) #(Double/parseDouble %)])
04:02dissipate_ordnungswidrig, thanks
04:03dissipate_ordnungswidrig, and how about indexing all of the functions (including comments) for search?
04:04ordnungswidrigdissipate_: have a look at clojure.repl/doc
04:05dissipate_ordnungswidrig, why is my idea bad?
04:05ordnungswidrigdissipate_: what's your goal?
04:06dissipate_ordnungswidrig, extreme rapid prototyping. i don't want to take the time to look up function names, i just want to whip out a search phrase and have the function looked up during run time.
04:06ordnungswidrigdissipate_: why not using the search in the repl to lookup the function?
04:08dissipate_ordnungswidrig, takes too much time. i have to stop to search the repl. i just want to type a phrase fast and have it figure out what to do at run time.
04:08ordnungswidrigdissipate_: I prefer to think before i code.
04:08ordnungswidrigordnungswidrig: you can also enhance your ide with a full text search for functions
04:09ordnungswidrigdissipate_: that would be a nice thing, imho.
04:09dissipate_ordnungswidrig, what do you think of the code: ["finds nth fibonacci number" 10]
04:09ordnungswidrigdissipate_: is't a vector
04:09ordnungswidrigdissipate_: and I'd prefer (fib 10)
04:10dissipate_ordnungswidrig, but do you see? i don't have to remember the name of the function that calculates fibonacci numbers.
04:10ordnungswidrigdissipate_: I might be an interesting experiment, though. go on and try :)
04:10kawIt's hard for a text search to get nuances, e.g. distinguish between something like "returns a sequence of fibonacci numbers starting with the nth fibonacci number" and "finds the nth fibonacci number"
04:10TEttingerdissipate_, there's a looku[ thing in lazybot or clojurebot
04:10TEttingerlookup*
04:11ordnungswidrigkaw: typed clojure will help, like hoogle is amazon for haskell
04:11dissipate_kaw, how about 'calculates nth fibonacci number'
04:12ordnungswidrigkaw: not amazon, amazing :-) But it's also a little bit like amazon
04:12TEttinger&findfn 1 2
04:12lazybotjava.lang.RuntimeException: Unable to resolve symbol: findfn in this context
04:13ordnungswidrig& clojuredocs fibonacci
04:13lazybotjava.lang.RuntimeException: Unable to resolve symbol: clojuredocs in this context
04:14ordnungswidrig$clojuredocs fibonacci
04:14lazybotNo results found.
04:14TEttinger$findfn [0 1 1 2 3]
04:14kawWell, if you have to get the wording (like "returns" vs "calculates" vs "finds") right in the text search, you're back to square one, aren't you?
04:14lazybot[]
04:14TEttingerfib isn't usually a lib function
04:14kawNow you just have to remember a phrase that's much longer than "fib", and you can choose between a few different phrases to remember
04:14ordnungswidrigkaw: he wanted to try one match after the other
04:14TEttingerbut
04:15kawHmm, okay
04:15TEttinger$findfn [0 1 1 2 3] [1 2 2 3 4]
04:15lazybot[]
04:15kawStill not convinced of its usefulness, but interesting as an experiment I guess
04:15TEttingerhm, it can't find combinations
04:15kawAgreed that types would help a lot
04:16TEttinger$findfn [0 1 1 2 3] "01123"
04:16lazybot[clojure.string/join]
04:16TEttingera ha!
04:16dissipate_kaw, what if you saw an application that had search phrases instead of function names?
04:17TEttingerdissipate_, no clue what to do
04:17kawI think I would probably be confused? Now there are several ways to refer to one function
04:17TEttingerand search isn't always approaching accurate
04:17ordnungswidrigdissipate_: how would this look like with search terms? https://gist.github.com/swannodette/3217582
04:18TEttingerlike a slight wording difference yields a slightly different function -- inc or unchecked-inc ?
04:19TEttingerhere, these all do the same thing for 1, but will react in different ways on BigIntegers
04:19TEttinger$findfn 1 2
04:19dissipate_ordnungswidrig, would look good imo
04:19ddellacostawhat is ".." in clojurescript? is it like "doto" ?
04:19lazybot[clojure.core/unchecked-inc-int clojure.core/unchecked-inc clojure.core/inc clojure.core/inc']
04:19TEttingera search for "add 1" could be any of those
04:20TEttinger$findfn 111111111111111111111111 111111111111111111111112
04:20lazybot[clojure.core/unchecked-inc clojure.core/inc clojure.core/inc']
04:20TEttingerI guess inc works, but (partial + 1) wouldn
04:20TEttinger't
04:22dissipate_TEttinger, no, the search phrase would be: "increment an integer value by 1"
04:24kaw$findfn 9223372036854775807 9223372036854775808
04:24ambrosebsnew blog post on annotating polymorphic types in core.typed http://t.co/50FFbZM1IN
04:24lazybot[clojure.core/inc']
04:26kawThat's a cool function, is $findfn available in the REPL or just a lazybot thing? Also what functions does it search?
04:26ddellacostaambrosebs: very cool, thanks
04:26ddellacostaambrosebs: been meaning to dig into core.typed for some time now.
04:26ambrosebsddellacosta: cheers
04:29bjais (map inc (range)) the way to get an infinite range starting from 1?
04:30ordnungswidrigbja: (rest (range))
04:31ambrosebs,(range 1)
04:31clojurebot(0)
04:31ordnungswidrig,(take 5 (rest range))
04:31clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$range>
04:31ordnungswidrig,(take 5 (rest (range)))
04:31clojurebot(1 2 3 4 5)
04:31ambrosebs,(doc range)
04:31clojurebot"([] [end] [start end] [start end step]); Returns a lazy seq of nums from start (inclusive) to end (exclusive), by step, where start defaults to 0, step to 1, and end to infinity."
04:31ordnungswidrigbja: map inc would work but you'd invoke inc for every element of the seq
04:33bjaordnungswidrig: in this case I don't think the N is large enough to matter, but (rest (range)) is both shorter and less intensive
04:33bjathanks
04:34ambrosebs,(take 5 (range 1 Long/MAX_VALUE))
04:34clojurebot(1 2 3 4 5)
04:34ambrosebsbja: I personally like that better ^
04:35ordnungswidrigambrosebs: that's more explicit
04:35ambrosebsI like explicit :)
04:36TEttingerkaw, let me find the source
04:36ordnungswidrigambrosebs: Me too, was not meant as a negative point :) But it's long to type
04:36TEttingerhttps://github.com/flatland/lazybot/blob/master/src/lazybot/plugins/clojure.clj#L214
04:37ambrosebsordnungswidrig: usually the tradeoff of explicitness I guess :)
04:37ordnungswidrigambrosebs: but Long/MAX_VALUE is very unsexy, too. "max-long" would be nicer
04:38bjafwiw, I defn'd it to range1
04:38bjaso (range1) should be reasonably explicit in my codebase
04:38ambrosebsbja: (range-start 1) might be a useful utility to have.
04:39ordnungswidrigor range>
04:40ordnungswidrigbtw range defaults to Double/POSITIVE_INFINITY
04:40ambrosebsah yes, that's what I meant.
04:42ordnungswidrigambrosebs: I just read about heterogeneous map and vectors. I wonder I one can use the core.typed annotations for web request validation
04:43ambrosebsordnungswidrig: yep. I've yet to find good specs describing compojure or ring web requests.
04:44ordnungswidrigambrosebs: the type of a handler is map -> map
04:45ordnungswidrigambrosebs: how do I declare a homogeneous map?
04:46ambrosebsordnungswidrig: (IPersistentMap k v) or (clojure.core.typed/Map k v)
04:46ambrosebsordnungswidrig: use :import/:require/alias as usual to bring into scope.
04:48ordnungswidrigambrosebs: it's hard to annotate because every ring middleware typically ads it's on stuff to the request map
04:49ordnungswidrigambrosebs: I think AWizzArd works on this.
04:49ambrosebsordnungswidrig: interesting. AWizzArd was talking to me before about ring.
04:50ordnungswidrigambrosebs: what I am interested in, is to do runtime validation with proper error reporting.
04:50ambrosebsordnungswidrig: core.typed supports that to some degree. It understands assertions.
04:50ordnungswidrigambrosebs: so I defined a "type system" for the request parameters. I need this for string -> x conversion
04:51ordnungswidrigambrosebs: and for validation. No I see that it is shaped somewhat like the core.typed system :)
04:51ambrosebscool!
04:52bjaugh
04:52ordnungswidrigambrosebs: but the error reporting from cf is not quite sufficient, IMHO (not tried, though)
04:53bjacongrats to myself for just futzing around with range>= so I could rewrite map-indexed
04:53ordnungswidrigbja: *g*
04:53clgvbja: ;)
04:53clgvbja: you learned something, didnt you? ;)
04:53ordnungswidrigbja: always tell us the complete story.
04:54ambrosebsordnungswidrig: ah, no, core.typed can tell you if your assertions are sufficient to never have a type error.
04:54TEttingerbja, I think many people here have done that once
04:54ordnungswidrigambrosebs: cant' we mix in some monadig fary dust and have a proper error reporting :-)
04:54dissipate_holy cow, this talk is hilarious http://www.youtube.com/watch?v=P76Vbsk_3J0&amp;feature=youtu.be (Clojure for Java Programmers Part 1 - Rich Hickey)
04:54ambrosebsordnungswidrig: so it's complimentary to your system.
04:54ambrosebsordnungswidrig: it's another thing if core.typed can understand yours though
04:55ambrosebsordnungswidrig: can you give me an idea of the reporting you want?
04:56ordnungswidrigambrosebs: I'd love to drop my own system. As reporting I imagined replacing every typed value with a pair (left: error, right: value)
04:56dissipate_listen to the javaheads be bewildered
04:58ambrosebsordnungswidrig: Could you go into a little more detail?
04:58ambrosebsordnungswidrig: with an example?
04:59ordnungswidrigambrosebs: so (validate (v/map :strict true :required {:a v/string :b (v/int 0 5)}) {:a "ab" :b 27}) gives [nil {:b ["integer within 0 5" nil]}]
04:59ordnungswidrigthis means, the error has the same "shape" as the type def, but uses vector-pairs to encode an error at a leaf
05:01ordnungswidrigI'm not sure about the exact "encoding". Thinking about web forms you will typically "iterate" over the fields and fetch the entered unparsed value and optional error
05:02ambrosebsordnungswidrig: hmm. core.typed might not be useful for that.
05:03ordnungswidrigambrosebs: I thought so. I just saw how my "type system" resemlbed the one in core.typed. Can a type in core.typed be instrospected at runtime easily?
05:04ambrosebsordnungswidrig: you might have a function validator-a-b-map which is Any -> (U [NoError {:a String :b Number}] [Error Any])
05:04ambrosebsordnungswidrig: not really, it's designed to only be used at development time.
05:05ordnungswidrigambrosebs: so it's all macro magic?
05:05ambrosebsordnungswidrig: yes. it's syntactic analysis.
05:06ordnungswidrigambrosebs: so I cannot access a "type value" like "(HMap required {:a AnyInteger})" at runtime?
05:07ambrosebsordnungswidrig: what are you thinking of doing?
05:08ordnungswidrigambrosebs: resuing a core.typed type definition for runtime validation
05:10ambrosebsordnungswidrig: you would need to load core.typed at runtime, which might not be cheap.
05:10ambrosebsordnungswidrig: but sure, core.typed has good facilities for manipulating types.
05:10ambrosebsor recursing over them etc.
05:11ordnungswidrigambrosebs: I see. So I will steel the syntax for type declaration and add custom validation like range checks in to.
05:11ambrosebsordnungswidrig: that's an area I'll like to explore also.
05:11ordnungswidrigambrosebs: you mean arbitrary validation functions?
05:12ambrosebsordnungswidrig: static types -> runtime contract transformation.
05:12ordnungswidrigambrosebs: does this include runtim contract validation?
05:13ambrosebsordnungswidrig: I'm more interested in throwing a type error on failed contracts.
05:13ordnungswidrigambrosebs: on runtime?
05:13ambrosebsordnungswidrig: yes
05:14ordnungswidrigambrosebs: what are the cases where a this could happen? wouldn't the type error be caught at compile time?
05:15ambrosebsordnungswidrig: when there is interaction between typed and untyped code, we want to protect typed code at runtime from "unchecked" untyped code.
05:16ordnungswidrigambrosebs: I see, on the boundaries between typed and untyped code. Could you then skip the runtime verification for calls from typed to typed?
05:16ambrosebsordnungswidrig: yes.
05:17ambrosebsordnungswidrig: core.typed doesn't do *any* runtime validation currently, so it's a deficiency that untype/typed interaction isn't checked at runtime.
05:17ordnungswidrigambrosebs: I see.
05:49AWizzArdcore.typed experts: I did (ann ring.adapter.jetty/run-jetty [Any Any -> org.eclipse.jetty.server.Server]) but still get “WARNING: Type Checker: Definition missing: ring.adapter.jetty/run-jetty”. Ideas?
05:51ambrosebs(ann ^:no-check ...)
05:53Anderkenthm. That seems like a disconnect between the error message and what it does. ^:no-check makes core.typed not validate calls to run-jetty, right? Why would that solve a 'definition missing' error? Or is that 'definition matching call missing', not 'symbol has no type definition'?
05:54ambrosebs:no-check means: don't check any `def`s of this var, and dont' worry if its missing.
05:54Anderkentah, the point is it has a type declaration but no definition. K.
05:55ambrosebsAnderkent: yes. I'll make the warning more descriptive.
05:55AWizzArdAh :)
05:55Anderkentso no-check means don't go into the definition of this function, but still verify that anything that *uses* this function is valid. Right?
05:55AWizzArdSo if I had a def somewhere, the warning would go away too.
05:56ambrosebsyes. The def must have a 2nd argument though.
05:56ambrosebsAnderkent: yes.
05:56Anderkentcool
06:03silasdavisI was just able to 'systemctl enable insync@<user>'
06:04silasdavisbut when I ran systemctl list-units and searched for 'insync' I found nothing
06:04silasdavisI thought list-units gave all available services...
06:04silasdavis?
06:04silasdavissorry wrong channel
06:34turbopapeHi guys,
06:34turbopapeanyone already done mahout/hadoop work on clojure ?
06:34turbopapehow did you find the journey ?
06:34turbopapedid you then use cascalog to query, etc.. ?
06:45llasramturbopape: It's mostly like integrating with any other Java library
06:45llasramturbopape: A significant amount of Mahout's functionality is pre-packaged into complete sets of Hadoop jobs fronted by "driver" classes
06:46llasramSo for the most part you can e.g. use Cascalog to build jobs which get the data into the appropriate input form
06:47turbopapeok llasram , just to make sure I understood, you mean that the algorithms are just queries
06:47turbopapeI Can issue using cascalog ?
06:47llasramMmmm. No
06:47turbopapeOk llasram , it's more like cascalog is used to feed mahout vectors etc... ?
06:48llasramSorry, haven't had my coffee yet and am typing slowly :-)
06:48llasramBut that's closer
06:48llasramMost of Mahout's entry points run complete Hadoop jobs
06:48turbopapeno problem, you are saving my life already :)
06:48llasramOr sets of jobs
06:48turbopapeI am totally new at this...
06:48llasramCascalog doesn't provide a direct way to integrate existing Hadoop jobs as queries
06:49llasramSo you end up running a query to get concrete output on HDFS
06:49turbopapeOk...
06:49llasramThen calling a Mahout driver class method on that intermediate output
06:49llasramAnd putting the Mahout output somewhere else concrete on HDFS
06:50turbopapeBut is there a significant gain to do this in clojure ? I'd like to take advantage of its vectors, immultability, expressiveness, etc...
06:50turbopapeBut will it add overhead ?
06:50turbopapelike translating to classes, etc... ?
06:51turbopape(I mean translating cloj seq <-> vectors, sequencefile, etc... ?)
06:51Anderkentis CinC published to clojars?
06:52llasramturbopape: There's no more overhead w/ Mahout than anything else in Clojure. If you're already using Cascalog, then it provides a completely reasonable and in-Clojure mechanism for building the input to Mahout's algorithms
06:52turbopapeOk llasram , that makes perfect sense :)
06:52turbopapeThank you for the help !
06:52llasramnp. Best of luck!
07:08ambrosebs_FYI just created #typed-clojure
07:08Anderkent,(apply @#'or nil nil [1 2])
07:08clojurebot(clojure.core/let [or__3943__auto__ 1] (if or__3943__auto__ or__3943__auto__ (clojure.core/or 2)))
07:08Anderkentwho said you can't take the value of a macro
07:08Anderkentmuahahahaha
07:12ucbeep
07:12ucbnice one Anderkent
07:12hhenkelHi all, someone here to the rescue? I don't get it I got a HashMap "collection" and a Vector "values" defined like that:
07:13hhenkel(def collection {"FreePhysicalMemorySize" {"cycle" 30, "option" "ignoreErrors=true", "action" "read", "attribute" "FreePhysicalMemorySize", "mbean" "java.lang:type=OperatingSystem"}, "FreeSwapSpaceSize" {"cycle" 30, "option" "ignoreErrors=true", "action" "read", "attribute" "FreeSwapSpaceSize", "mbean" "java.lang:type=OperatingSystem"}, "TotalPhysicalMemorySize" {"cycle" 3600, "option" "ignoreErrors=true", "action" "read", "attribute" "FreeSwapSpaceSize",
07:13hhenkel(def values ["FreePhysicalMemorySize" "attribute"])
07:13hhenkelNow I would like to do something like: ((collection (first values)) (rest values)) wich gives me nil
07:14hhenkelIf I do it like this: ((collection (first values)) "attribute") I get the expected value "FreePhysicalMemorySize" as a result.
07:14Anderkent,(rest [1 2])
07:14clojurebot(2)
07:15Anderkentrest gives you a list, not just the second param
07:15Anderkentsince you want "attribute" not ["attribute"], you must take it out with (second values) instaed of rest
07:15hhenkelAnderkent: okay, so I use (str (rest [1 2]) ?
07:15hhenkelhmm, okay
07:15Anderkenteither that or
07:16Anderkent(apply (collection (first values)) (rest values))
07:16Anderkentbut that doesnt make much sense in this example
07:16Anderkentdo you ever expect values to have more than 2 elements?
07:16Anderkentactually
07:16hhenkelNo, as I check for that earlier on.
07:16Anderkentthe best solution is (get-in collection values)
07:16hhenkelI could also use last I think?
07:17Anderkent,(get-in {"a" {"b" :c}} ["a" "b"])
07:17clojurebot:c
07:17Anderkentyou could, but second is better, and get-in is nicer still
07:19hhenkelAnderkent: Agreed, get-in is very nice...it looks like it solves all the thinks I want to do all at once.... ;)
07:19hhenkelBut I learned much...
07:35clgvany opinions on the comparison "congomongo vs monger"?
07:41AnderkentBronsa: I can't seem to get cinc analyzer to parse ns forms (complains about namespaced symbols in host expressions). Is that expected or new? Should I raise an issue?
07:48BronsaAnderkent: it's a bug, i'm looking into it thanks
07:50squidzhow can I use sets in clojurescript? when I call (set [1 2 3 3]) #{1 2 3 3} is returned. Shouldn't it be #{1 2 3} ?
07:50squidzis there a bug in clojurescript?
07:51AnderkentBronsa: the issue is that clojure.core/with-loading-context expansion includes (. clojure.lang.Var (clojure.core/pushThreadBindings
07:51BronsaAnderkent: yes, I saw that
07:51Anderkentwhich is apparently perfectly valid because the compiler just takes (name sym) as fn name, discarding the namespace
07:52BronsaAnderkent: I just fixed that but apparently there's still a problem with the method finder
07:53BronsaAnderkent: bleh, I just forgot to convert it back to a symbol, everything is working now
07:53Bronsagoing to push a fix just now, thanks a lot
07:54Anderkentno problem. I was looking at using cinc for code walking (with proper lexical scope tracking), and I think if I hook into -analyse/parse I might get something useful. There's no published jar of cinc yet though, right?
07:55squidzis there a way to find out the clojurescript version being used with lein cljsbuild? I am not sure why clojurescript wouldnt handle sets correctly
07:55BronsaAnderkent: no, it's not complete/tested enough that I feel confident to release even the analyzer only yet
07:55Anderkentthe analyzer on its own wouldn't be that useful either, at least without a unparse method :P
07:56BronsaAnderkent: I have a yet-to-finish emit-form pass here
07:57BronsaI'm having an exam at the uni tomorrow so I'm not going to finish it today but in the next days I'm going to push it
08:00squidzanybody know why i'm getting this? et [1 2 3 3])
08:01squidz(set [1 2 3 3]) -> #{1 2 3 3}
08:01Anderkent,(set [1 2 3 3])
08:01hyPiRionwell, that's a bug
08:01clojurebot#{1 2 3}
08:01Anderkent,(set [1 2 3 3L])
08:01clojurebot#<NumberFormatException java.lang.NumberFormatException: Invalid number: 3L>
08:01hyPiRion3N, rather.
08:01squidzit's only happening for clojurescript
08:01Anderkent,(set [1 2 3 3N])
08:01clojurebot#{1 2 3}
08:01Anderkentah.
08:02Anderkentblame javascript
08:02augustlsquidz: 3 vs "3" maybe?
08:02hyPiRionFloats, how to they work
08:02Anderkentmy thinking exactly
08:02hyPiRion,(set [1.0 1.0M])
08:02clojurebot#{1.0 1.0M}
08:02augustlthe literals 3 and 3 ought to be the same float, though
08:02hyPiRion,(set [1.0 1.0M 1.00M]) ;; etc.
08:02clojurebot#{1.0 1.0M 1.00M}
08:02augustlif the example is exactly that - (set [1 2 3 3])
08:02squidzyeah that is the exact example
08:03squidzlet me try it in a fresh clojurescript repl
08:03edbonddiscussion of the bug - https://groups.google.com/forum/#!msg/clojurescript/SKzdT-GOQaw/VOhPcpljil0J
08:03Anderkentreproduced on himera
08:04Anderkentright, http://dev.clojure.org/jira/browse/CLJS-516
08:05squidzah yeah I see it
08:05edbondsquidz, you can use distinct until is solved
08:06squidzedbond: thanks for the tip
08:08borkdudeIs it possible to start lein from a specific path?
08:15AnderkentOther than (cd path && lein), I guess?
10:21hhenkelI found "update-in" and I'm able to work with it, as long as it comes to numbers. All examples I found increment or modify number values. With what kind of function could I replace a string?
10:23pepijndevos&(update-in {:a "foo"} [:a] str "bar")
10:23lazybot⇒ {:a "foobar"}
10:24pepijndevoshhenkel, any function that returns a string relly
10:24clgvin mongodb how do I get a list of all collections or documents in the db?
10:24clgvI am using monger
10:26clgvah found it in the source: monger.db/get-collection-names
10:28clgvhhenkel: the function you need to pass to update-in is like follows (defn f [current-value & optional- arguments] ...) and then (update-in m [:somekey] f opt-arg1 opt-arg2 ...)
10:29clgvyou can implement everything you like in that function
10:35srrubyHow do I read in stdin as follows cat abc.txt | java -jar foo.jar ?
10:37nDuffsrruby: Depends. Do you want to iterate line-by-line? Read to EOF all at once? ...?
10:38nDuffsrruby: (as an aside -- it's more efficient to java -jar foo.jar <abc.txt, avoiding cat and the pipeline).
10:38nDuffsrruby: ...that way your process gets a FD directly on the file itself.
10:39srrubyAll at once
10:39nDuffI'd play with slurp, then.
10:40nDuffYou also have all the standard Java methods on System/in
10:42Anderkentyeah, (slurp *in*) should do it
10:46mpenetcore.async folks: is it safe to do (put! ch) then (close! ch), since put! is async is there a chance that the chan gets closed before the put! ?
10:47mpenetwell technically (put! ch :something)
10:51hhenkelpepijndevos: I don't want to join to strings I would like to replace it. That is the issue I got.
10:52pepijndevos&(update-in {:a "foo"} [:a] constantly "bar")
10:52lazybotclojure.lang.ArityException: Wrong number of args (2) passed to: core$constantly
10:53pepijndevos&(update-in {:a "foo"} [:a] (constantly "bar"))
10:53lazybot⇒ {:a "bar"}
10:53pepijndevoshhenkel, ^
10:53pepijndevosbut that's rellly just assoc-in
10:55hhenkelpepijndevos: ah, okay...that was what I was looking for. Currently I'm totally lost in my missing knowledge of the clojure vocabular, resulting in me trying to reimplement stuff that's allready there...but I keep learning by doing so... ;)
11:04sheldonhis there a clojure function that returns the first or last (don't care which) item in a coll, depending on whether first or last is fastest for the concrete type of the coll?
11:05clgvhhenkel: if you have only a flat map just use assoc
11:05supersymcan anyone tell me how to get the possible combinations of elements in a sequence while maintaining the order, like [2 2 5 5] ~> [[2][2 5 5]], [[2 2][5 5]], [[2 2 5][5]], [2 [2 5] 5]
11:05clgv&(assoc {:a "foo"} :a "bar")
11:05lazybot⇒ {:a "bar"}
11:06clgvhhenkel: btw there is `assoc-in` for replacing values
11:06hhenkelclgv: pepijndevos allready mentioned that earlier on.
11:06clgv&(assoc {:a {:b "foo"}} [:a :b] "bar")
11:06lazybot⇒ {[:a :b] "bar", :a {:b "foo"}}
11:06clgv&(assoc-in {:a {:b "foo"}} [:a :b] "bar")
11:06lazybot⇒ {:a {:b "bar"}}
11:07clgvhhenkel: oh ok. what I wanted to say is. for replacing the value with a constant (wrt the current value) use the assoc functions ;)
11:07llasramsupersym: So you want all possible ways of dividing a sequence into any number of subsequences?
11:09supersymllasram: that is correct, but the order can't be changed so [2 5 2 5] is out
11:09supersymlooks like a recursive pattern but I fail to
11:10supersymsee it
11:10hhenkelclgv: okay, an for "really" changing the value in the actual map I can create an atom from it and change the value with that, right?
11:11llasramsupersym: I believe what you actually want is all sequences of integers >0 which add up to (count coll)
11:11clgvhhenkel: I dont know if understand correctly. just provide a code example
11:11supersymllasram: dude..thank you
11:11supersymyou are right
11:12hhenkelclgv: respectively, it works like described for me, I'm not sure if it is the way to do it.
11:12clgvhhenkel: show example code demonstrating your atom idea and we can talk about it ^^
11:13hhenkelclgv: okay, I'll try to show a simple example.
11:13clgvand dont forget to state the goal you want to achieve
11:16hhenkel(def my-atom (atom {"aa" "a" "bb" "b"}))
11:16hhenkel(defn alter-value [collection variables new-string] (assoc-in collection variables new-string))
11:16hhenkel(swap! my-atom alter-value ["bb"] "test")
11:18clgvhhenkel: you can do that more directly if you like: (swap! my-atom assoc-in ["bb"] "test")
11:18hhenkelmy-atom now provides the altered value "test". As said, that works for me, I'm not total sure if it is the way to do stuff.
11:19clgvyes it is. except that you should not use (def my-atom ..) for "variables" like in other procedural languages in your regular program
11:20clgvbut for that demo or in repl that is ok
11:20clgvto try it here ##(let [my-atom (atom {"aa" "a" "bb" "b"})] (swap! my-atom assoc-in ["bb"] "test"))
11:20lazybot⇒ {"aa" "a", "bb" "test"}
11:21clgvhhenkel: usually you'd also use keywords as keys instead of strings except your application really needs strings
11:22hhenkelclgv: okay, so I better user "let" to define "variables" (like in other languages) then?
11:23clgvhhenkel: yes you use `let` to assign a name to values to reuse the value in the following code
11:24clgvhhenkel: def is only for top-level vars that reside in the namespace, e.g. functions or constants
11:24hhenkelclgv: I had keywords before but I struggeled with it, as I tried to reimplement stuff that was allready there and decided to stick with string for the moment...^^
11:25pbostromsheldonh: &(doc peek)
11:25pbostrom&(doc peek)
11:25lazybot⇒ "([coll]); For a list or queue, same as first, for a vector, same as, but much more efficient than, last. If the collection is empty, returns nil."
11:25hyPiRionpbostrom: ##(doc peek)
11:25lazybot⇒ "([coll]); For a list or queue, same as first, for a vector, same as, but much more efficient than, last. If the collection is empty, returns nil."
11:25hyPiRionheh
11:25hhenkelAs I allready mentioned first I struggled with a poor mans implementation of "get-in" and now with "assoc-in".
11:30hhenkelclgv: How would I do the altering when I using a ref instead of an atom? I know I need do-sync...and maybe alter?
11:31clgvhhenkel: yes like that: ##(let [my-ref (ref {"aa" "a" "bb" "b"})] (dosync (alter my-atom assoc-in ["bb"] "test")))
11:31lazybotjava.lang.RuntimeException: Unable to resolve symbol: my-atom in this context
11:31clgv&(let [my-ref (ref {"aa" "a" "bb" "b"})] (dosync (alter my-ref assoc-in ["bb"] "test")))
11:31lazybot⇒ {"aa" "a", "bb" "test"}
11:31clgv&(let [my-ref (ref {"aa" "a" "bb" "b"})] (alter my-ref assoc-in ["bb"] "test"))
11:31lazybotjava.lang.IllegalStateException: No transaction running
11:32clgvwithout the `dosync` you get that exception ^^
11:34hhenkelclgv: ah, okay, seems like I missed bracket. Thank you very much for your help!
11:35clgvnp
11:37zerokarmalefthhenkel: fwiw, if you altering a non-nested key, you can just use assoc
11:38zerokarmaleft&(-> {"aa" "a" "bb" "b"} (assoc "bb" "test"))
11:38lazybot⇒ {"aa" "a", "bb" "test"}
11:40zerokarmaleftassoc-in and update-in let you drill down into a nested map
11:40zerokarmaleft&(-> {:a 1 :b {:x "hello" :y "goodbye"} :c 3} (assoc-in [:b :x] "test"))
11:40lazybot⇒ {:a 1, :c 3, :b {:y "goodbye", :x "test"}}
11:41hhenkelzerokarmaleft: Thanks clgv mentioned that. I'm currently playing around with nested maps (configurations) - I would like to implement something like "variables" in config files, therefore replacing placeholders with other stuff.
11:42zerokarmalefthmm sorry, I should read the scrollback more carefully
11:44hhenkelzerokarmaleft: np, I'm impressed how helpful people are in this channel.
11:44clgv$karma zerokarmaleft
11:44lazybotzerokarmaleft has karma 1.
11:44clgv:O
11:45zerokarmaleftclgv: now you've done it
11:45clgv:D
11:59kittylystMonger is giving me this exception:
11:59kittylystreporting.core> (connect-to-jclarity-prod)
11:59kittylystMongoException can't find a master com.mongodb.DBTCPConnector.checkMaster (DBTCPConnector.java:518)
11:59kittylystI see a couple of references to this on SO, but no resolutions - anyone got any thoughts?
12:16ethanisHi folks, any core.typed users around?
12:18dnolenethanis: there are a few, just ask your question, there's also a core.typed IRC channel #typed-clojure
12:18ethanisI am just starting to try it out, but have run into an issue with annotating defrecords in version 0.1.26
12:19dnolenethanis: if no one can answer now you also have the core.typed mailing list, Ambrose is a pretty responsive guy
12:19ethanisalright, thanks for the suggestion dnolen
12:21ambrosebs_ethanis: Have you tried version 0.2.1?
12:22ethanisno!
12:22ethaniswill do that, thought latest was 0.1.26 for some reason
12:22ambrosebs_ethanis: That version is only a few weeks old.
12:23ethanis(I think I assumed this because on github, master is marked as 0.1.27-SNAPSHOT)
12:23ethanistrying 0.2.1 now
12:23ethanishere's what I'm attempting, just want to make sure I'm not being completely knuckleheaded about this
12:23ethanishttps://gist.github.com/sherbondy/6425817
12:23AnderkentI recommend using either [artifact-name "RELEASE"] or lein try artifact-name when playing around with stuff
12:24Anderkentexactly to avoid the pain of discovering what the last stable version of X was
12:24srrubyI want to read stdin into a string. Is there a more idiomatic way than this? (pprint (apply str (interpose "\n" (doall (line-seq (java.io.BufferedReader. *in*)))))))
12:25Anderkentsrruby: (slurp *in*)
12:25Anderkentweird, it's the second time reading stdin came up today
12:26ambrosebs_ethanis: there's no error there.
12:26ambrosebs_ethanis: do you mean the "INTERNAL BUG!"?
12:26ethanisyeah
12:26ethanisbut that doesn't appear in 0.2.1
12:27ethanisInstead, I get: "clojure.lang.Compiler$CompilerException: java.lang.Exception: Found inner call to check-ns or cf, compiling:(rt.core:12:1)"
12:27ethanisIs check-ns intended for use in the repl only?
12:27ambrosebs_ethanis: Yes, don't put check-ns directly in your namespace.
12:27ambrosebs_or for unit tests.
12:27ambrosebs_yes.
12:29clgvsrruby: (println (slurp *in*)) should work as well. maybe you can wrap the bufferedreader here as well
12:29ethanisambrosebs_ how is a user supposed to know that? was that mentioned somewhere and I glossed over it?
12:29ambrosebs_ethanis: I don't think its mentioned explicitly anywhere.
12:30futileIt seems that creating an uberjar is the right way to deploy a Lein (web) app, right?
12:30srrubyThanks all.
12:30Anderkentfutile: if you're deploying as an executable jar, yes.
12:30ambrosebs_ethanis: I'll add to the check-ns docstring.
12:30futileAnderkent: as opposed to..?
12:30Anderkenttargetting a servlet
12:30futileOh, no I'm just deploying to AWS.
12:30clgv futile: it is one option when you deploy with jetty. but you could also create a war file for a popular servlet container
12:31futileOkay.
12:31ethanisambrosebs_ woohoo, thanks. Would it be helpful for me to open an issue just for record keeping?
12:31ambrosebs_ethanis: yes.
12:31futileDoes "lein repl" require the source of a lein project to work?
12:31ethanison it!
12:31ambrosebs_ethanis: also mention that cf cannot be used recursively
12:31ambrosebs_thanks!
12:32technomancyfutile: technically bytecode is enough
12:32ethanisokay
12:32technomancyfutile: but lein assumes it's being run from a checkout
12:32futileOh.
12:33technomancyyou can embed nrepl in an application easily enough though
12:33futileBasically I'm wondering if I can deploy just an uberjar (per your mailing-list email on Aug 19) and still use lein repl in production.
12:33technomancyfutile: you would do `lein repl :connect $PORT` rather than `lein repl` but it should still work
12:33technomancyor `grench repl` =)
12:34srrubyecho "hello" | lein run works ok. But echo "hello" | echo "hello\nworld" | java -jar ./target/foo.jar fails- Exception in thread "main" java.lang.ExceptionInInitializerError
12:34lazybot"hello" | lein run works ok. But echo "hello" | echo "hello\nworld" | java -jar ./target/foo.jar fails- Exception in thread "main" java.lang.ExceptionInInitializerError
12:35futilegrenchman!
12:35Anderkent futile: our web app uses drawbridge in which case you can just lein repl :connect https://foo/debugging/repl
12:35Anderkentvery convenient
12:35futileAnderkent: I can dig that.
12:36technomancyfutile: sausage-leg jeans, kicky-boots; the whole deal
12:37Anderkentsrruby: does it run if you remove the slurp *in* call?
12:37Anderkentmy guess would be your packaging process went wrong
12:37Anderkentdidn't compile main or sth
12:37srrubyOK. looks like a java configuration problem
12:37callenfutile: prolly never since it encompasses Google Docs now.
12:37clgvfutile: when the NSA is tired of watching two places ;)
12:40futileheh
12:41ethanisalright ambrosebs_, issue submitted. Hope it's well-formatted (never used jira before): http://dev.clojure.org/jira/browse/CTYP-41
12:41ethanisthanks for your help, will ping if I run into further issues
12:42ambrosebs_ethanis: perfect!
12:42ambrosebs_ethanis: please do.
12:42Anderkentjira is just such a pain :((
12:44srrubyWhen I run it through java -jar it is failing when it sees slurp
12:45callentechnomancy: I am kinda curious as to what sausage leg jeans look like
12:45srrubyDo I have to downgrade Leiningen ?
12:45callenI'm almost afraid to know.
12:46Anderkentsrruby: works for me. Wanna post the code?
12:47Anderkentsrruby: https://www.refheap.com/18261
12:50TimMccallen: Perhaps those really skinny jeans that make people's legs look like they were stuffed into a sausage casing?
12:51callenTimMc: that's what I figured. Hrm.
12:51srrubyAnderkent: Thanks. That part works.
12:54technomancycallen: I think it means they're mostly round but tied off at the end
12:59dissipate__interesting fact: clojure's founder Hickey is a former C++ developer
13:00callendissipate__: yawn.
13:01callendissipate__: if you look at the sort of work he did, that's not surprising at all.
13:01muhoowell yeah, he wrote a famous paper on c++ functors in the 90s
13:01callenmuhoo: poor bastard was trying to get out of the trap even back then.
13:01srrubyWhen I run clojure via jar it is not finding my resource. I've got (slurp (clojure.java.io/resource (str "resources/fixtures/" file-name)))
13:02Anderkentsrruby: ah. is the resources dir included in your uberjar?
13:02dissipate__callen: why a yawn? i think it's interesting that lisp turned him around to a completely different 'paradigm'
13:02srrubyAnderkent: Yes
13:02Anderkentsrruby: basically when you run via lein run, current directory is on the classpath so it 'just works'
13:02Anderkenthm.
13:02callendissipate__: do you know what a functor is?
13:03dissipate__callen: in c++ no
13:03srrubyI'm running it via java -jar
13:04srrubyAnderkent: I'm running it via java -jar it works fine when I do lein run
13:04dissipate__callen: i ran into functors briefly in ocaml
13:05callenI don't think Hickey had any singular epiphanies. Clojure represents a well-thought out approach to design that he'd been accumulating for a long time.
13:05Anderkentsrruby: yes but that's because your classpath is different with lein run. What's your directory structure? The "resources/" in your name seems suspicious, it shouldn't have to be there (unless your file path is ./resources/resources/fixtures)
13:05callenI once got him to recommend some books to me and the impression I got was that Clojure was long coming.
13:06srrubyAnderkent: Thanks I'll look into it
13:07Anderkentsrruby: https://www.refheap.com/18261 that works for me
13:08dissipate__callen: this 'issue' of macros not being very composable with functions predates clojure, right?
13:10technomancydissipate__: yes, but it's less noticeable in CL because CL makes it awkward to use higher-order functions
13:10callendissipate__: gods yes. lol. What technomancy said is very true.
13:10callenmutable code and excessive macros made it overly difficult to compose functions in CL.
13:10callenmutable data, I guess I should say. you get my meaning.
13:11dnolendissipate__: people seem to misunderstand the source of that meme, in the early days Clojure devs were not primarily composed of people experienced with Lisp and produced libraries that unnecessarily leaned on macros where functions would suffice.
13:11Anderkentdissipate__: not composable? ##(apply (comp (partial @#'or nil nil) (partial @#'and nil nil)) [1 2 3])
13:11lazybot⇒ (clojure.core/let [and__3822__auto__ 1] (if and__3822__auto__ (clojure.core/and 2 3) and__3822__auto__))
13:13dissipate__dnolen: i see. in one of his talks aimed at Java devs, Hickey admitted that macros are really language design. that's pretty heavy.
13:14ethanisokay, ambrosebs_, here's a tricky one for you: is there any way to annotate an individual implementation (defmethod) of a multimethod that has been required from a library (and thus has no type annotations of its own)?
13:14ethanisor, alternatively, is it possible for me to annotate the multimethod once it's been required?
13:14muhoowell the problem i've had with macros is with libraries like noir, where, once you start down the road of macros, often you have to use more macros to deal with those, and you end up wiht a macro infestation.
13:14dissipate__i can totally see macros being abused
13:14ambrosebs_ethanis: hmm. Probably not currently.
13:15muhooor as zach said in one of his talks (paraphrasing), programs that write programs is cool, but programs that write programs that write programs puts you into a danger zone
13:15Anderkentmuhoo: or midje. I love midje, but sometimes it's such a pain
13:15dissipate__muhoo: how about a shop where your coworkers send you to macro hell?
13:15ambrosebs_ethanis: want to bring the convo over to #typed-clojure?
13:15muhoodissipate__: charge by the hour :-)
13:15ethanisokay!
13:16Anderkent(alter-var-root #'defmacro (constantly #'defn)).
13:16Anderkent;D
13:16dissipate__somehow i don't think all these java devs that Hickey is giving these talks to are going to properly implement macros
13:17srruby:Anderkent where is your resources directory
13:17Anderkentunder project root
13:17Anderkentall paths are relative to project root
13:17muhooall you have to do is screw it up once, then you go "oh, wow, i shouln'ta done that"
13:18technomancysrruby: resources/ is on the classpath; you should load things relative to it rather than relative to the project root
13:18technomancysrruby: (you should never see the string "resources" in your code)
13:18muhooi made a patch to a library some time ago that was all macros, and didn't need even one. i almost literally did what Anderkent suggested, and took out all the # and ~
13:19srrubyIs project root the src directory? I see the word resources in jar tvf foo.jar
13:19dissipate__muhoo: so it's all functions now?
13:19Anderkentsrruby: no, it's where your project.clj lives
13:19technomancythere shouldn't be a resources directory in your jar
13:21muhoodissipate__: yep. it was a small library, maybe a page or two of code, a wrapper around some java stuff. i changed all the macros to funtions, submitted a pull request, it got accepted. it was just a newbie "oh i though you needed macros fo that" situation, apparenntly
13:21lynaghkIs there a way to test with Midje that something is logged (via taoensso's timbre library)?
13:21callenlynaghk: 1. Don't use midje 2. with-out-str ?
13:22lynaghkI tried using Midje's prerequisites, but `info` is a macro
13:22lynaghkhmm, with-out-str is ghetto but may work.
13:22dissipate__muhoo: hmm, interesting. i could be wrong, but i suspect that functions are turing equivalent to macros.
13:22callenlynaghk: well, that or patch/mock the logging library to use an fn that puts messages into a core.async channel
13:22callenlynaghk: then take off the channel.
13:23Anderkentcallen: why not use midje? lynaghk: hook into timbre/send-to-appenders!
13:23lynaghkAnderkent: my gut feeling is that the proper way to do this is to ensure the logging fn is called, not actual try to catch the side effect.
13:23callenlynaghk: just add a callback fn, for pete's sake.
13:24Anderkentlynaghk: the problem is that there's no logging fn, timbre (if level ...) is inlined into your code to avoid the performance hit
13:24lynaghkAnderkent: yeah, right.
13:24muhoodissipate__: i dunno. seems to me that macros are functions! they just oprate on code before it compiles. i'm no expert on macros, they have been only minimally necessary for me so far.
13:25callenmuhoo: macros can be useful for things like Korma.
13:25callenmuhoo: but their use in Korma is very limited and represents only a top-level DSL.
13:25callenthe macros just gather the operator and body up.
13:25callenSeems a fine use of macros to me.
13:25dissipate__muhoo: yeah, that sounds about right. i'm staying far away from them for now. after watching that video 'macros are hard', i'm afraid they are going to get me all twisted up. some really gnarly stuff going on there.
13:25callenI am grateful their fn* counterparts exist though.
13:26Anderkentlynaghk: you can register middleware with timbre
13:26Anderkentand use that to see if your message comes through
13:26callenthat's what I said earlier.
13:26Anderkentit won't be an end to end test but you
13:26Anderkentyou can trust timbre to work and just test your side
13:26callenjust send logs through a core.async channel
13:26Anderkentcallen: you did? I didn't catch that.
13:27callenyes I've been trying to get him to use a core.async channel log-event handler this whole time.
13:27lynaghkcallen: I already have a core.async appender for timbre in this library, so I'll give that a go =)
13:27dnolendissipate__: there's nothing wrong with macros, #1 use case is simple sugar where functions will not suffice, or a functional solution is not worth the cost of admission
13:27lynaghkbut grudgingly; only because I can't stub the fn because timbre is using macros =)
13:28dnolendissipate__: Java devs are familiar with macros, sadly it's called ANTLR
13:29AnderkentI don't see why you'd use core.async instead of just appending the intercepted log messages to a list
13:29coventrylynaghk: Could you wrap the test in a lexical closure which stubs out the timbre macro?
13:29arityAre there any site for podcasts on clojure or functional programming in general?
13:29lynaghkAnderkent: the test syntax is a bit cleaner using core.async than with-out-str
13:30callendnolen: *shudder*
13:30callenlynaghk: it's not just syntax, it's semantically cleaner and easier to test.
13:31Anderkentuh what? I was thinking more of (fn logging-middleware [args] (alter seen-messages conj args)). Where does with-out-str come in?
13:31callenwith channels you get discrete log messages, with with-out-str you have to split and sanitize things yourself.
13:31Anderkentunless you really care that they arent printed out, but why would you
13:31Anderkentthen obvlsy reset seen-messages in a fixture around your tests (probably the same one that hooks the logging middleware in)
13:31callenAnderkent: the reason for using core.async rather than...a ref? (not sure what you're thinking there) is to avoid global state.
13:32callenAnderkent: if you have multiple tests or test-cases testing the logging library, core.async will work even if they run concurrently, this is not the case if you're using a top level def'd atom or ref.
13:32callenyou should hold your test code to a higher standard than that.
13:32dissipate__dnolen: you can change the java language with ANTLR?
13:32Anderkentyou create the atom in a fixture around your test
13:32Anderkentit's not global
13:32lynaghkcallen: unfortunately that's a moot point since Timbre uses a global atom as its config.
13:32callenAnderkent: that would work if it's scoped to each test.
13:33Anderkent(around :facts ...)
13:33callenlynaghk: I just got done figuring out a nice closure + global atom pattern for such things, I might consider patching timbre to use this.
13:33callenthen you're given the option of muggle-mode or a closure.
13:33lynaghkcallen: you should gist up and example and email me at the very least, I'd love to see that
13:33Anderkentwould core.async even preserve log message order? If you hit the channel twice, both writes will park and your read will read from a random one, right?
13:33lynaghkatoms rub me the wrong way.
13:33callenlynaghk: no need, just look at bulwark. github.com/bitemyapp/bulwark
13:34Anderkentor are you using some kind of buffering channel?
13:35callenAnderkent: I actually just got done hammering out a nice structure for core.async with functional tests that need to interact with "global" resources like queues and logging libraries.
13:35callenworked fine for me.
13:35Anderkentlynaghk: using mutable state to represent side effects to the 'outside' world in tests seems totally fine.
13:35Anderkentwell, gotta run
13:37callenit's not insanely problematic, but you can do better.
13:41srrubyIn project root I have /resources/fixtures/foo.txt How do I access foo.txt in my code ?
13:41justin_smithsrruby: io/resource
13:41justin_smithwhat looks things up in the resource path
13:42justin_smith(slurp (io/resource "fixtures/foo.txt"))
13:42justin_smiththe cool thing with io/resource is it even works if your code is inside a jar, without having to change anything
13:42justin_smithmake that "if your resource is inside a jar with your code"
13:46dnolenlynaghk: your notes re: analyzer/compiler are a good start but very broad. would like be nice to get smaller actionable chunks. cleaning up closure.clj would be a good start. closure.clj is meant be consumed so solidifying things there would be great. As far as exposing analyzer.clj and compiler.clj I think we need some file above them that provides tooling
13:46dnolenservices.
13:46lynaghkdnolen: yeah, I'm definitely not done with the notes
13:47lynaghkhear you on the actionable chunks---already a few people are asking for some really big stuff
13:47lynaghkbut I will try to arrange things so there are clear next steps
13:48lynaghkwhat do you think about putting public API fns in their own namespace (jonase's suggestion)
13:48dnolenlynaghk: yes this is what I meant when I said separate file.
13:48bbloomlynaghk: link to notes?
13:49lynaghkbbloom: https://github.com/lynaghk/clojurescript-compiler-proposal
13:49bbloomcore.async does this w/ a public API file. i like that approach in general, even though it's a little verbose/annoying to "copy" functions over to the public namespace
13:49lynaghkdnolen: I don't know if I actually want/need separate analysis stuff. I think that info could be returned with a sucessful compile
13:50lynaghki.e., a sucessful compile just returns a map {:namespaces [...] :js "actual-js-output" ...}
13:50bbloomi think we should focus on the compile API & keep the analyzer API private for now. the schema of the AST is much more important to spec out than the analyze API
13:50lynaghkI haven't thought through it all yet, though, hence the lack of concrete suggestions in the notes.
13:51dnolenlynaghk: these concerns will need to be kept separate, I'm not convinced you want to involve compile if you're getting a namespace dependency graph.
13:51dnolenlynaghk: nor do you want the overhead of compile if you just want to locate all errors/warnings
13:52lynaghkdnolen: from the source, I thought all errors/warnings came from Google Closure
13:52dnolenlynaghk: analyzer warnings?
13:52dnolenlynaghk: closure.clj just sets the flags for analyzer.clj
13:52lynaghkdnolen: maybe my grep skills failed me, but the only place I saw errors/warnings were Java interop calls
13:53dnolenlynaghk: no warnings come from many places in analyzer.clj
13:53lynaghkdnolen: separate sounds good to me; ideally there is some simple pipeline of analyze->emit->optimize or whatever that you can juggle yourself, or use an "easy" fn that does it for you.
13:53lynaghkdnolen: ah, cool.
13:54lynaghkI have to make some progress on my other yak shaves this morning, but I'll circle back to the cljs stuff this afternoon
13:56dnolenlynaghk: that should be the goal, re: pipeline, but it's going to take some work to get there.
13:57lynaghkdnolen: totes. I'm more than happy to dive in and do some of that work too---I just want to write out explicit goals and a plan first.
13:58dnolenbbloom: I agree AST aspects should be left alone, but I think errors/warnings/ns dependencies/pseudo-var facilities/ns queries in general all these we can sensibly expose.
13:58bbloomdnolen: probably
14:09futileCould ClojureScript get to the point of replacing Clojure for server-side web apps?
14:11bbloomfutile: i mean it could, but why should it?
14:11futilefaster start-up time :)
14:12bbloomfutile: how often are you starting your servers? :-P
14:12gfredericksnot having to deal with pesky exact arithmetic
14:12futileconstantly. they'er always crashing
14:12futileevery 10 sec prolly
14:12bbloomgfredericks: math is for suckers
14:14bbloomgfredericks: besides, don't everybody just use church numerals?
14:15futilenever heard
14:15bbloomfutile: google it
14:16futilethanks i just might
14:21squidzdnolen: do you know about the bug in clojurescript where sets aren't proper sets. calling (set [1 2 2]) will return #{1 2 2}
14:23gfredericksbbloom: just pastors afaik
14:25dnolensquidz: hrm, probably a unintended side effect of some optimizations we have in place, I check JIRA, feel free to make a ticket if not present
14:25dnolen"I would check JIRA"
14:25mihneadbsquidz: tried online at clojurescript.net and it works
14:26dnolenmihneadb: clojurescript.net is not a reliable resource, that's the CLJS-in-CLJS project
14:26squidzhm we tried earlier at himera, I assume that is the same site and it didnt work, let me try it again
14:26bbloomdnolen: can we get fogus/relevance to update clojurescript.net with a caveat about that? :-P
14:26dnolensquidz: I can confirm that it's broken
14:27dnolenbbloom: fogus/relevance don't run that domain
14:27bbloomdnolen: well they created himera. somebody else just pointed a domain at it
14:27dnolenbbloom: no, it's a seperate thing entirely, it's a CLJS-in-CLJS thing
14:28bbloomdnolen: ooooh i just re-read the copyright: CLJS-IN-CLJS © 2013 JOEL MARTIN
14:28bbloomHIMERA DESIGN © 2012-2013 FOGUS, JEN MYERS AND RELEVANCE INC.
14:28mihneadbdnolen: oh, ok
14:28bbloomdnolen: can we get joel to add a caveat? :-P
14:29dnolensquidz: feel free to file a bug
14:29rurumateHere's some 'basic' code that runs fine in clojure but crashes in clojurescript: https://www.refheap.com/18264
14:29rurumateany ideas what's going on there?
14:29jtoyim trying to refactor my code by moving code in one namespace into another (im grouping all the time methods into one ns), I then :use that time ns from many other namespaces, I am getting errors now though such as "now_long already refers to: #'pusher.time/now_long in namespace: pusher.web.admin" can anyone help me understand what i am doing wrong?
14:30squidzdnolen:
14:30`fogusOnly the "design" (i.e. pretty UI elements) are copy me and Relevance.
14:30squidzokay will do
14:30gfredericksjtoy: stale repl state?
14:31jtoygfredericks: I dont think so, I am calling "lein repl" and it dies loading that
14:32jtoyor can that be stale also?
14:32gfredericksshouldn't be
14:32gfredericksmaybe `lein clean` just to be paranoid
14:33dnolenrurumate: need more context, what's the actual error that you see? Is this a compiled program? Is this evaluated in the REPL?
14:33jtoygfredericks: nope, same error
14:33clojurebotexcusez-moi
14:33rurumatednolen: I'll make a github repo..
14:33dnolenrurumate: before you do that, more info please :)
14:34rurumateok, yes maybe github repo is not so useful, because it may be the emacs settings's fault
14:35rurumateso my inferior-lisp-program is "lein trampoline cljsbuild repl-listen"
14:35rurumatethe project looks exactly like the advanced example from lein-cljsbuild
14:36adamtHi. What is the name of "->"? Google is being really unhelpful. :P
14:36rurumateFirst, I start a ring server on localhost:3000 with lein ring server-headless
14:36futileadamt: thread-first
14:37justin_smithalso called thrush or arrow
14:37rurumatethen I open src-cljs/example/print.cljs in emacs and do C-c -z to open the inferior-lisp buffer in lisp-mode
14:37adamtthanks guys.
14:37justin_smithsymbolhound.com is cool for this stuff http://symbolhound.com/?q=-%3E+clojure
14:37justin_smithsymbolhound searches for the weird programming glyphs that google etc. do not index
14:38rurumateIn the inferior-lisp repl I write (ns example.print) and then (load-file "example/print.cljs")
14:38rurumate(have to open localhost:3000/repl-demo or evaluation will hang)
14:38dnolenrurumate: but does this error happen if you just compile your program? and you still haven't said what the exception *is* :) stack overflow?
14:39rurumateoops, I meant (ns example.dice) and (load-file "example/dice.cljs")
14:39ambrosebs_bbloom: https://github.com/frenchy64/lein-typed
14:39bbloomambrosebs_: yes! :-)
14:40rurumatednolen: I don't know what the exception is because the stack trace (or whatever it is) is so long, it would take very long to the first line
14:40bbloomambrosebs_: exciting. announce that bad boy :-)
14:40ambrosebs_bbloom: :)
14:40eric_normandvery exciting
14:41rurumateok anyway, so after the (load-file "example/dice.cljs") I run (cljs-ouch) and it crashes every time (after running for some seconds)
14:42rurumateto run it in nrepl (normal clojure), I just make a soft link to the file from another project and open nrepl....
14:43technomancyambrosebs_: why not collapse the two subcommands?
14:44ambrosebs_technomancy: I didn't give it much thought. Like what?
14:44technomancyambrosebs_: like the test task; it'll run all the namespaces you give it as args, but if you don't give it any, it'll just figure it out for itself
14:45technomancy(in this case it could be by looking at the project map, or scanning via bultitude or something)
14:45bbloomi say you should claim `lein type`
14:45ambrosebs_technomancy: ok thanks.
14:45technomancylooks handy though; very nice
14:46ambrosebs_bbloom: naww I like typed.
14:46ambrosebs_technomancy: thanks
14:46rurumatein https://www.refheap.com/18265 the function is written a bit shorter (shows the same behaviour and should be equivalent)
14:46bbloomambrosebs_: i guess i could deal w/ one extra letter :-P
14:46vijaykiranis there a way I can tel leiningen to build stuff from different dir ?
14:46technomancyambrosebs_: for bonus points you could emulate `lein compile` and accept regexes either on the cli or in the project map
14:46ambrosebs_bbloom: typed is so much cooler
14:46technomancyplus support :all
14:47technomancyvijaykiran: just add to :source-paths
14:47technomancy:source-paths ["src2"] or wahtever
14:47vijaykirantechnomancy: sorry - I meant while not in the project dir
14:48technomancyoh you mean like looking for project.clj in something other than the current directory?
14:48vijaykiranit was because we have a project in which the clojure project is in a subdir of git repo - so we want to specify a sub dir
14:48vijaykirantechnomancy: yes
14:49technomancyalias lein-in="pushd $1 && lein $@; popd"
14:49ambrosebs_technomancy: ok. I should probably support that in core.typed, then call it from lein-typed.
14:49vijaykirantechnomancy: :) thanks
14:49technomancyambrosebs_: yeah, I'm a fan of making plugins as small as possible
14:50technomancyambrosebs_: in many cases you can get rid of plugins entirely and just have :aliases {"typed" ["run" "-m" "clojure.core.typed"]}
14:50technomancy(but you can't do that if you need access to the project map)
14:51technomancyyou could get around that by using ns-level metadata instead of defproject keys, but then you have to load every ns before you can check a subset of them, which is slow
14:52rurumatednolen: could you reproduce it?
14:53ambrosebs_technomancy: right. good to know.
14:55gfredericksbbloom: `lein type` should be reserved for the thing that infers types and adds them to your source
14:56bbloomgfredericks: `lein type infer` :-)
14:57dnolenrurumate: sorry can't look at it closely right now, perhaps someone else can.
14:58ambrosebs_FWIW I like showing the relation to Typed Racket with "typed".
14:59ambrosebs_Since that's where the awesomeness comes from.
14:59rurumatehmm yeah, someone should be of help here
14:59dnolenrurumate: or ask your question on the CLJS mailing list
14:59rurumateoh yeah, but where can I join it?
15:00amalloygfredericks: lein do type infer, type check
15:01rurumatemailing list, or google group?
15:04dnolenrurumate: google group
15:09nopromptdnolen: is there a way to keep protocol extensions in clojurescript isolated to a namespace?
15:10nopromptdnolen: it seems like when you extend a protocol in one ns all others are affected
15:11noprompt:-(
15:11bbloomnoprompt: nope
15:11bbloomnoprompt: i needed that one time tho, so i made this project: https://github.com/brandonbloom/dispatch-map
15:11bbloomnoprompt: it's kinda experimental & doesn't have explicit cljs support, but it might be helpful to you
15:13nopromptbbloom: why does that happen?
15:13bbloomnoprompt: protocol dispatch tables are global/mutable
15:13bbloomnoprompt: they have dynamic scope, just like vars
15:14amalloybbloom: dynamic scope doesn't sound like a good way to describe protocol extensions at all
15:14bbloomamalloy: unbounded dynamic scope? :-P
15:15amalloyit's global and permanent
15:15nopromptbbloom: so what's the big difference from clj and cljs? why the bleed?
15:16bbloomnoprompt: with respect to protocols? both have the same behavior
15:16futileIs it a bad idea to stick @(future (Thread/sleep 200)) inside a (while true ...) on the main thread?
15:16callenfutile: it's a sign of a very bad design.
15:16futileWhy?
15:16clojurebotfutile: because you can't handle the truth!
15:16nopromptbbloom: really? cause that's not what it looks like from the repl.
15:17amalloyfutile: @(future ...) is always a sign of lunacy
15:17amalloynoprompt: it's the same
15:17noprompti think i'm missing something here.
15:17Apage43futile: you probably want a ScheduledTheadPoolExectuor
15:18futileOh.
15:18aaelonyI'm using nrepl from emacs within screen on a remote server and am trying to forward x11. It doesn't work yet but I think I'm pretty close b/c it works from lein repl, just not from screen + emacs/nrepl yet. The error is "java.awt.HeadlessException: null" even though my project.clj contains :jvm-opts ["-Xmx2g" "-Djava.awt.headless=true"] … DISPLAY=:0 and my localbox from which I am doing ssh -Y remote-server-name is already xhos
15:18Apage43https://github.com/overtone/at-at is a convenient wrapper around that
15:18aaelony…. any ideas?
15:18rurumatednolen: I posted in the group but now I can't find the post in the postings list.. does it normally take a while to show up?
15:20noprompti create a protocol in `ns foo`. then in `ns bar` i `(require 'foo)` and extend the protocol to c.l.PersistentVector or whatever. then i switch to `ns baz` and try to call some function from the protocol and it fails because it can't resolve the symbol.
15:20amalloyaaelony: setting headless to true is disabling graphics entirely; i think you just want to leave it on, and x-forwarding will take care of sending it to the right place
15:20nopromptin cljs that's not the case. calling the function w/o requiring the protocol ns happily works.
15:21nopromptwait. hang on.
15:21aaelonyamalloy: ok, will try that but I put it in the project.clj only because it was complaining about it and was reading through this http://stackoverflow.com/questions/10165761/java-cant-connect-to-x11-window-server-using-localhost10-0-as-the-value-of-t
15:21seancorfieldrurumate: first postings are moderated, I believe.
15:23amalloyhm. well, i confess i'm not very experienced with X forwaring, aaelony, it just seems like that would be a weird way for things to work
15:24nopromptoh geeze. nm. i see what's going on.
15:24aaelonyamalloy: thanks, I'll tinker a bit more…
15:24nopromptso it seems to me like extending protocols to object can be a bad idea, no?
15:25nopromptin cljs that is.
15:26llasramaaelony: What's the value of DISPLAY w/in the emacs (and parent screen) process? After removing the extraneous headless JVM arg, that seems like the most likely thing to check
15:26nopromptor at least certain protocols seem like a bad idea. ILookup being one of them.
15:27amalloynoprompt: that does sound dangerous
15:27nopromptcause say you implement ILookup for object then you create a new type and you also want to implement ILookup for it, you're fucked.
15:27amalloyuhhhh, don't cljs protocols obey the inheritance tree just like jvm protocols?
15:27dnolennoprompt: that's how protocols work
15:28dnolennoprompt: we might start issuing warnings about multiple implementations
15:29bbloomnoprompt: you should only extend a protocol to an object if you own (logical-or the-protocol the-object)
15:29bbloomor s/the-object/the-type/
15:30amalloydnolen: really? as i understand the discussion, that's not how they work in jvm-clojure, and i didn't realize it was different
15:32aaelonyllasram: in screen the value is :0 , not sure how to check the value within emacs
15:33llasramaaelony: Eval (getenv "DISPLAY")
15:34llasramM-: (getenv "DISPLAY") RET
15:34llasramaaelony: Probably is :0 too though, which would be the problem -- the `lein repl` launched by emacs will inherit that value, and thus not connect to the correct forwarded port
15:35aaelonyllasram: confirmed that it is set to :0 in emacs as well
15:35llasramaaelony: You should be able to w/in emacs use `M-x setenv` to set DISPLAY to the correct value, then all should be good!
15:36aaelonyllasram: I thought the correct value was :0 though…. or perhaps I can try `hostname`:0.0
15:36llasramaaelony: Usually it'll be something like `localhost:10` in a forwarded session. Check what it *actually* is in the forwarded session where things work
15:37llasramAnd then don't close the SSH session which is forwarding X :-)
15:38aaelonyllasram: can I check the forwarded session from emacs? where is that exactly? thx
15:39nopromptbbloom: i think that's sound advice.
15:40llasramaaelony: You mean w/o launching `lein repl` and seeing if you get explosions? You can always `M-!` an random X program, like `xdpyinfo`
15:41aaelonyllasram: hey, it worked!! within emacs did a (setenv "DISPLAY" "localhost:10") and voila!
15:41nopromptfwiw here's a gist of console macros for clojurescript https://gist.github.com/noprompt/6428301
15:42aaelonyllasram: awesome thanks :)
15:42llasramaaelony: Glad to help
15:44noprompti think the key with cljs is not fighting js.
15:45rurumatednolen: posted it here: http://bit.ly/1dDPCpV
15:47noprompti'm kind of surprised there isn't a clojurescript contrib or clojurescript.tools project for some of this shit. seems like every cljs project has some sort of console.log wrapper.
15:49nopromptwould it be of any benefit to someone if i just put these macros in a clojar? seems like that would make sense.
15:51amalloynoprompt: it doesn't really seem like those should be macros
15:52nopromptamalloy: not all of them, no.
15:52amalloyalmost none of them
15:52nopromptamalloy: most of those take a variable number of arguments and you can't use apply.
15:53amalloyyou can use apply, it's just a little less convenient
15:53amalloy(.apply (.-log js/console) js/console args) looks right from a quick glance at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
15:54nopromptamalloy: oh yeah, i forgot about the context part.
16:01robinkI have a small Java interop problem
16:01robinkWhen calling a method on a class instance (Rtf/rtf), I get the following exception: ClassCastException java.lang.String cannot be cast to [Ljava.lang.Object; user/eval1243 (form-init9112115781670751618.clj:1)
16:02robinkI know this is a question best asked in ##java, but I'm really flummoxed as to what I'm doing wrong.
16:06danlentzhello clojurers; I'm coming from a background in common-lisp and I was wondering if there was a clojure equivalent to "the idiot's guide to symbols and packages" which was a document I found very helpful at demystifying the basic issues when I was learning CL
16:07callendanlentz: http://www.infoq.com/presentations/Clojure-Namespaces-Vars-Symbols
16:07callendanlentz: I think you'll find it very educative. I came from CL and found that talk extremely helpful.
16:07scgilardirobink: some argument you're sending needs to be an array of objects, but you're providing a string. is this a variable-arity function in java? you'll need to pass an explicit object array from Clojure.
16:07danlentzcallen: thanks that looks good
16:08robinkscgilardi: Lemme look at the source to see what it expects.
16:09nopromptamalloy: thanks for pointing that out.
16:09bbloomdnolen: writing code in continuation passing style is my least favorite thing ever
16:10bbloomdnolen: and it doesn't even solve the fucking problem i have… i need a trampoline....
16:10dnolenbbloom: heh what are you doing?
16:10bbloomdnolen: CPS works for async calls b/c the call occurs in some dispatcher loop elsewhere
16:10bbloomdnolen: i'm experimenting w/ the effect system stuff more
16:11dnolenbbloom: oh yeah, the trampoline is the host event loop
16:11danlentzis it bad style to expect something like (def rdf/type " "http://www.w3.org/1999/02/22-rdf-syntax-ns#type&quot;) to work? IE defining symbols in packages other than the "current"?
16:11bbloomdnolen: i have a working interpreter, but it stack overflows in a lot of cases
16:11bbloomdnolen: b/c i'm doing some crazy stack hackery
16:11bbloomdnolen: w/o tail calls, restartable exceptions, etc it's absurdly hard to code those things in to your own interpreter w/o extreme care and verbosity
16:12robinkscgilardi: public static RtfTextPara p( Object... texts )
16:12robinkscgilardi: It wants an array? A list? A sequence?
16:12amalloydanlentz: it blatantly doesn't work, so i don't see how style is relevant
16:13scgilardia java array. see clojure.core/into-array
16:14scgilardi(you'll probably want the 2 arg version to avoid making the array the same type as the first item in the seq you pass in)
16:15danlentzamalloy: yes I've seen that. I was just wondering if there was a succinct reason why it should not. sorry i probably phrased the question poorly
16:15callendanlentz: try to learn more before proceeding.
16:15callena book and that talk is a good place to start.
16:15danlentz:)
16:15robinkscgilardi: 'k, thanks, will try
16:15callendanlentz: clojurebook.com
16:16danlentzk thanks; I will do that
16:16SegFaultAXAre ido-mode and org-mode minor modes?
16:17robinkscgilardi: Doesn't throw an exception, but returns nil when I call .p with (into-array "My single string"). I think I may be hitting bugs in jRTF now. Thanks for your help with the Java end of things.
16:17hiredmanorg-mode is pretty major
16:17SegFaultAXLet me ask my real question: how does one quickly find a file in their project
16:18SegFaultAXWithout typing the whole path
16:18SegFaultAXLike ctrl-p for vim
16:18llasramSegFaultAX: I use ido-mode + find-file-in-repository
16:18SegFaultAX(I'm trying to follow that tutorial posted earlier on HN for getting started in emacs. I'm a vim user)
16:20SegFaultAXllasram: Does that do fuzzy matching?
16:20amalloySegFaultAX: you can turn on fuzzy matching for ido
16:20llasramSegFaultAX: You can configure ido to do various kind of fuzzy matching
16:20llasramSegFaultAX: I just do filename substrings myself, but there's other options
16:20SegFaultAXamalloy: How?
16:20SegFaultAXOr what's the best way for an emacs newb?
16:21amalloySegFaultAX: i just turn on ido-enable-flex-matching
16:21amalloythere may be other options
16:21scgilardirobink: you're welcome
16:21SegFaultAXamalloy: Is that M-x what you just typed in?
16:21robinkscgilardi: and now it's fixed completely. Thanks very much :-)
16:21amalloyM-x customize-variable RET ido-enable-flex-matching RET
16:21scgilardisweet
16:22danlentzi'm glad to see how vibrant the clojure community t is -- an exciting difference from the sometimes echoing halls of CL. Thanks for the help, guys.
16:23amalloyhonestly i don't think flex matching has provided me any additional benefit over ido-mode, but doesn't hurt to turn it on
16:23dnolenbbloom: so dead end? or you got another plan?
16:24SegFaultAXamalloy: So if I wanted to navigate to a deeply nested file, I still have to type all the intermediate dirs?
16:24bbloomdnolen: i'm gonna replace my Evaluable protocol's eval method with an extend-k method. nothing will do any actual work, instead it will take a machine & return a new machine with an extended continuation. will be slow as hell, but i'm fine with that for now :-P
16:25amalloySegFaultAX: yes, though llasram's suggestion of find-file-in-repository may help, i dunno
16:25SegFaultAXamalloy: No that's fine for now.
16:25SegFaultAXOne does not simply switch from vim to emacs...
16:27gfredericksclojurebot: org-mode is pretty major
16:27clojurebotOk.
16:27SegFaultAXBut is it technically a major mode?
16:28callenSegFaultAX: yes but it supports editing code blocks in their native major mode.
16:29callenSegFaultAX: there's also outline-minor-mode that provides some of the org-mode look and feel in other major modes.
16:29SegFaultAXcallen: So when that article says that only one major mode can be active, he's kinda sorta lying?
16:29arohnerwhat was the name of the DSL for constructing regexes?
16:29technomancySegFaultAX: find-file-in-project lets you jump straight to deeply-nested files with ido
16:30SegFaultAXtechnomancy: When I do M-x find-file-in<tab> I get no completions
16:30callenSegFaultAX: major-mode combinators are...you don't want to go there unless you're an Emacs wizard. Assume it's true.
16:30technomancySegFaultAX: it's a third-party function
16:30SegFaultAXOh!
16:30callenand just bucket org-mode's functionality as magic.
16:31SegFaultAXHow do I install it? (emacs 24.3)
16:31technomancyhttp://marmalade-repo.org/packages/find-file-in-project
16:31SegFaultAXThanks
16:31technomancynp
16:32futileI must prefer https://github.com/hoffstaetter/find-file-in-repository
16:32SegFaultAXOh man, find-file-in-project is awesome.
16:32futile*much
16:32futile\cc SegFaultAX
16:32callenSegFaultAX: just be prepared to tweak the file extensions variable.
16:32callenand the project decls.
16:32callenbut yeah, ffip is nice.
16:33futilegenehack: with find-file-in-repository you don't need to tweak those things callen is talking about
16:33futilei mean SegFaultAX
16:33futiledangit
16:33callenfutile: I need to investigate this. thanks.
16:34futilecallen: the only time ffir has let me down is when I want to jump to a new file I haven't committed yet
16:34callenyeah that looks promising because @work uses hg. Tragically.
16:34callenfutile: potentially problematic but probably worth it anyway.
16:34callenthanks for the heads up.
16:34futileyup
16:34futilenp
16:34futilein melpa
16:36SegFaultAXtechnomancy: Starter kit is awesome! :)
16:36callenfutile: meh, installed it myself. Works brilliantly, thanks.
16:36futileheh
16:36technomancySegFaultAX: ehrm... it's okay.
16:36SegFaultAXtechnomancy: Well I don't know any better.
16:36callentechnomancy: isn't it moderately out of date/unmaintained?
16:36futileI wrote my own emacs starter kit once
16:37technomancycallen: more that it's The Wrong Thing
16:37SegFaultAXtechnomancy: Oh, what do you mean?
16:37futileDang, I wish I didn't delete this: http://lists.gnu.org/archive/html/help-gnu-emacs/2013-04/msg00040.html
16:38technomancylumping together unrelated functionality without any docs encourages cargo-culting without a deeper level of understanding
16:38SegFaultAXtechnomancy: That's exactly my argument against eg janus.
16:38technomancyhttps://github.com/technomancy/emacs-starter-kit/blob/v3/README.markdown <- SegFaultAX, callen
16:38gfrederickswe need to encourage cargo-culting with a deeper level of understanding
16:38SegFaultAXgfredericks: Your talk is next in my queue. ;)
16:39gfredericksSegFaultAX: cool, let me know if it's any use
16:39technomancyapplies to all "starter kits" including prelude, emacs-live, etc
16:39callentechnomancy: yeah, I tend to agree.
16:40TimMctechnomancy: Make one that self-destructs. "You have 30 days to grok this example setup before it wipes itself from your computer."
16:40SegFaultAXtechnomancy: Janus is particularly egregious in that it doesn't even function the way normal vim plugins are /supposed/ to function.
16:40callenTimMc: me gusta.
16:40technomancyTimMc: oh man that would be awesome
16:40technomancycallen: it made more sense back before package.el was usable
16:40callentechnomancy: sure.
16:40callentechnomancy: or you just do what I do and have an artisanally crafted Emacs setup.
16:41callenI know exactly what's in the path because I meticulously accumulated and installed all the packages and dependencies myself :P
16:41Brand0emacs-live
16:41technomancycallen: that's the goal of ESK v3
16:41callenBrand0: is a bad idea.
16:41technomancycallen: a prose guide to encourage people to learn and experiment on their own
16:41callentechnomancy: anybody using package.el would have considerably less work ahead of them than I put in.
16:41callentechnomancy: my dotfiles repo is based on ancient tarballs I would update from way back
16:41SegFaultAXThe biggest heartache for me right now is the lack of hjkl
16:42callenand then rsync and install wherever I lived.
16:42callenSegFaultAX: evil-mode?
16:42SegFaultAXI /really/ hate the arrow keys
16:42SegFaultAXcallen: No.
16:42callenso use --- okay.
16:42SegFaultAXcallen: I know there is no correct way to use emacs, but I'd like to have at least basic muscle memory in place before switching.
16:43callenSegFaultAX: fair enough.
16:44SegFaultAXPlus I feel it'll confuse me if both editors have pretty close but not identical mappings.
16:44technomancyuncanny valley
16:44SegFaultAXI'll start doing M-x in vim. :)
16:44callenSegFaultAX: well at least you're using a real editor now.
16:45rasmustoSegFaultAX: evil-mode isn't really that intrusive, so long as you know what default bindings it touches
16:45SegFaultAXrasmusto: But I don't know, that's the whole point of not switching until after I get comfortable with vanilla emacs.
16:45rasmustoSegFaultAX: I can't do arrow keys, so I use evil-mode
16:46rasmustoSegFaultAX: but yeah, I get your motivation
16:46robinkIf I'm doing interop with a Java library that suggests that people write Class.initializer.call.chain(somemethod("Value"), somemethod("Anothervalue"));, how would I correctly call "somemethod" when it's not an explicit method of the current instance (i.e. the last expression evaluated in doto), nor is it a method of its parent class?
16:46callenrasmusto: he's walking the golden path, leave him be :)
16:46rasmustocallen: M-x golden-path-major-mode
16:46SegFaultAXcallen: :)
16:47callentoday is a, "have a beer glass full of tea and whiskey" day because I'm sick. Also I'm writing Clojure. You win some, you lose some.
16:47callenGetting weird looks from coworkers because a beer glass full of tea and whiskey just looks like a glass full of whiskey.
16:47gfredericksrobink: what is it a method of? your code doesn't look like valid java anyhow
16:48robinkgfredericks: It's paraphrased valid Java for a Java library.
16:48hiredmanrobink: they are most likely static methods and they expect you to do a static import
16:48robinkgfredericks: and I probably need to know what somemethod is a method of before I even ask this question
16:48robinkhiredman: Ahh, OK, thanks :-)
16:48hiredmanhttp://en.wikipedia.org/wiki/Static_import
16:49robinkhiredman: Indeed, that's the first thing the documentation page has you do in Java. I wrongly assumed that (ns user (:import [com.tutego.jrtf Rtf])) would suffice.
16:49callenhiredman: how is there a whole wikipedia article about one language feature?
16:50gfrederickshiredman: yeah how did you let that happen
16:53hiredmangfredericks: huh?
16:54gfrederickshiredman: nm, just ineffective levity
17:00llasram"ineffective levity" would make a great name for a band/tumblr
17:02sandbagsonly 3 hits on Google... prime territory!
17:05futileReleased 0.1.0 of my testing lib :)
17:05futilehttps://github.com/sdegutis/nevermore
17:06futilewooooo
17:08SegFaultAXHow can I make all my splits the same width in emacs?
17:08technomancySegFaultAX: M-x balance-windows
17:08SegFaultAXtechnomancy: Thanks!
17:09technomancynp. the #emacs channel is pretty good too.
17:09rasmustothere's always something interesting going on in #emacs
17:09technomancythough it's more recommended for overall hilarity and jocularity than on-topic advice
17:12futilei dunno, they didnt take too well to my trolling
17:20callenfutile: don't troll #emacs, they're good people :)
17:21technomancyalso they get so many trolls that they have a strong immune system
17:21futilethen i probably should have tried harder than saying "emacs sucks!" and /parting quick
17:22futileto be fair though, emacs is a breath of fresh air compared to having healthy fingers
17:22futilebuh dum tshh!
17:22rasmustofutile: stop jk'ing
17:23futileok
17:23technomancyhttp://technomancy.us/62
17:23technomancyfutile: ^
17:24rasmustotechnomancy: man 6 vi
17:24futiletechnomancy: :( that only makes me feel inferior about my trolling skills
17:25technomancyyou gotta take your game to the next level with that crowd
17:25futileyou know us trolls are so insecure about our ability to make people feel insecure
17:25technomancytrolls within counter-trolls
17:25technomancymaybe a twist ending
17:25technomancyoh crap he's doing it
17:25technomancyshoulda kept my mouth shut
17:26technomancy<_>
17:26technomancyoops
17:26technomancy>_<
17:26rasmustotechnomancy: i prefer the disappointed/sad eyes in this case
17:33futilethat wasnt very fun
17:33technomancyyou need to operate in stages
17:34technomancywhere up front it seems completely reasonable, and as people dig deeper and deeper new levels of insanity present themselves
17:34technomancywhile attempting to maintain plausibility through the whole thing
17:36futilebut i was doing that
17:37technomancytoo implausible too soon
17:37technomancyneeds to be more gradual
17:38callentechnomancy: nice :)
17:40technomancyI spend a lot of time on IRC
17:41technomancyit is an art
17:44futiletechnomancy: wat? its totally plausible
17:46technomancyno, this one is better but you'd have better luck parting and rejoining with a different nick
17:47futilehmm maybe
17:48futiletechnomancy: no, theres a whole history here you're not seeing
17:48futiletechnomancy: im a computer collector and i know my stuff, thats why i can write a better emacs that works efficiently on old hardware
17:48technomancyah I see; it's part of a master plan coming together
17:48technomancymore than meets the eye
17:49futileucb: i can only hope
17:49ucbdon't reel me in man, I'm not here
17:50technomancy«like racket, except "done right"» <- now you're cookin'
17:50hyPiRiontechnomancy: haha
17:51hyPiRion«Like Clojure, but with a focus on immutability»
17:54futile:'(
17:55futiletechnomancy: its a long term project
17:58bbloomis it just me, or does everybody else's usage of deftype/defrecord, etc seem to follow a sine curve?
17:58futileI've.. never used it.
17:59technomancydo_not_want.jpg
17:59bbloomi tend to write a lot of code that looks kinda like product types by stuffing stuff in to a vector [:like this with args]
17:59bbloomthen i write multimethods with dispatch function first
18:00bbloombut occasionally, i need to interface w/ a protocol somewhere & that kinda sucks
18:00hyPiRionI just use multimethods and get over with it
18:01futileThere's one multimethod in my code and I'm regretting it and looking for a way to get rid of it.
18:01futileJust because these 2 things have a similar property doesn't mean they can be grouped together :/
18:02ToxicFrogmultimethods \o/
18:03bbloomthe biggest issue i have is when you kinda have two-phase things
18:04bbloomlike if you have some data structure & then want to "compile" that in to some other shape, then run your program against the compiled structure
18:04bbloomif both the source and destination structures are just trees of maps/vectors, then you have to be careful to have strict phase separation
18:05bbloomlike you can't have a phase 2 thing inside your phase 1 tree, unless you add some kinda of wrapper [:pre-compiled phase-2-stuff-here]
18:05bbloomor you have to have totally disjoint sets of keywords for that 0th vector position
18:06hiredmanbbloom: macro expansion
18:06hiredmanthe output of a phase should be valid input for any phase
18:07bbloomhiredman: that's not realistic if the phases have different features. that works for "expand" or "simplify" phases, but not for "translate"
18:08hiredmanwhy not?
18:08bbloomb/c the output of phase 2 might be totally nonsensical as input to phase 1
18:08hiredmanwell, that is what I am saying, don't do that
18:09bbloomlol, yeah, i realize you're saying that: i'm saying that's not realistic. phase 1 might be macro expand but phase 2 might be translate to some language which doesn't have macros, but has some other thing that phase 1 doesn't understand
18:10hiredmanI am not saying literally use macros, I am saying the process can be modeled like macro expansion
18:12bbloomhiredman: i understood that. my point is that given two schemas A and B, you can't necessarily rely on the fact that B is a subset of A, which is the case with macro expansion
18:13bbloomhiredman: in my case, i have two phases and 3 schemas. the relationship between schemas A, B, and C are defined by transforms 1 and 2. the process is not circular nor does any part iterate to a fixed point, like a macro expander
18:15futiletechnomancy: besides, who says all that stuff wasnt true? who says im trolling?
18:15hiredmanbbloom: why not? you are basically writing an interpreter/compiler with 3 phases, why not do them as an expander
18:16mgaarefutile: what are the system specs for your new editor? I'm looking for something I can run on my Tandy 1100HD
18:16callenmgaare: lol
18:16futilemgaare: yes.
18:16bbloomhiredman: macros are interpreted by implicit expansion and iterated to a fixed point. my data must be explicitly transformed, which also precludes fixed point iteration
18:16futilemgaare: my new editor will be much more efficient therefore it requires a retina MBP
18:16technomancyfutile: yeah, that one had some nice touches
18:17technomancythe hare-brained "I know I'm right" scheme implementor schtick has legs
18:17futiletechnomancy: you're only saying that because you havent seen my implementation. if you saw it youd agree.
18:17futiletechnomancy: if you want to join the venture as a profit-sharing LLC then i can show you
18:18futiletechnomancy: but i require a minimum 20+hours a week and you get 35% profits after first 12 months
18:18hiredmanbbloom: it just means instead of a single transform you need a transform and a predicate to determine if the transform is valid to be applied to a given tree
18:18technomancyfutile: where do I sign the NDA?
18:18MisterSinisterHi everyone! I thought this would be a good place to ask: I wanna check if a string contains a matched number of parentheses. I know I can do this with loop-recur, but I was wondering if there was a way to do it with the Clojure sequence stuff that didn't involve loop-recur. Could someone help me out?
18:18futiletechnomancy: youll have to fly to my office. does tomorrow work?
18:19futiletechnomancy: also pack enough things, theres no time to lose adn we'll need to get started tomorrow so youll be away for a while.
18:19justin_smithMisterSinister: this is a 4clojure puzzle I just did the other day!
18:19technomancyfutile: can you squirt it to my zune?
18:19MisterSinisterjustin_smith: OK. How did you do it?
18:19justin_smithloop
18:19justin_smithhah
18:19MisterSinisterFigures.
18:19hiredmantechnomancy: no, he'll mail you a flier you can scan with your cuecat
18:19futiletechnomancy: im getting the feeling you arent taking this business proposal very seriously. im having second thoughts about hiring you on.
18:19MisterSinisterThat's what I'm using, but I was wondering if there was something less ugly.
18:20justin_smithMisterSinister: reduce should be able to do it
18:20justin_smithnow I am thinking of translating...
18:20MisterSinisterActually, that's a *brilliant* idea.
18:20MisterSinisterLet me just try it now.
18:20technomancyhiredman: had to hit up wikipedia for that one
18:21edwI am utterly perplexed by the following Java-ism, and I have no idea how to interop with it. Could someone help me out? Given a DbxAccountInfo instance, how do I use Reader? http://bit.ly/15qOpdB
18:22amalloyDbxAccountInfo/Reader
18:22amalloyit's a global
18:23hiredmantechnomancy: they were great
18:23futiletechnomancy: just because you dont trust my expertise and experience in silicon valley doesnt mean a thing. ive been around the block son i know my stuff. but anyway sounds like you have other more lucrative opportunities (were it possible) so good luck to your enddavors
18:23justin_smithMisterSinister: the trick is immediately returning false if you have too many close tokens without opens
18:24MisterSinisterYeah, that was pretty much what I was thinking. I'm just trying to code it right now.
18:24MisterSinisterBut thanks for the suggestion - I never even *considered* reduce, for some strange reason.
18:24mgaarecan't really do that in the reduce though can you?
18:24MisterSinisterI've only been working with Clojure for a year, and I come from a Java background.
18:24MisterSinistermgaare: Yes you can.
18:24MisterSinisterHave reduce return an integer.
18:25MisterSinisterI think it can be done, anyway.
18:25mgaareMisterSinister: I think regardless of what you return in your reduce function, reduce is gonna keep plodding on through the rest of the input collection
18:25MisterSinistermgaare: Have some kind of 'dummy' value that basically ignores all subsequent input and returns itself.
18:25MisterSinisterFalse would be a good candidate.
18:27mgaareyes, I agree that you do some stuff to handle the situation, but it seems somewhat wasteful in the face of a string like this: ")abc123 ..." followed by 2 billion characters :D
18:31justin_smiththere is "reduction
18:31justin_smith"
18:31justin_smithin clojure 1.5+
18:32jkkramer,(doc reduced)
18:32clojurebot"([x]); Wraps x in a way such that a reduce will terminate with the value x"
18:32justin_smithimmediately jumps out of the reduce
18:33MisterSinisterAh, that would be easier.
18:37MisterSinisterOK, got an answer.
18:37MisterSinisterBut not using reduced.
18:37justin_smithwhy not reduced?
18:37MisterSinisterJust wanted to make sure my original code worked. Now I wanna try and do it with reduced.
18:37MisterSinisterBut you are right - reduce *can* do it with the right function.
18:38MisterSinisterIs there an example of using reduced somewhere?
18:38MisterSinisterI've never actually used it before, and I learn best from examples.
18:39MisterSinister(Also, why the hell didn't I come here before?)
18:39dissipate__what's the best way to validate an email address in clojure?
18:39justin_smithMisterSinister: my kind of ugly version https://www.refheap.com/18275
18:39MisterSinisterdissipate_: What do you mean 'validate'?
18:40justin_smiththe only true way to validate an email address is to send mail and not fail
18:40dissipate__MisterSinister: that it conforms to the RFCs for a well formed address
18:40justin_smithemail is weird
18:40MisterSinisterjustin_smith:Yours is more thorough than mine. Here's what I have: https://gist.github.com/anonymous/6430320
18:40MisterSinisterdissipate_: Regular expression?
18:40MisterSinisterIsn't that how pretty much everyone does it?
18:41dissipate__justin_smith: no, aren't there parsers?
18:41justin_smithhave you ever seen the actual rfc for valid email? it is fucking insane
18:41qz_heya, is pmap doing anything super-special compared to normal map? i hava jdbc throwing 'java.sql.SQLException: No suitable driver found' when running with pmap and its all fine with map
18:41justin_smithhttp://en.wikipedia.org/wiki/Email_address#Syntax
18:41dissipate__justin_smith: i have. believe me, i don't want to code that.
18:41justin_smithhttp://en.wikipedia.org/wiki/Email_address#Valid_email_addresses
18:41dissipate__justin_smith: what's the best way in clojure?
18:42justin_smithgood luck with a re that matches the good ones and not the bad ones
18:42MisterSinisterjustin_smith: Point taken.
18:42justin_smithsend an email, if it goes to recipient, address is good
18:42justin_smith"!#$%&'*+-/=?^_`{}|~@example.org" is a valid address
18:43dissipate__justin_smith: that's not good to send an email to every address. you can get black listed as a spammer. you know that right?
18:43ToxicFrogdissipate__: don't. Just don't. If you try to valid the email addresses as well formed, you will reject valid addresses and then your users will be unhappy and send you angry emails from addresses your software claims are invalid.
18:43mgaareI think google made a java library for this dissipate__
18:43MisterSinisterNow to figure out how the hell reduced works...
18:43dissipate__mgaare: right, but is there a 'clojure' way of doing it, or does everyone just call the java function?
18:44MisterSinisterBut in any case, thanks for the suggestion - never would have figured it.
18:44justin_smithMisterSinister: (reduced value)
18:44justin_smithinside the body of the function called by reduce
18:44MisterSinisterOh, is that all?
18:44MisterSinisterOK... let me try something.
18:45justin_smithone sec, checking, my main clojure is 1.4 for lib versions
18:45justin_smith*lib reasons
18:45MisterSinisterI use the latest, because I just have Leiningen build me stuff.
18:45mgaaredissipate__: SOP in clojure is to hop on a mature java library :D
18:45justin_smithMisterSinister: some libs don't work with 1.5 yet, ones I use
18:46dissipate__mgaare: SOP?
18:46MisterSinisterjustin_smith: I guess we do rather different code. I'm a Master's student, and my code is all algorithm implementations.
18:46MisterSinisterdissipate_: Standard Operating Procedure.
18:46justin_smithMisterSinister: backend web dev
18:46MisterSinisterjustin_smith: That would make sense.
18:46dissipate__MisterSinister: i see. that can potentially generate side effects though.
18:48justin_smithMisterSinister: oh, it is not reduction, it is reduced
18:48MisterSinisterReduced gives the intermediate steps, right?
18:48justin_smithnope
18:48MisterSinisterNo, wait, that's reductions.
18:48MisterSinisterDerp.
18:48justin_smithshort circuits if called
18:48justin_smithends the loop
18:48justin_smith,(reduce (fn [arg _] (reduced arg)) (range))
18:48clojurebot0
18:49justin_smithyay, reduce on an infinite list
18:49MisterSinisterSo that just halts on 0?
18:49dissipate__justin_smith: is that a lazy reduce?
18:50MisterSinisterOK, thanks for that. That'll give me what I need to work with.
18:50justin_smithdissipate__ it just short circuits
18:51justin_smithbails out of the loop
18:51coventryIs there an existing tool which will identify which subforms of a fully macroexpanded form will not get evaluated? (E.g., the contents of quoted lists or the bound symbols in binding forms)
18:51dissipate__justin_smith: isn't that a feature, not a bug?
18:52justin_smithyup
18:52justin_smiththat is why short circuit was a bad choice of words
18:52dissipate__coventry: sounds like a macro could do that
18:52MisterSinisterI'm still so noob at macros.
18:52MisterSinisterBut then again, I come from a Java background, and have only been using Clojure for a year.
18:53MisterSinisterAnd even then, I only really do it for algorithm implementations.
18:53justin_smithMisterSinister: we should follow each other on 4clojure, we would probably both learn a few things
18:53justin_smithI am noisesmith on there
18:53MisterSinisterI'm mistersinister, I *think*. Haven't logged in for a while, though.
18:53MisterSinisterLet me just check.
18:54dissipate__justin_smith: you haven't solved all of the problems on 4clojure?
18:54coventrydissipate__: It's not obvious how a macro would help here.
18:54justin_smithnot yet, only started a month ago
18:54justin_smithdissipate__: you have?
18:54MisterSinisterjustin_smith: mrsinister, as it turns out.
18:54coventryI think I can repurpose riddley.walk for this.
18:54dissipate__justin_smith: hellll no. i barely started on there. some of those problems only have like 50 people who have solved it.
18:55MisterSinisterdissipate_: Some of those are really interesting.
18:55MisterSinisterI liked the DFA one.
18:55MisterSinister(Since I have to do stuff related to automata theory)
18:55dissipate__coventry: you have a macro that takes in the macro expanded form and detect the subforms that are quoted etc.
18:56justin_smithwhy make it a macro? just walk the tree, and find calls to quote
18:56MisterSinisterjustin_smith: You're gonna laugh. Look at your 4clojure account settings, and check the code snippet in the formatting box....
18:56justin_smiththe form is just a list - or would you get the form as arg, not macroexpanded?
18:57dissipate__justin_smith: what if the argument is a macro?
18:57coventryjustin_smith: It's more than just calls to quote. The symbol "a" in (let [a 1] (foo)) does not get evaluated, either.
18:58justin_smithahh, yeah
18:58justin_smithMisterSinister: what am I looking for? oh, the default syntax, lol
18:59dissipate__coventry: does what i said make sense?
18:59MisterSinisterAnyways, thanks for your help. I will *definitely* be around more.
19:00dissipate__justin_smith: are you taking into account the fact that macro expansion order is the reverse of function call order?
19:01justin_smithdissipate__ not at all, but what about writing the function to take the fully expanded form as its input? any reason not to do it that way?
19:02justin_smithbecause the problem doesn't seem like one of creating syntax, but of investigating some form
19:03coventrySorry dissipate__, you're not making much sense to me. Macros have no obvious role in the problem I've described. I do want this function in order to make a macro, though.
19:05justin_smithI wish it was easier to browse a followed person's answers on 4clojure
19:07SegFaultAXjustin_smith: Submit a patch!