#clojure logs

2012-06-20

00:01adurefheap?
00:01RaynesIt's just me shamelessly plugging. https://refheap.com
00:01aduoh it uses noir! :)
00:02kennethokay, so i'm about to give up on jzmq
00:03TurnsRefheap looks nice.
00:05estebanni looked at zeromq a few months ago in a c context and it looked pretty good -- except that its feature set didn't really match my needs.
00:05estebannWhat is wrong with it?
00:07technomancythe java libraries are a mess
00:07estebannah, so just a bad port?
00:08technomancyit's also like ... not a message queue
00:08technomancyso a lot of people are mislead by the name
00:09estebannright.. so was I
00:09estebannbut it still seemed like a pretty cool idea
00:09technomancysure, if you have room in your stack for a protocol that's not HTTP and not a message queue
00:10cmajor7what is an idiomatic way to store and pass a struct/data structure in clojure? e.g. Need to create a request via populating "pounds / ounces / price / country / width / length / height / girth / size" on it (all values are required). Taking it in as a map does not seem right.. or is that the way?
00:10technomancyuse a map
00:11amalloymaps are the king of data
00:11brehautand the data of kings
00:11cmajor7I see.. that is what I did.. just feels a bit off, cause it is more than.. 3,4 keys
00:12cmajor7and needs to be repeated in functions definitions / let bindings, etc..
00:13amalloycmajor7: if the repetition is vexing, you can avoid it with macros
00:14cmajor7amalloy: thx. I'll look into it. it is not really 100% repeatable, so the macros will need to be somewhat smart..
00:16Turnscmajor7: More smart than just having default values?
00:17estebannwhy not define a type? <- (a genuine question)
00:17cmajor7Turns: well.. there is no really good defaults for it.. since it needs all the fields for each "request"
00:17aduok
00:17aduhttps://www.refheap.com/paste/3246
00:17brehautestebann: what would defining a type buy you? <- geniune question
00:17aduwhy is it not working
00:17amalloyestebann: that's just static-typing fetishism. maps already do everything you need
00:18brehaut(genuine socratic question that is)
00:18adujson/parse-stream is returning {"hello" "world"}, but mustache/render is expecting {:hello "world"}, what to do
00:18brehautadu: defs in fns are bad. use a let
00:19cmajor7estebann: you mean http://bit.ly/LzHPMI ?
00:19adubrehaut: I realize that, but I'm just trying to get it working, I'm going to refactor this code anyways
00:19brehautcmajor7: type is almost certainly not what you want. estebann may have been referring to defrecord or deftype. in either case he is wrong
00:20noidi,(keyword "hello")
00:20clojurebot:hello
00:20adunoidi: so (map keyword data)?
00:20cmajor7brehaut: I see. ok, good to learn about those as I go anyway :)
00:20brehautcmajor7: most people suggesting 'type' are meaning 'class' anyway
00:21cmajor7I see.. well it is only natural coming form imperative universe
00:21brehautcmajor7: but deftype is for low level stuff (not what you want) and defrecord defines a record type which is used like a map anyway, so unless you need those other features of records (participating in protocols for instance) you probably just want maps
00:21noidi,(into {} (for [[k v] {:hello "world"}] [(keyword k) v]))
00:21clojurebot{:hello "world"}
00:22aduo wait
00:22aduparse-stream takes an option :P
00:22aduhaha
00:22noidioops, I got the input wrong. anyway, it should convert string keys to keywords :P
00:22adu, (into {} (for [[k v] {"hello" "world"}] [(keyword k) v]))
00:22clojurebot{:hello "world"}
00:22aducool
00:23cmajor7brehaut: good stuff. next academic stop is at "participating in protocols defrecords"
00:23brehautcmajor7: thats a complicated way of saying, requires type directed polymorphism
00:24cmajor7right I get thata.. just cool to project it to clojure world
00:24cmajor7no need for it in my use case, but still need to cover
00:25brehautcmajor7: i think i have created 2 defrecords in anger in about 4 years of clojure
00:25brehautwell, thats not fair, there havent always been defrecords
00:25adunoidi: yey it's working: https://www.refheap.com/paste/3249
00:26aduthanks everyone
00:26cmajor7brehaut: ok, well I am only 4 defrecords behind..
00:26cmajor7what would be the clojure way go about templatizing XML (e.g. XML request) in order to layer this "{ :pounds :ounces :price :country :width :length :height :girth :size}" map on it… compose "str/replace"s or use some kind of templating engine?
00:27aducmajor7: maybe what I just did?
00:28brehautcmajor7: it would not be string munging
00:28brehautyou could use either a templating engine (such as enlive) or you could just generate the elements and then serialise that to a string
00:29cmajor7brehaut: right, I don't want to do that, but I am looking at hiccup/enlive, and .. not sure if I need to bring them in for a "simple" overlay..
00:29cmajor7generating elements might be a bit messy, since there are a lot of them to generate + some protocol specific ones
00:30cmajor7and if the protocol changes.. code would need to change
00:30cmajor7the template code I mean
00:31cmajor7ok, I'll take a look at enlive, never used it before, and on github it says "a selector-based (à la CSS) templating", but I always hear good things about it..
00:31brehauti think worrying about 'bringing in code' when its the size of enlive or hiccup is madness. just do it
00:31brehautor use the clojure.xml structures and use that
00:32cmajor7I see, that is what I did not know "how big/messy is enlive"..
00:32brehaut(ie, maps with keys :tag :attrs :contents from memory)
00:32brehautassume that no library in clojure other than clojure.core is big
00:33brehautand messy? everything is in its own namespace. doesnt matter how 'messy' it is
00:33brehautthis isn't C, you dont have to be afraid of using someone elses wheel
00:33cmajor7I see, I just like a predictable number of wheels.. usually 4 :)
00:34cmajor7cool, will do. appreciate you help.
00:39adubrehaut: I refactored it: https://www.refheap.com/paste/3250
00:39brehautmuch better
00:39adu:)
00:39brehautalthough i think you mean :require when you say :use
00:40adubrehaut: I have no idea what the difference is
00:40aduor import
00:40brehautuse brings all the public vars into the current namespace, require doesnt
00:40brehautyou need to qualify any var with require
00:40brehautthe fact that you have :as'd stuff with use indicates that you really want :require
00:40aduok
00:41brehautimport is specifically for importing java classes
00:41aduah ok
00:44kennethomg, i'm about to swear off clojure. i'm *this* close
00:44kennethi love clojure, but java is a fucking abomination
00:44aduo yey I can rename my-render to render :)
00:44kennethand every time i use clojure, i end up hating every minute of it because i spend 90% of my time fighting with java, and less 10% writing clojure
00:45brehautyou cant make a delorian monster truck without it being part monster truck
00:46adukenneth: why not write it in clojurescript, then port back?
00:46hashsetkenneth: what imperative language are you more comfortable with?
00:47kennethhashset: how about C, for starters
00:47Turnskenneth: You prefer C over Java?
00:47adubut then I got the agile bug, and I try to write thousands of lines of code per day, and C holds me back
00:48kennethi prefer many things over java, and c is pretty much at the top of the list
00:48Turnskenneth: That's amazing! What is it that you value that C provides and Java lacks?
00:48kennethobjective-c is pretty great, too. as for dynamic interpreted languages, ruby is fantastic. i love clojure as a language, too, it's pretty much one of my favorites
00:49aduI think C is more portable than Java
00:49TurnsI am also very impressed by many things about Clojure.
00:49TurnsClojure is certainly a great improvement over all other forms of Lisp.
00:49amalloywhy is it amazing that someone would prefer C to java?
00:49kennethTurns: how about 1) not loading a gigabyte virtual machine, 2) not being insanely verbose and needlessly complex, 3) being more modern
00:50aduyeah, like TLS
00:50kenneth3) is hard to believe, but these days C has fantastic concurrency libraries (libdispatch!), closures, macros
00:50Turnskenneth: Yeah, if you're counting bytes in memory, best to go with C. Not sure about those other two, though.
00:50aduC doesn't have closures
00:51kennethadu: libsystem_blocks
00:51kennethif you use a modern compiler
00:51kennethhere's an example that i do all the time in my code:
00:51TurnsPeople have added closures to C? That's even more amazing.
00:52kennethdispatch_async(queue, ^{ printf("Hello, world!\n");});
00:52adukenneth: (1) that isn't a library (2) it isn't portable, it's apple only, and (3) it's nonstandard, and (4) the syntax screws with every C parser I've tried
00:52kennethadu: if you're not into it, C++11 has lamdbas too
00:52aduthe ^ syntax even screws up GCC-XML
00:52adukenneth: which isn't C
00:53kennethGCC is pretty much an abomination too, IMHO. LLVM / Clang all the way
00:53aduagreed, LLVM rocks
00:54kennethadu: but 1) fair point, it's not a *library* per se., 2) it was written by apple, but is by no means apple only. it works on most unixes, 3) that's true and 4) why would you need to use a c parser that *isn't* clang's?
00:55kennethif you're willing to depend on clang (which i am), then you're fine
00:55TurnsI understand that Java is much more verbose than Clojure or any other functional language, but is it really so much more verbose than C?
00:55kennethyes, i think it is, Turns
00:55adukenneth: documentation generators, IDEs, syntax highlighers, pastebins, ctags, debugging, etc.
00:56kennethin C you don't write FooBarRunnableFactory
00:56hashsetbut you write sizeOf :P
00:56aduso if clang has all those in every text editor, then no you don't need another parser
00:56kennethyou don't every little thing in classes that don't need to be, you have few source file, and no import insanity for example
00:57TimMcWait, are we talking about C or C++?
00:57TurnsI've grown to love how everything in Java is in classes. I can see why not everyone would agree, though.
00:58aduTimMc: I'm talking about parsing
00:58TimMcOh, that was just a brief excursion.
00:58TimMc(Was looking at the C++11 thing.)
00:58kennethadu: for debugging lldb works fine with blocks, my code editors / syntax highlighters have no problems with the ^ syntax, and i don't use doc generators
00:58kennethso for me it works out
00:59kennethTurns: yeah, i love it when done right, as in in ruby
00:59Turnskenneth: It's not done right? What is wrong with it?
00:59kennethbecause ruby turns it into an advantage with its dynamism
00:59kennethduck typing, monkey patching, retrospection
00:59kenneththat's the kind of thing that makes objects everywhere awesome
00:59Turnskenneth: What's all that stuff?
01:00brehautmonkey patching is never a feature, and always an admission of defeat
01:00aduI think Go has duck typing
01:00LeonidasTurns: int is a class?
01:01kennethTurns: duck typing means you don't care about what class you're using, just that it implements what you need (e.g., if you need to turn something into a float, you just care that it implements .to_f)
01:01brehautadu: i think go has something more akin to typeclasses / protocols than monkey patching
01:01TurnsWow, duck typing is horrible. It's like it is trying to kill abstraction and type safety!
01:01kennethTurns: means you can add methods to already defined classes
01:02adubrehaut: there are 2 superconfusing techniques in Go: struct embedding and interface embedding
01:02kennethmonkey patching*
01:02PeregrinePDXWell monkey patching implies that you can add methods to defined classes dynamically at runtime.
01:02adubrehaut: I think struct embedding is monkey patching / mixins, and interface embedding is duck typing / typeclasses
01:02clojurebotc'est bon!
01:02kennethand related, that you can add methods to objects and classes at runtime
01:02kennethand retrospection means you can inspect objects at runtime to see what they are, what they support, etc
01:02brehautadu: duck typing is not typeclasses / polymorphism
01:03adubrehaut: then s/I think/I think not/
01:03Turnskenneth: I guess monkey patching could be useful, as long as it doesn't give you access to private members.
01:03adubrehaut: I've written lots of code in Go, but I've never understood those abstract terms
01:04PeregrinePDXPsh private members are an illusion in just about every language.
01:04aduI've also written lots of code in Haskell, so I'd like to say I understand typeclasses too
01:04kennethTurns: duck typing is fantastic, it lets you define methods that take as an argument *something that is coercible to float via .to_f*, instead of an *int* specifically
01:04brehautmonkey patching is like a rube goldberg machine that eventually pulls a trigger on a gun aimed at your feet
01:04kennethTurns: means for example if you write your own collection type things that have been written with the standard lib collection type in mind won't break, so long as you implement the original interface
01:05adubrehaut: that makes no sense
01:05TurnsHaskell typeclasses is what I would want to use monkey patching for. You can add any method to an object anywhere, so long as you know how to implement it for that object, just like type classes in Haskell.
01:05brehautTurns: exactly. typeclasses are the real solution to the hack that is monkey patching
01:05Turnskenneth: What you are describing as duck typing sounds exactly like what Java does.
01:06kennethbut back to my point about C, when you know what you're doing, you can write very concise and beautiful code, especially if you know how to use macros well
01:06brehautalso kenneth i think you mean introspection rather than retrospection?
01:07kennethbrehaut: er, yes
01:07Turnskenneth: Oh yeah, Java's got that.
01:07aduTurns: sounds like the Set Monad problem
01:08kennethi'm working on a game in Obj-C / C and my entire game state is container in a 82 byte malloced pointer
01:08kennethmy code is very well separated following the MVC pattern
01:08Turnskenneth: Just the sort of thing I would expect a C programmer to be pleased with: counting bytes.
01:08aduGo interfaces and Haskell typeclasses both have ways of "inheriting requirements", i.e. I'm defining something called X, and it must already be a Y
01:09noidiWhat's the difference between "Load file in REPL" and "Compile file in REPL" in CCW?
01:09PeregrinePDXA lot of languages have some form of fetishism. SO c programmers count bytes. So what.
01:09kennethTurns: the comparable code in java would have 100+ objects in memory, a good dozen classes, most of them empty containers with a couple accessors
01:09amalloyretrospection is when you wish you had planned your interfaces more carefully
01:10brehaut(inc amalloy)
01:10lazybot⇒ 24
01:11kennethTurns: also in my case the conciseness of the data matters, because i need to embed the entire game state into a URL
01:11kennethso people can text each other self-contained levels
01:12Turnskenneth: How you store it in memory and how you output as a URL shouldn't be connected. That's unfortunate coupling!
01:12adukenneth: brilliant
01:12kennethin java i'd have to build serialization routines for a more concise data format. just an example of how java makes my life a pain and how it requires more code and worse, more classes, to do the same thing
01:13PeregrinePDXWhy would you need to embed your entire game state into the url?
01:13Turnskenners: I'm sure making serialization for a game state of no more than 82 bytes wouldn't be hard.
01:13adukenneth: so if people reverse engineer your url-encoding format, they can give themselves 1 billion hitpoints, and 1 trillion credits?
01:13PeregrinePDXI can see wanting to do so but needing to do so seems like an awkward requirement.
01:13kennethPeregrinePDX: it's not a requirement, it's just a nice to have
01:14kennethbut i'm not talking in absolutes here, i'm just showing how java is a pain in my ass for doing even the simplest thing
01:14PeregrinePDXSo you wouldn't have to build serialization routines for java to make it encode your game state in a small space. Just if you wanted to make it feature identical to your other code.
01:14brehaut,(char-array 84)
01:14clojurebot#<char[] [C@7777ac14>
01:14brehautdamn
01:15brehauti wish there was a way to just get hold of 84 bytes in java
01:15kennethmy entire game logic, state, and an objective-c wrapper class fits in a 300 line .m file
01:16kennethif i were writing this in java, i'd be drawing a diagram of interconnected classes and objects on a whiteboard at this point and creating a folder structure to sanely hold my code
01:16TurnsI suppose C has its superior equivalent to Swing, too.
01:17kennethnever used pure C for building graphical user interface (aside from OpenGL), but in obj-c land UIKit & AppKit are fantastic libraries
01:18kennethhttps://gist.github.com/ac122324fbe724165d61
01:18kenneththere's a couple prototypes and typedefs in the header too, but that's pretty much it
01:18kay__would it be out of line to ask what a .m file is?
01:18Turnskenneth: What would prevent you from simulating C in Java by making all your functions static members of as many or as few classes as you like?
01:18tomjakubowskikay__: an objective C source file
01:20kennethTurns: well for one, you can't (sanely) do a callback pattern in java
01:20kennethbecause java doesn't support closures
01:20kenneth(anonymous inner classes implementing Runnable do not count as a sane closure)
01:20amalloybrehaut: i don't understand. do you just want (byte-array 84), or is this some kind of sarcasm/joke?
01:21brehautamalloy: it was some kind of sarcasm/joke
01:21Turnskenneth: What's wrong with anonymous inner classes?
01:21brehautamalloy: with an added not looking at my apropos output hard enough
01:22Turnskenneth: Does that nonstandard C closer syntax do something that anonymous inner classes don't do?
01:22kennethTurns: it's a syntactic nightmare, for one. secondly, you need to create an interface declaration for every "signature" you want your "closure" to have, IIRC
01:22kennethTurns: memory management and reference counting, for one. though i guess you don't have to deal with that since you have a GC
01:23Turnskenneth: How can you use a closure without a defined signature anyway?
01:24kennethclosures always have signatures, but you can define the type inline, or typedef it to give it a name if you'd like
01:24kennethno need to write protocols / interfaces for it
01:25Turnskenneth: What do you mean by "define the type inline"?
01:25kennethTurns: you can write a function like this for example
01:27kennethvoid do_something(void(^callback)(int *err, char *data));
01:28Turnskenneth: Oh, I see. It's just a little less verbose than the Java equivalent.
01:28kennethi.e. a function that takes an closure as its only argument, where the closure returns void and takes two arguments (a pointer to an int, and a string)
01:29jhowarthIs there anything special I need to do to get slime/swank to be able to work with my project after I do clojure-jack-in?
01:29kennethnot sure how i'd do this in java, but i'm pretty sure it involves writing an interface, then taking as argument that implements that interface, and then to use it i'd have to use an anonymous inner class that implements said interface
01:30Turnskenneth: Yeah, that's how.
01:30kennethmy point is not that java is not a capable language; that's been disproven by people smarter than myself
01:31kennethmy point is that java makes programming painful and slow and is (to me) incredibly containing and frustrating
01:32Turnskenneth: Language preferences cannot be proven.
01:32kennetheven in C, these are things I can do on the fly as i code, and i really enjoy my time doing it
01:32kennethand i can pretty much dig in as long as i've got llvm and vim around (or even gcc/gdb, god forbid)
01:33kennethjust thinking about using java without a massive IDE and its series of necessary tools makes my brain hurt
01:33Turnskenneth: I do that all the time. It's no problem, really.
01:34kennethyou're probably a much better java developer than i am
01:34kenneth:p
01:34kennethspeaking of which, if you know how to compile a JNI library and use it from a clojure project successfully, i'd love your help
01:34Turnskenneth: I doubt it. Worrying about memory management in a language with little or no static type checking and having to keep track of header files makes my brain hurt when I think about it.
01:35Turnskenneth: Wow. No wonder you're having troubles!
01:36kennethi've spent the past three hours trying to use ømq in a clojure project and nothing works :p
01:36Turnskenneth: What sort of problem are you having, though? It seems to me like it should work just fine as long as you keep things persistent.
01:37SgeoHmm
01:37SgeoI wonder if I could actually implement the Seer monad in Clojure
01:38Sgeo(Of course, that would require me to understand it)
01:38kennethTurns: in my experience, the compiler is smart enough to warm me when i'm doing something stupid. but when i know what i'm doing and i'm explicit about it, it will let me do anything i want, which is great. and i love header files because it's like documentation that informs both the compiler and users of my code. it saves me from having to write javadoc type stuff
01:38kennethto each his own, tho
01:39Turnskenneth: Just glancing at the ZeroMQ wikipedia page makes me think using it from Clojure seems like an awful task!
01:40kennethTurns: my problem is that `leon compile` fails. i've tried a couple things as suggested from online tutorials (since documentation is nonexistent) and each gives me a different failure
01:41Turnskenneth: What sort of failures are you talking about?
01:43kennethTurns: for example, i get java.lang.ClassNotFoundException: org.zeromq.ZMQ.Socket (log_scale.clj:1)
01:44kennethand i have no idea how to debug it
01:44kennethi've compiled the JNI, i've added it to project.clj
01:44kennethhttps://gist.github.com/802b506d17c68150b293
01:44kennethhere's my project.clj fwiw
01:44kennethand i'm trying to import [org.zeromq.ZMQ Socket]
01:45Turnskenneth: And you actually have that class in the classpath? I just have to ask that.
01:45amalloyi should really write a tool called leon. the amount of lein-typo google-juice it would get...
01:47kennethTurns: presumably
01:48kennethTurns: if i extract the jar that lein installed i've got org/zeromq/ZMQ/ZMQ$Socket.class
01:48kennethalso i verified that libjzmq is correctly in /usr/local
01:48kennethlike i said, i have no idea how to debug this
01:48Turnskenneth: That doesn't look like the right class. ZMQ$Socket isn't the same as Socket.
01:49kennethwell, fwiw i get the same error if i try to use org.zeromq.ZMQ.ZMQ
01:49kennethwhich does look like a class
01:50Turnskenneth: Exactly the same error? Or ClassNotFoundException: org.zeromq.ZMQ.ZMQ.Socket?
01:51kennethif i change the import to [org.zeromq ZMQ] i get a different exception (good sign?)
01:51kennethno jzmq in java.library.path
01:51kennethpresumably indicating that it can't find libzmq
01:52kennetheven though i do have this just in case: :jvm-opts ["-Djava.library.path=/usr/local/lib:/opt/local/lib:/usr/lib"]
01:53kenneth(java.lang.UnsatisfiedLinkError)
01:54kennethoh wtf, where did my /usr/local/lub go
01:54kennethwould lein ever nuke my usr local lib?
01:54Turnskenneth: I guess that means that at least you really have a class called org.zeromq.ZMQ. That is a good sign, actually!
01:55kennethjesus
01:55kennethlooks like lein rm'd my /usr/local/lib
01:55kennethwhat. the. fuck.
01:56kennethokay
01:56TurnsI'm surprised that lein would do that!
01:56_atoyou're running lein as root?
01:56kennethme too
01:56kenneth_ato: nope, but /usr/local is writable by me
01:57_atoah
01:57kennethre-did the make install on my compiled jzmq and looks like now it's picked up
01:57kennethprogress
01:57kennethnow my zeromq lib got nuked too
01:57kennethgrr
01:57kennethgood thing most of my libs were just symlinks and not binaries
01:58kennethotherwise iw ould be very fucked right now
01:58Turnskenneth: I can't really help you with making lein stop deleting things, but you should probably figure out why it is doing this stuff before you try to go any further.
01:59kennethyeah, good point
01:59kennethgot my libzmq back, good news. now i'm onto my next error: Could not locate org/zmq/clojure_zmq__init.class or org/zmq/clojure_zmq.clj
01:59kennethi take it that's related to the clojure-zmq package
02:00TurnsHave those files been deleted too, I guess?
02:00kennethnope, that's not in use lib that's in my project folder
02:01TurnsNormally files that are where they are supposed to be can always be located. So there's not many things that could be causing that problem.
02:01kennethif i unpack the clojure-zmq.jar i see org/zeromq/clojure.clj
02:02kennethonly source file aside from example in the unpacked jar
02:02_atothe JVM (pre the new APIs in Java 7) is completely unaware of symlinks. Could you have had a symlink to /usr/local/lib and lein followed it when cleaning up the target directory?
02:02Turnskenneth: That's not one of the missing files, though.
02:03kenneth_ato: i don't think so, though i did try at one point to set :native-path to "/usr/local/lib"
02:03kennethmy guess is that's the reason?
02:04Turnskenneth: Do you really have a package called org.zmq and one called org.zeromq? That's not a mistake?
02:26kennethomg got it to compile
02:26Turnskenneth: How?
02:26kennethtaking it step by step
02:26kennethi had to make a bunch of changes
02:35amalloySgeo: the Seer monad? the well of google runs dry when i try to find that
02:37Sgeoamalloy, top answer to http://stackoverflow.com/questions/11060565/tying-the-knot-with-a-state-monad
04:45noidiI've added this to my project.clj: :dev-dependencies [[lein-midje "2.0.0-SNAPSHOT"]]
04:45noidibut running 'lein midje' gives me: midje is not a task.
04:46noidiI'm using Leiningen 2.0.0-preview6
04:46clgvnoidi: you can omit adding it as dev dep. instead install it via lein plugin install lein-midje 2.0.0-SNAPSHOT
04:47clgvnoidi: a side note: :dev-dependencies is not used in lein2 anymore
04:47noidiokay, thanks
04:47noidithat means the midje docs are out of date
04:47clgv noidi: you have to add midje as dependency though
04:48clgvlein-midje is only the plugin to run the midje tests you have written via leiningen
04:48noidiyeah
04:48noidiwill midje be bundled in the uberjar, then?
04:48noidiif lein2 ignores dev-dependencies
04:49noidior does it just not load its plugins from dev-dependencies?
04:49clgvnoidi: you have to use the :profiles syntax in lein2. that should bge explained in the readme
04:50noidiok
04:59kralnamaste
05:02noidiwhat I ended up doing was :profiles {:dev {:plugins [[lein-midje....]]}}
05:02noidithe new profiles system looks great
05:02noidinow that I got the hang of it
05:03clgvstill waiting for lein2 to be released as a stable version ;)
05:07hyPiRionclgv: lein2 is relatively stable unless you're depending on the repl in Windows.
05:07clgvhyPiRion: I like the maintainer to be confident that he can do a stable release ;)
05:37noidiclgv, apparently it's not that lein2 is buggy, but clojars.org needs some repo rework, and Phil wants to use the new repos as defaults in lein2 http://groups.google.com/group/leiningen/browse_thread/thread/40f8ed97f37a47e1
05:53TEttingerhyPiRion, what is so unstable about the lein2 REPL on windows?
05:54TEttingerI haven't encountered any issues in my (light) usage
06:18clgvnoidi: who says it's buggy? I will upgrade when they say 2.0.0 is done. ;)
08:00cshellIs there a way to destructure a Java Pojo to a clojure map? ie. getName -> :name?
08:04gstamp(doc bean)
08:04ohpauleezcshell: bean
08:04cshellawesome, bean
08:04cshellhaha
08:04cshellthanks guys
08:04ohpauleeznp
08:06wmealingis clj-audio one of the saner ways to deal with microphones in clojure ?
08:06wmealingif there is a better way, i'm open to suggestions
08:13wmealingmy google is failing me
08:18clgvwmealing: you can just take a well established java lib therefore
08:21wmealingclgv, like javax.sound.sampled and go from there ?
08:22clgvI dont know any lib for it. either you use a good lib via interop directly or you build a wrapper layer for better usage from clojure
11:18edoloughlinCatching up/migrating from 1.2->1.4. What's the current best practice for working with exceptions? Slingshot?
11:20nDuffslingshot is good stuff, yes
11:21edoloughlinI seem to remember an attempt to bring Lispy conditions to Clojure. Did that go anywhere?
11:25foxdonutedoloughlin: what does that mean? more parens?
11:27edoloughlinfoxdonut: See http://clojuredocs.org/clojure_contrib/clojure.contrib.condition — The 'Where did clojure.contrib go?" page (http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go) says it was replaced by Slingshot, but it's not equivalent and seems to be removing functionality.
11:28S11001001slingshot is cooler
11:29S11001001choose your own dispatch
11:29clgvregarding "Where did Contrib go?": I wonder when clojure.core.incubator gets merged into clojure.core? 1.4 would have been a chance...
11:29S11001001autounboxing
11:29S11001001(you can get buried in those dumb runtimeexception boxes and it won't matter)
11:31edoloughlinS11001001: Ok. I didn't get a sense of these benefits from the slingshot github page...
11:33nDuff...well, _some_ of the things I'd like slingshot to have are still in the current snapshot tree rather than in a release yet
11:33nDuff...such as being able to use multiple conditions for a single catch clause...
11:33nDuff...but yeah, that's a pretty darned trivial quibble, and one that'll fix itself with time.
11:34gfredericksthere should be a term to insert into a version number to indicate "This is not my project but I want a release of the current edge snapshot so I'm throwing this up on clojars mostly just for myself."
11:34gfredericksmaybe could include a SHA prefix as well
11:34clgvgfredericks: thats your group-id that says this ;)
11:35gfredericksclgv: hard to distinguish that from "I'm forking this project because the maintainer is lazy"
11:35gfredericksI guess if you were seriously forking you'd probably rename it :/
11:35clgvgfredericks: sounds almost the same ;)
11:35clgvthe first comment I mean
11:35gfredericksokay, so the only thing is to put the SHA into the version number
11:36gfredericksclgv: I meant "forking" in a long term way
11:36cemerickgfredericks: "throwing this up on clojars for myself" should be replaced with "throwing this up into my private s3 repo for myself" https://github.com/technomancy/s3-wagon-private
11:36gfrederickscemerick: I'm not passionate enough to dispute that :)
11:37TimMccemerick: And make it unbuildable for others? Nah, I cut a release like org.clojars.timmc/enlive and call it good.
11:38gfrederickscemerick: yeah there is that ^ case
11:38clgvnDuff: erm the last commit was the change to the next version so probably the changes you like are in a release of slingshot (0.10.3)
11:38gfredericksooh oh oh; what happens to the diamond dependency situation when you've got two libs with different group/ids but identical namespaces? o_O
11:38cemerickThat's degenerate.
11:39cemerickMaybe with Leiningen 3. :-P
11:39gfredericksA -> B -> enlive; A -> C -> org.clojars.timmc/enlive
11:39gfredericksmaven will pull in both?
11:39gfredericksand clojure will be confused?
11:39TimMcJust block the regular enlive.
11:39gfredericksTimMc: so you have to be concious of the situation?
11:40TimMcAh, I see... A wouldn't know.
11:40TimMcBut yes, the existing coordinate system is insufficient.
11:40cemerickgfredericks: yeah, you'd get both jars on the classpath, and whichever came first would win.
11:40gfrederickshttps://twitter.com/stuartsierra/status/214023282511450114
11:41cemerickquite right :-D
11:41gfredericksand with that ^, I'm back to working on work
11:41TimMcIt should be group/artifact + publisher + version & variants
11:41clgvTimMc: :O
11:45TimMcclgv: Don't keep your mouth open like that, encoding bugs will fly in!
11:46clgvlol. dont worry, I dont do I/O right now - it's statistics right now
11:52S11001001edoloughlin: source docs
11:55nDuffclgv: Heh. Yay!
12:11jonasendnolen: ping
12:14dnolenjonasen: pong
12:15jonasendnolen: I've been running queries on cljs/core.cljs and I've found a few "interesting" things
12:15dnolenjonasen: shoot
12:15dnolenjonasen: by which I mean, what in particular?
12:16jonasenfor example, the assert macro is imported from the java side and expands to java.lang.AssertionException on the javascript side
12:17jonasenso we should probably move it over to the clojurescript macro side
12:17N8Dawgi had a question around test coverage tools for clojure
12:17N8Dawgdoes anyone know a good library, if one doesn't exist how useful would people find one?
12:18dnolenjonasen: huh, strange - we use assert in the tests and it works fine.
12:18technomancy,google lein-guzheng
12:19jonasendnolen: there are three usages of assert in cljs/core.cljs and the all expand to java.lang/AssertionException
12:20technomancyhiredman: looks like clojurebot has experienced an untimely demise
12:20technomancyN8Dawg: take a look at guzheng
12:20dnolenjonasen: just tried in REPL I don't see this at all, so I need more info.
12:20N8Dawgtechnomancy: Thanks, that looks exactly what i'm looking for, i'll give it a whirl
12:21jonasenhmm.. I'll try to find more info then :), I'll get back to you on that particular issue later.
12:22dnolenjonasen: I just checked the source. assert macro is excluded in HEAD and assert is defined in core.clj compiler macros file.
12:22jonasendnolen: ok. So this has been changed since the latest release then
12:26dnmtechnomancy: What's the weather there today?
12:26jonasendnolen: https://github.com/clojure/clojurescript/blob/r1424/src/cljs/cljs/core.cljs#L1273
12:26technomancydnm: in seattle? sunny and wonderful. 68℉
12:26technomancyhehe; yeah
12:26dnmFuck this place. Seriously. Take this climate and shove it.
12:26jonasendnolen: ^^ is that good style or should it be (.floor js/Math)
12:27dnolenjonasen: not sure yet - we want core.cljs to compile everywhere. so that might become a complier macro.
12:28jonasendnolen: Do you mean you want to remove all js/foo from core.cljs?
12:29dnolenjonasen: yes
12:29jonasendnolen: ok.
12:30jonasendnolen: Next one is at https://github.com/clojure/clojurescript/blob/r1424/src/cljs/cljs/core.cljs#L5702
12:31dnolenjonasen: ?
12:31jonasenI think that kind of form confuses the analyzer
12:31dnolenjonasen: why?
12:32jonasenfirst, the clojure reader expands it to (new cljs.core.PersistentTreeSet ...)
12:33dnolenjonasen: oh right oops that's a bug now. cljs.core/PersistentTreeSet
12:34jonasendnolen: ok
12:34jonasenit fails in resolve-var I think
12:34jonasenor failed
12:35jonasendnolen: On that note. What's the point of this case: https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/analyzer.clj#L165 ?
12:37jonasendnolen: There is a similar case in resolve-existing-var, and I've never really understood why they are present
12:39dnolenjonasen: I considered removing it at one point, but reluctant to address the likely breakage. patch welcome.
12:40jonasenI think it's a remnant from waaay back (before the js/* magic namespace)
12:41dnolenjonasen: we also didn't have proper property access syntax.
12:42jonasendnolen: Removing it will probably break some code out there... but I think it should be removed
12:42jonasenthere is no equivalent on the clojure side
12:42dnolenjonasen: I agree - I meant breakage from within CLJS itself.
12:43jonasendnolen: true, but they are fixable
12:43dnolenjonasen: one thing to consider is where cljs.core.PersistentTreeSet should actually be considered bad form. That's valid in Clojure JVM.
12:44dnolenwhere -> whether.
12:44jonasendnolen: I've been wondering the exact same thing :)
12:45dnolenjonasen: another reason i left that case alone.
12:46jonasendnolen: the real problem with cljs.core.PersistentTreeSet is that the analyzer thinks that cljs is the namespace and core.PersistentTreeSet is the name
12:46jonasenso it becomes cljs/core.PersistentTreeSet
12:49dnolenjonasen: yes resolve-var and resolve-existing var should be fixed. they should probably not create the ns field at all.
12:50dnolenjonasen: related, type hints of either form should probably work.
12:50jonasenI think they should figure out the ns, isn't that what resolving means?
12:51dnolencljs.core/List & cljs.core.List
12:51dnolenjonasen: perhaps but how do you reconcile cljs.core.PersistentVector/fromArrays ?
12:51dnolenjonasen: I supposed there could be check to see if the part before / is a type.
12:52jonasendnolen: that's another thing I've been thinking about :)
12:54jonasenisn't it the case that cljs.core.PersistentVector/EMPTY would correspond to a static field in java land, i.e. interop? And there are no static fields in javascript so that kind of interop form should maybe not even exist in ClojureScript?
12:56dnolenjonasen: you might want to refer directly to cljs.core.PersistentHashMap/EMPTY in CLJS - it's useful.
12:56jonasenusful - maybe, but misleading?
12:57dnolenjonasen: how?
12:57jonasendnolen: In clojure that would be considered an interop form only
12:58Bronsaor a namespaced var
12:58Bronsa*symbol
12:58jonasendnolen: if PersistentHashMap is implemented in pure clojurescript, why not simply a empty-persistent-hashmap form?
12:58jonasenempty-persistent-hashmap var I mean..
13:00dnolenjonasen: Clojure interop forms are valid Clojure forms. at this point I think water under the bridge.
13:01dnolenjonasen: I see little advantage to empty-persisistent-vector, persistent-vector-from-arrays etc.
13:03solussd_is it possible to add a static field to a record?
13:08dnolenjonasen: I have no definitive answers but this is how it was done. Changing it now seems like churn with little gain.
13:09dnolensolussd_: no - but then again only ClojureScript has to core data structures actually written in Clojure.
13:11jonasendnolen: My point is that java.lang.Math/PI means something specific in clojure land (interop to _static_ methods and fields). Such things are not necessary in javascript interop
13:12jonasenso why not (.-EMPTY cljs.core.PersistentHashMap)
13:13dnolenjonasen: I don't see how we can guarantee that work on all hosts.
13:13dnolenjonasen: the (set! cljs.core.PersistentHashMap/EMPTY ...) stuff is already suspect.
13:15dnolenjonasen: likely we'll need some kind of static field construct that the compiler actually understands. in anycase, this probably something that needs wider discussion on dev ML - it's not something I'm clear on myself.
13:15jonasendnolen: ok. More hammock time :)
13:15hiredmanstatic fields for deftypes would be nice
13:17hiredmanand almost required for bootstrapping purposes
13:17solussd_dnolen: So I have some static data 'about' a record- any suggestions for a proper place to put it? specifically, I have records that implement a Version protocol and each record type needs to know its "version-prefix", which I wanted to be a static field on each record type, so I could ask a record type what its "version-prefix" is.
13:18dnolensolussd_: I think this conversation revealed that I have no suggestions :)
13:18hiredmansolussd_: that's a def
13:20dnolenhiredman: jonasen: yes this conversation is definitely worthy of Confluence page and ML discussion. Seems useful for both Clojure JVM, and necessary to make cljs.core more portable.
13:20jonasendnolen: In general, since you have implemented the collections in pure clojure(script) stuff like static fields shouldn't be necessary
13:30dnolenjonasen: perhaps - tho again I'm not sure polluting core.cljs with a bunch of deftype implementation specific top-levels is a gain.
14:20kmicuOutOfMemoryError GC overhead limit exceeded clojure.core/filter (core.clj:2463) :(
14:23kmicuIf anyone knows the optimal algorithm for counting inversions in vector?
14:24gtrakwhat is gvec.clj?
14:27jonasengtrak: from the source " generic vector implementation for vectors of primitives"
14:29gtrakthat sounds pretty neat
14:30gtrakare the normal data-structures used too far down to be rewritten in clojure?
14:31gtrakI guess you need like a self-hosting compiler to make that work
14:34gtrakmaybe to build a clojure-in-clojure you need to rely on initial class-gen from an older clojure
14:35dnolengtrak: i take it you haven't been following CLJS closely.
14:35gtrakdnolen: bits and pieces
14:35gtrakI know that testing clj-in-clj was an intent of cljs
14:36gtrakon top of protocols
14:36dnolengtrak: gvec.clj was a proof of concept - CLJS takes it further. deftype & protocols were required to make the datastructures implementable in Clojure itself.
14:37gtrakah, gotcha, very curious indeed :-)
15:24uvtcHi #clojure. Yesterday some of us were discussing how we might make 3rd-party Clojure library docs available online (either via clojars.org, clojuredocs.org, or someplace else).
15:25uvtcI came up with something very simple.
15:25ohpauleez"doc strings"
15:25ohpauleez:)
15:25uvtcHere's a temporary demo: http://www.unexpected-vortices.com/temp/clojure-libs-doc/index.html
15:26uvtcIt requires that a project have its own "doc" directory. And I only know of 2 at the moment. So that's why there's only 2 entries in the Contents of that page.
15:26uvtcBut if anyone wants to add a doc dir to their lib, and follow the link to the "notify us" page, I'll add it.
15:26uvtc(well, and if they want to write at least a doc/index.md file)
15:27uvtcohpauleez, this would be separate from docstrings.
15:27ohpauleezFor sure, it looks solid
15:27uvtctechnomancy, xeqi, dakrone ^^
15:28uvtcohpauleez, thanks.
15:30tmciveruvtc: is this intended to be an analogue of github's README.md? So you could just drop your README.md in the doc dir?
15:30uvtctmciver, You could do that, yes. Though, this system requires that at least one file in doc is named "index.md".
15:31uvtcYou might also shorten the readme and move some or most of its content into a doc/index.md file.
15:32uvtcI think I like the idea of a shorter readme, with more detailed documentation shifted to docs in a doc directory.
15:33uvtcThe way github works now, it's tempting to jam everything into your README.md.
15:35tmciveruvtc: this could be a nice idea but I don't think a lot of people are going to be in a hurry to duplicate documentation.
15:36uvtctmciver, duplicate?
15:36tmciveruvtc: well the README is going to be a subset of what's in doc/index.md.
15:37tmciveruvtc: personally I think I'd rather jam everything into the README. :)
15:37tmciveruvtc: the function docstrings should take up the rest of the slack.
15:37tmciveruvtc: and marginalia could be used to make something pretty from them.
15:38tmciverimho
15:38uvtctmciver, Yes, I very much like marginalia and the other autodoc-style tools. And I think it might be nice to use their output with github's "pages" feature.
15:45uvtcHm. Makes me wonder. Maybe I should instead use the existing README.md as the index.md...
15:46nDuffBlerg.
15:46uvtcBlerg?
15:46jcromartieso is Clojure still too heavy for Android?
15:48S11001001,(doc juxt) ; nDuff
15:48clojurebot"([f] [f g] [f g h] [f g h & fs]); Takes a set of functions and returns a fn that is the juxtaposition of those fns. The returned fn takes a variable number of args, and returns a vector containing the result of applying each fn to the args (left-to-right). ((juxt a b c) x) => [(a x) (b x) (c x)]"
15:48S11001001or something, some parens right there?
15:50nDuffS11001001: Hmm; I thought there was a way to build a map without generating intermediate vectors for the k/v pairs...
15:50S11001001I imagine zipmap just generates intermediate vectors
15:50llasramnDuff: With reduce?
15:50S11001001anyway, a list of two-tuples is no more expensive than two lists of same length
15:50gtrak(doc 'map-entry)
15:50clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: clojure.lang.Cons cannot be cast to clojure.lang.Symbol>
15:50nDuffhmm; apply array-map looks like it does the trick
15:51VinzentnDuff, zipmap?
15:53gtrakhttps://github.com/flatland/useful/blob/develop/src/useful/map.clj just creates clojure.lang.MapEntry instances, maybe that's faster?
15:53mkhow do changes to inter-dependent identities work?
15:53nDuffVinzent: That works; graci.
15:54mksuppose I have a string, "abcd", and an index position of 3 (between c and d).
15:54mkif I change the string atom, deleting the b, I'd like the index atom to change to 2
15:55mkwhat's the correct way to do this?
15:55Vinzentmk, maybe watchers could help
15:56mkunfamiliar with watchers
15:56mkare they just listeners?
15:57uvtctmciver, thanks for the feedback. Will change to use the readme as the main doc landing page.
15:57uvtcthanks, dakrone, for the offline help
15:57nDuff...hrm; putting (#(map str %)) halfway through a long -> pipeline is kinda' icky.
15:58Vinzentmk, yeah
15:59mkdo watchers operate on state value?
15:59VinzentnDuff, you can use (-> a (->> (map f))) instead
15:59Vinzentmk, what do you mean?
15:59mk(I'm trying to look up docs on watchers)
15:59nDuffVinzent: ...ahh; much nicer. Thanks!
16:00tmciveruvtc: sure. I'm not saying a doc dir isn't a good idea, but maybe you could fallback to the README when the doc dir is missing.
16:00mkVinzent: err, maybe explaining another problem will help
16:00uvtctmciver: ✓
16:00mksuppose you have two positions marked by pipes: ab|c|de, in the string "abcde"
16:01mkI now delete bcd, leaving (presumably) a||e
16:01mkthe problem is that if I want to undo the change, I can't simply operate on the string atom
16:02mkI have to alter the two position atoms - but in different ways
16:02VinzentnDuff, I've peeped it in the kotka.de blog :)
16:02mktheir values are presently identical, so I have to somehow keep track of their previous states. If I inject bcd back into the middle of ae, I want neither a||bcde nor abcd||e
16:03Vinzentmk, just keeping log of operations is a no way?
16:04mkwell, it would be complicated because I would have to keep a log of "position movement" operations, and I'd like the "string atom" manipulation to be ignorant of what happens to the positions
16:05mka log of deltas is simple enough for the string itself: delete 1 to 4 (inverse is: insert bcd at 1)
16:07mkgiving each position a similar history seems incorrect
16:07Vinzenthm, why not save the cursor and mark positions too?
16:07mk(I'm unsure if I'm explaining this clearly)
16:08mkVinzent: what do you mean?
16:08VinzentI mean in the string's log
16:08Vinzentdelete 1 to 4, cursor was at 2
16:10Vinzentby the way, are you writing an emacs clone in clojure or what? :)
16:10mkthere might be a multitude of cursors/carets/positions (regex find, for example), and it seems strange to mix the two histories
16:11mkVinzent: something like that. Mostly just playing around with understanding how identity works in various cases. I'm a fan of how clojure distinguishes values and identities, but certain things become much more complicated
16:12winkhm, what's the most idiomatic way to put let/if-let/when-let into each other? one outer let and if inside, or try with some if-let...
16:13VinzentI probably don't understand then... By what rule you want to determine the cursor position after an undo? I thought cursor position should be restored to whatever it was before deletion and mark should stay the same
16:13ohpauleezwink: can you use `and`?
16:13mkVinzent: define mark?
16:14Vinzentthat thing which got swapped with cursor position when you're hitting C-x C-x
16:14winkohpauleez: there's one "or" right now
16:15kovasbunless the strings are huge, why store the edit histories rather than the old strings themselves
16:16ohpauleezwink: can you paste/gist an example? More than happy to help
16:16mkVinzent: well, the point and mark (if I have my terms right) would probably be aPbcdMe, and the operation deletes everything between point and mark. There are also two positions or cursors between the point and mark: ab|c|de
16:17ohpauleezkovasb: - are you coming tonight? I was digging through session the other night and I wanted to pick your brain about an idea
16:17kovasbyup! will b there
16:17ohpauleezAwesome
16:17kovasbsounds good. apologies for the ugly source
16:17kovasb;)
16:18ohpauleezhaha, no worries, I made it through. Also, Shoreleave is a train wreck to read right now
16:18kovasblol
16:18winkohpauleez: https://www.refheap.com/paste/3263
16:18mkif I don't have to worry about positions, I think that I can handle things easily - I mark each insert operation as either before or after the cursor (this corresponds to backspace vs delete)
16:19kovasbsometimes you just gotta write one to throw away
16:19winkI mean, I can get it to work with almost every combo, but how it is nice and short? :)
16:19ohpauleezwink: I got this, hang on
16:19mk(undoing a delete inserts the characters after the cursor, undoing a backspace, before)
16:21mkthis might be making things a bit more concrete - the general problem is how state changes work when some identities (atoms) depend on others
16:21kovasbyes, that is a big problem
16:22kovasb"top people are working on it"
16:22kovasbhttp://www.youtube.com/watch?v=q6-rQ6Jay6w
16:23ohpauleezwink: https://www.refheap.com/paste/3265
16:23ohpauleezone line
16:23Vinzentmk, oh, so it's like registers, got it (wrongly interpreted the term "cursor").
16:23winkohpauleez: oh, thanks
16:23ohpauleeznp!
16:24winkclever use of -> I must say.
16:24ohpauleezwink: Maps and keywords rock
16:24winkhappy enough to not wonder wtf is going on :)
16:25ohpauleezwink: You could also just drop the let completely
16:25Vinzentmk, I think you can have one one Buffer record with fields :text, :point, :mark, :registers in an atom and some protocol for operations, so you could define delete, backspase, killing region, etc
16:26bigbob38hi all. I'm trying to use xuggle from clojure, and basically wanted to port this: http://goo.gl/evyZw so far I've nly come up with this monstrosity of a function, which is basically a line-for-line translation from java: https://gist.github.com/2961994
16:26bigbob38anyone have any tips as to how I might start refacoring this? I'm kind of new at java interop
16:27pipelinei'm no pro at interop either
16:27pipelinebut
16:27pipelinethe function you wrote has a lot of side effects anyway
16:27pipelineand is calling into java code that is effectively imperative
16:27pipelinei don't know that there necessarily exists an elegant way to do this
16:28mkVinzent: perhaps, but I'm not sure how that would... work
16:28bigbob38ok that makes me feel a little better at least, that I'm not missing something major
16:28Vinzentalso, I'm not sure now why to worry about registers at all... You can just check if register's position are greater than the buffer length's and jump to max position then. Does it makes sense?
16:29Vinzentmk, hey, what about collaborating on this idea?
16:30mkVinzent: perhaps I misunderstand registers then. Perhaps thinking of them as footnote positions, or comment positions, etc.?
16:30mkVinzent: aren't we already? :)
16:31notbrentguys: what book would you recommend for a clojure beginner coming from a ruby/js background?
16:31notbrentor gals ;)
16:32bigbob38joy of clojure is pretty good
16:32cgagclojure programming is solid
16:32mhansonI'm reading Joy of Clojure right now, and it's fantastic so far.
16:32Vinzentbigbob38, first thought: you can write (if x ...) instead of (if (not (nil? x)) ...)
16:32notbrenttwo votes for joy of clojure!
16:32mkI've heard good things about that newer book
16:32mhansonI'm a Rubyist mostly, with little Lisp experience.
16:32ohpauleezJoy of Clojure is one of my favorite books
16:32ohpauleezto date
16:33notbrenthas anyone read russ olson's ruby books, eg eloquent ruby, and enjoyed them?
16:33mkI've forgotten the name now - clojure programming? I've heard it was better than JoC
16:33notbrentthose were my favorite rubybooks
16:34Vinzentmk, yeah, probably something like that... By "collaborating" I meant creating a github project, etc :)
16:34mknotbrent: you might consider searching the channel logs
16:34cgagI really like it, and i think it'd be more helpful for someone without much lisp experience
16:34notbrentmk: good idea
16:34ohpauleezmk, Joy of Clojure is definitely targeted at readers who are already familiar with Clojure and are settling in
16:34ohpauleezit answers a lot of "when" and "why" not "what"
16:35ohpauleezwhy is X in the language, and when should I use it over something else
16:35Wild_Catso JoC is more about the ecosystem and best practices than about the language itself?
16:35mkVinzent: oh, I have nothing that concrete at the moment :) though I wouldn't mind
16:36ohpauleezWild_Cat: I would say it very much covers the language, but it's not a guide to learn a lisp or help you bend your brain into functional programming approaches
16:36ohpauleezAlso, reading the ClojureScript source is an awesome way to gain a lot of Clojure knowledge
16:36bigbob38Vinzent: thanks! missed that, I copied that part right from stackoverflow heh
16:37ohpauleezAnd as stated a few days ago. Reading the Ring source is amazing
16:38mhansonI'm reading SICP at the same time I'm reading JoC to help fill in my missing functional/Lisp knowledge.
16:38ohpauleezmhanson: That's a great idea and approach
16:38ohpauleezfollow that up with a read of On Lisp and you'll be a pro
16:38mkthe state-changing problem I'm talking about is pretty generic. It also applies to alterations to a program. The repl often replaces functions, and it would be interesting to see how undo (especially partial undo) works there
16:39dgrnbrghello clojurians, i am seeing some really weird behavior in my clojure environment. I am launching clojure with a complex proprietary jvm runner, and somehow clojure.core/int is broken. I get (= java.lang.Long (class (int 3))), whereas in normal clojure environments (int 3) should return a java.lang.Integer
16:40mk,(class (int 3))
16:40clojurebotjava.lang.Integer
16:40Vinzentmk, actually, I just want to write an org-mode like todo-manager, but hadn't have enough courage to start :) Do you have jabber or something?
16:40Vinzentdgrnbrg, it depends on the clojure version afaik
16:41mkdgrnbrg: perhaps the runner replaces all ints with longs?
16:41Vinzentdgrnbrg, it gives me long too on 1.3
16:41dgrnbrgi'm using 1.3
16:41borkdude,(class (int 3))
16:41clojurebotjava.lang.Integer
16:41borkdude&(class (int 3))
16:41lazybot⇒ java.lang.Integer
16:41Vinzent,*clojure-version*
16:41dgrnbrg,(identity *clojure-version*)
16:41clojurebot{:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"}
16:41clojurebot{:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"}
16:41borkdude&(clojure-version)
16:41lazybot⇒ "1.4.0"
16:42dgrnbrghmm
16:42dgrnbrgwell, that doesn't help much, heh
16:42borkdudeon 1.3 it gives me long as well
16:42dgrnbrgif (int 3) gives a long, how can I coerce to an int?
16:43dgrnbrgmaybe I should try upgrading to 1.4
16:43Vinzentthat's exactly what I wanted to say :)
16:43mkVinzent: start a project on github and I'll follow, but I can't tell if I can much time (for even my own projects)
16:43dgrnbrghow can I exclude clojure 1.3 from every plugin ni my dependencies?
16:44dgrnbrgi have 20-30 plugins, and i don't know who is pulling me back to 1.3
16:44ohpauleezdgrnbrg: [vimclojure/server "2.3.3" :exclusions [org.clojure/clojure]]
16:44ohpauleezusing exclusions, but if your project depends on 1.4, it'll use 1.4
16:44dgrnbrgi have [org.clojure/clojure "1.4.0"] as the first dependency
16:44dgrnbrgbut it seems to be using 1.3 anyway
16:45ohpauleezbizzaro
16:45dgrnbrgi have to integrate w/ a lot of legacy code
16:45dgrnbrgwhich is actually kind of awesome that things work at all
16:45ystaelif (class (int 3)) is java.lang.Long in 1.3, does that necessarily mean that the result of (int 3) is a native long, or merely that the result of (int 3) boxes to a Long?
16:47llasramystael: My understanding is the latter. `int` calls RT.intCast, which returns an int. That int then just get boxed to a Long
16:47raekystael: the latter
16:48llasramdgrnbrg: Do you need an int or an Integer? If you need the former, you can always construct it explicitly
16:48dgrnbrgllasram: i need Integer--I'll give that a shot
16:48dgrnbrgyou mean like Integer/valueOf?
16:49cemerickYou should *always* construct an Integer if you actually want an integer.
16:49dgrnbrgcemerick: why does (int) exist then?
16:49aperiodicjava interop?
16:50cemerickyeah, it's a coercion operator
16:50cemerick(int …), (long …), et al. should be reserved for interop
16:50dgrnbrgi am doing interop, though
16:50dgrnbrgi thought
16:50dgrnbrgdoes clojure not use java's boxing rules?
16:50dgrnbrgi.e. short int long all box to Long?
16:51cemerickdgrnbrg: in 1.3, yes; that was fixed in 1.4 IIRC
16:51llasramdgrnbrg: Right, exactly (re: Integer/valueOf)
16:51dgrnbrggot it, thanks
16:51ystaeldgrnbrg: lein deps :tree is handy for debugging dependency mysteries
16:51dgrnbrgif only i was just using leiningen
16:52dgrnbrgi have modified eval-in-subprocess to do…special things to play nicely in my environment
16:53dgrnbrgand lein deps doesn't work for me either
16:53Vinzentmk, well I don't have any code\time yet too - I just wish to discuss design problems such as the one you've raised. About functions: I have no idea how it's implemented in emacs, but the first thing coming to mind is to intercept redefenitions and just save previous versions in the var's meta
16:53dgrnbrgso i use a 2ndary project to create an uberjar, then i use a lein plugin i wrote to mix that uberjar into my proprietary blend
16:59mkVinzent: that might work, though it might get messy if... suppose you want an "area" revert/undo, where only the changes to the function/paragraph are undone, as well as a global, as well as snapshot saving (and "area" snapshots)
17:00mkI think these things are rather complicated at the moment for me, but very interesting
17:01mkI've also been thinking of "revision levels" in programs - how certain parts of a program are locked down, and how this lockdown is the only thing that distinguishes source from program from data
17:03mkin most languages, the only thing you can alter is the data that the program works with, and there are various methods of revision (assignment, instantiation)
17:03Vinzentmk, if I understand correctly, the area undo would work the same: you just need to compute what functions are affected by changes in that area
17:05mkbut some languages (clojure, languages with an eval) give the programmer methods of revising the data of the program itself
17:07mkVinzent: right (areas are just... ranges, or substrings, in this case) but this is potentially problematic if areas overlap (as when merge conflicts occur). I suppose with clearly-defined "areas" like functions, this might be less of a problem...
17:08brehauteval is ussually not the tool you are looking for
17:08Vinzentyeah, and not all languages with eval support this kind of dynamism in the development process (like slime does)
17:08brehautpartial application is a better tool for generating new functions at runtime
17:09Vinzentmk, hmm, how could they overlap? Undos\revers are sequential, no?
17:09Vinzentbrehaut, I think he's rather talking about development process
17:10mkbrehaut: right. But the interesting thing is that eval is basically a compiler, so even taking into account the fact that the way a program edits itself and the way a human edits a program should be different, perhaps that says something about compilers and source code. Also, the repl is essentially an eval, no?
17:10brehautits not basically a compile. it is a compile
17:11brehautand only the 'e' of repl is an eval
17:12mkbrehaut: yes, but the r, p, and l might as well be silent
17:13brehauterr
17:15mkVinzent: usually they are sequential, but if I edit a first paragraph, then the second, then merge paragraphs, then perform a few edits, and then I want to undo the first edit... then it's complicated. I think someone was working on this - right, the "patch theory" for darcs. http://www.math.ucla.edu/~jjacobson/patch-theory/
17:16mkbrehaut: there's nothing substantial when it comes to "read" and "print" - I guess they indicate where the input comes from and where the output goes
17:19mkVinzent: I think the solution to the original problem might actually be to just track a history of changes. I think that the "elegant" alternative that I suspected existed is just to replay the whole edit history from revision 0
17:21Vinzentmk, by the way, reading and printing are substantial - lisp's eval works with datastructures, not with raw text
17:22uvtcOk, a project's README.md is now its landing page at http://www.unexpected-vortices.com/temp/clojure-libs-doc/index.html . However, I don't see any use in having docs there for a project with only a readme, since you could just see the readme at github for that.
17:23uvtctechnomancy, ^^ (wait TeXnomancy?)
17:23TeXnomancyhehe
17:23uvtcThere is a TeXpert in the house.
17:23TeXnomancymy bouncer is acting up, so I'm shadowing myself
17:24mkVinzent: right, the implementation, yes
17:24TeXnomancyI am actually not that good at TeX
17:24brehautI think the secret to TeX is just rerunning the latex command over an unchanged document until it looks like what you expect
17:24uvtcThe first thing a trained TeXpert is conditioned to say is that they're not very good at TeX --- otherwise everyone asks them to help them with "just one minor thing"...
17:25TeXnomancyI did my clojurewest presentation in latex but I probably won't do it again
17:25TeXnomancyearned that nerd merit badge, moving on
17:25brehautTeXnomancy: next up: write it all in factor
17:26TeXnomancybrehaut: my conj one was elisp
17:26brehautthat wins.
17:26uvtcTeXnomancy : after discussing Clojure lib docs yesterday, this is what I came up with: http://www.unexpected-vortices.com/temp/clojure-libs-doc/index.html .
17:27TeXnomancyuvtc: looks like a great start
17:27uvtcNeeds more projects with docs so that they can be included though.
17:27TeXnomancysubmitting pull requests to get your project added to that list would be a cool way to go
17:27TeXnomancyuvtc: Leiningen's got a pile of doc/*.md files
17:28uvtcTeXnomancy, leiningen added!
17:29TeXnomancycool
17:30solussd_can protocol functions be optional? afaict I can neglect to implement some of a protocol
17:30dabdi am using clojure jack in to start swank server. If I add a dependency to project.clj is there a way to avoid having to restart REPL after running lein deps?
17:31TeXnomancyuvtc: any further plans before you announce it?
17:31TeXnomancydabd: nothing yet unfortunately
17:32uvtcI wanted to show it off here before asking about hosting on clojuredocs.org.
17:32TeXnomancyuvtc: maybe a table of contents as a sidebar?
17:32TeXnomancyinstead of having to hit up "all of this lib's docs"
17:33uvtcTeXnomancy, also, it would be nice to get some more projects listed.
17:33TeXnomancyand I'm not sure about the word "lib", it's a bit loaded. "project" is probably better?
17:33TeXnomancyand maybe the link text in the toc should be the first h1 in the md file
17:34TeXnomancyguess I need to switch from ```clj to ```clojure
17:35uvtcTeXnomancy, thanks for the feedback. I need to go right now, but will get back to this.
17:35TeXnomancyexcited to finally see a documentation effort designed to unify rather than start their own thing
17:50dabdI added [incanter "1.3.0" :exclusions [swank-clojure]] to my dependencies but got the following error: Could not find artifact org.mongodb:mongo-java-driver:pom:2.6.5 in clojars (https://clojars.org/repo/)
17:50dabdFailed to collect dependencies for clojure.lang.LazySeq@2af2b9aa
17:50dabdIs 1.3.0 the correct version for incanter?
17:55ezyangHow does Clojure find out about Java classes which it needs to create new classes of?
17:56ezyang(via it's compilation process in clojure.lang.Compiler)
17:59KirinDaveIs slingshot… supposed to work?
17:59KirinDaveAs according to its readme?
17:59KirinDaveBecuase throw+ works, but catch+ seems to be failing to catch...
18:00hiredman(try+ is what you want, is there a catch+?
18:01mebaran151I don't think it uses catch+; it just rewrites catch clauses
18:01KirinDaveSorry
18:01mebaran151a catch inside try catch is just magically enabled to be smarter
18:01KirinDaveyeah
18:02KirinDave(try+ … (catch [:type :ramuh.data.job/invalid-input] …)) never catches
18:02KirinDaveHowever if I catch all exceptions and print it out, it shows: clojure.lang.ExceptionInfo: throw+: [:type :ramuh.data.job/invalid-input ...]
18:03KirinDaveSo clearly throw+ is doing its job. I am just failing to catch.
18:04raekKirinDave: are you re-throw+-ing the exception in the catch body?
18:04KirinDaveNo.
18:05KirinDaveI want to handle it.
18:05dakroneKirinDave: (catch [:type :foo] ...) would catch something like (throw+ {:type :foo}), are you throwing a map or a vector?
18:05raekand the thing you throw looks like {:type :ramuh.data.job/invalid-input, ...}, right?
18:05KirinDaveAh, in one case I accidentally throw a vector becuase the object I throw is constructed over the run.
18:06KirinDaveWasn't (into {} my-constructed-thing) in one path
18:06raek(I had this problem recently: https://github.com/scgilardi/slingshot/issues/25)
18:06KirinDaveThat's lame
18:06KirinDaveWhy can I throw a vector?
18:06KirinDaveAnd then render it uncatchable?
18:06TeXnomancyKirinDave: "it's more general"?
18:06dakroneKirinDave: because you could do (catch vector? v ...)
18:06KirinDaveYeah but if you cannot catch it...
18:06hiredmanit is actually still catchable
18:06KirinDaveOh
18:06TeXnomancyyou can still catch it; catch can be given an arbitrary predicate
18:06KirinDaveInteresting.
18:06KirinDaveNot sure I agree with the idea, but interesting.
18:07KirinDaveIf we're going to give up on Common Lisp error handling (i.e., the awesome way), then it seems weird to try and fancy it up.
18:07TeXnomancyI'm not sure how awesome the awesome way is if you don't have everyone on board.
18:08ohpauleezit's still pretty f'in awesome
18:08ohpauleezhaha
18:08ohpauleezBut you can't get correct interop
18:08KirinDaveYeah
18:08ohpauleezwhich is a total shame
18:08KirinDaveThat it won't work right with interop isn't necessarily a reason to ditch it.
18:08KirinDaveIt's not not a reason, I guess. :)
18:09KirinDaveTeXnomancy: So I made good on what I said. We're entirely phasing out Scala now.
18:09TeXnomancymwahaha
18:09KirinDaveNo one besides me could code with it anyways...
18:09TeXnomancyI guess that probably made the decision easier =)
18:09KirinDaveYeah well there is a new super-smart kid from MIT here
18:10KirinDaveand he was like, "Lisp? We could code in Lisp? Okay yea i am on board."
18:10KirinDaveThen proceeded to stay up for 2 days straight bootstrapping some stuff into Storm.
18:10TeXnomancyhaha; go MIT
18:10KirinDaveThen I pretended to be all upset while winking heavily and sighed to my team and said, "I guess we'll go with this. Shame to the enthusiasm of youth."
18:10KirinDaveAnd no one could bitch at me for trying another language pivot on the shop.
18:11TeXnomancystrategic.
18:11KirinDaveStrategery
18:11KirinDaveYeah well sometimes to make a good thing tasty one must consider the source.
18:14TeXnomancyKirinDave: is your pipeline by any chance final-fantasy-themed?
18:15KirinDaveTeXnomancy: It is actually a rule.
18:15KirinDaveTeXnomancy: Fenix, Ramuh, Alexandr are already in use.
18:15KirinDaveWhyt too
18:15KirinDaveThe only NON-FF-summons component is a project that was a one-off that grew into production, which is our storm topology repo bergenholm.
18:16KirinDaveTeXnomancy: It's how we differentiate Clojure services from non-Clojure services; no one else but us can spell them.
18:17TeXnomancyI would like to draw your attention to https://github.com/technomancy/lein-play and the fact that you can make the final fantasy victory fanfare play when the tests succeed; that is all.
18:17KirinDaveAmazing
18:17KirinDaveI can do this.
18:17KirinDaveLein2 compatible?
18:18TeXnomancyI think you should be good if you use :plugins rather than :dev-dependencies
18:18TeXnomancyif not let me know; I can make it happen
18:18KirinDaveOkay
18:18KirinDaveI actually have a really nice orchestratic version
18:20KirinDaveTeXnomancy: Gotta be mp3?
18:21TeXnomancyKirinDave: looks like that's the only thing this lib supports. probably wouldn't be hard to find another audio engine.
18:27dabdwhere did 'positions' from clojure.contrib.seq go in 1.4.0?
18:28muhooTeXnomancy: moved to the lone star state, have ya?
18:28KirinDaveTeXnomancy: Can't get it to fly, lein1 or lein2
18:28KirinDaveOh well
18:29TeXnomancyKirinDave: can you open an issue so I'll remember to get back to it?
18:29KirinDaveTeXnomancy: Sure. Maybe it's just classpath woes
18:29KirinDave"Put X on your classpath" is sort of like saying, "Please feel free to argue with the jvm for 20 minutes."
18:30TeXnomancyoh yeah, this was from back when lein and the project had their classpaths overlap
18:30TeXnomancyand probably the fact that lein-play is added to lein's classpath dynamically confuses it
18:33muhoocemerick: what should :login-failure-handler return? a ring response?
18:33mebaran151dabd: how about (fn [pred s] (map second (filter (comp pred first) (map vector s (range))))) for the same functionality?
18:35muhoocemerick: because, in openid/handle-return, if login-failure-handler returns a ring map, then workflow will consider that success and pass it up to authenticate* as an auth map
19:17brainproxysuppose I want to dynamically create a File that, say, enlive will think is a proper file an fill it with, say, the return of (hiccup/html ...)
19:17brainproxyis (as-file ...) a good place to start
19:17brainproxy?
19:22antoineBhello i would like to take the last digit of a number?
19:23antoineB,(last (str 123))
19:23clojurebot\3
19:24brehaut,(mod 123 10)
19:24clojurebot3
19:25brehautor, if you wish to have it as a char
19:25brehaut,(char (+ (mod 1234 10) (int \0)))
19:25clojurebot\4
19:26antoineBi just want to check that last digit of two number are different
19:26brehautantoineB: using last will cause a seq over your string to be created and then walked in its entirity.
19:26brehaut,(not= (mod 1234 10) (mod 1235 10))
19:26clojurebottrue
19:28brehautor, if you abhore the repeatition
19:28brehaut,(apply not= (map #(mod % 10) [1234 2345]))
19:28clojurebottrue
19:28antoineBok
19:38wmealingI'm having a problem with java interop, not being a java programmer makes it somewhat harder, i'm wondering if someone could take a look at https://github.com/wmealing/soundlevel/blob/master/src/soundlevel/core.clj and tell me why i'm failing.
19:38wmealingI think its in mixer-supports-recording
19:41xeqi&(.getClass String)
19:41lazybot⇒ java.lang.Class
19:41xeqiwmealing: TargetDataLine is already a class (line 8)
19:41wmealingok, so (Line$Info. TargetDataLine))
19:42wmealingsmooth ok
19:42wmealingso now i have some mixers that can record
19:43wmealingwhich is.. more what i expected
19:43wmealingthankyou.
19:45OwenOuhi guys, i would love to read clojure's source code, but not sure where to start, could anyone give me a pointer?
19:45OwenOuappreciate any suggestions :)
19:46S11001001core.clj
19:46S11001001it is the standard lib, the part written in clojure anyhow
19:46brehauthttps://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj
19:47brehautOwenOu: the easiest way to get started is with the 'source' function in your repl
19:47S11001001from there, you'll see many references to the java bits; take a look at those references as they interest you
19:47brehaut,(source source)
19:47clojurebotSource not found
19:47S11001001does source include comments?
19:47TeXnomancydon't look too closely at the java though
19:47brehautok so the bot hates it
19:48xeqi&(clojure.repl/source source)
19:48lazybot⇒ Source not found nil
19:48OwenOubrehaut: thanks, but what would u recommend the starting point on the java side?
19:48brehautS11001001: does the orriginal code include sources :P
19:48brehauterr comments
19:48OwenOui guess my question is i would love to know how the language is implemented on top of macro
19:48brehautif you havent dived into the clojure side yet, you probably arent ready for the java side
19:49S11001001yep, and something of a narrative in its ordering too
19:49brehautOwenOu: form is read by the read -> (macro expansion * repeat as necessary) -> compiler
19:50S11001001like, there are multiple impls of some bits, as more stuff gets bootstrapped
19:50brehautS11001001: i think its better to get started with functions you know in isolation
19:50brehautstarting at the top of core.clj and working your way down is diving into the very deep end
19:51brehautOwenOu: you'll probably find it more enlightening to play around with macroexpand and macroexpand-1 in a repl than by diving deep into the compiler
19:52S11001001start at bottom then
19:52S11001001into is down there I think
19:52OwenOubrehaut: i see, thanks for the recommendation, i would also be interested to know how the expanded macros are compiled to bytecodes
19:53brehautS11001001: so why not just start with source?
19:53brehautS11001001: frinstance, heres the sole comment before destructure ";redefine let and loop with destructuring"
19:53S11001001it's still a narrative to start at bottom
19:53S11001001yeah, that's neat
19:53brehautfollowed by 60 lines of uncommented code
19:54S11001001just the sort of interesting bits that vanish with tools
19:54brehautS11001001: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L3905-3965
19:54brehautwhat interesting bit vanishes with tools there?
19:54S11001001that very comment
19:55brehautthat comment gives you basiclly no information about how destructure works
19:55S11001001you referenced a comment that, in itself, is a perfect demonstration of the value of perusing core.clj directly
19:55S11001001it refers to "redefine"
19:55S11001001well, what is that?
19:55S11001001it's intriguing to first encounter
19:55brehautnowhere in destructure does let get redefined
19:56S11001001why is that relevant?
19:57S11001001it's the comment that hints at something deeper, not the code, in this instance
19:57brehautbecause thats all the comment says. if you are a newb, wanting to get started reading the source, it doesnt matter that destructure is used later. of course its used later. you want to understand one function at a time, and that comment is not at all elucidating about destructure
19:57BrianGhi
19:58S11001001yes, and as a clojure newbie, I would have preferred not to be so boxed in, one function at a time
20:03antoineBhow to make an integer divide?
20:04antoineBok it is quot
20:05gfredericks$findfn 7 4 1
20:05lazybot[clojure.core/quot clojure.core/unchecked-divide-int clojure.core/compare]
20:06TeXnomancyheh, compare
20:07gfredericks$findfn 7 4 7/4
20:07lazybot[clojure.core//]
20:07S11001001how many functions does that try?
20:08gfredericks7/4 functions
20:09TimMcS11001001: It's great for finding weird things like...
20:09TimMc$findfn + 3 4 7
20:09lazybot[clojure.core/trampoline]
20:09TimMcI like that trampoline can be used as an almost-synonym for the nonexistent "call" fn.
20:09amalloyS11001001: all of clojure.core, clojure.string, clojure.set, and maybe one other
20:10amalloy$findfn * 3 3
20:10lazybot[clojure.core/max-key clojure.core/cond clojure.core/dosync clojure.core/sync clojure.core/char-escape-string clojure.core/*data-readers* clojure.core/deliver clojure.core/with-loading-context clojure.core/default-data-readers clojure.core/*clojure-version* cloj... https://www.refheap.com/paste/3267
20:10amalloyhuh. some of those make little sense. i was expecting deliver
20:11TimMcit's there
20:11TimMc&(doc sync)
20:11lazybot⇒ "Macro ([flags-ignored-for-now & body]); transaction-flags => TBD, pass nil for now Runs the exprs (in an implicit do) in a transaction that encompasses exprs and any nested calls. Starts a transaction if none is already running on this thread. Any uncaught exce... https://www.refheap.com/paste/3268
20:12S11001001IIRC it implements dosync, which is thin sugar
20:13TimMcHrm, OK...
20:13TimMcIndeed.
20:19y3diall you need is love... xD
20:33TeXnomancygfredericks: it's under the "If your name is Rich [...]" section
20:34gfredericksTeXnomancy: some statements are equally plausible when interpreted seriously or jokingly
20:34gfredericksah found it
20:34gfrederickshttps://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L311
20:35gfredericksfaxinating
21:05brooksbphello
21:05brooksbpnew to clojure
21:05brooksbphow do I go about debugging this:
21:05brooksbpUnsupportedOperationException nth not supported on this type: Character clojure.lang.RT.nthFrom (RT.java:835)
21:08tmciverbrooksbp: could you post the offending code to refheap.com?
21:08zomgbrooksbp: based on the message I would say that you are attempting to use nth on a type which is not a list or such
21:08S11001001brooksbp: runtime or while loading
21:08brooksbpS11001001, runtime
21:09S11001001Look up the stack until your own code
21:09brooksbpCalling a function which calls a ton of other code, so no idea where it may be
21:09brooksbpI am not calling nth
21:09brooksbpBut I am trying to do destructuring on a string... can't you do that?
21:10brooksbpRight, I was hoping for some way to step through the code. Is that possible?
21:10S11001001a little, but it's probably overkill. Just look for your code on the stack
21:10S11001001then you'll know what you called that eventually bombed
21:11brooksbpthere's no call stack
21:11brooksbpI mean, it wont print one
21:11hiredman,(let [[[foo]] "foo"] )
21:11clojurebot#<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: Character>
21:12brooksbpI apply the function to an arg in the repl, and that exception message prints
21:12hiredman,(let [[foo] "foo"] foo)
21:12clojurebot\f
21:16S11001001brooksbp: use jack-in, or (try blah (catch Exception ex (.printStackTrace ex)))
21:17S11001001maybe there is a shortcut for normal repl
21:18amalloy(.printStackTrace *e)
21:19gfredericks(pst), no?
21:22brooksbp(defn- myfun [arg1 [first-char & xs :as arg2]] ...func body...)
21:23brooksbp(myfun 1 "mystring")
21:23brooksbphow do you destructure the second arg?
21:23S11001001gfredericks: slimer for life :)
21:23gfredericksI don't think you can do that directly with strings
21:23gfredericksor sets
21:24gfredericks,((fn [[a b]] [b a]) #{4 5})
21:24clojurebot#<UnsupportedOperationException java.lang.UnsupportedOperationException: nth not supported on this type: PersistentHashSet>
21:24gfredericks,((fn [[a b]] [b a]) "ha")
21:24clojurebot[\a \h]
21:24gfredericksoh works with strings
21:24gfredericksbrooksbp: okay so what's your issue?
21:25gfredericksyou say "how do you destructure the second arg?" but you appear to already be doing that
21:25brooksbpI am getting an exception when invoking that func... I must be passing it gibberish
21:25brooksbpThought I was destructuring improperly
21:26gfredericks,((fn [arg1 [first-char & xs :as arg2]] [arg1 first-char xs arg2]) :foo "bars")
21:26clojurebot[:foo \b (\a \r \s) "bars"]
21:33brooksbpIs it possible to use reduce with a line-seq?
21:33brooksbp(reduce fn [] (line-seq rdr))
21:33brooksbpI want to reduce fn over every line... but line-seq doesn't return a collection..? How to do..?
21:35S11001001Just try
21:35gfredericksline-seq doesn't return a collection?
21:35S11001001reduce, map, et al all take seqs, not just colls
21:36S11001001,(coll? (map identity '(42)))
21:36clojurebottrue
21:36S11001001ugh
21:36S11001001well whichever, it'll work
21:36gfredericks,(->> 943 range (map inc) coll?)
21:36clojurebottrue
21:36gfredericks,(doc coll?)
21:36clojurebot"([x]); Returns true if x implements IPersistentCollection"
21:37gfredericks,(coll? "coll?")
21:37clojurebotfalse
21:37gfredericksoh I guess that was obvious
21:37S11001001,(reduce + 0 (map long "hi there")) ;hmm...
21:37clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Character cannot be cast to java.lang.Number>
21:37brooksbpok... I must paste the code... I am trying, but...
21:38S11001001pick a fun
21:38brooksbphttps://www.refheap.com/paste/3270
21:38brooksbpI am calling parse-file
21:39brooksbpand the exception hits when invoking build-ir
21:39S11001001you should also paste full backtrace
21:39brooksbpoops... the vector brackets around (strip-line (line-seq rdr)) are not suppose to be there
21:39S11001001and, use map, you are giving seq to string function
21:40brooksbp(map strip-line (line-seq rdr)) ?
21:40brooksbpwhy map?
21:41S11001001you want the long answer or really long answer? ;)
21:41brooksbpreally long answer
21:43S11001001okay, what is strip-line?
21:43S11001001that is, what kind of arg does it take, and what does it return?
21:43brooksbpa function: string -> string
21:43S11001001okay, what does line-seq return?
21:44S11001001wait, are you haskellian?
21:44brooksbpenough to know about currying
21:44S11001001ok, let's continue
21:44S11001001line-seq is?
21:44brooksbpmy issue is that i dont understand seqs
21:44brooksbpi dont know what line-seq is
21:44brooksbplooking up..
21:44S11001001let's pretend they are lists
21:45S11001001line-seq is stream -> seq string
21:45S11001001a seq of strings
21:45brooksbpok so map is appropriate
21:45S11001001aye
21:45brooksbpbut why doesn't the reduce work?
21:46brooksbpeven if i do: (reduce build-ir [] (map strip-line (line-seq rdr)))
21:47brooksbpfails with an airity exception to build-ir
21:47brooksbp(defn- build-ir [ir [first-char & xs :as line]]
21:47brooksbpas far as i can tell, reduce passes build-ir 2 args... build-ir takes 2 args... second one is destructured
21:48S11001001paste trace?
21:48brooksbpdoh.. wrong function
21:48wkellybrooksbp: your build-ir works fine for me
21:48wkellyoh, too late
21:50S11001001good luck
21:52brooksbpback again
21:52brooksbpis there a better way to do this: https://www.refheap.com/paste/3271
21:54brehautbrooksbp: what is ir, and what is it supposed to be doing?
21:55gfredericksspanish verb meaning "to go"
21:55brooksbpir is a vector of maps
21:55brooksbpI want to pop off a map, conj to it... then put it back in the vector
21:56gfredericks,(assoc-in [{} {} {} {} {} {}] [3 :foo :bar] :baz)
21:56wkellybrooksbp: assoc-in
21:56clojurebot[{} {} {} {:foo {:bar :baz}} {} ...]
21:56brooksbp[{:a 1 :b 2} {:c 3}] -> {:d 4} ===> [{:a 1 :b 2} {:c 3 :d 4}]
21:58gfredericks,(let [ms [{:a 1 :b 2} {:c 3}]] (update-in m [1] merge {:d 4}))
21:58clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: m in this context, compiling:(NO_SOURCE_PATH:0)>
21:58gfredericks,(let [ms [{:a 1 :b 2} {:c 3}]] (update-in ms [1] merge {:d 4}))
21:58clojurebot[{:a 1, :b 2} {:d 4, :c 3}]
22:00gfredericks,(let [ms [{:a 1 :b 2} {:c 3}]] (-> ms pop (conj (-> ms peek (merge {:d 4})))))
22:00clojurebot[{:a 1, :b 2} {:d 4, :c 3}]
22:00brooksbpthis is difficult to understand
22:01gfredericksmore lets then
22:01gfredericks,(let [ms [{:a 1 :b 2} {:c 3}], new-last (merge (last ms) {:d 4})] (conj (pop ms) new-last))
22:01clojurebot[{:a 1, :b 2} {:d 4, :c 3}]
22:01brooksbpstill... just getting familiar with everything in the clojure cheat sheet
22:02gfrederickshmm
22:02gfredericksso pop will pull the last thing off a vector
22:02gfredericksconj will put something back on the end
22:02gfredericksthus the (conj (pop ms) new-last)
22:03brooksbpI get conj pop peek
22:03brooksbpbut update-in
22:03brooksbpand merge
22:03gfredericksoh we didn't even use that in the last iteration
22:03brooksbpand these other map fns
22:03gfredericksmerge isn't necessarily necessary; your requirements were a bit ambiguous
22:03gfredericksyou can use assoc instead of merge probably
22:06brooksbpyou have to specify a number as an index when you use update-in
22:06gfredericksright
22:06gfredericksso depending on what you have available that might be easy or hard
22:06brooksbpis there a way to do this, but always the last element in the vector?
22:06gfredericksyeah, use pop/peek/conj instead
22:06brooksbp:)
22:06gfredericksyou could define an update-last helper function
22:07gfredericks(defn update-last [v f & args] (-> v pop (conj (apply f (peek v) args))))
22:07brooksbpis there a reason to merge two maps instead of conj'ing them?
22:08gfredericks,(conj {:foo 4} {:bar 5})
22:08clojurebot{:bar 5, :foo 4}
22:08gfredericks,(conj {:foo 4 :faz 38} {:bar 5 :bing 498})
22:08clojurebot{:bar 5, :bing 498, :foo 4, :faz 38}
22:08gfredericksI am baffled
22:08brooksbp?
22:08brehautmerge is just a reduce of conj
22:08gfredericksI had no idea that worked
22:08brooksbpoh
22:08brooksbpI see what you mean
22:08brehautconj on maps gets a seq from the second map, which returns a seq of keypairs
22:09gfredericks,(conj {} [1 2])
22:09clojurebot{1 2}
22:09gfredericks,(conj {} [[1 2]])
22:09clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Vector arg to map conj must be a pair>
22:09brehautoh, my bad
22:09gfredericksthere must be a special case for maps as second arg
22:09brehautoh, it may be that its particular about wanting a MapEntry
22:10gfrederickswell a bare pair is accepted
22:10gfredericksalso a bear pear
22:10brehaut,(conj {} [(clojure.lang.MapEntry. :a 1)])
22:10brooksbp,(conj {}{})
22:10clojurebot{}
22:10clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Vector arg to map conj must be a pair>
22:10brooksbprace!
22:11brehaut,(conj {} [:a 1] [:b 2])
22:11clojurebot{:b 2, :a 1}
22:11brehauti would have thought i would have this down by now
22:12gfredericksmaps-as-second-arg is a special case; esplains everything
22:12brehautit does
22:12xeqi,(conj {:a 1} (seq {:b 2 :c 3}))
22:12clojurebot{:b 2, :c 3, :a 1}
22:12gfredericksbrooksbp: so apparently you can do it all sorts of ways
22:12gfredericksxeqi: stop wronging me!
22:13gfredericksokay maybe vectors are a special case
22:13xeqiheh, I was curious
22:13brehautxeqi: im boggled now
22:13gfredericksif a vector, assume it's a pair
22:13xeqi(class (seq {}))
22:13gfredericks,(conj {} [1 2 3])
22:13clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Vector arg to map conj must be a pair>
22:13gfredericks^ aHA
22:13xeqi,(class (seq {}))
22:13clojurebotnil
22:13gfredericks,(seq {})
22:13clojurebotnil
22:14xeqi,(class (seq {:a 1}))
22:14clojurebotclojure.lang.PersistentArrayMap$Seq
22:14xeqi,(class [[a 1]])
22:14clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: a in this context, compiling:(NO_SOURCE_PATH:0)>
22:14xeqi,(class [[:a 1]])
22:14clojurebotclojure.lang.PersistentVector
22:15brooksbp,(conj {} {:a 1} {:b 2})
22:15clojurebot{:b 2, :a 1}
22:17brooksbp,(conj {} '(1,2))
22:17clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map$Entry>
22:33amalloybrehaut: the implementation/contract of (conj some-map anything) is horrible
22:34brehautamalloy: i have decided there's an unholy implicit union type in there
22:34amalloyi say it this way because the implementation accident in APersistentMap has become a contract in IPersistentMap merely by being in the wrong place at the wrong time
22:35amalloyand now everyone has to implement that horrible implicit union in exactly the same awful way or else they don't work the way people expect
22:36brehautright
22:48gfrederickspeople who know what an implicit union is are smarter than me
22:49gfredericksbut not taller
22:49gfredericksexcept for technomancy
22:52TimMcgfredericks: Java has implicit union types: String|Null :-P
22:55adugfredericks: did you make a video recently?
22:55gfredericksadu: not on purpose
22:55aduoh ok
22:55gfredericksI mean I took a video on my phone of my son waddling around
22:56tmciveryeah, I think that's the one adu was talking about. :)
22:56gfredericksalso I _watched_ a video recently, which is a related activity
22:58trptcolingfredericks: your past 10 minutes here looks like most of my campfire conversations at work. i lol'ed.
23:01adugfredericks: good night, sorry for confusing you with someone else
23:05gfredericksadu: no trouble whatsoever