Fork me on GitHub

i just want to say: i’ve been writing javascript with flowtype for the past ~2 weeks. It’s a very nice type system and it’s very well implemented…. and I absolutely hate it. I miss clojure 😞


@bbloom No, no, you must be mistaken. Type systems are awesome 🙂


I’m finding new things to use clojure.spec for almost every day, I have to say…


i think i’ve hit more false positives about NPEs from flowtype in two weeks than i’ve had ACTUAL NPEs in a year of Go


So it’s telling you "This will likely NPE" but the code wouldn’t?


basically it says something like “potentially null or undefined” b/c it’s doing a map lookup or something, but i know with 100% confidence by construction that value is in the map


or similar


you wind up having to employ strategies all over the place:


1) making tons of extra structure types for every possible state of things


and 2) using invariant(whatever, ‘whatever may not be null’) which basically is just a glorified manual throw npe


Must admit, when we were using core.typed at work, that was one of the problems we had: nil was contagious and then we kept getting complaints about code not accepting nil (when we knew nil wouldn't flow to that point),


@seancorfield: Have you run into anything like that with spec yet?


@shaun-mahood no, but that’s because spec isn’t "contagious" in the same way that type systems tend to be: spec’ing one piece of code doesn’t ripple out into other pieces of code.


@seancorfield: That's awesome - I ran into similar issues with schema in a very limited manner and it really bothered me. I know you'll put spec through a lot more than I ever will so I've been using your notes and comments about as sort of my real-world expectations.


I'm surprised you hit that with Schema since it's really just runtime assertions.


Well, it's more likely that I did something stupid or am remembering different problems then - I really didn't put a whole ton of effort into figuring out exactly what was going on and it was quite a while ago. I probably just didn't know what I was doing as well as I though I did :)


Is it a deliberate difference between Clojure and ClojureScript that ClojureScript's clojure.spec.test/check only accepts a literal collection of syms instead of a code-generated value (e.g. (let [syms (filter in-my-namespaces? (st/checkable-syms))] (st/check syms)) will not work as it raises a Unable to resolve symbol: syms error.


Question about multi-spec, is it meant/possible to use with something else than a map? I cannot find examples and after a lot of trying it seems the multi-spec implementation doesn’t call the multi-method like one would expect


ah ok, i had a clear moment. I was a victim of multimethod + multi-spec reloading. It is possible with the right dispatch function

Alex Miller (Clojure team)15:09:13

retagging is discussed in the docstring - it’s for gen and can be a fn as well

Alex Miller (Clojure team)15:09:18

@jannis prob a question @dnolen would have to answer re check


@alexmiller Ok, I'll check with him


Might as well do it here. @dnolen: ping 😉


@tmtwd yep, we use it. Not in something we deployed in production (yet). But I have used it quite a lot now and it works well


Is anybody doing things with clojure.spec/unform at the moment? I asked something on the mailinglist about using it for data migrations, but no answer yet

Alex Miller (Clojure team)17:09:27

not many from my impression (given the number of bugs I am aware of but no one has mentioned yet :)

Alex Miller (Clojure team)17:09:48

data migration is one interesting use case for it though


thanks, for confirming the use case 🙂 I’ll see if I can make it work


Hello. With multi-spec, is there a way to generate values conforming to only a specific dispatch-value? For example, in the :event/event example in, the generator generates all events. What is the best way to generate events of only a certain type?


@dmarjenburgh you can get the spec (and hence the generator) for a specific dispatch value by just invoking the multi-method, (event-type {:event/type :event/search})


Ah, ofcourse. Thanks! 🙂