Hey Larry, <http://ocramius.github.com/>
On Wed, Jul 15, 2020 at 6:55 PM Larry Garfield <la...@garfieldtech.com> wrote: > I disagree entirely. The value of a Maybe over just null is > > 1) You can bind to it even if the result is empty; the "if is null" check > gets abstracted away from the main code. > That's correct: that's how the `Maybe` monad works too. > 2) You are forced to unwrap/extract the value if you're not just binding, > which makes it less likely you'll forget to check if it's null No need to unwrap: that's what `>>=` does for you. Assuming you use psalm or phpstan, a program that doesn't use `>>=`, or forgets to check for `null` on `?T` does not type-check anyway, and can be rejected before even writing any runtime tests: that's sound. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/