Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91859 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37311 invoked from network); 22 Mar 2016 18:35:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Mar 2016 18:35:03 -0000 X-Host-Fingerprint: 68.118.157.39 68-118-157-39.dhcp.mdsn.wi.charter.com Received: from [68.118.157.39] ([68.118.157.39:11351] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 53/61-30596-65091F65 for ; Tue, 22 Mar 2016 13:35:03 -0500 Message-ID: <53.61.30596.65091F65@pb1.pair.com> To: internals@lists.php.net References: Date: Tue, 22 Mar 2016 13:34:59 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 68.118.157.39 Subject: Re: [PHP-DEV] Re: RFC Proposal: Maybe monad and execution timepolymorphic methods From: me@stephencoakley.com (Stephen Coakley) On 03/21/2016 11:09 PM, Levi Morrison wrote: > This requires you to query state with `isSome()`. This is hardly any > different from a null case, just more code. We can already accurately > distinguish between `null` and 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's `match`). > I'm not sure how to pull that off. > Certainly. Ideally some sort of `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