packages feed

amazonka-core 0.2.0 → 0.2.1

raw patch · 3 files changed

+27/−19 lines, 3 filesdep ~natsPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: nats

API changes (from Hackage documentation)

- Network.AWS.Data: withNode :: String -> (Node -> Either String a) -> [Node] -> Either String a
- Network.AWS.Data: withContent :: String -> (Text -> Either String a) -> [Node] -> Either String a
+ Network.AWS.Data: withContent :: String -> [Node] -> Either String (Maybe Text)
- Network.AWS.Types: _Errors :: Prism' (ServiceError a_aBcG) [ServiceError a_aBcG]
+ Network.AWS.Types: _Errors :: Prism' (ServiceError a_aBc8) [ServiceError a_aBc8]
- Network.AWS.Types: _HttpError :: Prism' (ServiceError a_aBcG) HttpException
+ Network.AWS.Types: _HttpError :: Prism' (ServiceError a_aBc8) HttpException
- Network.AWS.Types: _SerializerError :: Prism' (ServiceError a_aBcG) (Abbrev, String)
+ Network.AWS.Types: _SerializerError :: Prism' (ServiceError a_aBc8) (Abbrev, String)
- Network.AWS.Types: _ServiceError :: Prism' (ServiceError a_aBcG) (Abbrev, Status, a_aBcG)
+ Network.AWS.Types: _ServiceError :: Prism' (ServiceError a_aBc8) (Abbrev, Status, a_aBc8)
- Network.AWS.Types: rqBody :: Lens (Request a_aBco) (Request a_aCmq) RqBody RqBody
+ Network.AWS.Types: rqBody :: Lens (Request a_aBbQ) (Request a_aClS) RqBody RqBody
- Network.AWS.Types: rqHeaders :: Lens (Request a_aBco) (Request a_aCmr) [Header] [Header]
+ Network.AWS.Types: rqHeaders :: Lens (Request a_aBbQ) (Request a_aClT) [Header] [Header]
- Network.AWS.Types: rqMethod :: Lens (Request a_aBco) (Request a_aCms) StdMethod StdMethod
+ Network.AWS.Types: rqMethod :: Lens (Request a_aBbQ) (Request a_aClU) StdMethod StdMethod
- Network.AWS.Types: rqPath :: Lens (Request a_aBco) (Request a_aCmt) ByteString ByteString
+ Network.AWS.Types: rqPath :: Lens (Request a_aBbQ) (Request a_aClV) ByteString ByteString
- Network.AWS.Types: rqQuery :: Lens (Request a_aBco) (Request a_aCmu) Query Query
+ Network.AWS.Types: rqQuery :: Lens (Request a_aBbQ) (Request a_aClW) Query Query

Files

amazonka-core.cabal view
@@ -1,5 +1,5 @@ name:                  amazonka-core-version:               0.2.0+version:               0.2.1 synopsis:              Core functionality and data types for Amazonka libraries. homepage:              https://github.com/brendanhay/amazonka license:               OtherLicense@@ -102,7 +102,7 @@         , xml-conduit          == 1.2.*      if !impl(ghc>=7.9)-        build-depends: nats >= 0.1.3 && < 1+        build-depends: nats >= 0.1.3  test-suite tests     type:              exitcode-stdio-1.0
src/Network/AWS/Data/Internal/XML.hs view
@@ -23,7 +23,6 @@     , findElement     , withContent     , withElement-    , withNode     , localName     , (.@)     , (.@?)@@ -74,7 +73,9 @@         }  parseXMLText :: FromText a => String -> [Node] -> Either String a-parseXMLText n = withContent n fromText+parseXMLText n = withContent n >=> maybe err fromText+  where+    err = Left $ "empty node list, when expecting single node " ++ n  toXMLText :: ToText a => a -> [Node] toXMLText x = [NodeContent (toText x)]@@ -111,23 +112,28 @@     fromMaybe (error $ "Failed to unflatten node-list for: " ++ show x)               (listToMaybe (toXML x)) -withContent :: String -> (Text -> Either String a) -> [Node] -> Either String a-withContent n f = withNode n (join . fmap f . g)+withContent :: String -> [Node] -> Either String (Maybe Text)+withContent n = exactly >=> \case+    Just  x -> Just <$> content x+    Nothing -> return Nothing   where-    g (NodeContent x)-        = Right x-    g (NodeElement e)-        = Left $ "unexpected element " ++ show (elementName e) ++ " when expecting node content: " ++ n-    g _ = Left $ "unexpected element, when expecting node content: " ++ n+    exactly :: [Node] -> Either String (Maybe Node)+    exactly = \case+        [x] -> Right (Just x)+        []  -> Right Nothing+        _   -> Left $+            "encountered node list, when expecting exactly one node: " ++ n -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+    content :: Node -> Either String Text+    content (NodeContent x)+        = Right x+    content (NodeElement e)+        = let k = show (elementName e)+           in Left $ "unexpected element " ++ k ++ ", when expecting node content: " ++ n+    content _ = Left $ "unrecognised element, when expecting node content: " ++ n  withElement :: Text -> ([Node] -> Either String a) -> [Node] -> Either String a-withElement n f = join . fmap f . findElement n+withElement n f = findElement n >=> f  findElement :: Text -> [Node] -> Either String [Node] findElement n ns = maybe err Right . listToMaybe $ mapMaybe (childNodes n) ns@@ -153,7 +159,9 @@     parseXML [] = pure Nothing     parseXML ns = Just <$> parseXML ns -instance FromXML Text    where parseXML = parseXMLText "Text"+instance FromXML Text where+    parseXML = withContent "Text" >=> fromText . fromMaybe mempty+ instance FromXML Int     where parseXML = parseXMLText "Int" instance FromXML Integer where parseXML = parseXMLText "Integer" instance FromXML Natural where parseXML = parseXMLText "Natural"
src/Network/AWS/Response.hs view
@@ -140,7 +140,7 @@                 x <- f (_svcAbbrev svc) hs bdy                 case x of                     Left  e -> return (Left e)-                    Right y -> return $! Right (s, y)+                    Right y -> return (Right (s, y))      svc = service :: Service (Sv a) {-# INLINE receive #-}