Hi Levi,

Thanks for replying. I don't think that automagically taking the T out of
the Maybe<T> 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<T> $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 <le...@php.net> 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<T> to automatically become a T if it's not null or something?
>

Reply via email to