Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91827 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37918 invoked from network); 21 Mar 2016 20:42:33 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 21 Mar 2016 20:42:33 -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.173 as permitted sender) X-PHP-List-Original-Sender: fnmartinez88@gmail.com X-Host-Fingerprint: 209.85.161.173 mail-yw0-f173.google.com Received: from [209.85.161.173] ([209.85.161.173:35919] helo=mail-yw0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 66/81-29631-7BC50F65 for ; Mon, 21 Mar 2016 15:42:33 -0500 Received: by mail-yw0-f173.google.com with SMTP id g3so229773392ywa.3 for ; Mon, 21 Mar 2016 13:42:31 -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=byOIOTy5Mlh2uXKYvr1PDXNUvQ11j55UaG6HWYK4Vz0=; b=Mo1L5rs41BoJ8hylPmwRm9wP90PkaDhtqF/uudGpElFj9vRo/W2XQY0VKBM7Na+wLn UAXauAnK8t9CuPg00KrZK15J4S2nILfAbcfE9cz1dtuE3GL6hw6oX0Ijrts/kLykp1Et sINsm2P7zAo3ik5g+F6mvzVaX5Ddi0z8LUMhMvkx2wPNUH93bqQ0Nbsm7IwgYgA7hDKM KXKfcc5xSAktyxDFwa2PSXx+Lpo6SqoSozvx8c+pvPAQSkvr+Xb7MAxhPA3SCugZtC+J bzFITLfxGFZ79hggAnJ4dxwZtIoHWMp+WEMwYmdti4vgWZRZLp1ns2Stgyihcw63Pq92 YIgA== 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=byOIOTy5Mlh2uXKYvr1PDXNUvQ11j55UaG6HWYK4Vz0=; b=c8hfy/9yx/VVd1hWGTOuGKiGff/74UiGtsm3Nc4XlAMSkctsEsW0ug2/Z85MY4xvFw jfDVtEm6DBbXju3+MMTvSKeshuhhUwS3u5A7Ft1NnJou3n+bkrq1VAp3BBq1vQK/lssj KVea2IK6HJ+IFe5Co+ct30G8IIRE77KSrDijBtIs0KUXr+6KMGA3b6bPZT2XPRtSbV+C BxF2ohE0KrZQ4tm1DL71CIg7yh0E19YZLDKHlfG/dEjN/+sdsVEUBJJyhqVPmt5Um4zs 4Yu/z7odkey9Q4jRUFMSeQSBHM3WDYft2q2RUO9N0adLbhBzFbhVV1nk/rW63nGNxAi/ wGOw== X-Gm-Message-State: AD7BkJIBKG0VOuRQpfokD/ovQepY1ww8RzaRED3PPmmg2BADNK7wpdeJaEaHE6l9O6JtOF5g6s12PsYmThnckQ== X-Received: by 10.129.157.80 with SMTP id u77mr14341417ywg.138.1458592948842; Mon, 21 Mar 2016 13:42:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.37.79.3 with HTTP; Mon, 21 Mar 2016 13:42:09 -0700 (PDT) In-Reply-To: References: Date: Mon, 21 Mar 2016 17:42:09 -0300 Message-ID: To: Levi Morrison Cc: internals Content-Type: multipart/alternative; boundary=94eb2c0b6a4496916e052e9522d9 Subject: Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods From: fnmartinez88@gmail.com (Facundo Martinez Correa) --94eb2c0b6a4496916e052e9522d9 Content-Type: text/plain; charset=UTF-8 Hi Levi, Thanks for replying. I don't think that automagically taking the T out of the Maybe would be a good idea, mainly because sometimes you don't need the T, you just want to know the result of it. What I would want in that PHP automagically executes the method myMethod(Maybe $object) if something was returned or the method myMethod(EmptyMaybe $object) if the returned was an EmptyMaybe. The use of Maybe is, in fact, a motivation for real operators oveloading. The kind that will be decided at execution time, with the type at hand. This motivation came when what I explained happened. And that's the reason why I'm also sugesting a Maybe. Regards, On Mon, Mar 21, 2016 at 5:27 PM, Levi Morrison wrote: > > My experience in Haskell reminded me of this. To have a structure than > > represents uncertainty, is the best way to take away the responsibility > > from NULL. To express it in no other way. But my experience in Java has > > taught me that Optional of something is not a good way to tackle the > > problem. I still have to check if my Optional isEmpty. I still have to > > check for null. That is because Java has that type erasure after > > compilation time that doesn't allow me to play nice with polymorphism. > But > > 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 > > for null ever again in my life. So my code can be free of nulls. So I can > > express uncertainty and nonexistance, while I return a User from my > > repository. > > I don't fully understand what you are asking for here. You want a > Maybe to automatically become a T if it's not null or something? > --94eb2c0b6a4496916e052e9522d9--