[GHC5] Creating Socket.PortNumber from Int?
Wed, 6 Jun 2001 10:17:34 +0100
> 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=20
> 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. =20
Besides, using fromIntegral as a general-purpose integral converter is
becoming standard practice now that we can optimise it well.