Fork me on GitHub
#clojure
<
2019-07-04
>
Gill Nitzan05:07:57

Hi, I am looking for some interesting open source (would like to contribute). Can someone please suggest me?

jakob06:07:34

Hi, I'm looking for something like prettier (https://prettier.io/) for clojure. It's an opinnionated code formatter that works across editors. What's awesome with this is that it removes all originial styling and reprints it pretty printed.

danieroux07:07:54

Look into https://github.com/kkinnear/zprint for a whole-project formatter. We standarised on https://tonsky.me/blog/clojurefmt across Cider and Cursive, and it’s working very well.

tavistock11:07:45

afaict it would be hard to remove all original styling because of macros. You would prbably want clojure.test/are to contain the same number of forms as its argv on each line, and other macros could have similar constraints. https://clojuredocs.org/clojure.test/are

ccfontes06:07:18

Hi, I’ve created this testing library: https://github.com/ccfontes/eg Hope someone finds it useful.

👀 4
Andrew15:07:37

Is there a nice way to get Robert Hooke (https://github.com/technomancy/robert-hooke) like behaviour with functions on records? I'm trying to record metrics for each invocation of every function on a large number of records, and don't really want to modify the implementations.

noisesmith15:07:26

@clojurians971 the only thing I can think of is using def-derived-map to reduce boilerplate a bit https://github.com/ztellman/potemkin#def-derived-map

noisesmith15:07:03

but maybe it makes more sense to use deftype, and delegate all the map methods plus the interface / protocol methods of the target

Andrew15:07:11

Thanks, I hadn't looked at Potemkin

dpsutton15:07:12

@clojurians971 zach tellman did a clever trick in manifold by making 1 out of 1024 records a stat emitting record. https://github.com/ztellman/manifold/blob/master/src/manifold/deferred.clj#L340 maybe this could help you?

dpsutton15:07:52

not sure if a sampling approach helps you but there's an example if you wanted to browse it

Andrew15:07:33

Cool, thanks. I'm happy for every invocation to be gather metrics, it's just a shame that I can't iterate over all vars on the protocol and wrap the invocation.

noisesmith15:07:16

if it's strictly protocols and not interfaces, you actually can access the method programatically, and you can even get the protocols implemented from a record programatically

noisesmith15:07:04

user=> (defrecord Foo [])
user.Foo
user=> (defprotocol IBar (do-bar [this]))
IBar
user=> IBar
{:on user.IBar, :on-interface user.IBar, :sigs {:do-bar {:name do-bar, :arglists ([this]), :doc nil}}, :var #'user/IBar, :method-map {:do-bar :do-bar}, :method-builders {#'user/do-bar #object[user$eval163$fn__164 0x565b064f "user$eval163$fn__164@565b064f"]}}
user=> (keys (:method-map IBar))
(:do-bar)
user=> (defrecord Bar [] IBar (do-bar [_]))
user.Bar
user=> (clojure.set/difference (supers Bar) (supers Foo))
#{user.IBar}

noisesmith15:07:35

that should be a starting point to iterating protocols on a record, finding the methods in them, and wrapping them programmatically

Andrew16:07:07

Ah! that looks useful, thanks

Andrew16:07:31

Do you know what :method-builders are?