2 ms·
> this bug only arises _because_ "One function's return value is [being passed, directly, without any interpretation, as ] another function's parameter". Which
by lmm 3y ago
> this bug only arises _because_ "One function's return value is [being passed, directly, without any interpretation, as ] another function's parameter".
Which is the normal way of programming. If you can't safely compose functions without adding an extra layer of interpretation between them, programming becomes much harder.
> If the type signatures were changed so that interpretation was required - so that "the answer is None" could be distinguished from "I don't have an answer" - then the bug in the overall system goes away.
Which is something that using sum types rather than union types achieves by default. Wherever you want to localise the problem, union types add a big, easy class of ways to shoot yourself in the foot that just aren't there if you use sum types.