[Haskell-cafe] Suggestion for Network.Socket in regards to
thomas.dubuisson at gmail.com
Sun Jun 21 19:22:42 EDT 2009
I'm in favor of the entire Network library being reworked with an
improved API that is higher level and type-safe instead of a direct
translation/FFI of Berkeley sockets. I also would like the Network
package to export Data instances for headers while taking advantage of
pretty, prettyclass, and parsec. I started such work with
network-data but never really got off the ground with it.
On Sun, Jun 21, 2009 at 2:45 PM, John Van Enk<vanenkj at gmail.com> wrote:
> Hello List,
> Is there any one else in favor of hiding the PortNum constructor in
> Network.Socket in the next release? Here's why:
> Prelude> :m + Network.Socket Data.Word
> Prelude Network.Socket Data.Word> let p = 5000 :: Word16
> Prelude Network.Socket Data.Word> let p' = PortNum p
> Prelude Network.Socket Data.Word> let p'' = fromIntegral p :: PortNumber
> Loading package parsec-184.108.40.206 ... linking ... done.
> Loading package network-220.127.116.11 ... linking ... done.
> Prelude Network.Socket Data.Word> p
> Prelude Network.Socket Data.Word> p'
> Prelude Network.Socket Data.Word> p''
> Notice that using the PortNum constructor does not at all do what the
> user expects. This really should be a hidden constructor.
> Perhaps we can add the following:
> mkPortNum :: (Num a) => a -> PortNumber
> mkPortNum p = fromIntegral p
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe