workspace
stringclasses 4
values | channel
stringclasses 4
values | text
stringlengths 1
3.93k
| ts
stringlengths 26
26
| user
stringlengths 2
11
|
---|---|---|---|---|
clojurians | clojure | the names must match for the `keys` spec to work | 2017-12-28T12:17:55.000093 | Shamika |
clojurians | clojure | I'm looking for a few more folks to share their workflow in detail over at ClojureVerse: <https://clojureverse.org/t/share-the-nitty-gritty-details-of-your-clojure-workflow/1208> Lots of great productivity hacks both big and small. Both Clojure beginners and experienced devs seem to be getting a lot out of it. :clj: | 2017-12-28T12:30:10.000363 | Milissa |
clojurians | clojure | <@Shamika> thanks for that answer. What would be the best way to spec data where the same keyword is used in different ways? For example, if I’m searching for books and music, both might return data with ‘results’ in it. But the shape of those results will be different. | 2017-12-28T12:55:03.000298 | Ira |
clojurians | clojure | `(s/def ::book-results (s/keys :req-un [::count ::results]))` | 2017-12-28T12:55:58.000098 | Ira |
clojurians | clojure | `(s/def ::music-results (s/keys :req-un [::count ::results]))` | 2017-12-28T12:56:21.000073 | Ira |
clojurians | clojure | So `::results` actually need to point to 2 different specs, but the keywords still need to match the data they are based on. | 2017-12-28T12:56:55.000006 | Ira |
clojurians | clojure | Unless I can do this: | 2017-12-28T12:57:11.000246 | Ira |
clojurians | clojure | `(s/def ::book-results (s/keys :req-un [::count ::book/results]))` | 2017-12-28T12:57:41.000110 | Ira |
clojurians | clojure | I’ll try it… | 2017-12-28T12:58:04.000243 | Ira |
clojurians | clojure | <@Ira> is there anything else in that map that indicates whether it’s a book or music? if so, maybe you could use `multi-spec` | 2017-12-28T13:08:24.000025 | Shamika |
clojurians | clojure | I think I figured it out <@Shamika>. | 2017-12-28T13:10:24.000461 | Ira |
clojurians | clojure | ```(s/def :my/result int?)
(s/def :your/result pos-int?)
(s/def ::test-spec-1 (s/keys :req-un [:my/result]))
(s/def ::test-spec-2 (s/keys :req-un [:your/result]))
``` | 2017-12-28T13:10:28.000094 | Ira |
clojurians | clojure | ```(s/valid? ::test-spec-1 {:result -2})``` | 2017-12-28T13:11:15.000012 | Ira |
clojurians | clojure | is valid | 2017-12-28T13:11:32.000295 | Ira |
clojurians | clojure | ```(s/valid? ::test-spec-2 {:result -2})``` | 2017-12-28T13:11:40.000083 | Ira |
clojurians | clojure | is not | 2017-12-28T13:11:41.000236 | Ira |
clojurians | clojure | Does spec have any impact on parsing XML? | 2017-12-28T15:27:50.000347 | Ira |
clojurians | clojure | <@Ira> how do you mean? | 2017-12-28T15:28:26.000128 | Jodie |
clojurians | clojure | Well, I’m about to pitch my CTO on Clojure and spec, and we consume a lot of XML API’s. I’d like to know definitively how they relate, and if spec is an advantage here or not. | 2017-12-28T15:29:07.000181 | Ira |
clojurians | clojure | <@Ira> I don't think there's much advantage, you could spec those XML APIs, and generate clojure.data.xml data structures automatically from them, to ensure that you have high coverage of the various data shapes that could be thrown at you from those APIs. | 2017-12-28T15:30:27.000253 | Jodie |
clojurians | clojure | Spec is really "one layer down" from application APIs, and is more centered around function APIs. | 2017-12-28T15:31:02.000379 | Jodie |
clojurians | clojure | Hmm. I see spec as a great way to validate calls to third-party API’s. | 2017-12-28T15:31:33.000200 | Ira |
clojurians | clojure | I’m trying to talk a Scala CTO into allowing some Clojure pilot projects. A big part of the argument is what spec brings to the table. | 2017-12-28T15:32:50.000029 | Ira |
clojurians | clojure | When you say "consume a lot of XML APIs" do you mean you POST XML to them or you get XML responses back? In either case you could convert from/to a Clojure data structure and spec validate that Clojure data structure. | 2017-12-28T15:33:35.000048 | Daniell |
clojurians | clojure | And we make quite a few XML calls. | 2017-12-28T15:33:39.000030 | Ira |
clojurians | clojure | Hmm, good question <@Daniell> | 2017-12-28T15:34:07.000172 | Ira |
clojurians | clojure | One of the reasons we initially tried Scala was that we had a problem that involved reading a SQL DB and generating XML to POST to a search engine -- and Scala has XML literals native in the language. | 2017-12-28T15:34:30.000249 | Daniell |
clojurians | clojure | It will be a mix of both. I want to demo the worst-case scenario, even if we end up working with JSON. | 2017-12-28T15:34:39.000275 | Ira |
clojurians | clojure | When we switched to Clojure, we used Hiccup to generate XML and that just transforms Clojure data structures so those could, in theory, be spec'd. | 2017-12-28T15:35:17.000144 | Daniell |
clojurians | clojure | Nice. I think we want to demo how we can consume changing API’s in Clojure more easily than in Scala. | 2017-12-28T15:35:59.000123 | Ira |
clojurians | clojure | So it’s more a concern with what we get from the vendor, than what we send them. | 2017-12-28T15:36:27.000381 | Ira |
clojurians | clojure | Converting XML to Clojure data structures is pretty painful in my experience. | 2017-12-28T15:37:05.000325 | Daniell |
clojurians | clojure | Ugh. | 2017-12-28T15:37:40.000002 | Ira |
clojurians | clojure | Thanks! | 2017-12-28T15:38:00.000204 | Glory |
clojurians | clojure | I’m working on a live coding demo with spec and JSON API returns. | 2017-12-28T15:39:05.000256 | Ira |
clojurians | clojure | XML is a real-world concern. | 2017-12-28T15:39:20.000250 | Ira |
clojurians | clojure | Cause some vendors still use it, and won’t be changing anytime soon. | 2017-12-28T15:39:34.000360 | Ira |
clojurians | clojure | <@Daniell> Oh really? We've been using clojure.data.xml internally for docbook stuff & it's been fairly good. | 2017-12-28T15:39:37.000161 | Jodie |
clojurians | clojure | We use `clojure.data.xml` in one place for a simple XML API response and also with `clojure.data.zip.xml` in another place for parsing a complex XML document -- lots of manual code mapping from the XML structure to the Clojure data structure we want. | 2017-12-28T15:40:30.000258 | Daniell |
clojurians | clojure | Where is XSLT when you need it? :wink: | 2017-12-28T15:41:08.000413 | Ira |
clojurians | clojure | I didn't use it for xml, but <https://github.com/halgari/odin/> had some nice helpers for xml, and might be a suitable XSLT-like tool. | 2017-12-28T15:41:14.000355 | Jodie |
clojurians | clojure | recently I made a toy clojure program that plays the wikipedia philosophy game (as a demo of a debugging library I wrote) and tree-seq plus clojure.xml was good enough for the little dumb thing I was doing <https://github.com/noisesmith/philoseek> | 2017-12-28T15:43:42.000086 | Margaret |
clojurians | clojure | We have lots of stuff like `(->boolean (or (zx/xml1-> node :required zx/text) false))` and `(->long (or (zx/attr node :minimum) 0))` and what is basically a custom recursive descent parser for the XML format :disappointed: | 2017-12-28T15:43:54.000262 | Daniell |
clojurians | clojure | (since XML is all plain text and we want Boolean, Long, Date etc from it) | 2017-12-28T15:44:28.000348 | Daniell |
clojurians | clojure | Agh! | 2017-12-28T15:46:41.000314 | Elijah |
clojurians | clojure | lol why does yours have such a huge picture compared to everyone else | 2017-12-28T15:46:54.000142 | Williemae |
clojurians | clojure | That sucks so bad. :stuck_out_tongue: | 2017-12-28T15:47:10.000066 | Elijah |
clojurians | clojure | I can’t remove the attachment on mobile, either! | 2017-12-28T15:47:27.000194 | Elijah |
clojurians | clojure | brb setting my gh profile pic to longcat | 2017-12-28T15:47:43.000355 | Margaret |
clojurians | clojure | ah just put it up we’ll get over it | 2017-12-28T15:47:48.000241 | Williemae |
clojurians | clojure | <https://github.com/eerohele/sigel> | 2017-12-28T15:48:03.000104 | Jodie |
clojurians | clojure | Whatever, can’t be bothered. I’d rather not plaster my ugly mug here again. :stuck_out_tongue: | 2017-12-28T15:48:04.000211 | Elijah |
clojurians | clojure | Better? :smile: | 2017-12-28T15:48:10.000155 | Jodie |
clojurians | clojure | Thanks! Yes. | 2017-12-28T15:48:14.000116 | Elijah |
clojurians | clojure | fwiw, I didn't see it as big (but I tweaked stuff a little) | 2017-12-28T15:48:18.000042 | Jodie |
clojurians | clojure | well when you posted it initially it didnt have such a big picture, it’s just when flowthing posts it lol | 2017-12-28T15:48:28.000058 | Williemae |
clojurians | clojure | shows up normally for me too (tested in my dm) | 2017-12-28T15:49:48.000121 | Williemae |
clojurians | clojure | Though in the spirit of full disclosure, I wouldn’t call that library exactly “battle-tested”… I just wanted to see whether you can write XSLT with parentheses instead of angle brackets, more or less. :stuck_out_tongue: | 2017-12-28T15:49:51.000202 | Elijah |
clojurians | clojure | I could always turn off previews from <http://github.com|github.com> but the summary is often useful (even if the picture not so much) | 2017-12-28T15:49:53.000051 | Daniell |
clojurians | clojure | But the XPath bits might be useful for querying XML documents, I guess. | 2017-12-28T15:50:41.000085 | Elijah |
clojurians | clojure | <@Daniell> yeah, no need, it’s just weird that Slack uses that humongous version of my profile picture every time… gotta try to figure out why sometime. | 2017-12-28T15:52:35.000087 | Elijah |
clojurians | clojure | Justin and I have talked about it a couple times but haven’t buckled down to do it. It’s on my list for January | 2017-12-28T19:52:26.000092 | Sonny |
clojurians | clojure | Hey guys. I'm just starting out with clojure and reagent, was wondering why luminus does this
```
(defn mount-components []
(r/render [#'navigation/navbar] (.getElementById js/document "navbar"))
(r/render [#'router/current-page] (.getElementById js/document "app")))
;; --------^ why hash quote? it works fine without it too
``` | 2017-12-29T04:32:08.000046 | Alessandra |
clojurians | clojure | that's probably so they reference the var rather than the function itself...so when they reload the file containing router/current-page the new value of the var is taken into account | 2017-12-29T05:35:02.000002 | Amee |
clojurians | clojure | i guess the router/current-page var must have the ^:dynamic meta data | 2017-12-29T05:35:26.000162 | Amee |
clojurians | clojure | router/current page is a multimethod. Anyways, it's not a big deal right now, was just curious. I'll read up on vars at some point | 2017-12-29T05:40:02.000215 | Alessandra |
clojurians | clojure | what about navbar ? | 2017-12-29T05:41:04.000160 | Amee |
clojurians | clojure | clojurescript has slightly different semantic for vars, not quite sure that's appropriate or not | 2017-12-29T05:41:37.000012 | Amee |
clojurians | clojure | simple reagent component.
```
(defn navbar []
(fn []
[:nav.navbar.navbar-dark.bg-primary
...
``` | 2017-12-29T05:42:04.000150 | Alessandra |
clojurians | clojure | try this : remove the #' for the navbar code ... load that file ...then modify your navbar and load that file | 2017-12-29T05:43:00.000108 | Amee |
clojurians | clojure | check if you see your modification | 2017-12-29T05:43:45.000189 | Amee |
clojurians | clojure | i can see the changes | 2017-12-29T05:44:00.000152 | Alessandra |
clojurians | clojure | ahwell =) | 2017-12-29T05:44:06.000234 | Amee |
clojurians | clojure | i use this trick in clojure code | 2017-12-29T05:44:26.000012 | Amee |
clojurians | clojure | you're using figwheel ? | 2017-12-29T05:44:59.000001 | Amee |
clojurians | clojure | yep. maybe it's one of those good practice kind of things | 2017-12-29T05:45:24.000115 | Alessandra |
clojurians | clojure | for clojure code that's quite necessary during development. I'm not sure about clojurescript | 2017-12-29T05:46:40.000087 | Amee |
clojurians | clojure | I'll try removing it in clojure code, see if I still get my changes reloaded | 2017-12-29T05:48:00.000145 | Alessandra |
clojurians | clojure | #'foo is a shorthand for (var foo) | 2017-12-29T05:49:25.000242 | Amee |
clojurians | clojure | a simple test, in ns a have : (def a b/b) , in ns b have : (def b 1) ... if you change b and reload the ns b, a should still be 1, unless you set b dynamic and change a to (def a #'b/b) | 2017-12-29T05:51:57.000131 | Amee |
clojurians | clojure | alright, it's making some sense. thank you for taking your time to explain :slightly_smiling_face: | 2017-12-29T05:59:24.000212 | Alessandra |
clojurians | clojure | hi all | 2017-12-29T07:48:12.000131 | Sam |
clojurians | clojure | another disillusioned java-dev jumping on board :slightly_smiling_face: | 2017-12-29T07:48:52.000068 | Sam |
clojurians | clojure | i'm not bitter! really! | 2017-12-29T07:49:17.000074 | Sam |
clojurians | clojure | I’m not bitter either, I’m having too much fun writing clojure :wink: | 2017-12-29T07:56:29.000184 | Marx |
clojurians | clojure | could anyone explain the rationale for the following? | 2017-12-29T12:15:10.000059 | Venessa |
clojurians | clojure | ```
(def foo {:a 1})
(when-let [a (:a foo)] (println a))
;; => prints "1", returns nil
(when-let [{:keys [a]} foo] (println a))
;; => prints "1", returns nil
(when-let [a (:a (assoc foo :a nil))] (println a))
;; => returns nil
(when-let [{:keys [a]} (assoc foo :a nil)] (println a))
;; => prints "nil", returns nil
``` | 2017-12-29T12:15:13.000266 | Venessa |
clojurians | clojure | i would like for the final expression to not print “nil”, ie the destructuring bind on a nil key to not evaluate the body of the when | 2017-12-29T12:16:27.000213 | Venessa |
clojurians | clojure | does clojure have a distinction between a missing and nil key in its map type? | 2017-12-29T12:16:48.000220 | Venessa |
clojurians | clojure | <@Venessa>it's because the value pre-destructuring is not nil. | 2017-12-29T12:16:55.000088 | Jodie |
clojurians | clojure | It does, you can use `contains?` to distinguish the 2. | 2017-12-29T12:17:05.000243 | Jodie |
clojurians | clojure | right | 2017-12-29T12:17:16.000208 | Venessa |
clojurians | clojure | ok thanks <@Jodie> | 2017-12-29T12:17:21.000276 | Venessa |
clojurians | clojure | so the idea is that the expression used as the value for that binding must be nil for the `when` to not execute? | 2017-12-29T12:18:32.000145 | Venessa |
clojurians | clojure | contains has nothing to do with what <@Venessa> is asking here -- there's just no way to use `when-let`/`if-let` on destructured values | 2017-12-29T12:19:49.000137 | Kareen |
clojurians | clojure | when you do `(when-let [{:keys [a]} x] ..)` the when-let is testing on the value of `x` | 2017-12-29T12:20:08.000258 | Kareen |
clojurians | clojure | <@Kareen> no that was helpful! i get its not exactly related to my example under question | 2017-12-29T12:20:18.000074 | Venessa |
clojurians | clojure | because it expands to something like `(when-let [the-map x] (let [{:keys [a]} the-map ..))` | 2017-12-29T12:20:30.000252 | Kareen |
clojurians | clojure | right | 2017-12-29T12:20:36.000294 | Venessa |
clojurians | clojure | (that's not the macroexpansion at all, just what it's doing logically) | 2017-12-29T12:20:52.000073 | Kareen |
Subsets and Splits