Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#2446 closed bug (wontfix)

Network.Socket.PortNum should not be exported

Reported by: cjs Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.8.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:


Network.Socket exports a PortNum? value constructor. Though there's no haddock documentation to say so, this constructs a value of type PortNumber? by taking a Word16 in *machine* order, i.e., byte-swapped on little-endian machines.

However, PortNumber? is an instance of Num and has a fromIntegral (that converts from a non-byte-swapped int), so when specifying a PortNumber? for a something such as a SockAddrInet?, one should just use an Integral. That is, instead of

SockAddrInet? (PortNum? $ fromIntegral (byteswap 12345)) hostaddr

one should just use

SockAddrInet? 12345 hostaddr

I think that the PortNum? constructor should not be exported; it's difficult to use due to the lack of documentation (and its own nature, really), is not necessary, and worst of all, its existence has mislead at least two programmers I know of to use it when they didn't want or need to.

Change History (3)

comment:1 Changed 6 years ago by igloo

  • Difficulty set to Unknown
  • Resolution set to wontfix
  • Status changed from new to closed

Please file a library submission if you want to propose this:

comment:2 Changed 6 years ago by simonmar

  • Architecture changed from Multiple to Unknown/Multiple

comment:3 Changed 6 years ago by simonmar

  • Operating System changed from Multiple to Unknown/Multiple
Note: See TracTickets for help on using tickets.