X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=src%2FMain.hs;h=1393d4c0d41aee7983100fd1125975b59d97ec18;hb=7a0c3bbbad82825ed430d9e2a4e60aff943a4f08;hp=0e7c30fa03bd5d93e23a5f61acf716d55ff549a9;hpb=eae92cebe7fab4afc5c7de377ec30ec348ef09ad;p=email-validator.git diff --git a/src/Main.hs b/src/Main.hs index 0e7c30f..1393d4c 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,42 +1,47 @@ {-# LANGUAGE DoAndIfThenElse #-} {-# LANGUAGE RecordWildCards #-} -module Main +module Main (main) where import Control.Concurrent.ParallelIO.Global ( parallelInterleaved, - stopGlobalPool) -import Control.Monad (unless) + stopGlobalPool ) +import Control.Monad ( unless ) import qualified Data.ByteString.Char8 as BS ( hGetContents, hPutStrLn, lines, null, pack, - readFile) + readFile ) import Network.DNS ( Domain, Resolver, - ResolvConf(..), + ResolvConf( resolvTimeout ), defaultResolvConf, makeResolvSeed, - withResolver) -import Network.DNS.Lookup (lookupA, lookupMX) -import System.Directory (doesFileExist) -import System.Exit (exitWith, ExitCode(..)) + withResolver ) +import Network.DNS.Lookup ( lookupA, lookupMX ) +import System.Directory ( doesFileExist ) +import System.Exit ( exitWith, ExitCode( ExitFailure ) ) import System.IO ( IOMode( WriteMode ), hClose, hFlush, openFile, stdin, - stdout) + stdout ) -import CommandLine (Args(..), apply_args) -import EmailAddress -import ExitCodes (exit_input_file_doesnt_exist) +import CommandLine ( + Args( Args, accept_a, input_file, output_file, rfc5322 ), + get_args ) +import EmailAddress( + Address, + parts, + validate_syntax ) +import ExitCodes ( exit_input_file_doesnt_exist ) -- | Resolver parameters. We increase the default timeout from 3 to 10 @@ -103,7 +108,7 @@ validate resolver accept_a rfc5322 address = do main :: IO () main = do - Args{..} <- apply_args + Args{..} <- get_args -- Get the input from either stdin, or the file given on the command -- line. @@ -142,7 +147,7 @@ main = do -- Output the results. let valid_addresses = map fst valid_results - _ <- mapM (BS.hPutStrLn output_handle) valid_addresses + mapM_ (BS.hPutStrLn output_handle) valid_addresses stopGlobalPool