Fork me on GitHub
#clojure-uk
<
2017-08-16
>
thomas08:08:57

morning 😼 mogge

Sam H09:08:51

Anyone here read Mastering Clojure Macros? Recommended reading?

reborg09:08:04

I did, it's nicely written.

reborg09:08:47

it goes by baby steps into all the macro features. If you like a gentle introduction, that's it.

dominicm09:08:41

I'm still looking for a regular practical usage of macros in a codebase, I haven't really found it. Does "Mastering Clojure Macros" go into any of that at all?

reborg09:08:45

Depending on the meaning of "regular practical usage" I guess 🙂

reborg09:08:43

there are a few examples toward the end of the book, on how to implement pattern matching or walking code via macros

reborg09:08:36

personally, I don't use them a lot (perhaps 1 or 2 per project)

otfrom09:08:40

@reborg 1 or 2 per project? I don't think I've written one yet. 🙂

Sam H10:08:21

@dominicm I’ve recently had to do something similar to https://github.com/clojure/tools.logging/blob/master/src/main/clojure/clojure/tools/logging.clj#L69 to get the namespace of where a “utility” function was called in.

dominicm10:08:45

Grabbing the *ns* is a good one, yep

dominicm10:08:02

But usually only for logging isn't it?

Sam H10:08:58

yeah, it was logging related. Definitely interested to see more use cases of it tho

danielneal10:08:17

I use a cheeky macro to grab the lexical scope for debugging sometimes, when the things I want to inspect are too big for printing and I want to explore them at the repl

(defmacro capture-env
  "Interns the lexical scope into user/sym"
  [sym]
  `(intern (symbol "user") (symbol ~sym) ~(into {} (for [[k# v#] &env] [(keyword k#) k#]))))

reborg10:08:33

also in my case, mostly tests or debugging, so very few

dominicm10:08:19

@danieleneal https://github.com/gfredericks/debug-repl a favourite tool of mine for exploring at the repl.

dominicm10:08:06

https://github.com/georgejahad/debug-repl also the original, which isn't nrepl integrated.

actionshrimp10:08:15

that looks awesome

actionshrimp10:08:33

I've missed debugger; from js land

dominicm10:08:43

I use vim, so I don't have the cider debugger. I really like this instead though.

actionshrimp10:08:54

I've got into the cider debugger a bit more recently. Although does it only work if you kick off execution from the REPL? I've tried instrumenting a function then making e.g. a request from a browser rather than the REPL and it doesnt seem to kick in that way

dominicm10:08:13

I think so. There's a branch of debug-repl which adds support for that workflow.

danielneal10:08:14

and that's usually when I need it most 🙃

dominicm10:08:39

Yep, because wtf is even in a req at this point!

danielneal10:08:47

hahaha we've all been there

dominicm10:08:18

I do wonder if it's a sign of overloading req's, but that's another conversation

danielneal10:08:47

any problem in web apps can be fixed by adding another middleware

dominicm10:08:44

or changing the order, sometimes that helps

dominicm10:08:02

weird, seems overly specific to http too. which makes me think it might require something

mccraigmccraig12:08:45

does anyone have a good experience creating excel files (ideally .xlsx) from clojure ? i seem to recall some #clojure-uk conversation about it a while back

danielneal12:08:25

mm my colleagues been using docjure

danielneal12:08:31

I think elise_huard was asking

danielneal12:08:00

docjure uses apache poi underneath

actionshrimp12:08:57

although I cant work out why my lens isnt dissocing

actionshrimp12:08:06

and it gives a very cryptic error message

danielneal12:08:16

what does it say

danielneal12:08:24

we can trade cryptic error messages

actionshrimp12:08:36

lens.cljc?rel=1502887456005:28 Uncaught TypeError: Cannot read property 'call' of null
    at traversy$lens$update (lens.cljc?rel=1502887456005:28)
    at lens.cljc?rel=1502887456005:99
    at core.cljs:5002
    at Function.cljs.core.update_in.cljs$core$IFn$_invoke$arity$3 (core.cljs:5002)
    at cljs$core$update_in (core.cljs:4993)
    at lens.cljc?rel=1502887456044:21
    at traversy$lens$update (lens.cljc?rel=1502887456005:28)
    at lens.cljc?rel=1502887456005:99
    at traversy$lens$fapply (lens.cljc?rel=1502887456005:35)
    at traversy$lens$update (lens.cljc?rel=1502887456005:28)

actionshrimp12:08:40

always a pleasure

danielneal12:08:24

both null pointers :facepunch:

danielneal12:08:27

is it a custom lens

actionshrimp12:08:38

fortunately not, I think I'm just being silly

danielneal12:08:43

don't be discouraged. Are you sure you're calling the update that you think you are? Perhaps you're using clojure.core/update in place of tl/update or something

elise_huard13:08:32

@mccraigmccraig my question was more about parsing excel files, not creating them - though would be interested to know if that works!

thomas13:08:15

@mccraigmccraig we use the apache poi (so just Java) to create excel files without too much trouble.

mccraigmccraig13:08:25

not even any jar-hell from poi @thomas ?

thomas13:08:19

not that I am aware of @mccraigmccraig

mccraigmccraig13:08:47

cool, i'll give that a blast then. thanks y'all