k0001 / network-simple

Haskell library abstracting common network sockets usage patterns.
BSD 3-Clause "New" or "Revised" License
33 stars 9 forks source link

`network-simple` for `SockAddr` #5

Open jdnavarro opened 10 years ago

jdnavarro commented 10 years ago

I made network-simple work with resolved SockAddr here: https://github.com/jdnavarro/network-simple-sockaddr

Notice that it also works with IPv6 and Unix Sockets.

Do you think it could be included somehow in network-simple? Perhaps in a different module and make the current `Network.Simple.TCP depend on it and just focus on resolving addresses?

If you are in favor of this idea, I could do all the integration work.

k0001 commented 10 years ago

Ah, this is a good idea! Yes, this definitely has a home within network-simple. Thanks for doing this.

I'm not sure if Network.Simple.TCP should just focus on resolving addresses, maybe it should continue to export the functions it currently exports as a convenience (so that users don't need to worry about SockAddr if they don't care), but I agree that it should rely on the SockAddr support when possible.

I haven't looked at your changes in great detail yet, I'll do it later.

jdnavarro commented 10 years ago

That's great to hear.

Sorry, I didn't explain myself clearly. I tried to say that if Network.Simple.TCP could depend on Network.Simple.SockAddr, the only code specific to Network.Simple.TCP, while maintaining the same API, would be related to resolving addresses.

I'll be easier to understand once I have some integrated code. I'll let you know then.

jdnavarro commented 10 years ago

There is still a lot to polish, but now with those commits referenced above you can get a better idea of the changes I propose.

The only real breaking API change I'd like to propose is to use MonadIO m instead of IO everywhere, including the callback functions. But if you don't want it (the type signatures will become messy and we'd need to use RankNTypes), it's OK, it's not so crucial for me, it'd be just nice for me to have.

I'll wait for your input before completing the changes and submitting a proper pull request.

Please don't feel pressed to accept these changes, if you think these changes are too drastic, there is no problem, I can keep using the network-simple-sockaddr fork but I thought it'd be nice to have it all in a single package.