Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91984 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45076 invoked from network); 29 Mar 2016 02:23:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Mar 2016 02:23:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=fnmartinez88@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=fnmartinez88@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.180 as permitted sender) X-PHP-List-Original-Sender: fnmartinez88@gmail.com X-Host-Fingerprint: 209.85.161.180 mail-yw0-f180.google.com Received: from [209.85.161.180] ([209.85.161.180:33698] helo=mail-yw0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DF/11-37399-927E9F65 for ; Mon, 28 Mar 2016 21:23:37 -0500 Received: by mail-yw0-f180.google.com with SMTP id h65so2770443ywe.0 for ; Mon, 28 Mar 2016 19:23:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=3IF8hYH9tDz/jxO43XYg8eam97WAjL6dTq86PL4JcTU=; b=rZ0JTpNrcXpbUTx6arY7CAfrM8c752ZE+BduaxFsVQoZgUzAT/KcWHnZ1REbhSPQxE 0d8FpR1V9nt3KpsyBRkXtGz1PS6AQcM8nMEYL5Xizn5pKKuCbZu8rs+k7e23ai4iRpdz u+TNprXKr5HujZHvC6MBxn/GvCKTwj1xKrLPLa3AZCAoSQmmBYY8LM6IInQwijwEQVSl ckq8qBrPWXqcqjXJRV7vdnRuZA//gyX6p1njmgoqdcp7b7kB6XbBtV0m5jxJCjWe7KGf ibYtCm3u4kO4CHGZqyPsn4CJaK2qzoOizbpDZnK4tsJGaUk/C41ot4WQLYOTo4Fz4FO2 HEsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=3IF8hYH9tDz/jxO43XYg8eam97WAjL6dTq86PL4JcTU=; b=awaK/fBbIVIRY+qEhYrxkwOgGdFRIpkHE8PiCsNKXWTDKuRAszsqHwlbat7cvUhqPO 66XhN05UGap7owsOC5TADRB7kBqiKY+kqY6y00BysWxD8IYBZT7DtS9FO2GlJDl0KCUS qFsQNyEzot3oMQUry3oF3SlvlaBR796hKlfyBgzREHO5/Zc31ospPtHe3rdYOt593eP0 2F9Oqb/294JVjUw34vIKiw0V16874Nogq5MI4FWqeFeie8aCEsYoNtwfeOifUsea8FCh dLzopPWJYiVGf/5dY7zX6043fWWnP6/vqsW5D89YZIuiGMViQZEubSg0QWTXGc1nu7iF yVQA== X-Gm-Message-State: AD7BkJKNgxaYt1fAkihfdqEuhTXW5NIO9hx+IhVP7hAhJ/8C4r/DgTnnOsdXa187x1L2sanqifel58vCvDYacg== X-Received: by 10.129.157.80 with SMTP id u77mr14324287ywg.138.1459218215018; Mon, 28 Mar 2016 19:23:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.79.3 with HTTP; Mon, 28 Mar 2016 19:23:15 -0700 (PDT) In-Reply-To: <56F9C89F.2000200@gmail.com> References: <56F9C89F.2000200@gmail.com> Date: Mon, 28 Mar 2016 23:23:15 -0300 Message-ID: To: Stanislav Malyshev Cc: internals Content-Type: multipart/alternative; boundary=94eb2c0b6a445b25fb052f26b72f Subject: Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods From: fnmartinez88@gmail.com (Facundo Martinez Correa) --94eb2c0b6a445b25fb052f26b72f Content-Type: text/plain; charset=UTF-8 Hi Stanislav, Yes, as you are saying, it is no easy task. I believe it would make a nice feature, though. I don't know it is really necessary to use union types, I believe that with a class hierarchy would suffice. But maybe there is something that I'm not looking at right, and the unions are needed. It would certainly need some kind of generics or templates, though I don't know how powerfull they ought to be. In fact, having generics was something that also came into my mind when dealing with this project, since I would use the Builder Patter for my Entities, had a couple of Entities that extended one from the other and I couldn't play it nice with the Type Hinting. Maybe is as Jakub told me, and PHP is not aiming to be Java nor anything similar in anyway. But I believe that if it is moving into type checking, it means that the community is seeing it as something needed. So it would be interesting maybe to have something similar to TypeScript, something like Gradual Typing. But to have that, everything from both worlds must work. Thanks for the reply. Kind regards, Facundo On Mon, Mar 28, 2016 at 9:13 PM, Stanislav Malyshev wrote: > Hi! > > > maybe PHP can. Maybe PHP will give me the polymorphism at execution time > to > > discern an empty Maybe from the one that is not. So I don't have to check > > In order for that to work, we should have a facility to: > a) define union types > b) ensure somehow that code dealing with the union type covers all variants > c) if we really want to be able to handle such types smoothly, we need > something like monads to be able to convert f(SomeClass $x) to f(Maybe $x). > > This does not sound trivial at all. (c) is not strictly required for the > rest to work, but will also require some kind of generics, since Maybe > should have information about contained type (maybe what? maybe file, > maybe database connection, maybe pastrami sandwich?). If you give up on > (c), you still need some facility like case-of for (b). > > And, of course, you will still need to write code to cover the "nothing" > case of the Maybe. So it might be easier getting a code analyzer that > would just identify missing null checks? > > -- > Stas Malyshev > smalyshev@gmail.com > --94eb2c0b6a445b25fb052f26b72f--