git.iko.soy/typeable/http-api-data
on master help sign in
Remove dependency on string-conversions package.
acc2cd4(cdep)illabout
http-api-data.cabal+1−1
@@ -30,7 +30,7 @@ library
30 , time
30 , time
31 , time-locale-compat >=0.1.1.0 && <0.2
31 , time-locale-compat >=0.1.1.0 && <0.2
32 , network-uri >= 2.6 && < 2.7
32 , network-uri >= 2.6 && < 2.7
33− , string-conversions
33+ , utf8-string >= 1
34 if flag(use-text-show)
34 if flag(use-text-show)
35 cpp-options: -DUSE_TEXT_SHOW
35 cpp-options: -DUSE_TEXT_SHOW
36 build-depends: text-show >= 2
36 build-depends: text-show >= 2
src/Web/HttpApiData/Internal/FormUrlEncoded.hs+14−12
@@ -16,17 +16,19 @@ module Web.HttpApiData.Internal.FormUrlEncoded where
16import Control.Applicative
16import Control.Applicative
17#endif
17#endif
18
18
19−import Control.Arrow (first, left, second)
19+import Control.Arrow (first, left, second)
20import Control.Monad.State
20import Control.Monad.State
21−import qualified Data.ByteString.Lazy as BSL
21+import qualified Data.ByteString.Lazy as BSL
22−import qualified Data.Map as M
22+import qualified Data.ByteString.Lazy.UTF8 as BSLUTF8
23+import qualified Data.Map as M
23import Data.Monoid
24import Data.Monoid
24−import Data.String.Conversions (cs)
25−import qualified Data.Text as T
25+import qualified Data.Text as T
26+import Data.Text.Encoding (decodeUtf8With)
27+import Data.Text.Encoding.Error (lenientDecode)
26−import GHC.Exts (IsList (..))
28+import GHC.Exts (IsList (..))
27import GHC.Generics
29import GHC.Generics
28−import Network.URI (escapeURIString, isUnreserved,
30+import Network.URI (escapeURIString, isUnreserved,
29− unEscapeString)
31+ unEscapeString)
30
32
31import Web.HttpApiData.Internal.HttpApiData
33import Web.HttpApiData.Internal.HttpApiData
32
34
@@ -137,7 +139,7 @@ instance (GFromForm f) => GFromForm (M1 C x f) where
137encodeForm :: Form -> BSL.ByteString
139encodeForm :: Form -> BSL.ByteString
138encodeForm xs =
140encodeForm xs =
139 let escape :: T.Text -> BSL.ByteString
141 let escape :: T.Text -> BSL.ByteString
140− escape = cs . escapeURIString isUnreserved . cs
142+ escape = BSLUTF8.fromString . escapeURIString isUnreserved . T.unpack
141 encodePair :: (T.Text, T.Text) -> BSL.ByteString
143 encodePair :: (T.Text, T.Text) -> BSL.ByteString
142 encodePair (k, "") = escape k
144 encodePair (k, "") = escape k
143 encodePair (k, v) = escape k <> "=" <> escape v
145 encodePair (k, v) = escape k <> "=" <> escape v
@@ -147,7 +149,7 @@ decodeForm :: BSL.ByteString -> Either String Form
147decodeForm "" = return mempty
149decodeForm "" = return mempty
148decodeForm q = do
150decodeForm q = do
149 let xs :: [T.Text]
151 let xs :: [T.Text]
150− xs = T.splitOn "&" . cs $ q
152+ xs = T.splitOn "&" . decodeUtf8With lenientDecode . mconcat . BSL.toChunks $ q
151 parsePair :: T.Text -> Either String (T.Text, T.Text)
153 parsePair :: T.Text -> Either String (T.Text, T.Text)
152 parsePair p =
154 parsePair p =
153 case T.splitOn "=" p of
155 case T.splitOn "=" p of
@@ -155,9 +157,9 @@ decodeForm q = do
155 , unescape v
157 , unescape v
156 )
158 )
157 [k] -> return ( unescape k, "" )
159 [k] -> return ( unescape k, "" )
158− _ -> Left $ "not a valid pair: " <> cs p
160+ _ -> Left $ "not a valid pair: " <> T.unpack p
159 unescape :: T.Text -> T.Text
161 unescape :: T.Text -> T.Text
160− unescape = cs . unEscapeString . cs . T.intercalate "%20" . T.splitOn "+"
162+ unescape = T.pack . unEscapeString . T.unpack . T.intercalate "%20" . T.splitOn "+"
161 toForm <$> mapM parsePair xs
163 toForm <$> mapM parsePair xs
162
164
163data Proxy3 a b c = Proxy3
165data Proxy3 a b c = Proxy3