Fork me on GitHub
#clojure
<
2018-08-15
>
tcrawley01:08:38

@joshua.d.horwitz @eigenhombre @dbernal Just to close the loop here - the default repo is hosted by a Fastly CDN. I suspect they were having some temporary issues.

noisesmith01:08:08

@emccue try already has an implicit do

noisesmith01:08:03

when I wrote that macro I used (catch Exception _#)

noisesmith01:08:18

bodies with nothing in them return nil

emccue01:08:39

eh, but that isnt entirely hygenic that way

emccue01:08:01

if i wrote the macro using the implicit do I could say

emccue01:08:28

I prefer to explicitly return nil, but thats just my taste

emccue01:08:11

not sure if that actually fits how hygiene is defined, but im not googling it

petterik05:08:48

shell script for calling the structural diff library autochrome like git diff.

đź‘Ź 4
petterik05:08:45

It's so awesome that one can use clj with inline deps like this.

colinkahn05:08:02

I'm trying to get tools.cli to parse an option with the config: [["-ph" "--proxy-host HOST" "Proxy host"]], but it interprets the short version as two unknown flags -p and -h. Is there a way to make -ph work?

dominicm07:08:54

How is unquote bound? I can't see anything from grepping the clojure codebase.

jeroenvandijk07:08:02

Question about tools.deps / clj . I'm trying to use a :gen-class namespace with tools.deps, but haven't been successful so far. I have to go back to boot to get what I want (i.e. compile a namespace). Is there a way to get tools.deps to support :gen-class namespaces?

Alex Miller (Clojure team)11:08:51

Built-in, no - tools.deps is designed for projects that don’t require a build step and their deps

Alex Miller (Clojure team)11:08:29

You could explicitly invoke compile and include the output dir as two commands

jeroenvandijk18:08:40

Cool, thanks. I'll experiment a bit to find a workable option

jeroenvandijk09:08:04

@U064X3EF3 The following works for me. If I compile my subproject with boot (and a deps.edn file) like follows

boot -d seancorfield/boot-tools-deps:0.4.5 deps aot -a target
And when I add the dir target to the classpath the depending projects don't need to compile anything:
{:paths ["resources" "src" "target"] 
...
}

dominicm07:08:56

That appears to convert ~ to (clojure.core/unquote ...). But how does unquote do something?

schmee07:08:49

if you search for “unquote” in LispReader.java you can see all the places where it is handled

dominicm07:08:55

I did, but didn't find much. Although may case sensitivity bit me

Alex Miller (Clojure team)12:08:30

It’s all in the reader

dominicm12:08:29

Okay, I'll have another poke.

dominicm12:08:38

Although I've now gone down a different path for resolving what I'm up to.

noisesmith17:08:00

quick experiment using tools.deps in docker such that it could be used in a shell script (long story, it makes sense in a specific infrastructure)

justin.smith@C02RW05WFVH6: ~/ledger$ docker run -i clojure:tools-deps-1.9.0.381 clojure -e '(def important :a)' - << HERE
> (defn go
>   []
>   (println important))
> 
> (go)
> HERE
#'user/important
:a

parrot 8
abdullahibra18:08:01

how can reset atom to it's default state ?

abdullahibra18:08:30

(def hello (atom {:hello nil :world []}) ; default state

abdullahibra18:08:49

now doing some processing and want to get back to default state again how can i do this?

abdullahibra18:08:58

something like copy object in OOP

noisesmith18:08:08

you can use reset! if you don't care about what some other thread is doing with the data

noisesmith18:08:40

to be clear, the "default state" would be a concept in your code but not actually built into the atom itself

the2bears18:08:47

(def default-state {:hello nil :world []})

abdullahibra18:08:52

but if i have an atom with default values which behave as initial values

the2bears18:08:06

(def hello (atom default-state))

the2bears18:08:35

As noisesmith said, this isn't something built into the atom

abdullahibra18:08:46

thanks guys got it

fingertoe20:08:05

Seems like gorilla-repl is a bit unmaintained these days. Are there alternative notebook style environments that support CLJ/CLJS?

mkvlr20:08:13

@fingertoe Nextjournal does support both (and is written in it). But support isn’t as easy as we’d like it to be yet, see or remix https://nextjournal.com/schmudde/repl-driven-development for how to add deps currently. If you’d like to give it a try, use the invite code curryon2018 to signup.

fingertoe20:08:38

Thanks! I will check it out.

mkvlr20:08:49

let me know if you have questions or any other feedback!

emccue20:08:09

is there a good walkthrough of wiring lacinia up to a ring app outside of pedestal? specifically I want to use graphiql and have a schema available like with apollo

emccue20:08:34

I have a windows machine so unfortunately i cant just use the pedestal integration

skrat21:08:34

please remind me someone: what's the syntax for defining fixed arity anon fn, eg. #(foo) with fixed arity, of say 2 args, meant for java interop, there was some special syntax for that, in front of the # or between the # and (, not sure

pauld21:08:08

Hmmm, #(foo %1 %2)?

skrat21:08:24

yeah, but I'm not using any of the args 🙂 that the issue

skrat21:08:01

just side-effecting

pauld21:08:11

I probably can't help. I didn't know you could pass functions into java methods.

skrat21:08:50

yeah, you can, they become Runnable or something, not sure how this works with arguments

pauld21:08:41

Maybe if I saw an example I would understand better.

phronmophobic21:08:49

@skrat, how about (fn [_ _] *do stuff* )

skrat21:08:47

@smith.adriane of course, I'm just nitpicking here, and I'm quite sure there is a syntax for this 🙂

skrat21:08:16

"no one knows about it", not google, but I've seen it somewhere

pauld21:08:46

ah, yeah I had that issue too and I just did what skat did in the past if I recall correctly.

skrat22:08:19

(#(+ 1 2) 1) will throw an ArityException

hiredman22:08:05

all clojure functions implement Runnable

hiredman22:08:55

user=> (supers (class (fn [_] _)))
#{clojure.lang.IFn java.lang.Runnable clojure.lang.IObj java.io.Serializable clojure.lang.IMeta clojure.lang.AFunction java.util.concurrent.Callable java.util.Comparator java.lang.Object clojure.lang.AFn clojure.lang.Fn}
user=> 

hiredman22:08:35

you may be thinking of memfn, but don't think about it, it is a best forgotten thing that existed before the #() short hand syntax did

phronmophobic22:08:56

the only form I’ve seen with the # type of anonymous function is (#(do %1 (+ 1 2)) 1) for specifying arity

hiredman22:08:46

user=> (#(do %& (+ 1 2)) 1 2 3 4 5)
3
user=>

hiredman22:08:16

but all that is silly, better to use (fn [& _] ...) or similar as already recommended

skrat22:08:16

yeah 🙂 then I'd rather stick to using (fn ...)

skrat22:08:33

jeeez, there is such a thing!

skrat22:08:41

found it by trying out different things

skrat22:08:50

(#(^%1 + 1 2) 1)

skrat22:08:05

might be a reader hack though, but it works

hiredman22:08:32

absolutely not

dpsutton22:08:44

what's going on there?

skrat22:08:51

guess I'm just adding meta to the +

skrat22:08:12

but the reader recognizes that the %1 is used, and make an arity 1 function

hiredman22:08:39

you are type hinting the value returned when looking up the name + with with the gensym the reader creates

hiredman22:08:46

absolutely not

skrat22:08:57

this works too (#(#_%1 + 1 2) 1)

skrat22:08:29

less gore

hiredman22:08:49

slightly less gross, but still, what are you even doing? just write some code people will be able to read

skrat22:08:37

no I'm definitely sticking with (fn [_] ...), but wound up hacking the reader for fun

dpsutton22:08:04

the #_%4 side effects the reader even though it is commented out?

dpsutton22:08:57

cljs$user$thing(p1__50868_SHARP_,p2__50869_SHARP_,p3__50870_SHARP_,p4__50871_SHARP_,p5__50867_SHARP_){
return ((1) + (1)).call(null);
}
yup

dpsutton22:08:08

#(#_%5 (+ 1 1))

skrat22:08:15

yeah, not sure I'd call it side effecting, but it makes it recognize 4th arguments being used, and creates arity 4 fn

skrat22:08:43

well, it's not an issue in JS, but in JVM it is

dpsutton22:08:47

a comment that changes the emitted code is side effecting to me

skrat22:08:55

all fns are variadic in JS, there's no checks, but in JVM it throws ArityException

dpsutton22:08:19

if you provide too few its a problem nvm that a cljs protection

john23:08:00

user=> ((constantly (+ 1 2)) 2 3 4)
3
user=>

john23:08:00

kinda verbose though lol

john23:08:51

sometimes I'll use the #(do ...) for brevity

john23:08:14

oh, you're looking for enforced fixed arity for java interop, gotcha

pauld23:08:58

#(do %1 %2 *stuff*) - does that fix the arity?

noisesmith23:08:50

yes, #(do %2 ...) does as well, but why not (fn [ ] ...)

noisesmith23:08:39

it's only two characters longer and a lot cleaner

đź‘Ť 8