I tend to fall into the use of forM_ in Haskell which is quite like .each in Ruby or foreach in Scala.
import Control.Monad (forM_)
import Network.BSD (getHostByName, hostAddresses)
import Network.Socket (inet_ntoa)
import System.Environment (getArgs)
resolve address = do
  ent <- getHostByName address
  mapM inet_ntoa (hostAddresses ent)
main = do
  args <- getArgs
  args `forM_` (\address -> do
    ips <- resolve address
    ips `forM_` (\ip -> putStrLn $ address ++ "\t" ++ ip))
It doesn't seem to be idiomatic to me but using mapM_ seems clumsy. Is there an idiomatic way of rewriting this code?
 
     
    