amazonka-core 0.1.3 → 0.1.4
raw patch · 9 files changed
+9/−66 lines, 9 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Network.AWS.Data: takeText :: Parser Text
+ Network.AWS.Data: takeLowerText :: Parser Text
- Network.AWS.Types: _Errors :: Prism' (ServiceError a_aCTO) [ServiceError a_aCTO]
+ Network.AWS.Types: _Errors :: Prism' (ServiceError a_aBfc) [ServiceError a_aBfc]
- Network.AWS.Types: _HttpError :: Prism' (ServiceError a_aCTO) HttpException
+ Network.AWS.Types: _HttpError :: Prism' (ServiceError a_aBfc) HttpException
- Network.AWS.Types: _SerializerError :: Prism' (ServiceError a_aCTO) (Abbrev, String)
+ Network.AWS.Types: _SerializerError :: Prism' (ServiceError a_aBfc) (Abbrev, String)
- Network.AWS.Types: _ServiceError :: Prism' (ServiceError a_aCTO) (Abbrev, Status, a_aCTO)
+ Network.AWS.Types: _ServiceError :: Prism' (ServiceError a_aBfc) (Abbrev, Status, a_aBfc)
- Network.AWS.Types: rqBody :: Lens (Request a_aCTw) (Request a_aE3y) RqBody RqBody
+ Network.AWS.Types: rqBody :: Lens (Request a_aBeU) (Request a_aCoW) RqBody RqBody
- Network.AWS.Types: rqHeaders :: Lens (Request a_aCTw) (Request a_aE3z) [Header] [Header]
+ Network.AWS.Types: rqHeaders :: Lens (Request a_aBeU) (Request a_aCoX) [Header] [Header]
- Network.AWS.Types: rqMethod :: Lens (Request a_aCTw) (Request a_aE3A) StdMethod StdMethod
+ Network.AWS.Types: rqMethod :: Lens (Request a_aBeU) (Request a_aCoY) StdMethod StdMethod
- Network.AWS.Types: rqPath :: Lens (Request a_aCTw) (Request a_aE3B) ByteString ByteString
+ Network.AWS.Types: rqPath :: Lens (Request a_aBeU) (Request a_aCoZ) ByteString ByteString
- Network.AWS.Types: rqQuery :: Lens (Request a_aCTw) (Request a_aE3C) Query Query
+ Network.AWS.Types: rqQuery :: Lens (Request a_aBeU) (Request a_aCp0) Query Query
Files
- amazonka-core.cabal +1/−1
- src/Network/AWS/Data/Internal/ByteString.hs +0/−5
- src/Network/AWS/Data/Internal/Header.hs +0/−11
- src/Network/AWS/Data/Internal/JSON.hs +0/−4
- src/Network/AWS/Data/Internal/Query.hs +0/−11
- src/Network/AWS/Data/Internal/Text.hs +4/−11
- src/Network/AWS/Data/Internal/XML.hs +0/−19
- src/Network/AWS/Error.hs +3/−3
- src/Network/AWS/Types.hs +1/−1
amazonka-core.cabal view
@@ -1,5 +1,5 @@ name: amazonka-core-version: 0.1.3+version: 0.1.4 synopsis: Core functionality and data types for Amazonka libraries. homepage: https://github.com/brendanhay/amazonka license: OtherLicense
src/Network/AWS/Data/Internal/ByteString.hs view
@@ -47,14 +47,12 @@ showBS :: ToByteString a => a -> String showBS = BS8.unpack . toBS-{-# INLINE showBS #-} class ToByteString a where toBS :: a -> ByteString default toBS :: ToText a => a -> ByteString toBS = Text.encodeUtf8 . toText- {-# INLINE toBS #-} instance ToByteString ByteString where toBS = id instance ToByteString Builder where toBS = toBS . Build.toLazyByteString@@ -73,14 +71,12 @@ buildBS :: ToBuilder a => a -> LazyByteString buildBS = Build.toLazyByteString . build-{-# INLINE buildBS #-} class ToBuilder a where build :: a -> Builder default build :: ToByteString a => a -> Builder build = build . toBS- {-# INLINE build #-} instance ToBuilder Builder where build = id instance ToBuilder ByteString where build = Build.byteString@@ -173,4 +169,3 @@ stripBS :: ByteString -> ByteString stripBS = BS8.dropWhile isSpace . fst . BS8.spanEnd isSpace-{-# INLINE stripBS #-}
src/Network/AWS/Data/Internal/Header.hs view
@@ -33,31 +33,25 @@ where note Nothing = Left (BS.unpack $ "Unable to find header: " <> CI.original k) note (Just x) = Right x-{-# INLINE (~:) #-} (~:?) :: FromText a => ResponseHeaders -> HeaderName -> Either String (Maybe a) hs ~:? k = maybe (Right Nothing) (fmap Just . fromText . Text.decodeUtf8) (k `lookup` hs)-{-# INLINE (~:?) #-} class ToHeaders a where toHeaders :: a -> [Header] toHeaders = const mempty- {-# INLINE toHeaders #-} (=:) :: ToHeader a => HeaderName -> a -> [Header] (=:) = toHeader-{-# INLINE toHeaderText #-} hdr :: HeaderName -> ByteString -> [Header] -> [Header] hdr k v hs = (k, v) : filter ((/= k) . fst) hs-{-# INLINE hdr #-} hdrs :: [Header] -> [Header] -> [Header] hdrs xs ys = Fold.foldr' (uncurry hdr) ys xs-{-# INLINE hdrs #-} toHeaderText :: ToText a => HeaderName -> a -> [Header] toHeaderText k = toHeader k . toText@@ -67,23 +61,18 @@ default toHeader :: ToText a => HeaderName -> a -> [Header] toHeader k = toHeader k . toText- {-# INLINE toHeader #-} instance ToHeader Text where toHeader k = toHeader k . Text.encodeUtf8- {-# INLINE toHeader #-} instance ToHeader ByteString where toHeader k = toHeader k . Just- {-# INLINE toHeader #-} instance ToByteString a => ToHeader (Maybe a) where toHeader k = maybe [] (\v -> [(k, toBS v)])- {-# INLINE toHeader #-} instance (ToByteString k, ToByteString v) => ToHeader (HashMap k v) where toHeader p = map (\(k, v) -> (p <> CI.mk (toBS k), toBS v)) . Map.toList- {-# INLINE toHeader #-} hHost :: HeaderName hHost = "Host"
src/Network/AWS/Data/Internal/JSON.hs view
@@ -40,22 +40,18 @@ parseJSONText :: FromText a => String -> Value -> Parser a parseJSONText n = withText n (either fail return . fromText)-{-# INLINE parseJSONText #-} toJSONText :: ToText a => a -> Value toJSONText = String . toText-{-# INLINE toJSONText #-} (.:>) :: FromJSON a => Object -> Text -> Either String a (.:>) o k = case Map.lookup k o of Nothing -> Left $ "key " ++ show k ++ " not present" Just v -> parseEither parseJSON v-{-# INLINE (.:>) #-} (.:?>) :: FromJSON a => Object -> Text -> Either String (Maybe a) (.:?>) o k = case Map.lookup k o of Nothing -> Right Nothing Just v -> parseEither parseJSON v-{-# INLINE (.:?>) #-}
src/Network/AWS/Data/Internal/Query.hs view
@@ -83,17 +83,14 @@ pair :: ToQuery a => ByteString -> a -> Query -> Query pair k v = mappend (Pair k (toQuery v))-{-# INLINE pair #-} (=?) :: ToQuery a => ByteString -> a -> Query (=?) k v = Pair k (toQuery v)-{-# INLINE (=?) #-} toQueryList :: (IsList a, ToQuery (Item a)) => ByteString -> a -> Query toQueryList n = mconcat . zipWith (\i v -> n =? (toBS i, v)) idx . toList where idx = [1..] :: [Int]-{-# INLINE toQueryList #-} renderQuery :: Query -> ByteString renderQuery = intercalate . sort . enc Nothing@@ -121,24 +118,19 @@ default toQuery :: ToText a => a -> Query toQuery = toQuery . toText- {-# INLINE toQuery #-} instance ToQuery Query where toQuery = id- {-# INLINE toQuery #-} instance (ToByteString k, ToQuery v) => ToQuery (k, v) where toQuery (k, v) = Pair (toBS k) (toQuery v)- {-# INLINE toQuery #-} instance ToQuery Char where toQuery = toQuery . BS.singleton- {-# INLINE toQuery #-} instance ToQuery ByteString where toQuery "" = Value Nothing toQuery bs = Value (Just bs)- {-# INLINE toQuery #-} instance ToQuery Text where toQuery = toQuery . Text.encodeUtf8 instance ToQuery Int where toQuery = toQuery . toBS@@ -149,15 +141,12 @@ instance ToQuery a => ToQuery (Maybe a) where toQuery (Just x) = toQuery x toQuery Nothing = mempty- {-# INLINE toQuery #-} instance ToQuery a => ToQuery [a] where toQuery = List . zipWith (\n v -> toBS n =? toQuery v) idx where idx = [1..] :: [Integer]- {-# INLINE toQuery #-} instance ToQuery Bool where toQuery True = toQuery ("true" :: ByteString) toQuery False = toQuery ("false" :: ByteString)- {-# INLINE toQuery #-}
src/Network/AWS/Data/Internal/Text.hs view
@@ -15,7 +15,7 @@ module Network.AWS.Data.Internal.Text ( FromText (..) , fromText- , AText.takeText+ , takeLowerText , matchCI , ToText (..)@@ -47,11 +47,12 @@ fromText :: FromText a => Text -> Either String a fromText = AText.parseOnly parser-{-# INLINE fromText #-} +takeLowerText :: Parser Text+takeLowerText = Text.toLower <$> AText.takeText+ matchCI :: Text -> a -> Parser a matchCI x y = AText.asciiCI x <* AText.endOfInput >> return y-{-# INLINE matchCI #-} class FromText a where parser :: Parser a@@ -66,30 +67,24 @@ instance FromText Bool where parser = matchCI "false" False <|> matchCI "true" True- {-# INLINE parser #-} showText :: ToText a => a -> String showText = Text.unpack . toText-{-# INLINE showText #-} class ToText a where toText :: a -> Text instance (ToText a, ToText b) => ToText (a, b) where toText (a, b) = "(" <> toText a <> ", " <> toText b <> ")"- {-# INLINE toText #-} instance ToText a => ToText [a] where toText xs = "[" <> Text.intercalate ", " (map toText xs) <> "]"- {-# INLINE toText #-} instance ToText a => ToText (CI a) where toText = toText . CI.original- {-# INLINE toText #-} instance ToText (Response a) where toText rs = Text.pack . show $ rs { responseBody = () }- {-# INLINE toText #-} instance ToText Text where toText = id instance ToText ByteString where toText = Text.decodeUtf8@@ -105,8 +100,6 @@ instance ToText Bool where toText True = "true" toText False = "false"- {-# INLINE toText #-} shortText :: Builder -> Text shortText = LText.toStrict . Build.toLazyTextWith 32-{-# INLINE shortText #-}
src/Network/AWS/Data/Internal/XML.hs view
@@ -75,42 +75,33 @@ parseXMLText :: FromText a => String -> [Node] -> Either String a parseXMLText n = withContent n fromText-{-# INLINE parseXMLText #-} toXMLText :: ToText a => a -> [Node] toXMLText x = [NodeContent (toText x)]-{-# INLINE toXMLText #-} (.@) :: FromXML a => [Node] -> Text -> Either String a ns .@ n = findElement n ns >>= parseXML-{-# INLINE (.@) #-} (.@?) :: FromXML a => [Node] -> Text -> Either String (Maybe a) ns .@? n = case findElement n ns of Left _ -> Right Nothing Right xs -> parseXML xs-{-# INLINE (.@?) #-} (.!@) :: Either String (Maybe a) -> a -> Either String a f .!@ x = fromMaybe x <$> f-{-# INLINE (.!@) #-} namespaced :: Text -> Text -> [Node] -> Element namespaced g l = element (Name l (Just g) Nothing)-{-# INLINE namespaced #-} element :: Name -> [Node] -> Element element n = Element n mempty-{-# INLINE element #-} nodes :: Name -> [Node] -> [Node] nodes n ns = [NodeElement (element n ns)]-{-# INLINE nodes #-} (=@) :: ToXML a => Name -> a -> Node n =@ x = NodeElement (element n (toXML x))-{-# INLINE (=@) #-} -- | /Caution:/ This is for use with types which are 'flattened' in -- AWS service model terminology. It is applied by the generator/templating@@ -119,7 +110,6 @@ unsafeToXML x = fromMaybe (error $ "Failed to unflatten node-list for: " ++ show x) (listToMaybe (toXML x))-{-# INLINE unsafeToXML #-} withContent :: String -> (Text -> Either String a) -> [Node] -> Either String a withContent n f = withNode n (join . fmap f . g)@@ -129,18 +119,15 @@ g (NodeElement e) = Left $ "unexpected element " ++ show (elementName e) ++ " when expecting node content: " ++ n g _ = Left $ "unexpected element, when expecting node content: " ++ n-{-# INLINE withContent #-} withNode :: String -> (Node -> Either String a) -> [Node] -> Either String a withNode n f = \case [x] -> f x [] -> Left $ "empty node list, when expecting a single node: " ++ n _ -> Left $ "encountered node list, when expecting a single node: " ++ n-{-# INLINE withNode #-} withElement :: Text -> ([Node] -> Either String a) -> [Node] -> Either String a withElement n f = join . fmap f . findElement n-{-# INLINE withElement #-} findElement :: Text -> [Node] -> Either String [Node] findElement n ns = maybe err Right . listToMaybe $ mapMaybe (childNodes n) ns@@ -149,18 +136,15 @@ ++ show n ++ " in nodes " ++ show (mapMaybe localName ns)-{-# INLINE findElement #-} childNodes :: Text -> Node -> Maybe [Node] childNodes n (NodeElement e) | nameLocalName (elementName e) == n = Just (elementNodes e) childNodes _ _ = Nothing-{-# INLINE childNodes #-} localName :: Node -> Maybe Text localName (NodeElement e) = Just (nameLocalName (elementName e)) localName _ = Nothing-{-# INLINE localName #-} class FromXML a where parseXML :: [Node] -> Either String a@@ -168,7 +152,6 @@ instance FromXML a => FromXML (Maybe a) where parseXML [] = pure Nothing parseXML ns = Just <$> parseXML ns- {-# INLINE parseXML #-} instance FromXML Text where parseXML = parseXMLText "Text" instance FromXML Int where parseXML = parseXMLText "Int"@@ -185,12 +168,10 @@ default toXML :: ToXMLRoot a => a -> [Node] toXML = (:[]) . NodeElement . toXMLRoot- {-# INLINE toXML #-} instance ToXML a => ToXML (Maybe a) where toXML (Just x) = toXML x toXML Nothing = []- {-# INLINE toXML #-} instance ToXML Text where toXML = toXMLText instance ToXML Int where toXML = toXMLText
src/Network/AWS/Error.hs view
@@ -85,9 +85,9 @@ deriving (Eq, Ord, Enum, Show, Generic) instance FromText ErrorType where- parser = takeText >>= \case- "Receiver" -> pure Receiver- "Sender" -> pure Sender+ parser = takeLowerText >>= \case+ "receiver" -> pure Receiver+ "sender" -> pure Sender e -> fail $ "Failure parsing ErrorType from " ++ show e instance FromXML ErrorType where
src/Network/AWS/Types.hs view
@@ -431,7 +431,7 @@ def = NorthVirginia instance FromText Region where- parser = takeText >>= \case+ parser = takeLowerText >>= \case "eu-west-1" -> pure Ireland "eu-central-1" -> pure Frankfurt "ap-northeast-1" -> pure Tokyo