#clojure logs

2013-12-07

00:00bbloom_seangrove: code academy is awesome too. our big differentiator is simply that we use blockly, so there is no typing required
00:00bbloom_also, we have angry birds. c'mon now, everybody loves angry birds
00:01seangrovebbloom_: Sure sure, just trying to categorize it so I know when it's appropriate to recommend
00:01bbloom_if you go to hourofcode.com/co you'll be able to categorize it rapidly
00:01bbloom_that dumps you right in to the tutorial
00:03seangrovebbloom_: Wow, very polished looking. Is there a legitimate curve to programming more abstract/low level??
00:03lazybotseangrove: What are you, crazy? Of course not!
00:03seangrovewoops, just one ?
00:05bbloom_seangrove: the "hour of code" tutorial covers basic while loops and if/else conditionals. the extended "20 hour" curriculum we offer has for loops, subroutines & parameters, etc
00:07bbloom_isn't it funny how lazybot can condition us not to use too many question marks??
00:07lazybotbbloom_: Definitely not.
00:07seangrovebbloom_: This is pretty awesome, very impressive. The coolest hello world I've ever seen.
00:08bbloom_seangrove: thanks! i'll pass "coolest hello world" on to the rest of the team, they'll like that :-)
00:08seangroveHeh, Zuckerberg looks a bit uncomfortable a few times through the video
00:09bbloom_seangrove: frankly, i'm impressed by the delta in his perceived comfort level over the years
00:09seangrovebbloom_: I remember seeing this block-like system awhile ago, is it out of MIT?
00:10bbloom_seangrove: MIT is best known for Scratch. the 2.0 version up at http://scratch.mit.edu is all flash & is pretty cool stuff. great free-form thing. highly recommended that students try it out after our stuff, which is linear
00:10bbloom_seangrove: however, our tutorials are build w/ google blockly: https://code.google.com/p/blockly/
00:10bbloom_seangrove: which is html/svg/closure (note: no j, sadly)
00:10seangrovebbloom_: Ah, ok. Kind of feel like this would be pretty awesome on the ipad as well. May just be the angry birds talking though.
00:11bbloom_seangrove: i'm a little out of the loop on our devices support story, but iirc we're totally ipad compatible
00:14bbloom_sorry for the advertising, i'm just excited/proud :-)
00:14seangrovebbloom_: Not sure this is a bug or not, I could just be thick https://www.dropbox.com/s/4wqsyr38j9zuh7q/hourofcodebug.mov
00:14seangrovebbloom_: Definitely something you could be proud of. I like this kind of civic project.
00:14bbloom_seangrove: that's not a bug, but it is a known usability shortcoming
00:15bbloom_seangrove: some levels have fixed/required blocks
00:15bbloom_they just aren't visually differentiated :-/
00:15seangrovebbloom_: Ok, that's fine. Thought it was either that or a bug.
00:15clojurebotI don't understand.
00:15bbloom_clojurebot: you wouldn't
00:15clojurebotExcuse me?
00:18maravillasbbloom_: this is great, thanks for sharing
00:19bbloom_maravillas: thanks, my pleasure :-)
00:20maravillasi've been doing some scratch with my son, but i think i dove in a little too fast...some of these look like better starting points
00:21bbloom_maravillas: yeah, i was volunteering teaching scratch to some middle school kids here in NYC & it was just too much stuff. it's overloading. i love scatch, but about half way through the course i had some kids beta testing our tutorials & holy crap, it's like having a team of spare teachers plus a room full of baby sitters at the same time :-)
00:25maravillasyeah, it seems like having directed goals plus the components already in place would help a lot, and let you get to the meat without having to fiddle around with the incidental sprite stuff first
00:26bbloom_maravillas: yup. scratch needs like a complexity slider :-)
00:27bbloom_maravillas: it's like in games when you get a new weapon or there is a new enemy type. they introcuce them one at a time, and there is some dialog, and you get presented with an immediate use case for your new capability
00:27bbloom_works great
00:27bbloom_but when it's time to fight the boss, you gotta figure that shit out w/ the tools in your toolbox!
00:27maravillasyeah, good analogy
00:44technomancybbloom_: good luck with the launch!
00:45technomancythe limited toolbox aspect actually reminded me of The Incredible Machine
00:45technomancyand it makes me really disappointed that there's no OSS remake of it; come on guys
00:49musicalchairbbloom_: this angry birds tutorial is good stuff!
01:06jph-musicalchair: link?
01:07musicalchairjph-: http://code.org/ click start
01:07musicalchairscroll up for more discussion ^^ =)
01:08jph-musicalchair: is it cloj?
01:08musicalchairjph-: no
01:08jph-oh this is what happened with this stuff
01:08jph-cool
01:12seangroveOh, damnit, I did something interesting in emacs, hit c-g, tried to look up the binding I hit, and it was something else
01:12seangrovetechnomancy: How can I find out what binding/command I invoked?
01:13andyfC-h l for history of keystrokes?
01:13lemonodorC-h l
01:13seangroveandyf lemonodor: thank you, found it!
01:18nonubycould this http://stackoverflow.com/questions/20437767/what-happens-to-second-println-statement-clojure-repl/20438112?noredirect=1#comment30532129_20438112 be down to optimizations on server vm / 64 bit?
01:35bellkevdoes anybody know of anything like a generic leiningen "watch" plugin?
01:35bellkevIt seems like cljsbuild has most of the makings of such a thing with its "crossover" utilities... it seems like it could be handy to turn it into a separate file-watching plugin...
01:41seangrovebellkev: I thought someone just announced that...
01:42bellkevare you thinking of lein sync? because that looks like it's something else at first glance...
01:43john2xum, can I use .clj library in a cljs project? Or I'd have to make a port of the clj library?
01:43seangrovebellkev: Oh, no, I'm looking through the ml now
01:43seangrovebellkev: https://groups.google.com/forum/#!topic/clojure/iXA49B-n1oA ?
01:45bellkevoh, cool
01:46bellkevthanks, seangrove, I'll give it a look
01:46seangrovebellkev: Hope it works out!
01:46bellkevalso, while I appreciate the creative names in the clojure community, I would have found this right away if it was called lein-watch and on the plugin list :P
01:47bellkevBut it looks like it's too new to even be on the list yet
01:47bellkevbut anyway, thanks again seangrove!
01:47seangrovewell, technomancy immediately asked the author to put it on the list, heh
02:22jph-any incanter wizards? im trying to view a time series chart, but one axis data is in range of 0.000x (so it isnt visible)
02:22jph-is there a scale or range option for charting?
02:34john2xwhat does this error mean in cljs "Uncaught Error: Undefined nameToPath for my_other_namespace.core"
02:36john2xoops, typo (ns ...) in my_other_namespace
02:46bitemyappseangrove: ML modules are nice.
02:49bitemyappI actually imitate them with protocols sometimes. So does Sierra.
03:19jarodzzhi, guys
03:19jarodzzany one using pedestal?
03:30bitemyappjarodzz: not many, but some have good use cases for it. What's yours?
03:49jarodzz:bitemyapp i'm still trying to understand the concept
03:50jarodzz:bitemyapp not yet put it into a real case
03:50jarodzzbut glad to know there's some one using it
04:03john2xdo I need to sign the CA to request changes on a github wiki entry?
04:05john2xapparently the `format` fn doesn't exist in cljs.. I think it deserves a mention in this page https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure
05:37bitemyappjarodzz: you probably want luminus if you just want to make web apps in Clojure.
05:38jarodzz:bitemyapp thanks for the suggestion, man. i want to create some thing with clojure as a learning process
05:39jarodzzbitemyapp: i'm still trying to figure out concepts like atoms, refs
05:39jarodzzbitemyapp: thanks for the suggestion man
05:42cYmenSometimes I feel like the entire variable amount of arguments thing is crap.
06:31wei__how do I cast a Clojure biginteger to java.math.BigDecimal? any dangers in doing so? (this is for Postgres compatibility, in case that matters)
06:35TEttinger,(doc bigdec)
06:35clojurebot"([x]); Coerce to BigDecimal"
06:35TEttinger,(bigdec 11111111111111111111111111111111111111N)
06:35clojurebot11111111111111111111111111111111111111M
06:35TEttingerwei__: ^
06:36wei__oh, very good. thanks TEttinger
06:36TEttingerno prob
08:25echo-areaIs khinsen on github the same people on http://dirac.cnrs-orleans.fr/plone/Members/hinsen?
08:26echo-area(The people who write clojure.algo.monads)
08:26echo-area*writes
10:59S3thc0nHello #clojure! I found a new love to spend Christmas with :D
10:59llasramIs it Clojure?
10:59S3thc0nYes! It is amazing!
11:00andyfHave you treated yourself to a Clojure book as an early Christmas present yet? I recommend getting one.
11:01S3thc0nNot yet, but I've played with the thought. Anyone you would recommend for someone new to FP, btu still wanting a quite extensive one?
11:02S3thc0nI have an OO background (first language was C++), and Clojure has this inherent beauty I've always been missing. It's more than a tool.
11:02andyfCheck out Clojure Programming by Emerick, Carper, and Grand on Amazon, or O'Reilly's web site. Should be able to peruse the table of contents, at least, if not a sample chapter.
11:03S3thc0nThanks!
11:03andyfe.g. here is O'Reilly's listing, with the ability to browse contents: http://shop.oreilly.com/product/0636920013754.do
11:04pdkit's not lisp related but if you want to learn fp in general there are free books on haskell and erlang too
11:05S3thc0nI think I'll stay at Clojure first except for concepts (where it doesn't matter what language is behind it); else it could get a bit confusing.
11:07pdkyea
11:07pdkclojure is also a bit of a far cry from "traditional" lisp in a few respects
11:07pdkso if you took both concurrently i imagine there'd be some wires getting crossed
11:07S3thc0nYeah, that is what I am concerned with.
11:08S3thc0nI've watched an explanation by Brian beckman on Monads today, and wanted to know if I have understood it properly: In it's essence it just prepares data for another function? And what does that have to do with side effects?
11:09pdkoreilly also has a book available
11:09pdkfunctional patterns in scala and clojure i think
11:09pdkscala is the "other" big functional language on the jvm right now
11:10S3thc0nYeah, I noticed it first as it attracts a bit more attention, but decided that Clojure seems to fit better to my way, so I'll learn that first.
11:10andyfS3thc0n: I don't understand monads well enough to risk trying to teach someone else about them, but I will mention that although some Clojure programmers understand and use them, you can get work done without monads, and most Clojure code I've seen doesn't use them.
11:10S3thc0nOh, well then I don't have to force my head around them for now. Thanks for the clarification :)
11:12andyfS3thc0n: I'd like to grok them some day more fully, but it isn't high on my priority list of things to do at the moment. Clojure programmers tend to write lots of pure functions, but then call them from functions that do modify state explicitly.
11:12andyfIdeally with the state modification code fairly well contained in a relatively small fraction of the code.
11:14S3thc0nAM I right when I think that you face the very same problems you have avoided internally by not having mutable state as soon as you start interacting with something like a database which uses locks?
11:19justin_smithS3thc0n: a lock is how something mutable can pretend it has some consistency
11:20justin_smithif anything the part where it has locks is helpful
11:21justin_smithand since immutibility makes async easier, you can use async to make the locks invisible (except so far as they affect timing / performance - but those should not be first class things you have to deal with in your code, just side effects of a design)
11:31S3thc0nOk, I have one more question. Does a clojure have any purpose apart from saving you from needing to keep the arguments for a function that would do the same somewhere?
11:31S3thc0nClosure I meant. oop.s
11:36andyfS3thc0n: I am not sure if this is an example of what you are asking about, or a different reason to use closures, but they are very convenient when locally defining a function to be passed to another function like map, mapcat, filter, etc., and you want that function you write to refer to values in the environment where the map/filter/etc. call is.
11:37andyfAn example would clarify that statement, I think.
11:37WWWest1S3thc0n: that's the main point, it makes it easier to create functions on the fly for your program while keeping a consistent state
11:37S3thc0nI get it like that, thanks!
11:39S3thc0nSo I said 'any purpose apart from ', but actually it solves my main concern with functional languages yet, namely being forced to pass around every little thing as argument.
11:48justin_smithS3thc0n: a full object system (inheritance, multimethods, etc. etc.) can be constructed out of closures - they are extremely powerful
11:48justin_smithof course given that our base language is the jvm we don't have to do that
11:49S3thc0nWouldn't that kind of defeat he point of immutability?
11:52newblueS3thc0n: a closure can be a nice place to quarantine state. Unfortunately (or fortunately) we can't *always* be stateless
11:53justin_smithS3thc0n: you can replace an object instead of mutating, also
11:53S3thc0njustin_smith. That is what I thought it is commonly done like.
11:53andyfS3thc0n: When people are taught the Scheme programming language, closures are often used to show how to create private mutable state, similar to objects in many other languages. It isn't often used in Clojure, because the JVM has mutable objects already.
11:54S3thc0nSo using JVMs built in objects is preferable to using clojures for 'emulating' objects?
11:55justin_smithmostly
11:55justin_smithmaybe I did to much scheme programming, but sometimes it is a natural fit
11:55newblueandyf: you got me! that's where I learned about closures and how I approach them - never gave much thought to using interop instead
11:56andyfnewblue: There is nothing wrong with using that technique in Clojure -- I just haven't seen it very often used. That particular sharp-edged tool is there in the toolbox, though.
11:59justin_smithit is the yin to the yang of writing procedural code where you repeatedly rebind the same symbol in a let binding block
11:59justin_smith,(let [a 0 a (inc a) a (* a a)] a)
11:59clojurebot1
11:59justin_smithbad example
11:59justin_smith,(let [a 1 a (inc a) a (* a a)] a)
11:59clojurebot4
11:59newblueandyf: I just don't know Java that well so I avoid interop when I can since debugging it is really scary
12:00justin_smithinterop is easier to debug eventually - because stack traces and errors are presented in terms of the jvm version of reality, rather than the clojure version
12:00justin_smithbut you need to grok the jvm's concept of things a little before that works
12:01justin_smithwhat trips me up is the interaction of laziness and stack traces - your code order in the stack does not really reflect the order in the file sometimes...
12:04newbluejustin_smith: having the stack traces make more sense is an enticing benefit...
12:05wei__trying to use tools.namespace: (use '[clojure.tools.namespace.repl :only (refresh)]) and getting FileNotFoundException: Could not locate clojure/tools/namespace/repl__init.class
12:06justin_smithnewblue: it is also partially a fluency thing - you read them more, they make more sense
12:06justin_smithI remember when I would see one and my eyes would glaze over - I would get no information out of the huge mass of spew
12:07justin_smithwei__: how are you declaring the tools.namespace dependency?
12:08wei__justin_smith: :profiles { :dev {:source-paths ["dev"] :dependencies [[org.clojure/tools.namespace "0.2.4"]]}
12:08wei__in project.clj
12:08justin_smithif you run lein classpath, do you see clojure.tools.namespace in the output?
12:10wei__interesting, yes but it's pointing to 0.1.3. is the dependency version getting overwritten somewhere?
12:10justin_smithlein deps :tree
12:10justin_smithsee what is pulling it in
12:10justin_smithadd an :exclusions clause
12:11wei__hmm, lein deps :tree gives me: Consider using these exclusions: java.lang.NullPointerException
12:11justin_smithlol, it would be good to exclude that, huh
12:11justin_smiththere is also mvn deps:tree
12:12wei__no reference to tools.namespace though
12:13wei__justin_smith: mvn deps:tree also errors with "No plugin found for prefix 'deps' in the current project"
12:13justin_smithsorry, wrong command
12:13justin_smithmvn dependency:tree
12:13justin_smiththat one works (just verified)
12:15wei__looks like ring is the culprit? https://gist.github.com/yayitswei/7845544
12:15justin_smithso you can do [ring "1.2.0" :exclusions [org.clojure/tools.namespace]]
12:16justin_smithor something similar to that syntax
12:16justin_smithyeah, that's the syntax
12:16justin_smithor maybe use a newer ring, while you are at it
12:20wei__ah, thanks
12:20wei__btw I found the source of the NPE, lein deps :tree seems to break when there are duplicates in dependency vector
12:21justin_smithinteresting
13:51wei__I'm suddenly getting this exception when calling "lein run": Exception in thread "main" javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial.
13:52wei__anyone seen something similar before?
14:23sverihi, i set up a cljs project with leiningen, now when i run lein cljsbuild auto it retrieves a lot of jars, but then hangs on: Retrieving clj-stacktrace/clj-stacktrace/0.2.5/clj-stacktrace-0.2.5.jar is there anything wrong with this? i tried this already some hours ago from another internet provider and it hang at the same place, i never seen this happen
14:33lvhHello! I've got a tiny little project I'd like to try to get my feet wet with in Clojure. I've got an SVG Christmas card envelope, and a bunch of addresses in CSV. I guess what I want after that is obvious :) Should I create a lein project for this?
14:33lvhIt seems that's what everything starts with
14:33seangrovelvh: Definitely
14:34seangrovelein new my-project, find a library to handle svg and add it to your project.clj under :dependencies, start up `lein repl` and you're off!
14:34thiemanlvh: There are also some specific lein templates that you might want to use, for example if you want to start a project using Compojure you could `lein new compojure my-project` to start a project with the right dependencies
14:35lvhAh, okay.
14:35lvhFor SVG I was just thinking of using an svg parser.
14:36lvhEssentially I just need to change the text of "#address tspan" (to use CSS selectors)
14:36lvhI'm guessing there's no particular kind of lein template for this?
14:37arcatansveri: cljsbuild auto does not say anything when it's waiting for the source to change, so if that's the last message, then it might be just waiting for you to do some changes in your cljs
14:37thiemanProbably not, but you might look into the library enlive for modifying the SVG. Lets you transform parts of the document based on CSS-like selectors, at least for HTML. Not positive it works for SVG.
14:37sveriarcatan: that makes sense
14:37emaphis``sveri: try [clj-stacktrace "0.2.7"], I just downloaded it to a dummy project and it worked.
14:37sverii got it working now
14:37sverii cleaned the .m2 folder
14:48justin_smithlvh: http://liebke.github.io/analemma/ analemma is good for making svg out of clojure data structures
14:48justin_smithyou can use clojure.data.xml to do the converse
14:48lvhjustin_smith: Yeah, I was gonna do that. I already have an SVG.
14:48lvhI basically just want to fill it with data from a CSV file.
14:48justin_smithit may be easier to use a templating library in that case
14:48lvhthe SVG already has proper tag ids, so I just have to grep for #address tspan, #name tspan, etc
14:49justin_smithanalemma is good for if you want to use a data structure to generate the svg from scratch
14:49justin_smithwell if you use clojure.data.xml you don't need to grep, you can look up the tags in the data structure, do the modification, then turn it into xml again
14:49justin_smithsvg is just a kind of xml
14:50amacdougallCurious about testing. I've got a Clojure/ClojureScript app. I want to run functional tests on the CLJS side. Since I want it to have a fixed set of test data, it seems like I should strike at the very root, and replace the server-side "db" namespace with something that returns stuff from files instead of the database.
14:50amacdougallBasically I want to run the server-side app in a different mode which has a different code path. I'm just not sure of the most straightforward way to do that.
14:51justin_smithamacdougall: one option is to refactor so your "interface" (the part that interacts with the data source) is as thin and trivial as possible, and the rest is all simple pure functions
14:52justin_smiththen you can test those functions with the inputs you know they will get
14:52justin_smithand have a couple of simple tests for the data gathering stage
14:53amacdougallI'm not so concerned with testing the db access functions themselves -- I'm looking for a dead-simple way to enforce a static data set for the client-side tests.
14:53cprice404hey, anyone know whether there are restrictions on what characters can be used in function / method names when using `proxy`?
14:54amacdougalljustin_smith: The client side just makes API requests. /api/v1/users/1 and so on. Obviously I could mock things at the client side instead, but changing the functionality of the server-side db functions seems even simpler.
14:54justin_smithamacdougall: so make the functions so they don't rely on the db, and call them with data structured in the way you expect
14:54cprice404i have a protocol that has a function name with a dash in it, and it seems like it might not be possible to define that function inside of a `proxy` call
14:55justin_smithunless your db layer is untrustworthy, why test db access? just call your code with the data the db will return
14:55amacdougalljustin_smith: I think I get you. Maybe what I'm really asking is how to run my app in a test mode which has the different behavior.
14:56amacdougallStep One: Understand Thy Own Question.
14:56justin_smithamacdougall: my way of doing it is not to run the app, but to run the individual fucntions and verify their output
14:57justin_smithamacdougall: if you design in an fp style this is easy, and if it is hard to do that, it is a sign you could make your codebase more functional
14:57justin_smithbut that's just how I prefer to do it, there are probably other good ways to do this, like with-redefs or making something that implements the right protocol (test stub) but I think that stuff gets weird and more complicated than it needs to be
15:01amacdougalljustin_smith: The ultimate goal is that on the client side, I test things by simulating user actions. I'm using a JS library called FuncUnit that makes this easy. It loads the entire site, does stuff, asserts a DOM state, closes the site; repeat. I just want to load the site with a static dataset. It's not the data I'm testing -- it's the UI functionality and application flow.
15:02amacdougalljustin_smith: I might have been phrasing things wrong, or I might currently be misunderstanding your advice.
15:04amacdougallI can think of plenty of ways of doing this by changing the main application code -- like checking some test-only constant to decide whether to serve test data, or something. But that seems totally wrong. I might just be stuck in an OO mindset where my first thought is dependency injection.
15:04amacdougall"Just replace the db object!" except obviously it's not an object.
15:04justin_smiththere may be a reasonable way to do that. I avoid full-app mockup testing myself so I wouldn't be able to give good leads about it.
15:04seangroveThe only place you should be injecting dependencies is behind the dumpster in an alleyway
15:04coventryI think justin_smith's suggestion is that you factor out your cljs so that you can simulate the client-side/database events just by passing them in as function arguments.
15:05amacdougallseangrove: It's safe as long as I don't share IDEs.
15:05seangroveI don't actually believe that, but it sounded vaguely plausible.
15:05justin_smithcoventry: exactly
15:05seangroveamacdougall: Good man.
15:06amacdougallAh, okay, I did misunderstand, then. So basically, put the test-specific functionality at the CLJS level in the first place. That makes sense, since it's the CLJS that I'm testing anyway.
15:06justin_smithcoventry: amacdougall clearly not the only way to do it, but the only reliable and simple way I have found
15:10solidus_can someone recommend some open source projects written in clojure? I want to get a feel to how clojure is used in medium/big projects
15:11noncomhi, is there any simple way to make timbre log 2 different sets of information to 2 different files?
15:12thiemansolidus: Not a great answer for you, but GitHub will point you to some neat projects for a given language. https://github.com/trending?l=clojure
15:12dsrxStorm is a pretty massive project
15:13dsrxalbeit, mostly written in java i guess
15:15dnolendsrx: a lot of that Java is/was generated according to Nathan Marz
15:15coventrysolidus: I've gotten a lot out of reading ztellman's code. I wouldn't read those projects to get a sense for how it's used, as their intended usage is a bit out there. But one of his popular ones might be good.
15:16justin_smithnoncom: https://github.com/ptaoussanis/timbre/blob/master/src/taoensso/timbre.clj#L174 global atom, you could do it but it would be a pain in the ass :(
15:16coventrysolidus: Maybe aleph or lamina?
15:16justin_smithnoncom: you could lock the atom, reset! it, log, then restore and release the lock for each call, but that would be a pain
15:17justin_smithsolidus_: the default caribou template installs a cms capable of building a whole site, so it could arguably be considered a large open source clojure app
15:18justin_smiththough it is meant to be extended with one's own pages and controllers etc.
15:19justin_smithseconding ztellman's projects as good for reading, stuart sierra is another good one for that
15:19coventry"those projects" meaning the ones I read, riddley and sleight.
15:22noncomyah, looks like no simple way...
15:23justin_smithwe need a pure functional logger!
15:23justin_smithor at least one with lexical bindings for config
15:23noncom:)
15:23andyf_justin_smith: It has one. identity :-)
15:24noncombut maybe i could use a dynamic var to designate the path for the file and create two helper functions with (binding ...) ?
15:24coventry"What do you mean it has no side-effects? *I* know it ran."
15:24noncomdo string values get passed by pointer or value?
15:24noncompointer i gueess
15:25andyf_noncom: In Java, they are passed by reference (i.e. pointer), but they are immutable, so I'm not sure when it would make a difference between by reference and by value.
15:25justin_smithnoncom: may be simpler / more powerful to simply replace the global atom with a dynamic var / binding forms
15:26justin_smithstack usage?
15:26devngood afternoon all
15:26justin_smithI don't think passing by value even happens in the jvm world, except maybe for unboxed primitives
15:26noncomuhh.. i jut did not want to make any invasive surgery :)
15:26andyf_justin_smith: Yes, it would make a difference in time and/or memory usage, but for other kinds of observable behavior, I can't think of a difference.
15:26justin_smithright
15:27noncomi mean when i designate the file path by a dynamic variable, it will be the pointer, not the value of it, so i can later bind the dynamic var to diferent strings... i guess.... or i'll have to dig inside timbre and redefine some stuff
15:28justin_smithyeah, I was trying to suggest forking timbre and changing the definition of config would be simpler than dynamic binding of config vars with the existing timbre
15:28justin_smithbut that could be wrong
15:29noncomoh forking, right
15:33akurilinbitemyapp: just fyi I started using xmonad earlier yesterday, pretty cool so far, very spartan. On a side note, Haskell syntax looks super alien right now. I wonder if everybody feels that way at first :)
15:33seangroveakurilin: The endless complaints about clojure syntax hints that everyone does...
15:34akurilinseangrove: hah yes I know what you're talking about. Every Clojure-related HN post ever has at least a couple of replies saying "now if only the syntax didn't have so many parentheses"
15:35coventryThey care more about their power-to-weight ratio than their appearance. :-) http://book.realworldhaskell.org/
15:35noncombtw, how do you usually format (let) ? do you start the bindings [] on the next line or on the same line?
15:37akurilincoventry: is that a good starting point?
15:37andyf_noncom: same line always for me, and most code I've read
15:38noncomdamn...
15:38justin_smithnoncom: not universally agreed with, but a good starting point https://github.com/bbatsov/clojure-style-guide
15:39akurilinoh man, I remember using bbatsov's guide back in my ruby days
15:39andyf_noncom: About the only time I've ever seen it on a separate line is when I pprint forms that have been read in, but that is machine-generated.
15:40noncomheh :)
15:40akurilinit'd be cool if there was one guy out there who was the arbiter of good taste for many key languages
15:41andyf_akurilin: There is. It is just so many people disagree with him and don't follow his good taste :-)
15:41justin_smithakurilin: this was traditionally the role of the Queen of England, but she has been slacking
15:41akurilinandyf_: I haven't followed any conversation regarding his guides, but I imagine anybody in that position would receive a lot of criticism.
15:41coventryakurilin: I can recommend the first few chapters, but that's all I've read. That much suffices for casual reading of haskell in CS papers.
15:41akurilinjustin_smith: :D
15:42akurilincoventry: fair enough. Should suffice if I just want to be able to read it.
15:43akurilinHas haskell syntax changed much over the years or has it been stable for a while?
15:43coventryI'm sure you would benefit much more by reading the whole thing.
15:45coventryI only brought it up because of the bug-ugly bug with the high power-to-weight ratio on the cover. :-)
15:46justin_smiththe syntax is pretty stable, it is basically a super sugarry ml
15:48seangrovecoventry: Ah, clever.
15:59akurilincoventry: that was deep
16:01amacdougallOkay, I've been thinking "what's the simplest thing that could possibly work", and here's what I came up with: the test runner loads the full site with ?test-data=true in the querystring. Initial site bootstrap code detects this and sets a Var in the core namespace. Whenever I call data/GET (a simple AJAX wrapper), the function delegates to test-data/GET if necessary. Finally, test-data/GET compares the URL to a mapping of URL patterns to EDN files i
16:01amacdougallThis still seems a lot more complicated than necessary.
16:02amacdougallCall it "the simplest thing I could think of that could possibly work."
16:02amacdougallAnd it involves adding test-specific code to the main app, which seems like it should be avoidable.
16:03seangroveamacdougall: You could probably just make some helpers in your test code runner and clojurescript.test
16:03seangrove(deftest ... (with-mocked-ajax ... (... webdriver-code )))
16:05seangrove(with-mocked-ajax ...) relying on (with-redefs ...) under the hood.
16:05seangroveHrm, now I'm wondering if with-redefs exists in cljs. Maybe not.
16:07seangroveAh, the older days, before bbloom_ refused to use confluence and dnolen pretended to read the design docs https://groups.google.com/forum/#!topic/clojure/6cmnkHmHBNw
16:07amacdougallclojurescript.test seemed really hard to use for UI testing. Which makes sense. And if it's black-box functional testing, there's no reason not to just use a JS library.
16:10amacdougallAt work, we're using the same library, but in a Rails environment. Thanks to the efforts of our test engineer, we're able to use Capybara to set up some fixtures, open the test runner HTML using Selenium, wait for results, close it all back down.
16:10amacdougallI just don't have the determination or the need to set up something that complex and automated.
16:12noncomhow do i make concat here work at compile time? (this version does not work):
16:12noncom(defmacro z [f & args] `(println (apply ~f ~(concat [1] args))))
16:19coventrynoncom: What's wrong with a simple (defmacro z [f & args] `(println (~f 1 ~@args)))?
16:20noncomi think i just complicated it :)
16:22amalloywhat's wrong with (defn z [f & args] (println (apply f 1 args)))?
16:25coventryamalloy: It doesn't teach you anything about how to use syntax quote.
16:26noncomi just want to make it execute at compile-time, not everytime during runtime. am i correct that this macro will help with this or not?
16:27llasramNope. Totally wrong.
16:27dsrx.wea
16:27dsrxoops wrong window
16:28bbloom_seangrove: heh
16:28noncomso apply is a function which means it has a runtime overhead?
16:29noncomdoesn't apply have a runtime overhead?
16:29noncomnot the whole function at compile time i mean, but just the application to the passed args
16:30bbloom_seangrove: i now have a much much much better understanding of dynamic variables & bindings. i don't think that clojure can possibly get the "right" binding conveyance semantics w/o some way to take a "slice" of bindings up to a marked point in the stack (ie. effect handlers :-P)
16:31raeknoncom: yes, but you can't use the macro in all circumstances where you could use the function (eg. you can't apply it or use it as a value)
16:32raekmacros make code less composable
16:32justin_smithhttp://www.chrisstucchio.com/blog/2013/write_some_fucking_code.html an adolescent and foul-mouthed intro to monads
16:33seangrovejustin_smith: There's also crockford's google talk, where he does it in javascript and makes a lot of strange references to male anatomy
16:34justin_smith"Monads are like a dildo factory, staffed by midgets"
16:35raeknoncom: also, I reckon this particular extra step of indirection won't be the performance bottleneck of your application
16:35seangrovejustin_smith: I guess that one does win on the strange-meter
16:45devnIs there a better way to write this? https://gist.github.com/devn/befc73863d0f6c4a6144
16:51kilexI've given myself a toy problem to solve with core.logic: http://bit.ly/19q9V3Y. Any suggestions for improvement?
17:02alsoare there any good examples of the idiomatic use of ex-info?
17:04noncomdevn: maybe something like (apply merge (mapv (fn [v ks] (reduce (fn [acc k] (assoc acc k v)) {} ks)) {your-map-here})) ?
17:05alsoI have some code that throws IllegalArgumentException, but I'd like it to work in ClojureScript
17:05justin_smithalso: we have used something similar (but with the slingshot lib) in order to recover elegantly from template rendering errors with an informative message
17:06noncomat least something like that would definitely be better than using update-in in such a cae
17:06noncoms/cae/case
17:07noncomdevn: oh, looks like i have incorrectly read your example.
17:07noncomso that's not a solution to your qustion
17:09gdevupdating by hand a project that still uses a ton of contrib libraries is a pain
17:09gdevI feel like my computer is going to laugh at me tonight because I'm did all of its work
17:10gdev%s/I'm/I
17:10devnjustin_smith: that guy is insane
17:11coventryjustin_smith: LMAO
17:17gdevkilex, if it works, ship it
17:23gdevkilex, actually I'm confused why B1 and B2 have no relation or is it okay for them to come in any order?
17:27kilexgdev: that's the point, there's no constraint on their order. It works, but is awfully slow. There must be a better way (with core.logic that is).
17:28kilexAlso, am interested to learn an idiomatic way to express (distinct) in core.logic
17:30technomancyalso: use ex-info over IllegalArgumentException
17:31alsoyeah, that was the direction i was heading. i was just wondering if there was a usual way of doing that
17:32llasramalso: The only potentially-non-obvious suggestion I'd have is not to stuff the info map with the kitchen sink. Printing the exception prints the map non-pretty-printed, which can be annoying to sift through if it contains too much
17:34cYmenI am trying to figure out 4clojure 121. My first two solutions have been branded evil because the used eval and ns-map. Do I have to create my own map from '+ to clojure.core/+ or is there some other way?
17:36llasramcYmen: I haven't looked at a problem, but building a map from keywords or symbols to functions for dispatch is a pretty pattern common
17:36llasrams,a problem,the problem,
17:36llasramEr, and "pattern common" / "common pattern"
17:38cYmenIt is?
17:38nkozothere is a way to redirect all stdout to the nrepl repl buffer?
17:38cYmenUnder what circumstances?
17:40llasramcYmen: Well, when you want to dispatch :-). I usually only see people fairly new to Clojure (and usually coming from Ruby) use `ns-map`, `resolve`, etc over manually constructing a map of specific allowed dispatch options
17:40coventryI hear it's better style to use multimethods than a dispatch map, but they're almost semantically equivalent in this case and you don't need to learn a new language feature at the same time you're doing this problem.
17:42llasramcoventry: And I think it does depend on the problem. Definitely multimethods if the dispatch is open, or complex
17:44cYmenHm...maybe I should jump at the chance to use multimethods...
17:44coventryI would do it with a dispatch map first and rewrite with multimethods once I had that down.
17:45coventryBut multimethods aren't that much more to keep track of, I guess.
17:56xpeI'm looking for a way to run some code only when the :dev profile is active. My use case is enabling Enlive reloading.
17:58xpeI think I want :init or :init-ns
17:59xpebut those are only REPL options, best I can tell
18:00coventryxpe: I have {:user {:repl-options {:init (load-file "~/.lein/replrc.clj")}}} in my profiles.clj. You might try something like that, with s/:user/:dev/
18:00xpeit looks like I have to setup a different entry point, just like Pedestal does with `run-dev`
18:00xpecoventry: thanks for that idea
18:01xpefor my use-case, I'll add my function calls into `run-dev` I think
18:02justin_smith(when (= (System/getenv "environment") "development") ...) is another way to do it
18:03justin_smithbut then you have to set the key via env vars
18:03xpejustin_smith: also a good idea
18:04xpehaving `(net.cgrand.reload/auto-reload *ns*)` in my production code seems silly. I'll bet others are also thinking about ways of pulling out reloading in production environments
18:05xpeWhile we're talking environment variables, I could also set a global. :(
18:05justin_smithwell, yeah, but it has to come in from somewhere
18:05justin_smithin caribou we grab the "environment" from the env, and put it in a dynamically scope config
18:06justin_smithso you can bind it in the repl to do things with the prod db or whatever
18:06justin_smithwithout having to run a repl in prod
18:07justin_smithwe make sure the root binding is the default env config, so threads all see the right config etc. but any part of the code that needs to can override it in a scoped way
18:07noncomwhy in clojure there is no in-line comment like /* */ in c or java (except for the (comment) macro which is different) ?
18:08xpenoncom: you can use ;
18:09noncomjust at the end of the line. it makes everything after it a comment
18:09justin_smith#_ comments a whole form
18:09xpeor #_(whatever)
18:09noncomi know that in other lisps there is no such thing too.. but..
18:09noncom#_ ??? wow!
18:10justin_smith#_ is very handy, it always comments out a balanced expression
18:10xpenoncom: I'm sure, I couldn't evaluate that. What did you saY?
18:10justin_smithlol
18:10xpeI mean "i'm sorry..." i blew that joke
18:10noncom:)
18:11xpeRuntimeException Invalid token: :
18:11noncom; :)
18:11xpeRuntimeException Unmatched delimiter: )
18:11justin_smiththe only problem with #_ is how many clojure programmers don't know what it does
18:11justin_smithand emacs doesn't even highlight the form it precedes as commented
18:11justin_smithwhich is sad
18:12justin_smithI guess I could see if I can figure out how to fix it.... I've hacked elisp in the past
18:12noncomi think that its usefullness is so great that we should start a world-wide campaign with banners, parades and such to announce that it exists..
18:13xpejustin_smith: emacs's parsing could be fixed, right?
18:13noncomemacs is lisp, so it never was broken
18:13_ViHow to write (doall (map ... shorter? Is there something like domap?
18:13xpehaha
18:14noncom_Vi: (mapv) ?
18:14SegFaultAXThat gives different results.
18:14noncomit gives a vector
18:14SegFaultAXSo it isn't the same.
18:14noncom(mapl) ?
18:15SegFaultAX_Vi: What's wrong with just calling doall? Are you sure you even need to do that?
18:15_ViUnable to resolve symbol: mapl in this context
18:15noncom_Vi: sorry, that was a joke
18:15_ViSegFaultAX, Typing more and closing more parentheses.
18:15SegFaultAX:/
18:15_Vi"mapv" suits well.
18:16coventryWhat is the purpose of #! vs ';'? Just some vestigial thing? https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L108
18:17justin_smithcoventry: the unix kernel interprets that magically
18:17justin_smith#!java -jar clojure.jar ...
18:17coventryOh, so you can make clojure scripts. Cool.
18:19andyf_Vi: You are welcome to define a domap yourself, of course.
18:20justin_smithif you already want to greedily do the whole map, what is the advantage of not doing mapv?
18:20noncomand be sure to make a pull request. but that's another joke :)
18:20justin_smithit's not like the datatype has some advantage
18:21noncomunless you are really working with lists like building clojure forms, but that's sorta exotic for (map) i guess..
18:21justin_smithnoncom: seq on a vector is cheap
18:21andyfnoncom: Making pull requests against Clojure or contrib libraries is no laughing matter :-)
18:22justin_smithwhereas arbitrary lookup on non-vector sequentials is expensive
18:22SegFaultAXandyf: I assume he meant against the github repo, in which case PRs are expressly declined.
18:22llasramHumor on the Internet: NP-hard
18:22noncom:D
18:22andyfuncomputable, I'd say
18:23noncommaybe core.logic can get it right, if given enough IRC logss
18:23SegFaultAXHey girl, are you a travelling saleman because you make me NP-Hard.
18:24noncomhaha
18:24llasramYeah, the dec then inc karma cancel out
18:24_ViClojure's Github repository is arrogant one like linux.git and git.git and don't accept too-easy-to-do pull requests and issues?
18:25SegFaultAXI don't often write jokes on the spot, but when I do, I regret them immediately
18:25CaptainLexSegFaultAX: I liked it
18:25noncomyeah, joking is nice. i like feeling that someone was in a mood to joke, it makes me glad
18:25coventryL'esprit de let-me-show-you-the-way-out-thank-you-very-much
18:26SegFaultAXOk, now I /have/ to tweet it.
18:27CaptainLexalt: you make me NP-complete
18:28andyf_VI: If you consider that to be arrogant, then yes, it is. I don't understand the value judgement you are making though.
18:29SegFaultAX_Vi: No, they don't accept PRs because all work is done via jira and you must have signed the CA.
18:31_Viandyf, I've seen some recommendations to avoid using Github "pull request" feature regarding to Linux repository (along with some general criticism of the features). This gives feeling that "one cannot simply pull request to the Linux repo" and that Github pull requests are for lesser repositories.
18:31SegFaultAXirccloud sent me an invite.
18:31SegFaultAX1.5 years after I applied.
18:32gdev_Vi, in the case of Clojure core it's just a matter of using a different workflow
18:32andyf_Vi: If some software project has a different process for submitting change requests besides pull requests on Github, then I think that is their choice. If you create a software project, you get to decide how you will accept requests for changes. Seems simple to me.
18:32SegFaultAXandyf: Well said.
18:35coventryIt would be cool if there was a clojure-unstable like debian-unstable, pulling in patches more liberally than the clojure core team does. But no one seems to be interested in curating such a thing.
18:37andyfcoventry: I considered it for a while, but it would be a big time sink, and most likely things would get added that were never put into Clojure itself. Effectively what you would have is a very similar but somewhat different programming language, incompatible in perhaps well-documented ways.
18:37cYmenI find it irritating that this doesn't work: (letfn [r [] 3] r)
18:38cYmenCould somebody offer some insight into what is going on?
18:38coventryandyf: Yeah, it would probably lead to some friction down the road.
18:39justin_smith,(letfn [r ([] 3)] (r)) ; cYmen do you want this?
18:39clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Symbol>
18:39coventrycYmen: Have you seen the example at http://clojuredocs.org/clojure_core/clojure.core/letfn
18:39justin_smitherr
18:39amalloy,(letfn [(r [] 3)] (r))
18:39clojurebot3
18:40arrdem,(doc letfn)
18:40clojurebot"([fnspecs & body]); fnspec ==> (fname [params*] exprs) or (fname ([params*] exprs)+) Takes a vector of function specs and a body, and generates a set of bindings of functions to their names. All of the names are available in all of the definitions of the functions, as well as the body."
18:41cYmenOne beer... well thanks for your help in finding my missing brackets guys... ;)
18:42cYmenoh parens actually...whatever
18:46coventryIs there a way to identify what threads are running and kill one of them, either from the repl or some kind of emacs nrepl thing short of the ritz debugger?
18:49justin_smithjvisualvm
18:50justin_smith,(Thread/getAllStackTraces)
18:50clojurebot#<AccessControlException java.security.AccessControlException: access denied (java.lang.RuntimePermission getStackTrace)>
18:51coventryThanks, Thread/getAllStackTraces looks like it would work.
18:51justin_smithit is a hash from thread handle to stacktrace
18:51bitemyappakurilin: Haskell in general feels like alien technology at first.
18:51justin_smithso you could use that handle to kill it, if it has the stack trace that interests you, I think
18:52coventryjustin_smith: Yeah, should be able to identify the thread from the stack trace.
18:58justin_smithalso, depending on how the thread is started, you could store a reference to it for later
18:59coventryjustin_smith: Yeah, this is more for development. My experimentation started a long-running thread which turned out to be a bit of a nuisance and I was wondering what tools there are for that kind of situation.
19:06gdevugh i hate when i finally have the answer just to find out the person has left irc
19:08justin_smithwhich is why one should never leave irc
19:08bitemyappgdev: I hate that too.
19:08bitemyappjustin_smith: leavers are a weird breed.
19:08bitemyapphard to get much value from IRC unless you lurk.
19:08bitemyappmaybe they pay for their internet by the minute?
19:09gdevhrm, or maybe they finally ran out of the 1000 free hours of AOL
19:09gdevwell good, now I can go back to working on my problem ^_^
19:09SegFaultAXgdev: Heh, nice.
19:12dsrxwhat's a good way to test macros? test the output of macroexpand or macroexpand-1?
19:12dsrxprobably the latter if anything
19:13amalloydsrx: just test that they do the right thing when you use them. you shouldn't need to test that they expand to exactly what you expect
19:13dsrxhmm
19:13amalloyif you do, you tie yourself to an implementation strategy for no reason
19:14dsrxi see that you answered almost this exact question on SO earlier this year. makes sense, thanks :
19:14dsrx:)
19:14amalloymore than once a year, i'd wager
19:18gdevI'm working on an irc client that searches google and the channel history for the past three years before it shows a question in the channel. calling it bitemyChat
19:22gdevbitemyapp, that name isn't taken yet is it?
19:24bitemyappgdev: not yet.
19:28gdevi think I'm abusing lein-ancient. instead of looking up the version of the libraries I want to use I just put "0.1.0" and then run lein-ancient
19:30llasramgdev: lein-ancient can lookup the most recent version of a lib you provide on the command-line
19:31gdevllasram, I know, but if i do lein ancient :interactive it will update the project file for me
19:31llasramFair enough :-)
19:32devn`lein search conch` returns a version which is 0.6.0
19:32devn`lein ancient` in a project including conch returns the latest is 0.5.1
19:33devnAny idea why?
19:35gdevdevn, did you try running ancient with :allow-all ?
19:35devnnosir
19:35gdevdevn, what about with :aggressive ?
19:35devnsame result with :allow-all
19:35devnaggressive found it
19:36gdevneato
19:38gdevllasram, whoops I meant `lein ancient upgrade` updates it for you, interactive just prompts you before doing so
19:46dsrx`lein ancient aliens`
19:47devnhaha
19:47devn*sad face* OpenRefine won't load my dataset in the browser despite me upping the heap to 8GB
19:48gdevbitemyapp, now that c.j.j dropped the sql dsl, that's one less thing you have to test in blackwater =D
19:49devnmethinks i need a 16GB machine if i want to run this on this dataset
20:06zmansivhi, i wrote this code to construct a tree structure for a given directory http://pastebin.com/hT7pXnQm . since the jvm doesn't support tail call optimization, i get a StackOverflowError if i run this on a dir with lots of nested directories. how can i solve that problem?
20:07zmansivi looked into loop/recur but couldn't come up with a way to use it here
20:07amalloy&(doc file-seq)
20:07lazybot⇒ "([dir]); A tree seq on java.io.Files"
20:08amalloyor use tree-seq if you don't want actual File objects
20:08amalloythe point is to do it lazily
20:09bitemyappgdev: I'm grateful for that.
20:09bitemyappgdev: it makes the awkward relationship between c.j.j and Korma less awkward too.
20:09zmansivamalloy doesn't file-seq return just a flat structure?
20:11justin_smithbut you can use the paths to construct the tree
20:11justin_smithusing assoc-in
20:12justin_smithor whatever tree constructor, if you don't want to use maps / records
20:13amalloywell, you're trying to build a tree of depth N, where each node is eagerly realized, all at once. that can't help but consume unlimited stack
20:17zmansivright now my goal is to display a gui with a treeview that shows the directory and its contents
20:18zmansivi was doing that by constructing the tree structure with the code i linked, and then recursively iterating over that and creating TreeItems
20:18zmansivwhat would be a good way to achieve that?
20:22deadghostif I do a map in a map will the inner % have problems with the outer?
20:22deadghostor can I give it a name or something
20:24aspotashevdeadghost: AFAIK you cannot make nested anonymous functions with the #() syntax
20:25aspotashevbut you still can make an anonymous function by writing it in a full form: (fn [a b c] something)
20:25aspotashevso yes -- you have to give the arguments some names
20:26bbloom_which is a good idea even if your #() isn't nested, but the % is visually far away
20:37deadghosthttp://pastebin.com/8rUCU952
20:37deadghostnot sure if I'm doing this right
20:39_Videadghost, % should be paired with #(
20:40deadghostit's a map inside a map
20:40justin_smith_Vi: also notice the unmatched paren, this is just an incomplete snippet
20:40justin_smithdeadghost: it gets the individual values in the sequence %
20:40aspotashev#(map (fn [name] (insert-categories name business-id)) %)
20:40justin_smithuse for instead of map inside map though
20:40cljris there something similar to python's asyncore in clojure, or an easy way to do similar functionality?
20:41_ViI think usually better to use #( ... % ...) for inner functions, and (fn[...]...) for outer ones.
20:42justin_smith,(for [a (range 4) b (range a)] b)
20:42clojurebot(0 0 1 0 1 ...)
20:42justin_smithmuch easier than setting up nested maps
20:44aspotashevjustin_smith: wow1
20:44aspotashev*!
20:45justin_smithcljr: you can attach a future or agent to an input source, or manually run Thread objects - or do you really want to do explicit polling and dispatching, because it is possible, I just don't see the point
20:46justin_smithcore.async is pretty cool for taking asynchronous tasks and writing them out the way you would normal code
20:46justin_smithcljr: but it could be I don't understand what feature you actually want from asyncore
20:47cljrjustin_smith: yeah, I'm not positive mnyself, I think I need to do some more research.....thanks
20:48justin_smithcljr: there are a lot of options for async and thread based stuff in clojure, it is one of the things that distinguishes the language
20:48justin_smiththat is a big part of why so many things are immutible - it makes threaded stuff so much nicer / simpler
20:49cljrright
20:49cljrive done enough clojure programming to know that, but this specific area is new to me
20:50cljri was looking at how Bitcoin clients work and one in particular seemed to handle messages over a socket async, hence my reference to that library anove, but im just trying to wrap my head around that
20:51justin_smithhttp://docs.python.org/2/library/asyncore.html the example client here looks a lot like a state machine. core.async takes normal looking code and makes a state machine, so that may be somewhere to start
20:52cljrk, thanks again
21:01justin_smithcljr: clojure version of 17.6.1, the asyncore HTTP client example (future (println (slurp "http://clojure.org&quot;)))
21:02musicalchairsome people here might like this. p2p webworkers: https://grimwire.net/ http://grimwire.com
21:03cljrjustin_smith: https://github.com/jgarzik/pynode/blob/mini-node/node.py
21:03cljrjustin_smith: not asking you to spend time looking at it, but it seems to create or connect to a socket, then just checks for reveieved messages on it and handles that asyncr
21:08john2xis there a fn that converts clojurescript datastructures into native javascript? e.g. PersistentVector -> JS Array
21:08zmansivany way to get the value that would be set if you passed certain keys to assoc-in?
21:09john2xbut handles other datastructures as well, automagically
21:09zmansivi.e. using the "users" vector defined in the example at http://clojuredocs.org/clojure_core/clojure.core/assoc-in
21:09justin_smithzmansiv: you can run assoc in, and if you don't like the result, don't use it - it doesn't mutate the input
21:09zmansivhow can i see what the keys [1 :age] yield in that data struct? (should be 43)
21:09justin_smiththere is get-in
21:10zmansivoh awesome, thank you
21:10justin_smith,(get-in {:a {:b {:c 42}}} [:a :b :c])
21:10clojurebot42
21:11zmansivperfect
21:12justin_smithcljr: depending on the intent, in clojure you would do what that node.py is doing with ring (an async web service lib that lets you define functions that massage the incoming data and generate responses), or core.async (if you wanted to work on the level of the logic of various events that take a variable amount of time)
21:14cljrjustin_smith: ring isn't limited to just http?
21:17radsjohn2x: (clj->js [1 2 3])
21:18zmansivsay i have this structure: { :value "1", :children ({ :value "2", :children () }) }
21:18john2xrads: thanks!
21:18zmansivhow could i get "2" ? i tried (get-in x [:children 0 :value]) but no dice
21:19zmansivx being that structure above
21:20zmansivit's the 0 that's not working, i guess that works on vectors but not lists. can i achieve that using a list or do i need to be using a vector?
21:20dnolenzmansiv: lists are not associative data structures that won't work
21:21zmansivalrighty vector it is then
21:22justin_smithcljr: oh, it is limited to http I think, so it may not be as general as what you were thinking
21:30justin_smithcljr: random snippet from my own code that may be a bit closer to what you have in mind? https://www.refheap.com/21593 I define a thread that handles output from a shell process stdout, and returns functions to write to the process stdin or ask it to close
21:40justin_smith"symbols, whose values are looked up in the court of the LORD’s glory."
21:40justin_smithhttp://kingjamesprogramming.tumblr.com/ this site is funny
21:40cljrjustin_smith: very cool, thanks
21:56rads"The global environment is chosen here, because this is the will of God."
21:56justin_smithAMEN
21:56justin_smiththat whole blog is gold, he needs to update more
21:58justin_smithThat quote places bitemyapp as the Satan, who tells you to forsake the global environment of our LORD in favor of explicit arguments and monads.
22:10Raynesbitemyapp is webscale.
22:11seangrove+1 explicite arguments with state monads
22:12pragmatismback
22:18dnolencomprehensive #js literal support in CLJS master, fixed behavior of #inst and #uuid to match Clojure's
22:24mcblumpersondoes the #js literal have the same effect as js->clj ?
22:25bitemyappall of a sudden people like my milkshakes?
22:26dsrxhere's a good project name, something that incorporates edn and garden, "eden"
22:27seangrovedsrx: Love it. A return to innocence and perfection.
22:27seangroveBut could imply ignorance as well
22:27radsI've heard people say "eden" out loud when referring to edn so that could get a little confusing
22:27ivanmcblumperson: isn't it more like clj->js?
22:29mcblumpersonright
22:29mcblumpersonsorry, got my arrows crossed
22:41egosumIs there a good/easy/nice way to store arbitrary datastructures (e.g. a map with nested maps/lists within) in Datomic?
22:41egosumI'm reading "no" but I want to make sure…
22:43nightflyserialized to a string
22:45cljrim not familia enough with java libhraries, but from what I can te4ll BUfferedReader just let syou continue to read from a socket when yuou feel like it, but is there nothing that basically notifies you when there is a data on a socket to be read and uses your callback?
22:45dnolenmcblumperson: no it's just data literal syntax for JS objects / arrays
22:45egosumnightfly: Yeah :\ so, "no"
22:45dnolenmcblumperson: no conversions
22:45gdevegosum, yeah you could have db.type/string and then store values such as "[1 2 [4 5 6]]"
22:46egosumgdev: I suppose that is a reasonable way to do it, anyway. Could make a new type and apply a function to it in the transactor to read it, too, perhaps…?
22:46egosumProbably not necessary.
22:47gdevegosum, just curious what system you're building that would need to store nested collections
22:48egosumgdev: Storing representations of finite state machines
22:48egosumbasically
22:49justin_smithegosum: there is always the conversion of an arbitrary graph to two key/value maps: one with the identities, and one describing connections between entities
22:49justin_smithyou can even do arbitrary recursive relations you could not describe with nested structures
22:50justin_smithand for the non-recursive case it is straightforward to convert the two flat maps into a nested structure
22:52igorwI have a case of two sets that should be the same, yet my test suite says they're not
22:52egosumjustin_smith: I'm not sure I entirely follow; could you say/point to more?
22:52igorw actual: (not (= #{0.0 4.0} #{0.0 4.0}))
22:52igorwany ideas or suggestions for debugging?
22:54xpe# (= #{0.4 0.0} #{0.0 04})
22:54xpeI forget the bot's prefix
22:55gdev,(= #{4. 0.0} #{0.0 4.0})
22:55clojurebottrue
22:55xpeigorw: testing locally, I get (= #{0.4 0.0} #{0.0 0.4}) ; true
22:55gdevworks on this box
22:55xpeigorw: can you reduce your test and try in the REPL
22:55igorwyes, same when copying to the repl :-/
22:56xpemachine type? java version? clojure version?
22:56justin_smithegosum: {:a 0 :b {:c 1}} -> {:entities {:a 0 :b {} :c 1} :edges {:b :c}}
22:56igorwbut the value must be somehow different from what is dumped
22:56justin_smithall the information is present, it is in a flattened form
22:56xpeigorw: i'll bet it is a typo somewhere :)
22:56justin_smithalso that can express recursive / circular nestings that cannot be expressed in a single literal
22:57justin_smithie. if :c had :b in it
22:57igorw64-bit jvm, java version 1.6.0_65, clojure 1.5.1
22:57xpeigorw: yeah, I'll bet you have a typo somewhere :)
22:57egosumjustin_smith: Ah, yes. Makes sense, thank you
22:58justin_smithin practice you would not use the keywords from the original structure - I did that for clarity, you would map a unique id to [k v] as a pair
22:59igorwxpe: well the thing I pasted is copied directly from the tests output
22:59egosumjustin_smith: What about a list representation, though?
22:59egosumjustin_smith: Er, that's unclear. Say :b's value was a list.
22:59justin_smithright
22:59xpeigorw: please make a gist of the test
23:00xpeI'll wager that the problem isn't with Clojure's set equality
23:00justin_smithegosum: there may be a standard way to do that, but the easiest way is to treat a list as a hash of indexes to values with some key indicating it should be treated as sequential
23:02justin_smithie. [:a :b :c] -> {:type :seq 0 :a 1 :b 3 :c}
23:02egosumRight, makes sense. Have you been using datomic in production, out of curiosity?
23:02justin_smithI have not used it, I just know it is a keystore and I think graphs are awesome and I know how they map to keystores
23:03justin_smithwell it isn't a keystore
23:03justin_smithbut I know it can be used in that way
23:03egosumjustin_smith: Fair enough :) Thanks!
23:05gdevjustin_smith, its a datom store ;)
23:06justin_smithgdev: OK, someday I will know what a datom is I guess
23:06gdevjustin_smith, [E A V Tx]
23:08gdevthe other day I gave a presentation on avoiding jargon during speeches, then the next day I gave a presentation on Datomic...was so hard to follow my own advice
23:08justin_smithso on further reading, the datomic model is basically a graph (nodes with key/val + edges as I showed above) with an explicit time component
23:08justin_smithI think
23:08justin_smithgdev: lol
23:08xpejustin_smith: in case you want to learn more about diatoms http://westerndiatoms.colorado.edu/about/what_are_diatoms
23:09justin_smithROFL
23:09justin_smiththat extra i makes a big difference
23:09xpethey have special forms and history too
23:09justin_smithbut they are not immutible
23:09justin_smithin fact they evolve via mutation
23:10xpehaha, so true
23:10xpeholy cow: It is estimated that 40% of the earth’s oxygen (02) is produced through the photosynthetic activities of diatoms.
23:10justin_smithLOL someone needs to do a creationist programming project in clojure (since we don't do mutation)
23:10gdevdiatoms are web scale
23:11gdevjustin_smith, yeah we'll call it "in the garden of edn"
23:12justin_smithbut they have global scope (found everywhere) plus mutation, so they are bad
23:12justin_smithlol
23:14igorwxpe: one thing I noticed is that there is a negative zero involved in the calculation which might have some strange effects...
23:14gdevjustin_smith, they're a legacy system so you just have to deal with it
23:14xpegdev: going way back ^^^ it is only jargon if your audience doesn't understand it right?
23:14john2xhow do I "explode" a vector to be passed as args in a fn? like foo(*args) in python.
23:14igorwtrying to reduce the test case now
23:14xpejustin_smith (apply str [1 2 3])
23:14gdevxpe, I don't think they did =/
23:14xpewhoops that was for john2x
23:15justin_smithheh, np
23:15arrdemjohn2x: example input? but yes apply is probably the rigt fix
23:15gdevarrdem, don't you have a scala project to work on ;)
23:15xpeigorw: a negative zero? you've got problems then, haha
23:15arrdemgdev: it's done :D
23:16arrdemoh right I was gonna post code...
23:16john2xI'm trying (subs some-str [start end]).. so the first arg needs to be provided.
23:16gdevarrdem, good job
23:16igorwxpe: oh? can you elaborate?
23:16xpe,-0
23:16clojurebot0
23:16justin_smiththe other half of that: (fn [& [a b c :as args]]) in order to get all args as a list you can use further
23:16igorw,-0.0
23:16clojurebot-0.0
23:16arrdemgdev: https://github.com/arrdem/fractals
23:16igorwit's a float ;-)
23:17arrdemno README yet, but you can sbt run it just fine :P
23:17xpe,(type 0.0)
23:17clojurebotjava.lang.Double
23:17xpe,(type -0.0)
23:17clojurebotjava.lang.Double
23:17justin_smith,(= -0.0 +0.0)
23:17clojurebottrue
23:18gdevarrdem, turles all the way down
23:18gdev*turles
23:18arrdemgdev: that was the design intent :D
23:19gdevarrdem, now you can rewrite it in clojure, just use a map ;D
23:19justin_smith,(applyu subs "hello" [1 4]) ; john2x
23:19clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: applyu in this context, compiling:(NO_SOURCE_PATH:0:0)>
23:19justin_smith,(apply subs "hello" [1 4]) ; john2x
23:19clojurebot"ell"
23:19arrdemgdev: I benchmarked the L system expansion in Clojure vs in Scala and Clojure won by a factor of 4 :P
23:19john2xooh nice. thanks
23:19arrdemgdev: no clojure port will be forthcomming tho.. too many other projects
23:20gdevarrdem, cool, anything fun?
23:21arrdemgdev: I got the go ahead to help finish clojure in clojure as my graduation project... I've got a stack of JVM books on the way for my Christmass relaxation reading as a result
23:21arrdemnever did finish cloutjure tho...
23:22justin_smitharrdem: that is awesome, great news
23:22gdevlol yeah we didn't get far enough to have anything to continue
23:22gdevarrdem, now I know what I'm getting you for christmas =D
23:24arrdemgdev: hehe I played for a couple days with neo4j and ultimately did get something reasonable working, I just realized that the graph construction issues were more complex than I could fathom without a partner :/
23:24arrdemso the whole
23:24arrdem"social graph" thing kinda killed it
23:27gdevarrdem, yeah I tried modeling it in Datomic, but I didn't have the data you had scraped so I wasn't sure what all we were capturing
23:29arrdemgdev: :/ yeah. sometime when you can get away we should get together and take a second stab at that... in fairness tho our toolset & codebase coordination was essentially no-existant :P
23:29arrdemnext year'll be better if clojurecup runs again
23:30gdevarrdem, yeah next year lets just do a windjammers clone in clojurescript
23:30arrdemgdev: hahaha that'd be awesome.
23:32gdevmy latest project is doing 8bit clones with Quil and Overtone. but everyone is migrating to the browsers
23:32justin_smithI want to model something in blender this weekend that I can print with the 3d printer at work
23:33justin_smithbonus points for an idea that lets me use clojure to help generate the structure
23:34arrdemjustin_smith: 3d serpinsky triangle
23:34justin_smithhttps://github.com/krumholt/penumbra-blender-exporter I found this
23:34arrdemjustin_smith: trivial to compute, uses turtles in 3D!!!11!1
23:34justin_smithI can thus make a shape, export to edn, fuck with it, then export to blender
23:34justin_smitharrdem: awesome idea
23:36gdevjustin_smith, lol 4 year repo, good luck with that
23:37justin_smithit's just a python script that turns blender format into edn
23:37justin_smithso it shouldn't be too bad? worth a try
23:37arrdemwhat could possibly go wrong...
23:37gdevoh, sorry I'm just burned because I've been trying to get penumbra up to date for a couple days now
23:39justin_smithoh, I am unaware of the larger project
23:39arrdemclojurebot: turtle |is| http://www.rockpapercynic.com/strips/2011-11-25.jpg
23:39clojurebot'Sea, mhuise.
23:42gdevjustin_smith, yeah, and its not under active development
23:43arrdemgdev: do you remember who got the domain name?
23:43gdevarrdem, no idea
23:44arrdemoh. it was James.
23:47igorw,(= #{0.0 4.0} #{0.0 (Float/valueOf "4.000")})
23:48clojurebotfalse
23:48igorw,(= #{4.0} #{(Float/valueOf "4.000")})
23:48clojurebottrue
23:48arrdemgdev: I figured out what I've been doing wrong... I've been trying to munge multiple datasources into a single graph. Split it out into a single representation per service and suddenly everything falls into place.
23:48igorwanyone want to explain that one to me? :)
23:49igorwxpe: ^
23:49arrdemigorw: you're comparing the set #{0.0 4.0} with the set #{4.0}
23:49arrdemigorw: that should fail
23:49arrdemoh wait.
23:49arrdemwhat?
23:49clojurebotwhat is http://gist.github.com/306174
23:49arrdemclojurebot: go away
23:49clojurebotGabh mo leithscéal?
23:49arrdem~botsmack
23:49clojurebotOwww!
23:51igorwso, is it a bug? I have no clue how to debug this
23:52arrdemigorw: not sure... whatever's going on here sure isn't obvious.
23:53justin_smith,,(= #{0.0 4.0} #{0.0 (Double/valueOf "4.000")})
23:53clojurebottrue
23:53justin_smith0.0 as a literal is a double
23:53justin_smithnow why it is not doing the implicit numberic equality in sets is another question
23:53gdev,(class 0.0)
23:53clojurebotjava.lang.Double
23:54xpeigorw: that's pretty cool
23:54xpenicely done
23:55igorwjustin_smith: ah nice, thanks!
23:55justin_smithmuch simpler:
23:55justin_smith,(= #{4.0} #{4})
23:55clojurebotfalse
23:55justin_smith,(= 4 4.0)
23:55clojurebotfalse
23:56xpe,(hash 4.0)
23:56clojurebot1074790400
23:56xpe,(hash (Float/valueOf "4.0"))
23:56clojurebot1082130432
23:56xperight?
23:57arrdemxpe: Double/
23:57arrdemoh.
23:57arrdem(inc xpe)
23:57lazybot⇒ 1
23:57xpeigorw ^
23:57arrdemigorw: this...
23:57arrdem,(= #{0.0 (Double/valueOf "4.0")} #{0.0 4.0})
23:57clojurebottrue
23:57justin_smith,(every? #(apply == %) (map list #{4} #{4.0}))
23:57clojurebottrue
23:58justin_smithif you have nothing but numerics in your sets, that should suffice
23:58arrdemigorw: Double and Long are the standard numeric literal types in Clojure
23:58justin_smith,(every? #(apply == %) (map list (sort #{3 4}) (sort #{3.0 4.0})))
23:58clojurebottrue
23:59igorwconfusing part is that the sets behave differently when they contain mixed types
23:59justin_smithigorw: notice my ammendment to call sort above
23:59gdevconvert them all to string
23:59justin_smithbecause sets are not ordered
23:59justin_smithgdev: my above works if the sets are strictly numeric
23:59gdevjustin_smith, converting them to string makes everything just work