+-- | Takes a String representing either a hostname or an IP
+-- address. If a hostname was supplied, it is resolved to either an
+-- [IPv4] or an error. If an IP address is supplied, it is returned
+-- as a singleton [IPv4].
+--
+-- Examples:
+--
+-- >>> resolve_address "example.com"
+-- Right [93.184.216.34]
+-- >>> resolve_address "93.184.216.34"
+-- Right [93.184.216.34]
+--
+resolve_address :: String -> IO (Either DNSError [IPv4])
+resolve_address s =
+ case read_result of
+ Just addr -> return $ Right [addr]
+ Nothing -> do
+ default_rs <- makeResolvSeed defaultResolvConf
+ withResolver default_rs $ \resolver ->
+ lookupA resolver (BS.pack s)
+ where
+ read_result :: Maybe IPv4
+ read_result = readMaybe s
+
+
+-- | This calls lookupMX, and returns the result as the second
+-- component of a tuple whose first component is the domain name
+-- itself.
+--
+-- Examples:
+--
+-- The example domain, example.com, has no MX record.
+--
+-- >>> rs <- makeResolvSeed defaultResolvConf
+-- >>> let domain = BS.pack "example.com."
+-- >>> withResolver rs $ \resolver -> lookupMX' resolver domain
+-- ("example.com.",Right [])
+--