This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-07
Channels
- # announcements (10)
- # babashka (11)
- # beginners (69)
- # calva (1)
- # cider (2)
- # clj-kondo (35)
- # cljdoc (48)
- # cljs-dev (3)
- # clojure (60)
- # clojurescript (10)
- # community-development (6)
- # cursive (4)
- # datahike (1)
- # datalog (33)
- # deps-new (2)
- # depstar (8)
- # docker (24)
- # fulcro (1)
- # graphql (4)
- # honeysql (5)
- # java (2)
- # leiningen (2)
- # missionary (3)
- # off-topic (104)
- # pedestal (8)
- # polylith (18)
- # portkey (3)
- # reagent (7)
- # reveal (1)
- # rewrite-clj (4)
- # shadow-cljs (19)
- # specter (3)
- # tools-deps (2)
Not really what you are asking for, but it reminds me of http://pedestal.io/api/pedestal.log/io.pedestal.log.html#var-spy from pedestal.log, which is quite useful
With tap you still retain the ability to print later, yet it opens up so much more possibilities
@isak (doto x tap>)
-- works really well in threading too (-> x (f1) (doto tap>) (f2 :a) (doto tap>) (f3))
I don't remember where I first saw that suggestion but I used to use it with println
in threading pipelines prior to tap>
appearing.
good point @U04V70XH6
I use it all the time for debugging. I have Reveal as a tap>
"listener" so when I run code I see all the values show up in Reveal and I can browse them structurally.
My RDD videos show tap>
in action
For tap if you are using cursive, something that makes it work pretty well in development:
(require '[puget.printer])
(let [print-taps-fn
(fn [x]
(puget.printer/with-options
{:width 40 :map-coll-separator :line}
(puget.printer/cprint x)))]
(add-tap print-taps-fn))
my only issue here is add-tap on a local means you have no handle to call remove-tap on
true, but I'm just evaluating it once when starting the program in development mode, so it hasn't been a problem for me
@deleted-user tap
is like Ruby’s tap
, if that helps at all
i guess i just meant to underscore it is used in practice an awful lot like a .tap in rubyland
https://github.com/devn/getclojure/blob/master/src/getclojure/search.clj#L40 this is really old
i think there was something funky about elasticsearch where certain chars would be treated like special chars within the query
Can someone explain where the function cyan
is coming from? https://github.com/cryogen-project/cryogen-core/blob/8318bde771d39515b5f5a7f5af53ba5c55aeec35/src/cryogen_core/sass.clj#L52
https://github.com/liquidz/clj-text-decoration/blob/master/src/text_decoration/core.clj#L26-L28
yep. makes sense.
What's the best way to figure out a shape of a nested data structure? Ie, the outline of the shape with empty structures, eg
'([{{}{}}][{{}}]) etc.
nice q, I gave it a shot:
(->> [[[1 {2 2}] {3 []}]]
(walk/postwalk (fn [x]
(cond
(not (coll? x))
x
(map-entry? x)
x
(map? x)
{}
true
(into (empty coll)
(remove (complement coll?))
x)))))
it doesn't go deep into maps b/c I don't have it clear what to do for an input like {1 []}
. If you remove the 1, you'd get an invalid map entryThe best way depends on the context. I use clojure fns at the repl to explore clojure data.
was wondering about a function that takes instances of a data structure and returns a valid spec for it
perhaps it could be applied to itself too if future versions of spec look more like data ([data samples] -> Spec) -> Spec
> was wondering about a function that takes instances of a data structure and returns a valid spec for it (edited) Such things exist, but they likely won't help you in a real application with so much going on. Your best bet is that a) there are tests b) you can repl in at the point of inspection c) visibility tools like tap or spy
d) there are specs
The background of my question is that the nested structure I'm getting from an api is way too long (thousands of records) to explore in repl. Moreover I'd be useful to check the right shape as one of the test cases. @U45T93RA6 snippet is interesting to explore further
thanks for explaining. There are also tools like revel or ciders inspect which will pretty print data and let you explore it. but i just wanted to give an overview. I usually end up using mix of everything all at once.