3 ms·
The return types of fallible functions map naturally onto sum types. By using product types instead there is a semantic mismatch. You get an error and a value b
by dthul 5y ago
The return types of fallible functions map naturally onto sum types. By using product types instead there is a semantic mismatch. You get an error and a value but only one of those is valid. So you need to follow certain code idioms to get back the sum type semantics whereas this is something the type system could handle for you.
Go's reasoning for that might be that they didn't want to have the complexity of sum types in the language, which is fair but is a tradeoff.