lookup package:iproute

The lookup function looks up IPRTable with a key of AddrRange. If a routing information in IPRTable matches the key, its value is returned.
>>> let v4 = ["133.4.0.0/16","133.5.0.0/16","133.5.16.0/24","133.5.23.0/24"] :: [AddrRange IPv4]

>>> let rt = fromList $ zip v4 v4

>>> lookup "127.0.0.1" rt
Nothing

>>> lookup "133.3.0.1" rt
Nothing

>>> lookup "133.4.0.0" rt
Just 133.4.0.0/16

>>> lookup "133.4.0.1" rt
Just 133.4.0.0/16

>>> lookup "133.5.16.0" rt
Just 133.5.16.0/24

>>> lookup "133.5.16.1" rt
Just 133.5.16.0/24
lookupAll is a version of lookup that returns all entries matching the given key, not just the longest match.
>>> :set -XOverloadedStrings

>>> let rt = fromList ([("192.168.0.0/24", 1), ("10.10.0.0/16", 2), ("10.0.0.0/8", 3)] :: [(AddrRange IPv4, Int)])

>>> lookupAll "127.0.0.1" rt
[]

>>> lookupAll "192.168.0.1" rt
[(192.168.0.0/24,1)]

>>> lookupAll "10.10.0.1" rt
[(10.10.0.0/16,2),(10.0.0.0/8,3)]
The lookupKeyValue function looks up IPRTable with a key of AddrRange. If a routing information in IPRTable matches the key, both key and value are returned.
>>> :set -XOverloadedStrings

>>> let rt = fromList ([("192.168.0.0/24", 1), ("10.10.0.0/16", 2)] :: [(AddrRange IPv4, Int)])

>>> lookupKeyValue "127.0.0.1" rt
Nothing

>>> lookupKeyValue "192.168.0.1" rt
Just (192.168.0.0/24,1)

>>> lookupKeyValue "10.10.0.1" rt
Just (10.10.0.0/16,2)