Skip to content

Add newtype wrapper around IP[v6|v4] #5515

@lehins

Description

@lehins

Ledger uses IP type from iproute package.
It does help with parsing and such, but using that type directly has a couple of issues that need to be fixed:

  • Show instance for the type is incorrect, since it produces invalid Haskell:
    ghci> show $ Just (read "2001:db8:00:00:00:00:00:01" :: IPv6)
    "Just 2001:db8::1"
    output should be quoted, since it is a string. It should be:
    ghci> show $ Just (read "2001:db8:00:00:00:00:00:01" :: IPv6)
    "Just \"2001:db8::1\""
    There is no need to attempt and fix this upstream, since such patch would be a big breaking change and would be unlikely accepted. We can fix it however for us, by using a newtype
  • It forces us to define orphan instances in Cardano.Ledger.Orphans, which can and should be avoided.

I think the best path forward would be create newtypes with same names while importing original types as qualified. However, it doesn't have to be done this way

Metadata

Metadata

Assignees

Labels

🍰 good first issueGood for newcomersmaintenanceTasks that are planned to be done as part of the regular maintenance of the project.

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions