+-- Use weird caps, and optional trailing dot all over the place to
+-- make sure everything is handled normalized:
+--
+-- >>> import qualified Data.Set as Set ( fromList )
+-- >>> import Forward ( fwd )
+-- >>> let fwds = [fwd "user1@exAmPle.com." "user2@examPle.net"]
+-- >>> let mx_set = Set.fromList ["mx.EXAMPLE.com"]
+-- >>> let example_mx_pairs = [("Example.com", mx_set)]
+-- >>> let mx_map = Map.fromList example_mx_pairs
+-- >>> let droplist = MxList ["mx.EXAMple.com", "mx2.example.COM"]
+-- >>> map pretty_print (dropby_mxlist droplist mx_map fwds)
+-- []
+--
+-- This time it shouldn't be dropped, because ["mx.example.com"] is
+-- not contained in ["nope.example.com"]:
+--
+-- >>> import qualified Data.Map as Map ( fromList )
+-- >>> import qualified Data.Set as Set ( fromList )
+-- >>> let fwds = [fwd "user1@example.com" "user2@example.net"]
+-- >>> let mx_set = Set.fromList ["mx.example.com"]
+-- >>> let example_mx_pairs = [("example.com.", mx_set)]
+-- >>> let mx_map = Map.fromList example_mx_pairs
+-- >>> let droplist = MxList ["nope.example.com"]
+-- >>> map pretty_print (dropby_mxlist droplist mx_map fwds)
+-- ["user1@example.com -> user2@example.net"]
+--
+-- Now we check that if a forward has two MXes, one of which appears
+-- in the list of excluded MXes, it doesn't get dropped:
+--
+-- >>> import qualified Data.Map as Map ( fromList )
+-- >>> import qualified Data.Set as Set ( fromList )
+-- >>> let fwds = [fwd "user1@example.com" "user2@example.net"]
+-- >>> let mx_set = Set.fromList ["mx1.example.com", "mx2.example.com"]
+-- >>> let example_mx_pairs = [("example.com.", mx_set)]
+-- >>> let mx_map = Map.fromList example_mx_pairs
+-- >>> let droplist = MxList ["mx1.example.com"]
+-- >>> map pretty_print (dropby_mxlist droplist mx_map fwds)
+-- ["user1@example.com -> user2@example.net"]
+--
+dropby_mxlist :: MxList -> MxSetMap -> [Forward] -> [Forward]
+dropby_mxlist (MxList []) _ = id
+dropby_mxlist (MxList mxs) domain_mx_map =
+ filter (not . is_bad)