Skip to content
IP data structures and textual representation
Latest commit 9c5cffe May 27, 2013 @sebnow Merge pull request #7 from mwotton/master
Update cabal maximum version

Network Address

The network-address library provides data structures for IP addresses as well as sub-networks. The goal is to have a generic, fast and complete library for representing network addresses in binary or textual form. Currently it supports IPv4 and IPv6 (partially).


*Data.Network.Address> readAddress "" :: IPv4
IPv4 2130706433
*Data.Network.Address> let ip = readAddress "" :: IPv4
*Data.Network.Address> showAddress ip
*Data.Network.Address> let subnet = readSubnet "" :: IPSubnet IPv4
*Data.Network.Address> subnet
IPSubnet (IPv4 3232235776) (-256)
*Data.Network.Address> showSubnet subnet
*Data.Network.Address> showAddress . base $ subnet
*Data.Network.Address> (readAddress "" :: IPv4) `member` subnet
*Data.Network.Address> (readAddress "" :: IPv4) `member` subnet
*Data.Network.Address> let ip = readAddress "2001:db8:0:0:0::1" :: IPv6
*Data.Network.Address> ip
IPv6 2306139568115548160 1
*Data.Network.Address> showAddress ip
*Data.Network.Address> let subnet = readSubnet "2001:db8::1/56" :: IPSubnet IPv6
*Data.Network.Address> showSubnet subnet
*Data.Network.Address> ip `member` subnet


The network-address library is build using Cabal and Hackage. Just run:

cabal configure
cabal build
cabal install


The library has not reached v1.0.0 yet, and thus has an unstable API. And minor version increase (e.g. v0.1.0 -> v0.2.0) may break backwards compatibility until v1.0.0 is reached.


Documentation is available online on Hackage:

Documentation can be generated locally using Cabal and Haddock:

cabal haddock


The test suite can be built and run with Cabal:

cabal configure --enable-tests
cabal build
cabal test


A benchmarking tool using Criterion is provided by enabling the 'benchmark' flag in Cabal:

cabal configure -fbenchmark
cabal build


  • Support for IPv4 embedded in IPv6 as per RFC 4291 Section 2.2.


The network-address library is licensed under the MIT license. Please read the LICENSE file for details.

Something went wrong with that request. Please try again.