Skip to content

Commit 559c4be

Browse files
committed
v0.5 Okay
1 parent abf4156 commit 559c4be

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

Text/IPv6Addr.hs

+12-2
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ module Text.IPv6Addr
1616
, maybeIPv6Addr
1717
, maybePureIPv6Addr
1818
, maybeFullIPv6Addr
19+
, sameIPv6Addr
1920
, fromIPv6Addr
20-
, toIP6ARPA
21-
, toHostName
2221
, toIPv6
22+
, toHostName
23+
, toIP6ARPA
2324
, getIPv6AddrOf
2425
, randIPv6Addr
2526
) where
@@ -60,6 +61,15 @@ maybePureIPv6Addr t = maybeTokPureIPv6Addr t >>= ipv6TokensToIPv6Addr
6061
maybeFullIPv6Addr :: T.Text -> Maybe IPv6Addr
6162
maybeFullIPv6Addr t = maybeTokPureIPv6Addr t >>= (ipv6TokensToIPv6Addr . expandTokens . fromDoubleColon)
6263

64+
-- | Returns 'True' if arguments are two textual representations of the same IPv6 address.
65+
sameIPv6Addr :: T.Text -> T.Text -> Bool
66+
sameIPv6Addr a b =
67+
case maybePureIPv6Addr a of
68+
Nothing -> False
69+
Just a' -> case maybePureIPv6Addr b of
70+
Nothing -> False
71+
Just b' -> a' == b'
72+
6373
-- | Returns the reverse lookup domain name corresponding of the given IPv6 address (RFC 3596 Section 2.5).
6474
--
6575
-- > toIP6ARPA (IPv6Addr "4321:0:1:2:3:4:567:89ab") == "b.a.9.8.7.6.5.0.4.0.0.0.3.0.0.0.2.0.0.0.1.0.0.0.0.0.0.0.1.2.3.4.IP6.ARPA."

0 commit comments

Comments
 (0)