speculative

https://github.com/borkdude/speculative
flowthing 2018-12-01T07:48:03.007600Z

Done.

borkdude 2018-12-01T07:53:00.007900Z

@flowthing Is there anything else you would like to do before we merge it?

borkdude 2018-12-01T08:05:19.008600Z

I haven’t heard comments about the PR from @slipset or @mfikes so I assume they are fine with it

flowthing 2018-12-01T08:12:06.011100Z

Well, I wanted to give coal mine one last go on my own laptop. There's a run ongoing right now, let's see how it goes. Aside from that, I don't think there's anything left to do. We can make the non-set args change later if necessary, I think.

👍 1
flowthing 2018-12-01T12:14:37.011900Z

I got coal-mine to run 🙌 it'll take me a while to sort through the logs, though.

slipset 2018-12-01T12:36:22.012900Z

@flowthing looks good to me! As I mentioned in the PR, if you could squash the PR into one commit (or a couple if that makes more sense to you), I’d be very happy.

slipset 2018-12-01T12:36:47.013400Z

Also, I’m happy that you’ve taken the approach that the set fns should receive and return sets.

flowthing 2018-12-01T12:38:54.014200Z

Sure thing, I have no problem squashing the whole thing.

borkdude 2018-12-01T12:48:37.014600Z

@slipset I agree on the set in and out

flowthing 2018-12-01T13:00:48.015200Z

Heh, my coal mine run eventually died with this:

rlwrap(1622,0x10e2db5c0) malloc: Incorrect checksum for freed object 0x7fd3cd001000: probably modified after being freed.
Corrupt value: 0xa700
rlwrap(1622,0x10e2db5c0) malloc: *** set a breakpoint in malloc_error_break to debug

clojure: Oops, crashed (caught SIGABRT) - this should not have happened!
If you need a core dump, re-configure with --enable-debug and rebuild
Resetting terminal and cleaning up...

flowthing 2018-12-01T13:01:04.015500Z

Should've probably used clojure instead of clj.

borkdude 2018-12-01T16:55:24.015700Z

https://github.com/borkdude/spec-search/

mfikes 2018-12-01T17:04:00.016200Z

Yeah, I think you are right Eero. That looks like rlwrap itself died.

flowthing 2018-12-01T17:09:17.016600Z

Yep. I tried clojure and I got a successful run.

flowthing 2018-12-01T17:09:33.016700Z

>Ran 50004 tests containing 191647 assertions. >0 failures, 782 errors.

borkdude 2018-12-01T17:10:08.017Z

kewl!

flowthing 2018-12-01T17:11:14.017300Z

Here's the log file (~5 Mb): https://gist.github.com/eerohele/416de832a832d64573a81942eae05fc1

flowthing 2018-12-01T17:12:29.018700Z

I just skimmed some of the clojure.set related failures. Every one I've seen so far has been a case of passing non-set args. A quick grep says there are almost 2000 clojure.set related hits, so, uh...

flowthing 2018-12-01T17:13:09.019500Z

I'll probably need to try to come up with some way of filtering the log.

flowthing 2018-12-01T17:14:17.019600Z

That's very cool! A bit like Hoogle for Clojure. 🙂

borkdude 2018-12-01T17:15:15.019800Z

Right!

flowthing 2018-12-01T17:16:42.020800Z

If I got my regexp right, 559 of the 782 failures are clojure.set related. I'll try to sort through at least some of them later.

borkdude 2018-12-01T17:37:56.021800Z

@flowthing

curl <https://gist.githubusercontent.com/eerohele/416de832a832d64573a81942eae05fc1/raw/75285f458af58a2dd6305ddbecba14a1b1065424/log.txt> | grep -a2 "Call to #'clojure.set"
should give you most of them

borkdude 2018-12-01T17:38:37.022Z

559 calls

borkdude 2018-12-01T17:38:45.022200Z

that’s what I got too with this

flowthing 2018-12-01T17:43:26.022700Z

Some interesting stuff here... for example, (set/subset "H" #{\! \, \.})

borkdude 2018-12-01T17:43:42.022900Z

lol

borkdude 2018-12-01T17:44:07.023300Z

if you feel bored, you can submit a PR to coal-mine to remove these 559 examples

flowthing 2018-12-01T17:44:37.023600Z

Ehh... 😛

borkdude 2018-12-01T17:44:50.023900Z

$ clj -Aspeculative --args 'inc [1 2 3]' -r '[2 3 4]' -e
(clojure.core/map)
😎

👏 1
borkdude 2018-12-01T17:45:11.024300Z

can’t wait to try this with your set functions 😉

flowthing 2018-12-01T17:47:31.024500Z

Heh. 🙂

flowthing 2018-12-01T17:48:01.025100Z

A lot of cases of people calling set/union with map args here.

borkdude 2018-12-01T17:50:32.025900Z

probably for the same reason people call merge instead of conj all the time. they just try stuff, and if it works they’re happy and keep using this pattern

flowthing 2018-12-01T17:51:03.026200Z

Yep.

borkdude 2018-12-01T17:53:39.026700Z

In contrast, I haven’t found any such error in advent-of-cljc so far

borkdude 2018-12-01T19:45:03.027Z

New feature:

$ clj -Aspeculative --args '"foo" 1' --ret 'string?' -v

|          function | arguments | return value |
|-------------------+-----------+--------------|
| clojure.core/subs |   "foo" 1 |         "oo" |
|  clojure.core/str |   "foo" 1 |       "foo1" |

borkdude 2018-12-01T20:20:37.027400Z

Another project on core specs: https://github.com/gnl/ghostwheel.specs

slipset 2018-12-01T20:32:04.027900Z

Interesting, a lot of work done there.

flowthing 2018-12-01T21:09:30.029200Z

Well, I went through the log. The overwhelming majority of cases is calls to set/union with list or vector args. I didn't spot anything that seemed to be an error in the specs.

flowthing 2018-12-01T21:09:56.029900Z

So if you're happy with the current state of the PR, as far as I'm concerned, you can push the "Merge and Squash" button, or I can squash it manually tomorrow.

flowthing 2018-12-01T21:11:09.030100Z

Off to sleep now...

borkdude 2018-12-01T21:12:37.030300Z

done

borkdude 2018-12-01T21:46:56.031Z

$ clj -Aspeculative --args 'nil' --ret 'nil' -e -v

|                 function | arguments | return value |
|--------------------------+-----------+--------------|
| clojure.set/intersection |       nil |          nil |
|       clojure.core/first |       nil |          nil |
|       clojure.core/merge |       nil |          nil |
|   clojure.set/difference |       nil |          nil |
|        clojure.set/union |       nil |          nil |

borkdude 2018-12-01T21:47:00.031300Z

it works 🙂

alexmiller 2018-12-01T21:47:07.031500Z

If you have data and analysis of set fn calls in the wild, please add to that ticket in CLJ

borkdude 2018-12-01T21:48:21.031700Z

$ clj -Aspeculative --args '#{1 2} #{2 3}' --ret 'set?' -v

|                 function |     arguments | return value |
|--------------------------+---------------+--------------|
| clojure.set/intersection | #{1 2} #{2 3} |         #{2} |
|   clojure.set/difference | #{1 2} #{2 3} |         #{1} |
|        clojure.set/union | #{1 2} #{2 3} |     #{1 3 2} |
|       clojure.set/select | #{1 2} #{2 3} |         #{2} |

alexmiller 2018-12-01T21:52:11.032300Z

Frequency data of important cases would be most useful

borkdude 2018-12-01T22:11:18.033500Z

Going through the data of 4clojure, it’s mostly garbage calls that could be replaced by conj probably. But now that we have it in speculative, we may find more “real life” cases and I’ll definitely report them

alexmiller 2018-12-01T22:28:15.034100Z

Well I’m interested in frequent wrong cases too

borkdude 2018-12-01T22:30:57.034600Z

The thing that happens frequently in 4clojure data is that merge is called as a conj replacement.

alexmiller 2018-12-01T22:32:03.035200Z

How does that relate to clojure.set?

borkdude 2018-12-01T22:36:21.035700Z

@flowthing is probably detecting the same stuff: https://clojurians.slack.com/archives/CDJGJ3QVA/p1543698570029200

borkdude 2018-12-01T22:36:57.036300Z

if you’re interested:

curl <https://gist.githubusercontent.com/eerohele/416de832a832d64573a81942eae05fc1/raw/75285f458af58a2dd6305ddbecba14a1b1065424/log.txt> | grep -a2 "Call to #'clojure.set"
will give you an impression

borkdude 2018-12-01T22:42:35.037100Z

Funny, I detected one spec error in an advent of code solution by myself. None of the other solutions (48) gave problems.

borkdude 2018-12-01T22:43:06.037500Z

Here I’m calling set/difference with a key-seq instead of a set: https://github.com/borkdude/advent-of-cljc/blob/master/src/aoc/y2017/d07/borkdude.cljc#L42

borkdude 2018-12-01T22:43:14.037900Z

it wasn’t on purpose, just something that happened to work

borkdude 2018-12-01T22:44:52.038700Z

I guess the second and others arg don’t have to be a set, as long as the first one is, because it uses reduce + disj

borkdude 2018-12-01T22:47:29.040100Z

something that might have to be changed to the spec, or maybe we can agree that we should not rely on it

borkdude 2018-12-01T22:54:54.040500Z

This is a case where coercing to a set also is unnecessary

borkdude 2018-12-01T23:04:46.042Z

The only other place off the top of my head where a set fn isn’t called with a set if also with KeySeqs: https://github.com/clojure/clojure/blob/master/src/clj/clojure/data.clj#L118

borkdude 2018-12-01T23:23:10.042700Z

but I would be happy to change my advent of code solution to fit the spec