Re: RFC Proposal: Maybe monad and execution time polymorphic methods
| From: | Levi Morrison | Date: | Mon, 21 Mar 2016 20:27:55 +0000 |
| Subject: | Re: RFC Proposal: Maybe monad and execution time polymorphic methods | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91826@lists.php.net to get a copy of this message | ||
> 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?