git.iko.soy/typeable/servant
on master help sign in
Remove dependency on bytestring-conversion
9b5a564Alex Mason
servant/servant.cabal−1
@@ -54,7 +54,6 @@ library
54 , aeson >= 0.7 && < 1.1
54 , aeson >= 0.7 && < 1.1
55 , attoparsec >= 0.12 && < 0.14
55 , attoparsec >= 0.12 && < 0.14
56 , bytestring >= 0.10 && < 0.11
56 , bytestring >= 0.10 && < 0.11
57− , bytestring-conversion >= 0.3 && < 0.4
58 , case-insensitive >= 1.2 && < 1.3
57 , case-insensitive >= 1.2 && < 1.3
59 , http-api-data >= 0.1 && < 0.3
58 , http-api-data >= 0.1 && < 0.3
60 , http-media >= 0.4 && < 0.7
59 , http-media >= 0.4 && < 0.7
servant/src/Servant/API/ResponseHeaders.hs+6−7
@@ -31,9 +31,8 @@ module Servant.API.ResponseHeaders
31 ) where
31 ) where
32
32
33import Data.ByteString.Char8 as BS (pack, unlines, init)
33import 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)
37import qualified Data.CaseInsensitive as CI
36import qualified Data.CaseInsensitive as CI
38import Data.Proxy
37import Data.Proxy
39import GHC.TypeLits (KnownSymbol, symbolVal)
38import GHC.TypeLits (KnownSymbol, symbolVal)
@@ -69,17 +68,17 @@ class BuildHeadersTo hs where
69instance OVERLAPPING_ BuildHeadersTo '[] where
68instance OVERLAPPING_ BuildHeadersTo '[] where
70 buildHeadersTo _ = HNil
69 buildHeadersTo _ = HNil
71
70
72−instance OVERLAPPABLE_ ( FromByteString v, BuildHeadersTo xs, KnownSymbol h )
71+instance OVERLAPPABLE_ ( FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h )
73 => BuildHeadersTo ((Header h v) ': xs) where
72 => BuildHeadersTo ((Header h v) ': xs) where
74 buildHeadersTo headers =
73 buildHeadersTo headers =
75 let wantedHeader = CI.mk . pack $ symbolVal (Proxy :: Proxy h)
74 let wantedHeader = CI.mk . pack $ symbolVal (Proxy :: Proxy h)
76 matching = snd <$> filter (\(h, _) -> h == wantedHeader) headers
75 matching = snd <$> filter (\(h, _) -> h == wantedHeader) headers
77 in case matching of
76 in case matching of
78 [] -> MissingHeader `HCons` buildHeadersTo headers
77 [] -> MissingHeader `HCons` buildHeadersTo headers
79− xs -> case fromByteString (BS.init $ BS.unlines xs) of
78+ xs -> case parseHeader (BS.init $ BS.unlines xs) of
80− Nothing -> UndecodableHeader (BS.init $ BS.unlines xs)
79+ Left _err -> UndecodableHeader (BS.init $ BS.unlines xs)
81 `HCons` buildHeadersTo headers
80 `HCons` buildHeadersTo headers
82− Just h -> Header h `HCons` buildHeadersTo headers
81+ Right h -> Header h `HCons` buildHeadersTo headers
83
82
84-- * Getting
83-- * Getting
85
84