Skip to content

Ord for PortNnumber behaves strangely #346

@MichaelXavier

Description

@MichaelXavier

I don't know if this is something you all want to solve but there's some really weird behavior that happens due to eagerly converting for endiannes at construction of PortNumber (I assume that's what's going on)

50000 < (51000 :: PortNumber)
False

50000 < (52000 :: PortNumber)
True

I discovered this when attempting to validate a port range (PortNumber, PortNumber) such that the first is <= the second. I expect one solution would be to covert back to integer for Ord. Another would be to not pre-convert the word into network byte order until you need it internally (perhaps even creating an internal newtype to convert between the two), but that sounds very tricky to get right and a much larger diff.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions