getNameInfo: how are Bool arguments and Maybe results related?
I do not understand the warranties, getNameInfo makes about its results.
If an argument is False, does this mean that the corresponding result is always Nothing?
Likewise, if an argument is True, does this mean that the corresponding result is always Just?
Related to #416.
I'm not the original author. But the code says that your two assumptions are yes.
On Mon, 17 Jan 2022, Kazu Yamamoto wrote:
I'm not the original author. But the code says that your two assumptions are yes.
In this case I propose we have a variant of getNameInfo that expresses these assumptions in types. E.g.
getNameInfo :: (Option f, Option g) => [NameInfoFlag] -> SockAddr -> IO (f HostName, g ServiceName)
class Option f where instance Option Identity where instance Option Ignore where
data Ignore a = Ignore -- isomorphic to Proxy
I agree with you. We should define variants, for instance, getAddrInformation and getNameInformation which are clean for error codes.