Fork me on GitHub
#clojure
<
2015-09-06
>
rauh00:09:44

@sonnyto What's the exact trouble with read-string? Wild guess: Do you have a leiningen as a dependency?

sonnyto00:09:41

its probably not a problem with read-string... i have a very large edn string that fails with read-string

sonnyto00:09:53

its actually a datascript edn

sonnyto00:09:01

i am just trying to find out what is failing

sonnyto00:09:27

the edn is too large for me to guess what is failing

sonnyto00:09:45

i want to look at the value read-string is having a problem with

sonnyto00:09:05

the exception does not give enough information

sonnyto00:09:24

CompilerException java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.Number, compiling:(form-init8554715131569529748.clj:1:11)

tel00:09:20

Is there a way to extend-type functions?

tel00:09:27

(type +) just shows up as its name

tel00:09:21

(class +)
=> clojure.core$_PLUS_
?

tcrayford00:09:07

they all extend IFn and AFunction, so you can likely just use either of them

tel00:09:20

(defprotocol X (x [x]))
(extend-type AFunction X (x [f] 1))

CompilerException java.lang.RuntimeException: Unable to resolve symbol: AFunction in this context…
?

tel00:09:28

Same with IFn

tel00:09:36

Am I doing something wrong?

tcrayford00:09:54

clojure.lang.IFn

tel00:09:07

oh, cool, thanks!

tcrayford00:09:08

it's a neat thing: clojure is just a java program, you can go read how it works

cigitia00:09:47

I’m trying to remember the name of a (core?) function such that, given a collection, it applies a unary function f to every element, then returns a map from the function’s results to the elements that gave those results. For instance, (mystery-fn empty [[3 2] #{5} [4] {:x 3}]) would return something similar to {[] ([3 2] [4]), #{} (#{5}), {} ({:x 3}).

cigitia00:09:58

I could have sworn that it was in clojure.core, but I can’t find it.

tel00:09:03

Amusingly I’ve never really touched Java.. Closest I get is Clojure simple_smile

tel00:09:11

sometimes Scala

amithgeorge00:09:03

user=> (group-by empty [[3 2] #{5} [4] {:x 3}])
{[] [[3 2] [4]], #{} [#{5}], {} [{:x 3}]}

amithgeorge00:09:23

off-topic, how did tcrayford manage to have his url displayed prettily, with page title/description n stuff. I am able to only post a vanilla url - https://clojuredocs.org/clojure.core/group-by

akiva01:09:29

It’s probably the site.

amithgeorge01:09:08

Could be, looking at the urls posted over last few days, not all of them get the pretty url treatment. Thanks.

cigitia01:09:58

@amithgeorge: Yes, thank you so much.

bobmoff12:09:59

Hi everybode, I am a Clojure noob and coming from the Node-world. I wanted to try and create a http api and got it up and running using http-kit. My question is if there is any way to get a instant reload/feedback loop going while developing? Making a change in a router and then having to recompile everything takes very long. Any tips and trix to get the dev flow up to par with node?

jaen12:09:32

@bobmoff: try the code here, last time I tried it it worked - http://www.http-kit.org/migration.html#reload

jaen12:09:57

Also if you feel like learning https://github.com/stuartsierra/component at some point then it has a really nice development workflow with https://github.com/danielsz/system#boot-system

amacdougall16:09:39

Does anyone have a preference for an automatic test runner for clojure.test? It seems like https://github.com/jakemcc/lein-test-refresh lets you put failures on a Growl or send-notify or whatever, which is nice; but then https://github.com/jakepearson/quickie automatically reloads namespaces, which is also nice.

nberger17:09:02

There was a bit of discussion about automatic test runners in #C08LK2DH7, you might want to check it

amacdougall17:09:32

Unfortunately, until someone comes up with the $20,152/month ($8/mo, 2519 in channel right now) for Slack to archive messages for this organization, or Slack provides more features to nonprofit orgs like this one, stuff falls out of the archive very quickly.

amacdougall18:09:38

Anyway, I think I can get the best of both worlds by combining Quickie with multitail. If I get it working, I'll post it here!

kardan18:09:02

What are people using for form validation, been using schema but wonder if Bouncer, Herbert or something else would be better. Any tips?

jaen18:09:41

IMO schema only makes sense for coercion if we're talking about forms. I mean, I imagine you can user predicates to validate things other than types for sure, but it feels weird to me to use that for logic validation. For validation I've used validateur, bouncer and cats' Validation applicative with a custom map semigroup implementation that would merge error sets (in order I tried those solutions). I think bouncer seemed slightly nicer to me than validateur (YMMV though) and the last one is just me being silly.

jaen18:09:37

https://github.com/jkk/verily looks interesting in that validators get the whole map as argument (thus a validator can validate how two fields relate for example) which seems interesting, but I didn't have an occasion to try it yet

kardan18:09:11

@jaen agree on Schema in this use case. I mostly used it since I already know it simple_smile Had not seen Verily, thanks for the tip!

amacdougall18:09:07

So this is what ended up working for me:

multitail -cT ANSI -ex "(FAIL|ERROR|error-while-loading)" "notify-send -i stop" -l "lein quickie"
Replace notify-send with the Growl-like command of your choice.

amacdougall18:09:42

This gives me the namespace reloading of Quickie, and the error notification of lein-test-refresh. I briefly tried it with success notifications, but it was too spammy.

paulspencerwilliams18:09:02

Hi all, any pointers for writing ring POST endpoints to accept application/transit+json using ring-transit/wrap-transit-body. My handler, and POST request coming from re-frame is included at https://gist.github.com/paulspencerwilliams/10bf7a0bf69fbcc92308 - :body ends up nil.

paulspencerwilliams18:09:06

@roberto: cheers, just like my request :body 😉 Damn intermittent internet.

roberto18:09:04

what are you getting back?

paulspencerwilliams18:09:36

request :body is nil rather than the expected json data.

roberto18:09:40

silly question: is db/get-all returning anything?

roberto19:09:12

I would check that, then see if (json/write-str (db/get-all)) returns anything

roberto19:09:03

oh, your Content-Type should also be application/transit+json ???

paulspencerwilliams19:09:33

@roberto: it’s the request body that’s nil, not the response body.

roberto19:09:47

oh, i thought it was the response

roberto19:09:11

yeah, you would need to post the code that is doing the request

paulspencerwilliams19:09:31

@roberto: I think that might be the problem, I’d updated my cljs code, but was running it with lein ring, rather than lein figwheel, and thus I don’t think my cljs had compiled.