3 ms·
Thanks for the example. Yeah this is another case where people have trouble understanding subtyping relation and which type should be the subtype of which. And
by kccqzy 9y ago
Thanks for the example. Yeah this is another case where people have trouble understanding subtyping relation and which type should be the subtype of which.
And I agree with you that the opposite should be true conceptually, because if you ask yourself, "if a partial function is being demanded, can you use a function instead?" you might answer yes.
Alternatively, think of a partial function conceptually as a function that returns an option type, i.e. in Haskell syntax
type Function a b = a -> b
type PartialFunction a b = a -> Maybe b
and with the obvious addition that "b" is a subtype of "Maybe b", then we again conclude that function should be a subtype of partial function.
- acjohnson55 9y agoFor sure. And since all functions can throw exceptions, a partial function is just a function that just happens to throw a lot of them :)