Assertion memoization for `proveTrue` inside `Option::do`
klimick opened this issue · 0 comments
klimick commented
It would be nice if proveTrue
can memoize assertions:
/**
* @return Option<positive-int>
*/
function provePositiveInt(?int $number): Option
{
return Option::do(function() use ($number) {
yield proveTrue(null !== $number);
yield proveTrue($number > 0);
// for now it will be type error, because assertions from above will be ignored
return $number;
});
}