X-Git-Url: http://gitweb.michael.orlitzky.com/?p=list-remote-forwards.git;a=blobdiff_plain;f=src%2FForward.hs;h=d4936eda5c2169fbbcdc3130689125cb111195cd;hp=8d977fac299e46017850efdcc625fa99a9001ca3;hb=66345cef9e56c6175cb6f25f41fbf628648d15a3;hpb=34d9cc7a2def43cb2d588ee3d1d405f0b9d4a1d0 diff --git a/src/Forward.hs b/src/Forward.hs index 8d977fa..d4936ed 100644 --- a/src/Forward.hs +++ b/src/Forward.hs @@ -11,7 +11,7 @@ where import Data.String.Utils ( split, strip ) -import DNS ( normalize_string_domain ) +import DNS ( NormalDomain, normalize_string ) -- | Type synonym to make the signatures below a little more clear. -- WARNING: Also defined in the "Report" module. @@ -220,27 +220,23 @@ domain_part address = parts = split "@" address --- | Given a list of 'Domain's @domains@ and a list of 'Forward's +-- | Given a list of 'NormalDomain's @domains@ and a list of 'Forward's -- @forwards@, filter out all elements of @forwards@ that have a -- goto domain in the list of @domains@. -- -- ==== __Examples__ -- --- >>> let ds = ["example.com", "example.net"] +-- >>> let ds = map normalize_string ["example.com", "example.net"] -- >>> let f1 = fwd "a@example.com" "a@example.com" -- >>> let f2 = fwd "a@example.com" "a1@example.net" -- >>> let f3 = fwd "a@example.com" "a2@example.org" -- >>> map pretty_print (dropby_goto_domains ds [f1,f2,f3]) -- ["a@example.com -> a2@example.org"] -- -dropby_goto_domains :: [Domain] -> [Forward] -> [Forward] -dropby_goto_domains domains = +dropby_goto_domains :: [NormalDomain] -> [Forward] -> [Forward] +dropby_goto_domains normal_domains = filter (not . is_bad) where - -- If we don't normalize these first, comparison (i.e. `elem`) - -- doesn't work so great. - normalized_domains = map normalize_string_domain domains - -- | A 'Forward' is bad if its goto domain appears in the list, or -- if we can't figure out its goto domain. -- @@ -248,4 +244,5 @@ dropby_goto_domains domains = is_bad f = case (goto_domain f) of Nothing -> True -- Drop these, too. - Just d -> (normalize_string_domain d) `elem` normalized_domains + -- Nice, we can't compare unless we normalize @d@! + Just d -> (normalize_string d) `elem` normal_domains