THRIFT-2641 Improvements to Haskell Compiler/Libraries
- test/test.sh integration
- add json and compact protocol
This closes #175
Signed-off-by: Roger Meier <roger@apache.org>
diff --git a/lib/hs/src/Thrift/Transport.hs b/lib/hs/src/Thrift/Transport.hs
index 3e5f18b..306edc2 100644
--- a/lib/hs/src/Thrift/Transport.hs
+++ b/lib/hs/src/Thrift/Transport.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE DeriveDataTypeable #-}
+{-# LANGUAGE MultiParamTypeClasses #-}
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
@@ -26,8 +27,9 @@
import Control.Monad ( when )
import Control.Exception ( Exception, throw )
-
+import Data.Functor ( (<$>) )
import Data.Typeable ( Typeable )
+import Data.Word
import qualified Data.ByteString.Lazy as LBS
import Data.Monoid
@@ -36,6 +38,7 @@
tIsOpen :: a -> IO Bool
tClose :: a -> IO ()
tRead :: a -> Int -> IO LBS.ByteString
+ tPeek :: a -> IO (Maybe Word8)
tWrite :: a -> LBS.ByteString -> IO ()
tFlush :: a -> IO ()
tReadAll :: a -> Int -> IO LBS.ByteString
@@ -46,8 +49,8 @@
let rlen = fromIntegral $ LBS.length result
when (rlen == 0) (throw $ TransportExn "Cannot read. Remote side has closed." TE_UNKNOWN)
if len <= rlen
- then return result
- else (result `mappend`) `fmap` (tReadAll a (len - rlen))
+ then return result
+ else (result `mappend`) <$> tReadAll a (len - rlen)
data TransportExn = TransportExn String TransportExnType
deriving ( Show, Typeable )
@@ -60,4 +63,3 @@
| TE_TIMED_OUT
| TE_END_OF_FILE
deriving ( Eq, Show, Typeable )
-