2014-06-29
| 00:03 | gastove | (defn hack [arg] (Shennendoah$DeviceEvent$DeviceRegistrationEvent/parseFrom arg) |
| 00:03 | gastove | ...damnit. |
| 00:06 | ambrosebs | gastove: nice one |
| 02:20 | Shayanjm | I'm trying to build a function that returns all values of a given key inside a nested map |
| 02:20 | Shayanjm | https://gist.github.com/shayanjm/9702996c62ef46e8fc1e |
| 02:20 | Shayanjm | I'm having an issue though, because given this data: https://gist.github.com/shayanjm/a1986f9787870a070507 |
| 02:21 | Shayanjm | I get this result: https://gist.github.com/shayanjm/8a3114b18055dded0941 |
| 02:21 | Shayanjm | when searching for the key :content |
| 02:21 | Shayanjm | any assistance would be much appreciated |
| 02:34 | TEttinger | Shayanjm, those parens don't line up in the last gist |
| 02:34 | TEttinger | is it returning a nested seq? |
| 02:35 | Shayanjm | ah yes sorry, the last 2 parens got cut off for some reason |
| 02:35 | Shayanjm | The use case is this: I'm getting a map from enlive which represents a DOM structure. I'm trying to extract the text content from the page while essentially 'ignoring' the fact that some of the text might be links and such |
| 02:35 | TEttinger | I'd guess that has to do with the recursive call to (all-values-of-key) |
| 02:36 | Shayanjm | Yeah I mean the nested seq thing isn't too bad currently |
| 02:36 | Shayanjm | the part I was referring to is the fact that it returned a string, a map, and then a string |
| 02:36 | Shayanjm | when I need it to return 3 strings |
| 02:36 | TEttinger | yeah that's a bit odd |
| 02:36 | Shayanjm | The map it returned also has the key :content |
| 02:37 | Shayanjm | so ideally instead of that map being there, it would just have the value for that :content (in this case: "Washington Wizards" |
| 02:37 | Shayanjm | )* |
| 02:38 | TEttinger | well one of the :content fields has a value of a seq |
| 02:38 | TEttinger | so I am guessing it mostly finds that |
| 02:39 | TEttinger | :content ("Andre Miller’s agent, Andy Miller, said he had been officially notified by the " {:tag :a, :attrs {:class "meta-org", :title "Recent news and scores about the Washington Wizards.", :href "http://topics.nytimes.com/top/news/sports/probasketball/nationalbasketballassociation/washingtonwizards/index.html?inline=nyt-org"}, :content ("Washington Wizards")} " that the team would guarantee Andre Miller’s contract |
| 02:40 | Shayanjm | TEttinger: any ideas on how I can adjust my function to account for that? |
| 02:40 | Shayanjm | I've been poking at this for a little over an hour :\ |
| 02:41 | TEttinger | well you have :content keys with non-string values, how do you want to handle those? |
| 02:59 | Shayanjm | I'd essentially like to grab the value and turn it into a string |
| 02:59 | Shayanjm | (or extract the string from the sequence) |
| 03:24 | TEttinger | Shayanjm, right, I'm looking at clojure.zip now |
| 03:25 | Shayanjm | k, just pulled up docs |
| 04:03 | TEttinger | Shayanjm: |
| 04:05 | TEttinger | ,(def data {:tag :p, :attrs {:class "story-body-text story-content"}, :content ("Andre Miller’s agent, Andy Miller, said he had been officially notified by the " {:tag :a, :attrs {:class "meta-org", :title "Wizardry.", :href "http://"}, :content ("Washington Wizards")} " that the team would guarantee Andre Miller’s contract for $4.6 million in 2014-15.")}) |
| 04:05 | clojurebot | #<CompilerException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn, compiling:(NO_SOURCE_FILE:0:0)> |
| 04:05 | TEttinger | ,(def data {:tag :p, :attrs {:class "story-body-text story-content"}, :content (list "Andre Miller’s agent, Andy Miller, said he had been officially notified by the " {:tag :a, :attrs {:class "meta-org", :title "Wizardry.", :href "http://"}, :content (list "Washington Wizards")} " that the team would guarantee Andre Miller’s contract for $4.6 million in 2014-15.")}) |
| 04:05 | clojurebot | #'sandbox/data |
| 04:05 | TEttinger | ,(reduce (fn get-strings-out [base nx] (cond (string? nx) (str base nx) (map? nx) (get-strings-out base (get nx :content "")) (sequential? nx) (reduce get-strings-out base nx) :else base)) "" data) |
| 04:05 | clojurebot | "Andre Miller’s agent, Andy Miller, said he had been officially notified by the Washington Wizards that the team would guarantee Andre Miller’s contract for $4.6 million in 2014-15." |
| 04:06 | TEttinger | Shayanjm, took me a fair amount of time to figure it out, I'm glad it works |
| 04:21 | crocket | Where does clojure excel? |
| 04:22 | crocket | Is it suitable for web backends such as search engine? |
| 04:47 | daGrevis | can I have a little help with deps? |
| 04:47 | daGrevis | I want to use http://richhickey.github.io/clojure-contrib/math-api.html#clojure.contrib.math/sqrt |
| 04:47 | daGrevis | it's not built-in, right? i need to put it in project.clj |
| 04:48 | technomancy | clojurebot: what happened to contrib? |
| 04:48 | clojurebot | Well... it's a long story: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go |
| 04:48 | technomancy | daGrevis: that lib is deprecated, but you may be able to find similar functionality elsewhere |
| 04:49 | daGrevis | where did it go? :O |
| 04:49 | daGrevis | link you gave me is 404 :D |
| 04:49 | technomancy | oh really, ugh. |
| 04:49 | daGrevis | basically https://github.com/clojure/math.numeric-tower |
| 04:50 | daGrevis | i should be careful thought, because i'm targeting clojurescript and java interopt wont work |
| 04:53 | daGrevis | or... i could use javascript interopt. |
| 04:53 | daGrevis | ugh |
| 06:33 | daGrevis | whats the best way to deal with functions that have multiple versions based on param count? |
| 06:38 | daGrevis | i guess something like this is fine https://github.com/daGrevis/clojure-koans/blob/master/src/koans/09_runtime_polymorphism.clj#L1 |
| 07:05 | pradeepc | Hi, i have a vector of maps .. I want to create a new map out of each map and return a new vector of new maps. can someone tell me how to do this. |
| 07:36 | Glenjamin | pradeepc: ##(doc mapv) |
| 07:36 | lazybot | ⇒ "([f coll] [f c1 c2] [f c1 c2 c3] [f c1 c2 c3 & colls]); Returns a vector consisting of the result of applying f to the set of first items of each coll, followed by applying f to the set of second items in each coll, until any one of the colls is exhausted. Any remai... https://www.refheap.com/87650 |
| 07:40 | visof | hello |
| 07:40 | visof | is there a binary search over a list strings in clojure "builtin" ? |
| 07:56 | pradeepc | Glenjamin: thank you :) |
| 08:34 | visof | i tried this code to convert a file separated by : into a hash but return a nil that's my code (into {} (with-open [rdr (clojure.java.io/reader path)] (doseq [line (line-seq rdr)] (clojure.string/split line #":"))))) |
| 08:34 | visof | can anybody help in this? |
| 09:28 | zoldar | Hi. I'm creating a basic cljs om app project that - when fully functional - I want to convert into a lein template. I have a problem with compiling for release (a single file version) - the advanced mode fails and I don't know how to track the cause down. Is there any way to debug the advanced compilation process in some way? Or at least disable name mangling leaving all other optimizations? |
| 09:29 | zoldar | What I have so far is here: https://github.com/zoldar/om-with-tests |
| 09:55 | szymanowski | Hello, is there a simple way to make custom type that acts exactly like a vector without rewrite implementation? |
| 09:58 | zoldar | Ok that was some problem with temporary files, when I've started with a clean output-dir for the target, it worked |
| 10:31 | zoldar | szymanowski: what do you mean by "acts exactly as vector"? You could extend IPersistentVector protocol (and all other relevant protocols) simply proxying to existing implementations where needed. |
| 10:34 | szymanowski | I would like this to extend this new type to some locals protocols but I don't want to extend IPersistentVector to those protocols |
| 10:34 | szymanowski | I would like to extend this new type to some locals protocols but I don't want to extend IPersistentVector to those protocols |
| 10:34 | szymanowski | sorry |
| 10:35 | zoldar | ok, but without extending IPersistentVector you won't be able to use the same vector API related fns |
| 10:35 | zoldar | afaik at least |
| 10:36 | szymanowski | ok i will look at the IPersistentVector interface |
| 10:37 | szymanowski | thank you |
| 10:37 | zoldar | szymanowski: I'm not familiar with your exact requirements but maybe the other way around would be more suitable? like extending LazilyPersistentVector with your local protocols? |
| 10:38 | szymanowski | I will look at this :) |
| 10:38 | zoldar | wrong wording: extending your local protocols for the LazilyPersistentVector type |
| 10:40 | Bronsa | you really mean PersistentVector, not LazilyPersistentVector |
| 10:40 | zoldar | Bronsa: guess you're right |
| 10:40 | Bronsa | LPV just contains some static methods to construct a PV |
| 10:40 | Bronsa | it's probably just a leftover |
| 10:49 | jinks_ | Hi. I'm trying to find a simple schema-less embed-able database to use as storage engine for a collection of nested objects. I can't seem to find anything that fits. Is there such a thing with a basic clojure API? (There's a more fleshed out version of what I already tried at http://redd.it/29dzb8) |
| 10:53 | zoldar | jinks_: what about jiraph? |
| 10:55 | shiranaihito | is there a way to "consistently" add an element to a collection's end (without relying on conj used on a vector, for example)? |
| 10:56 | jinks_ | zoldar: To be honest, I couldn't make heads or tails of jiraph. It has pluggable storage backends? Can it run without native dependencies? I want to distribute the final result as a single jar without requiring external libs or databases |
| 11:09 | zoldar | jinks_: after a short research (was curious myself) it seems that jiraph relies on an interface to key-value stores that - from what I see - has support for redis, tokyo and memcached |
| 11:11 | jinks_ | zoldar: all of those require native compiled dependencies which is a route I'd like to avoid... also the advertised website (jiraph.org) seems to not exist which tends to fill me with mistrust in it's long-term viability |
| 11:12 | zoldar | jinks_: right, these were just my 2 c |
| 11:12 | pradeepc | Hi.. i have an arrays of hashmaps .. how can i check that all hashmaps has one of the key not null ? |
| 11:14 | jinks_ | to be honest, the whole flatland namespace looks like a dumping ground for i-didn't-really-know-what-to-with-it projects and circlejerking (huge lists of interdependencies between the different flatland projects) |
| 11:14 | jinks_ | maybe I'm just picky :D |
| 11:16 | zoldar | shiranaihito: you could use concat with one-element list as a second argument, or convert the collection to vector with vec and use conj |
| 11:17 | shiranaihito | zoldar: thanks, that seems to be the standard "workaround".. it's kind of weird that there's a problem like this though |
| 11:17 | shiranaihito | ofc, some people don't consider it a problem |
| 11:18 | zoldar | jinks_: I'm not a native English speaker but 'circlejerking' sounds a bit offensive. It's just a way to keep the small libs organized and modular/resusable, don't see anything wrong with it |
| 11:18 | zoldar | shiranaihito: depends on what are your requirements |
| 11:20 | jinks_ | zoldar: You're probably right, it's a bit of a harsh judgment. I don't know the whole flatland ecosystem just rubs me the wrong way without me being able to pinpoint why. |
| 11:20 | shiranaihito | zoldar: yep.. well, my requirement was just to append an element to a collection's end, but have it happen "consistently", without having to worry about what the collection's type is |
| 11:24 | Shayanjm | I'm trying to build a function that returns all values of a given key inside a nested map |
| 11:24 | zoldar | shiranaihito: adding to the end of the list is considerably less efficient. Anyway, it ain't that hard to create a helper fn for such case - it's only a list that you have to branch out for from the basic collection types available in clojure |
| 11:24 | Shayanjm | https://gist.github.com/shayanjm/9702996c62ef46e8fc1e |
| 11:25 | Shayanjm | I'm having an issue though, because given this data: https://gist.github.com/shayanjm/a1986f9787870a070507 |
| 11:25 | Shayanjm | I get this result: https://gist.github.com/shayanjm/8a3114b18055dded0941 |
| 11:25 | Shayanjm | when trying to return for the :content key (there shouldn't be a map inside the result) |
| 11:25 | Shayanjm | any ideas? |
| 11:26 | shiranaihito | zoldar: branching out? .. i don't follow.. but anyway, i think i'm getting the result i want by applying a separate variadic function etc |
| 11:27 | wheeee | Om tutorials out there? |
| 11:27 | wheeee | I'm writing one and want to see what folks are addressing |
| 11:27 | zoldar | shiranaihito: I mean putting a conditional branching out for list type |
| 11:28 | zoldar | wheeee: testing :P |
| 11:28 | shiranaihito | zoldar: .. to what end? |
| 11:29 | shiranaihito | (the "conditional branching", that is) |
| 11:30 | zoldar | shiranaihito: now I don't follow :) I just mean (defn append [coll elem] (if (list? coll) (append-with-concat...) (do-a-simple-conj-or-sth...))) |
| 11:30 | shiranaihito | zoldar: alright :P |
| 11:31 | zoldar | wheeee: I mean that's what is usually missing |
| 11:34 | wheeee | zoldar: testing is missing? |
| 11:34 | wheeee | I'm trying to write for JS devs new to CLJS |
| 11:37 | halogenandtoast | Can anyone explain what the Cons class is and how that differs from a PersistentVector? |
| 11:38 | bbloom | ~seqsandcolls |
| 11:38 | clojurebot | Huh? |
| 11:38 | bbloom | ~colls |
| 11:38 | clojurebot | colls is http://www.brainonfire.net/files/seqs-and-colls/main.html |
| 11:39 | zoldar | halogenandtoast: this so answer may be partly relevant: http://stackoverflow.com/a/3009747 |
| 11:39 | bbloom | halogenandtoast: the Cons class specifically is more or less legacy, but it's related to LazySeq and PersistentList.... which differ in quite a few ways from PersistentVector |
| 11:40 | zoldar | wheeee: it's a chore to set it up properly |
| 11:41 | Shayanjm | can anyone help with my function to return all values of a key given a nested map? |
| 11:42 | zoldar | wheeee: I've just made a simple skeleton for an om app that takes into account the testing aspect: https://github.com/zoldar/om-with-tests . I want to convert it into a template when it proves to work as expected |
| 11:44 | zoldar | yet still it's bound to a particular os due to test runner requirements |
| 11:48 | wheeee | zoldar: I know some friends who are using phantom to test. I'll take a look at it and see what's doin' |
| 11:48 | wheeee | I think I want to target my writing at folks who ask questions like "Wtf does #() mean?" |
| 11:48 | zoldar | wheeee: that's that I'm using as well |
| 11:49 | wheeee | At least initially |
| 11:49 | zoldar | wheeee: Nolen's tutorial is pretty good in that regard I think |
| 11:51 | zoldar | Shayanjm: the value under :content seems to contain a nested structure so that's what is grabbed in the process. Don't see anything wrong with it |
| 11:51 | Shayanjm | zoldar: there is a :content inside of the nested structure |
| 11:51 | Shayanjm | which I would like to return instead of the structure itself |
| 11:52 | zoldar | Shayanjm: you have to account for a situation where value under :content is a nested structure - collect this first value (string) from that structure and process the rest recursively |
| 11:52 | Shayanjm | zoldar: if you look at the function that I gist'd, I thought I was doing that |
| 11:53 | zoldar | Shayanjm: no, you simply cons the value on acc when the key is matched and the cond processing ends there |
| 11:54 | wheeee | zoldar: I think it seems good from the eyes of someone who has done Clojure but a lot of JS devs don't "get" it as easily |
| 11:55 | zoldar | wheeee: guess you are right |
| 11:55 | zoldar | wheeee: but this will be a pretty loaded task for a single tutorial |
| 11:56 | zoldar | wheeee: anyway, good luck! |
| 12:22 | {_blake_} | I've got a project that refers to other of my projects (in the same master directory) and lein is telling me it can't find the SNAPSHOTs for these projects. I haven't had this problem before. (This is my first time with this project under Windows. Been using Linux up till now.) What needs to be pointed where? |
| 12:33 | Shayanjm | I have 2 swap! statements - one assoc-in's [:key] with a nested collection, and the other maps an averaging function to each collection |
| 12:33 | Shayanjm | and assoc-in's that result to [:anotherkey] on the same atom |
| 12:33 | Shayanjm | is it 'good clojure' to perform both of these within a single dosync? |
| 12:35 | bbloom | Shayanjm: dosync has nothing to do with swap! |
| 12:36 | Shayanjm | ehh, okay - is it 'good clojure' to perform both swap!'s within a single function? |
| 12:36 | zoldar | Shayanjm: can you show the actual code? |
| 12:37 | bbloom | Shayanjm: prefer pure functions, compose them together, use swap! at the top-level / edges-of-system only |
| 12:38 | Shayanjm | sure zoldar one minute |
| 12:38 | bbloom | it's not that uncommon to see relatively large programs with zero or one atom... and zero or one swap call! |
| 12:39 | zoldar | Shayanjm: basically what bbloom says but the actual code would give better context to give more concrete advice (if necessary) |
| 12:41 | Shayanjm | https://gist.github.com/shayanjm/469a8f0484753f777672 |
| 12:42 | zoldar | Shayanjm: just do that in a single swap! |
| 12:42 | zoldar | Shayanjm: and dosync is completely unnecessary here, as it was already pointed out |
| 12:44 | squeedee | because swap is already synchronos? |
| 12:44 | squeedee | 'atomic' |
| 12:45 | daniel__ | im trying to write a tempfile from upload to the local disk, can't get past this error: https://gist.github.com/danielstockton/cb5e5c60cb98ff493ff5 |
| 12:46 | zoldar | squeedee: atoms allow only atomic change of a single reference |
| 12:46 | squeedee | cool thanks zoldar |
| 12:47 | squeedee | I kind of knew that, but every bit of reinforcement helps |
| 12:54 | shiranaihito | i'm using Jetty as an embedded server, and it contains a "Request" -class.. and now i'm getting the error: "ClassFormatError: Duplicate interface name in class file" probably because i'm defining a record called "Request" too.. but my record is in a file that does not import Jetty's "Request" .. what's wrong? |
| 12:55 | shiranaihito | (in fact, the compile error happens specifically where i define the Request record) |
| 12:55 | shiranaihito | can i just not have a record with that name, or am i missing something? |
| 12:56 | Shayanjm | If I want to round various values to their nearest integers - is it better to use the clojure.contrib.math library or just build my own rounding function since that's the only thing I need? |
| 13:02 | zilti | Is cider 0.6.0 failing for anyone else too? It can't connect to an nREPL session, it just is stuck at connecting to it. |
| 13:03 | daniel__ | zilti: i saw on /r/clojure people were having issues |
| 13:03 | daniel__ | whats the most popular sql library for clojure nowadays? korma? |
| 13:04 | zilti | daniel__: I'd say korma, yes. I had good experiences with it too. Seems like it's the only actively developed one. Except the tools.sql one of course |
| 13:10 | shiranaihito | (nevermind, i think i found the problem) |
| 13:31 | whodidthis | yesql |
| 13:31 | fifosine | I have the following in my profiles.db http://pastebin.com/PxqQjCwN but when I try to open my repl I get the following compilation error http://pastebin.com/WtrNrwe4. Have I set something up wrong? |
| 13:32 | fifosine | *profiles.clj |
| 13:34 | whodidthis | missing outer curly brackets maybe |
| 13:52 | zilti | whodidthis: Wow, that's a very neat lib! |
| 13:53 | fifosine | Is anyone familiar with working with environ? |
| 13:54 | fifosine | I've added an :env map to my profiles in project.clj, but it doesn't seem to be loading the values |
| 14:12 | wheeee | zoldar: once I put it out would really dig comments from folks |
| 14:18 | halogenandtoast | Forgot to thank zoldar and bbloom earlier, thanks for the Cons info. |
| 15:13 | fifosine | How do I create a composite key with clojure.java.jdbc.create-table? |
| 15:31 | ybit2 | why wouldn't you use models with Om? |
| 15:31 | ybit2 | the value-oriented programming talk didn't quite explain this one for me, |
| 15:31 | ybit2 | maybe i need to rewatch and not skim |
| 15:32 | squeedee | take a look at nolens blog too |
| 15:32 | borkdude | can I ask an Om question in here? #clojurescript seems to be very quiet now |
| 15:36 | Frozenlock | You can, but both #clojure and #clojurescript tend to be quite slower on weekends |
| 16:05 | Frozenlock | That's weird... I get this error when uberjaring: |
| 16:05 | Frozenlock | Exception in thread "nREPL-worker-0" java.lang.Error: java.net.SocketException: Socket closed |
| 16:10 | fifosine | how do I test if my database connection is working? |
| 16:11 | gfredericks | SELECT 1 |
| 16:19 | Raynes | gfredericks: drop table production.stuff; |
| 16:19 | Raynes | Actually, drop schema production cascade; |
| 16:19 | bbloom | Raynes: i was going to suggest drop database |
| 16:20 | Raynes | I think you win. |
| 16:52 | TEttinger | Shayanjm: you around? |
| 16:53 | TEttinger | ,(def data {:tag :p, :attrs {:class "story-body-text story-content"}, :content ("Andre Miller’s agent, Andy Miller, said he had been officially notified by the " {:tag :a, :attrs {:class "meta-org", :title "Wizardry.", :href "http://"}, :content ("Washington Wizards")} " that the team would guarantee Andre Miller’s contract for $4.6 million in 2014-15.")}) |
| 16:53 | clojurebot | #<CompilerException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn, compiling:(NO_SOURCE_FILE:0:0)> |
| 16:54 | TEttinger | right |
| 16:54 | TEttinger | ,(def data {:tag :p, :attrs {:class "story-body-text story-content"}, :content (list "Andre Miller’s agent, Andy Miller, said he had been officially notified by the " {:tag :a, :attrs {:class "meta-org", :title "Wizardry.", :href "http://"}, :content (list "Washington Wizards")} " that the team would guarantee Andre Miller’s contract for $4.6 million in 2014-15.")}) |
| 16:54 | clojurebot | #'sandbox/data |
| 16:54 | TEttinger | ,(reduce (fn get-strings-out [base nx] (cond (string? nx) (str base nx) (map? nx) (get-strings-out base (get nx :content "")) (sequential? nx) (reduce get-strings-out base nx) :else base)) "" data) |
| 16:54 | clojurebot | "Andre Miller’s agent, Andy Miller, said he had been officially notified by the Washington Wizards that the team would guarantee Andre Miller’s contract for $4.6 million in 2014-15." |
| 17:12 | ivan | searching for ":keyword" does not quite work in the presence of :keys destructuring, heh |
| 17:19 | bbloom | ivan: i get burned by that occasionally when using * and # in vim |
| 17:28 | andonilsson | I'm looking for a "function?"-predicate. |
| 17:28 | andonilsson | I have a map, where some of the values are functions, and I'd like to filter them... |
| 17:29 | bbloom | (doc fn?) |
| 17:29 | clojurebot | "([x]); Returns true if x implements Fn, i.e. is an object created via fn." |
| 17:29 | bbloom | (doc ifn?) |
| 17:29 | clojurebot | "([x]); Returns true if x implements IFn. Note that many data structures (e.g. sets and maps) implement IFn" |
| 17:29 | andonilsson | Doh! |
| 17:29 | andonilsson | I was only looking for function, never fn... |
| 17:29 | andonilsson | thx bbloom |
| 17:29 | bbloom | andonilsson: http://clojure.org/cheatsheet |
| 17:30 | zoldar | when creating a lein template, how do I set file's executable flag? |
| 17:38 | zoldar | ok, found it. :executable true has to be added at the end of path definition vector in ->files form |
| 18:24 | zoldar | I have created a basic template for a Om application with continuous testing setup if anyone's interested: https://github.com/zoldar/om-with-tests-template . It can be used with 'lein new om-with-tests app-name' command. Any feedback welcome. |
| 19:25 | rurumate | I have a nice function that returns a core.async channel. How to make a nice java API of it? Is there a java interface "Channel" or what to return? Thanks |
| 19:26 | rurumate | ManyToManyChannel seems not a regular java interface, and there is not much else in the src/java folder of core.async |
| 19:27 | rurumate | or is there an "aot plugin" for maven yet, so I can aot the ManyToManyChannel? |
| 19:31 | whodidthis | how do i open a file by namespace in vim |
| 19:34 | whodidthis | like what fireplace does when gf on a namespaced function |
| 19:42 | talios | rurumate - you mean like clojure-maven-plugin? |
| 19:43 | talios | a protocol should generate an interface - failing that, just write your api in Java and use the clojure.api.* to refer to your clojure |
| 19:44 | talios | not sure how exporting a channel to java would look like tho. |
| 19:44 | talios | if using Java8 streams could be an idea, maybe. |
| 19:56 | zilti__ | I'm trying to add type annotations to an untyped library. Now I get "Polymorphic function clojure.core.async/<! could not be applied to arguments: Polymorphic variables: p, t Domains: (Chan2 p t) Arguments: (Chan2 (Boxed java.lang.String) (Boxed java.lang.String))" |
| 19:57 | zilti__ | I'm trying to figure out now what I did wrong when annotating Boxed. |
| 19:57 | rurumate | talios: ManyToManyChannel implements Queue, so maybe return that? |
| 19:58 | rurumate | or no, actually that would suck because it's not straightforward to wait on a queue in java |
| 19:58 | rurumate | a Future would be natural and suffienct in many cases (if only one value is ever put on the ch) |
| 19:58 | talios | it would be nicer in Java8 due to lambdas |
| 19:59 | zilti__ | You can't use the lambdas together with Clojure anyway |
| 19:59 | talios | no - but if the clojure exposed a Queue, that doesn't matter |
| 19:59 | rurumate | so the moral is there's nothing to help integrate core.async into the java world yet? |
| 20:00 | talios | the moral is clojure interop is a lie :) for advanced things anyway |
| 20:00 | rurumate | well at least there should be some way to represent a channel in java, that would be a start |
| 20:01 | talios | you could do it via say a bridge to Akka actors |
| 20:01 | rurumate | never heard of that |
| 20:01 | zilti | vert.x has a Clojure- and a Java-API |
| 20:02 | zilti | But what I'd do is use the observer pattern and let the Java classes register in a Clojure namespace so they get what they want and can send back |
| 20:03 | Jaood | STM is a lie too |
| 20:04 | rurumate | if channels become more prevalent in clojure libs, good for them but will be bad for interoperability? |
| 20:06 | rurumate | returning a channel is good style in clojure, but no easy way to deal with it if you're calling from java |
| 20:06 | rurumate | if you don't know who's calling you |
| 20:06 | zilti | rurumate: You can read a channel asynchronously providing a callback |
| 20:07 | rurumate | hmm |
| 20:07 | zilti | rurumate: And you can read and write it blockingly, too |
| 20:07 | zilti | No big deal, essentially |
| 20:07 | rurumate | but then would need to write extra code for the case of a java caller |
| 20:07 | rurumate | can't we just make a nice java library and say here's a channel and here are your tools to use it? |
| 20:08 | zilti | rurumate: Of course we can. But it seems no one really wants to do it at the moment. |
| 20:08 | rurumate | it's ok if it's more work than in clojure, the java people are used to it |
| 20:09 | rurumate | zilti: yes but if IChannel is not a thing, it's hard. core.async should define that core abstraction |
| 20:10 | zilti | rurumate: Basically you shouldn't use any of the internal Clojure interfaces since they're implementation detail. |
| 20:13 | rurumate | is there an example how to use channel with callback? |
| 20:16 | zilti | rurumate: A Callable should be enough to pass to "take!", but I haven't tried it. |
| 20:16 | zilti | Just took a quick glance at the code |
| 20:17 | rurumate | ok but calling RT.val("clojure.core.async","take!").invoke(ch, callback) from java is not fun |
| 20:17 | rurumate | *RT.var |
| 20:18 | rurumate | it would be possible like that of course, but the java people will not like it |
| 20:18 | zilti | rurumate: Then make a wrapper class! |
| 20:18 | brehaut | FFI not as nice as native use, film at 11 |
| 20:18 | rurumate | no use, the will read that and complain about improper implementation |
| 20:19 | rurumate | they& |
| 20:19 | rurumate | FFI? film? |
| 20:20 | zilti | rurumate: Well but what do you want, type safety inside the channels? You don't even have that in Clojure itself |
| 20:21 | rurumate | no not the channels, it's ok for them to return an object I guess. but at least they should provide blockingGet() functionality, clojure.util.Queue doesn't have that |
| 20:21 | talios | rurumate - so wrap that in your service API - you're java users don't need to use RT or clojure.api.API directly |
| 20:21 | rurumate | *java.util.Queue |
| 20:22 | zilti | rurumate: <!! is blocking get |
| 20:22 | rurumate | I know, but that's not java either |
| 20:22 | zilti | Yeah, well, it's a Clojure library after all, and in the end it's all Bytecode |
| 20:23 | rurumate | in the java world, this function name is not allowed due to code style guidelines, pmds checkstyles |
| 20:23 | rurumate | and findbugs |
| 20:24 | zilti | rurumate: Then wrap it, either in a clojure ns or in a Java wrapper. You don't even call it as a function in Java, you just pass the String to RT.var |
| 20:25 | rurumate | mkay got that |
| 20:26 | rurumate | it's a java world out there, you know |
| 21:00 | log0ymxm | Anyone know how to use the "in" operator with clojurescript? |
| 21:00 | log0ymxm | Something like the following (js* "\"onwheel\" in document.createElement(\"div\")") |
| 21:06 | bbloom | log0ymxm: just use `undefined? |
| 21:07 | bbloom | (undefined? (.. js/document (createElement "div") -onwheel)) |
| 21:07 | bbloom | there's also `exists? |
| 21:08 | bbloom | you can also use `aget |
| 21:08 | bbloom | and .hasOwnProperty, depending on your needs |
| 21:49 | noncom|2 | can i get a vector or list of required namespaces for a namespace? |
| 21:50 | noncom|2 | all in all, can i reflect on required namespaces and put them in a list? |
| 21:50 | bbloom | (find-doc "ns-") |
| 21:51 | bbloom | try something like (ns-refers *ns*) |
| 21:52 | noncom|2 | (ns-refers) gets all available top-level declarations.. but (ns-aliases) does the job! |
| 21:52 | noncom|2 | thanks! |
| 21:54 | michaelrose | question I know little about clojure atm but when I start lein repl looking at system resources I have 3 java processes eating a total of 1.2gb of memory |
| 21:54 | noncom|2 | ,(ns-aliases *ns*) |
| 21:54 | clojurebot | {} |
| 21:54 | noncom|2 | michaelrose: thats strange |
| 21:55 | noncom|2 | bbloom: hey, could you please try (ns-aliases *ns*) - it will return a map. then tell me, how can i extract namespaces from it by keys ? whatever i try for the key, (get (ns-aliases *ns*) key) retuns nil |
| 21:56 | bbloom | ,(alias 'clj 'clojure.core) |
| 21:56 | clojurebot | nil |
| 21:56 | bbloom | ,(ns-aliases *ns*) |
| 21:56 | noncom|2 | i even tried (symbol "my-alias-key") but still.. |
| 21:56 | clojurebot | {clj #<Namespace clojure.core>} |
| 21:56 | brehaut | michaelrose: one of those is lein; another is your project. they run in seperate JVMs to allow you to use a different clj version than lein. no idea about the third |
| 21:57 | bbloom | ,(get (ns-aliases *ns*) 'clj) |
| 21:57 | clojurebot | #<Namespace clojure.core> |
| 21:57 | bbloom | seems to work |
| 21:57 | noncom|2 | umm... straaaange.. |
| 21:57 | bbloom | ,(get (ns-aliases *ns*) (symbol "clj")) |
| 21:57 | clojurebot | #<Namespace clojure.core> |
| 21:57 | noncom|2 | hmmm |
| 21:57 | bbloom | ,((ns-aliases *ns*) 'clj) |
| 21:57 | clojurebot | #<Namespace clojure.core> |
| 21:57 | bbloom | ,('clj (ns-aliases *ns*)) |
| 21:57 | clojurebot | #<Namespace clojure.core> |
| 21:57 | bbloom | :-) |
| 21:58 | noncom|2 | :) |
| 21:58 | noncom|2 | oh, i must confess, i made a stupid mistake |
| 21:58 | noncom|2 | brehaut: but should it take that much memory? i guess no.. |
| 21:59 | brehaut | i dont like to guess but i have no way to measure so i cant answer that |
| 22:02 | Frozenlock | michaelrose: are you running Cider? I remember having a bunch of weird RAM issues with it. |
| 22:03 | michaelrose | I had added as it was recommended by I think tpopes vim fireplace but deleting it had no effect |
| 22:04 | michaelrose | to be clear I'm assuming deleting it from .lein/profiles.clj is immediately sufficient |
| 22:05 | Frozenlock | I honestly don't know, it's just something I noticed before going back to nrepl.el |
| 22:06 | michaelrose | freaking wierd worse it leaves beyond a zombie java , and each of the 3 actually use around 400mb |
| 22:11 | michaelrose | anyone using clojure 1.6? |
| 22:11 | michaelrose | with lein repl |
| 22:16 | Frozenlock | But I'm far below 400 mo per java instances. And I don't have zombies either... :-/ |
| 22:16 | Frozenlock | Oh wait... does lein repl uses nrepl? |
| 22:17 | Frozenlock | Hmm looking at the source I'd say yes. |
| 22:17 | brehaut | yeah it does; trptcolin's reply project |
| 22:24 | michaelrose | aaand found the problem |
| 22:25 | Frozenlock | michaelrose: What was it? |
| 23:17 | munderwo | Hey all. I've just read clojure Programming. And im tossing up about reading either "Programming Clojure" or "The Joy of Clojure" … any suggestions or insight into pros, cons? |
| 23:17 | brehaut | JoC is a deep dive. its really good, but be ready to drink from the firehose |
| 23:19 | brehaut | if you want to get deep into the mindset of clojure, JoC(2) is the one to get |
| 23:22 | munderwo | Cool. Thats what I thought. Thanks for the Advice! |
| 23:23 | brehaut | the book you have read is the oreilly one right? |
| 23:55 | fitz | Om/cljs question on this https://www.refheap.com/87660 |
| 23:56 | fitz | Anyone know why the build-all in canvas is failing? build works, build-all doesn't, I've tried hard coding values with the same result |
| 23:56 | fitz | I just get a data-react-id span |