
I might be mistaken, but is there a bug in the Show instance of PortNum? λ PortNum 1 256 λ PortNum 2 512 λ PortNum 3 768 λ let (PortNum x) = PortNum 10 λ x 10 Tested with network-2.4.1.2

Replying to all. Sorry for the duplicate, Florian. The fact that the constructor `PortNum` is exported has been argued to be a bug in past discussions. PortNumber is stored big endian, which leads to behaviors that people don't expect. I suggest you lean on the fact that PortNumber is an instance of the Num class: ghci ...
478 :: PortNumber 478
Cheers, Thomas On Wed, Apr 10, 2013 at 12:26 AM, Florian Hofmann < fhofmann@techfak.uni-bielefeld.de> wrote:
I might be mistaken, but is there a bug in the Show instance of PortNum?
λ PortNum 1 256 λ PortNum 2 512 λ PortNum 3 768
λ let (PortNum x) = PortNum 10 λ x 10
Tested with network-2.4.1.2
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Wed, Apr 10, 2013 at 3:26 AM, Florian Hofmann < fhofmann@techfak.uni-bielefeld.de> wrote:
I might be mistaken, but is there a bug in the Show instance of PortNum?
Not a bug, an annoying misdesign (IMO). A PortNum is actually in network byte order. If you extract it, you get the original port; if you simply show it, you see it byteswapped on little-endian platforms. -- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

Ah ok ... thanks for the clarification
2013/4/10 Brandon Allbery
On Wed, Apr 10, 2013 at 3:26 AM, Florian Hofmann < fhofmann@techfak.uni-bielefeld.de> wrote:
I might be mistaken, but is there a bug in the Show instance of PortNum?
Not a bug, an annoying misdesign (IMO). A PortNum is actually in network byte order. If you extract it, you get the original port; if you simply show it, you see it byteswapped on little-endian platforms.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net

This is a case where a line of documentation could save a lot of people a lot of trouble. Anyone have a clone of network handy that they could make a pull request from? Jeff On Wed, Apr 10, 2013 at 4:31 PM, Florian Hofmann < fhofmann@techfak.uni-bielefeld.de> wrote:
Ah ok ... thanks for the clarification
2013/4/10 Brandon Allbery
On Wed, Apr 10, 2013 at 3:26 AM, Florian Hofmann < fhofmann@techfak.uni-bielefeld.de> wrote:
I might be mistaken, but is there a bug in the Show instance of PortNum?
Not a bug, an annoying misdesign (IMO). A PortNum is actually in network byte order. If you extract it, you get the original port; if you simply show it, you see it byteswapped on little-endian platforms.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

There's actually a comment near the definition of PortNumber http://hackage.haskell.org/packages/archive/network/latest/doc/html/src/Netw...
-- newtyped to prevent accidental use of sane-looking -- port numbers that haven't actually been converted to -- network-byte-order first. Why the hell isn't it exported to haddocks is beyond me.
On Wed, 10 Apr 2013 16:51:23 -0400 Jeffrey Shaw
This is a case where a line of documentation could save a lot of people a lot of trouble. Anyone have a clone of network handy that they could make a pull request from?
Jeff
On Wed, Apr 10, 2013 at 4:31 PM, Florian Hofmann < fhofmann@techfak.uni-bielefeld.de> wrote:
Ah ok ... thanks for the clarification
2013/4/10 Brandon Allbery
On Wed, Apr 10, 2013 at 3:26 AM, Florian Hofmann < fhofmann@techfak.uni-bielefeld.de> wrote:
I might be mistaken, but is there a bug in the Show instance of PortNum?
Not a bug, an annoying misdesign (IMO). A PortNum is actually in network byte order. If you extract it, you get the original port; if you simply show it, you see it byteswapped on little-endian platforms.
-- brandon s allbery kf8nh sine nomine associates allbery.b@gmail.com ballbery@sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (5)
-
Brandon Allbery
-
Florian Hofmann
-
Jeffrey Shaw
-
kudah
-
Thomas DuBuisson