THRIFT-407. hs: Refactor and improve Haskell-related code



git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@763031 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/test/hs/Client.hs b/test/hs/Client.hs
index 81d7f0f..c5e4d90 100644
--- a/test/hs/Client.hs
+++ b/test/hs/Client.hs
@@ -18,18 +18,25 @@
 --
 
 module Client where
-import Thrift
+
 import ThriftTest_Client
 import ThriftTest_Types
-import TSocket
-import TBinaryProtocol
 import qualified Data.Map as Map
 import qualified Data.Set as Set
 import Control.Monad
-t = TSocket "127.0.0.1" 9090 Nothing
+import Control.Exception as CE
 
-main = do to <- topen t
-          let p =  TBinaryProtocol to
+import Network
+
+import Thrift
+import Thrift.Transport.Handle
+import Thrift.Protocol.Binary
+
+
+serverAddress = ("127.0.0.1", PortNumber 9090)
+
+main = do to <- hOpen serverAddress
+          let p =  BinaryProtocol to
           let ps = (p,p)
           print =<< testString ps "bya"
           print =<< testByte ps 8
@@ -44,5 +51,8 @@
           print =<< testList ps [1,2,3,4,5]
           print =<< testSet ps (Set.fromList [1,2,3,4,5])
           print =<< testStruct ps (Xtruct (Just "hi") (Just 4) (Just 5) Nothing)
-          tclose to
+          CE.catch (testException ps "e" >> print "bad") (\e -> print (e :: Xception))
+          CE.catch (testMultiException ps "e" "e2" >> print "ok") (\e -> print (e :: Xception))
+          CE.catch (CE.catch (testMultiException ps "e" "e2">> print "bad") (\e -> print (e :: Xception2))) (\(e :: SomeException) -> print "ok")
+          tClose to