#clojure logs

2012-09-08

00:42basicsenseihi, I'm new to clojure and leiningen and counterclockwise, I am using eclipse+ccw and imported a github project, I'm failing to figure out how to export a .jar from a Leiningen project in eclipse, the ccw doc says to use classic Eclipse export as Jar wizard, but that seems to ignore project.clj settings(?) like :aot and :manifest
00:42basicsenseithis is the project: https://github.com/jonnay/Watership-Down and you may see the project.clj there
00:47basicsenseimy question is, how should I correctly export .jar if I'm using eclipse+ccw ?
00:48tomojany reason to use eclipse to export a jar instead of just running `lein uberjar`?
00:48basicsenseiokay, apparently I've stumbled upon something, loading the main .clj file in repl generated a bunch of classes inside the classes folder
00:49basicsenseitomoj, I wouldn't know where to run that
00:49basicsenseitomoj, that sounds like I need more stuff installed than eclipse+ccw ?
00:49tomojwell, leiningen
00:51basicsenseitomoj, there seems to be leiningen already existing in ccw
00:56SgeoSo you should be able to use it from there (not sure how convenient it is). Open a command prompt
01:01basicsenseiwindows command prompt? not repl?
01:03basicsenseiI could get lein.bat but this seems like doing it wrong, I mean, there must be a way to do it with eclipse+ccw considering that ccw has lein support(as I see it)
01:04tomojccw cannot support all the features of lein, so it makes sense to get lein.bat anyway
01:04tomojI don't know specifically about ccw's support of uberjar
01:05basicsenseirunning lein uberjar, what tomoj said, seems to work in that it creates a 'classes' folder in 'target' folder which means I don't have to load the main .clj in repl inside eclipse to do that; but should that also yield me a .jar ?
01:06tomojyes, it should put it in target
01:07basicsenseiit's nothing there (or anywhere else inside the project) except a bunch of .class files, I'm wondering if this is maybe how the project.clj intended it (no jar , only classes) maybe?
01:08Raynes$mail xeqi I'm not sure you caused it. Looks like a threadpool died and that causes very weird things to happen. Anyways, feel free to mess with it tomorrow and see if you can get it happening again.
01:08lazybotMessage saved.
01:09SgeoIs there a way to extend-type an interface such that, if an interface or protocol is implemeneted, I can say that XYZ code is used to implement another interface or protocol?
01:10SgeoThat is, let's say, I want to say that all IFns are IMonadValues
01:10basicsenseitomoj, i tried it on an new empty project and it works, the .jar are there, thank you for that command; I'll try and see what's the difference between the two to detect why the .jar isn't generated
01:11tomojyou can extend IMonadValue to IFn because IFn is an interface on the jvm, but you probably shouldn't...
01:12basicsenseitomoj, I didn't realize that this was actually an error: http://pastebin.com/amSb94DR I thought it's more like a warning, but that is why the .jar wasn't generated
01:13tomojyeah, either add -SNAPSHOT to your project's version in project.clj, or find a stable version of the snapshot dep you have
01:13Sgeotomoj, clarify?
01:14tomojif IFn were a protocol, like it should be (it is in cljs), you couldn't do that
01:14basicsenseitomoj, sweet thanks
01:14tomojyou can't extend a protocol to another protocol, at least not now
01:14SgeoI thought all protocols make interfaces?
01:14tomoj(never, I suspect..)
01:14tomojyeah
01:15tomojI guess you could extend a protocol to another protocol's interface, but it seems wrong
01:15tomojthe interface hatch is there for java interop
01:16basicsenseithis is awesome, 'lein uberjar' did the job which I somewhat expected to be able to do with eclipse+ccw, I'll be using a combination of these then:)
01:16scodeGetting http://pastebin.com/hbGWdhGC trying to use swank w/ leinigen. Assuming I'm looking at matching soure (1.2.1), it looks like baseLoader() is probably returning null causing the NPE. THis is on a fairly clean ubuntu. Same with both JDK6 and JDK7. Anyone recognize this?
01:17tomojSgeo: so e.g. if you extend to both IFn and IPersistentSet, you've got multiple inheritance and it's undefined which implementation gets called
01:19tomojhuh, the doc for extend says both "extend an interface to a protocol" and "extend a protocol"
01:23Sgeotomoj, erm, I guess I don't quite understand extend
01:25SgeoI want all IFns to be IMonadValues but not all IMonadValues to be IFns. If I also want IPersistentSet to be IMonadValues, wouldn't that be a separate thing? (Unless all IPersistentSets are IFns, which I guess they are. Is that what you mean?)
01:26abpIs it possible to traverse through the whole source code of an expression(resolving all calls to forms etc) in a macro?
01:26tomojthat's what I meant, but I guess just the IPersistentSets we run into are always IFn
01:27Sgeoabp, possible, but may or may not be easy
01:27Sgeo,(doc macroexpand-all)
01:27clojurebotI don't understand.
01:27Sgeohttp://richhickey.github.com/clojure/clojure.walk-api.html#clojure.walk/macroexpand-all
01:27lazybotNooooo, that's so out of date! Please see instead http://clojure.github.com/clojure/clojure.walk-api.html#clojure.walk/macroexpand-all and try to stop linking to rich's repo.
01:28SgeoI blame Google.
01:28tomojwhat else do you think might be a monad value besides IFns?
01:28tomojer, an IMonadValue I mean
01:29arohnerI have a ref. I also have quartzite https://github.com/michaelklishin/quartzite. Quartz can only schedule jobs with serializable arguments. Is there a way to get a "pointer" to the ref, so I can look up the ref by its id later?
01:30Sgeo:/ sequences
01:30arohnerbasically, my goal is to call (f ref), a minute from now
01:31abpOk, now let's assume I've written that macro and use it to traverse the whole program to find calls to some other macros. Would that be a good solution..? I need to build meta-data on things that get not eval'ed due to if's etc. so theres no other way, I think.
01:31SgeoWait, whole program?
01:32SgeoIt can only see calls that are inside of it... hmm, I may have misunderstood you
01:32Sgeo(my-macro (f a b c))
01:32Sgeomy-macro will see (f a b c), and if f is a macro, it can see the expansion... but if f is a function, I think it's opaque to the macro.
01:32abpSgeo: Err, yes. That's what I meant, resolve calls to fns to their forms, so I can traverse those and so on.
01:32abpSgeo: Damn.
01:33casionI think I'm about ready to give up on clojure :| I've spent all day trying to figure out IO, and I still have no clue
01:33abpSo I have to wait for _zach|away to work on https://github.com/ztellman/sleight ? :)
01:33Sgeocasion, hmm?
01:33abpcasion: What are you trying?
01:34casionI want to tokenize a very large file based on specific byte-arrays
01:35casionas far as I can figure, I have to use line-seq and parse… except everything I try just seems ridiculously slow
01:36casionsince the files have no 'lines' per se, and the tokens often get split across what .readLine decides is a line
01:37casionit seems like I have to parse the entire read up til that point for every iteration of line-seq
01:37tomojdon't use line-seq
01:38abpcasion: You don't have to use line-seq, you can use clojure.java.io/reader for example
01:38SgeoHmm, will the reducers library have some alternative to line-seq that's clean? Because the post mentions Iteratees, and I think this sort of thing is right up Iteratee's alley
01:39tomojI don't know if it will go into the reducers library or a separate library, but I expect it's coming
01:39casionabp: I've been trying with reader, and I haven't come up with a solution
01:39casionwell, I have… but it's slow as molasses
01:39abpcasion: So, that's what you got then: http://docs.oracle.com/javase/6/docs/api/java/io/Reader.html
01:40SgeoWait, why does read() read in as an ... int?
01:40SgeoWhat.
01:41casionabp: but how do I efficiantly tokenize on a 4 byte array?
01:41casionefficiently*
01:42abpSgeo: I suppose because Reader can take different encodings in different impls, so you can get at UTF-8 chars with it for example.. But I don't know for sure.
01:42jkkramerreaders are character-oriented. if you're reading byte arrays you may want to be using input streams
01:42casionjkkramer: that's what I was doing, but I was told earlier today to use readers :(
01:43Sgeocasion, are you reading text or bytes?
01:43casionSgeo: bytes
01:43abpjkkramer: casion: So readers use streams under the hood I think..
01:44Sgeoabp, but readers might make assumptions about what those bytes mean
01:44casionthis evening I've been using readers with :encoding "UTF-8" to read per byte
01:44jkkramerthat sounds silly
01:44Sgeocasion, if the data is not UTF-8 text, don't do that. Otherwise you may end up with several bytes ending up as one value
01:45SgeoBecause in UTF-8, several bytes can make up one codepoint.
01:45casionSgeo: I'm aware.. and this is part of the issues I've encountered in this attempt
01:46casionI did try with InputStreams, and I have't been able to figure out how to find a byte-array in a byte stream
01:47abpcasion: casion You could use FileInputStream, wrapped in a BufferedInputStream directly, Readers seem to add encoding all the time
01:48casionabp: and then how do I tokenize?
01:48casionsince the separator can occur at any byte boundary
01:48tomojcommons-lang has ArrayUtils/indexOf
01:49SgeoIf I were thinking imperatively, I might take in a chunk at a time, check if the seperator's in it, and if not, keep adding to the chuck
01:49SgeoWhen I find the seperator, then do whatever at that point
01:49casionSgeo: that's the only way I managed to get it working… and it was really slow
01:51SgeoWell, hmm. The size of the chunks is a tradeoff. Too small, and you keep reading from disk too often, too large, and it takes up a lot of memory.
01:51abpcasion: Could you show how you did it? I must admit I'm not a good programmer when it comes to functional algorithms by now..
01:51abpSgeo: No, that's what BufferedInputStream is for
01:51Sgeoabp, oh
01:51abpSgeo: Read a chunk into a buffer once, pass to reader in sizes he takes
01:51SgeoI'm not really too familiar with the JVM ecosystem
01:51casionabp: I don't have the code available, been writing over it
01:51abpcasion: Ok
01:52abpcasion: Then how much data do you process?
01:52casionabp: 4gb-10gb or so
01:52casionper file
01:53casionif these were small files, I think I could handle it
01:53abpcasion: Neat. What do you do with the processed data? Do you have reference implementation you can compare to in terms of performance or why do you think it's slow?
01:54casionabp: data is RIFF64 wav files, right now I'm just trying to parse the header (which can be of arbitrarily large size)
01:55casionand as reference I'm comparing to javax.sound.sampled's RIFF header parsing
01:55casionit doesn't handle RIFF64, but the headers are nearly identical besides some extra feilds
01:56casionso I'd think I could get this performing nearly identically
01:58abpcasion: Probably.. But that's a java lib, so why don't you just wrap javax.sound.sampled or use it directly?
01:58abpcasion: oh ok
01:58casionabp: because I'm trying to support file types it does not
01:58abpcasion: Just saw doesn't handle, sorry
01:58casionI've already written half a wrapper for it though (read only atm)
02:00abpcasion: Yes then writing Clojure that matches the performance of a Java lib isn't easy but quite doable in many cases. It's probably a bit of work to get your head around programming performant code..
02:01jkkramerif you're dealing with individual bytes, arrays, large files, and want speed, your code will probably be heavily imperative and interop-y
02:01abpjkkramer: Indeed
02:02casionin that case, I will go back to that concept
02:02abpcasion: you can look at http://stackoverflow.com/questions/12176832/quicksort-in-clojure (dnolens answer), also he suggests looking at http://github.com/clojure/test.benchmark to archieve java perf
02:03casionis there a clojure way to compare byte-arrays, or is it proper to use java.util.Arrays.equals()
02:05abpcasion: http://docs.oracle.com/javase/6/docs/api/java/util/Arrays.html#deepEquals(java.lang.Object[], java.lang.Object[]) don't know of a clojure way
02:05casionok
02:06casionI was using java.util.Arrays/equals before, which seemed to work correct
02:07casionthanks for the help, I'm going to see if I can get input streams working again so I have some code to show if it's still slow
02:07abpcasion: should be shallow comparison. :x
02:07abpcasion: You're welcome
02:08casionapologies for the 'I'm going to quit clojure' drama… getting frustrated trying to do stuff I can do/have done in another language
02:11tomojcasion: you might consider looking at gloss sometime
02:11tomojnot sure if netty makes sense, or how fast it would be, but your code would almost certainly be simpler :)
02:12casiontomoj: ok, I will do so once I at least conoquer this basic bit on my own :) thank oyu
02:12casionconoquer… lol
02:12abpcasion: I was frustrated some times with banging my head into fp-thinking but never enough to start a drama. Perhaps I'm to stubborn. ;)
02:15casionok, I have the 'working' input-stream code
02:16casionhttps://www.refheap.com/paste/4936
02:17casionthat takes 5ms to just 'pull' the header, where the java equiv pulls and parses the header in 0.002ms
02:17casionso obviously something is broken with my code I would think
02:18casionand I checked, seems comparing seqs is faster than java.util.Arrays/equals
02:18abpcasion: first this, don't call (byte-array) in every step, one array instance is enough
02:18abpthis=thing
02:19casionabp: where do I bind it then?
02:19casionif I put it outside the loop, I end up with an array of whatever the last read was N times
02:19abpcasion: let around loop, carry throug loop/recur, as you prefer I think
02:20abpah I see
02:20abpcasion: you conj array-refs into vec
02:22abpcasion: use (into coll ba)
02:22casionok, let me try
02:24abp,(into [] (byte-array 4))
02:24clojurebot[0 0 0 0]
02:24abp,(into [] (byte-array 4))
02:24clojurebot[0 0 0 0]
02:24abp,(conj [] (byte-array 4))
02:24clojurebot[#<byte[] [B@2b41bb40>]
02:24abpI need to start using the bot for explanations. :)
02:26casionheh, just that emacs instance
02:27casiondoes this look like what you were suggesting? https://www.refheap.com/paste/4937
02:32abpcasion: Yes, now let ,(byte-array 4 (map byte [100 97 116 97])) in the outer let too and do ,(java.util.Arrays/equals (byte-array 4 (map byte [100 97 116 97])) (byte-array 4 (map byte [100 97 116 97]))) insted of (= (seq ba) ...
02:32casionjust did that… it's 4x slower
02:32abpcasion: Sorry, just setting up an account for refheap so I can edit there..
02:33casionno prob, the help is greatly appreciated
02:33abpcasion: java.util.Arrays.deepEquals is for objects, equals for primitives, so that's ok here, said something wrong earlier
02:35abpcasion: Oh, that's weird, paste the code again?
02:36casionsure
02:36casionhttps://www.refheap.com/paste/4938
02:39abpcasion: wow, that's slower than (= (seq...? Wouldn't assume that
02:40casionyeah… I don't get it either
02:40casionI had this code this morning and stumbled on using (seq) because I didn't know about java.util.Arrays/equals, and I was naively using (= )
02:41casionwhen I tried equals after learning of it… it was quite plainly slower
02:41abpcasion: Hm, do you benchmark properly, ie multiple runs, taking the mean, for the jvm to warm up?
02:43casionabp: yep
02:45casionhmm, with another file they're benching about equal
02:46casionI'm so confused :|
02:46casionequals isn't better at all yet though
02:51tomojmust a reducer never call reducef after returning from reduce?
03:14devncasion: "another file"?
03:14casiondevn: one with a shorter header
03:14devnso you're trying to seq on the contents of a file?
03:15casionno, only on a 4 byte-array
03:16casionthis https://www.refheap.com/paste/4937 compared to this https://www.refheap.com/paste/4938
03:16casionthere's a mising parens in the second one
03:17devnwhich is faster?
03:17devn2?
03:17clojurebot2 is mark
03:17casion1 is faster for me
03:18devnand that's surprising?
03:19casionI would think java.util.Arrays/equals would be faster
03:19casionbut I have little to base that on
03:19devnyeah but it's sort of pleasant that it isn't, no?
03:19casionyes
03:20tomojreflection?
03:20devnhaha
03:20devnman, this channel
03:21devn"Do you have *warn-on-refle..."
03:21devntomoj swoops in
03:22casionwarn-on-reflection is off
03:23SgeoWhat is it about reflection that's slow?
03:23SgeoIs it just -reflection on the JVM- or -reflection in general-?
03:24SgeoIf the latter, do things such as Ruby's pervasive use of reflection for metaprogramming in various frameworks make things slow?
03:36amroSgeo: reflection in general
03:42abpSo, I ran casion's byte-array comparisons without IO etc, measuring with criterium
03:43abp(seq (= .. Evaluation count : 1144172760 in 60 samples of 19069546 calls. Execution time mean : 52,665007 ns
03:44abpjava.util.Arrays/equal Evaluation count : 1220332860 in 60 samples of 20338881 calls. Execution time mean : 49,670757 ns
03:45abpAt least not much of a difference..
03:48SgeoIs Clojure suitable for making proprietary applications? In terms of legality/licenses, I mean
03:49abphttps://www.refheap.com/paste/4940
04:11Sgeohttps://github.com/rplevy/swiss-arrows
04:12SgeoThe example of the diamond wand with two maps seems like it might be a compelling use-case
04:14muhoohappy (reduce #(assoc %1 %2 (get-tag %2 j)) {} [:id :title :city :url])
04:15muhoothat one line leaves me going to sleep with a smile on my face
04:41_KY_I used "doseq" to evaluate something, but it still seems to be lazy... is that normal?
04:42_KY_But if I add a "print" to debug it, it evaluates fully
04:42_KY_This laziness is driving me nuts....
05:01SgeoUse for a macro-writing macro: A macro to make a macro that's merely an alias of another macro
05:21callenokay, what'd you change this time?
05:21callenplugin is gone, swank-clojure is gone, how do I make clojure-jack-in work?
05:21callenwhat are user profiles and why can't I install a plugin without creating a project or a profile?
05:26callenI seem to have gotten it to behave, but a lot has changed o_o
05:26RaynesI'd suggest abandoning swank and slime and trying out nrepl.el. You don't need any extra plugins for it, just nrepl.el and leiningen 2.
05:26RaynesIf you install it, you can do nrepl-jack-in
06:01tsdhGiven a namespace and a symbol, how do I get the qualified name of the var the symbol refers to in the namespace?
06:01tsdhBasically, I want (ns-resolve ns 'var) but as symbol, not as var.
06:02callenRaynes: I ended up doing that right around the same time you suggested it (Ritz and NRepl are recommended in swank clojure's readme)
06:02callenRaynes: it worked great, thanks.
06:03callenalso light table seems neat, but where's the source? I want to turn live-eval on in table mode.
06:06tsdhHm, seems there's no clean way. Even clojure.repl/doc uses str for that task...
06:14leafwjust posted on clojure monads: albert.rierol.net/clojure-monads.html -- I hope you find it interesting, and I would appreciate comments.
10:20ro_stdatomic question: how do i update schemas? i'm getting a ":transact/bad-data Unique conflict: :db/ident, value: :my/ident already held by 62" error
10:39Sweden_jackHey, what's the easiest way to find the {min,max}imum of a list by some “key” function? Let's say that I want to find the shortest list in a list of lists: (? [[1 2 3] [-2] [3 2] :key count) → [-2]
10:39Sweden_jackIn Python you'd use: min(..., key=len) and in Haskell you'd use minimumBy (comparing length)
10:40dhmSweden_jack: reduce + min/max i think
10:40raekSweden_jack: check out min-key and max-key
10:40raek,(apply min-key count [:a :aa :aaa])
10:40clojurebot#<UnsupportedOperationException java.lang.UnsupportedOperationException: count not supported on this type: Keyword>
10:41Sweden_jack,(apply min-key count [[1 2 3] [-2] [3 2]])
10:41clojurebot[-2]
10:41Sweden_jackOK fantastic :)
10:41raek,(apply min-key (comp count name) [:a :aa :aaa])
10:41clojurebot:a
10:41Sweden_jackThanks a bunch
10:42raekinga problem
10:42Sweden_jackhaha, I'm not really Swedish ;) up until 2 weeks ago I was Iceland_jack
10:44hyPiRion$findfn [:a :aa :aaa] :a
10:44lazybotjava.lang.ClassCastException: clojure.lang.PersistentStructMap$Def cannot be cast to clojure.lang.IFn
12:24deeplloydexit
12:25deeplloydexit
12:25Frozenlo`enter
12:39ro_stcan anyone tell me how to handle schema migrations with datomic?
12:45gfredericksabedra told me the other day that maybe it was somehow even simpler than renaming everything
12:46gfredericksbut I haven't even used datomic so I really can't speculate about what he meant.
12:47gfredericksrhickey was asked the question at a talk here recently and gave some incomprehensible "what schema!?" response
12:47ro_sti thought i could just transact schemas over and over and it'd all just sort itself out. but i'm getting Unique conflict exceptions (unless i _delete_ the database), which leads me to wonder how one can safely update the schema
12:48ro_sti'm sure it's dead simple. docs don't talk about it at all, though
12:55ro_stlooks like the answer is boils down to 'only define new schemas'
12:56gfredericksis that limiting?
12:57ro_stonly in the sense that i have to construct a migrations sytem, now
12:57ro_stsystem*
12:59BronsaOlegYch|h:
13:35SgeoWhat happens if a library provides an atom but I want to modify it in a transaction only if the transaction succeeds?
13:42raekSgeo: one way could be to let the transaction extression return everything you need when you update the atom, and then do the update outside the transaction
13:43SgeoWould it even be that inconvenient if atoms didn't exist?
13:43raek(but maybe that's not possible in your data flow)
13:46raek(let [delta (dosync ...)] (swap! a + delta))
14:02solussd_can I not have a namespace with hyphens in it? my namespace is some-words.server and I'm getting java.lang.ClassNotFoundException: some-words.server. I have a path in my project of src/some_words/server.clj. ?
14:04llasramsolussd_: You can have '-' in your namespace name just fine, but there are occasional issues with inconsistent munging. What's the context in which you're getting the error?
14:05solussd_'lein run'
14:05solussd_and i think it's my project.clj :main section
14:05solussd_:)
14:06solussd_nope..
14:06solussd_now I'm getting java.lang.ClassNotFoundException: some_words.server
14:08llasramBoth of those should work without problem, so I think there's another issue
14:14solussd_hmm.
14:41arohner_Sgeo: you can send to the atom, in the transaction
14:41arohner_i.e. using an agent
14:42arohner_agent sends inside a transaction only fire on success, after the transaction completes
14:42arohner_that will be async btw
15:04djanatyn...hmm. how possible would it be to have a clojure library similar to lispbuilder-sdl?
15:04djanatynis it possible for us to create clojure bindings to SDL, on the JVM?
15:05emezeskedjanatyn: Possibly, through the use of JNI
15:05emezeskedjanatyn: I think that many people on the JVM use lwjgl as an alternative to SDL though
15:06emezeskedjanatyn: E.g. see https://github.com/ztellman/penumbra
15:10ro_stemezeske: so happy cljsbuild is working 100% on lein 2. thanks for your effort!
15:10ro_stwe're using lein2 end to end, now. yay
15:10djanatynemezeske: I've tried using penumbra, but opengl is a little difficult to wrap my head around :\
15:11emezeskero_st: That's great!
15:12ro_stit's so much simpler using lein2
15:12ro_stprofiles.clj is a big help
15:12emezeskedjanatyn: If you don't need opengl, can you just use Swing?
15:12emezeskero_st: Yeah, profiles are really nice
15:12djanatynI guess though
15:13djanatyn*so. Is Seesaw appropriate for writing little simulations and games?
15:13emezeskedjanatyn: If that's your goal, have you looked at quil?
15:13djanatynYeah, I have. I should probably take a closer look at quil
15:14emezeskeI've done a couple simple physics simulations with quil
15:14emezeskeIt's good if you just need a super quick way to display something
15:14djanatynI had trouble figuring out how to manipulate state using quil
15:14emezeskeUsing quil's built-in state stuff?
15:14emezeskeI dropped that immediately and just manage my own state with an atom
15:15djanatyncould you elaborate? how do you manage your state with an atom?
15:16emezeskedjanatyn: Would it be helpful if I just put my little physics demo up on github?
15:16djanatynyeah, it would! that would be great.
15:16emezeskedjanatyn: cool, it's pretty ugly code, but I'll put it up in a sec
15:16ro_stemezeske: did you see the cljsbuild enfocus shoreleave demo i put up?
15:17ro_sthttps://github.com/robert-stuttaford/demo-enfocus-pubsub-remote/
15:18emezeskedjanatyn: In no way do I represent this as good code: https://github.com/emezeske/germ
15:18emezeskedjanatyn: :)
15:18emezeskero_st: taking a look
15:18ro_stjust as a sort of a starter kit for projects that want to use cljsbuild crossovers + enfocus for ui + shoreleave for remotes and client-side pubsub
15:19emezeskero_st: That looks really cool! I need to read more about shoreleave
15:20ro_stit's nice. the remotes stuff is pretty much just fetch but with csrf protection baked in
15:20ro_stthe pubsub is nice. declaratively bind ui and model
15:22emezeskeNice, built-in csrf protection is cool. Also, not depending on noir is cool.
15:23ro_stcemerick just released a nice redo of the server side of shoreleave remotes
15:23ro_sthttps://github.com/cemerick/shoreleave-remote-ring
15:23ro_stwe're using noir anyway :-)
15:24emezeskehah :)
16:13SgeoIf it's possible to make cyclic immutable data structures in Haskell, why shouldn't it be possible in Clojure?
16:15seancorfieldYou can certainly construct lazy sequences that are cyclic in Clojure...
16:16SgeoHow about trees or other graphs
16:16seancorfieldSure, as long as you can specify the cycle points... (he says blithely without trying it)
16:17hiredman,(doc cycle)
16:17clojurebot"([coll]); Returns a lazy (infinite!) sequence of repetitions of the items in coll."
16:18hiredmandepends what you mean by cycle
16:18emezeskeSgeo: You are talking about referential cycles, right? Like a circular linked list
16:18seancorfieldThat's not really quite the same tho' hiredman - not as a general cyclic graph
16:18hiredmanthe tail of the seq contains the whole seq
16:18seancorfieldA has children B C D and C has children E F and A, for example
16:19emezeskeseancorfield: Can you really make an immutable datastructure with a referential cycle? It seems like there's a chicken and egg problem there.
16:19ivancan one do http://en.literateprograms.org/Fibonacci_numbers_%28Haskell%29#Infinite_Lists in Clojure?
16:19emezeskeseancorfield: You could roll your own reference system, like storing the lookup key for a cyclic structure
16:19Sgeoemezeske, you can if there's sufficient non-strictness
16:19ToxicFrogivan: yes; clojure has lazy data structures
16:20ivanToxicFrog: yeah, but I tried porting it directly and got a terrible algorithmic complexity explosion, because it wasn't reusing the outer lazy-seq
16:20rlbhttp://stackoverflow.com/questions/4580865/how-can-one-create-cyclic-and-immutable-data-structures-in-clojure-without-ext
16:20hiredmanemezeske: you can definitely do it with laziness
16:20seancorfieldemezeske: sure if the lazy expansion of the tree resolves to nodes you've already generated
16:21emezeskehiredman, seancorfield: I see. That makes sense.
16:22SgeoThe thing with delays is that they need to be explicitely forced
16:22hiredmanrecursive functions, recursive data, whats the difference?
16:23hiredmanhttps://gist.github.com/1179073
16:24rlbI imagine people used to traditional lisps may be likely to reach for direct graph representations by default (via set-cdr! or similar)...
16:43konrDo you remember the name of that JS library that implements ClojureScript functions in vanilla JS?
16:44Bronsamori?
16:44konryes! thank you
16:50ro_stanyone modelled tags with datomic yet?
16:51nbeloglazovDoes nrepl have feature to search in history with prefix? I think swank has it.
16:52nbeloglazovI mean nrepl.el
16:58callenso does anyone use anything other than the code-heavy hiccup for templating for web dev in Clojure?
16:58ro_stYES
16:58callenI'd like my frontend guy to be able to wrangle the templates.
16:58ro_stenlive.
16:58callenokay, enlive is equally guilty of what I'm talking about.
16:58ro_sthttps://github.com/robert-stuttaford/demo-enfocus-pubsub-remote/blob/master/resources/public/templates/templates.html + https://github.com/robert-stuttaford/demo-enfocus-pubsub-remote/blob/master/src-cljs/depr/view.cljs
16:58callenI need plain-text templates he can understand.
16:59ro_stlet him do the html and you do the clj
16:59ro_stthat code is enfocus (cljs port-ish of enlive) but the principle applies
17:00callenlooks a little complicated for what's generally a simple problem.
17:00ro_stthat scales incredibly well.
17:01callen...right.
17:01callenwhat scales well is something more people than just me can understand.
17:01emezeskecallen: There's like at least 42 mustache implementations in Clojure
17:01duck1123when you edit your templates, are they automatically picked up?
17:01FrozenlockI've yet to understand what's the point of templating... isn't there HTML (from clj) and the rest is CSS?
17:01ro_stduck1123: yup. you can optionally have em compiled in at compile time
17:01callenemezeske: aha, thank you.
17:01ro_stbut i prefer not to
17:02ro_stFrozenlock: hiccup doesn't scale all that well. nice for simple stuff but big projects it gets sticky on
17:02emezeskecallen: You might have to poke around a bit to find the most current/maintained one
17:02callenI figured
17:03duck1123I looked into using closure template, but It didn't automatically pick up the changes, and I went back to hiccup
17:03ro_stduck1123: for cljs?
17:03duck1123Now that I'm using Knockout, I'm trying to get as much of the logic out of my templates as possible
17:03duck1123I was only using the server-side at that point
17:04ro_stgclosure's soy templates are not a fun experience
17:04duck1123Now I send a blank template and my page fetches a viewmodel on load and then loads any other missing models
17:05duck1123I was hoping I could just pass it my record, but the soy compiler was way too picky about types
17:05ro_styup
17:06duck1123I have a series of multimethods where I have common names for types of display (index-section, show-section, etc) and it dispatches on the type of records passed to it and the format being used. Works well for me
17:07ro_stnice
17:07xeqiemezeske, callen: https://github.com/davidsantiago/stencil for mustache
17:07mr_rm'(clojure.string/join "," #{1 2})
17:07mr_rm`(clojure.string/join "," #{1 2})
17:07mr_rmhmmm how do you talk to the bot again?
17:08nbeloglazov,
17:08ro_st,
17:08clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
17:08clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
17:08Bronsalol
17:08mr_rm,(clojure.string/join "," #{1 2})
17:08clojurebot"1,2"
17:08nbeloglazovOr &(clojure.string/join "," #{1 2})
17:08Frozenlockand iirc, # is for when you want to mess around
17:08mr_rminteresting... this is blowing up on my clojure 1.4 in eclipse
17:08nbeloglazov&(+ 1 1)
17:08lazybotjava.lang.ClassCastException: clojure.lang.PersistentStructMap$Def cannot be cast to clojure.lang.IFn
17:08Bronsa&+
17:08lazybotjava.lang.ClassCastException: clojure.lang.PersistentStructMap$Def cannot be cast to clojure.lang.IFn
17:08nbeloglazovо_О
17:08Bronsawtf.
17:09mr_rmoh... no. ccw is using 1.3 i think
17:09Sgeo&(meta #'+)
17:09lazybotjava.lang.ClassCastException: clojure.lang.PersistentStructMap$Def cannot be cast to clojure.lang.IFn
17:09Bronsawho broke lazybot
17:09Sgeo&(class +)
17:09lazybotjava.lang.ClassCastException: clojure.lang.PersistentStructMap$Def cannot be cast to clojure.lang.IFn
17:09duck1123if you know you're going to be messing with the bot a lot, it'll respond to /query
17:09xeqiI might have yesterday
17:14nbeloglazov$javadoc Thread
17:14lazybothttp://docs.oracle.com/javase/6/docs/api/java/lang/Thread.html
17:14SgeoIsn't one of the bots a self-wiping thing?
17:16hyPiRionSgeo: clojurebot is, afaik.
17:16SgeoAh
17:16ethanishas anyone ever seen an exception of this sort?
17:16lnostdali figured i'd try nrepl.el since swank is on its way out, but it doesn't seem to be listed as a package to install via marmalade? (i've tried M-x package-refresh-contents)
17:16ethanisException in thread "main" java.lang.IllegalArgumentException: Parameter declaration if should be a vector
17:16ethanisI've been slamming my head on it for a while
17:16ethanisthe stack trace is… opaque
17:17ethanishttps://gist.github.com/3679797
17:17hyPiRionlnostdal: nrepl should be there
17:17ethanisthis is a web application, my namespace is startlabs, the .server is noir's standard server setup
17:17ro_stethanis: remove all your view clj files
17:18Bronsaethanis: you're doing (defn foo (args) ..)
17:18ro_stand put em back one at a time
17:18Bronsainstead of (defn foo [args] ..)
17:18ro_stor ignore me and listen to Bronsa
17:18ethanisvery good tip
17:18Bronsaro_st: haha
17:18ethanisBronsa: I may have made a typo, I'll look into that
17:18ethanisthank you very much for the advice, folks
17:18Bronsaethanis: defn or defmacro, that is
17:18ro_stBronsa speaks as one with personal experience -grin-
17:22ethanisyou were right Bronsa, I accidentally snipped the [] from a defn by copy-pasting
17:22ethanisnice call
17:22Bronsahappy to be of help
17:25ro_stdatomic is lots of fun but the lack of people to pester for help is annoying
17:25ro_st#datomic might as well be called #tumbleweed
17:27ro_styou guys need to get cracking so i have someone to talk to about it :-)
17:28lnostdalhyPiRion: odd .. i'm not seeing it .. packages like slime etc. are missing too .. strange
17:28duck1123ahh the burdens of being into fringe topics
17:29ro_styeah
17:29ro_stfirst world problem!
17:29ro_stmy favourite first world problem: "I'm bored, but I don't want to do anything"
17:31djanatynemezeske: thanks, I'm having much more fun with quil now that I read up on atoms
17:31djanatynI assumed that they were the same as atoms in scheme, which led to a lot of confusion :)
17:33lnostdalhyPiRion: never mind .. i'm an idiot .. i thought emacs 24.x already had the marmalade repo. included by default
17:42emezeskedjanatyn: Great!
17:44emezeskedjanatyn: The state stuff in quil probably has certain advantages, but I found using an atom to be just very straightforward.
17:47djanatynemezeske: Yeah. I'm trying to get overtone set up now, to play with both of them together.
17:50mmitchellIn this example, How do I create an instance of Geometry in clojure? https://github.com/neo4j/spatial/blob/master/src/test/java/org/neo4j/gis/spatial/TestSpatialQueries.java#L60
17:50mmitchellI just don't know how you translate "new Geometry[] {...}" to clojure?
17:58thoughtmanifestmmitchell: it's just an array of that object which the for loop iterates over. Is that what you're asking? http://docs.oracle.com/javase/1.5.0/docs/guide/language/foreach.html
18:24mindbender1Is there a way of knowing which library is requesting for a particular dependency
18:25mindbender1something keeps requesting for thneed SNAPSHOT each time I try starting a repl
18:28emezeskemindbender1: "lein deps :tree" might help
18:29konrI've managed to run a 'hello world' project in clojurescript, yet I don't know what to do next. What APIs can I use? How can I manipulate things? In my main .cljs file, there are no uses or includes, for example
18:30emezeskekonr: You can use any JS library, for instance the Google Closure Library is available
18:30emezeskekonr: There's also jayq if you want to go down the jQuery route
18:30emezeskekonr: Or enfocus or domina
18:33gfredericksemezeske: does cljsbuild determine the require-order for namespaces just once?
18:33gfredericks(when running auto)
18:33emezeskegfredericks: I think that may be the case
18:33emezeskeOh that? It's a bug in the ClojureScript compiler
18:34gfredericksoh cool
18:34emezeskehttp://dev.clojure.org/jira/browse/CLJS-282
18:34gfredericksit always gets fixed by restarting cljsbuild though
18:34emezeskeYeah, the first time will work
18:35emezeskeI gotta run; if that bug seems to be what you're encountering, please vote or comment
18:36emezeskeMaybe at some point I'll have a chance to look at it
18:36emezeske:)
18:37konrIn an example cljs application, there is a (js/alert) call without any require. Is 'js' an automatically available namespace? If so, is it documented somewhere?
18:46xeqimindbender1: its coming from trammel, which is used by leinjacker.. which is used by some lein plugins, for example lein-ring
18:46casionhow can I improve this, or what concepts could I apply to make it more idiomatic? (besides checking for file end) https://www.refheap.com/paste/4956
18:46xeqilein deps :tree doesn't help with finding out plugins deps :/
18:51basicsenseihey guys, is it possible to have *use-context-classloader* set to false before clojure loads itself ? as to avoid this error: http://pastebin.com/atUEgBQL
18:51basicsenseiwithout having to recompile clojure
18:52gfrederickskonr: js/foo gets compiled directly to "foo"
18:52gfredericksso I guess it's a way to refer to global stuff in the js runtime
18:52gfredericksI don't know if that's the permanent solution for doing things like that
18:52gfredericksbut it works for now
18:53mmitchelloops, i posted this a while ago but lost my connection... my question was: how do you translate this (java) "new Geometry[] {...}" to clojure?
18:53mmitchellan example: https://github.com/neo4j/spatial/blob/master/src/test/java/org/neo4j/gis/spatial/TestSpatialQueries.java#L60
18:54gfredericksmmitchell: http://clojure-log.n01se.net/#17:50
18:54xeqimmitchell: (into-array Geometry [...})
18:55mmitchellawesome thank you!
18:55xeqi* ])
18:59gfredericksdoes clojurescript have with-redefs?
18:59TimMcmmitchell: Are you converting that Java code?
19:00basicsenseiTimMc: is there a better way ?
19:00basicsenseito convert that java code
19:01mmitchellTimMc: yes, converting it to clojure
19:04gfredericksbasicsensei: depends on how strictly he needs to preserve what the code does
19:05gfrederickse.g., does he really need an array?
19:06TimMcRight, mmitchell doesn't need an array -- [shortLineString longLineString] is sufficient for iterating over, if you want to iterate over it.
19:06basicsenseiI was thinking maybe there's some kind of automation that does java to clojure, and that's why he asked; or that he wanted to suggest a different project which already had neo4j converted or simply use clojure java interop, or a project that uses that existed already
19:07mmitchellactually, i just had no idea how to make that code work in clojure (not a java programmer)
19:11basicsenseiregarding my first question for this session, I was hoping leiningen had an option in project.clj like ':warn-on-reflection true' which (if that's even possible at that stage, before clojure loads that is) would allow setting *use-context-classloader* to false to void this error: http://pastebin.com/atUEgBQL
19:12basicsenseiavoid*
19:48basicsenseishouldn't leiningen yell when invalid options are encountered in project.clj ? ie. I had :java-source-path "javasrc" but for 2.x should've been :java-source-paths ["javasrc"] (notice the extra "s")
19:54gfredericksI don't think lein could reasonably determine what an invalid option is, given plugins can use arbitrary options
19:59basicsenseiplugins for lein? maybe each plugin can "register" every valid option so that lein can check that and detect if it's valid? I mean, it would seem better than assuming your option is handled but at the same time not knowing if it is or isn't
20:00S11001001basicsensei: ah, the old typed versus untyped problem :]
20:00basicsenseijava vs clojure ? :)
20:01basicsenseithat's actually what I am afraid of with clojure, that errors are simply ignored and you wouldn't even know there would be one
20:01basicsenseiwell I mean, in cases like above
20:02basicsenseiit's not that it cannot be programmed to handle those cases, it's that it allows those to go unnoticed by default; well at least that's my first impression
20:03S11001001basicsensei: java is a typed straw man, doesn't even have higher kinds
20:04S11001001basicsensei: but yes, asking for options to be registered explicitly is just asking for types, so it is a philosophical black hole when it comes to clojure
20:05seancorfieldproject.clj is just a map - it can have arbitrary key/value pairs in it
20:05basicsenseiseancorfield: I understand that, but there are no checks being done by lein to see if those keys are valid "options", and coming from java let's say, I would've expected that
20:06seancorfieldfor example it could have options for a plugin that you are not using - is it then still a valid project.clj file? yes - if the plugin is not used, the option is ignored, if the plugin is in use then the option is used
20:07basicsenseithat makes sense, but in that cause I would want to see maybe a warning if not an error
20:07seancorfieldjava doesn't validate that every entry in a configuration file is valid / used
20:07shaunxcodeduck1123: added the jsedn bin you requested on latest version so you can pipe edn forms to it and us -s "x y z" path style to explore
20:08seancorfieldif i develop a library and use a custom plugin locally for some development task, i should be able to ship that library - still containing options for that plugin - and have people use it regardless of whether they have that plugin installed or not
20:08seancorfieldotherwise my library will break for users without that plugin - which would be silly
20:10basicsenseiseancorfield: but what if that plugin being installed and used is a requirement to compile that library (btw, I noticed that project.clj is included inside the uberjar , am I to understand that the options inside it are used also after the jar is compiled, like at runtime?)
20:11seancorfieldif the plugin is a _requirement_ i'd list it in the :plugins section and lein would automatically download it :)
20:11seancorfieldi'm talking about _optional_ plugin usage
20:11seancorfieldand, yes, it's possible that options apply at runtime if you do, say lein run on that project
20:12basicsenseiok, but look in my case above, i had an obsolete option :java-source-path in project.clj which while it existed lein uberjar would still work, but it wouldn't also include a .java class, and it took me a while to realize, but if a warning for that option would've been issues, so much time would've been saved
20:13seancorfieldif you think lein 2 should give a warning if it sees the lein 1 java source path option, open an issue on lein's github repo
20:14seancorfieldbut remember that some projects are actually set up to run with both lein 1 and lein 2 (not many, admittedly)
20:15seancorfieldso it isn't necessarily an error to see lein 1 options in project.clj when running lein 2 (unless, i guess you've explicitly specified the minimum lein version as an option as well?)
20:16seancorfieldbut i'm pretty sure an application can pull options out of project.clj at runtime if it is run via lein, so the options in there don't necessarily relate just to plugins...
20:16basicsenseiI hear you, :min-lein-version "2.0.0" ? I'll add that too, thanks
20:17seancorfieldok, dinner time... curry is calling!
20:17basicsenseithat's good to know
20:17djanatynsay I have a map, {:foo nil :bar nil}. how can I return a new map which is the same but with :bar being 100?
20:18djanatynI'm doing this because I have maps that contain the state of Things, and I want to modify just a certain part of a Thing usually
20:19gfredericksassoc
20:19gfredericks,(let [ihaveamap {:foo nil :bar nil}] (assoc ihaveamap :bar 100))
20:19clojurebot{:foo nil, :bar 100}
20:19basicsensei,(assoc {:foo nil :bar nil} :bar 100)
20:19clojurebot{:foo nil, :bar 100}
20:19djanatynsweet, thank you!
20:20djanatynhey, can we do the same thing with records?
20:21gfrederickstotes
20:21djanatynomg it worked
20:21djanatynthat's so excellent
20:22gfredericksI think the community consensus is that records are rather advanced though; so without knowing what you're doing, if you just learned about assoc then you probably don't need records
20:22djanatyn(defrecord Foo [bar]) (assoc (Foo. nil) :bar 100) ;=> Foo{:bar 100}
20:23gfredericksdjanatyn: you can also assoc extra keys onto a record
20:23djanatynwell, I've used records in haskell before, and clojure records seem pretty similar
20:23gfredericksif you want to really have a wild time
20:23djanatynthe protocols remind me of java interfaces, like they said in a blog post I read
20:24djanatynin haskell the record syntax was prett funky; if I understand correctly, there's been a lot of campaigns to clean it up
20:24djanatynbut this is really cool, just using assoc to mess with records!
20:24gfredericksdjanatyn: it depends on how concerned you are about what "idiomatic clojure" is; I don't want to imply that you _ought_ to be concerned about that
20:25hiredmandjanatyn: protocols are more like typeclasses in that they are open ended
20:25hiredman(compared to java interfaces)
20:26djanatynnow that you mention it, I can think of places I've used records where simple maps would have been sufficient
20:27gfredericksdjanatyn: it's probably somewhat of a static vs dynamic aspect as well
20:27djanatynwhen should you use a regular map, and when should you use a record? is it appropriate to use records if you're not going to make any protocols?
20:27Sgeodjanatyn, keep in mind though that using Clojure maps for stuff is not type safe the way using Haskell records is.
20:27SgeoHaskell does have Data.Map which you could use but it's ugly because it's not type-safe
20:28SgeoTo assume that, say, you have a key "mykey"
20:28gfredericksI'm curious how much people use records. I've seen a lot more uses for protocols and deftype together
20:28gfredericksusually for libraries or bootstrapping the language
20:28tomojrecords have faster access to defined fields
20:28tomojso _after_ you profile, you might make some defrecords for performance
20:29gfredericksgood point
20:29gfredericksmore like structs I guess :/
20:29gfrederickswhat about defrecords with protocols?
20:30SgeoClojure maps are less painful than Haskell records, but keep in mind that you're losing typesafety.
20:30tomojI don't think I've done that yet..
20:30gfredericksI feel like people are inclined at first to see defrecord as a solution for business objects
20:30tomojseems wrong
20:30nodenameHi, I just posted a problem to the Clojure Google group: "Can't start Rhino repl for ClojureScript". Would love it if someon can help
20:31tomojif it's data, it shouldn't be a business object, if it's not data, why is it a defrecord?
20:31tomojwish I could run a query to find all examples of defrecord w/ protocols on github
20:32gfrederickstomoj: I don't understand "if it's data, it shouldn't be a business object"; I must be missing at least one of your definitions
20:33hiredmanNoBusinessObjects
20:33tomojI only have a vague idea what 'business object' means
20:33hiredmanit'sa dual of NoSQL
20:33gfredericksyes me too
20:33gfrederickswhat I meant by it (since I used it first)
20:34gfredericksis maybe "domain objects" but not using the word "object" in any kind of programming language sense
20:34hiredmandomain data
20:34gfredericksyou know the typical user and account and client and etc
20:34gfrederickssure
20:34gfredericksdomain data
20:35gfredericksso tomoj your first phrase was just that domain data should be in maps and not custom types?
20:35tomojwell, either maybe
20:35tomojas an example my domain right now is neural networks, and I have a (defrecord Node ...) for performance
20:35duck1123I use a lot of defrecords for that purpose. I find it's useful to have a type you can dispatch on
20:35tomojbut the Node doesn't know how to activate itself
20:36tomojthat logic is agnostic to the type, just takes any associative
20:36gfredericksduck1123: you have protocols for your domain data?
20:36duck1123I haven't used too many protocols. A lot of the design was done with multimethods
20:37duck1123some of it predates protocols
20:37hiredman:(
20:37gfrederickssatisfies? is not a function in cljs?
20:37SgeoYou could dispatch on the value of a key in the map
20:37SgeoRather than dispatching on type
20:38hiredmanduck1123: if you are using multimethods using records for "performance" is just silly
20:38duck1123originally, way back, I used metadata on the maps
20:38gfrederickshiredman: duck1123 didn't mention perf I don't think
20:38duck1123hiredman: it's not for perf
20:39hiredmanmultimethods are slow, and until 1.5 goes out they have locking overhead
20:39gfrederickstomoj likes perf, duck1123 likes type dispatch
20:39gfredericksFIGHT!
20:39SgeoI still want to bring lenses into the picture
20:40Sgeo(Composable thingies that conceptually know how to "get" and "modify" (not really modify but like what assoc does) a location)
20:40duck1123I'm actually dispatching on more than just the type of a record, so while protocols may be able to replace some of it, I'd still need multimethods for the rest
20:41solussd_is there a clojure reader macro that repeats the last evaluated form in the repl? Also, is there a reader macro for the last result?
20:42tomojI guess you might sensibly implement IComparable or IPrintable or the like in a defrecord?
20:42gfrederickssolussd_: *1 isn't a reader macro, but holds the last result
20:42solussd_cool
20:43gfredericksdoubt there's anything for "replay last form"
20:44tomojer, IPrintWithWriter
20:46SgeoHmm, I guess I should make the "throw two functions together" form of lenses be a deftype rather than a defrecord?
20:48gfredericksSgeo: are lenses some kind of abstract nonsense?
20:48SgeoThey might be somewhat abstract but how are they nonsense?
20:49SgeoAre monads "abstract nonsense"?
20:49Sgeohttp://hackage.haskell.org/packages/archive/data-lens/2.10.2/doc/html/Data-Lens-Common.html
20:49casionmonads are abstract nonsense :P
20:50gfredericksoh this is starting to sound familiar
20:50tomojtry e-prime
20:51gfredericksis it reasonable to aim to spend my time around strange loop finally learning the heck out of some haskell?
20:51gfredericksI would need something non-trivial to do with it
20:51casionwrite a file handling library in it then
20:52SgeoThere's an e-prime form, but it seems abandoned
20:53Sgeo*forum
20:54hiredmanlens are years of researchers trying to write update-in and get-in
20:55xeqimy goto non-trivial programs is a calculator
20:55mmitchellTimMc: Hey there, so the java interop, iterate thingy... I'm still not understanding this syntax: "new Geometry[] { shortLineString, longLineString }" and how you convert that into clojure?
20:55xeqi"1 + 1" -> 2
20:55xeqietc
20:56SgeoWith update-in and get-in can you use a smart selector, let's say, one that ... reverses stuff
20:56xeqimmitchell: that says make an array of two elements, shortLineString and longLineString
20:57xeqiif I remember the java example you're porting, its put directly into a for loop
20:57gfredericks[short-line-string long-line-string]
20:57xeqiso the clojure equiv might be (for [x [short-line-string long-line-string]] ....)
20:57SgeoIn order for get-in and update-in to work, the strucuture needs to recognize the keys. Lenses do not need to be recognized by the structure being retrieved from or modified.
21:02mmitchellxeqi: ok, so isn't it creating an instance of Geometry?
21:03gfredericksmmitchell: it's creating an instance of Geometry[] which is an array of Geometrys
21:03mmitchellgfredericks: ahh! I get it now, thanks.
21:05gfredericks~hurray
21:05clojurebot\o/
21:09gfrederickssingle-bit probabilistic circuits are fascinatingly trivial
21:09SgeoI think maybe the idea of monads should be modified a bit to work better in a Clojure environment
21:10SgeoThere are a lot of Clojure macros and concepts that are similar to various monads, but easier to use.
21:10SgeoIf using monads could result in similar simple macros, that would be ideal.
21:28xeqimaybe they augmented ones should be called marshmellows
21:40Sgeoxeqi, marshmellow burritos?
21:46xeqisattvik: leinjacker 0.2.0 -> trammel 0.7.0 -> thneed 1.0.0-SNAPSHOT = sadness
21:46gfredericksa thneed is a thing that everyone needs
21:48gfredericksthneed must be fogus's useful
21:49Sgeo# thneed
21:49SgeoFIXME: write description
21:49Sgeo## Usage
21:49SgeoFIXME: write
21:50Sgeohttps://github.com/fogus/thneed/blob/master/src/fogus/thneed/cps.clj
21:50SgeoThis could be written to use a function and then the macro just puts its body into a ... hmm, n/m
21:55carkah technomancy, now you're nitpicking for the sake of it
21:55carkcase in point : look at the update-val function at https://github.com/clojure/algo.monads/blob/master/src/main/clojure/clojure/algo/monads.clj
21:56carkit uses (get s key) and really couldn't do it any other way without CL's setf =)
21:58S11001001cark: I think you mean to be talking to me
21:58carkoh !
21:58carkwell you ! with the number name !
21:59carki wouldn't cry bug if my case wasn't well researched
22:00carkand have no fear for double negation =(
22:00S11001001and instead of setf, you use a lens
22:01carki don't know much about these
22:01S11001001cark: essentially it is the pair of getter and updater functions
22:02S11001001cark: here's a quick hack that uses the idea with algo.monads a bit: https://bazaar.launchpad.net/~scompall/+junk/clojure-stuff/view/head:/src/com/nocandysw/cloj_dummy/punch.clj#L13
22:03S11001001cark: and edwardk wrote a tutorial: https://github.com/ekmett/lens/wiki/Tutorial
22:04carki'll be looking at it
22:04S11001001cark: indeed, scalaz has lots of functions for working with lenses directly in combination with states
22:06carki hape reading scala code =( that's one language i never really tried
22:08SgeoOh hey so there's already a lenses library for Clojure?
22:08S11001001Sgeo: not that I'm aware of
22:08SgeoOh, so what's fetch-val?
22:08carkS11001001: I'm wondering why you are so bent on refusing a fix for set-val ?
22:09S11001001Sgeo: a simple function for working with states in algo.monads
22:09Sgeoerm, focus
22:09SgeoAh... hmm
22:09SgeoS11001001, oh, btw, I officially hate m-lift
22:09carkSgeo: haha yes, it's always doing almost what i want too !
22:09SgeoAlthough I shouldn't say anything until I actually _test_ my replacement
22:09carkbut not quite
22:09S11001001cark: you mean fetch-val? For one, I *like* its current behavior, and use it with arbitrary functions in the file I linked above
22:09Sgeohttps://github.com/Sgeo/algo.monads/blob/master/src/main/clojure/clojure/algo/monads.clj#L270
22:10carkS11001001: well then, why not write an additional function that does what you want
22:10carkand keep this one as is
22:10carkas should be i mean !
22:11S11001001cark: because writing your fetch-val as a specialization of the current fetch-val is easier than the other way around, which means that fetch-val as-is is more primitive
22:11carkyou have to admit that there is a logical problem when you consider the rest of the -val functions
22:12SgeoI think a lens library should be independent of a monad library, and provide things to make working with the monad library easier, but not require it
22:12SgeoAlso, that last line I feel like I'm talking in the style of someone I know in a different channel
22:12S11001001maybe, but consistency isn't a good enough reason to lose primacy
22:13S11001001and resolving things with doc updates has a proud history in the clojure community
22:13carkS11001001: I'm sorry, I can't go and use it as it is, because it will be fixed some day. And then the code calling it to work around that bug will need to be rewritten
22:13S11001001cark: I doubt it
22:14S11001001,(let [x (to-array [42]) xv (vec x)] [(xv 0) (do (aset x 0 33333) (xv 0))])
22:14clojurebot[42 33333]
22:14S11001001^^^ solved with a doc change
22:16carkI think your function (the one currently there) should also exist, but it should have another name, or all the -val functions should change name i don't care, it is very possible to both have consistency and what you want
22:16S11001001a more useful enhancement would be to update the other state primitives to work with lenses
22:18carkyou've been using this function in a non documented way, taken advantage of a bug, and now you want to block a fix.
22:19S11001001no, I think the docstring was just wrong, and the fix should be made to the docstring
22:19S11001001that's not "block[ing] a fix"
22:20S11001001anyway I have no such powers; unlike technomancy, I have no position in the clojure community, just an interested programmer
22:20carki don't know how i thought you were him =)
22:20carkanyways !
22:20S11001001sometimes I report things that I think are bugs but get fixed with doc updates instead; sometimes I disagree with that resolution, but such is as it is
22:21carkwhen i look at this function as it is right now, i feel like the guy who wrote it didn't think about all implications not only with this bug, but also with the efficiency thing, and coding standard
22:22S11001001Like technomancy, I have contributed code to lein; there is a significant difference of degree though :)
22:25carknotice also the with-state-field function, it also works with keys of any type
22:26carkbut really, i feel that this whole bunch of functions does not belong in the monad library itself
22:26S11001001probably not
22:27S11001001they aren't terribly useful as-is
22:27carki need to find some tutorial on lenses and check that out .... with haskell rather than ugly scalla =)
22:29S11001001true; edwardk's tutorial linked above is for his relatively new and popular lens library for haskell
22:29S11001001as for algo.monads problems, I find http://dev.clojure.org/jira/browse/TMACRO-1 more pressing
22:30SgeoOh hey maybe I can complain about m-lift there
22:34seancorfieldBugs rarely get fixed without patches, in my experience, unless the library maintainer themselves runs into the same bug repeatedly...
22:34seancorfield(of course, to submit a patch, you have to be a signed up contributor)
22:35SgeoI have a replacement for m-lift
22:35SgeoJust need to actually test it somehow
22:35seancorfieldbut, hey, if a bug is annoying enough that should be incentive to sign & mail the CA :)
22:35S11001001Sgeo: btw the new lens library is "lens", which will probably deprecate "data-lens" at some point
22:36carkhum i won't go the trouble for a 3 line correction...
22:36carkeither a maintainer maintains, or a glaring bug stays in the algo.monad !
22:36Sgeoseancorfield, jimduey has a separate monad library using protocols
22:39casionhow can I improve this, or what concepts could I apply to make it more idiomatic? (besides checking for file end) https://www.refheap.com/paste/4956
22:40S11001001casion: use map and into instead of reduce
22:41casionS11001001: why?
22:41S11001001casion: it's more idiomatic than using reduce, and easier to read
22:42casionhmm ok
22:42casionall the examples of doing I/O I found used reduce, that's why I ended up with that
22:43S11001001casion: probably because they didn't have the forcing guarantee that into will give you
22:43tomojinto is just a shortcut for a particular reduce
22:43S11001001tomoj: a non-obvious shortcut, though
22:43tomojbasically reduce conj but sometimes faster
22:43S11001001casion: the order of preference is pretty much loop/recur last when nothing else works, then reduce, then all the other HOFs or `for' if you're into `for' for whatever reason
22:46seancorfieldcark: i'll bring up ALGOM-4 on clojure-dev and see if anyone objects to me fixing it...
22:46carkseancorfield: thanks !
22:46casionS11001001: would there perhaps be a better way to approach creating a map from an input-stream?
22:46carkhum jduey's protocol based monads has a strange treatment about return
22:47carkcan't write generic monadic code with that
22:47SgeoI should look at it again
22:48carkbasically he says that return is just the constructor for a type, and he's right about it
22:48S11001001casion: your code seems fairly reasonable to me
22:48carkbut then you need to tie your code to a specific monadic value
22:49cark*but then you need to tie your code to a specific type of monadic value
22:49casionS11001001: ok, thank you for the advice
22:49SgeoReturn-type-based polymorphism would be nice (is that the right terminology?)
22:49carkyes
22:50S11001001cark: you should look at semigroupoids too sometime; they're like applicative functors that lack a natural return, so monad without return is called "bind"
22:50carkbut really i don't feel like algo.monad is slow
22:51Sgeocark, I'd imagine the problem with algo.monad is that it's excessively macroic
22:51carkthos you can't go around it
22:51carktho*
22:52carkhow do you invent a do notation without macros ?
22:52Sgeocark, m-lift does not need to be a macro
22:52carkthere is a non-macro version floating around
22:52SgeoThe one I wrote or a different one?
22:52seancorfieldfunctions > macros :)
22:53SgeoAlthough maybe I should make mine be curried automatically
22:53seancorfield(i.e., more composable and generally more usable)
22:53SgeoSo ((m-lift-fn foo) (m-result bar) (m-result baz))
22:53SgeoAlso, I need to test it.
22:55carkseancorfield: we all agree about that i think, but the do notation is really new syntax, that's a good fit for a macro
22:55SgeoI think m-lift is a good example of what happens if you try to translate from Haskell and see that Haskell can't do something and assume that that means the solution is to use a macro.
22:57SgeoHaskell does not have apply.
23:14michaelr525good morning
23:15tolstoyIs there a way to write a plugin that's inside my project for lein2, like you used to be able to do for lein1?
23:19tolstoyHm. Maybe you can add a hook in project.clj?
23:31RaynesSgeo: Is apply even possible in Haskell? With type magic?
23:32Sgeoapply seems like it would be non-type-safe in Haskell
23:32SgeoAlthough, it is possible to have variadic functions with type magic
23:33RaynesHaskell is fun.
23:38S11001001cark: haskell "do" doesn't imply return anywhere
23:39carki didn't say that
23:39S11001001cark: oh, I read "without macros" as "without monads", sorry :]
23:39cark=)
23:41carki watched Edward Kmett's talk about lenses (lots of scala to read =( )
23:41carklooks like it can solve a problem of mine
23:42carki'm trying to have a very large data structur and maintain it in a purely functional way
23:43carkbut there are points where some collection has to have the same values that are in other collections
23:43carkso i need to make some of these values, references to others
23:44carkbut in a purely functional way
23:44carkit looks like lenses are all about that
23:49S11001001lenses must be applied in relation to some context
23:50carkright, stick eveery entity in an id-map, and provide lenses into the id-map to all entities that refer to other entities
23:50carksounds right ?
23:51S11001001seems okay, but at that point, what's wrong with just putting the ids in the colls?
23:52S11001001(I haven't done anything more sophisticated than safe update-in replacement with them at this point, so can't be much help with things above that)
23:52casionS11001001: I have it implemented and your suggestion was fantastic. thank you again.
23:52S11001001casion: no prob
23:53carkI am currently putting id in those collections, but i like the idea of having a kind of reference there instead of just an integer
23:54S11001001well, as it happens, anything that is a map key also qualifies as a map lens :)
23:54carkindeed
23:56carksee my problem is kind of like this : i have a country which is a map from social security number to people, then i have a list of houses, each house has a list of name to people ... how do i go about updating a person's hair color
23:56carkeach house could also have a country
23:57carkso now it gets quite hairy
23:57carkif working in a purely functional way
23:57carkso i decided to stick everything in a map from id to entity
23:58carkbut 2 things are bothering me
23:58S11001001you also have sequence item lenses, and lenses are morphisms so can be composed end-to-end
23:59S11001001indeed update-in is just map map-lens followed by a composition fold, then using that lens for the update
23:59carkright, i watched the talk, it looks great to go down the tree