Helper function for type-safe casting as an expression.
None or result of one of the cases callable
if partial, returns None, else returns the result of the matching case