Fork me on GitHub
#clojure-spec
<
2018-02-23
>
otfrom12:02:29

dumb question of the day: can you add a fsepc to a defmethod? (I remember reading somewhere you couldn't but I think I'm misremembering and google has been failing me)

mpenet12:02:55

You can't. you can spec the dispatch fn or/and create separate defns that will be called by the multimethod impl

otfrom13:02:32

I hadn't thought about specing the dispatch function but it is obvious now that you point it out

mpenet13:02:19

@alexmiller pointed that out the other day, didn't think of it either before then šŸ™‚

Alex Miller (Clojure team)13:02:52

That covers the args side at least

otfrom13:02:56

man, he should write a book

otfrom13:02:09

oh, sorry didn't see you there @alexmiller;-)

otfrom13:02:49

@alexmiller I was a bit surprised yesterday and today w/instrumenting an fspec. It looks like it calls gen/check on the way in which I wasn't expecting (21 times if I'm reading correctly)

otfrom13:02:10

we got caught out b/c we had a spec that was wider than the code that was being called

Alex Miller (Clojure team)13:02:15

Yeah, you are not the first

jjttjj19:02:50

Is leaning on spec's conform/unform to do translations to and from some outside api an intended and/or acceptable use case? IE if the api gives dates and integers as strings and i need to convert them to java dates and real ints when the come in, and convert them back to strings when they go back out to the api, and there are a lot of varied translations like this in a nested structure. I'm thinking I spec all the incoming string data with conformers, then additionally spec out all my own representations as normal. Is there a reason I'm missing not to do this?

taylor20:02:45

agree that cautioning against ā€œabusingā€ conformers should be documented

seancorfield20:02:06

I would have sent a PR for the site repo -- but conformer isn't even mentioned anywhere there. So I think it would have to be a docstring update for the function itself? @alexmiller thoughts?

Alex Miller (Clojure team)21:02:41

Itā€™s intentionally not mentioned as anti documentation :)

Alex Miller (Clojure team)21:02:06

but maybe it should be more explicitly unmentioned :)