10 ms·
assuming you're sampling the same distribution. every call to a function can have different arguments. this seems to make the assumption that the types and shap
by a-dub 5y ago
assuming you're sampling the same distribution. every call to a function can have different arguments. this seems to make the assumption that the types and shape don't change so you can amortize the cost of type checking over multiple function calls... but they can, and do, sometimes with low probability and those are the hard bugs to solve.
especially when you think types are being checked.
- eru 5y agoI suspect you are reading different things into my comment than I wanted to convey. Your argument is perfectly valid, if you try to steelman my argument into something like a mathematical argument. But it wasn't meant that way. I meant exactly what I said: empirically, in practice, randomised checking is unreasonably effective. You illustrated the 'unreasonable' part.
- a-dub 5y agoi'd never seen this quickcheck thing before... it's basically fuzzing built into unit tests, neat... it is, however, quite different from a type checker though. where a fuzz tester generates random inputs to try and break a function... a type checker enforces assertions on data that is actually flowing through the system. i think my big beef with this library is that it does so probabilistically, while marketing itself as something that does complete checks and has been highly optimized. it's not a fast assertion checker, it is one that employs random sampling... that's fine, but it should be extremely upfront about that as this misunderstanding has the potential to cause a lot of pain on top of already painful situations.
- eru 5y agoYes, calling this a typechecker is perhaps a bit euphemistic. Btw, if you want to try something like QuickCheck, Python's Hypothesis is perhaps the most accessible implementation of the idea.