Thrift: Haskell library and codegen
Summary: It's thrift for haskell. The codegen is complete. The library has binary protocol, io channel transport, and a threaded server.
Reviewed by: mcslee
Test plan: Yes
Revert plan: yes
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665174 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/hs/src/TChannelTransport.hs b/lib/hs/src/TChannelTransport.hs
new file mode 100644
index 0000000..df1aedc
--- /dev/null
+++ b/lib/hs/src/TChannelTransport.hs
@@ -0,0 +1,22 @@
+module TChannelTransport(TChannelTrans(..)) where
+import System.IO
+import IO
+import Thrift
+import Control.Exception
+data TChannelTrans = TChannelTrans (Handle)
+
+instance TTransport TChannelTrans where
+ tisOpen a = True
+ topen a = return a
+ tclose a = return a
+ tread a 0 = return []
+ tread (TChannelTrans h) i = Prelude.catch
+ (do c <- hGetChar h
+ t <- tread (TChannelTrans h) (i-1)
+ return $ c:t)
+ (\e -> if isEOFError e then return [] else throwDyn (TransportExn "TChannelTransport: Could not read" TE_UNKNOWN))
+ twrite a [] = return ()
+ twrite (TChannelTrans h) (c:t) = do hPutChar h c
+ twrite (TChannelTrans h) t
+ tflush (TChannelTrans h) = hFlush h
+