[Haskell-cafe] Re: Haskell not ready for Foo [was: Re: Hypothetical Haskell job in New York]

John Goerzen jgoerzen at complete.org
Thu Jan 8 17:05:05 EST 2009

On Thu, Jan 08, 2009 at 10:37:55PM +0100, Bardur Arantsson wrote:
> Don't get me wrong -- the socket support is pretty decent, but there are  
> also some weird idiosyncrasies, for example requiring that the PortNum  
> is specified in network byte order and lacking a function to convert  
> host->network byte order (hton).

Look at Haddock for PortNumber:

newtype PortNumber
    PortNum Word16  


  Enum PortNumber
  Eq PortNumber
  Integral PortNumber
  Num PortNumber
  Ord PortNumber
  Real PortNumber
  Show PortNumber
  Typeable PortNumber
  Storable PortNumber

Try it in ghci:

Prelude Network.Socket> 15 :: PortNumber
Prelude Network.Socket> PortNum 15
Prelude Network.Socket> (fromIntegral (15::Int))::PortNumber

So, in essence, there are *many* functions that let you do this.  You
should not be needing to construct PortNum by hand.

More information about the Haskell-Cafe mailing list