connect' :: ConnectInfo -> IO Handle
connect' i = loop (connectAuth i)
  where
    loop [] = do
        connectTo (connectHost i) (connectPort i)

    loop [a] = do
        h <- connectTo (connectHost i) (connectPort i)
        auth a (\_ -> return h) throwIO h

    loop (a:as) = do
        h <- connectTo (connectHost i) (connectPort i)
        handle (\(_::IOError) -> loop as) $
            auth a (\_ -> return h) (\_ -> loop as) h
connect' :: ConnectInfo -> IO Handle
connect' i = loop (connectAuth i)
  where
    loop [] = do
        connectTo (connectHost i) (connectPort i)

    loop [a] = do
        h <- connectTo (connectHost i) (connectPort i)
        auth a (\_ -> return h) throwIO h

    loop (a:as) = do
        h <- connectTo (connectHost i) (connectPort i)
        handle (\(_::IOError) -> loop as) $
            auth a (\_ -> return h) (\_ -> loop as) h
connect' i = loop (connectAuth i)
  where
    loop [] = do
        connectTo (connectHost i) (connectPort i)

    loop [a] = do
        h <- connectTo (connectHost i) (connectPort i)
        auth a (\_ -> return h) throwIO h

    loop (a:as) = do
        h <- connectTo (connectHost i) (connectPort i)
        handle (\(_::IOError) -> loop as) $
            auth a (\_ -> return h) (\_ -> loop as) h