This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-11-30
Channels
- # admin-announcements (13)
- # announcements (2)
- # avi (1)
- # aws (10)
- # beginners (427)
- # boot (3)
- # cider (4)
- # clara (26)
- # cljs-dev (21)
- # cljsrn (24)
- # clojure (205)
- # clojure-dev (32)
- # clojure-india (26)
- # clojure-japan (1)
- # clojure-russia (256)
- # clojurescript (41)
- # clojurex (1)
- # cursive (38)
- # datavis (99)
- # datomic (15)
- # emacs (19)
- # events (2)
- # funcool (5)
- # immutant (45)
- # ldnclj (3)
- # om (60)
- # omnext (4)
- # onyx (383)
- # overtone (7)
- # parinfer (1)
- # re-frame (3)
- # reagent (7)
- # ring (1)
- # testing (5)
Sometime when I include cljs.core.async
when I try to build my app I get some dependency error with clojure.core.cache
in memoize
and I didn't have any problem with lein deps :tree
so I wonder what else I can do? Since I have already used :exclusions
ok wth
No such var: clojure.core.cache\through
?
I don't get it
How can I include sente
if it keeps giving me No such var: clojure.core.cache\through
every time I include it
I have proper :exclusions
set and everything even
Do you see org.clojure/core.cache in the output of lein deps :tree
? It sounds like you may be excluding the version of core.cache that defines through
and one of your dependencies is trying to use it.
oh kill me
[com.emerick/friend "0.2.1"] -> [org.clojure/core.cache "0.6.2"] overrides...
an older version was overriding a later one
I must have missed it before
Thanks @noonian
@trancehime: No problem, I’m glad you figured it out!
I'm still a clojure newbie (been learning how to use CLJ+CLJS for about a month now) so I'm kind of stumbling my way through this
Thats understandable. There is a lot to learn if you are new to Clojure entirely. You might checkout the #C053AK3F9 channel also if you run into more stumbling blocks.
Could someone please explain to me, why this triggers a NullPointerException
((fn [[_ registered _]] (
(println registered)
)) [12 34 56])
A found it, the second parenthesis of the function where the reason.
println returns nil
and in that case you are trying execute a nil
that causes the NPE.
Hi, does anyone thought about using http://www.grpc.io? They have bindings for Java, but I’m a bit worried how can I use in Clojure because some protobuffs compilation
@artemyarulin: I've seen protobufs used from Clojure. It can be done, but it's awkward. Protobufs are very Java-ish, you have to add an extra translation layer between Java objects and Clojure.
@stuartsierra: Thanks. OK, I’ll try and play around with it for a while
I had an idea, and wonder if such a thing exists: a JIT type system. A tool (IDE) keeps track of the type or structure (hashmaps) of the arguments that go into a function and deduces a type. When you call the function with something else, the tool can produce a warning: you're calling this function with a number instead of a string (because you have called it with a string 99 times already and never with a number), that could be helpful to the programmer.
oke, I cannot implement it. This sort of things are much much much more then I could chew
I'm using peridot to create requests, since I also have to deal with sessions and cookies
@artemyarulin: There is a library around for interacting with Protobuf from Clojure, and it adds a record & leiningen compilation integration.
@dominicm: Thanks, I guess I found something already
@borkur: maybe the same way as here but then change the content-type : http://stackoverflow.com/questions/17035319/how-do-i-mock-a-json-post-request-in-ring
I have trouble reloading my compojure routes in Cursive. My workflow works in Emacs, but somehow the changes aren't picked up in Cursive while writing tests
@dominicm: I see all the files I changed are being reloaded. As an extra step I reload the file where the handler is defined.
@borkdude but what is it actually doing? Checking for the tools.namespace dependency of some kind? er.. I mean the "sync files with REPL" as the trigger here.
Have you seen if a def
'd variable appears when you add it to the file, then ask evaluate it in the repl? That should isolate the issue somewhat.
@dominicm: When I re-evaluate my routes, I think the handler I'm using doesn't see those changes somehow
What's the connection between your handler & routes (same namespace or sep)? Has it worked if you've manually re-evaluated the handler file?
It might be that Cursive's clever dependency finder, isn't being quite as clever as it should be.
handler is in lob.handler. that references a route from lob.api.students, that is the file where the route is changed
https://cursiveclojure.com/userguide/repl.html Scroll down to "Interaction with the editor"
@cfleming is active here, he might have a solution and if not, I'm happy to file something
https://github.com/cursiveclojure/cursive/issues/1179 I don't suppose you fit into this category do you?
@borkdude: Interesting. It's a shame cursive is in an awkward position. tools.namespace
is PERFECT for this.
But it can't load it, because, it would inject the dependency & would also remove some of it's control.
Related to Cursive + Macros: https://twitter.com/CursiveClojure/status/555841948246761472
I see peridot does already do something: https://github.com/xeqi/peridot
@borkdude you can call peridot.multipart/build
with the params you want to send, and then merge that with other request data
is there a more transducery way of writing (map f (into [] g coll) (into [] h coll))
? this is a bit repetitive
Any library/technique suggestions for flattening a deeply nested map for CSV export?
@ghadi Yeah, I know it hjas everything I need, but I'm trying to figure out how to use something like this:
{
"id": "12345678-1234-5678-1234-567812345678",
"actor":{
"mbox":""
},
"verb":{
"id":"",
"display":{
"en-US":"created"
}
},
"object":{
"id":""
}
}
To columns like id,actor_mbox,verb_id,verb_display_en-us,object_id
I think I need something like medley's reduce-kv
?
(let [getter (fn [path]
(fn [row] (get-in row path)))
gets (map getter [[:id]
[:actor :mbox]
[:verb :id]
[:verb :display]
[:object :id]])
make-row (apply juxt gets)]
make-row)
juxt ftw
oooh, nice
not always true, but a great attitude to have. the core is very capable
But it's important to push the boundaries of core from the inside -> out, rather than starting with a lib
True that.
canweriotnow: is your data dynamic? a function can be implemented to do that to any map with reduce-kv
@jr yes, I know the structure but not necessarily which keys will be present in advance.
(defn map->csv-map
([map] (map->csv-map "" map))
([prefix map]
(reduce-kv (fn [m k v]
(let [prefixed (if (empty? prefix)
k
(str prefix "_" k))]
(merge m (if (map? v)
(map->csv-map prefixed v)
{prefixed v}))))
{}
map)))
oh wow that's exactly it. Thanks!
@borkdude: I’m happy to receive an issue for that - AFAIK routes should be reloaded correctly, Cursive really just does a load-file
so there’s no magic on the actual loading.
Cursive’s issues with macros only affect the editor, never the REPL - what you evaluate in the REPL works like any other editor.
@cfleming: the issue in my case was that the handler does not get re-evaluated when a route that it uses gets re-evaluated
@borkdude: Oh, so your handler ns calls an impl ns, the impl has changed but the handler has not?
@xeqi: I ended up doing this. Is that ok? https://gist.github.com/borkdude/18d5875a2a37f4716ea6
@cfleming: normally, the wrap-reload middleware takes care of reloading, but when I'm writing tests, I'm not using that
@borkdude: I’m planning a change for protocols, that will reload implementations of protocols when then the protocol has changed
I’m surprised that tools.namespace handles that, though - I’m sure there’s no compojure-specific magic there.
@borkdude: Note that if you reload the handler ns that will always be reloaded even if it hasn’t changed, and its deps as well.
normally the reloading is done by this: https://github.com/weavejester/ring-server/blob/master/src/ring/server/standalone.clj#L59
@cfleming: yeah, that's what I want: the handler should be redefined, because one of it's parts has changed
@cfleming: I only bumped into this problem now, using Cursive. In emacs there is the same problem
ghadi: this is the extended (map f (into [] g coll) (into [] h coll))
I'm trying to write in a nicer way: https://gist.github.com/sander/30c3c36c005b3eee71fc#file-transducing-cljs-L52 . I hope to use the same transducer (composition) on core.async channels, this is just for debugging still
@borkdude: Ok, that makes more sense - thinking about it, it requires quite a lot of magic
@borkdude if your using peridot and sending a file in the params it will make it a multipart request. Ex: (request session url :request-method :put :params {:picture (io/file ..)})
@borkdude: In the meantime, if you call Load file in REPL in the handler ns, that will always be loaded (since it always loads the file you tell it to) and any transitive deps will be loaded in the right order.
@borkdude: Right, as long as there’s an explicit dependency chain from the handler to the impl. This is sometimes not true in tests that test some functionality indirectly, but in your case sounds like it should work.
@xeqi: should these be equivalent? https://gist.github.com/borkdude/d932f36e402ebae0269b
@xeqi: the second one crashes like this: https://gist.github.com/borkdude/d27a3d73ea913697f189
I guess it has something to do with ring headers having to be strings instead of longs, but I'm not sure. This is one of those situations when static typing makes sense...
@jr made a few tweaks:
This ensures the keys will be strings so that (str prefix "_" k)
doesn't choke on keyword keys, and puts all the values in vectors so I can just (apply merge-with into list-of-maps)
WTB: well-maintained emacs configuration that works well in the console and has the bare essentials and not much more: cider, clojure-mode, completion, paredit
@xeqi: fwiw, I analysed this and I think the problem is the string vs. long in the headers under content-length: https://gist.github.com/borkdude/ec80dddf2c5bc5b38f74
canweriotnow: Keeping in line with the tactic of flattening the whole map, another thing you can do is to make the keys be the original path: {["level_one" "two" "three"] value}
so you can vary the choice about naming the keys independently of flattening
I like that...
What I've got now is kind of the inverse:
{"object_verb_display_en-US" ["will visit"], "actor_objectType" ["Agent" "Agent"], "verb_display_en-US" ["planned" "answered"], "object_object_definition_name_en-US" ["Some Awesome Website"], "object_verb_id" [""], "object_object_id" [""], "actor_mbox" [""], "object_actor_objectType" ["Agent"], "object_definition_description_en-US" ["Example activity description"], "object_objectType" ["SubStatement" "Activity"], "object_definition_name_en-US" ["Example Activity"], "object_id" [""], "object_actor_mbox" [""], "verb_id" ["" ""]}
But I can already see I'm going to run into a problem when a key is present, then not, then present again re: rows, since there aren't any nil/blank placeholders between values in my vectors... hmm...
yah... the problem of flattening a tree into CSV is not fun (esp with 1->N relationships). Perhaps revisit my idea of being explicit about what you select
E.g., I don't know what map "object_actor_mbox" ["
came from
after the fact.
If I could iterate over all the maps to get the keys, and then set paths for the getter dynamically, that solution would work.
The problem domain is based on a spec that determines the overall structure, so I could theoretically map out all possible paths... we actually use Prismatic schema to validate these things, so I probably have a good list of valid keys in my codebase.
I'll revisit that and let you know what I come up with
I especially like the idea of making the keys be the path.
Question for anyone using Validateur: The API looks nice except that it appears to me that the validation tuple [valid? map-of-errors]
is entirely redundant because, if it is valid, the tuple will always be [true {}]
. In other words, the tuple is unnecessary and validators could just return a map of errors (`(empty? errors)` => true
). Is my understanding correct or am I missing something crucial?
hey guys, hoping anyone can clear a doubt
is it possible to use partial
with a record's function? been trying (partial .record-fn arg1)
but throwing an error because of the .
oh right
forgot to try that
didn't define protocols yet because I was just prototyping
I was putting everything on the Object
so time to define them now
@domkm: yeah, but it makes writing client code easier. Instead of (if (empty? validation)
, it becomes (if valid?
thanks a lot!
@tcrayford: Sorry, I don't follow. Wouldn't the test for [true {}]
and {}
be (if (first x) ...
and (if (empty? x) ...
respectively?
@tcrayford: I just checked validation-set
and in fact it completely ignores the leading boolean in the tuple: https://github.com/michaelklishin/validateur/blob/master/src%2Fcljx%2Fvalidateur%2Fvalidation.cljx#L539-L543
Is it possible to have an atom always put on a channel whenever it's updated? In that way, one could "listen" to an atom
@codemartin: add-watch
@borkdude: That is amazing! Thank you! Boy is Clojure nice to work with or what
I love that we're not in here talking about design patterns BTW. It's a breath of fresh air.
@borkdude an issue would be nice, looks like ring added a type hint in 1.4 that causes the problem
@xeqi: serious, I thought they were only 'hints' for the compiler to prevent reflection, not enforced types
sometimes they are enforced, sometimes they are not. sometimes a wrong type hint will be silently ignored, sometimes it will cause an exception at compile time, sometimes an exception at runtime when you don't expect it
https://github.com/ring-clojure/ring/commit/bb4a079a94330cea9d4d9999b1a141750680b5e0 type hints the header value as a string, but peridot causes a long to returns there. The Long
constructor would be happy with either, but it seems the Clojure compiler had to reflect there?
@xeqi: I made an issue. https://github.com/xeqi/peridot/issues/25 If you want more info like ring version etc, I can answer tomorrow.
ah I see, when you use a type hint, Clojure will choose the constructor matching that type, right?