On Wed, Jul 15, 2020, at 11:59 AM, Marco Pivetta wrote: > 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.
That... is what I'm describing? A Maybe Monad? > > 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 My Haskell experience is zilch, but since PHP lacks a dedicated bind operator that also magically unwraps, that doesn't seem relevant. (Mind you, I'd be all for a dedicated bind operator that also auto-unwraps! But that's not on the radar at the moment.) --Larry Garfield -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php