This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-08-03
Channels
- # admin-announcements (2)
- # arachne (1)
- # architecture (6)
- # boot (316)
- # cider (7)
- # cljsrn (7)
- # clojure (169)
- # clojure-argentina (3)
- # clojure-belgium (1)
- # clojure-canada (4)
- # clojure-india (1)
- # clojure-russia (39)
- # clojure-spec (27)
- # clojure-uk (55)
- # clojurescript (213)
- # css (1)
- # cursive (20)
- # datavis (2)
- # datomic (52)
- # devcards (3)
- # dirac (78)
- # emacs (20)
- # events (1)
- # funcool (3)
- # hoplon (15)
- # jobs-rus (2)
- # om (57)
- # onyx (82)
- # overtone (1)
- # re-frame (10)
- # reagent (1)
- # ring-swagger (46)
- # spacemacs (7)
- # specter (31)
- # spirituality-ethics (1)
- # sql (43)
- # test-check (1)
- # testing (4)
- # untangled (30)
Don't know - prob best to file a jira for it
I'll try to look at it later this week
A patch would be even better :)
@mkaschenko: Had a quick look at the code and noticed there's an ":escape-slash" option that you can turn off which should get you the same as ruby
@mokr: The platform differences are not theoretical either. I remember fixing a bug once in a ruby test suite caused by the difference in the order files were returned between osx and linux.
hey guys, is there a corresponding function that can be used as an equivalent to the map namespace reader literal?
with specter: (transform (walker keyword?) #(keyword "user" (name %)) {:a 1 :b {:c 3}})
@borkdude @mpenet a better way to do that with specter is to express "keyword namespace" as a new navigator:
(defnav KW-NS []
(select* [this kw next-fn]
(next-fn (namespace kw)))
(transform* [this kw next-fn]
(let [kw-name (name kw)
new-ns (next-fn (namespace kw))]
(keyword new-ns kw-name)
)))
(setval [ALL FIRST KW-NS] "user" {:a 1 :b 2 :c 3})
;; => {:user/a 1, :user/b 2, :user/c 3}
now that concept is composable and reusable
I would just write a 2 line function that takes a map and return a the new map, just as composable
I don't think that's nearly as composable
e.g.: working on sorted maps without changing the type, changing the namespace of just one keyword in the map, working on a sequence of maps
there's infinite examples I could list
still, if you need to change just 1 key you would probably just use assoc, for sequence of map you can just use map
etc etc. As I said for complex transformations why not, but I doubt it's the default
even for just one key I think the Specter code is better (in my opinion):
(update mymap :a (fn [kw] (keyword "user" (name kw))))
(setval [:a KW-NS] "user" mymap)
and then you can use the navigator to do other things, such as (transform [:a KW-NS] (fn [s] (str s s)) mymap)
the thing is, while using empty
to preserve the type is possible, it's a constant burden you have to deal with every time you write a function that manipulates a data structure
it's classic complexity... all you want to do is manipulate the nested keywords but you have this extra burden interwoven in the function
another separate concern is performance, the optimal way to reduce through the map is totally different for small maps vs. larger maps
specter is able to encapsulate those different mechanisms for you so you don't have to worry about it
did your work on specter sparked new tickets for performance optimisations in core btw?
for small maps (PersistentArrayMap) the highest performance mechanism I found was using the "keyIterator" and "valIterator" methods, for large maps it was reduce-kv + transient PersistentHashMap
I made some suggestions on a ticket about a proposed map-vals
function, but otherwise didn't find anything to optimize in core
the work on specter was more about discovering those best methods and abstracting them away
well, kv-reduce knows nothing about the output
the optimizations baked into specter are based on knowing that the output type is the same as the input type (for ALL
)
@nathanmarz: [this](https://clojurians.slack.com/archives/clojure/p1470213401002703) looks really cool but I don't know Specter well enough yet to understand it
@borkdude: happy to explain it... maybe we should continue discussion in #C0FVDQLQ5
Is there a quick way to scan for a resource so I know the path prefix to use? Only intended for use at the REPL.
from the clojure.spec >By default map-of will validate but not conform keys because conformed keys might create key duplicates that would cause entries in the map to be overridden. If conformed keys are desired, pass the option `:conform-keys true’. any example of conform keys causing entries overridden?
If a particular namespace is aliased to e.g. x, is there a shorthand for producing the namespaced keyword in that ns?
Does anyone here use clojure-clr at all?
@shaun-mahood: there’s a #C060SFCPR channel
@bostonaholic: yeah, it doesn't seem to have much going on in there. From everything I've seen in the past few years, it seems like the only action in the clojure-clr space is in maintaining the language and in Arcadia. This is kind of my last ditch effort to see if there's anything I've missed.
@lambeta: try with/without the conform-keys opt
(s/def ::1 (s/and string? (s/conformer (constantly :boom))))
(s/def ::x (s/map-of ::1 string? :conform-keys true))
(s/conform ::x {"foo" "bar"} )
ex:
(s/def ::1 (s/and string? (s/conformer (constantly "boom"))))
(s/def ::x (s/map-of ::1 string? :conform-keys true))
(s/conform ::x {"foo" "bar" "boom" "default"})
foo is conformed to "boom" then "boom" -> "default" map entry overwrites it. no matter the number of entries in your original map you'll always get 1 entry if you conform with this specocd makes me want to have a "?" added to that option name tho, :conform-keys?
would be nicer
core.match is not actively maintained by anyone afaik
@lvh @domina re ::x/name - it’s always worked that way. autoresolved keywords can be ::foo for current ns ::alias/foo to use ns aliases or even ::fully.qualified/foo (although not really any reason to do that)
from my own experience though, people tend to get a bit itchy when you see "last commit 7 months" ago in github. I find clojure libraries, even dormant ones, to be pretty hardy against rot
yeah, I think it does what it does and continues to do so :)
if someone wanted to take it over and act as an active owner that’s another option
^ what @alexmiller said… That’s how I ended up maintaining java.jdbc and more recently tools.cli 🙂
@dbushenko: not abandoned per se, just don’t have cycles for it myself. if you want to help out let me know. There’s some enhancements, fixes I’ve been wanting to do for a couple of years now just needs somebody to care as I’m too tied up with ClojureScript etc. to devote time to it now.
@dnolen: it looks extremely complex, i don't expect i can get into it so deeply that i could implement something there...
Is there a built-in function that drop the last item of a vector and return a vector?
doglooksgood: there's pop
Does anyone have a pointer to copyright / fair reuse information related to the Clojure logo? I’m looking into the possibility of creating special keycaps with the Clojure logo on them.
i'm interested in working with core.match, will need some time to get up to speed with it though
Like @jell I would like a recommendation about writing a SOAP client in Clojure. Anyone? Context on my part: Don’t know SOAP and I’m not big on Java/interop. All I need is to just tease some useful data out of a system and I don’t have a lot of time to invest in the task. Far fetched, maybe?
any recommended ways of doing key destructuring in a macro? Right now typing stuff like:
[{::keys [~'path-segs ~'name ~'schema]}]
which doesn’t seem great.Thanks. What was the latter referring to, exactly? SOAP is not pleasant, or parsing WDSL?
Java clients might be awful but they still provide a ton of value if SOAP is what you want
@mokr: I would have gone for the WSDL -> Java and then use those classes via Java Interop.
so that it’s easier to just extract information on what APIs exist from the WSDL rather than feed it to a SOAP generator or whatever
Thanks, again, this adds to my impression about interacting with SOAP. Do you think I would gain anything by going for an external script in Python, Perl or similar?
Any “simple” language having a nice library would do. As long as I can call it from Clojure and pass some parameters that would be used in the query.
Some interop research and experience would absolutely be useful, so I think I will try that route and see where it takes me. Thanks again.
Any ideas on how to short-circuit a map operation if an exception is thrown? My use case: if an iteration of map
throws an exception, I'd like to stop processing and return the sequence of already processed values to that point.
@rmuslimov: And send them using HTTP POST? After some more googling I get the impression that I can get away with something as simple as that. Or am I perhaps missing something?
@mokr yep, we have bunch of python apps working that way. and now in clojure I’m still thinking it will be the easiest/fastest path
@manderson: Don’t know if it would work or be any good, but my first thought was to try using a combo of: reduce, try, catch and reduced instead of map.
hm. good thought @mokr. that might be the easiest impl. I was looking at how keep
is implemented in core and realizing there's a lot going on with chunked-seq's etc.
thought this might be a common enough pattern as to have a lib somewhere already...
you could pass a fn into map that catches the exception and returns a sentinel value when an exception is thrown, then use take-while or something to take results until the sentinel value is encountered
another good thought @markmarkmark , but in my case I don't want the rest to process. Maybe map
is the wrong use for this as my function could be performing side effects.
If you think of implementing your own map
by using reduce
, it should also be relatively straightforward
map is lazy, so it won't process the rest if it's stopped by take-while
something like that
If I have a record defined in one namespace and an instance of that record stored in a central state atom, how can I (in a different namespace) execute a function on that instance?
@snowell: call the function on the protocol and pass the record in as the first param.
@mokr, @rmuslimov: I've been down all of the aforementioned routes to interact with SOAP APIs in my current app. I currently just use clj-http
to throw HTTP posts of the payloads I generate using clojure.data.xml
. Those payloads conform with the varying SOAP interfaces I interact with (3 in this app) and I've found maintaining the code much easier keeping it all in Clojure.
I started off using the JAX-WS code generators and using them via interop and that was fine until I needed to start extending the code... at which point it became onerous pretty quickly.
I'm having a hard time coming up with the functional solution to something that seems fairly trivial
not to mention, having multiple SOAP APIs I interact with from one app, re-use was completely out of the question with the generated code between the different WSDLs. In straight clojure, I've been able to abstract reasonably.
I want to filter the list of strings by the list of filter terms, returning a new list with only the items that match ALL filters
https://gist.github.com/rattboi/1dc8debbc8610dc98b4efddf28409f03 here's what I have that will filter with one term. I'm not positive what I need to do to apply all filters.
I was having a hard time figuring out how to get the "item" bound. You broke it into multiple functions, and that makes sense.
I always try that kind of approach with Clojure - multiple functions, each function doing one thing and doing it good
That’s a basic tenet of FP for most. Better to have a hundred tiny functions that each do one thing well than one monolithic function that does many things poorly. I’m paraphrasing here, of course.