THRIFT-2401 Haskell tutorial compiles
Patch: John Chee & Roger Meier
includes minifix from:
THRIFT-2453 haskell tutorial: fix up division by 0 example
diff --git a/tutorial/hs/HaskellClient.hs b/tutorial/hs/HaskellClient.hs
index a56187b..18d72ad 100644
--- a/tutorial/hs/HaskellClient.hs
+++ b/tutorial/hs/HaskellClient.hs
@@ -30,7 +30,9 @@
import Thrift.Transport.Handle
import Thrift.Server
+import Control.Exception
import Data.Maybe
+import Data.Text.Lazy
import Text.Printf
import Network
@@ -52,9 +54,8 @@
f_Work_comment = Nothing
}
- -- TODO - get this one working
- --catch (Client.calculate client 1 work) (\except ->
- -- printf "InvalidOp %s" (show except))
+ Control.Exception.catch (printf "1/0=%d\n" =<< Client.calculate client 1 work)
+ (\e -> printf "InvalidOperation %s\n" (show (e :: InvalidOperation)))
let work = Work { f_Work_op = Just SUBTRACT,
@@ -67,7 +68,7 @@
printf "15-10=%d\n" diff
log <- SClient.getStruct client 1
- printf "Check log: %s\n" $ fromJust $ f_SharedStruct_value log
+ printf "Check log: %s\n" $ fromJust $ unpack `fmap` f_SharedStruct_value log
-- Close!
tClose transport