- withResolver rs $ \resolver -> do
- good_addresses <- filterM (validate resolver) nonempty_addresses
- let good_address_strings = map BS.toString good_addresses
- mapM_ (hPutStrLn stdout) good_address_strings
+ let validate' addr = withResolver rs $ \resolver ->
+ validate resolver accept_a rfc5322 addr
+
+ -- Construct a list of [IO (Address, Bool)]. The withResolver calls
+ -- are the ones that should be run in parallel.
+ let actions = map validate' nonempty_addresses
+
+ -- Run the lookup actions in parallel.
+ results <- parallelInterleaved actions
+
+ -- Filter the bad ones.
+ let valid_results = filter snd results
+
+ -- Output the results.
+ let valid_addresses = map fst valid_results
+ _ <- mapM (BS.hPutStrLn output_handle) valid_addresses
+
+ stopGlobalPool