From 5950c1e313201c9876e63cbdc2ba4626a4bab09f Mon Sep 17 00:00:00 2001 From: Philipp Balzarek Date: Wed, 27 Feb 2013 15:41:19 +0100 Subject: [PATCH] replace isJust / fromJust with pattern matching --- source/Network/Xmpp/Concurrent.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/Network/Xmpp/Concurrent.hs b/source/Network/Xmpp/Concurrent.hs index cd70ed0..d9f2512 100644 --- a/source/Network/Xmpp/Concurrent.hs +++ b/source/Network/Xmpp/Concurrent.hs @@ -143,13 +143,13 @@ session :: HostName -- ^ Host to connect to -- JID resource (or Nothing to let -- the server decide) -> IO (Either XmppFailure (Session, Maybe AuthFailure)) -session hostname realm port tls sasl = runErrorT $ do +session hostname realm port mbTls mbSasl = runErrorT $ do con <- ErrorT $ openStream hostname port realm def - if isJust tls - then ErrorT $ startTls (fromJust tls) con - else return () - aut <- if isJust sasl - then ErrorT $ auth (fst $ fromJust sasl) (snd $ fromJust sasl) con - else return Nothing + case mbTls of + Nothing -> return () + Just tls -> ErrorT $ startTls tls con + aut <- case mbSasl of + Nothing -> return Nothing + Just (handlers, resource) -> ErrorT $ auth handlers resource con ses <- ErrorT $ newSession con return (ses, aut)