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
smalys...@gmail.com

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to