RE: [GHC5] Creating Socket.PortNumber from Int?

2001-06-07 Thread Simon Marlow

> Wed, 6 Jun 2001 10:17:34 +0100, Simon Marlow 
> <[EMAIL PROTECTED]> pisze:
> 
> > Think of it this way: mkPortNumber has been renamed to 
> fromIntegral, and
> > now supports making port numbers from any integral type, 
> not just Int.
> 
> BTW, why PortNumber is not just Int?

It's kept in network byte order.  We could make it an Int and do the
translation to/from network byte order whenever we need to pass one
outside Haskell - I didn't investigate doing it this way, it may or may
not be simpler.

Cheers,
Simon

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: [GHC5] Creating Socket.PortNumber from Int?

2001-06-06 Thread Marcin 'Qrczak' Kowalczyk

Wed, 6 Jun 2001 10:17:34 +0100, Simon Marlow <[EMAIL PROTECTED]> pisze:

> Think of it this way: mkPortNumber has been renamed to fromIntegral, and
> now supports making port numbers from any integral type, not just Int.

BTW, why PortNumber is not just Int?

-- 
 __("<  Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
 \__/
  ^^  SYGNATURA ZASTÊPCZA
QRCZAK


___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: [GHC5] Creating Socket.PortNumber from Int?

2001-06-06 Thread Volker Stolz

In local.glasgow-haskell-users, you wrote:
>Think of it this way: mkPortNumber has been renamed to fromIntegral, and
>now supports making port numbers from any integral type, not just Int.
>I didin't see the need for a special purpose convesion from Int, when
>fromIntegral does the job in a much more general way.  

Okay, here a nice way to handle this:

#if __GLASGOW_HASKELL__ >= 501
 mkPortNumber = fromIntegral
#endif
-- 
Abstrakte Syntaxträume.
Volker Stolz * [EMAIL PROTECTED] * PGP + S/MIME

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: [GHC5] Creating Socket.PortNumber from Int?

2001-06-06 Thread Simon Marlow

> Until 5.00 I could use mkPortNumber to get what I want, i.e.
>   PortNumber (mkPortNumber port)
> Now in 5.01, this function now longer exists.
> (PortNumber 5) works, but (PortNumber (5::Int)) does not, so I
> have to use "fromIntegral" to get it to work again:
>   PortNumber (fromIntegral (5::Int))
> 
> I suppose I'm missing something essential here, as there must be a 
> better way of doing it when passing a variable of type Int.

Think of it this way: mkPortNumber has been renamed to fromIntegral, and
now supports making port numbers from any integral type, not just Int.
I didin't see the need for a special purpose convesion from Int, when
fromIntegral does the job in a much more general way.  

Besides, using fromIntegral as a general-purpose integral converter is
becoming standard practice now that we can optimise it well.

Cheers,
Simon


___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users