speculative

https://github.com/borkdude/speculative
borkdude 2018-10-20T18:12:04.000200Z

hi

mfikes 2018-10-20T18:15:07.000100Z

Howdy

borkdude 2018-10-20T18:51:33.000100Z

@slipset I’m still trying to merge, even after you closed the PR… damn 🙂

slipset 2018-10-20T18:51:56.000100Z

Sorry 🙂

slipset 2018-10-20T18:52:05.000100Z

Hopefully it’s all in now.

borkdude 2018-10-20T18:52:09.000100Z

now I’ve got a conflict on the README. wait a minute 😉

borkdude 2018-10-20T18:52:21.000100Z

no, I made a fix for the merge test so it worked on cljs as well

slipset 2018-10-20T18:52:32.000100Z

Ah, ok.

slipset 2018-10-20T18:52:53.000200Z

Chaotic times in the start of the project. Lots of stuff moving atm

borkdude 2018-10-20T18:52:57.000100Z

and I added instruction to README, but I’m fixing this conflic tnow

slipset 2018-10-20T18:54:31.000100Z

BTW, I discussed this a bit with @mfikes already, but I’m sort of wanting to offer whatever becomes of speculative to clojure/core. That is, I would like speculative to be in a state for clojure/core to take what ever they want from it.

slipset 2018-10-20T18:54:48.000100Z

I hope that’s ok with you @borkdude.

slipset 2018-10-20T18:55:32.000100Z

I’ve already sent an email to Alex asking what he needs from the project in terms of license/CA and stuff for them to be able to take code from speculative, if they ever wanted to do so.

borkdude 2018-10-20T18:57:32.000100Z

OK, PR ready. I’m sorry for the merge commits, but this is me trying to keep up 😓

borkdude 2018-10-20T18:59:25.000100Z

They can take whatever they want for core, no problem.

slipset 2018-10-20T19:00:32.000100Z

Merged.

slipset 2018-10-20T19:00:56.000100Z

You know with “Squash + Merge” in github, the merge-commits don’t matter 🙂

borkdude 2018-10-20T19:01:23.000100Z

ah GH can do that? nice.

borkdude 2018-10-20T19:02:09.000100Z

@mfikes The tests now run with planck. See the README

slipset 2018-10-20T19:04:42.000100Z

hmm, the test for merge is failing under cljs 😕

borkdude 2018-10-20T19:05:38.000100Z

Not on my machine

$ plk -A:test -e "(require '[clojure.test :as t])" -e "(require '[speculative.core-test])" -e "(t/run-tests 'speculative.core-test)"

Testing speculative.core-test

Ran 2 tests containing 8 assertions.
0 failures, 0 errors.

slipset 2018-10-20T19:06:25.000100Z

jeeeez this is moving to fast for me 🙂

borkdude 2018-10-20T19:09:17.000100Z

we could add those test expressions for plk into a script, I’m not aware of anything more concise. is this something you can put into deps.edn?

slipset 2018-10-20T19:16:22.000100Z

I just did like that,

slipset 2018-10-20T19:17:08.000100Z

Could probably be improved to return correct return-status so it could be used in the build pipeline.

slipset 2018-10-20T19:17:52.000100Z

@mfikes have you used circle with plk, as in any examples on the config.yml that would be needed to make sure plk is available?

borkdude 2018-10-20T19:19:06.000100Z

@slipset we could also use cljs.main with some other JS runtime, but this was just the easiest to get going initially

slipset 2018-10-20T19:19:22.000100Z

probably

slipset 2018-10-20T19:19:41.000100Z

I guess the most important thing is to get a critical amount of specs in 🙂

borkdude 2018-10-20T19:29:18.000100Z

@slipset I made a PR using https://github.com/Olical/cljs-test-runner. Maybe that’s easier on Circle. It supports various engines.

slipset 2018-10-20T19:30:12.000100Z

will have a look

borkdude 2018-10-20T19:30:12.000200Z

default is node

mfikes 2018-10-20T19:35:21.000100Z

Even if Alex doesn't take anything and the core team writes their own stuff, much of it would have to be ported to ClojureScript. So, ensuring speculative contributors have signed the Clojure CA would make that easier.

mfikes 2018-10-20T19:37:27.000100Z

So long as Circle is running Ubuntu 16 then it should be relatively easy to have it be set up for plk

mfikes 2018-10-20T19:38:14.000100Z

sudo add-apt-repository ppa:mfikes/planck
sudo apt-get update
sudo apt-get install planck

mfikes 2018-10-20T19:41:20.000100Z

I'll see if I can get plk running; it would be good to have both JVM and self-hosted coverage for ClojureScript.

borkdude 2018-10-20T19:59:48.000100Z

We could use https://lispcast.com/100-most-used-clojure-expressions/ (download: https://lispcast.com/wp-content/uploads/2015/11/clojure-analysis-results.csv) as a list of popular Clojure core functions and work our way down. Make an issue for each function. How does that sound?

mfikes 2018-10-20T20:00:07.000100Z

That does make sense

borkdude 2018-10-20T20:00:20.000100Z

I can also imagine that a lot of functions have a lot of common spec. Like keep/filter/map

slipset 2018-10-20T20:04:52.000100Z

That’s a very good idea. I was just spec’ing fns that came to mind.

borkdude 2018-10-20T20:05:15.000100Z

ok, I’ll filter this list on core functions that are not macros/special forms that already have some spec

borkdude 2018-10-20T20:06:29.000100Z

you can f/def a macro right? I’m not sure how a useful fdef for -> would look like

mfikes 2018-10-20T20:14:15.000100Z

Oh, wow. That CircleCI box is running an Ubuntu that was just released a couple of days ago (18.10, cosmic)

mfikes 2018-10-20T20:15:16.000100Z

Yeah, you can do macro defs @borkdude Here is an example https://github.com/clojure/clojurescript/blob/master/src/main/cljs/cljs/core/specs/alpha.cljc#L68

mfikes 2018-10-20T20:18:29.000100Z

I'm making a release of Planck for Ubuntu 18.10, which will probably take a few hours to churn through the system.

borkdude 2018-10-20T20:23:09.000200Z

https://github.com/slipset/speculative/issues/9

👍 1
borkdude 2018-10-20T20:29:33.000100Z

https://github.com/slipset/speculative/issues/10

borkdude 2018-10-20T20:33:06.000100Z

Not sure what’s going on with #10… I haven’t even instrumented anything yet

borkdude 2018-10-20T20:34:04.000100Z

Maybe CIDER is doing (stest/instrument) and then our fdef trips some error inside cider

borkdude 2018-10-20T20:35:44.000100Z

so we have a case to improve our reduce fdef, it’s not working on this expression: https://github.com/clojure-emacs/orchard/blob/master/src/orchard/misc.clj#L36

borkdude 2018-10-20T20:37:19.000100Z

it’s the same issue again with seqable? vs sequential?

mfikes 2018-10-20T20:46:23.000100Z

I think the spec might need to be something like that in https://github.com/slipset/speculative/issues/5

slipset 2018-10-20T20:50:56.000100Z

I might just let you file a PR for #5 @mfikes 🙂

slipset 2018-10-20T20:55:25.000100Z

It’s a bit strange writing tests for str and =

mfikes 2018-10-20T20:57:47.000100Z

Yeah, I'll file a PR for #5... it might be possible to use sequable? in there under Clojure, but at least the proposal in #5 would get things closer to right

borkdude 2018-10-20T20:59:28.000100Z

closer to right what we’re aiming for.

mfikes 2018-10-20T21:00:03.000100Z

Actually, CollReduce has this verbiage: https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/protocols.clj#L15

mfikes 2018-10-20T21:00:15.000100Z

So maybe it really is seqable?

mfikes 2018-10-20T21:00:43.000100Z

I'll try a cleaner patch and see what you all think.

borkdude 2018-10-20T21:05:34.000100Z

How do you spec the return value based on the args? Not possible currently in spec I think? E.g. ret val of map should be transducer in case of two args. Else it’s a sequential?.

borkdude 2018-10-20T21:09:16.000100Z

so (s/def ::seq-or-transducer seq?) => (s/def ::seq-or-transducer (s/or :seq :seq? :transducer ifn?))

borkdude 2018-10-20T21:09:49.000100Z

or maybe even (s/def ::transducer ifn?) so we can improve upon that one later

borkdude 2018-10-20T21:09:59.000100Z

why ifn? instead of fn? again?

borkdude 2018-10-20T21:10:22.000100Z

right:

boot.user=> (fn? #{:a})
false
boot.user=> (ifn? #{:a})
true

mfikes 2018-10-20T21:18:22.000100Z

For :ret you can say (s/or :fn fn? :seq seq?) but if you want to then make statements that depend on the number of args you'd use :fn as described here https://clojure.org/guides/spec#_spec_ing_functions

mfikes 2018-10-20T21:19:48.000100Z

(I think that, and the :ret spec, really only come into play when you are testing the implementations of the functions.)

mfikes 2018-10-20T21:20:12.000100Z

I take that back, :ret does matter for doc

borkdude 2018-10-20T21:20:18.000100Z

yes. I think it would be more correct if we went that way for map, etc.

slipset 2018-10-20T21:20:25.000100Z

Agreed

slipset 2018-10-20T21:20:52.000100Z

Also, in other news, stuff is published directly onto clojars now.

slipset 2018-10-20T21:22:17.000100Z

@mfikes: I’m seeing that the tests are becoming rather repetitive, if this were a pure clojure project, I’d write a (with-instrumentation ...) macro in speculative/core-test

slipset 2018-10-20T21:22:47.000200Z

But since we’re also supporting the land of selfhosted clojurescript as well, I need some help on that.

borkdude 2018-10-20T21:23:05.000100Z

one note about the tests: I’m not sure if we should call unstrument, because before the tests someone may have instrumented it already.. but we don’t expect people to run these tests, so probably OK

slipset 2018-10-20T21:23:20.000200Z

I guess the help I need is just understanding/being reminded of where to put the macro.

borkdude 2018-10-20T21:23:47.000100Z

we could use macrovich for this and define the macro in the .cljc file

mfikes 2018-10-20T21:24:08.000100Z

If that with-instrumentation macro were is some utility namespace, then it would be a little easier. It would go in a clj file, but there would also be a cljs file that does :require-macros on it

mfikes 2018-10-20T21:24:31.000200Z

Macrovich works too

slipset 2018-10-20T21:24:43.000100Z

so test_utils.clj(s) it is

borkdude 2018-10-20T21:24:45.000100Z

utility namespace is better probably

borkdude 2018-10-20T21:24:55.000100Z

.clj

borkdude 2018-10-20T21:25:06.000100Z

eh self hosted…

borkdude 2018-10-20T21:25:18.000100Z

macrovich works 😉

borkdude 2018-10-20T21:25:39.000100Z

so a test_utils.cljc file then?

borkdude 2018-10-20T21:26:04.000100Z

I think we might not even need that macro. Just instrument all and run the tests.

borkdude 2018-10-20T21:26:52.000100Z

It’s mostly that I wanted to prevent this weird CIDER issue that I called unstrument

borkdude 2018-10-20T21:27:02.000100Z

but we just have to fix it

mfikes 2018-10-20T21:28:21.000100Z

You can have a test_utils.cljs and test_utils.clj file and it will work in self hosted

borkdude 2018-10-20T21:28:40.000100Z

cool, didn’t know

mfikes 2018-10-20T21:28:40.000200Z

In other words, self-hosted also loads macros from clj files

borkdude 2018-10-20T21:30:15.000100Z

if you want to do it correctly you have to record which functions are instrumented before testing and then restore after, but I wouldn’t bother @slipset. Just remove the unstruments

mfikes 2018-10-20T21:31:04.000100Z

Hrm. @slipset I wonder if you have things deploying to clojars in CI. In my personal CI build it is failing when trying to do this.

mfikes 2018-10-20T21:32:03.000100Z

https://circleci.com/gh/mfikes/speculative/13

slipset 2018-10-20T21:40:39.000100Z

Hmm, bummer. I guess I need to set up a script that checks what repo we’re building from, and only deploy when building from mine.

borkdude 2018-10-20T21:47:07.000100Z

btw: (map 'lol [1 2 3]) is valid usage of map

borkdude 2018-10-20T21:47:50.000100Z

oh it’s already ifn? in the code, the README is behind

mfikes 2018-10-20T21:48:04.000100Z

Right 'lol can be used to look up things

mfikes 2018-10-20T21:49:38.000100Z

Heh, also, if nothing else, participating in this project is a great way to explore the corners of the language 🙂

borkdude 2018-10-20T21:49:50.000100Z

yeah, it’s fun already 😉

borkdude 2018-10-20T21:51:49.000100Z

@slipset did you read my comments on unstrument btw? 🙂

borkdude 2018-10-20T21:52:07.000100Z

I only added it because of the CIDER issue I had, not really necessary anymore imho

borkdude 2018-10-20T21:52:38.000100Z

and what if I instrumented map and then run the tests? suddenly it’s unstrumented 😉

borkdude 2018-10-20T21:53:04.000100Z

so what I would do is not bother with this macro at all, just call (st/instrument) and be done

mfikes 2018-10-20T21:53:41.000100Z

That's kind-of what I had in mind. (st/instrument) near the top of the test namespace

borkdude 2018-10-20T21:53:50.000100Z

exactly

borkdude 2018-10-20T21:55:33.000100Z

one more thought: could we order the specs alphabetically so they’re at least easy to find?

mfikes 2018-10-20T21:55:56.000200Z

I agree with that

borkdude 2018-10-20T21:55:58.000100Z

goodnight

mfikes 2018-10-20T21:56:09.000100Z

🌔

mfikes 2018-10-20T21:58:25.000100Z

Dang. Erik is on fire.

slipset 2018-10-20T22:02:59.000100Z

🙂

borkdude 2018-10-20T22:03:34.000100Z

typo: (is (= "") (str nil))

slipset 2018-10-20T22:04:00.000100Z

Ok, I’ll revert the test-util stuff tomorrow.

mfikes 2018-10-20T22:04:28.000100Z

One simplification that could be done is

`map
can be used instead of
`clojure.core/map

slipset 2018-10-20T22:04:30.000200Z

Fighting a bit with circle to only make it deploy from master and on my thing.

borkdude 2018-10-20T22:04:54.000100Z

you could leave the util ns if we’re not using the macro, it’ll probably come in handy later

borkdude 2018-10-20T22:05:37.000100Z

thanks Erik!

slipset 2018-10-20T22:13:19.000100Z

Hopefully latest master only deploys from my circle

slipset 2018-10-20T22:17:27.000100Z

Oh, well. There’s a day tomorrow as well. Thanks for all the help!

mfikes 2018-10-20T22:18:34.000100Z

👍

slipset 2018-10-20T22:28:42.000200Z

btw, do we need the :binary/:trinary thing any more?

slipset 2018-10-20T22:28:53.000100Z

(s/fdef clojure.core/reduce
  :args (s/or :binary  (s/cat :f fn? :coll ::reduceable-coll)
              :trinary (s/cat :f fn? :val any? :coll ::reduceable-coll)))

slipset 2018-10-20T22:29:49.000100Z

The error is a bit more verbose than it needs to:

slipset 2018-10-20T22:29:52.000100Z

speculative.core> (reduce 'lol 'lol)
Evaluation error - invalid arguments to clojure.core/reduce at (NO_SOURCE_FILE:44).
lol - failed: fn? at: [:binary :f]
lol - failed: fn? at: [:trinary :f]
speculative.core>