packages feed

amazonka-mtl 0.1.0.0 → 0.1.1.0

raw patch · 10 files changed

+123/−13 lines, 10 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Control.Monad.AWS: localEnv :: MonadAWS m => (Env -> Env) -> m a -> m a
+ Control.Monad.AWS: withAuth :: MonadAWS m => (AuthEnv -> m a) -> m a
+ Control.Monad.AWS.Class: localEnv :: MonadAWS m => (Env -> Env) -> m a -> m a
+ Control.Monad.AWS.Class: withAuth :: MonadAWS m => (AuthEnv -> m a) -> m a

Files

CHANGELOG.md view
@@ -1,4 +1,8 @@-## [_Unreleased_](https://github.com/freckle/amazonka-mtl/compare/v0.1.0.0...main)+## [_Unreleased_](https://github.com/freckle/amazonka-mtl/compare/v0.1.1.0...main)++## [v0.1.1.0](https://github.com/freckle/amazonka-mtl/compare/v0.1.0.0...v0.1.1.0)++- Add `withAuth` and `localEnv`  ## [v0.1.0.0](https://github.com/freckle/amazonka-mtl/tree/v0.1.0.0) 
amazonka-mtl.cabal view
@@ -1,6 +1,6 @@ cabal-version:      1.18 name:               amazonka-mtl-version:            0.1.0.0+version:            0.1.1.0 license:            MIT license-file:       LICENSE maintainer:         Freckle Education@@ -86,9 +86,10 @@         TypeApplications TypeFamilies      ghc-options:-        -Weverything -Wno-missing-exported-signatures+        -Weverything -Wno-all-missed-specialisations+        -Wno-missed-specialisations -Wno-missing-exported-signatures         -Wno-missing-import-lists -Wno-missing-local-signatures-        -Wno-monomorphism-restriction -Wno-unsafe -Wno-safe+        -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe      build-depends:         amazonka,@@ -122,9 +123,10 @@         TypeApplications TypeFamilies      ghc-options:-        -Weverything -Wno-missing-exported-signatures+        -Weverything -Wno-all-missed-specialisations+        -Wno-missed-specialisations -Wno-missing-exported-signatures         -Wno-missing-import-lists -Wno-missing-local-signatures-        -Wno-monomorphism-restriction -Wno-unsafe -Wno-safe -pgmL+        -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe -pgmL         markdown-unlit      build-depends:@@ -164,9 +166,10 @@         TypeApplications TypeFamilies      ghc-options:-        -Weverything -Wno-missing-exported-signatures+        -Weverything -Wno-all-missed-specialisations+        -Wno-missed-specialisations -Wno-missing-exported-signatures         -Wno-missing-import-lists -Wno-missing-local-signatures-        -Wno-monomorphism-restriction -Wno-unsafe -Wno-safe -threaded+        -Wno-monomorphism-restriction -Wno-safe -Wno-unsafe -threaded         -rtsopts -with-rtsopts=-N      build-depends:
library/Control/Monad/AWS.hs view
@@ -26,6 +26,8 @@ import Data.Typeable (Typeable)  -- | Version of 'Amazonka.send' built on our 'sendEither'+--+-- @since 0.1.0.0 send   :: ( MonadIO m      , MonadAWS m@@ -38,6 +40,8 @@ send = sendEither >=> hoistEither  -- | Version of 'Amazonka.paginateEither' built on our 'sendEither'+--+-- @since 0.1.0.0 paginateEither   :: (MonadAWS m, AWSPager a, Typeable a, Typeable (AWSResponse a))   => a@@ -52,6 +56,8 @@         maybe (pure (Right ())) go (Pager.page rq rs)  -- | Version of 'Amazonka.paginate' built on our 'paginateEither'+--+-- @since 0.1.0.0 paginate   :: ( MonadIO m      , MonadAWS m@@ -65,6 +71,8 @@   paginateEither >=> hoistEither  -- | Version of 'Amazonka.await' built on our 'awaitEither'+--+-- @since 0.1.0.0 await   :: (MonadIO m, MonadAWS m, AWSRequest a, Typeable a)   => Waiter.Wait a
library/Control/Monad/AWS/Class.hs view
@@ -5,7 +5,9 @@  import Amazonka.Prelude +import Amazonka (AuthEnv) import Amazonka.Core (AWSRequest, AWSResponse, Error)+import Amazonka.Env (Env) import qualified Amazonka.Waiter as Waiter import Data.Typeable (Typeable) @@ -21,13 +23,32 @@ -- - "Control.Monad.AWS.ViaReader" -- - "Control.Monad.AWS.ViaMock" class Monad m => MonadAWS m where+  -- | The type-class version of 'Amazonka.sendEither'.+  --+  -- @since 0.1.0.0   sendEither     :: (AWSRequest a, Typeable a, Typeable (AWSResponse a))     => a     -> m (Either Error (AWSResponse a)) +  -- | The type-class version of 'Amazonka.awaitEither'.+  --+  -- @since 0.1.0.0   awaitEither     :: (AWSRequest a, Typeable a)     => Waiter.Wait a     -> a     -> m (Either Error Waiter.Accept)++  -- | Supply the current credentials to the given action.+  --+  -- @since 0.1.1.0+  withAuth :: (AuthEnv -> m a) -> m a++  -- | Run the given action with a modified 'Env'+  --+  -- For instances that supply 'Env' via Reader, this should behave like+  -- 'local'.+  --+  -- @since 0.1.1.0+  localEnv :: (Env -> Env) -> m a -> m a
library/Control/Monad/AWS/EnvT.hs view
@@ -33,6 +33,9 @@ import Control.Monad.Reader import Control.Monad.Trans.Resource +-- |+--+-- @since 0.1.0.0 newtype EnvT m a = EnvT   { unEnvT :: ReaderT Env (ResourceT m) a   }@@ -47,5 +50,8 @@     )   deriving (MonadAWS) via (ReaderAWS (EnvT m)) +-- |+--+-- @since 0.1.0.0 runEnvT :: MonadUnliftIO m => EnvT m a -> Env -> m a runEnvT f = runResourceT . runReaderT (unEnvT f)
library/Control/Monad/AWS/Matchers.hs view
@@ -25,14 +25,18 @@  -- | Define a response to provide for any matched requests data Matcher where-  -- Matches calls to 'send' where the given predicate holds+  -- | Matches calls to 'send' where the given predicate holds+  --+  -- @since 0.1.0.0   SendMatcher     :: forall a      . (AWSRequest a, Typeable a, Typeable (AWSResponse a))     => (a -> Bool)     -> Either Error (AWSResponse a)     -> Matcher-  -- Matches calls to 'await' where the given predicate holds+  -- | Matches calls to 'await' where the given predicate holds+  --+  -- @since 0.1.0.0   AwaitMatcher     :: forall a      . (AWSRequest a, Typeable a)@@ -40,25 +44,41 @@     -> Either Error Waiter.Accept     -> Matcher +-- |+--+-- @since 0.1.0.0 newtype Matchers = Matchers   { unMatchers :: [Matcher]   }   deriving newtype (Semigroup, Monoid) +-- |+--+-- @since 0.1.0.0 class HasMatchers env where   matchersL :: Lens' env Matchers +-- |+--+-- @since 0.1.0.0 instance HasMatchers Matchers where   matchersL = id  -- | Add a 'Matcher' for the duration of the block+--+-- @since 0.1.0.0 withMatcher :: (MonadReader env m, HasMatchers env) => Matcher -> m a -> m a withMatcher = withMatchers . pure  -- | Add multiple 'Matcher's for the duration of the block+--+-- @since 0.1.0.0 withMatchers :: (MonadReader env m, HasMatchers env) => [Matcher] -> m a -> m a withMatchers ms = local $ matchersL <>~ Matchers ms +-- |+--+-- @since 0.1.0.0 matchSend   :: forall m env a    . ( MonadIO m@@ -77,6 +97,9 @@       cast resp     AwaitMatcher {} -> Nothing +-- |+--+-- @since 0.1.0.0 matchAwait   :: forall m env a    . (MonadIO m, MonadReader env m, HasMatchers env, Typeable a)@@ -99,6 +122,9 @@   matchers <- view matchersL   pure $ listToMaybe $ mapMaybe f $ unMatchers matchers +-- |+--+-- @since 0.1.0.0 newtype UnmatchedRequestError = UnmatchedRequestError   { unmatchedRequestType :: String   }@@ -108,6 +134,8 @@ -- representation (derived is best), and displayException is where you make it -- human-readable. Sadly, too many tools (*cough* hspec) use show instead of -- displayException, and we want it to look nice there. Sigh.+--+-- https://github.com/hspec/hspec/issues/289 instance Show UnmatchedRequestError where   show ex =     "Unexpected AWS request made within MockT: "
library/Control/Monad/AWS/MockT.hs view
@@ -45,6 +45,9 @@ import Control.Monad.IO.Unlift import Control.Monad.Reader +-- |+--+-- @since 0.1.0.0 newtype MockT m a = MockT   { unMockT :: ReaderT Matchers m a   }@@ -58,5 +61,8 @@     )   deriving (MonadAWS) via (MockAWS (MockT m)) +-- |+--+-- @since 0.1.0.0 runMockT :: MockT m a -> m a runMockT f = runReaderT (unMockT f) mempty
library/Control/Monad/AWS/ViaMock.hs view
@@ -57,11 +57,15 @@  import Prelude +import Amazonka (AuthEnv (..)) import Control.Monad.AWS.Class import Control.Monad.AWS.Matchers import Control.Monad.IO.Class (MonadIO) import Control.Monad.Reader (MonadReader (..)) +-- |+--+-- @since 0.1.0.0 newtype MockAWS m a = MockAWS   { unMockAWS :: m a   }@@ -76,3 +80,14 @@ instance (MonadIO m, MonadReader env m, HasMatchers env) => MonadAWS (MockAWS m) where   sendEither = matchSend   awaitEither = matchAwait+  withAuth = ($ fakeAuthEnv)+  localEnv _ = id++fakeAuthEnv :: AuthEnv+fakeAuthEnv =+  AuthEnv+    { accessKeyId = "mock-aws-access-key-id"+    , secretAccessKey = "mock-aws-secret-key"+    , sessionToken = Just "mock-aws-sessin-token"+    , expiration = Nothing+    }
library/Control/Monad/AWS/ViaReader.hs view
@@ -69,19 +69,30 @@  import Prelude +import qualified Amazonka.Auth as Amazonka import Amazonka.Env import qualified Amazonka.Send as Amazonka-import Control.Lens (Lens', view)+import Control.Lens (Lens', to, view, (%~)) import Control.Monad.AWS.Class import Control.Monad.Reader import Control.Monad.Trans.Resource (MonadResource)+import Data.Functor.Identity (runIdentity) +-- |+--+-- @since 0.1.0.0 class HasEnv env where   envL :: Lens' env Env +-- |+--+-- @since 0.1.0.0 instance HasEnv Env where   envL = id +-- |+--+-- @since 0.1.0.0 newtype ReaderAWS m a = ReaderAWS   { unReaderAWS :: m a   }@@ -102,3 +113,9 @@   awaitEither w a = do     env <- view envL     Amazonka.awaitEither env w a++  withAuth f = do+    auth <- view $ envL . env_auth . to runIdentity+    Amazonka.withAuth auth f++  localEnv f = local $ envL %~ f
package.yaml view
@@ -1,5 +1,5 @@ name: amazonka-mtl-version: 0.1.0.0+version: 0.1.1.0 maintainer: Freckle Education category: Utils github: freckle/amazonka-mtl@@ -58,12 +58,14 @@  ghc-options:   - -Weverything+  - -Wno-all-missed-specialisations+  - -Wno-missed-specialisations   - -Wno-missing-exported-signatures # re-enables missing-signatures   - -Wno-missing-import-lists   - -Wno-missing-local-signatures   - -Wno-monomorphism-restriction-  - -Wno-unsafe   - -Wno-safe+  - -Wno-unsafe  when:   - condition: "impl(ghc >= 9.2)"