#clojure logs

2013-10-25

00:11sritchiehey all --
00:11sritchiedo you guys have a rec for functional reactive programming libraries for Clojurescript?
00:12tbaldridgesritchie: I'd look into core.async. You'll probably find that it's much more sensible than FRP
00:13sritchietbaldridge: okay, that's fair. I've been following dnolen's examples
00:13sritchiejust trying to figure out how all of the pieces fit together
00:13tbaldridgesritchie: FRP tends you put you into a world where you have to put everything into a FRP world. Core.async makes it easier to mix event streams into existing code.
00:15sritchiecool. just found a good todo list example
00:15sritchieshould be perfect
00:21bitemyappseangrove: not yet, but there have been rumblings of cljx.
00:21ddellacostasritchie: not that I disagree with tbaldridge--I've found core.async a real blessing--but this is useful if you want to investigate FRP in Clojure(/Script) further: http://kevinoncode.blogspot.jp/2013/05/a-short-survey-on-state-of-functional.html
00:22bitemyappsritchie: I'm with tbaldridge. I had a pretty easy time mixing core.async into a work project without having to remodel everything in terms of FRP
00:23sritchiegood to know - I'll go core.async, and play with FRP in Scala (in the upcoming coursera class)
00:23sritchieone more qq, as it looks like we've got some clojurescript folks around -
00:23justicefriesooh, mind linking to the coursera class?
00:23sritchiesure, one sec
00:24sritchieThis is the "intro the scala" course on Coursera, supposedly really good: https://www.coursera.org/course/progfun
00:24sritchieI'm at Twitter, and a bunch of folks here took this and loved it
00:24sritchieand this is the sequel, Principles of Reactive Programming: https://www.coursera.org/course/reactive
00:25sritchieErik Meijer wrote that Reactive Manifesto, and Odersky wrote scala, so good instructors
00:25sritchieone more qq - lein-cljsbuild seems to be the tool of choice?
00:25sritchieand it looks compatible with cljz?
00:25sritchieerr
00:25sritchiecljx
00:25bitemyappsritchie: lein-cljsbuild is the tool of choice.
00:26bitemyappsritchie: I would just mention that cljs isn't required to experiment with core.async if that is exclusively what you have in mind.
00:26sritchiebitemyapp: yup, I've played with it in clojure - I'm working on a race timing system,
00:27sritchieand want to update my app to show live results on each race page
00:27sritchieso core.async + websockets + cljs seems like the way to go there
00:27seangrovesritchie: Sounds like a pretty good match, yeah
00:28sritchieJust trying to figure out if the right way to start sharing code; looks like cljsbuild's crossovers will do it
00:28sritchieand I'm not seeing pitches for cljx; but I'll play with both
00:28bitemyappErlang users have to be pissed that their concurrency model is getting co-opted into a marketing campaign for a different language.
00:28sritchieit's exciting to be back coding more clojure!
00:28bitemyapppi-calculus not-withstanding
00:29sritchiehaha
00:29bitemyappsritchie: if I know Haskell and Clojure, what do you think I would get out of learning more Scala?
00:29bitemyappyou seem best positioned to know out of most here.
00:30sritchiebitemyapp: if you know Haskell already… the eye opener for me was an understanding of the type system, but that won't be new for you
00:30bitemyappThe primary utility of Scala over Haskell for me would be the JVM, which is fine, but I'm wondering what I could *learn*.
00:30sritchieyes, for sure
00:30sritchielearning Scala taught me a lot about proper object oriented design
00:30bitemyappsritchie: I've already been poking my nose around Scalaz. I'm a Fluokitten nut in Clojure too :P
00:31bitemyappproper OOP? I think you just tripped over the Clojure anti-shibboleth. ;)
00:31sritchiehaha
00:31sritchieI was terrible at writing these libraries when I first started, not trusting the type system;
00:31sritchiebut I find myself using records and protocols in Clojure much more heavily now
00:31bitemyappI think given the history of the compiler, I wouldn't trust it either >:P
00:31sritchie:)
00:32sritchieas a way to write Clojure libraries that are extensible by the user
00:32bitemyappsritchie: multimethods are fine too ;_;
00:32technomancywhen I was playing with OCaml, it seemed like the whole point of using records was to get exhaustiveness checks from pattern matches
00:32technomancywhich was very cool
00:33technomancybut not applicable at all to untyped clojure
00:33bitemyapptechnomancy: seems like a cherry-picking of what Haskellers use monads for.
00:33bitemyapppretty interesting.
00:33sritchietechnomancy: yeah, you end up just hoping you don't forget one of the damned types, and adding nodes only with much thought
00:34technomancysritchie: does scala give you exhastiveness checks on matches too?
00:34sritchieyup
00:34technomancyhandy
00:34sritchieyou can do algebraic data types with the pattern of
00:34sritchiesealed trait A; case class B extends A; case class C extends A;
00:34sritchie"sealed" means that all implementations are found in that file
00:35technomancydoes typed clojure cover core.match yet?
00:35technomancythat could be a stretch goal =)
00:35sritchie:) I haven't played with core.typed yet; really excited that Ambrose has gotten so much support, though
00:37sritchiebitemyapp: so, yeah, JVM, object oriented design, learning to lean on type inference and type classes;
00:37sritchiebitemyapp: another thing that Scala does really well (not sure what it maps to in Haskell) is implicit parameters
00:37sritchiewhich took a while to learn to think about
00:38sritchiebasically, a function can declare that it takes some parameter of type T implicitly (or many parameters); the type system has a series of scopes that it searches for declared variables of that type
00:38sritchieand the process works recursively
00:38sritchieit's type-safe dependency injection, basically
00:38sritchieand you can make the type system do a hell of a lot of work for you
00:38technomancycompiler-enforced dynamic binding?
00:39sritchieyeah, that's one way of putting it -
00:39sritchiefolks use this to pass around little environments, say by taking an implicit Config object on all methods -
00:40sritchiethen it can be used in the functions, but you don't have to actually pass it in each time
00:40bitemyappoh whoa.
00:40sritchiewe use it in the work I've been doing to build up these Monoid instances to do aggregation in analytics
00:41sritchiehere's one example (then I'll shut up about Scala in this channel :)
00:41bitemyappsritchie: I'm enjoying this!
00:41sritchiesay my function takes an (implicit monoid: Monoid[V])
00:41sritchie(a monoid is an interface with "plus", so it can add two Vs together to get a third V… super simple, not a Monad, just an Adder)
00:42bitemyappsritchie: Haskell does have this in case you were wondering.
00:42bitemyapp"Implicit parameters: dynamic scoping with static types", J Lewis, MB Shields, E Meijer, J Launchbury, 27th ACM Symposium on Principles of Programming Languages (POPL'00), Boston, Jan 2000
00:42sritchieokay, cool, shame on me to think they're missing any of this business :)
00:42sritchiea function that takes an implicit Monoid[V] basically "asks" the compiler for an instance of a Monoid for whatever V you actually used
00:43bitemyappYou know people wise-crack about how Emacs has an option or key combo for everything? GHC's compiler flags are like that.
00:43sritchienice
00:43sritchieso if I called that function with V = Map[String, Long],
00:43sritchiethe compiler would go do a search and find a function I wrote that declares the Monoid[Map[K, V]]
00:44bitemyapptype constraints on implicit parameters in Haskell are optional, due to the Damas Milner.
00:44sritchie(which is basically (partial merge-with <some-monoid-on-V>)
00:44bitemyappso the compiler will go on similar "search", but it'll do so with the most generalizable Damas Milner type signature for the function.
00:44bitemyappyou can constrain with a specified type if desired though.
00:44sritchieand then that function ALSO implicitly takes a Monoid[V]; so the compiler goes and finds that, and passes the final one in the the function I wanted.
00:44sritchiebitemyapp: okay, wild
00:45bitemyappit does require pausing for a moment to think about the most general applicable typeclass for your function is though.
00:45bitemyappleads to pretty reusable code, which is nice, since anybody can implement something for the same typeclass.
00:45bitemyappdoesn't have to be a specific impl or anything.
00:46sritchieScala does that with different implicit scopes
00:46bitemyappsritchie: are monoids common to your work because commutative operations are useful in your work?
00:46sritchieso you can override the default Monoid[Int]
00:46sritchiebitemyapp: yeah, we built this MapReduce library called Summingbird that uses them for that reason
00:46sritchiehttp://github.com/twitter/summingbird
00:46bitemyappI knew you worked on Summingbird, was just wondering in general.
00:47sritchiebitemyapp: so we as library implementers have been trying to solve the systems issues in terms of the algebraic properties of the V,
00:47bitemyappsritchie: how much cross-talk is there between Summingbird and Cascalog/Cascalog 2?
00:47sritchieand yeah, commutativity and associativity
00:47dobry-denWhat's the go-to method for writing the function (foo "ffff") -> 65535
00:47sritchiebitemyapp: after Summingbird was released I found a few days and rewrote the guts of Cascalog to make the planner implementation generic;
00:47sritchiewhich means that before clojure/conj we'll have a Storm planner
00:48dobry-den(unsigned numbers)
00:48bitemyappsritchie: one of the things I like about writing Haskell is that I can often just "guess" at the correct code and let the compiler inform me as to how to write what I meant. Do you find Scala lends itself to this as well?
00:48bitemyappalso, how do you deal with the slow compile times? this is a genuine concern if I'm doing the "mash build, get type error" event loop.
00:48sritchiebitemyapp: it still has java stack trace awfulness, but yes;
00:48bitemyappI'd heard about fsc but didn't know how much it helped.
00:49sritchieand the same loveliness with refactorings and large code changes as well
00:49bitemyappsritchie: oh pish. I write Clojure. I eat stacktraces taller than my desk for breakfast.
00:49sritchiehaha
00:49bitemyappsritchie: what about compile times? Does fsc help? Do you use anything for this?
00:49bitemyappa build cluster? :P
00:49sritchieno, it's freaking terrible
00:49sritchieon our large internal projects
00:49sritchieit's absolutely abysmal
00:49bitemyappthere's nothing to help with this?
00:50sritchiethere is,
00:50coventrydobry-den: ##(Long/parseLong "ffff" 16)
00:50lazybot⇒ 65535
00:50sritchieand Ensime + Emacs does a really good job
00:50sritchiebut we have an old pythonish build system at Twitter compiling our Scala,
00:50sritchieand it's just not good at incremental compilation
00:50bitemyappEnsime...handles the incremental compilation for you?
00:50dobry-dencoventry: How about for bigintegers?
00:50sritchiebitemyapp: yeah
00:50sritchieI think a lot of folks just use Intellij, which does use Zinc under the hood for incremental compilation
00:50bitemyappWhoa.
00:51bitemyappBrava my Emacs brethren, brava.
00:51sritchieyup, no compelling reason to leave emacs yet, even for Scsala
00:51sritchiefor java, hell yeah
00:51bitemyappsritchie: when you say pythonish build system...is this standing in for what people use sbt for?
00:51coventrydobry-den: Don't know.
00:51sritchiebitemyapp: yes
00:51sritchiewhoops, gotta run for some dinner --
00:51sritchieback soon
00:51sritchiefun talking about this stuff!
00:52bitemyappsritchie: please do come back. I have to go to a birthday thing but look forward to speaking to you more!
00:52dobry-dencoventry: nevermind, (BigInteger. 1 (hex-decode "ffff")) -> 65535
00:52dobry-denyeah, dumb question but ive been staring at my mess of hex/bytes/int converter functions for too long
00:53coventryHmm, where would you find the docs for that? It's not on http://docs.oracle.com/javase/6/docs/api/java/math/BigInteger.html
00:53dobry-dencoventry: yeah i was just there and saw this constructor: BigInteger(int signum, byte[] magnitude)
00:53dobry-deni guessed that 1 for signum is positive, 0 is negative
00:54coventryAh, I see.
00:54dobry-denim new to working with bytes/hex/number-overflow so ive been rewriting my code to just pretend everything is a biginteger
01:13dobry-denWhat would a Typed Clojure workflow look like? Do you add annotations as you go or are annotations more helpful when you want to 'solidify' your code?
01:15bitemyappdobry-den: I'd recommend adding them as you go.
01:48marcopolo2how does the cljs hash function work?
02:03marcopolo2nvm source code was pretty helpful
02:32arrdemis there a compelling reason to use something besides clojure.tools.reader for EDN?
02:34muhooarrdem: clojure.edn/read-string is what i use
02:35muhooor other things in clojure.edn namespace. is either included in 1.5.1 or as a transitive dependency of things i always include, not sure which
02:36muhoowhat's the tool of choice for creating api docs from a library that doesn't come with api docs?
02:36arrdemmuhoo: ok thanks. I knew there was tools.reader, but I couldn't find data.edn. yay naming consistency.
02:42arrdemugh. If I want function literals I'm stuck with "real" clojure, arn't I.
02:43Apage43meaning #(do stuff here) ? yeah, those aren't "in" EDN
02:43Apage43oh fun
02:44muhoojust use read-string
02:44arrdemhey guys, chord is begging to get unbant :P
02:45arrdemOkay. fooie.
02:45muhoonot the edn version. it evals, IIRC, and that's something to consider the security issues of.
02:46muhoo,(doc read-string)
02:46clojurebot"([s]); Reads one object from the string s. Note that read-string can execute code (controlled by *read-eval*), and as such should be used only with trusted sources. For data structure interop use clojure.edn/read-string"
02:46arrdemyeah so the issue I'm running into is that I need configuration files with embedded code. I really don't want to build a DSL, so that's probably just embedded clojure.
02:46arrdemthe security risks of having a directory of plugin source files that are assumed safe are obvious, but I fear unavoidable.
02:47Apage43that's leiningen, riemann
02:47Apage43your "configuration" is just a clojure program
02:48Apage43What's the trust model here?
02:49arrdemApage43: user provided configs eval'd on the users host. AKA none.
02:49Apage43I mean, if you don't actually have any reason to prevent input from any particular class of source from executing code, don't bother. It's a headache.
02:50arrdemOkie doke... (load-file) it is :D
02:51Apage43Hell, it's a feature :)
02:52arrdemhaha. If I really decide that I care I'll create a sandboxed ns and (load-file) in there. some other day once the prototype works.
04:38ChongLiyeah I keep dying to eels
04:38ChongLioops
05:18dobry-denAnybody on OSX Mavericks notice process `distnoted` taking up large chunk of memory?
05:21vijaykirandobry-den: yup - it has been like that since betas
05:22vijaykiranI keep killing it every now and then
05:27dobry-deni keep feeling like i have 5 zombie jvms running
05:28dobry-dennot sure why i upgraded. it was an impulse at 4am. anything to procrastinate sleep, even potentially breaking my environment
05:29dobry-denbut frankly the only thing ive noticed amiss aside from distnoted is Alfred
05:30dobry-den"define <word>", "spell <word>" no longer work which i depend on for sounding coherent on the internet
05:59degWhat is the compiler trying to tell me when lein jar suddenly starts failing on the first line of my program with "Exception in thread "main" java.lang.NoClassDefFoundError: clojure/tools/reader/reader_types/Reader, compiling:(server.clj:1:1)"
06:01mercwithamouthhas anyone tried Cider out yet? it's built on top of emacs-live....
06:02mercwithamouthi'm having a hard time understanding what it actually is...emacs-live seems overly damn complete
06:02mercwithamouthahh just an update to nrepl...m
06:02mercwithamouthnm*
06:17CookedGryphonHi, I'm trying to reflect all the public fields of some POD java objects
06:17CookedGryphonbean does exactly what I want, but isn't available on this platform
06:18CookedGryphonclojure.reflect is available and I can get a list of the symbols I want off the class but am having trouble turning that into a way of accessing the field on the object
06:35broquaintFYI my nrepl/cider problem was resolved by removing the *.elc files.
06:37ambrosebstechnomancy: core.typed support for core.match will happen
06:38ambrosebsCinC really helps, played around a bit already http://www.youtube.com/watch?v=g2zts1hW19k
07:43Viestidunno if it is even worth asking, but is there a way to find references to a symbol in nrepl.el, like a counterpart to nrepl-jump
07:44supreme__Hi, has anyone used moving average to smoothen out "hotness" over time for "topics"?
07:44supreme__like topic A got 10 hits but they happend 50 minutes ago and topic B has only 8 hits but they all happend 5 minutes ago, then topic B is more "hot"
07:44supreme__is moving average a good choice for this?
07:45supreme__without overdoing it and using something like Storm
08:18corecodelooking for people interested in creating a good open-source schematic capture + layout system in clojure. plz take a number, everybody will get in.
09:14mdrogalistbaldridge: You start work awfully early for being a west-coaster. :P
09:15tbaldridgemdrogalis: I work on EST time, so yeah, I tend to start early.
09:16mdrogalistbaldridge: I suppose you get to finish early, so that's good. :)
09:40dobry-dendatomic has been the perfect database for modeling the bitcoin blockchain
09:42dobry-dennot so much h2 though -_-
09:47dobry-deni wonder how they stand on granting something like open-source licenses for datomic
09:48mdrogalisdobry-den: You can use the free edition for open source.
10:51silasdavisI want every thread in my application to have its own s3 client
10:51silasdaviswhat's a nice way of doing this?
10:53mdrogalissilasdavis: Are you using futures?
10:54silasdavisI'm using a scheduledtaskexecutor
10:54silasdavisthrough at-at
10:54silasdavisso.. um, no?
10:55silasdaviscurrently I'm doing a lot of passing s3-client around
10:55silasdaviswhich I don't particularly like
10:59mdrogalissilasdavis: You could use thread-local bindings I suppose.
11:01silasdavisso use a set! statement in the head of my thread's main function?
11:02mdrogalissilasdavis: http://stackoverflow.com/questions/7387098/threadlocal-counter-in-clojure
11:31noncomhi, what is the idiomatic way to get a subvector from a vector by indices. for example, i have a vector and i want a subvector which starts at index 5 and goes up for 10 positions, ending on index 15
11:32noncomdrop-take?
11:38nathanicnoncom: http://clojuredocs.org/clojure_core/clojure.core/subvec
11:58seangrovecemerick: We have an html page we use for developing that has a few dom elements and the generated javascript - it's not clear how I can get austin to open up that page. Am I misunderstanding the usecase for austin?
11:59cemerickseangrove: this is the page that contains/loads your app?
11:59seangroveYes
12:00seangroveWith piggieback, we call `(repl/connect "http://localhost:9000/repl&quot;)` from it
12:00cemerickseangrove: in that use case, _you_ open that page in your browser.
12:00cemerickJust like the classic browser REPL, except you don't have to mess with port numbers, can have multiple browser REPLs running, etc.
12:02seangrovecemerick: Do I open the page in the window that opens from running `(cemerick.austin.repls/exec :exec-cmds ["open" "-ga" "/Applications/Google Chrome Canary.app"])`? Navigating away seems to (obviously) break the connection
12:02cemerickseangrove: no, that's solely for "headless" REPLs that still have your project's code on the classpath, etc.
12:02seangroveSay my page is on http://localhost:3001/example.html and the repl env has opened on http://localhost:59554/2305/repl/start
12:03seangroveOk, let me re-read
12:03cemerickThere's two use cases; the classic browser-connected REPL one is detailed @ https://github.com/cemerick/austin/tree/master/browser-connected-repl-sample
12:04seangrovecemerick: Wait, do I want the classic browser-connected REPL? I'm manipulating the dom and rendering templates to see how they look.
12:07cemerickseangrove: Yeah, you need your app open and initiating the connection so you can see it behaving, etc.
12:07cemerickThe headless option is fine for automated testing of DOM manipulations and such, but none of that is going to be human-visible, etc.
12:08seangrovecemerick: Yeah, sorry, I thought I was doing the project repl
12:12seangrovecemerick: Also, while you're around, this patch look like the right way for cljsbuild to hook into analyzer warnings? http://dev.clojure.org/jira/browse/CLJS-636
12:18cemerickseangrove: yeah, something like that would work, though I flinch at more dynamic vars floating around. I'd prefer to have all warnings and the result of compilation (i.e. the analysis or a string of js) bundled into a return value, but I don't know that anyone (including dnolen) has the stamina to write/review such a sweeping change at the moment.
12:18cemerickAlso, I'd like to hear what ambrosebs and Bronsa need in this area before running full bore into anything.
12:20seangrovecemerick: Yeah, I suppose the iterative warning-callback approach isn't as nice as a complete datastructure with the results of the compilation at the end.
12:22cemerickseangrove: it goes along with the nature of things at the moment, since everything is done on a form-by-form basis, but we really want to think of compilation/analysis as a per-file (maybe per-namespace) thing.
12:23cemerickJust having gotten done tweaking around how the reader interacts with the analysis of ns forms, the imperativeness left a strong impression. :-)
12:32seangrovecemerick: Also, thank you so much for everything you've done, you're hugely responsible for cljs being usable at all
12:32cemerickseangrove: thanks, just hacking the underbrush I come across :-)
12:33cemerickJust wait 'til my stuff breaks, then you won't be so happy! ;-)
12:33seangrovecemerick: Oh your stuff breaks all over the place, hence my recent issues ;)
12:34cemerickhah, well
12:34seangroveOne difference I've notice while in the cljs-nrepl.el vs jvm-nrepl.el envs though is that when in ns example.a in the repl, and evaulating a form in example.b's buffer, the form is evaulated in the repl in example.a, which causes plenty of problems
12:35yeoj___what's the proper way to wrap "new's" of class names, when it comes to java interop?
12:35seangroveI just switch namespaces with C-c M-n, but I often trip over this, and with the newcomers around me, they're really running into a lot of these things I've just learned to work around
12:35yeoj___for instance, new OutputStreamWriter(new FileOutputStream("outfilename"), "UTF-8")
12:36seangroveyeoj___: (OutputStreamWriter. (FileOutputStream "outfilename") "UTF-8")
12:36seangroveWoops, a period at the end of the FileOutputStream too
12:37yeoj___ahh, ok.
12:37yeoj___seangrove: thanks.
12:39cemerickseangrove: That *should* work, but I haven't looked into how cider sends "eval expression" operations. Feel free to open a ticket on piggieback describing the observed problem.
12:40seangrovecemerick: Will do, would like to start helping out a bit more on the cljsbuild/piggieback side
12:40seangrovecemerick: What did you do around the namespaces? I've noticed quite a few problems with them actually
12:41cemerickseangrove: not sure what you mean; do around namespaces where?
12:42seangroveYou mentioned you tweaked how the reader interacts with the analysis of ns forms
12:43cemerickseangrove: oh, that change is still just on HEAD, hasn't been released yet
12:50poppingtonichello
12:50dnolencemerick: yeah I think anything major should probably wait for integration with standard analyzer and backend tools
12:51poppingtoniccemerick: I'm reading your book, and it's amazing. Thanks. :)
12:53cemerickdnolen: Yeah. Though, I will be adding a hack in cljsbuild v2 to be able to fail on different warnings based on grepping the output.
12:53poppingtonichow do I get pprint to work? 1.5.1
12:54cemerickDirty, but I need builds to fail when there's particular classes of problems. Right now, automated deployment processes can leak out busted .js without a peep.
12:54dnolencemerick: why wouldn't you just use what seangrove is working on?
12:54cemerickdnolen: If you decide to merge it, I'll use it. :-)
12:55cemerickBut, that's a month out anyway. Hoping to finish cljsbuild v1.0 early Nov.
12:55poppingtoniccemerick: doesn't pprint work out of the box? I can't get to use it for the game-of-life example.
12:55dnolencemerick: heh, we need a stop gap, I'm pretty sure seangrove's thing'll make it in.
12:56cemerickThen we can start ripping things up into some simpler/easier bits.
12:56cemerickpoppingtonic: glad you're liking the book. My coauthors were instrumental. :-)
12:56cemerickpoppingtonic: Have you done (require 'clojure.pprint), or similar?
12:57poppingtoniccemerick: I get this: "CompilerException java.lang.RuntimeException: Unable to resolve symbol: requie in this context, compiling:(NO_SOURCE_PATH:1:1) "
12:58cemerickpoppingtonic: you misspelled 'require'
12:58poppingtonicbecause it's a misspell :)
12:59poppingtonicworks.
13:02cemerickpoppingtonic: :-)
13:04poppingtoniccemerick: Thank you.
13:10seangroveddellacosta: I wasn't really talking about the library ecosystem (I think that's a different story that'll improve on its own) re: cljs tooling challenges
13:10ddellacostaseangrove: sorry if I digressed. Was thinking generally about the beginner story, as you put it
13:12seangroveddellacosta: Quick start guide could definitely be updated
13:12seangroveWith a lein template, there's probably a one-liner someone could copy/paste and have a full lein cljs app running and open in their browser
13:12seangroveThe step after that is tough though...
13:13radsI noticed with lein-cljsbuild 0.3.4, when I use "lein cljsbuild auto", it sometimes fails with an error and stops the process. this means I have to fire up a new JVM every time this happens. is there a way to keep it recompiling even when there's an error?
13:13ddellacostayeah, I think a template is part of it
13:13ddellacosta^^ haha
13:13ddellacostasorry, just funny timing
13:14ddellacostaseangrove: but yeah, don't mean to suggest it is a simple fix--was really just trying to brainstorm. Twitter maybe not best place for that.
13:14technomancyrads: `lein do cljsbuild auto, cljsbuild auto, cljsbuild auto, cljsbuild auto` =)
13:16technomancythere are a bunch more actually useful higher-order lein plugins that should exist, but I just want to write lein-ski
13:16radsI see, so the answer is, restarting the process is out of the scope of lein-cljsbuid?
13:17technomancysorry, I haven't actually used lein-cljsbuild. ignore me. =)
13:18cemerickrads: that's a recent regression; use 0.3.3 until it's fixed for v1.0
13:18poppingtoniccemerick: the ghastly exception returns: "CompilerException java.lang.RuntimeException: Unable to resolve symbol: pprint in this context, compiling:(NO_SOURCE_PATH:1:1) "
13:18cemerickrads: https://github.com/emezeske/lein-cljsbuild/issues/249
13:18cemerickpoppingtonic: you've probably switched namespaces
13:19radscemerick: oh cool. I was thinking it was intentional after reading gh-234. good to hear it's not
13:19radsty!
13:21gfrederickstechnomancy: how usable would leiningen be w/o maven?
13:21gfredericksas a "run tasks in deployment" kind of tool
13:21technomancygfredericks: without aether you mean?
13:22gfrederickse.g., if I have all the jars for lein itself already on the machine somewhere, and ditto for the project, can I do a reasonable subset of lein things without it using maven?
13:23justin_smithgfredericks: no dependencies list, and manually put each jar in the classpath via resource-paths or source-paths ?
13:23gfrederickswell the dependencies list will still be in the project.clj, but presumably no need to read it
13:23technomancygfredericks: depends how deeply you're interested in mangling lein I guess?
13:24gfrederickstechnomancy: just trying to get a feel for how much work that would be to enable
13:24justin_smithgfredericks: then you would need to create the classpath including all those jars in some other way, right?
13:24technomancygfredericks: you could (ns leiningen.core.classpath) (def get-classpath (constantly ["/some/" "/coll" "/of" "/paths"])) (ns user) (defproject ...)
13:24technomancymaybe
13:25gfrederickshmmm
13:25gfredericksinteresting; thanks
13:26technomancyprobably better to dump everything in :resource-paths and leave :dependencies empty though
13:28gfredericksideally wouldn't have to muck with the project.clj to make this work
13:28gfredericksbut I'm leaning toward abandoning the idea altogether
13:36cemerickgfredericks: what's your original pain?
13:51dnolenif somebody has time it would be nice to test this one on a non-Windows box - http://dev.clojure.org/jira/browse/CLJS-637
14:01seangrovednolen: I can check it out later today
14:01dnolenseangrove: thanks much
14:02dobry-dendoes byte-array of a single byte have an endianness (even though it can't be expressed with a single byte), or does it have no endianess.
14:03dobry-dennevermind. painful to read my own question. is ["a"] sorted a-z or z-a?
14:04znDuffdobry-den: How is it "sorted" in any sense at all?
14:04dobry-denznDuff: I would say it's sorted in the way it would be sorted had it one more byte of info
14:04justin_smithdobry-den: I don't think endianness comes into play, bytes are always signed 8 bit in the jvm no?
14:05znDuff...but vectors are ordered, so the sorting is user-defined.
14:05dobry-denyeah, the context is weird
14:05justin_smithit is only when you coerce a byte array into some other type that endianness is even a factor, and "a" is not a byte
14:06dobry-denthat was me judging myself with an analogy
14:06dobry-denin my codebase, i decided to represent all bytes as vectors of hexstr pairs
14:06justin_smithok, but 8 bit things are immune to all concerns of endianness
14:07justin_smithjust remember to do the signed conversion
14:08dobry-denin my head, endianness describes a collection of 8-bit things.
14:08justin_smithright, but if each one is 8 bits, endianness does nothing
14:08justin_smithnow if the question is "what is the endianness of a double when stored as a byte array" - that may be getting at what we want
14:09justin_smithbut that is not the byte's endianness - it is the object being converted to byte
14:31dobry-denjustin_smith: thanks. that reminded me that endianness only matters in that it describes how to interpret the bytes that represent something (when there's more more than 1 byte)
14:39justin_smithnp
14:42dobry-denthe eternal `util` namespace is like a function waiting room for abstractions/extractions that will probably never happen
14:44mdrogalisI used to think that, but on projects of bigger size, little things emerge.
14:44mdrogalisSimulant as a util ns.
14:44mdrogalisHas*
14:45dobry-denyeah i think a util namespace is a solid place to put some things until you can see the patterns that lead to abstractions
14:48dobry-denim just looking at my util namespace right now and it's starting to feel like a massive CSS file i keep telling myself im gonna refactor
14:50dobry-denbut i think the uneasiness comes from other languages where a large file means im probably coupling things together
14:50dobry-denin clojure ive found it usually more trouble than it's worth to try and organize prematurely
14:51em-dashI started porting clojure's persistent data structures to objective-c: https://github.com/emmanuel/clojure-objc
14:51em-dashI conceived the effort as a start towards a full implementation of Clojure in Objective-C. My intentions were self-pedagogical, but I have some hopes that the effort will be more widely useful.
14:52dnolenem-dash: how will that work w/o GC? (honestly curious)
14:52em-dashNow I'm taking a look around and trying to get a sense of what's out there
14:52em-dashdnolen: reference counting
14:52em-dashARC, specifically
14:53em-dashthough, frankly, I may be completely oblivious to major issues on that front
14:53em-dashThe underlying storage of pointers is managed by NSArray (persistent vector) & NSPointerArray (persistent hash map)
14:54poppingtonicI need a little help figuring out why pprint won't work. This is basically what's happening every time: https://www.refheap.com/20169
14:54dobry-denem-dash: i like this kind of stuff m8.
14:54em-dashboth of which provide ARC retain/release management of their contents (when the content is objc objects)
14:54mdrogalisdobry-den: I hear that.
14:54dobry-denit's my kind of yak shaving
14:56em-dashdobry-den: you and me both :D
14:56`cbppoppingtonic: you need to call it like clojure.pprint/pprint
14:57poppingtonicem-dash: can you help me out?
14:57poppingtonichi :)
14:57em-dashpoppingtonic: one bit of irony is, I don't know clojure well (yet)
14:57poppingtonicoh, `cbp: thanks. works quite well.
14:58`cbppoppingtonic: or you need to require like (require '[clojure.pprint :refer [pprint]])
14:59poppingtonic`cbp: that's even better! I was wondering if (require x) has syntax like the (:require x) during namespace creation. Like (:require 'clojure.pprint :as pprint)
15:00poppingtonicem-dash: you and me both :)
15:02`cbppoppingtonic: they're practically the same thing
15:02justin_smithpoppingtonic: yes it does - if you look at almost any well used clojure project on github you will see them doing that in their namespace definitions
15:02em-dashdnolen: re: your question about memory management/GC, I'd love to chat through what considerations one should bear in mind. I think that ARC will work for the persistent collections, but I am far from an expert there.
15:03poppingtonicjustin_smith: Well, I have seen that pattern many times from the projects I've cloned.
15:09em-dashand... I've got to run for a bit...
15:28jtoyhow would I convert BytesInputStream into a string? str and other methods I have tried dont seem to work
15:29noonianjtoy: i think you can use slurp
15:29noonian,(doc slurp_
15:29clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
15:29noonian,(doc slurp)
15:29clojurebot"([f & opts]); Opens a reader on f and reads all its contents, returning a string. See clojure.java.io/reader for a complete list of supported arguments."
15:30justin_smithjtoy: apply str
15:33jtoyslurp worked but apply str didnt work in this situation,thx
15:34justin_smithok, interesting
15:34justin_smithmaybe I was thinking of something different, I thought that had worked for me before
15:35jtoyjustin_smith: it could be the library i am using
15:35jtoythat is acting differently
15:36justin_smithI see now I wasn't using a BytesInputStream - is that something from org.httpkit?
15:36jtoyjustin_smith: yes, exactly
15:36noonian(apply str blah) would be for converting a seq of chars to a string for instance
15:36noonianor turning a seq of strings into a single string
15:37justin_smithI misremembered
15:37justin_smithI was using (String. bytes)
15:37justin_smithor, more exactly (String. bytes "UTF-8")
15:38jtoyjustin_smith: are slurp and (String. bytes "UTF-8") equivalent here?
15:39justin_smithString. works for me with bytes where str and (apply slurp ...) do not- but I don't know that it would be identical to slurp
15:39justin_smitherrr... make that (apply str ...) above, sorry
15:39justin_smith,(slurp (.getBytes "hello"))
15:40clojurebot"hello"
15:40justin_smith,(String. (.getBytes "hello"))
15:40clojurebot"hello"
15:40justin_smith,(str (.getBytes "hello"))
15:40clojurebot"[B@1f2929c"
15:40justin_smith,(apply str (.getBytes "hello"))
15:40clojurebot"104101108108111"
15:40justin_smithso yeah, String. and slurp seem to be doing something similar
15:43nooniani just like reading the word 'slurp' in my code :p
15:44coventryYay, http://clojure-log.n01se.net/ is back.
15:58dobry-denHow can you check for value equality regardless of the sequence type? (= [:a [1]] '(:a '(1)))
16:02shoshin_ping. i came across this snippet of code recently, i didn't understand this fully.
16:02shoshin_(every? identity (mapv (fn [x] (println x))[1 2 3 4 5]))
16:02shoshin_returns 1 2 3 4 5 false.
16:03shoshin_this is form (every? identity ...) used for iterating over a collection?
16:03coventryshoshin_: ##(nil? (println "foo"))
16:03lazybot⇒ foo true
16:03hiredman,(doc every?)
16:03clojurebot"([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false."
16:03hiredman,(doc identity)
16:03clojurebot"([x]); Returns its argument."
16:03coventryshoshin_: ##(every? odd? '(3 5 7))
16:03lazybot⇒ true
16:04shoshin_yeah. i understand what every? and identity do separately.
16:04shoshin_but what exactly is happening in this code here?
16:04shoshin_coventry, hiredman ^^ :)
16:05coventryprintln is printing out the vector elements, then returning nil, so you end up with a list of nills, passed through identity to every?, which then returns false when it hits the first nil.
16:07shoshin_coventry a list of nils?
16:07coventry,(mapv (fn [x] (println x))[1 2 3 4 5])
16:07clojurebot1\n2\n3\n4\n5\n[nil nil nil nil nil]
16:08shoshin_coventry oh. okay. got it.
16:08shoshin_thank you!
16:08shoshin_is it an effective way to iterate over a collection?
16:09coventryYou need to be more specific. It can be.
16:10shoshin_coventry the collection here is a vector of URLs and the anonymous function is used to determine if they are valid URLs or not.
16:10coventryshoshin_: Try it and see.
16:13sritchieanyone here using the piggieback repl?
16:14technomancy~anyone
16:14clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
16:14bitemyappsritchie: I see piggieback mentioned regularly.
16:16sritchiebitemyapp: was curious about the workflow for having a clojure + clojurescript repl up at the same time
16:19bitemyappsritchie: seangrove recently got somebody rolling with such a setup, I don't think anything is stopping you from having two nrepls.
16:19sritchienice
16:19sritchieboom
16:23sverihi, i am trying to include the java recaptcha library, but i get a java.lang.ClassCastException when i run my code, i think that i use the java lib wrong in the clojure sense, can someone hint me how to do it right please? here is the code: http://pastebin.com/Xk1jQY7B
16:24cmajor7is "https://github.com/pauldorman/clj-ldap&quot; the way to go with LDAP in Clojure? thx
16:28coventrysveri: http://clojure.org/java_interop You are trying to call a java object as if it were a clojure one. You need to learn about the . notation.
16:28gfredericksis it weird that sorted sets don't support nth?
16:29svericoventry: ok, i will have a look at it, thank you
16:29bitemyappgfredericks: no
16:31gfredericksbitemyapp: why is that?
16:33bitemyappgfredericks: sets fall under "blind seq'ing and membership checks". nth-ness isn't meaningful and relies on the exact composition of the entire set.
16:33bitemyappsets are not associative by position.
16:34bitemyappso between the overly data-dependent nature of what an nth against a sorted set will get you, and that they aren't associative by position, I don't think it makes sense.
16:34bitemyappIt would just, no offense, lead to brittle code.
16:34coventrylists aren't associative by position either, are they?
16:35bitemyappcoventry: vectors are, but lists don't suffer from the data dependence total re-ordering of all values that sorted sets do.
16:35technomancyyeah, i dont buy that
16:35bitemyappall your shit gets shuffled to the right if a "least" value gets added to the sorted set
16:35gfrederickstotal re-ordering?
16:35gfredericksoh
16:36bitemyappsorry, not re-ordering. The shuffle/waterfall effect from shoving things around.
16:36bitemyapplists get cons'd predictably and vectors get conj'd predictably.
16:36bitemyappconjing onto the end of a vector doesn't invalidate the "nth-ness" of all preceding values.
16:37bitemyappI'm less concerned with the validity of nth'ing lists, it has practical value and is less brittle than sorted set nth, but vectors are the best example.
16:37bitemyappgfredericks: does my position make sense?
16:37gfredericksI can definitely see the distinction
16:38coventrySometimes that's exactly the data dependence you'd want though. Sometimes you want to know the 5th lowest element in a set.
16:38technomancyit feels like an attempt to retroactively justify the behaviour though =)
16:38gfredericksthe particular reason this has come up for me is when doing algorithms on undirected graphs, where I represent an edge as #{a b}
16:39gfredericksand I kept wanting to destructure the edge without caring which thing came out first
16:39gfredericks(let [[a b] #{1 2}] ...)
16:41gfredericksI somewhat understood it failing for regular sets; then it failed for sorted sets and my other eyebrow went up
16:42stuartsierragfredericks: You can call `seq` on the set and then destructuring will work
16:42gfredericksyep
16:42bitemyapptechnomancy: it makes perfect sense to me, I'm not bending over backwards here.
16:42TimMcI'm surprised it doesn't call seq automatically.
16:42gfredericksthat's what I ended up doing
16:54l3dxI'm playing around with compojure and trying to fetch both a url param and the body content of the request. Here's what I got -> http://pastebin.com/wzNLSARk
16:56l3dxprobably a newbie error
16:58znDuffl3dx: would you mind posting that somewhere without the ads? pastebin.com is something of an eyesore for folks not running adblock.
16:59l3dxznDuff: oh, I didn't know
16:59l3dxgive me a sec
17:01l3dxhttps://gist.github.com/tskardal/c4141b519a0e591ff159
17:04znDuffl3dx: thanks; just a moment while I get set up to validate what I remember about compojure's destructuring syntax.
17:14znDuffl3dx: https://gist.github.com/charles-dyfis-net/6e7362a50e043ae7b327
17:14znDuffl3dx: note the :as keyword
17:15TimMcI've been using Clojure's PersistentHashMap from Java, and now I'm getting some bullpucky about contains? not being supported on PersistentList: https://www.refheap.com/20171
17:16TimMcAll I did was change some internal dependencies internal to my project; is there something I should be doing to initalize Clojure?
17:18l3dxznDuff: ah, thanks! :)
17:19stuartsierraTimMc: `contains?` was never supported on PersistentList.
17:19znDuffl3dx: ...by the way, you can do that kind of experimenting in Light Table, if it makes the feedback loop a bit quicker. :)
17:20stuartsierraTimMc: Clojure 1.5 changed `contains?` to throw an exception if you try to call it on something it doesn't support, instead of returning nil.
17:20TimMcstuartsierra: But if I put static { RT.init(); } near the top of one of my main Java files, the error goes away.
17:21stuartsierraTimMc: Then I have no idea what's going on. :)
17:21TimMc(And RT.init() chides me for calling it.)
17:21dnolennice core.logic video from tbaldridge - http://www.youtube.com/watch?v=HHZ8iqswiCw&amp;feature=youtu.be&amp;a
17:21l3dxznDuff: I'll check it out
17:22TimMcstuartsierra: But to your knowledge I should just be able to use PHM and Util such?
17:22TimMc*and such
17:22stuartsierraTimMc: Theoretically yes, although those APIs are not stable across Clojure versions.
17:23stuartsierraTimMc: But that stack trace looks like an error in Clojure code caused by calling `contains?` on a list.
17:23coventryYeah, I'm curious what file it's trying to load.
17:23TimMcYeah, haven't really dug into what's going on there.
17:26TimMchttps://github.com/clojure/clojure/blob/clojure-1.5.1/src/clj/clojure/core.clj#L5364
17:27TimMc(contains? @*loaded-libs* lib)
17:27stuartsierra*loaded-libs* is a set
17:27TimMcSo you claim. :-P
17:27hiredmanTimMc: you shouldn't call init, the satic init for RT will take care of that
17:28TimMchiredman: It was a debugging step.
17:28stuartsierrahttps://github.com/clojure/clojure/blob/clojure-1.5.1/src/clj/clojure/core.clj#L5271-L5274
17:28TimMcAnd yet.
17:29TimMcI mean, it *should* be a set...
17:32stuartsierraTimMc: Check if you somehow have multiple versions of Clojure on the classpath.
17:34rurumate,(count (clojure.lang.Var/getThreadBindings))
17:34clojurebot9
17:35rurumatewhat is this, and why is it 9?
17:36jacktasiais there a way to convert a string (code from a file) to something that can be used by clojure.pprint/write?
17:36coventryjacktasia: Convert a string to a clojure datastructure? Maybe read-string is what you're after?
17:36stuartsierra,(doc get-thread-bindings)
17:36clojurebot"([]); Get a map with the Var/value pairs which is currently in effect for the current thread."
17:36rurumatein my repl, it's 26
17:37jacktasiacoventry: thanks, i've tried read-string but it seems to only take the first line of the string
17:37rurumate,(let [afasdf 1328767658] (count (clojure.lang.Var/getThreadBindings)))
17:37stuartsierrarurumate: It's the set of thread-local Var bindings currently in effect. The REPL sets a bunch of thread-local bindings automatically.
17:37clojurebot9
17:37gfredericks,(->> (get-thread-bindings) (keys) (map str))
17:37clojurebot("#'clojure.core/*err*" "#'clojure.core/*print-length*" "#'clojure.core/*out*" "#<Var: --unnamed-->" "#'clojure.core/*ns*" ...)
17:37stuartsierraTools like Leiningen and nREPL set a bunch more bindings.
17:38TimMcstuartsierra: Pretty darn sure.
17:38jtoyim trying to do some basic macros with korma, could anyone let me know what I am doing wrong: https://www.refheap.com/20172
17:39coventryjacktasia: It will take the first form. You could do something like ##(read-string (str "[" "(1 2 3) {4 5 6 7}" "]"))
17:39lazybot⇒ [(1 2 3) {4 5, 6 7}]
17:40gfredericksjtoy: you have feeds as a keyword in the not-macro example
17:40gfredericksbut it'll be a symbol with your macro
17:40gfredericksso you should get the same error as having used (table feeds)
17:40coventryjacktasia: But actually, you probably want clojure.edn/read-string
17:41pjh_hey ben, welcome to the clojure channel
17:43jtoygfredericks: I thought that might be the issue, I also tried with this but got the same error https://www.refheap.com/20172
17:45rurumatestuartsierra: thanks for the insight; I'm trying to make sense of the mess that (macroexpand '(go (<! c)) produces
17:45stuartsierrarurumate: Ha! Talk to tbaldridge.
17:48tim_rurumate: short answer: http://hueypetersen.com/posts/2013/08/02/the-state-machines-of-core-async/
17:48jtoyanyone else know what I am doing wrong with this macro definition ? https://www.refheap.com/20172
17:49rurumatetbaldridge: gee thanks, that's exactly what I'm brooding over!
17:49tbaldridgejtoy: the argument to (table ...) is a kw, not a symbol
17:50tbaldridgerurumate: if you want the long answer, there's about 2 hours of video on the subject here : http://www.youtube.com/channel/UCLxWPHbkxjR-G-y6CVoEHOw
17:51jtoytbaldridge: i tried with symbol, keyword, and passing directly in and get the same error
17:52jtoy(table (keyword ~ent))
17:52dnolentbaldridge: nice core.logic video
17:52rurumatetbaldridge: that's so cool
17:52tbaldridgednolen: thanks.
17:53jtoythe error always says it is this line : (deftable feeds)
17:56gfredericksjtoy: you want to convert it to a keyword at macroexpand time
17:56gfredericksso ~(keyword (name ent))
17:57jacktasiacoventry: thanks clojure.edn/read-string works but it still with only the first form...and ##(read-string (str "[" "(1 2 3) {4 5 6 7}" "]")) doesn't seem to work for me
17:57lazybot⇒ [(1 2 3) {4 5, 6 7}]
17:57gfredericksjtoy: i.e., you want to insert a keyword into the code, not write code that calls the keyword function
17:58jtoygfredericks: ah, i see, i need to study that more
18:00jacktasiaconventry: or are you saying just wrap the code in []?
18:00coventryjacktasia: Leave off the ## prefix. That is just a way to tell lazybot to report the result of evaluation here.
18:01mattmossMaybe I'm missing something obvious... but how can I "functionally bind"? What I mean is being able to do something like: (let [{:keys ids} (reduce #(assoc % %2 (str %2)) {} ids)] a)
18:01mattmossBut where the (str %2) is some non-trivial result.
18:01gfredericksjtoy: shameless plug: http://www.infoq.com/presentations/macros-clojure-west-2013
18:02mattmossAnd that last 'a' would be a larger body, able to make use of any ident found in ids.
18:02mattmossids being a vector like: [:a :b :c]
18:11RaynesOw! My back!
18:12stuartsierraWas there ever an answer on how to prevent Leiningen from injecting 'test'-scoped dependencies into the pom.xml it generates?
18:16staaflgood evening
18:16staafli'm solving this: http://www.4clojure.com/problem/28#prob-title
18:16staaflis there a concise way to check if sth is a list OR a vector
18:18mattmoss(or (list? x) (vector? x)
18:19mattmosswith closing paren
18:20staaflmattmoss, nothing built-in?
18:20justin_smithseqential? is close, but maybe not quite it
18:21staafljustin_smith, it seems to work nicely
18:21staaflthat's the catch?
18:21mattmossstaafl: Those are all builtins. And fairly concise, I'd say. Though you could define a new function if you like: (defn list-or-vector? [x] (or (list? x) (vector? x))) and then just use (list-or-vector? x)
18:21justin_smithmaybe java arrays and bytevectors
18:21justin_smiththose may be also sequential?
18:21jacktasiacoventry: thanks that worked - although now i have to strip off the extra brackets, but i can't get pprint-write to go into a variable. i thought print-str would work but doesn't
18:21AimHereBoth lists and vectors have the java.util.List type
18:21mattmossseq? or sequential? is close, but means something different, methinks
18:22AimHere,(seq [3 4 5])
18:22clojurebot(3 4 5)
18:22AimHere,(seq? [3 4 5])
18:22clojurebotfalse
18:22justin_smithstaafl: acutally those are not sequential?
18:22justin_smith,(sequential? (into-array (range 34)))
18:22clojurebotfalse
18:23justin_smith,(sequential? (.getBytes "hello"))
18:23clojurebotfalse
18:23justin_smiththose surprise me
18:23staaflfor my purposes, sequential? will do nicely
18:23justin_smithbut they mean sequential? does what you want
18:23justin_smithyeah
18:23staaflyeah
18:23mattmossstaafl: sequential? may be what you want, but you may have meant a different question than what you asked.
18:24mattmoss,(sequential? #{1 2 3})
18:24clojurebotfalse
18:24staaflmattmoss, in general it'd be nice to be able to check if something is "iterable"
18:24justin_smithseq
18:24staaflbeing a total newb i don't know if sequential is the proper word for it
18:24justin_smitherr not seq
18:24mattmoss,(map sequential? ['(1 2 3) [1 2 3] #{1 2 3} {:a 1 :b 2 :c 3} (seq 1 2 3)])
18:24clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: core$seq>
18:24justin_smithiterable would be coll?
18:25mattmoss,(map sequential? ['(1 2 3) [1 2 3] #{1 2 3} {:a 1 :b 2 :c 3})
18:25clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: )>
18:25mattmossdanngit
18:25justin_smith(map coll? [[] '() {} #{}])
18:25mattmoss(map sequential? ['(1 2 3) [1 2 3] #{1 2 3} {:a 1 :b 2 :c 3}])
18:25mattmoss,(map sequential? ['(1 2 3) [1 2 3] #{1 2 3} {:a 1 :b 2 :c 3}])
18:25clojurebot(true true false false)
18:25justin_smith,(map coll? [[] '() {} #{}])
18:25clojurebot(true true true true)
18:25justin_smithcoll is for things you can iterate with map etc.
18:25justin_smith*coll?
18:26staafljustin_smith, looks quite useful
18:26staafland good to know, anyway for this little exercise either will do nicely
18:26justin_smithnot quite complete though
18:26mattmossstaafl: Okay, yeah, "iterable" is different than "list or vector". coll? sounds close (http://clojuredocs.org/clojure_core/clojure.core/coll_q)
18:26justin_smith,(map identity (.getBytes "hello"))
18:26clojurebot(104 101 108 108 111)
18:26justin_smith,(coll? (.getBytes "hello"))
18:26clojurebotfalse
18:27justin_smithso there is something missing still to finding if you can map on something
18:27staaflmattmoss, i indicated the limited scope of my question :-)
18:27staaflbtw, how do i hook into the repl startup process
18:27staafli want to change the prompt
18:27jacktasiacoventry: nvm (with-out-str) is what i was looking for
18:27justin_smithso what is the more general version of coll? that would also return true for a jvm array you can map over? I wonder
18:28AimHere,(instance? java.util.List [:a :b :c])
18:28clojurebottrue
18:28AimHere,(instance? java.util.List #{:a :b :c})
18:28clojurebotfalse
18:28stuartsierra(try (seq x) true (catch Exception _ false)))
18:28justin_smithreally, no way without a try/catch?
18:30stuartsierra`seq` is defined as a bunch of special cases for things like Java arrays, so there's no one predicate that defines what it works on.
18:30justin_smithgood to know, thanks
18:31stuartsierraSome things are "sequable" but are not really collections, e.g. Strings.
18:32justin_smithheh, at that point, why not make namespaces and classes sequable too (just kidding lets not actually do that)
18:34stuartsierraIf you want the gory details: https://github.com/clojure/clojure/blob/c32511a4073edc7e7a38d47e097fb9e0c2b0a3f5/src/jvm/clojure/lang/RT.java#L480
18:35staaflthere is no reason not to consider a string a collection
18:35staafla read-only collection of chars
18:35justin_smitha namespace is a collection of vars
18:36justin_smitha class is a collection of methods and fields
18:36stuartsierrastaafl: It depends on your use case. E.g. ##(flatten [1 [2] "345"])
18:36lazybot⇒ (1 2 "345")
18:37staaflhmm
18:37stuartsierrajustin_smith: Clojure's Namespace is essentially a map in an Atom.
18:37dnolen,(doc coll?)
18:37clojurebot"([x]); Returns true if x implements IPersistentCollection"
18:37justin_smithstuartsierra: I kind of assumed that was hiding under there somewhere :)
18:38`cbpbitemyapp: ping
18:45nicholas_hey, I want to write a simple json API, writing to postgres
18:45nicholas_what's a good framework for that? I'm thinking of using Luminus
18:46bitemyapp`cbp: pong
18:46bitemyapp`cbp: I was discussing connection life cycle management strategies with yogthos last night, he seemed to think what I had in mind made sense.
18:46bitemyapp`cbp: you know the current state of things isn't thread-safe at all right?
18:47yogthoscan confirm :P
18:47bitemyappactually, you don't even need threads to cause a race condition, just one query that is slower than the next.
18:47bitemyapp`cbp: did you have a question/desire?
18:47bitemyappI was hoping to get the connection management stuff done this weekend. (I'm still at work atm)
18:48`cbpbitemyapp: yeah i was gonna ask you if you had any ideas regarding the connection handling
18:49bitemyapp`cbp: I most certainly do. I can either outline them ahead of time or provide a report/commits after I'm done experimenting.
18:49bitemyapp`cbp: I want to get the test harness up, move the commented queries to their own tests, and then reproduce a race condition
18:49bitemyappthen start hammering out the connection stuff based on the design I have in mind.
18:50bitemyapp`cbp: the main change is simply that (run ...) will take two arguments instead of one - you'll pass the connection object directly. No implicits/globals.
18:50`cbpI'm writing some tests but nothing interacting with the db so far
18:50bitemyapp`cbp: just beware, I might have to make sweeping changes for testability and/or the conn mgmt stuff.
18:51`cbpthat's ok
18:51bitemyapp`cbp: also, I'm refusing to do any client-side connection pooling. I don't think it's a good idea, I don't think it's a good idea for Revise/RethinkDB, and RethinkDB provides a conn pooling service to run on each client anyway.
18:51bitemyappI may consider a conn reconnect/retry mechanism though.
18:51`cbpOh ok
18:51bitemyappsomething with backoff -> exponential backoff or something.
18:52bitemyappor just failure after so many tries. Whatever.
18:52bitemyapp`cbp: langohr has something like what I am talking about where if the connection is lost it'll attempt to bring it back up.
18:54`cbprdb has different kind of queries, start, continue and so on. The start queries are working. But I'll prolly wait to see what you have in mind to implement the others
18:54`cbpwhat you have in mind regarding the connections*
18:54`cbpsince that's part of the send fn
18:55bitemyapp`cbp: yeah, you'll want to wait until I hammer out some of that. I'm thinking of a conn object that you pass around, possibly arbitrating query results through an agent that delivers into promises returned by the API
18:56bitemyapp`cbp: queries and their results are matched by the unique number associated with the protobuf message and dissoc'd out of the "on-deck" hash-map associated with the connection object
18:56bitemyapp`cbp: "parallelization" insofar as that's a thing basically just means firing up more connections with can be m-n mapped through the pooling servers RethinkDB provides.
18:56bitemyappthe agents aren't a guarantee, it's just an idea.
18:56staafl,(map char (range (int \a) (int \d)))
18:56clojurebot(\a \b \c)
18:56staaflhow do I turn this into "abc"?
18:57bitemyappstaafl: (apply str ...)
18:57staaflbitemyapp, neat, thanks
18:57bitemyapp`cbp: a while loop and a dedicated thread are equally as possible as an agent. NO SINGLETONS THOUGH.
18:58staaflany way to create an operator section with the first operator
18:58staaflbeing on the left
18:58staaflI mean, something like (partial > 0) is misleading
18:59bitemyappI want people to be able to use arbitrary databases/connections with their queries. I hate the unnecessary global singleton crap people do.
18:59staaflit's (0>) but looks like (>0)
18:59bitemyappstaafl: that's prefix notation for you.
18:59bitemyappstaafl: if you speak it out loud, it makes more sense.
18:59`cbpYeah ofc
19:00staaflbitemyapp, you're right, but I don't want to risk confusing someone or myself
19:00technomancystaafl: with < and > in particular just think of it as args-in-increasing-order? and args-in-decreasing-order? respectively
19:00technomancybecause they're variadic
19:01staafltechnomancy, I don't like thinking
19:01technomancythis could be a problem
19:01bitemyappsritchie: without necessarily wanting to confuse Scala's actual "apply" method, is there a way to do something like Clojure's apply in Scala?
19:01staafli'll just use #(> 0 %1)
19:01technomancyor pos?
19:01staafltechnomancy, i mean i don't like having to think :-)
19:01staaflor forcing others to do it
19:01sritchiesort of - you can call "tupled" on a function
19:02sritchieand it returns a version that takes one arg that's a tuple
19:02sritchiethen you can pass the return of another func in directly
19:02sritchiemakes composition easier
19:02technomancystaafl: it's part of learning lisp
19:02technomancystaafl: everyone who knows clojure already reads it that way
19:04`cbpbitemyapp: good stuff. Let me know if you need any help understanding the smoke signals you need to send to rdb for it to accept a connection
19:04bitemyapp`cbp: dude, I tackled that nonsense when I first started Revise.
19:04bitemyapp`cbp: I hate that.
19:04bitemyapp`cbp: hopefully I don't need to bug you. Thanks :)
19:04`cbpbitemyapp: yeah they also changed it since last time hah
19:05`cbpThey like to make backward incompatible changes
19:05bitemyappsritchie: well, tupled is fine, but can the arguments just be Object typed?
19:05staafl,(filter Character/isUpperCase "aAaA")
19:05clojurebot#<CompilerException java.lang.RuntimeException: Unable to find static field: isUpperCase in class java.lang.Character, compiling:(NO_SOURCE_PATH:0:0)>
19:05staaflsome help with the syntax here
19:05sritchiebitemyapp: nope, not that I know of
19:05sritchiethose patterns go out the window
19:06bitemyapphum.
19:06bitemyappsritchie: I will meditate on this. Thank you.
19:06`cbpThe queries are fns so it should be very easy to add some preconditions or even typed clojure on them
19:07`cbpstaafl: ##(filter Character/isUpperCase "aAaA")
19:07lazybotjava.lang.RuntimeException: Unable to find static field: isUpperCase in class java.lang.Character
19:07`cbper ##(filter #(Character/isUpperCase %) "aAaA")
19:07bitemyapp`cbp: you could define a typed clojure HMap for a document coll but the database isn't going to enforce it.
19:07lazybot⇒ (\A \A)
19:07bitemyapp`cbp: clj-schema might be a better fit. Maybe.
19:07bitemyappkinda almost want both.
19:08staafl`cbp, so the anon function is the only way?
19:08`cbpNo i mean something like (table 1) will throw some obscure protocol buffer error
19:08justin_smithstaafl: yeah, jvm methods are not first class functions, so you can't use them as first class values
19:09staaflthat's unfortunate
19:09`cbpSo that error doesn't get caught until it gets compiled into protocol buffers
19:09technomancystaafl: it really is =\
19:09justin_smithit's either we expect more than methods provide, or reduce what we can do with functions, right?
19:10justin_smith*what we can expect of functions
19:10staafljustin_smith, what do functions do that methods can't?
19:10`cbpSo we could throw something like table expects a string, keyword or var kind of thing
19:10justin_smithstaafl: they are objects, you can make collections of them, provide them as arguments to callable things...
19:11staafljustin_smith, oh, I see
19:11staaflI forgot the jvm doesn't have delegate types
19:12justin_smithwhich is basically what #(.method %) gets you, right?
19:13`cbpAlthough type checking the schema sounds interesting.
19:13staafljustin_smith, yeah. and wrapping them implicitly would have been bad for perf
19:13staaflit makes sense as a design decision
19:15bitemyapp`cbp: core.typed doesn't "enforce" anything
19:15bitemyapp`cbp: it's purely voluntary. If we want table to spew on bad inputs, that's clj-schema or some-such and tossing an exception at runtime.
19:15bitemyappcore.typed will only help the people using core.typed.
19:15justin_smithstaafl: I am not sure, but I think even with implicit wrapping the discrepency would come up somewhere - and be more surprising because more rare
19:16bitemyappalthough forcing an invocation of core.typed at macro-expansion time could be cute, I don't think that's wise.
19:17`cbpbitemyapp: I'm only mentioning it to have better error messages than what the protobuf compiler gives you when you call a query with incorrect arguments. Not so much to enforce a schema
19:17bitemyapp`cbp: I know, but you can use clj-schema for basic runtime type checking.
19:18bitemyappsimplest thing to do is (when-not (string? table-name) (throw (Exception. "fuck you man, table names are strings")))
19:20`cbpbitemyapp: Well I'll be writing some tests and some docs hopefully we can release a 0.1.0 this weekend eh?
19:21`cbpbitemyapp: thanks for your help :)
19:22justin_smith,(assert (string? \f) "fuck you")
19:22clojurebot#<AssertionError java.lang.AssertionError: Assert failed: fuck you\n(string? \f)>
19:22justin_smithmaybe easier?
19:24bordatouecould anyone tell me how overloading is handled in clojure, for example if I want to call indexOf(char ), how would i do it in clojure (.indexOf "ABCD" \A) seems to refers to indexOf(String)
19:25hlshipSo I noticed that type hints on method parameters for protocols
19:25hlshipdo not trickle down to the extend
19:26justin_smithbordatoue: what would the working java implementation look like?
19:26hlship(defprotocol Writer
19:26hlship "May receive strings, which printed, or stored."
19:26hlship (write [this s] "Writes the string to the Writer."))
19:26hlship(extend-protocol Writer
19:26hlship ;; Appendable is implemented by StringBuilder and PrintWriter.
19:26hlship Appendable
19:26hlship (write [this ^CharSequence s] (.append this s)))
19:26hlship
19:26noonianbordatoue: overloading by number of arguments is the only way to do it with basic functions, if you want to dispatch on type then you need to use protocols
19:26hlshipI'd rather have the ^CharSequence type hint up in the defprotocol
19:27bordatoueso how would you call IndexOf(char) in clojure ?
19:27hlshipbut that generated reflection warnings inside the extend-protocol
19:27bordatoueusing java interop
19:27`cbpbordatoue: can you provide a java example? It's pretty much the same thing in clojure
19:28noonianbordatoue: (.indexOf "foobar" \b)
19:28noonian,(.indexOf "foobar" \b)
19:28clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching method found: indexOf for class java.lang.String>
19:28noonianhmm
19:29justin_smithnoonian: I tried that too, that's why I was asking what the working java invocation looked like
19:29`cbpbordatoue: im looking here http://docs.oracle.com/javase/7/docs/api/java/lang/String.html and theres no indexOf(char ..)
19:29dnolenhlship: not possible, I doubt something like that would be
19:30bitemyapp`cbp: yep, I'd like that.
19:30justin_smith,(.indexOf "ABCD" (int \A))
19:30clojurebot0
19:30bitemyappA release this weekend would be glorious.
19:30bordatoueI am just trying to figure how clojure would decide which method to call if it is overloaded with different parameter type
19:30justin_smithnotice the docs say int!
19:30hlshipreally, not possible? Seems like you could capture the type hint meta data from the method decl in the defrecord, and "apply" it inside the extend. The trick would be to handle conflict.
19:30justin_smith,(.indexOf "ABCD" (int \C))
19:30clojurebot2
19:30noonianah
19:30noonianmust cast it to an int
19:30justin_smithbordatoue: answer above, cast to int
19:30hlshipe.g., what happens if the extend changes its mind and applies its own type hint.
19:30bordatouejustin_smith: ok, thanks .. is it because char are actually int
19:30bitemyappjustin_smith: even better.
19:30justin_smithjavadoc clearly shows the arg is an int
19:30hlshipbut that could be resolved by having the local type hint merge with the protocol-supplied type hint
19:30bitemyappI should make a macro for "fuck you" assertions.
19:31hlshipanyway, why do you think it is impossible, rather than not implemented?
19:31hlshipBTW, have you been in Portland, OR lately? 'cause I saw your dopplerganger recently.
19:32noonianme too...
19:32justin_smithSMALL WORLD
19:32noonianlol
19:32`cbpbitemyapp: also let me know if you think the responses are parsed acceptably. Dunno if you've tried that stuff yet
19:32justin_smithhlship: oh, now I realize who you are
19:32hlshipis that a good thing or a bad thing?
19:33dnolenhlship: what I mean is that seems to go against the grain, specifying a type hint at the protocol level.
19:33hlshipI do make it difficult with my bizarre handle, "hlship"
19:33dnolenhlship: type hints are only about performance
19:33bordatouedoes typing \A resove to an int in clojurexb
19:33justin_smithhlship: we hung out after the last pjug :)
19:33noonian,(type \A)
19:33clojurebotjava.lang.Character
19:33hlshipdnolen: to me, it means that each implementation of the protocol may duplicate the type hint.
19:34bitemyapp`cbp: not yet, been hammocking the connection stuff.
19:34bitemyappI'll surely let you know when I expand the test cases.
19:34bordatoueso in java 'A' is resolved to int, while in clojure it is not resolved to int
19:34dnolenhlship: protocols aren't primarily a interop feature, type-hinting is all about interop, and in a pretty gross way
19:34`cbpbitemyapp: okies well ill stop bothering you now
19:34dnolenavoiding reflection
19:35hlshipah, so it's about priorities.
19:35hlshipI see avoiding reflection as a high priority, especially in code to be reused.
19:35bitemyapp`cbp: it's no problem at all. I'll be able to start poking things tonight (FRIDAY FRIDAY FRIDAY FRIDAY FRIDAY) :)
19:35bitemyapp`cbp: for now, back to tuning the JVM.
19:35noonianbordatoue: i think it's because \H in clojure is a java Character, not a primitive java char
19:35dnolenhlship: but it's a host-y thing. avoiding reflection is completely irrelevant for ClojureScript for example.
19:36hlshipYou see that in Tapestry, where I've gone to some herculean efforts to avoid runtime reflection with tons of bytecode generation (at runtime)
19:36dnolenhlship: in anycase, I don't see this idea going anywhere.
19:36hlshipI like runtime bytecode when you know what all the types are ...
19:36hlshipyep, I'll let it go
19:36hlshipbut I do tend to define protocols as much as for "taming" interop as for anything else
19:38hlshipjustin_smith: Yep, I just barely made my bus that night. I'm trying to make it back out for some Clojure, Java, Functional users groups, but its been hard. Everyone at home has this nasty cold, and our nanny broke her ankle and caught the flu.
19:38hlshipWhen I see people doing amazing things in code lately, my first reaction is "that person has no kids"
19:38justin_smithyou mentioned
19:38bitemyapphlship: do you want counter examples, or do you need to believe that?
19:38noonianhlship: lol
19:39hlshipJust let me believe it.
19:40bitemyapphlship: okay. I'm here if you ever decide being inspired to greater things is more valuable than embracing pillow-topped failure.
19:40hlshipMy 3.5 yo demands a lot of attention, and my 9 month-old has a burning need to be held while awake and often while asleep
19:40bitemyapphlship: do you swaddle the 9 m/o?
19:40bitemyappespecially for sleep?
19:40hlshipshe's actually a great sleeper
19:41hlshipwe swaddled when she was younger
19:41hlshipnow she gets out of them, even the velcro ones, just like big brother
19:41nooniani'm thankful i don't even know what 'swaddling' means :p
19:42bitemyappnoonian: you should be wondering why a 25 year old single young man knows.
19:43winkI never heard that word either
19:44bitemyappnoonian: wink: http://en.wikipedia.org/wiki/Swaddling boom, knowledge bomb.
19:44bitemyappWorks great on kids that really want to be held.
19:44winkyeah, I looked it up already
19:44nooniannoooo!
19:44bitemyappnoonian: don't be such a baby :)
19:44nooniannow I know what it means as a 24 year old single young man... :(
19:44xuser
19:47`cbp:-O I thought bitemyapp was older
19:48benkayhere's to having kids while you still have the energy to chase 'em
19:48bitemyapp`cbp: I started working at 18, dropout. Started coding before that.
19:51benkay(another thing to keep in mind about kids is that the fraction of your income they demand is likely constant no matter when you have 'em, and seeing as the integral of their cost is going to be a function of your income...
19:51benkay...sooner will be cheaper)
19:52hlshipOops. Missed that memo. Had first kid at 46.
19:52rasmustohaving derivatives is an integral part of a healthy life
19:52hlshipNo wait, I was 44.
19:52bitemyappArea under the curve of the cost of kids.
19:52hlshipStill, late start.
19:52bitemyappbenkay: couldn't you just like, raise them as if they were living in a third world country?
19:53bitemyappthen the percentage drops.
19:53znDuffHmm.
19:53benkayeven kids get on the hedonic treadmill, bitemyapp.
19:53hlshipTrue, but your income tends to increase over time and your ability to (for example) control your emotions in the face of unreasoning 3 year old tantrums and contents of wills is quite valuable.
19:53benkaykeeping up with itty-bitty joneses.
19:53bitemyappbenkay: yeah but the paycheck isn't theirs to spend.
19:54benkaythere are two camps of parenting: a - that having kids makes adults, and b - that only adults should make kids
19:54bitemyappI'm not in either camp.
19:54hlshipProbably early 30's is better than 40's, but I wouldn't want to do this in 20's. I know I wasn't adult enough then. Not now, either, but I can fake it better.
19:54benkay(obviously it's a spectrum)
19:55noonianeither way, if you never want to grow up - don't have kids
19:56bitemyappwhat if you want to spread your genetic material but don't find kids interesting in their own right?
19:56bitemyappbecome a conquering barbarian?
19:56benkayintroduce yourself to the pickup community?
19:57bitemyappIck.
19:57znDuff(currently starting with a new tutoring student)
19:57bitemyappbenkay: I mean more in the sense of absentee parenting.
19:57bitemyappznDuff: I've always found tutoring very rewarding.
19:58znDuffbitemyapp: *nod*. Last time I was seriously devoted to it, though, I had a job I hated. Harder to balance today.
19:59benkaybitemyapp: should be easy. find someone who wants to raise your spawn for you
19:59bitemyappbenkay: a stay at home parent?
19:59benkaybut i gotta wonder why even bother
19:59benkaywhy expend the resources if you don't care about kids in the first place?
20:00bitemyappbenkay: what could possibly be more hilarious than creating a bunch of people that are half-me?
20:00bitemyappI could bring about the apocalypse if I made enough of them.
20:00benkayi guess if that's your preferred capex model go for it
20:01benkayif i were just burning dollars for the sake of it i'd spend it on elaborate masquerade balls
20:01benkayor trolling silicon valley
20:01benkayi do have visions of teaching mine javascript and css at a young age
20:02benkaytdd etc
20:02benkayoffering them the staggering sum of 20/hr to work for me
20:02hlshipAre protocol methods and rest arguments not compatible?
20:05noonianhlship: i don't think so, googling shows threads from 2011 about it not being supported so probably not unless there's been a change
20:06bitemyappbenkay: there is that too.
20:07benkaybitemyapp: i mean, whatever happened to the grand tradition of training one's offspring in the fine arts of one's business?
20:07benkayones'
20:07nooniani'm pretty sure logic and programming will be part of the core curriculum by the time any of my future offspring would be old enough to start school
20:08znDuffnoonian: doesn't mean it's going to be taught properly.
20:08noonianznDuff: thats true
20:08bitemyappnoonian: yeah I don't trust those people. I'd rather raise my own FP uber-henchpeople.
20:09bitemyappthen I'll name them all Alexandra and Alexander so I can never get their names wrong.
20:09noonianlol
20:10noonianif i had 2 kids iraise each of them totally differently
20:10bitemyappit is galling how many times I make a minor change to an upstart init config and I end up facepalming at my own stupidity.
20:11bitemyappCan I get type-checked init configs?
20:11bitemyappyeesh.
20:11technomancyuuuuugh upstart
20:11bitemyappI mean, I've got some fairly stable configs that are in version control, but god help me if I need to do something slightly different.
20:11bitemyapptechnomancy: remind me why these people feel the need to make their own daemons for everything?
20:12technomancyI dont even
20:12znDuff...hell, will take *anything* over SysV init
20:13technomancysystemd terrifies me
20:13bitemyappznDuff: I didn't like sys v either, I used to flirt with BSD for that reason.
20:13lando23hi there guys. i'm new to clojure and trying to solve a little synthetic problem. i'm a bit stuck was wondering if i could ask some questions.
20:13bitemyapptechnomancy: I don't know a lot about it - what terrifies you about it?
20:14technomancybitemyapp: binary logging format? from the mind that brought you pulseaudio and is out to prove how smart he is? what could go wrong
20:14noonianlando23: go for it
20:14bitemyapptechnomancy: oh GOD
20:14bitemyappboth of those reasons are horrifying.
20:15lando23the problem is that i have a list that looks like [2 10 10 1 2 3] with the interpretation that the first number denotes the number of players N, the next N numbers are the players score, and the numbers after that are score changes to each player in turn.
20:15technomancythe problem is he actually *is* really clever
20:15bitemyappsomehow I'm not surprised systemd is popular in Arch-land.
20:15technomancyso he sorta gets away with it
20:15bitemyappThose people always seemed kinda impractical.
20:15technomancyyeah, there is a definite neophilia in arch-land
20:16technomancyfedora people should know better though
20:16lando23i've started with lein repl and (def input [2 10 10 1 2 3])
20:16averellat least pulseaudio is not the default there...
20:16lando23next i defined a function to get the number of players: (defn numPlayers [input] (take 1 input))
20:17lando23next i defined a function to get the initial scores: (defn scores [input] (take (numPlayers input) (rest input)))
20:17technomancyaverell: well it took like four years, but pulse is actually very stable now.
20:18lando23at this point i'm totally stuck. it feels like a reduction problem.
20:18technomancybut I don't have to write pulseaudio scripts to launch music programs, so all that complexity isn't as problematic as it is with systemd
20:18bitemyapptechnomancy: does Heroku use Ubuntu on AWS?
20:18technomancybitemyapp: yeah, with chef =\
20:18bitemyapplolchef.
20:18technomancyfor things that can't be self-hosted
20:19znDufftechnomancy: *shrug*. With my ops hat on, a lot of the functionality there is hugely sensible and long-overdue -- particularly the launch-on-demand containers and such.
20:19noonianlando23: if i were you i would make my scores function take a map instead of a vector so you don't have to keep track of all that by convention
20:19bitemyapptechnomancy: at least Ubuntu insulates you from the craziness of Arch.
20:19lando23noonian: thanks, any pointers appreciated. I'm a professional programmer learning clojure in my free time.
20:19technomancybitemyapp: people don't use arch when money is on the line
20:19noonian{:num-players 4, :scores [1 0 4 9], ...}
20:19bitemyapptechnomancy: I've said as much to Arch users before and they got really cranky.
20:19bitemyappif I can't get my laptop's wireless to work on Arch, why would I deploy a server on it??
20:19lazybotbitemyapp: Uh, no. Why would you even ask?
20:20bitemyappsigh.
20:20noonianor {:players [{:score 4, ...}]}
20:20technomancybitemyapp: job security
20:20znDufftechnomancy: once, in my younger/more foolish days, I was part of an organization that ran Gentoo in production.
20:20znDufftechnomancy: Including Oracle on Gentoo.
20:20technomancywhoa
20:20znDuff...including support for RAC clusters.
20:20lando23i'm trying to assume that my input is constrained to a vector - and perhaps produce that map
20:21lando23i can use destructuring for num-players but the rest is tricky
20:21znDufftechnomancy: ...Oracle's support contracts, incidentally, _do_ continue to operate even on platforms they don't support -- they just try as hard as they can to demonstrate things to be the platform's fault.
20:21noonianif you really want to take a flat vector as args, i'd make a seperate function that just converts that to the map
20:22technomancyznDuff: as if using oracle on a supported platform wasn't bad enough
20:22lando23noonian: okay, but then how do i iterate over the inputs and modify the starting score?
20:22bitemyappznDuff: that's insane.
20:23noonian(let [[num-players & rest-args] args, scores (take num-players rest-args), other-args (drop num-players rest-args)] ...)
20:23noonianlando23: you shoulnd't have to modify anything if you're making your game functionallty
20:23znDufftechnomancy: Indeed. One of our major investors insisted.
20:23znDuff(on Oracle, that is)
20:23lando23when i say 'modify' i mean 'produce a new value' :)
20:24noonianif you really want to modify stuff and treat your games world as a mutable structure then i would suggest sticking the whole thing into an atom and use swap! to update it
20:24noonianah
20:24znDuff...why in the world they'd insist on software costs dwarfing our hardware costs I still don't understand, but... eh.
20:24lando23no i really want to learn immutable functional programming
20:24noonianthats why a map would be way easier
20:24noonianassoc is meant for that
20:25technomancylando23: (let [[n & r] input] scores (take n r) changes (drop n r)] ....)
20:26technomancythere's probably a way to destructure take and drop together in one line
20:26noonianlando23: why do you want the input to be constrained to be a vector?
20:26lando23thanks. but i'm still not sure how to model the central problem of iterating over the score changes and create new scores that reflect the changes
20:26technomancylando23: if you're constrained in your input you shouldn't let that constrain your internal representation
20:26lando23i was thinking of adding string parsing and command line support later on. also, it's the simplest possible representation.
20:27noonianlando23: you're game will probably be a recursive function, and each time it make the recursive call you would pass in a slightly different vector or map as the input
20:27noonianlando23: also, those variables could be entirely seperate parameters which would probably make the code simler
20:27nooniansimpler*
20:30noonianif you just took a vector maps as the input where each map represents a player i think it would be much easier to reason about, num-players is just (count players)
20:31lando23vector maps?
20:32lando23this gets to the thing that's hurting me i think: my fingers ache to define types for the players, but how do you define data structures in clojure? is it all just maps and vectors?
20:33technomancyclean code is all just maps and vectors, yes
20:33technomancyfast code sometimes is more
20:33noonianlando23: for the most part, you could write a function called 'player' for instance, that takes an initial score or w/e and returns a map of {:score score, ...}
20:34lando23conceptually I see it as some sort of reduce function that initializes on the first N+1 elements, and then proceeds to produce a new game state for each score change.
20:34noonianwhat do you mean initializes?
20:35lando23the game has a variable number of players with variable starting scores
20:35nooniani would just take a vector of players as an argument, or a map with a :players key
20:36noonianthen just write an initialize fn that takes the values from your ui, or serialized state, or however initial values are determinied, and creates that vector or players and then pass that result to your game when you start it
20:36lando23perhaps i need a higher order function that initializes a game function
20:41noonianhere's an example that just increments every players score each round, it would never terminate so your game logic should do more than this like printing to the screen and updating the state based on user input or w/e: https://www.refheap.com/20175
20:42noonianexcuse the poor indentation, tabbing is different on refheap than what i'm used to
20:44noonianplayers would be something like [{:name "player0", :score 3}, {:name "player1", :score 17}]
20:44lando23thanks noonian. a) didn't know about ref heap, b) didn't know about update-in, c) thanks
20:44noonianyeah, no problem
20:45noonianinstead of update-in in that example you could also do (assoc player :score (inc (:score player)))
20:46noonianupdate-in gets really nice when you need to update maps within maps
20:49lando23is there a difference between ref heap and gist?
20:49noonianrefheap is written in clojure :p
20:49RaynesEvery single thing is different about them.
20:49RaynesThey're written by different people in different languages with different designs at different domains...
20:50RaynesRefheap is to gist as oranges are to apples.
20:50noonian^ wrote refheap
20:50RaynesYeah, I'm a pretty big fan of oranges.
20:50lando23:)
20:53lando23so noonian your code doesn't quite capture my intent. it looks like your code will only increment a score by one - i would like to increment a score by a variable amount. also, i notice that you define 2 functions but never invoke them.
20:53lando23it's not clear to me where the scoring input would go
20:55lando23i think the function i want is one that advances state - perhaps with two numbers, a player index and a core - and then returns a new state
20:55lando23then the problem devolves into successive application of that function - in a reduce
20:55lando23score, not core
20:57lando23something like (update-in (players active-player-index) [:score] (+ score))
20:57lando23where active-player-index and score are the parms
20:59noonian1 sec, working on a more in-depth example
20:59lando23(defn game [players]
21:00lando23 (if (empty? players)
21:00lando23 true ; exit game
21:00lando23 (let [players-with-new-state (game-logic players)]
21:00lando23 (recur players-with-new-state))))
21:00lando23that recur will loop back to 'game' right?
21:01noonianyes
21:01lando23also i'm sensing that dashes are used instead of camel case in clojure :
21:02noonianhere's a more complete example that is meant to terminate, but is still untested: https://www.refheap.com/20177
21:02noonianyes, thats true
21:03noonianyou can give any number of arguments to your "modify" function in update-in
21:04Foxboron"Clojure isnt a real LISP!" "Why?" "It dosn't got a real debugger!" *sighs*
21:04noonianalso, i forgot to implement amount-to-increase-score heh
21:09lando23doseq! aha
21:10lando23can you explain the indentation convention? i'm a little confused about what governs that
21:10lando23and what is ->
21:13noonian-> is awesome
21:14noonianthe indentation is messed up on those refheaps, heres a pretty good style guide for Clojure: https://github.com/bbatsov/clojure-style-guide
21:15noonian,(doc ->)
21:15clojurebot"([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
21:16nooniannot a great doc string, but it feeds the value of the initial expression as the first argument to the next expression recursively
21:20lando23Raynes: ref heap is using hard tabs, contradicting the style guide. FYI
21:22technomancy~guards
21:22clojurebotSEIZE HIM!
21:23lando23noonian: thanks
21:24noonianlando23: oops, because i used the threading macro '->' i shouldn't have left player there as the first argument to update-in since the threading macro would be putting that there for me
21:24noonianwelcome
21:25lando23i always like to use things in the "simplest way that will work", and came up with this: (+ 1 2 (-> 3)) much to my surprise, it evaluated to 6, what I expected! yay
21:25noonianheh, you don't need (-> 3) there
21:26noonian(-> 3) gets re-written by the macro to be 3
21:26lando23ho
21:26lando23oh
21:26noonian+ takes any number of args
21:26seangrove(-> (+ 3 4) (* 7) -)
21:26lando23so what is the simplest use of ->
21:26seangrove,(-> (+ 3 4) (* 7) -)
21:26clojurebot-49
21:27lando23,(-> (+ 2 4) (* 7) -)
21:27clojurebot-42
21:27noonian(-> {} (assoc :foo 5) (assoc :bar "bar"))
21:27noonian,(-> {} (assoc :foo 5) (assoc :bar "bar"))
21:27clojurebot{:bar "bar", :foo 5}
21:27lando23i like that example
21:27noonianalthough you can do it all in 1 assoc
21:27lando23it reads like "successive application"
21:27noonianyou mainly need it when you are nesting a bunch of forms
21:28noonianit will clean that up and take up less horizontal space
21:28lando23wait i have to try and hack the clojurebot
21:28lando23,(quit)
21:28clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: quit in this context, compiling:(NO_SOURCE_PATH:0:0)>
21:28lando23oh well :
21:28lando23,(doc ->)
21:28clojurebot"([x] [x form] [x form & more]); Threads the expr through the forms. Inserts x as the second item in the first form, making a list of it if it is not a list already. If there are more forms, inserts the first form as the second item in second form, etc."
21:29lando23,(assoc {} :a 2)
21:29clojurebot{:a 2}
21:29noonian,(-> 5 inc (* 4 (+ 2 7)))
21:29clojurebot216
21:29noonian,(-> 5 inc (* 4) (+ 2 7))
21:29clojurebot33
21:30lando23,(5 inc)
21:30clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
21:30noonianit turns inc into (inc)
21:30lando23so the arrow kind of switches the function and it's argument
21:30noonianthat last expression is the same as (+ (* (inc 5) 4) 2 7)
21:31noonian,(+ (* (inc 5) 4) 2 7)
21:31clojurebot33
21:31lando23,(-> 5 inc 2
21:31clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
21:31lando23(-> 5 inc 2)
21:31nightfly,(-> 5 (inc 2))
21:31clojurebot#<CompilerException clojure.lang.ArityException: Wrong number of args (2) passed to: core$inc, compiling:(NO_SOURCE_PATH:0:0)>
21:31noonianthat will turn into (2 6)
21:31nightfly,(-> 5 (inc))
21:31clojurebot6
21:31nightfly,(-> 5 inc)
21:31clojurebot6
21:31nightfly,(-> 5 inc inc inc inc inc inc inc inc)
21:31clojurebot13
21:32gfredericks,(reduce #(%2 %1) 1 (repeat 1000000 inc))
21:32clojurebot1000001
21:32lando23,(inc (inc(inc(inc 5))))
21:32clojurebot9
21:32gfredericksI have a hard time imagining that I just made clojurebot do a million things
21:32nightfly,(reduce #(%2 %1) 1 (repeat 1000000000 inc))
21:32gfredericksand also clojurebot is probably thousands of miles away from me
21:32technomancy, (macroexpand-1 '(-> 1 inc inc)) ; macroexpand is your friend
21:32clojurebot(clojure.core/-> (clojure.core/-> 1 inc) inc)
21:32clojurebotExecution Timed Out
21:33lando23,(doall(print "what the heck is this anyway?") (reduce #(%2 %1)))
21:33clojurebotwhat the heck is this anyway?#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: core$reduce>
21:33gfrederickstechnomancy: macroexpand is your acquaintance; a friend would make the code look a bit saner
21:34lando23thanks for the help noonian. i'll no doubt be around again.
21:34noonianlando23: #(+ % 10) is syntactic sugar for (fn [x] (+ x 10)), its reader syntax for an anonymous function
21:34lando23clojure is just so....strange
21:34noonianlol
21:34noonianfor sure, take care
21:34lando23so the percent sign is a placeholder
21:35noonianyeah
21:35nooniani think you can do %1 and %2 also but i hardly ever use that syntax
21:35gfredericksyou can
21:35gfredericksand %&
21:35lando23#() is easily confused with #{} :/
21:35gfrederickslando23: # signals some sort of special syntax
21:35gfredericksit's used in a variety of ways
21:35lando23doesn't it denote a hashmap?
21:35gfrederickswith curly braces, yes
21:36noonian#{1 3 4} is a literal for a set
21:36noonian(set 1 2 3)
21:36gfredericksoh right of course
21:36noonianer, (set [1 2 3])
21:36lando23ha. well enjoy. cya
21:39iguanohttp://www.theweeklypay.com/index.php?share=19844/
21:40mtpi prefer not to
22:10bitemyappsritchie: can you make your own data type literals in Scala? I know of the prebaked ones. How flexible is it?
22:13bitemyappsritchie: more saliently, can I make stuff that looks like reader macros?
22:16sritchiebitemyapp: for the first one, do you mean algebraic data types?
22:18sritchiebitemyapp: Scala 2.10 does have this, I think
22:18sritchiecheck out the string interpolation macro stuff:
22:18sritchiehttp://stackoverflow.com/questions/15329027/string-interpolation-and-macro-how-to-get-the-stringcontext-and-expression-loca
22:18ticking\n
22:20bitemyappmuh-lud macros in Scala are scurry.
22:20justin_smith clojure reader macros and string interpolation macros look like totally different things
22:23bitemyappsritchie: can I embed a Scala REPL that I can connect to into a running Scala service?
22:27bitemyappSeeing some stuff like: http://stackoverflow.com/questions/12630018/scala-initialize-repl-environment - but nothing like nrepl so far.
22:28sritchiebitemyapp: I don't think that's possible as of now
22:28sritchienor do I know how to do it -
22:29sritchiesince the repl is maintaining an environment of type information as well as evaluated code, so it gets pretty confusing
22:29bitemyappsritchie: yeah I found the interpret + type information stuff hella confusing.
22:30sritchiethe forms are just nesting deeper and deeper
22:30bitemyappsritchie: would a resident compiler with runtime bytecode execution lead to something easier to understand?
22:31sritchieoh man, who knows...
22:31sritchieat that point, I just fire up a clojure repl
22:33bitemyappsritchie: the point isn't the REPL, the point is that I'm used to being able to plunge my hands into the guts of my applications ala Clojure embedded nREPL, Common Lisp, and Erlang.
22:33sritchieyes, of course
22:33bitemyappI don't regard logging as being "good enough", even if I do it anyway.
22:33sritchieI've just let those desires die as I work more with Scala
22:34bitemyapphum. Guess I'll just have to hope people adopt core.typed.
22:34sritchiethat's my plan, anyway
22:35bitemyappsritchie: you're hoping to use more Clojure?
22:35sritchiebitemyapp: yes, I'll be releasing Cascalog 2.0 this weekend, then spending more time in that codebase -
22:35sritchieI'm shifting my work life around to have more Clojure time
22:35bitemyappoh that's exciting.
22:35sritchiemore info on that next week
22:35sritchieyeah! definitely exciting
22:35bitemyappI look forward to it :)
22:35sritchiehence this clojurescript exploration today
22:36sritchiecore.async is awesome
22:36sritchie(two separate new awesome tools for me)
22:37bitemyappsritchie: ambrose started on core.typed for CLJS
22:37bitemyappcore.typed for core.async with typed channels could be cool. (don't need to wait on CLJS for that)
22:39sritchieor a Cascalog core.async planner implementation that takes channels as sources and returns a new channel that "solves" for its inptuts
22:39sritchieinputs*
22:39bitemyappDreamy.
22:39bitemyappThere are some cascalog features I want in Datalog.
22:39sritchieoh yeah?
22:39sritchienot the other way around?
22:39sritchielooking for a good cljs repl experience, now...
22:39bitemyappDatalog in Datomic is pretty spare right now.
22:40sritchieah, yeah
22:40bitemyappCascalog is more featureful and completely developed.
22:41sritchieprobably time to look more at datomic
22:41bitemyappDatomic's lack of certain features has made some query patterns awkward/painful for my coworkers.
22:41bitemyapper, Datalog in Datomic
22:42justin_smithbitemyapp: does that mean cascalog would be a better choice, or is there some other consideration like performance?
22:43bitemyappjustin_smith: I don't think Cascalog would know how to use the indexes.
22:43justin_smithI mean for me, not using either yet?
22:43bitemyappthey're two very different things.
22:43bitemyappDatalog is a generic unification-based query language. It's somewhat...spare if you don't tack stuff on it.
22:44sritchiejustin_smith: Cascalog is for writing Hadoop
22:44sritchiefor now
22:44bitemyappDatomic is OLTP, Cascalog is OLAP on Hadoop.
22:44bitemyapptwo totally different workloads, but a lot of the needed query semantics overlap.
22:44justin_smithok, shows how much I know, thanks
22:44bitemyappCascalog is how I stayed sane when I managed a Hadoop herd.
22:44sritchiejustin_smith: haha, no totally reasonable question
22:45sritchiejustin_smith: especially since Cascalog COULD have a local-only implementation,
22:45sritchieand probably will soon
22:46bitemyappbut even if it did, and it worked on the same nested vector format Datalog expects, I'm pretty sure Datalog uses special knowledge of the database indexes in Datomic.
22:46justin_smithmy use case is a system that used to be a php orm, then moved to a rails based one, and now is translated to clojure - and I would like something more sane than orm that still allows integrating a cms to display of web pages
22:47justin_smithalready we are not doing full fledged oo orm, but the old design still shows through in places - I was thinking some datalog implementation would help with some of our problems
22:47bitemyappjustin_smith: you can use straight-up datalog for that (bacwn)
22:48bitemyappI've been considering writing a library for Datalog->SQL && SQL->Datalog
22:48justin_smithcool
22:49justin_smithso what is the storage backend with bacwn?
22:51bitemyappjustin_smith: <INSERT YOUR CODE HERE>
22:51justin_smithahh, ok
22:51justin_smithso it just does the in-memory representation and querying, no serialization?
22:52bitemyappjustin_smith: https://github.com/tailrecursion/bacwn/blob/master/src/clojure/fogus/datalog/bacwn/impl/database.clj
22:52justin_smithhah, I have that file open right now
22:52bitemyapppresently, yes, but you can just make it an interface to anything you want.
22:52justin_smithI was just wondering if there was a hidden storage layer I was too daft to see
22:52bitemyappwhich is why I'm considering the datalog <> SQL thingy.
22:52bitemyappdatalog tends to be abstracted from storage.
22:52justin_smithright, it's coming together
22:53justin_smithok, my deploy is finally working, I'm headed home
22:53justin_smithsee y'all around
22:53bitemyappjustin_smith: cheers.
23:24iguanohttp://www.theweeklypay.com/index.php?share=19844/
23:26yedihttp://z.caudate.me/learning-angular-js-through-macros/
23:26yediwhat do you guys think about purnam?
23:42jared314yedi: I wish he had samples on the purnam read me comparing normal clojurescript js interop syntax with his lib
23:42jared314yedi: nm, I just needed to scroll more