speculative

https://github.com/borkdude/speculative
borkdude 2018-12-02T10:16:03.001600Z

@flowthing I would be curious of more people used set/different as (set/difference set non-set ....)

borkdude 2018-12-02T10:17:09.002800Z

As KeySeqs are unique it feels a bit iffy to have to do (set/difference my-set (set (keys my-map)))

flowthing 2018-12-02T12:19:51.003400Z

Here's a map of [function-name occurrences] => examples of args passed to that function: https://gist.github.com/eerohele/0dd0606213331c2dc5e3b8df2b21f352

flowthing 2018-12-02T12:19:59.003700Z

Hope I didn't mess it up too bad... it's a pretty quick job.

flowthing 2018-12-02T12:21:03.003900Z

Yeah, I agree. Need to look into that.

borkdude 2018-12-02T12:22:27.004400Z

so 41 occurrences of difference with the arguments if I read that right?

flowthing 2018-12-02T12:22:45.004600Z

Yes.

borkdude 2018-12-02T12:23:12.005600Z

Seems like the (set/difference set non-set ....) pattern is pretty widely used

flowthing 2018-12-02T12:23:30.006100Z

With arguments that don't adhere to the specs now in Speculative, that is.

flowthing 2018-12-02T12:23:41.006300Z

Yep.

borkdude 2018-12-02T12:24:32.006800Z

I suggest making the but-first args reducible-colls as here: https://github.com/slipset/speculative/blob/master/src/speculative/specs.cljc#L70

flowthing 2018-12-02T12:26:22.008700Z

That can yield unexpected (non-set) return values.

borkdude 2018-12-02T12:26:34.008900Z

@flowthing how?

borkdude 2018-12-02T12:26:53.009200Z

I mean just for set/difference

flowthing 2018-12-02T12:27:57.009700Z

Ah! I misunderstood. Yeah, that might work, need to look into it.

borkdude 2018-12-02T12:30:57.010600Z

I’m looking at the offending calls to subset?. It seems only the second args has to be a set there. The first one is sufficient to be a seqable?.

borkdude 2018-12-02T12:32:52.011200Z

union is disputable if that should accept non-sets.

borkdude 2018-12-02T12:33:44.012200Z

according the :ret set? it’s wrong.

borkdude 2018-12-02T12:34:18.012700Z

lastly, I don’t see any offending calls for other set functions. is that correct? only three.

flowthing 2018-12-02T12:41:00.013500Z

Yeah, only three.

flowthing 2018-12-02T12:47:00.014800Z

I think it's sort of back to the old question… should the specs allow everything that works (albeit coincidentally) or is it more logical to just allow sets. I don't know the answer, at least.

borkdude 2018-12-02T12:49:32.016500Z

Summary : We discovered calls like: (set/difference set non-set) and (set/subset? non-set set). Both return sets in those cases. Coercion to set is unneeded. Not sure if users are relying on undefined behavior there or if we should account for it in the specs.

borkdude 2018-12-02T13:03:19.017400Z

Maybe make an issue for it as the history of this chat will disappear after a while

alexmiller 2018-12-02T15:37:08.018100Z

I would love any info like this to be on the CLJ ticket you made

alexmiller 2018-12-02T15:37:34.018700Z

that should be the place to record all data that goes into “deciding what to do”

alexmiller 2018-12-02T15:39:39.020300Z

my main questions are: 1) what are the main error cases that a spec (or validation) could tell someone about early and 2) what are the existing non-set use cases that people rely on that we want to preserve if the code is changed

alexmiller 2018-12-02T15:40:16.021Z

so that we can add value by detecting broken code and NOT break people’s existing non-broken code

slipset 2018-12-02T15:54:06.021700Z

That would be this issue, right? https://dev.clojure.org/jira/browse/CLJ-2433

alexmiller 2018-12-02T15:58:33.021900Z

yeah

slipset 2018-12-02T16:17:34.023200Z

There is definitely a blogpost if not a talk in this process that is speculative.

alexmiller 2018-12-02T16:19:43.026500Z

stuff that works should continue to work or (in our opinion) the spec is wrong

slipset 2018-12-02T16:20:08.027500Z

From its inception, mainly as a stubborn argument against you can’t contribute to Clojure without contributing to core. Through its development, where you Alex have shown interest and offered advice, to now where it’s somewhat helpful in the development of core (if you squint pretty hard)

alexmiller 2018-12-02T16:20:34.027600Z

you should account for it in specs

alexmiller 2018-12-02T16:21:50.029Z

I am interested in reaching some conclusions on the set stuff and doing whatever that conclusion is in the next release (whether it’s specs, validation, coercion, etc)

alexmiller 2018-12-02T16:22:01.029300Z

if only so we can never speak of it again :)

slipset 2018-12-02T16:22:36.029500Z

:)

slipset 2018-12-02T16:24:01.031600Z

Some informal chit-chat: I’m sitting on a plane watching conj-videos on my way to London to speak at ClojureX. The future is now :)

flowthing 2018-12-02T17:50:18.031900Z

All right, that's clear enough (and understandable, since it's in line with Clojure's don't-break-the-userspace policy). I'll check what that entails and modify the specs accordingly.

flowthing 2018-12-02T18:04:06.032100Z

(By extension, I guess that means that the functions in clojure.set will never include assertions, either. So the only options are either coercion or something like clojure.set2.)