THRIFT-1598 Update Haskell generated code to use Text, Hash{Map,Set}, Vector
Patch: Itai Zukerman
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1340014 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/hs/src/Thrift/Protocol/Binary.hs b/lib/hs/src/Thrift/Protocol/Binary.hs
index c55ea5a..1bc9add 100644
--- a/lib/hs/src/Thrift/Protocol/Binary.hs
+++ b/lib/hs/src/Thrift/Protocol/Binary.hs
@@ -1,5 +1,6 @@
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE MagicHash #-}
+{-# LANGUAGE OverloadedStrings #-}
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
@@ -30,6 +31,7 @@
import qualified Data.Binary
import Data.Bits
import Data.Int
+import Data.Text.Lazy.Encoding ( decodeUtf8, encodeUtf8 )
import GHC.Exts
import GHC.Word
@@ -38,7 +40,6 @@
import Thrift.Transport
import qualified Data.ByteString.Lazy as LBS
-import qualified Data.ByteString.Lazy.Char8 as LBSChar8
version_mask :: Int32
version_mask = 0xffff0000
@@ -76,7 +77,9 @@
writeI32 p b = tWrite (getTransport p) $ Data.Binary.encode b
writeI64 p b = tWrite (getTransport p) $ Data.Binary.encode b
writeDouble p d = writeI64 p (fromIntegral $ floatBits d)
- writeString p s = writeI32 p (fromIntegral $ length s) >> tWrite (getTransport p) (LBSChar8.pack s)
+ writeString p s = writeI32 p (fromIntegral $ LBS.length s') >> tWrite (getTransport p) s'
+ where
+ s' = encodeUtf8 s
writeBinary p s = writeI32 p (fromIntegral $ LBS.length s) >> tWrite (getTransport p) s
readMessageBegin p = do
@@ -136,7 +139,7 @@
readString p = do
i <- readI32 p
- LBSChar8.unpack `liftM` tReadAll (getTransport p) (fromIntegral i)
+ decodeUtf8 `liftM` tReadAll (getTransport p) (fromIntegral i)
readBinary p = do
i <- readI32 p