Patch with new API for get/setsockopt

Bryan O'Sullivan bos at
Sun Sep 9 00:03:45 EDT 2007

Hi, Matthew -

> I've concocted another API which allows values to be constructed from
> a specific disjoint union.  This should make it possible to use
> options like SendTimeOut which expect a struct timeval.

Thanks for posting the patch.  Unfortunately, I don't think it's an 
improvement over the current API, as it dcontinues to defer the 
detection of mismatches between names and the types of their values to 

I would prefer to see the API changed to associate the type of a value 
with the name of its constructor, like this:

data SocketOption = DontRoute Bool
                   | TimeToLive Int64
                   | ...

One could still pass values of this type into getSocketOption by filling 
out the arguments to a constructor with any value, including undefined. 
  There's already ample precedent for this, in the form of 
Data.Storable's sizeOf.

This presents a safer statically checkable interface, while remaining in 
the bounds of H98.


More information about the Libraries mailing list