on master help sign in
Remove dependency on bytestring-conversion
commit9b5a564f3c151c699a6ee16c7e0dfc9564fcc1f8 authorAlex Mason <Alex.Mason@data61.csiro.au> dateFri 2 Sep 2016, 23:14 (10 years ago) parenta1b2301
2 files changed+6−8
servant/servant.cabal−1 servant/src/Servant/API/ResponseHeaders.hs+6−7
servant/servant.cabal−1
@@ -54,7 +54,6 @@ library
5454 , aeson >= 0.7 && < 1.1
5555 , attoparsec >= 0.12 && < 0.14
5656 , bytestring >= 0.10 && < 0.11
57− , bytestring-conversion >= 0.3 && < 0.4
5857 , case-insensitive >= 1.2 && < 1.3
5958 , http-api-data >= 0.1 && < 0.3
6059 , http-media >= 0.4 && < 0.7
servant/src/Servant/API/ResponseHeaders.hs+6−7
@@ -31,9 +31,8 @@ module Servant.API.ResponseHeaders
3131 ) where
3232
3333import Data.ByteString.Char8 as BS (pack, unlines, init)
34−import Data.ByteString.Conversion (--ToByteString, toByteString',
35− FromByteString, fromByteString)
36−import Web.HttpApiData (ToHttpApiData,toHeader)
34+import Web.HttpApiData (ToHttpApiData,toHeader
35+ ,FromHttpApiData,parseHeader)
3736import qualified Data.CaseInsensitive as CI
3837import Data.Proxy
3938import GHC.TypeLits (KnownSymbol, symbolVal)
@@ -69,17 +68,17 @@ class BuildHeadersTo hs where
6968instance OVERLAPPING_ BuildHeadersTo '[] where
7069 buildHeadersTo _ = HNil
7170
72−instance OVERLAPPABLE_ ( FromByteString v, BuildHeadersTo xs, KnownSymbol h )
71+instance OVERLAPPABLE_ ( FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h )
7372 => BuildHeadersTo ((Header h v) ': xs) where
7473 buildHeadersTo headers =
7574 let wantedHeader = CI.mk . pack $ symbolVal (Proxy :: Proxy h)
7675 matching = snd <$> filter (\(h, _) -> h == wantedHeader) headers
7776 in case matching of
7877 [] -> MissingHeader `HCons` buildHeadersTo headers
79− xs -> case fromByteString (BS.init $ BS.unlines xs) of
80− Nothing -> UndecodableHeader (BS.init $ BS.unlines xs)
78+ xs -> case parseHeader (BS.init $ BS.unlines xs) of
79+ Left _err -> UndecodableHeader (BS.init $ BS.unlines xs)
8180 `HCons` buildHeadersTo headers
82− Just h -> Header h `HCons` buildHeadersTo headers
81+ Right h -> Header h `HCons` buildHeadersTo headers
8382
8483-- * Getting
8584