Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods

2016-03-28 Thread Facundo Martinez Correa
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 need

Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods

2016-03-28 Thread Facundo Martinez Correa
Hi Jakub, Regarding the Null Object, I believe it to be a second hand solution. Having a Null Object that returns 0, null, "" or false for every method call, or a nil that acts as in Objective C that doesn't tell you when is being poked the wrong way is the first step into madness. It will never t

Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods

2016-03-28 Thread Stanislav Malyshev
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 cove

Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods

2016-03-27 Thread Kubo2
Hi Facundo Martínez, I think the best solution to yourself described problem above would be the Null Object Design Pattern (https://en.wikipedia.org/wiki/Null_Object_pattern). In my opinion, NULL belongs to PHP and this language never aimed to become Java or similar. Jakub On 22 March 2016 at 01

Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods

2016-03-22 Thread Rowan Collins
Andreas Heigl wrote on 22/03/2016 16:25: In the PHP 7 and typing presentations I've been giving[1], I've advocated either: > >1) Throw an exception if the rest of the code is going to break anyway. >2) Define an empty object with matching interface if you want an equivalent of 0/empty string.

Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods

2016-03-22 Thread Larry Garfield
On 3/22/16 11:25 AM, Andreas Heigl wrote: Am 22.03.2016 um 15:56 schrieb Larry Garfield : On 3/21/16 10:23 PM, Côme Chilliet wrote: Le lundi 21 mars 2016, 17:04:30 Facundo Martinez Correa a écrit : But then I realized the problem. There are many times where we need uncertainty. Code is a ref

Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods

2016-03-22 Thread Andreas Heigl
> Am 22.03.2016 um 15:56 schrieb Larry Garfield : > >> On 3/21/16 10:23 PM, Côme Chilliet wrote: >> Le lundi 21 mars 2016, 17:04:30 Facundo Martinez Correa a écrit : >>> But then I realized the problem. There >>> are many times where we need uncertainty. Code is a reflection of reality, >>> and

Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods

2016-03-22 Thread Larry Garfield
On 3/21/16 10:23 PM, Côme Chilliet wrote: Le lundi 21 mars 2016, 17:04:30 Facundo Martinez Correa a écrit : But then I realized the problem. There are many times where we need uncertainty. Code is a reflection of reality, and as such, it must reflect uncertainty. NULL is a good enough way to exp

Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods

2016-03-21 Thread Côme Chilliet
Le lundi 21 mars 2016, 17:04:30 Facundo Martinez Correa a écrit : > But then I realized the problem. There > are many times where we need uncertainty. Code is a reflection of reality, > and as such, it must reflect uncertainty. NULL is a good enough way to > express nonexistence, albeit a bad one.

Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods

2016-03-21 Thread Facundo Martinez Correa
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 somet

Re: [PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods

2016-03-21 Thread Levi Morrison
> 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 > probl

[PHP-DEV] RFC Proposal: Maybe monad and execution time polymorphic methods

2016-03-21 Thread Facundo Martinez Correa
Hello, I am reaching you in order to obtain feedback on this RFC proposal. I have been playing with PHP 7 for a project in the company that I am currently working for. One of the many drawbacks that I saw in PHP was the there were no types. With type hinting I had confindence again in PHP. With r