Fork me on GitHub

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)


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


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


@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


man, he should write a book


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


@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)


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


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?


agree that cautioning against “abusing” conformers should be documented


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 :)