mask package:iproute

The mask function returns a contiguous IP mask from AddrRange.
The masked function takes an Addr and a contiguous mask and returned a masked Addr.
The intToMask function takes an Int representing the number of bits to be set in the returned contiguous mask. When this integer is positive the bits will be starting from the MSB and from the LSB otherwise.
>>> intToMask 16 :: IPv4
255.255.0.0
>>> intToMask (-16) :: IPv4
0.0.255.255
>>> intToMask 16 :: IPv6
ffff::
>>> intToMask (-16) :: IPv6
::ffff