speculative

https://github.com/borkdude/speculative
borkdude 2018-12-21T16:09:39.000900Z

@mfikes Should the spec of the arg to into be ::ss/seqable or ::ss/reducible-coll? I’m always wondering about this myself when writing new specs. https://github.com/slipset/speculative/pull/172/files Maybe a good question is: are there reducible collections that are not seqables

mfikes 2018-12-21T16:13:19.001600Z

My guess is that the 1st arg needs to simply be a collection (upon which conj works)

alexmiller 2018-12-21T16:13:36.001900Z

yes - eduction is an example

borkdude 2018-12-21T16:14:03.002600Z

@alexmiller just tried that:

(def e (eduction (map inc) [1 2 3]))
(seqable? e) ;;=> true

borkdude 2018-12-21T16:14:11.002900Z

(this is CLJS)

alexmiller 2018-12-21T16:14:15.003100Z

well doesn’t implement Seqable

alexmiller 2018-12-21T16:14:34.003600Z

it is seqable via iteration in clojure

borkdude 2018-12-21T16:14:37.003800Z

(seq e) ;;=> (2 3 4)

borkdude 2018-12-21T16:15:43.004500Z

basically the question is: is the seqable? predicate sufficient for the args to into

alexmiller 2018-12-21T16:16:12.005100Z

but generally, yes they are independent protocols

borkdude 2018-12-21T16:16:51.005700Z

so reducible-coll would be better right? in theory it’s possible to implement something that is reducible, but not seqable

alexmiller 2018-12-21T16:17:16.006Z

yes

alexmiller 2018-12-21T16:17:29.006300Z

into is a reduction

borkdude 2018-12-21T16:17:38.006500Z

yep

borkdude 2018-12-21T16:20:15.007300Z

so, from should be a ::ss/reducible-coll, but the first arg only has to be something for which conj works. is there a protocol for that as well?

borkdude 2018-12-21T16:26:26.008100Z

welcome @andreas862

2018-12-21T16:26:58.008500Z

thank you - author of the massive into PR

borkdude 2018-12-21T16:27:42.008900Z

I figured 🙂 can you read the discussion above?

2018-12-21T16:28:21.009600Z

yep, but awaiting response regarding to

borkdude 2018-12-21T16:29:31.010Z

someone on Stackoverflow suggests that the predicate for this should be something like this: https://github.com/clojure/clojure/blob/clojure-1.8.0/src/jvm/clojure/lang/RT.java#L649-L653

borkdude 2018-12-21T16:30:01.010900Z

so maybe we need something like ::ss/conjable that looks at the type

borkdude 2018-12-21T16:30:16.011300Z

or there may already be one, maybe coll?

alexmiller 2018-12-21T16:30:31.011700Z

this kind of stuff is exactly why we are hesitant to spec parts of clojure

alexmiller 2018-12-21T16:30:51.012200Z

b/c anything you write will eventually be wrong - this stuff is intentionally polymorphic and not nailed down

borkdude 2018-12-21T16:31:04.012500Z

right, conj may change. but so may our specs 🙂

alexmiller 2018-12-21T16:31:22.012900Z

yeah, but code will present as broken when not actually broken

alexmiller 2018-12-21T16:32:24.014Z

part of the secret of stability/compatibility is to avoid saying things when you don’t have to - all these -ables you have are the places where you are trying to make something concrete that is intentionally not concrete

borkdude 2018-12-21T16:33:13.014700Z

I understand the hesitation on making something official in the name of Cognitect/Clojure and sealing it for the future.

borkdude 2018-12-21T16:34:19.015500Z

in speculative we have room to experiment and be wrong I think. if we come across reasons to change our -ables, we just fix it.

alexmiller 2018-12-21T16:34:47.016100Z

just highlighting that this is the kind of place where it’s appropriate to not fool yourselves or your users into believing this is The Answer

borkdude 2018-12-21T16:34:56.016300Z

yeah

alexmiller 2018-12-21T16:35:33.016600Z

because everyone will be sad when it changes later

borkdude 2018-12-21T16:36:07.016900Z

there must be something better than any? for the to argument?

borkdude 2018-12-21T16:37:04.017500Z

btw, I think speculative is already more precise in some specs than other libs that try to do something similar

borkdude 2018-12-21T16:37:21.017800Z

it will never be perfect and it may be good to write that down in the README

2018-12-21T16:42:56.018800Z

So the argument is that conj maybe could stop relying on clojure.lang.IPersistentCollection and that would break this spec?

2018-12-21T16:44:08.019600Z

and that core doesn't feel that IPersistentCollection is a part of any "structural" promise?

alexmiller 2018-12-21T16:45:19.020Z

nil doesn’t implement IPersistentCollection, but it works with conj

mfikes 2018-12-21T16:45:50.021Z

In ClojureScript, coll? is associated with conj

2018-12-21T16:47:12.021900Z

ah, gotcha - Just staring at the function signature. Kotlin is nice with explicit nil types

mfikes 2018-12-21T16:47:41.022700Z

So maybe it is (s/nilable coll?)

alexmiller 2018-12-21T16:50:55.023900Z

even if there is some baseline now, this is exactly the kind of thing where we want to be able to extend the language in the future

alexmiller 2018-12-21T16:51:53.024700Z

so boxing it in is just putting fences in the way of that - this is a philosophical thing embedded deeply in Clojure

borkdude 2018-12-21T16:55:06.026200Z

One goal of ours specs is to capture wrong inputs. I think using anything more than any? is boxing things that might change in the future. I don’t think it’s unreasonable to expect these specs to co-evolve with future Clojure versions, but for now they are compatible with the most recent Clojure and CLJS releases

2018-12-21T16:56:23.027500Z

@borkdude why does (map inc nil) validate? nil doesn't seem like a sequential

borkdude 2018-12-21T16:56:38.027900Z

maybe reduce is going to support another kind of protocol in the future. we can add an extra alternative to ::ss/reducible-coll. I don’t see the problem

borkdude 2018-12-21T16:57:05.028700Z

@andreas862 sequential is something else than seqable. seqable also accepts nil

alexmiller 2018-12-21T16:57:11.028900Z

it’s not a problem, I just think it’s important to manage expectations

borkdude 2018-12-21T16:58:23.029800Z

that is something we might need to work on. maybe removing the reference to clojure.core and the CA is an option. also putting words like ‘unofficial’ in the README.

borkdude 2018-12-21T16:58:38.030Z

this is up to @slipset as the CA and “hoping it would end up in clojure.core” are his ideas

alexmiller 2018-12-21T17:03:23.032300Z

I think it’s worth some sentences in the readme about some of the stuff I said above

alexmiller 2018-12-21T17:07:40.035400Z

there is pressure sometimes in trying to “nail everything down” and I think that comes at least partially from the static typing world (and partially from our programmer brains)

alexmiller 2018-12-21T17:08:25.036300Z

I think the message from Clojure and from Rich is - push back on that. don’t be afraid to leave ambiguity and room for future extension into your designs.

alexmiller 2018-12-21T17:12:07.038800Z

when you say “wrong inputs”, it’s important to keep in mind that that’s a perspective *at a given point in time*

borkdude 2018-12-21T17:12:39.039100Z

right, as per clojure 1.10.0 and clojurescript 1.9.439

2018-12-21T17:18:28.040400Z

I think that specced core has a value even when it is version bound. The question is if the value is more or less than the cost of future problems. Some tooling aren't possible without specs. I think it would be interesting to explore that domain even if speculative only works with clojure x.x.x

2018-12-21T17:19:41.042Z

On the other hand. If the fear is that the specs will restrict to a subset of legal code, then that is something problematic

alexmiller 2018-12-21T17:19:45.042100Z

I think there is definitely value to having specs, so I’m not trying to naysay that

alexmiller 2018-12-21T17:19:51.042400Z

I just think it’s useful to set expectations

2018-12-21T17:26:46.044700Z

My expectations for everything in life is low 😉 Anyhow I pushed another commit with (s/nilable coll?)

alexmiller 2018-12-21T17:28:12.045100Z

well that’s a good way to be more surprised than disappointed :)

borkdude 2018-12-21T18:11:27.045800Z

@andreas862 looks good to me. one enhancement: can you make a ::coll spec in specs.cljc, we have the convention to use keywords instead of predicates. see: https://github.com/slipset/speculative/blob/master/doc/style.md

borkdude 2018-12-21T18:23:41.046900Z

would that be a good text for managing expectations?

borkdude 2018-12-21T18:24:11.047400Z

Also see the text Speculative broke my project below it that I wrote a while ago

slipset 2018-12-21T18:28:04.049100Z

I’d be happy to remove the stuff about included in core as well. And the ca thingy.

borkdude 2018-12-21T18:29:14.050Z

I’m not actively hostile to those ideas 🙂 but they do set expectations. That’s why I suggested that.

borkdude 2018-12-21T18:30:58.050900Z

clojure.core never asked for something like this. I never expect them to take any of this, but if they want, I’m not complaining.

slipset 2018-12-21T18:32:09.051800Z

which basically was my thoughts as well. And I figured that requiring a Clojure CA wouldn’t be to much to ask.

borkdude 2018-12-21T18:32:28.052100Z

the text in the PR may be enough for now

borkdude 2018-12-21T18:32:41.052400Z

if y’all agree with the content and the tone

slipset 2018-12-21T18:33:51.052600Z

Go!

🚀 1
alexmiller 2018-12-21T18:53:35.053600Z

yep, thx

👍 1