#clojure logs

2014-09-13

00:00justin_smithand of course, that really means the general programming style that works with immutibility
00:00caternlearning that value has made programming in mutable languages *more* painful!
00:00justin_smithwhy? why not just program immutibly in whatever language?
00:00justin_smithin clojure, you can still need to touch mutible state or APIs in the jvm
00:01justin_smiththough its true you will find less immutible infrasctucture, some stuff isn't so hard to adapt
00:03ToxicFrogSo I have the following form: (some-> (:name x) (.equalsIgnoreCase (:name y)))
00:03ToxicFrogI want to eliminate reflection, and know that (:name x) and (:name y) have type String.
00:04ToxicFrogWhere do I put the ^String annotations?
00:04ambroseb_(let [^String a (:name x)] (some-> a ....))
00:04ToxicFrog(rather, I know that (:name y) has type String and (:name x) is either a String or nil, but if it's nil the some-> will never get around to making the method call anyways)
00:04justin_smithToxicFrog: this code may be clearer without the some-> form if annotated
00:06ToxicFrogambroseb_: aah. The docs say that type hints can be placed on "expressions" as well as parameters, var-names and let-names, but isn't really clear on how you do that.
00:06ToxicFrogSo I was hoping I could attach the ^String to (:name x) directly somehow.
00:06ambroseb_ToxicFrog: mm it's an art
00:06ambroseb_:)
00:06ambroseb_ToxicFrog: especially when you're passing nil ...
00:07ToxicFrogActually, looking at it, I'm not sure I am passing nil. The some-> may be a holdover from an earlier version.
00:31michaniskinis it possible to have nested nrepl clients?
00:31michaniskinlike if i have a repl session going can i attach to another nrepl server
00:32justin_smithmichaniskin: yeah, I would be surprised if it did not work, via clojure.tools.nrepl
00:32michaniskini must be doing something wrong, it disconnects me from the current session
00:33justin_smithhrm - I would think it would be re-entrant
00:33ToxicFrogDear god the type signature on every?
00:33justin_smithhaha, I can only imagine
00:33ToxicFrogI was expecting something like [(Seqable Any) -> Boolean]
00:33ToxicFrogInstead it's (All [x y] (IFn [(IFn [x -> Any :filters {:then (is y 0), :else tt}]) (Coll x) -> java.lang.Boolean :filters {:then (is (Coll y) 1), :else tt}] [(IFn [x -> Any :filters {:then (is y 0), :else tt}]) (U (IPersistentCollection x) nil) -> java.lang.Boolean :filters {:then (is (U (IPersistentCollection y) nil) 1), :else tt}] [(IFn [x -> Any]) (U (Seqable x) nil) -> java.lang.Boolean]))
00:34justin_smithwoah
00:34ToxicFrog(why am I looking at this? Because core.typed doesn't come with type annotations for clojure.core/not-any?)
00:35ToxicFrog(so I figured I'd check every?, which I thought would have the same type)
00:35ToxicFrog(I'm not so sure anymore)
01:15ToxicFrogjustin_smith: so it turns out to be a lot more readable if you run it through pprint and ignore the filters.
01:16ToxicFrogI am a bit confused as to why it has three signatures, though -- one taking (Coll x), one (U (Seqable x) nil), and one (U (IPersistentCollection x) nil)
01:27ToxicFrogArgh. It's complaining that String/contains can't be applied to arguments (U String nil), but String implements CharSequence and the code in fact runs fine
01:27ToxicFrogmaybe this will make more sense in the morning
02:39dorkmafiahttp://paste.debian.net/120653/ how come that doesn't work? I also tried {:libpaths [["python/"]["skype4py/Skype4Py/"]] } but {:libpaths ["python/"]} working?
02:40dorkmafia/ing/d
06:45dagda1is there anything similar to respond_to? in clojure that will let me know if a datatype has a method or am I thinking about this all wrong
06:45justin_smithdagda1: you can use clojure.reflect/reflect to get all slots and methods on an object
06:46dagda1justin_smith: thanks
06:46justin_smithor you can use instance? / isa? to see if it implements the protocol or interface defining that method
06:46justin_smiththat's less expensive, but also less reliable
07:00papachanhi
07:01papachani would like conj a map {} with doseq because i need to iterate each key value of another map
07:01papachani was thinking something like this, but obviously it doesn't work
07:01papachanhttps://code.stypi.com/papachan/conj.clj
07:32milos_cohagenpapachan: if you want to create a new map, from an old map, with some transformations in between, you can use reduce perhaps
07:32milos_cohagen,(reduce (fn [m [k v]] (assoc m k v)) {} {:a 0 :b 1})
07:32papachanmilos_cohagen thank you i will try with reduce
07:32clojurebot{:a 0, :b 1}
07:33milos_cohagendoXXX functions are mostly for performing side effects, like mutating something, printing something, etc
07:34milos_cohagenclojure functions like conj or assoc or "pure", no side-effects
07:35milos_cohageni mean "are pure" not "or pure"
07:37papachanmilos_cohagen ok it does the same think when i am using conj
07:41milos_cohagenpapachan would be happy to take a look if you post a snippet
07:43papachanmilos_cohagen,
07:44papachanhttps://code.stypi.com/papachan/snippet.clj
07:49milos_cohagenpapachan thanks but from that repl session i'm having a hard time interpreting your goal. what are the requirements of params-parser
07:51papachanmilos_cohagen i am receiving a params {:model "android" :version "1.2.1"}
07:52milos_cohagenok
07:52papachanneed to put it in a session cookie structure
07:52papachanas at final
07:52papachanand assoc with the actual session cookie
07:54papachani was working with do seq but its not the result: it executed each times it detect a keyword
07:55milos_cohagenok so, we want a function f which accepts two maps as arguments a and b. (defn f [a b] ..)
07:55milos_cohagenmap "a" keys and vals should be added in someway to map "b"?
07:57milos_cohagenand an updated version of map "b" should be returned?
07:57papachanyes i was trying with your reduce code, but still don't understand how i recur each keywords to make a new map structure
07:57papachanshould return the final at my snippet but not repeated
08:01milos_cohagenok so we do (defn f [a b] ...), the ... could be a reduce form, so we say (defn f [a b] (reduce reduce-fn b a))
08:01papachanok
08:03milos_cohagenreduce-fn accepts two args, the accumulated vale, which starts with "b", and second arg is the first k,v of "a", and should return the new accumulated value
08:04milos_cohagensorry hard to explain, i can't just write the answer for you because your examples don't show what "a" and "b" values look like exactly with exact desired output
08:06papachanmilos_cohagen i am trying to make something work. will try your example
08:17milos_cohagengood luck!
08:30kqrcan I somehow figure out the type of an object I have in my clojure program? it exhibits some interesting properties and I'd like to know what it is
08:30kungiI am trying to test my core async code but the test finishes with the report before the assertations in the go-blocks had a chance to run
08:31kungiIs there an asynchronous testing helper for clojure.test?
08:31kungikqr: class maybe what you want
08:31kungi,(class "")
08:31clojurebotjava.lang.String
08:31kqrkungi, yes I did, thanks
08:32kqrit's just a java.io.File
08:32kqrinteresting!
08:54kqrdoes anyone know why I get the exception: http://lpaste.net/2155899009351286784 ? even though according to javadocs one of the copy methods take two paths as arguments?
08:55kqr...wait
08:55kqrclojure has a copy function?
08:55kqrjust maybe i should use that instead
09:00kqrbut that fails too
09:00kqrhm
09:01kungikqr: https://clojure.github.io/clojure/clojure.java.io-api.html
09:01kqrwho woulda thunk copying files would be so difficult on the jvm :D
09:01kungikqr: there is also a copy function
09:01kqri saw that
09:01kqrbut if I try to (clojure.java.io/copy (File. "t1.txt") (File. "t2.txt")) it complains about one of them not being a var
09:02kqrif I assign them to variables before doing the call I get an IllegalArgumentException in multimethod "do-copy"
09:02ToxicFrogkqr: re Files/copy: is it possible that the reflector is finding the wrong method for it?
09:03ToxicFrogThere's a bunch of different versions of copy, including one that takes (Path OutputStream) and one that takes (Path Path); if it's only finding the former, there's your problem
09:03kqrhttp://lpaste.net/4103219378718244864
09:03kqrfull version of the error I get with the clojure-native copy function
09:04kqrToxicFrog, yeah, that's what I suspected... but I don't know how I can make it find the other one
09:05ToxicFrogkqr: hmm. I tried adding type annotations to mark both src and dest as ^Path but that didn't work :/
09:06kqrweird
09:07ToxicFrogOh, I see, reading the docs on java interop it looks like type hints help it on resolving the type of this when making method calls but no mention is given of resolving arguments in overloaded functions
09:07kqrwell
09:07kqr(clojure.java.io/copy (clojure.java.io/file "t.txt") (clojure.java.io/file "t2.txt")) works
09:08kqreven though clojure.java.io/file according to docs passes the argument straight to java.io/File
09:10ToxicFrogkqr: ok, but that's expected?
09:10ToxicFrogLook at the docs: "Input may be an InputStream, Reader, File, byte[], or String."
09:10ToxicFrogclojure.java.io/copy supports Files but not Paths
09:11kqrToxicFrog, shit yeah you're right
09:11kqrToxicFrog, I thought my variables source and dest were files, but they are paths
09:11kqrToxicFrog, thanks
09:12kqrthey were files for the longest time, then I made them into paths before asking here :)
09:15ToxicFrogHuh. I must not understand how to set type hints.
09:15ToxicFrogI thought they were stored in the metadata, but:
09:15ToxicFroguser=> (let [^Path p (.toPath (File. "/etc/passwd"))] (meta p))
09:15ToxicFrognil
09:16kqri thought so too
09:28ToxicFrogHuh.
09:28ToxicFrogOk, so if I use with-meta, everything works fine
09:28ToxicFrogIf I use the ^ macro, no metadata is applied
09:28ToxicFrogOh. Because I'm using it in the wrong position.
09:28ToxicFrogasdfh
09:35kqrhaha
09:36ToxicFrogBut it still doesn't work with Path!
09:36ToxicFrogaaaaaaaaagh
09:36ToxicFroguser=> (def x ^int {}) (meta x)
09:36ToxicFrog{:tag #<core$int clojure.core$int@12a133b2>}
09:36ToxicFroguser=> (def src ^Path (.toPath (File. "/tmp/foo"))) (def dst ^Path (.toPath (File. "/tmp/bar"))) (meta dst)
09:36ToxicFrognil
09:57kqris there a way to store some information about my application in a separate file? i'm trying to create a web app, and both ragtime and korma wants information about the database but in separate formats
09:58kqrand i'd rather not commit the details of the database to the repo
09:58rweir_I've used https://github.com/weavejester/environ pretty happily
09:58rweir_which doesn't help with getting the stuff into your libraries, but it does do the 'what are the values' bit
10:00kqrI just now realised that project.clj is a normal clojure file
10:00kqrthat certainly helps
10:01rweir_yeah
10:01rweir_think carefully about how much magic you put in there though
10:03kqrwell ragtime wants a jdbc url, so somehow I need to convert the db details into a url
10:03kqris that too much magic?
10:03rweir_ah
10:03rweir_I'd probably do that in my real-code instead of project.clj, but I don't have a strong opinion either way :)
10:03kqrhow'd that work?
10:04kqrwhat I'm imagining is a file that simply contains a map with host, db name, username and password
10:04rweir_ie do at the point where you first interact with ragtime [I've not used it, so apologies if that's a stupid answer]
10:04kqrand then project.clj *and* src/db/schema.clj must use that information
10:04kqrthe first interaction with ragtime is in the project.clj file
10:04rweir_oh, interesting
10:04kqror rather, that's where you're supposed to tell it which database to use
10:05rweir_ah, I see [looking at the docs]
10:05kqrthe broader context is that I'm trying to learn the luminus framework
10:05kqrI find it as confusing as the next guy
10:20dagda1is there a way to find the common elements in 2 vectors?
10:21zotconvert to set and do intersection?
10:47gfredericksanybody know what's up with marmalade?
10:51Raynesgfredericks: Everything sucks.
10:52gfredericks(inc Raynes)
10:52gfredericksa few of my packages aren't available after removing marmalade from my list
10:57gfrederickslazybot being gone is symbolic of everything being broken this morning
10:58Bronsait's not like lazybot being gone is a first
10:59Raynesyou know what
11:00RaynesFuck it
11:00justin_smithBronsa: that's the difference between FUBAR and SNAFU
11:00RaynesIT'S THE ONLY WAY TO BE SURE
11:00hyPiRionRaynes: Have a supervisor on it?
11:00hyPiRionget mail every time it crashes
11:01BronsaRaynes: <3
11:01RayneshyPiRion: I'd love for it to be as simple as monitoring it, but it's not quite that easy.
11:01RayneshyPiRion: When lazybot dies his process almost never dies.
11:01hyPiRionRaynes: oh, right
11:01RaynesHe is designed in such a way that if he can't talk to one IRC he doesn't really care that much
11:01RaynesThe problem is he can't tell when he can't talk to ANY irc :P
11:02justin_smithRaynes: I assume it also has to detect and act on disconnects fro mthe server
11:02RaynesIt does not.
11:02hyPiRionIt's the "100% CPU time after server disconnect"-bug?
11:02RaynesUses an ancient unmaintained version of irclj that doesn't handle disconnects at all, really.
11:02RaynesNah, he just loses connection and can't do anything about it
11:02RaynesSo he sends pings every now and then
11:02hyPiRionah, haha
11:02RaynesHoping for an answer
11:02RaynesIt's quite sad really
11:02RaynesLet me put the kid out of his misery
11:03justin_smithyou could make him close the connection and reconnect every half hour
11:03justin_smithlol
11:03RaynesThat's srs engineering right there
11:03hyPiRionWell, if anyone has nothing to do in their sparetime, they could patch up poor lazybot
11:03RayneshyPiRion: Step one: use newer half-assed irclj implementation.
11:03RaynesStep two: figure out it needs to be less half assed, make it less half assed
11:03RaynesStep three: #win
11:04hyPiRionRaynes: I was talking about step two mostly
11:04hyPiRionimplement proper irclj
11:04RaynesThe newer irclj is pretty solid
11:04RaynesI don't think it actually lacks much of anything lazybot would need.
11:08gfredericksRaynes: so a vigorous manual restart tends to fix transient problems?
11:08Raynesgfredericks: It doesn't actually go down that much.
11:08gfredericksbut when it does that fixes it?
11:08RaynesWell yes, because the only 'problem' is usually just that it has lost connection for one reason or another.
11:09RaynesBirds sitting on power lines and shit.
11:09RaynesNormal stuff.
11:09RaynesIrclj needs handling for connection loss and lazybot needs new irclj after that.
11:09RaynesThen he will be legion without my help.
11:09gfredericksthe hipchat bot I run at work is run in a bash loop that kills/restarts every ten minutes
11:10RaynesSounds like an average Python program.
11:10justin_smithgfredericks: that was my "joke" suggestion
11:10gfredericksit has the advantage that it's easy to do :P
11:10RaynesHey
11:11RaynesCould be like "Hmmmmmm... Nobody has said anything on any of these 40 channels I'm in in the past half hour..."
11:11Raynes"I... guess I should kill myself now?"
11:11Raynes"(System/exit 0) ; goodbye cruel world"
11:12justin_smithRaynes: sounds like my ex having a bpd attack
11:13justin_smithRaynes: isn't there an IRC protocol level thing for checking if you are connected?
11:13Raynesjustin_smith: What's the first thing they do to a robot at the doctor's office?
11:13RaynesTHEY CHECK HIS BYTLES.
11:14Raynesjustin_smith: Well, ideally your socket realizes nothing's popping out the other end, but you can send PINGs to the server and if you do not get a response in a timely manner you can assume you're lost in interspace.
11:14justin_smithRaynes: like every half hour he could run /msg nickserv listchans
11:14justin_smithor just that
11:14RaynesIRC is super async.
11:15justin_smithright, distributed, async
11:15RaynesIt's real hard to be like "gimme a list of channels" and then say "oh, here's my list of channels"
11:15RaynesYou kinda have to send 'gimme a list of channels' off into the void and then receive the response from the void.
11:15gfredericksso srsly should I expect marmalade to be down for a long time?
11:15RaynesThe problem is six other commands could return before that one, despite your ordering :P
11:15Raynesgfredericks: It's marmalade. Expect it to never come back up.
11:15justin_smithRaynes: reminds me of my experiments with mud scripting
11:16justin_smithbasically you need multiple state machines ready to be triggered or finalized, because who knows which part of your logic a given message may be destined for
11:16gfredericksI need to give up on emacs package managers and just maintain a personal collection of .el files, don't I?
11:17justin_smithgfredericks: technomancy seems fond of el-get
11:17gfrederickswhat's that? another package manager?
11:17justin_smithhttp://www.emacswiki.org/emacs/el-get
11:17gfredericksmy current problem is that some of my packages are only in this one repo that Raynes said will never come back
11:17xeqigfredericks: I'm going to guess its maintained by one person, so yes
11:18justin_smithgfredericks: above link has a "why have both" rationale (up to you whether it's reasonable or not, of course)
11:18gfredericks"Think apt-get for emacs"
11:18Raynesgfredericks: It is way too early and I'm way too bitter to say one single useful non-silly thing right now.
11:19gfredericksRaynes: it's like 10am amirite
11:19RaynesI woke up at 7AM
11:19RaynesDidn't even get to go to the toilet before having to solve crisises.
11:19gfrederickswaking up at 7am is sleeping in for me
11:19RaynesWaking up at noon is sleeping in for me.
11:20gfredericksI woke up at 8am today and that was *highly* unusual
11:23gfrederickswho is going to stramg lop
11:24justin_smithbizzaro justin am going stramg lop thisy ear
11:24justin_smith(not actually going to strange loop)
11:26gfredericksdoes cider have a buffer-local current-ns variable?
11:27gfredericksI was looking at my 0.5.0 source and it seemed to mostly just infer based on an initial (ns ...) form, which doesn't help my org-babel uses
11:28gfredericksI see nrepl-client.el has (defvar-local nrepl-buffer-ns ...)
11:32justin_smithgfredericks: edebug is an awesome stepping debugger, that shows you the result of every form as it is evaluated, by the way
11:34gfredericksjustin_smith: thanks; I'm still n00b enough that extra tools are likely to just layer confusion
11:37allendoes anyone know of a plugin that allows me to load clojar or external libraries from within a lein repl
11:37allensimilar to https://github.com/rkneufeld/lein-try
11:38allenexcept have the ability to load different libraries as we go with the flow
11:38Rayneshttps://github.com/cemerick/pomegranate
11:38xeqialembic
11:39allenRaynes, beautiful. Thanks
11:39allen(inc Raynes)
11:39lazybot⇒ 51
11:39gfrederickshi lazybot
11:39RaynesWhatever is at the top of the inevitable 1200 libraries on top of pomegranate I guess
11:40gfredericksgimme uses fireflox uses alembic uses pomegranate so if you're not using gimme you're basically losing
11:41RaynesIt looks like alembic doesn't use pomegranate?
11:41RaynesWhich is horrifying
11:41xeqiit does
11:41gfredericksI use pomegranate, with a helper: https://github.com/gfredericks/repl-utils/blob/master/src/com/gfredericks/repl.clj#L12-18
11:41Raynesxeqi: Oh, a transitive dep?
11:41RaynesLovely
11:41xeqiI think through lein-as-resource
11:42hugoduncanwhich is woefully out of date
11:43mantas$ lein run [11:39:52]
11:43mantasException in thread "main" java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to clojure.lang.Keyword, compiling:(caffeinate/web.clj:1:1)
11:43mantasline one is simple: (ns caffeinate.web
11:43mantasany explanation as to why this happens?
11:43RaynesWell, I'd close that for starters.
11:43justin_smithallen: pallet/alembic is easier to use than pomegranate
11:44RaynesLine one is a red herring, mantas. Please show us your whole ns form
11:44allenok cool, i'll check out all three
11:44xeqimantas: through the magic of macros, line 1 is basically everything in the (ns ..) form
11:44allenohh nvm alembic is developed by pallet
11:44RaynesIs pomegranate difficult to use? O.o
11:45xeqiRaynes: well, you do have to pass the repositories. and if you have mirrors...
11:45justin_smithRaynes: alembic uses the project.clj dep syntax, and is automatically recursive
11:45hugodalembic keeps pomegranate off your project's classpath
11:45justin_smithand you don't need to specify repos at all
11:45xeqihugod: does alembic keep track of what is already been distilled?
11:45xeqito avoid different distilled calls bring in conflicting deps?
11:46hugodxeqi: it checks what is already loaded in the clsspath
11:46hugodand warns on conflicts
11:46RaynesWell, clearly alembic is the best thing since sliced ham.
11:46justin_smithxeqi: alembic, in my experience, does not import things if some other version is already imported
11:46xeqiright, I thought it had something that way
11:46justin_smithRaynes: I found it much easier to use compared to pomegranate
11:46RaynesI understand
11:48zeebrahi'd like to trace a function for debugging. is it doable?
11:48justin_smithzeebrah: tools.trace
11:48justin_smithhttps://github.com/clojure/tools.trace very easy to use
11:49zeebrahjustin_smith: cheers
11:50zeebrahthis isn't quite what i had in mind. i was hoping for a CL like trace :(
11:51justin_smithzeebrah: tracing the execution of the function?
11:51zeebrahyep
11:52justin_smithzeebrah: I hear tell cursive clojure (it's an intellij idea plugin) has good step debugging, but have not actually tried it myself
11:53zeebrahjustin_smith: actually wait, trace-ns is kinda cool and does the job :)
11:54justin_smithzeebrah: it doesn't get you the step by step internals though, but I guess it gets you your helper functions
11:55justin_smithon a more insane end of things, you can use jdb to trap and step and interact with the stack on the byte code level
11:55justin_smithbut if trace-ns suffices, cheers :)
11:55zeebrahjustin_smith: thanks for the help :)
11:56justin_smithnp
11:57kungiI would like to have an atom containing a map of key -> #set pairs. How do I append to such a structure? When the #set belonging to a key is empty it is easy, but how do I append to an existing set in a map with a swap! operation?
11:58justin_smith,(swap! (atom {:numbers #{0}}) update-in [:numbers] conj 1 2 3)
11:58clojurebot{:numbers #{0 1 3 2}}
11:58justin_smithdefinitely looks weird, as both swap and update-in take their args just stacked on the end without parens
11:59kungijustin_smith: yes it does :-)
11:59kungijustin_smith: Can I add a non existing key that way?
11:59gfredericksit's fun once you get the hang of it though
11:59gfredericksyes
11:59kungi,(swap! (atom {:numbers #{0}}) update-in [:blubber] conj 1 2 3)
11:59clojurebot{:blubber (3 2 1), :numbers #{0}}
11:59kungiAwsome!
11:59justin_smithkungi: you need fnil for that if it needs to be a set
11:59gfredericks(fnil conj #{}) instead of conj
12:00justin_smith,(swap! (atom {:numbers #{0}}) update-in [:blubber] (fnil conj #{}) 1 2 3)
12:00clojurebot{:blubber #{1 3 2}, :numbers #{0}}
12:00mantashuh, thanks! yes, the issue was later in the (ns... ) declaration. i didn't know macros had this effect.
12:01kungijustin_smith: Thank you
12:01justin_smithnp
12:02gfredericks,(def my-atom (atom {:foo [1 2 3]}))
12:02clojurebot#'sandbox/my-atom
12:02gfredericks,(swap! my-atom update-in [:foo 0] dec)
12:02clojurebot{:foo [0 2 3]}
12:03gfredericks,(swap! my-atom update-in [:foo 0] + 42)
12:03clojurebot{:foo [42 2 3]}
12:19allendate
12:21iartarisiHello, I'm using Korma and trying to restrict the number of fields from a select query. I'd like to get SELECT games.white_id FROM games; but I get all the fields *plus* white_id instead:
12:21iartarisi(dry-run (select games (fields :white_id)))
12:21iartarisidry run :: SELECT "games"."stones", "games"."white_id", "games"."black_id", "games"."white_id" FROM "games" :: []
12:21iartarisi
12:22iartarisiI have the latest korma: 0.4.0
13:10ShoopWhats the best way to turn ((1 1) (2 2)) into [[1 1] [2 2]]?
13:11shosti,(vec (map vec '((1 1) (2 2))))
13:11clojurebot[[1 1] [2 2]]
13:12justin_smith,(mapv vec '((1 1) (2 2)))
13:12clojurebot[[1 1] [2 2]]
13:16ShoopThanks :D
13:18ShoopIs vec the same as #(apply vector %)?
13:19justin_smith$source vec
13:19lazybotvec is http://is.gd/GCHYnT
13:20Shoopnot literally but conceptually
13:20justin_smithinterestingly, if you supply an array as the argument, it aliases it, and you break the contract of vectors if you later modify the array
13:23justin_smithwhere vector will not do anything like that
13:27Jaoodcider needs some keep-alive method
13:42gfredericks,(def argh (into-array [0 1 2 3 4]))
13:42clojurebot#'sandbox/argh
13:42gfredericks,(seq argh)
13:42clojurebot(0 1 2 3 4)
13:42gfredericks,(def vee (vec argh))
13:42clojurebot#'sandbox/vee
13:42gfredericks,vee
13:42clojurebot[0 1 2 3 4]
13:42gfredericks,(aset argh 2 :hehe)
13:42clojurebot#<ArrayStoreException java.lang.ArrayStoreException: clojure.lang.Keyword>
13:42gfredericks,(aset argh 2 42)
13:42clojurebot42
13:42gfredericks,vee
13:42clojurebot[0 1 42 3 4]
13:43gfredericks,(doc vec)
13:43clojurebot"([coll]); Creates a new vector containing the contents of coll. Java arrays will be aliased and should not be modified."
13:43gfrederickswelp can't say it didn't warn you
13:43gfredericksdoes it do that even for large arrays?
13:44gfredericks,(def argh (into-array (range 100000)))
13:44clojurebot#'sandbox/argh
13:44gfredericks,(def vee (vec argh))
13:44clojurebot#'sandbox/vee
13:44gfredericks,(aset argh 0 42)
13:44clojurebot42
13:44gfredericks,(take 10 vee)
13:44clojurebot(0 1 2 3 4 ...)
13:45justin_smithfascinating
13:45gfredericksit'd have to break it up at some point anyways; might as well be immediately
13:45justin_smithso maybe "will be" should say "can be"
13:45gfredericksright :)
13:46gfrederickswe need a variant of the word "modify" for talking about immutable data structures
13:47gfrederickshow about "schmodify"
13:47gfredericksor "schmutate"
13:47justin_smithelaborates?
13:47gfredericksyeah?
13:47justin_smithexponunds upon
13:47justin_smitherr, expounds upon
13:47gfredericksnot really a good analogy from normal life
13:51jjl`hi all. I'm writing some clojure that will need to be usable from java. what's the simplest way of writing test cases in java within a clojure project?
13:51gfredericksjjl`: test cases for automated testing?
13:51jjl`yes
13:51gfredericksleiningen has an option for specifying the location of java sources
13:52gfredericksI guess the rest of the answer depends on how you want to execute/launch the tests
13:52gfrederickse.g., do you mind writing tests in clojure that call your java code?
13:52gfredericksor do you need a java test framework?
13:53jjl`i think okay with the former, provided the java test harness doesn't get shipped in the final jar
13:53gfredericksyeah, leiningen lets you distinguish between dev stuff and final-package stuff
13:54jjl`okay. do you know which project.clj keys i'll need to read up on?
13:56gfrederickscheck the sample.project.clj file in the leiningen repo; they'll be one called :java-source-path or something similar
13:57gfredericksthen try writing a test with clojure.test that runs your java code
13:57jjl`yeah, i just found that. presumably :exclusions is the other one i need?
13:57gfredericksor first you could try `lein run -m MyClass`
13:57gfrederickswhich I think works
13:57gfredericksjjl`: if you put it in the :dev profile then you don't need to exclude anything
13:57gfredericks:profiles {:dev {:java-source-paths ...}}
13:57jjl`oh, handy :)
13:58jjl`thanks :)
13:58gfredericksnp
14:28nkozoI start a "lein repl" and then connect from emacs using cider, now if a Thread prints to *out* (using the timbre logging library) only the "lein repl" prompt shows the output, the cider nrepl session doesn't show it. Why? How you can print to both?
14:44gfredericksnkozo: um.
14:44gfrederickswhen you say "a Thread" I assume you mean not the thread you're using directly from cider
14:49gfredericksI think I know what all the pieces involved are, I just don't know what the best approach is
15:17ultranapoletanociao
15:17ultranapoletano!list
15:27jjl`is there a way of building an abstract class member in clojure? i need it for some java interop and i'd be loathe to write it in java
15:30gfrederickswhat's an abstract class member?
15:31jjl`an abstract method
15:31gfrederickswhat would that look like in java?
15:32jjl`abstract class Foo { abstract void bar(); }
15:32gfredericksI'm curious what sort of java interop that's useful for
15:34jjl`Basically I'm building something where arbitrary objects will be passed around because of dynamic typing. All lovely and fine in clojure, but in javaland, you need type safety. I'd like a generic callback mechanism a la Callable, but different
15:35gfrederickswhy not an interface?
15:36jjl`because an interface doesn't permit you to enforce a given constructor
15:37gfrederickswelp I don't know of any way to do abstract stuff in clojure; it doesn't sound like it'd be intolerable to write it in java
15:38jjl`no, indeed, it's not that much hassle, it's just i'd prefer to keep as much in clojure as possible
15:45arohneris #datomic logged anywhere?
15:46TEttingerarohner, it would be kinda ironic if the channel for a database wasn't logged in some database
15:46arohnergoogle doesn't seem to know about it
15:47redblackbitany idea why (meta ^:foo 'bar) return nil while the documentation states that: Symbols and collections support metadata
15:48TEttinger,(meta ^:foo +)
15:48clojurebotnil
15:48TEttinger,(meta +)
15:48clojurebotnil
15:48TEttingerhm
15:49TEttinger,(meta inc)
15:49clojurebotnil
15:49TEttingermight need var-quote
15:49redblackbitright
15:49arohner+ resolves to the fn
15:49arohner,(meta #'+)
15:49clojurebot{:added "1.2", :ns #<Namespace clojure.core>, :name +, :file "clojure/core.clj", :inline-arities #<core$_GT_1_QMARK_ clojure.core$_GT_1_QMARK_@6e4c32>, ...}
15:49redblackbitbut why doesn’t it work with a symbol?
15:49TEttinger,(meta ^:foo #'bar)
15:49clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve var: bar in this context, compiling:(NO_SOURCE_PATH:0:0)>
15:50arohner,(meta (with-meta 'bar {:foo true}))
15:50clojurebot{:foo true}
15:50gfredericksredblackbit: it's because of what ' does
15:50TEttingermaybe ^:foo isn't evaluated until the form is done?
15:50gfredericks,(meta ^:foo (quote bar))
15:50clojurebotnil
15:50gfredericks,(meta (quote ^:foo bar))
15:50clojurebot{:foo true}
15:50gfredericksredblackbit: your code is equivalent to the first of those two ^
15:51redblackbitgfredericks: oic
15:51gfredericksalso there is:
15:51redblackbitgfredericks: makes kinda a pain to attach metadata to symbols though
15:51gfredericks,(with-meta 'bar {:foo true})
15:51clojurebotbar
15:51gfredericks,(meta (with-meta 'bar {:foo true}))
15:51clojurebot{:foo true}
15:54redblackbitgfredericks: anyway, thx!
15:54gfredericksnp
16:11danielszmulewiczQuestion to the emacs power users: I'm writing a minor mode that makes sense only with clojurescript files, however, there is no clojurescript-mode hook. Any ideas?
16:16gfredericksis there a clojurescript-mode?
16:23danielszmulewiczgfredericks: People have written their own, but now with cider and the official stack. Anyway, I posted an issue on cider's github.
16:41noncom,(.getConstructor (java.lang.Class/forName "java.util.ArrayList"))
16:41clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: No matching field found: getConstructor for class java.lang.Class>
16:42noncom^^^ why is it searching for the constructor in class Class ? why does not it looking for the constructor in class ArrayList ?
16:46dbaschnoncom: you’re calling a method that doesn’t exist
16:47dbasch: ,(.getConstructors (java.lang.Class/forName "java.util.ArrayList"))
16:47dbasch&(.getConstructor (java.lang.Class/forName "java.util.ArrayList"))
16:47lazybotjava.lang.IllegalArgumentException: No matching field found: getConstructor for class java.lang.Class
16:47dbasch&(.getConstructors (java.lang.Class/forName "java.util.ArrayList"))
16:47lazybot⇒ #<Constructor[] [Ljava.lang.reflect.Constructor;@b3cde94>
16:48dbasch&(first (.getConstructors (java.lang.Class/forName "java.util.ArrayList”)))
16:48lazybotjava.lang.RuntimeException: EOF while reading string
16:49dbasch&(first (.getConstructors (java.lang.Class/forName "java.util.ArrayList")))
16:49lazybot⇒ #<Constructor public java.util.ArrayList(java.util.Collection)>
16:55noncomdbasch: thanks!
17:12raspasovhi everyone
18:21onielfaHello, I have a stupid problem. When trying to use println like (println "Hello") in the REPL, I got a java.lang.NoSuchMethodError. Am I missing something?
18:22hyPiRiononielfa: `lein downgrade 2.4.2`
18:23hyPiRionwe're working on it, there's a bug in latest stable =/
18:23onielfahyPiRion: Thanks a lot! I am going to downgrade :)
18:25onielfahyPiRion: It works now :) Let's continue learning Clojure, thanks!
18:25hyPiRiononielfa: no problem =)
20:48Bronsait's kind of unfortunate that disj only works on sets and not on maps
20:59gfredericksBronsa: so (disj {1 2} [1 3]) would return {1 2}?
21:01Bronsagfredericks: yeah, disj and dissoc have the same function signature
21:02gfredericksBronsa: huwhat? dissoc doesn't take a value
21:02Bronsagfredericks: wat
21:04Bronsawhat I'd like is for disj to be (defn poly-disj [m & args] (apply (if (map? m) dissoc disj) args))
21:06gfredericksBronsa: so then you lose the conj/disj symmetry
21:06Bronsano? the opposite
21:06gfredericksthe symmetry being the type
21:06Bronsaright now disj only works on sets
21:06gfredericks,(defn poly-disj [m & args] (apply (if
21:06gfredericks (map? m) dissoc disj) args))
21:06clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
21:06raspasov_yea conj works on everything
21:06gfredericks,(defn poly-disj [m & args] (apply (if (map? m) dissoc disj) args))
21:06clojurebot#'sandbox/poly-disj
21:07gfredericks,(-> {} (conj [1 2]) (disj [1 2]))
21:07clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.IPersistentSet>
21:07gfredericks,(-> {} (conj [1 2]) (poly-disj [1 2]))
21:07clojurebot[1 2]
21:08gfredericks,(-> #{} (conj [1 2]) (ploy-disj [1 2]))
21:08clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: ploy-disj in this context, compiling:(NO_SOURCE_PATH:0:0)>
21:08gfredericks,(-> #{} (conj [1 2]) (poly-disj [1 2]))
21:08clojurebot[1 2]
21:08gfrederickswat
21:08gfredericks,(defn poly-disj [m & args] (apply (if (map? m) dissoc disj) m args))
21:08clojurebot#'sandbox/poly-disj
21:08gfredericks,(-> {} (conj [1 2]) (poly-disj [1 2]))
21:08clojurebot{1 2}
21:08gfredericks,(-> #{} (conj [1 2]) (poly-disj [1 2]))
21:08clojurebot#{}
21:08gfredericksBronsa: ^ that is the mismatch I'm referring to
21:09gfredericks(had to fix a boog in your poly-disj)
21:09Bronsayeah sorry for the typo :(
21:10Bronsagfredericks: I honestly don't see how what you're trying to say
21:10Bronsasticking a key/value pair in a disj doesn't make any sense
21:10gfrederickswrt sets, conj and disj are opposites
21:10gfredericksconj takes a thing to add, disj takes a thing to remove
21:10gfrederickswrt maps, conj and poly-disj are not opposites in that sense
21:10gfredericksconj takes a PAIR to add, poly-disj takes a KEY to remove
21:12Bronsagfredericks: different operations take different inputs
21:13Bronsaby your point dissoc is not the opposite of assoc
21:13gfredericksI might be imagining and intended pairing of conj and disj
21:13gfredericksan*
21:14Bronsagfredericks: yeah, disj right now has definitely nothing to do with conj, the latter being highly polymorphic while the former being defined only on sets
21:14gfredericksthe names seem related
21:14gfredericksand "defined only on sets" always made sense to me as being the only context where it could be defined
21:14amalloyBronsa: i don't really agree: disj and conj seem to me like they're intended to be inverses
21:15gfredericksamalloy! thank goodness you're here!
21:15amalloyif disj worked on maps i'd expect it to work like gfredericks's version, not yours
21:15amalloyor, probably, to require an actual MapEntry
21:16gfrederickseh, conj takes a vector pair
21:16amalloygfredericks: yeah, but the mapentry didn't exist yet. it's plausible that disj on the map would only remove entries which are in the map
21:17gfredericksdoes java-style never involve creating map entries before adding them to maps?
21:18amalloyi can't think of an instance of that, but maybe
21:18gfredericksamalloy: in any case do you have a less hand-wavey argument for this than I do, or is it just "they seem like inverses"?
21:18Bronsaamalloy: gfredericks it had never crossed my mind that (disj {} [k v]) might make sense, and I still don't think it does but point taken
21:19BronsaI still wish there was a function that behaved like poly-disj, whichever its name
21:19amalloyno, i have nothing concrete
21:19gfredericksamalloy: at least there's two of us
21:20amalloyBronsa: you can create that function, of course, with protocols. i'm sure you know that; are you hoping for it to be in core instead?
21:20Bronsaamalloy: yeah I meant in core
21:23Bronsa`remove-keys` maybe
21:24amalloyBronsa: you could even call it `without`, like the java method on maps
21:24amalloy(-> my-set (without x y z))
21:25amalloyer, i guess i meant the method on sets
21:25Bronsayeah without is probably better. remove-keys might suggest an association with select-keys, which only works on maps
22:56weiwhat’s a good way to pass data between two clojure processes? redis/carmine?
23:00bbloomwei: dramatically more information needed
23:04weibbloom: good point. i have one process that controls multiple processes. the child processes are interchangeable and can start and stop unpredictably. requirements are that the messages be encrypted and durable across restarts. tangentially related, I recall Rich’s Language of the System talk had some great principles but he didn’t have time to cover how to implement such a system in Clojure
23:05bbloomare the processes on one box or distributed across several?
23:14weibbloom: would it significantly change the design?
23:15bbloomwei: you can use the file system or you can use the network
23:15bbloomwei: why do you need encryption?
23:15bbloomwei: why do you need durability?
23:15bbloomyou asked a reeeaaaallly general (and difficult) question
23:15weithanks for humoring me :)
23:16bbloommaybe talk about your high level goal a bit
23:18weihaha, this reminds me of a previous conversation where you said, “guaranteed deliverability is a lie”
23:18bbloomwei: i would have reminded you of that :-P
23:20weireading up on some design now.. i’ll come back later with more specific questions :)
23:21vanilahi
23:21vanilahttps://www.youtube.com/watch?v=f84n5oFoZBc
23:21vanilaHammock Driven Development - Rich Hickey