A network address format

Latest on Hackage:0.3.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow to host generated Haddocks.

BSD3 licensed and maintained by Micxjo Funkcio


Hackage Build Status

A multiaddr implementation in Haskell. Multiaddr is a self-describing network address format supporting a variety of protocols, with both string and binary representations.


We're on Hackage, so just add multiaddr to your cabal build-depends.


import Network.Multiaddr

let Just somewhere = readMultiaddr "/ip4/"
protocolNames somewhere -- ["ip4", "tcp"]

-- Encapsulation
-- Multiaddr is a monoid, `encapsulate` is just an alias for (<>)
let Just proxy = readMultiaddr "/ip6/::1/tcp/443"
let proxied = proxy `encapsulate` somewhere

toText proxied -- "/ip6/::1/tcp/443/ip4/"
hasIPv6 proxied -- True

-- Grab an individual part of the address
parts proxied !! 2  -- "/ip4/"

-- Encode into a ByteString
let bytes = encode proxied

-- Decode and get back the original!
let Just decoded = decode bytes
decoded == proxied -- True
Used by 1 package:
comments powered byDisqus