THRIFT-560. haskell: Move to ByteString and compiler fixes
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@898012 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/hs/src/Thrift/Transport.hs b/lib/hs/src/Thrift/Transport.hs
index 29f50d0..80e4914 100644
--- a/lib/hs/src/Thrift/Transport.hs
+++ b/lib/hs/src/Thrift/Transport.hs
@@ -28,23 +28,25 @@
import Data.Typeable ( Typeable )
+import qualified Data.ByteString.Lazy.Char8 as LBS
+import Data.Monoid
class Transport a where
tIsOpen :: a -> IO Bool
tClose :: a -> IO ()
- tRead :: a -> Int -> IO String
- tWrite :: a -> String ->IO ()
+ tRead :: a -> Int -> IO LBS.ByteString
+ tWrite :: a -> LBS.ByteString -> IO ()
tFlush :: a -> IO ()
- tReadAll :: a -> Int -> IO String
+ tReadAll :: a -> Int -> IO LBS.ByteString
- tReadAll a 0 = return []
+ tReadAll a 0 = return mempty
tReadAll a len = do
result <- tRead a len
- let rlen = length result
+ 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 ++) `fmap` (tReadAll a (len - rlen))
+ else (result `mappend`) `fmap` (tReadAll a (len - rlen))
data TransportExn = TransportExn String TransportExnType
deriving ( Show, Typeable )