Fork me on GitHub
#clojure
<
2018-08-23
>
pbaille09:08:38

Hello, i’m struggling on something:

(do
  (refer 'clojure.core :exclude '[cat])
  (def cat 0))
is this supposed to emit a warning?

bronsa09:08:25

if you're evaluating that in the context of a namespace that already imported clojure.core, yes

pbaille09:08:09

thank you, do you know how can i evaluate something before importing clojure.core? I’ve got namespaces that (load ...) files after the ns form and those loaded files are containing the previously posted form.

bronsa09:08:01

you probably want to load those files in the context of a temporary namespace that doesn't import clojure.core

pbaille09:08:27

ok i will think about a way to do that, thank you for your help.

henrik11:08:36

Is there any good alternative to buddy for signing JWTs?

roklenarcic11:08:55

when writing a macro, is there a way to say if x emit symbol else emit nothing

moxaj11:08:05

@roklenarcic you have to return a valid clojure expression - nil at the very least

moxaj11:08:42

what is your use case?

veddha12:08:33

can someone tell how to use media query css at fulcro?

sundarj12:08:55

@veddha.riady i've answered this in a thread at #beginners

josh_tackett16:08:54

is (doseq...) done async?

ghadi16:08:22

no it's eager

seancorfield17:08:26

Do I remember correctly someone observing that Clojure Applied uses records fairly heavily? I'm trying to remember what Alex said about that (and whether he's changed his position any since writing that)? (I don't want to @ him right now since he doesn't show "green")

Eric Ervin18:08:05

Yes. I just reread that book and it does. It then goes on to validate the records using Prismatic Schema. That has all been washed away by clojure.spec?

johnj18:08:51

I would like to know his answer too

Eric Ervin18:08:17

I'm a few chapters away from the records chapter in Getting Clojure. I'll probably take that as the current, informed opinion on records.

bbrinck18:08:31

Alex speaks about this on episode 143 of cognizant. Discussion of book and spec stars at 18:30

bbrinck18:08:06

The cognicast, I mean

seancorfield18:08:53

Cool, I'll try to find time to listen to that later today!

Alex Miller (Clojure team)20:08:40

in some future version records will be less prominent and spec will replace schema

4
👍 4
seancorfield23:08:55

Good episode of the Cognicast -- thanks for the pointer @U08EKSQMS!

👍 4
mschmele17:08:39

I'm trying to find the size in some multiple of bytes of given objects and was trying to use Java's Instrumentation class but was having some trouble. Is there a better approach to this? I'm hoping to be able to log the size of ingested data into a system for metric purposes

mauricio.szabo18:08:52

Did you try to use VisualVM?

micahasmith18:08:15

does anyone have any working examples of building an async api web project? i'm cool with using aleph, http-kit, ring, compojure, anything, that works and does the basic stuff (send/receive json) and isn't error-prone. i've been trying to get an async web server up and running for the past 2-3 days and the experience has been pretty terrible

dominicm19:08:25

Aleph with manifold has been really great. What are you struggling with exactly?

dominicm19:08:00

Peculiar. I would expect the same example to work in yada

micahasmith19:08:17

i've yet to see a full POST example for async in yada either on the web

hiredman19:08:58

have you looked at pedestal?

hiredman19:08:49

the only async webserver stuff I've done was built on top of https://github.com/mrniko/netty-socketio which was a requirement because using socket io was a requirement, but that required a lot of building up to get anywhere. free of the socket io requirement I think I would start with pedestal

johnj19:08:16

for what its worth, the difference between synchronous ring/compojure and async pedestal is not much per the web frameworks benchmarks game.

josh_tackett19:08:44

anyone know a good POS tagger for clojure?

josh_tackett19:08:33

nvm found a few

john20:08:22

Not sure if this does what you want, but your question reminded me of it: https://github.com/clojure-goes-fast/clj-memory-meter

mschmele20:08:36

This looks perfect - thanks!

mschmele20:08:41

Going to give it a try now

leontalbot19:08:30

Maybe with this syntax?

(let [params {:a 1 :b 1 :c nil :d nil}] 
  (cond$-> params
    (:a $)       (update :b inc)
    (= (:b $) 2) (assoc :c "here")
    (:c $)       (assoc :d "here")))

;;=> {:a 1, :b 2, :c "here", :d "here"}

micahasmith19:08:38

always wanted that too. kinda like a mix of cond-> and as->

👍 4
josh_tackett20:08:52

is there a good place to find what the POS tags actually stand for? Like what is RB and CD?

the2bears20:08:45

Had to look POS up 🙂

seancorfield20:08:42

@leontalbot At work we have condp-> and condp->> that thread through the predicate as well as the expression and that's usually enough:

(let [params {:a 1 :b 1 :c nil :d nil}]
  (condp-> params
    :a (update :b inc)
    (as-> p (= (:b p) 2)) (assoc :c "here")
    :c (assoc :d "here")))

leontalbot20:08:17

is :c apply to original params or new version of it?

seancorfield20:08:04

New version. It threads through everything.

leontalbot20:08:20

close-sourced?

seancorfield20:08:28

Well, it's part of our production code base. We haven't turned it into a library yet because it's just "utilities".

seancorfield20:08:24

@micahasmith Maybe I should just open source our little worldsingles.clojure.extensions namespace... People keep asking for these things 🙂

😃 8
seancorfield20:08:06

condp-> -- an extension to cond-> that threads the expression
    through the predicate(s) as well as the result(s).
  condp->> -- an extension to cond->> that threads the expression
    through the predicate(s) as well as the result(s).
  condq -- a version of condp that accepts a unary predicate and omits the
    expr (that condp uses as the second argument to the predicate).
  dissoc-all -- an extension to dissoc that dissoc's a sequence of keys.
  flip -- a companion to partial that allows the first argument to be
    omitted (rather than the trailing arguments). Inspired by Haskell's flip.
  interleave-all -- an extension to interleave that uses all elements
    of the longer sequence argument(s).

micahasmith20:08:16

@seancorfield oh, yeah definitely. i will very gladly open source our helpers.clj file of misc helpful fns and macros as well. always wonder what those look like at other companies

micahasmith20:08:43

(and how many bugs we're unaware we have in ours...)

seancorfield20:08:17

☝️:skin-tone-2: Yes, a very good reason to open source something -- more 👀 on it!

jeroenvandijk09:08:05

I have been happily using seancorfield/boot-tools-deps:0.4.5 with deps.edn projects lately. A must have to be able to work with deps.edn and aot projects 🙂

4
Michael Stokley23:08:32

are partial functions (partially applied functions) not as first class as they could be?

Michael Stokley23:08:35

rules-engine.core> (replace {"inc" (partial + 1) "0" 0} '("inc" "0"))
(#function[clojure.core/partial/fn--5380] 0)
rules-engine.core> (eval *1)
IllegalArgumentException No matching ctor found for class clojure.core$partial$fn__5380  clojure.lang.Reflector.invokeConstructor (Reflector.java:163)

Michael Stokley23:08:37

i was thinking that would work just as this does:

rules-engine.core> (replace {"+" + "1" 1 "2" 2} '("+" "1" "2"))
(#function[clojure.core/+] 1 2)
rules-engine.core> (eval *1)
3

hiredman23:08:08

eval works on forms

hiredman23:08:20

a function object is not a form

hiredman23:08:49

sort of by accident because of this special case in eval it does work for some function objects

Michael Stokley23:08:00

(#function[clojure.core/partial/fn--5380] 0) <- that isn't a form?

hiredman23:08:40

a form would be ((partial + 1) 0)

Michael Stokley23:08:43

the fact that (#function[clojure.core/+] 1 2) will eval is an accident?

hiredman23:08:02

you are effectively feeding the output of eval into the input of eval, and the domain and range of eval are different

hiredman23:08:02

accident is maybe a strong word, unintended consequence of a decisions to support some other features

Michael Stokley23:08:37

so maybe i should be doing it like this:

rules-engine.core> (replace {"inc" '(partial + 1) "0" '0} '("inc" "0"))
((partial + 1) 0)
rules-engine.core> (eval *1)
1

Michael Stokley23:08:56

ah, just read the link you sent.