Re: Re: RFC Proposal: Maybe monad and execution timepolymorphic methods
| From: | Stephen Coakley | Date: | Tue, 22 Mar 2016 18:34:59 +0000 |
| Subject: | Re: Re: RFC Proposal: Maybe monad and execution timepolymorphic methods | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91859@lists.php.net to get a copy of this message | ||
On 03/21/2016 11:09 PM, Levi Morrison wrote:
This requires you to query state withCertainly. Ideally some sort ofisSome(). This is hardly any different from a null case, just more code. We can already accurately distinguish betweennulland another value. If we want an option for safer PHP code I think we need a safer construct that requires exhaustive matching (such as Rust'smatch). I'm not sure how to pull that off.
match, which is listed as future scope in the enum RFC. The above definition of a Maybe is just some sort of basis for a type. You probably wouldn't use isSome() much and would use pattern matching on the enum instead.
As much as I do love Rust's type system though, PHP isn't Rust. :)
--
Stephen