normalize package:ip

Normalize an IPv4Range. The first result of this is that the IPv4 inside the IPv4Range is changed so that the insignificant bits are zeroed out. For example:
>>> IPv4.printRange $ IPv4.normalize $ IPv4.IPv4Range (IPv4.fromOctets 192 168 1 19) 24
192.168.1.0/24

>>> IPv4.printRange $ IPv4.normalize $ IPv4.IPv4Range (IPv4.fromOctets 192 168 1 163) 28
192.168.1.160/28
The second effect of this is that the mask length is lowered to be 32 or smaller. Working with IPv4Ranges that have not been normalized does not cause any issues for this library, although other applications may reject such ranges (especially those with a mask length above 32). Note that normalize is idempotent, that is:
IPv4.normalize r == (IPv4.normalize . IPv4.normalize) r
Normalize an IPv6Range. The first result of this is that the IPv6 inside the IPv6Range is changed so that the insignificant bits are zeroed out. For example:
>>> addr1 = IPv6.ipv6 0x0192 0x0168 0x0001 0x0019 0x0000 0x0000 0x0000 0x0000

>>> addr2 = IPv6.ipv6 0x0192 0x0168 0x0001 0x0163 0x0000 0x0000 0x0000 0x0000

>>> IPv6.printRange $ IPv6.normalize $ IPv6.IPv6Range addr1 24
192:100::/24

>>> IPv6.printRange $ IPv6.normalize $ IPv6.IPv6Range addr2 28
192:160::/28
The second effect of this is that the mask length is lowered to be 128 or smaller. Working with IPv6Ranges that have not been normalized does not cause any issues for this library, although other applications may reject such ranges (especially those with a mask length above 128). Note that 'normalize is idempotent, that is:
IPv6.normalize r == (IPv6.normalize . IPv6.normalize) r