Re: [RFC][Discussion] Objects can be declared falsifiable
| From: | Marco Pivetta | Date: | Wed, 15 Jul 2020 16:59:38 +0000 |
| Subject: | Re: [RFC][Discussion] Objects can be declared falsifiable | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111027@lists.php.net to get a copy of this message | ||
Hey Larry,
<http://ocramius.github.com/>
On Wed, Jul 15, 2020 at 6:55 PM Larry Garfield <larry@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/