packages feed

Thrift 0.4.0 → 0.5.0

raw patch · 11 files changed

+169/−117 lines, 11 filessetup-changedPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Thrift.Protocol: readBinary :: (Protocol a, Transport t) => a t -> IO String
+ Thrift.Protocol: readBinary :: (Protocol a, Transport t) => a t -> IO ByteString
- Thrift.Protocol: readByte :: (Protocol a, Transport t) => a t -> IO Int
+ Thrift.Protocol: readByte :: (Protocol a, Transport t) => a t -> IO Word8
- Thrift.Protocol: readFieldBegin :: (Protocol a, Transport t) => a t -> IO (String, ThriftType, Int)
+ Thrift.Protocol: readFieldBegin :: (Protocol a, Transport t) => a t -> IO (String, ThriftType, Int16)
- Thrift.Protocol: readI16 :: (Protocol a, Transport t) => a t -> IO Int
+ Thrift.Protocol: readI16 :: (Protocol a, Transport t) => a t -> IO Int16
- Thrift.Protocol: readI32 :: (Protocol a, Transport t) => a t -> IO Int
+ Thrift.Protocol: readI32 :: (Protocol a, Transport t) => a t -> IO Int32
- Thrift.Protocol: readListBegin :: (Protocol a, Transport t) => a t -> IO (ThriftType, Int)
+ Thrift.Protocol: readListBegin :: (Protocol a, Transport t) => a t -> IO (ThriftType, Int32)
- Thrift.Protocol: readMapBegin :: (Protocol a, Transport t) => a t -> IO (ThriftType, ThriftType, Int)
+ Thrift.Protocol: readMapBegin :: (Protocol a, Transport t) => a t -> IO (ThriftType, ThriftType, Int32)
- Thrift.Protocol: readMessageBegin :: (Protocol a, Transport t) => a t -> IO (String, MessageType, Int)
+ Thrift.Protocol: readMessageBegin :: (Protocol a, Transport t) => a t -> IO (String, MessageType, Int32)
- Thrift.Protocol: readSetBegin :: (Protocol a, Transport t) => a t -> IO (ThriftType, Int)
+ Thrift.Protocol: readSetBegin :: (Protocol a, Transport t) => a t -> IO (ThriftType, Int32)
- Thrift.Protocol: writeBinary :: (Protocol a, Transport t) => a t -> String -> IO ()
+ Thrift.Protocol: writeBinary :: (Protocol a, Transport t) => a t -> ByteString -> IO ()
- Thrift.Protocol: writeByte :: (Protocol a, Transport t) => a t -> Int -> IO ()
+ Thrift.Protocol: writeByte :: (Protocol a, Transport t) => a t -> Word8 -> IO ()
- Thrift.Protocol: writeFieldBegin :: (Protocol a, Transport t) => a t -> (String, ThriftType, Int) -> IO ()
+ Thrift.Protocol: writeFieldBegin :: (Protocol a, Transport t) => a t -> (String, ThriftType, Int16) -> IO ()
- Thrift.Protocol: writeI16 :: (Protocol a, Transport t) => a t -> Int -> IO ()
+ Thrift.Protocol: writeI16 :: (Protocol a, Transport t) => a t -> Int16 -> IO ()
- Thrift.Protocol: writeI32 :: (Protocol a, Transport t) => a t -> Int -> IO ()
+ Thrift.Protocol: writeI32 :: (Protocol a, Transport t) => a t -> Int32 -> IO ()
- Thrift.Protocol: writeListBegin :: (Protocol a, Transport t) => a t -> (ThriftType, Int) -> IO ()
+ Thrift.Protocol: writeListBegin :: (Protocol a, Transport t) => a t -> (ThriftType, Int32) -> IO ()
- Thrift.Protocol: writeMapBegin :: (Protocol a, Transport t) => a t -> (ThriftType, ThriftType, Int) -> IO ()
+ Thrift.Protocol: writeMapBegin :: (Protocol a, Transport t) => a t -> (ThriftType, ThriftType, Int32) -> IO ()
- Thrift.Protocol: writeMessageBegin :: (Protocol a, Transport t) => a t -> (String, MessageType, Int) -> IO ()
+ Thrift.Protocol: writeMessageBegin :: (Protocol a, Transport t) => a t -> (String, MessageType, Int32) -> IO ()
- Thrift.Protocol: writeSetBegin :: (Protocol a, Transport t) => a t -> (ThriftType, Int) -> IO ()
+ Thrift.Protocol: writeSetBegin :: (Protocol a, Transport t) => a t -> (ThriftType, Int32) -> IO ()

Files

+ LICENSE view
@@ -0,0 +1,16 @@+Licensed to the Apache Software Foundation (ASF) under one+or more contributor license agreements. See the NOTICE file+distributed with this work for additional information+regarding copyright ownership. The ASF licenses this file+to you under the Apache License, Version 2.0 (the+"License"); you may not use this file except in compliance+with the License. You may obtain a copy of the License at++  http://www.apache.org/licenses/LICENSE-2.0++Unless required by applicable law or agreed to in writing,+software distributed under the License is distributed on an+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+KIND, either express or implied. See the License for the+specific language governing permissions and limitations+under the License.
README view
@@ -20,46 +20,53 @@ specific language governing permissions and limitations under the License. -Running+Compile ======= -You need -fglasgow-exts. Use Cabal to compile and install. If you're trying to-manually compile or load via ghci, and you're using ghc 6.10 (or really if your-default base package has major version number 4), you must specify a version of-the base package with major version number 3. Furthermore if you have the syb-package installed you need to hide that package to avoid import conflicts.-Here's an example of what I'm talking about:+Use Cabal to compile and install; ./configure uses Cabal underneath, and that+path is not yet well tested. Thrift's library and generated code should compile+with pretty much any GHC extensions or warnings you enable (or disable).+Please report this not being the case as a bug on+https://issues.apache.org/jira/secure/CreateIssue!default.jspa -  ghci -fglasgow-exts -package base-3.0.3.0 -hide-package syb -isrc Thrift.hs+Chances you'll need to muck a bit with Cabal flags to install Thrift: -To determine which versions of the base package you have installed use the-following command:+CABAL_CONFIGURE_FLAGS="--user" ./configure -  ghc-pkg list base+Base Types+========== -All of this is taken care of for you if you use Cabal.+The mapping from Thrift types to Haskell's is: + * double -> Double+ * i8 -> Data.Word.Word8+ * i16 -> Data.Int.Int16+ * i32 -> Data.Int.Int32+ * i64 -> Data.Int.Int64+ * string -> String+ * binary -> Data.ByteString.Lazy+ * bool -> Boolean  Enums ===== -become haskell data types. Use fromEnum to get out the int value.+Become Haskell 'data' types. Use fromEnum to get out the int value.  Structs ======= -become records. Field labels are ugly, of the form f_STRUCTNAME_FIELDNAME. All+Become records. Field labels are ugly, of the form f_STRUCTNAME_FIELDNAME. All fields are Maybe types.  Exceptions ========== -identical to structs. Throw them with throwDyn. Catch them with catchDyn.+Identical to structs. Throw them with throwDyn. Catch them with catchDyn.  Client ====== -just a bunch of functions. You may have to import a bunch of client files to+Just a bunch of functions. You may have to import a bunch of client files to deal with inheritance.  Interface
Setup.lhs view
@@ -1,23 +1,21 @@ #!/usr/bin/env runhaskell -#-# Licensed to the Apache Software Foundation (ASF) under one-# or more contributor license agreements. See the NOTICE file-# distributed with this work for additional information-# regarding copyright ownership. The ASF licenses this file-# to you under the Apache License, Version 2.0 (the-# "License"); you may not use this file except in compliance-# with the License. You may obtain a copy of the License at-#-#   http://www.apache.org/licenses/LICENSE-2.0-#-# Unless required by applicable law or agreed to in writing,-# software distributed under the License is distributed on an-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY-# KIND, either express or implied. See the License for the-# specific language governing permissions and limitations-# under the License.-#+> -- Licensed to the Apache Software Foundation (ASF) under one+> -- or more contributor license agreements. See the NOTICE file+> -- distributed with this work for additional information+> -- regarding copyright ownership. The ASF licenses this file+> -- to you under the Apache License, Version 2.0 (the+> -- "License"); you may not use this file except in compliance+> -- with the License. You may obtain a copy of the License at+> -- +> --   http://www.apache.org/licenses/LICENSE-2.0+> -- +> -- Unless required by applicable law or agreed to in writing,+> -- software distributed under the License is distributed on an+> -- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+> -- KIND, either express or implied. See the License for the+> -- specific language governing permissions and limitations+> -- under the License.  > import Distribution.Simple > main = defaultMain
Thrift.cabal view
@@ -18,26 +18,27 @@ --  Name:           Thrift-Version:        0.4.0+Version:        0.5.0 Cabal-Version:  >= 1.2.3 License:        OtherLicense Category:       Foreign Build-Type:     Simple Synopsis:       Thrift library package-homepage:       http://incubator.apache.org/thrift-maintainer:     thrift-user-subscribe@incubator.apache.org -description:-  The Thrift Haskell package that shipped with Thrift v.0.4.0, released under the Apache 2.0 license.+Homepage:       http://incubator.apache.org/thrift+Maintainer:     thrift-user-subscribe@incubator.apache.org +Description:+  The Thrift Haskell package that shipped with Thrift v.0.5.0, released under the Apache 2.0 license.  Library   Hs-Source-Dirs:     src   Build-Depends:     base >=4 && < 5, network, ghc-prim, binary, bytestring, HTTP-  ghc-options:-    -fglasgow-exts-  Extensions:-    DeriveDataTypeable   Exposed-Modules:     Thrift, Thrift.Protocol, Thrift.Transport, Thrift.Protocol.Binary-    Thrift.Transport.Handle, Thrift.Transport.HttpClient,  Thrift.Server+    Thrift.Transport.Handle, Thrift.Transport.HttpClient, Thrift.Server+  Extensions:+    DeriveDataTypeable, ExistentialQuantification, FlexibleInstances,+    KindSignatures, MagicHash, RankNTypes,+    ScopedTypeVariables, TypeSynonymInstances+
src/Thrift.hs view
@@ -1,3 +1,6 @@+{-# LANGUAGE DeriveDataTypeable #-}+{-# LANGUAGE KindSignatures #-}+{-# LANGUAGE RankNTypes #-} -- -- Licensed to the Apache Software Foundation (ASF) under one -- or more contributor license agreements. See the NOTICE file@@ -56,6 +59,7 @@     toEnum 3 = AE_WRONG_METHOD_NAME     toEnum 4 = AE_BAD_SEQUENCE_ID     toEnum 5 = AE_MISSING_RESULT+    toEnum t = error $ "Invalid AppExnType " ++ show t      fromEnum AE_UNKNOWN = 0     fromEnum AE_UNKNOWN_METHOD = 1@@ -78,34 +82,35 @@         writeFieldEnd pt      writeFieldBegin pt ("type", T_I32, 2);-    writeI32 pt (fromEnum (ae_type ae))+    writeI32 pt (fromIntegral $ fromEnum (ae_type ae))     writeFieldEnd pt     writeFieldStop pt     writeStructEnd pt  readAppExn :: (Protocol p, Transport t) => p t -> IO AppExn readAppExn pt = do-    readStructBegin pt-    r <- readAppExnFields pt (AppExn {ae_type = undefined, ae_message = undefined})+    _ <- readStructBegin pt+    record <- readAppExnFields pt (AppExn {ae_type = undefined, ae_message = undefined})     readStructEnd pt-    return r+    return record -readAppExnFields pt r = do-    (n, ft, id) <- readFieldBegin pt+readAppExnFields :: forall (a :: * -> *) t. (Protocol a, Transport t) => a t -> AppExn -> IO AppExn +readAppExnFields pt record = do+    (_, ft, tag) <- readFieldBegin pt     if ft == T_STOP-        then return r-        else case id of+        then return record+        else case tag of                  1 -> if ft == T_STRING then                           do s <- readString pt-                             readAppExnFields pt r{ae_message = s}+                             readAppExnFields pt record{ae_message = s}                           else do skip pt ft-                                  readAppExnFields pt r+                                  readAppExnFields pt record                  2 -> if ft == T_I32 then                           do i <- readI32 pt-                             readAppExnFields pt r{ae_type = (toEnum  i)}+                             readAppExnFields pt record{ae_type = (toEnum $ fromIntegral i)}                           else do skip pt ft-                                  readAppExnFields pt r+                                  readAppExnFields pt record                  _ -> do skip pt ft                          readFieldEnd pt-                         readAppExnFields pt r+                         readAppExnFields pt record 
src/Thrift/Protocol.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE DeriveDataTypeable #-} -- -- Licensed to the Apache Software Foundation (ASF) under one -- or more contributor license agreements. See the NOTICE file@@ -28,9 +29,10 @@  import Control.Monad ( replicateM_, unless ) import Control.Exception--import Data.Typeable ( Typeable ) import Data.Int+import Data.Typeable ( Typeable )+import Data.Word+import Data.ByteString.Lazy  import Thrift.Transport @@ -79,6 +81,7 @@     toEnum 13 = T_MAP     toEnum 14 = T_SET     toEnum 15 = T_LIST+    toEnum t = error $ "Invalid ThriftType " ++ show t  data MessageType     = M_CALL@@ -94,63 +97,64 @@     toEnum 1 = M_CALL     toEnum 2 = M_REPLY     toEnum 3 = M_EXCEPTION+    toEnum t = error $ "Invalid MessageType " ++ show t   class Protocol a where     getTransport :: Transport t => a t -> t -    writeMessageBegin :: Transport t => a t -> (String, MessageType, Int) -> IO ()+    writeMessageBegin :: Transport t => a t -> (String, MessageType, Int32) -> IO ()     writeMessageEnd   :: Transport t => a t -> IO ()      writeStructBegin :: Transport t => a t -> String -> IO ()     writeStructEnd   :: Transport t => a t -> IO ()-    writeFieldBegin  :: Transport t => a t -> (String, ThriftType, Int) -> IO ()+    writeFieldBegin  :: Transport t => a t -> (String, ThriftType, Int16) -> IO ()     writeFieldEnd    :: Transport t => a t -> IO ()     writeFieldStop   :: Transport t => a t -> IO ()-    writeMapBegin    :: Transport t => a t -> (ThriftType, ThriftType, Int) -> IO ()+    writeMapBegin    :: Transport t => a t -> (ThriftType, ThriftType, Int32) -> IO ()     writeMapEnd      :: Transport t => a t -> IO ()-    writeListBegin   :: Transport t => a t -> (ThriftType, Int) -> IO ()+    writeListBegin   :: Transport t => a t -> (ThriftType, Int32) -> IO ()     writeListEnd     :: Transport t => a t -> IO ()-    writeSetBegin    :: Transport t => a t -> (ThriftType, Int) -> IO ()+    writeSetBegin    :: Transport t => a t -> (ThriftType, Int32) -> IO ()     writeSetEnd      :: Transport t => a t -> IO ()      writeBool   :: Transport t => a t -> Bool -> IO ()-    writeByte   :: Transport t => a t -> Int -> IO ()-    writeI16    :: Transport t => a t -> Int -> IO ()-    writeI32    :: Transport t => a t -> Int -> IO ()+    writeByte   :: Transport t => a t -> Word8 -> IO ()+    writeI16    :: Transport t => a t -> Int16 -> IO ()+    writeI32    :: Transport t => a t -> Int32 -> IO ()     writeI64    :: Transport t => a t -> Int64 -> IO ()     writeDouble :: Transport t => a t -> Double -> IO ()     writeString :: Transport t => a t -> String -> IO ()-    writeBinary :: Transport t => a t -> String -> IO ()+    writeBinary :: Transport t => a t -> ByteString -> IO ()  -    readMessageBegin :: Transport t => a t -> IO (String, MessageType, Int)+    readMessageBegin :: Transport t => a t -> IO (String, MessageType, Int32)     readMessageEnd   :: Transport t => a t -> IO ()      readStructBegin :: Transport t => a t -> IO String     readStructEnd   :: Transport t => a t -> IO ()-    readFieldBegin  :: Transport t => a t -> IO (String, ThriftType, Int)+    readFieldBegin  :: Transport t => a t -> IO (String, ThriftType, Int16)     readFieldEnd    :: Transport t => a t -> IO ()-    readMapBegin    :: Transport t => a t -> IO (ThriftType, ThriftType, Int)+    readMapBegin    :: Transport t => a t -> IO (ThriftType, ThriftType, Int32)     readMapEnd      :: Transport t => a t -> IO ()-    readListBegin   :: Transport t => a t -> IO (ThriftType, Int)+    readListBegin   :: Transport t => a t -> IO (ThriftType, Int32)     readListEnd     :: Transport t => a t -> IO ()-    readSetBegin    :: Transport t => a t -> IO (ThriftType, Int)+    readSetBegin    :: Transport t => a t -> IO (ThriftType, Int32)     readSetEnd      :: Transport t => a t -> IO ()      readBool   :: Transport t => a t -> IO Bool-    readByte   :: Transport t => a t -> IO Int-    readI16    :: Transport t => a t -> IO Int-    readI32    :: Transport t => a t -> IO Int+    readByte   :: Transport t => a t -> IO Word8+    readI16    :: Transport t => a t -> IO Int16+    readI32    :: Transport t => a t -> IO Int32     readI64    :: Transport t => a t -> IO Int64     readDouble :: Transport t => a t -> IO Double     readString :: Transport t => a t -> IO String-    readBinary :: Transport t => a t -> IO String+    readBinary :: Transport t => a t -> IO ByteString   skip :: (Protocol p, Transport t) => p t -> ThriftType -> IO ()-skip p T_STOP = return ()-skip p T_VOID = return ()+skip _ T_STOP = return ()+skip _ T_VOID = return () skip p T_BOOL = readBool p >> return () skip p T_BYTE = readByte p >> return () skip p T_I16 = readI16 p >> return ()@@ -158,17 +162,17 @@ skip p T_I64 = readI64 p >> return () skip p T_DOUBLE = readDouble p >> return () skip p T_STRING = readString p >> return ()-skip p T_STRUCT = do readStructBegin p+skip p T_STRUCT = do _ <- readStructBegin p                      skipFields p                      readStructEnd p skip p T_MAP = do (k, v, s) <- readMapBegin p-                  replicateM_ s (skip p k >> skip p v)+                  replicateM_ (fromIntegral s) (skip p k >> skip p v)                   readMapEnd p skip p T_SET = do (t, n) <- readSetBegin p-                  replicateM_ n (skip p t)+                  replicateM_ (fromIntegral n) (skip p t)                   readSetEnd p skip p T_LIST = do (t, n) <- readListBegin p-                   replicateM_ n (skip p t)+                   replicateM_ (fromIntegral n) (skip p t)                    readListEnd p  
src/Thrift/Protocol/Binary.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE ExistentialQuantification #-}+{-# LANGUAGE MagicHash #-} -- -- Licensed to the Apache Software Foundation (ASF) under one -- or more contributor license agreements. See the NOTICE file@@ -28,6 +30,7 @@ import Data.Bits import Data.Int import Data.List ( foldl' )+import Data.Word  import GHC.Exts import GHC.Word@@ -35,9 +38,13 @@ import Thrift.Protocol import Thrift.Transport -import qualified Data.ByteString.Lazy.Char8 as LBS+import qualified Data.ByteString.Lazy.Char8 as LBSChar8+import qualified Data.ByteString.Lazy as LBS +version_mask :: Int32 version_mask = 0xffff0000++version_1 :: Int32 version_1    = 0x80010000  data BinaryProtocol a = Transport a => BinaryProtocol a@@ -47,7 +54,7 @@     getTransport (BinaryProtocol t) = t      writeMessageBegin p (n, t, s) = do-        writeI32 p (version_1 .|. (fromEnum t))+        writeI32 p (version_1 .|. (fromIntegral $ fromEnum t))         writeString p n         writeI32 p s     writeMessageEnd _ = return ()@@ -58,20 +65,20 @@     writeFieldEnd _ = return ()     writeFieldStop p = writeType p T_STOP     writeMapBegin p (k, v, n) = writeType p k >> writeType p v >> writeI32 p n-    writeMapEnd p = return ()+    writeMapEnd _ = return ()     writeListBegin p (t, n) = writeType p t >> writeI32 p n     writeListEnd _ = return ()     writeSetBegin p (t, n) = writeType p t >> writeI32 p n     writeSetEnd _ = return () -    writeBool p b = tWrite (getTransport p) $ LBS.singleton $ toEnum $ if b then 1 else 0+    writeBool p b = tWrite (getTransport p) $ LBSChar8.singleton $ toEnum $ if b then 1 else 0     writeByte p b = tWrite (getTransport p) (getBytes b 1)     writeI16 p b = tWrite (getTransport p) (getBytes b 2)     writeI32 p b = tWrite (getTransport p) (getBytes b 4)     writeI64 p b = tWrite (getTransport p) (getBytes b 8)     writeDouble p d = writeI64 p (fromIntegral $ floatBits d)-    writeString p s = writeI32 p (length s) >> tWrite (getTransport p) (LBS.pack s)-    writeBinary = writeString+    writeString p s = writeI32 p (fromIntegral $ length s) >> tWrite (getTransport p) (LBSChar8.pack s)+    writeBinary p s = writeI32 p (fromIntegral $ LBS.length s) >> tWrite (getTransport p) s      readMessageBegin p = do         ver <- readI32 p@@ -80,7 +87,7 @@             else do               s <- readString p               sz <- readI32 p-              return (s, toEnum $ ver .&. 0xFF, sz)+              return (s, toEnum $ fromIntegral $ ver .&. 0xFF, sz)     readMessageEnd _ = return ()     readStructBegin _ = return ""     readStructEnd _ = return ()@@ -120,29 +127,32 @@         return $ floatOfBits $ fromIntegral bs     readString p = do         i <- readI32 p-        LBS.unpack `liftM` tReadAll (getTransport p) i--    readBinary = readString+        LBSChar8.unpack `liftM` tReadAll (getTransport p) (fromIntegral i)+    readBinary p = do+        i <- readI32 p+        tReadAll (getTransport p) (fromIntegral i)   -- | Write a type as a byte writeType :: (Protocol p, Transport t) => p t -> ThriftType -> IO ()-writeType p t = writeByte p (fromEnum t)+writeType p t = writeByte p (fromIntegral $ fromEnum t)  -- | Read a byte as though it were a ThriftType readType :: (Protocol p, Transport t) => p t -> IO ThriftType-readType p = toEnum `fmap` readByte p+readType p = do+    b <- readByte p+    return $ toEnum $ fromIntegral b -composeBytes :: (Bits b) => LBS.ByteString -> b-composeBytes = (foldl' fn 0) . (map (fromIntegral . fromEnum)) . LBS.unpack+composeBytes :: (Bits b) => LBSChar8.ByteString -> b+composeBytes = (foldl' fn 0) . (map (fromIntegral . fromEnum)) . LBSChar8.unpack     where fn acc b = (acc `shiftL` 8) .|. b  getByte :: Bits a => a -> Int -> a getByte i n = 255 .&. (i `shiftR` (8 * n)) -getBytes :: (Bits a, Integral a) => a -> Int -> LBS.ByteString-getBytes i 0 = LBS.empty-getBytes i n = (toEnum $ fromIntegral $ getByte i (n-1)) `LBS.cons` (getBytes i (n-1))+getBytes :: (Bits a, Integral a) => a -> Int -> LBSChar8.ByteString+getBytes _ 0 = LBSChar8.empty+getBytes i n = (toEnum $ fromIntegral $ getByte i (n-1)) `LBSChar8.cons` (getBytes i (n-1))  floatBits :: Double -> Word64 floatBits (D# d#) = W64# (unsafeCoerce# d#)
src/Thrift/Server.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE ScopedTypeVariables #-} -- -- Licensed to the Apache Software Foundation (ASF) under one -- or more contributor license agreements. See the NOTICE file@@ -31,7 +32,7 @@ import System.IO  import Thrift-import Thrift.Transport.Handle+import Thrift.Transport.Handle() import Thrift.Protocol.Binary  @@ -43,23 +44,23 @@                   -> (h -> (i t, o t) -> IO Bool)                   -> PortID                   -> IO a-runThreadedServer accepter hand proc port = do+runThreadedServer accepter hand proc_ port = do     socket <- listenOn port-    acceptLoop (accepter socket) (proc hand)+    acceptLoop (accepter socket) (proc_ hand)  -- | A basic threaded binary protocol socket server. runBasicServer :: h                -> (h -> (BinaryProtocol Handle, BinaryProtocol Handle) -> IO Bool)                -> PortNumber                -> IO a-runBasicServer hand proc port = runThreadedServer binaryAccept hand proc (PortNumber port)+runBasicServer hand proc_ port = runThreadedServer binaryAccept hand proc_ (PortNumber port)   where binaryAccept s = do             (h, _, _) <- accept s             return (BinaryProtocol h, BinaryProtocol h)  acceptLoop :: IO t -> (t -> IO Bool) -> IO a-acceptLoop accepter proc = forever $+acceptLoop accepter proc_ = forever $     do ps <- accepter-       forkIO $ handle (\(e :: SomeException) -> return ())-                  (loop $ proc ps)+       forkIO $ handle (\(_ :: SomeException) -> return ())+                  (loop $ proc_ ps)   where loop m = do { continue <- m; when continue (loop m) }
src/Thrift/Transport.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE DeriveDataTypeable #-} -- -- Licensed to the Apache Software Foundation (ASF) under one -- or more contributor license agreements. See the NOTICE file@@ -39,7 +40,7 @@     tFlush  :: a -> IO ()     tReadAll :: a -> Int -> IO LBS.ByteString -    tReadAll a 0 = return mempty+    tReadAll _ 0 = return mempty     tReadAll a len = do         result <- tRead a len         let rlen = fromIntegral $ LBS.length result
src/Thrift/Transport/Handle.hs view
@@ -1,3 +1,8 @@+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE KindSignatures #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE TypeSynonymInstances #-}+{-# OPTIONS_GHC -fno-warn-orphans #-} -- -- Licensed to the Apache Software Foundation (ASF) under one -- or more contributor license agreements. See the NOTICE file@@ -23,7 +28,7 @@     ) where  import Control.Exception ( throw )-import Control.Monad ( replicateM )+import Control.Monad ()  import Network @@ -55,6 +60,7 @@     hOpen = uncurry connectTo  +handleEOF :: forall a (m :: * -> *).(Monoid a, Monad m) => IOError -> m a handleEOF e = if isEOFError e     then return mempty     else throw $ TransportExn "TChannelTransport: Could not read" TE_UNKNOWN
src/Thrift/Transport/HttpClient.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE FlexibleInstances #-} -- -- Licensed to the Apache Software Foundation (ASF) under one -- or more contributor license agreements. See the NOTICE file@@ -26,7 +27,6 @@ import Thrift.Transport import Network.URI import Network.HTTP hiding (port, host)-import Network.TCP  import Control.Monad (liftM) import Data.Maybe (fromJust)@@ -47,26 +47,29 @@       readBuffer :: ReadBuffer     } +uriAuth :: URI -> URIAuth uriAuth = fromJust . uriAuthority++host :: URI -> String host = uriRegName . uriAuth  port :: URI -> Int-port uri =+port uri_ =     if portStr == mempty then         httpPort     else         read portStr     where-      portStr = dropWhile (== ':') $ uriPort $ uriAuth uri+      portStr = dropWhile (== ':') $ uriPort $ uriAuth uri_       httpPort = 80  -- | Use 'openHttpClient' to create an HttpClient connected to @uri@ openHttpClient :: URI -> IO HttpClient-openHttpClient uri = do-  stream <- openTCPConnection (host uri) (port uri)+openHttpClient uri_ = do+  stream <- openTCPConnection (host uri_) (port uri_)   wbuf <- newWriteBuffer   rbuf <- newReadBuffer-  return $ HttpClient stream uri wbuf rbuf+  return $ HttpClient stream uri_ wbuf rbuf  instance Transport HttpClient where @@ -89,8 +92,8 @@        res <- sendHTTP (hstream hclient) request       case res of-        Right res -> do-            fillBuf (readBuffer hclient) (rspBody res)+        Right response -> do+            fillBuf (readBuffer hclient) (rspBody response)         Left _ -> do             throw $ TransportExn "THttpConnection: HTTP failure from server" TE_UNKNOWN       return ()