←back to thread

49 points todsacerdoti | 1 comments | | HN request time: 0.2s | source
1. twhitmore ◴[] No.42278692[source]
The examples at the start seem confused & poor. A type that "can return either one result, many results or an error" is trying to fit two different cardinalities into a single API.

APIs should either be typed to be unary (possibly with optionality/ error), or plural (allowing 0..many).

I've dealt with similar woolly design before. Introducing clear distinction between cardinalities gave a major improvement in logical clarity.