Fork me on GitHub
#clojure-uk
<
2017-04-04
>
thomas07:04:53

hhmmm very empty here... what happened?

Rachel Westmacott08:04:36

"The Silence of the Lambdas"

yogidevbear08:04:27

I'm sure I'm not along in this sentiment, but there really aren't enough hours in the day

yogidevbear08:04:16

or there are too many factors taking up my time from the things I really want/need to focus more on

glenjamin08:04:53

I’ve found increasing my day rates and working a bit less has helped there

Rachel Westmacott08:04:27

I've found that having children does not help with this problem

yogidevbear08:04:24

@glenjamin I wish I could tell my boss to up my pay and decrease my working hours 😉

agile_geek08:04:13

the other thing with increasing day rate is if you're in an advisory/consultancy role your voice gets listened to more!

Sam H09:04:20

did we give up on the clojure.core function of the day?

agile_geek09:04:34

When was that a thing? Must have missed it!

Rachel Westmacott10:04:16

@shan if you have a core function to share I'm sure we're all happy to learn about it...

Rachel Westmacott10:04:54

((juxt :name :doc) (-> 'clojure.core the-ns ns-publics vals rand-nth meta)) sadly Clojurebot thinks this is too risky and won't run it

mccraigmccraig10:04:45

huh, what's bad about ns-publics ?

bronsa10:04:30

you can break the sandbox

bronsa10:04:57

by accessing eval through ns-publics

mccraigmccraig10:04:09

ah, yeah, that makes sense

Rachel Westmacott10:04:29

the-ns is also bad (and not actually needed here)

dominicm10:04:29

@benedek I love clojure.data/diff! Used it on a number of occasions. It's definitely as useful as juxt (in my experience anyway)

benedek10:04:07

yup very helpful function and frequently forgotten, overlooked

dominicm11:04:09

Perfect for datomic's cardinality many types, where you can't "clobber" them (e.g. say that x = #{1 2 3}) You have to do a diff of current value (`#{3 4 5}`) and generate the list of things you're actually adding/removing.

benedek11:04:08

basically getting a delta, right? i should get some datomic foo at some point 😉

agile_geek12:04:04

I've been using clojure.data/diff a lot in tests to make more sane error messages on equality failure of more complex data structures.

dominicm12:04:05

+👍 I'd forgotten that

dominicm12:04:13

I hate it when I add a key and 100 tests fail

dominicm12:04:21

Those are tests wasting my time

Rachel Westmacott12:04:00

brittle tests can really be an impediment to change

tcoupland12:04:30

diff in tests is super handy, so handy i made this:

(defmacro is-submap
  [expected actual & [msg]]
  `(try
     (let [act# ~actual
           exp# ~expected
           [only-in-ex# only-in-ac# shared#] (clojure.data/diff exp# act#)]
       (if only-in-ex#
         (clojure.test/do-report {:type :fail
                                  :message (or ~msg "Missing expected elements.")
                                  :expected only-in-ex# :actual act#})
         (clojure.test/do-report {:type :pass
                                  :message "Matched"
                                  :expected exp# :actual act#})))
     (catch Throwable t#
       (clojure.test/do-report {:type :error :message "Exception diffing"
                                :expected nil :actual t#}))))

tcoupland12:04:16

which i bring up any time some mentions testing it seems these days 🙂

agile_geek13:04:43

@tcoupland useful! The only time I've ever written a macro (other than just playing around) was for testing to wrap kerodon expressions so that they return true or false rather than just output to the clojure.test/report-counters so I could use kerodon expressions in normal is tests (and in my case use kerodon in cucumber-jvm tests). https://gist.github.com/chrishowejones/4e8c60e3bcf1573de543

tcoupland13:04:28

testing is a good place for macro'ing i think, can be lots of repetition and fiddling about that won't quite fit into higher order fns. Plus, it is just good fun 🙂

agile_geek13:04:24

Also unless you want you're tests to be very brittle you don't often compose them!

reborg13:04:44

@tcoupland is that macro testing green with something like (is-submap nil anything-else)?

tcoupland13:04:20

@reborg cld do, not tried it, but that would in some ways fit with the idea. It's only checking if you have the expected stuff and is intentionally uncaring about anything extra. So, if your minimum is nothing, then anything is fine.

glenjamin13:04:32

@agile_geek are they usable in both contexts if you do that? Is that something that could be added to kerodon itself?

agile_geek13:04:11

Hmm, not sure. Been a long time since I looked at that stuff

tcoupland14:04:42

that said, i might add a map? in there 🙂

reborg14:04:58

@tcoupland I suppose it depends and it might be perfectly fine. I guess I just wanted to highlight corner cases related with nils and data/diff.

tcoupland14:04:00

it always depends doesn't it. Good highlighting, thanks!

reborg14:04:07

no worries! Nice use of diff anyway

glenjamin14:04:42

is that something you could do in the test runner?

glenjamin14:04:53

oh, sorry - i just read that properly

glenjamin14:04:10

i thought this was about diff for formatting, rather than diff for only asserting on bits you actually care about