Skip to content

Commit 1f48062

Browse files
authored
Merge pull request #1015 from endgame/remove-hook-typeable
amazonka: Remove redundant `Typeable` constraints from Hooks
2 parents fbc91ee + 5c2c639 commit 1f48062

File tree

3 files changed

+14
-19
lines changed

3 files changed

+14
-19
lines changed

lib/amazonka/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
```
2121

2222
- `amazonka`: Add `(Typeable req, Typeable (AWSResponse req))` to the superclasses of `class AWSRequest`.
23-
`Typeable` is required for any nontrivial use of `AWSRequest` because Amazonka routes requests through the hooks system in `Amazonka.Env.Hooks`, so this reduces a little visual clutter. (Thanks @dalpd) [\#993](https://github.com/brendanhay/amazonka/pull/993),[\#994](https://github.com/brendanhay/amazonka/pull/994)
23+
`Typeable` is required for any nontrivial use of `AWSRequest` because Amazonka routes requests through the hooks system in `Amazonka.Env.Hooks`, so this reduces a little visual clutter. (Thanks @dalpd) [\#993](https://github.com/brendanhay/amazonka/pull/993),[\#994](https://github.com/brendanhay/amazonka/pull/994),[\#1015](https://github.com/brendanhay/amazonka/pull/1015)
2424
- New package `amazonka-dynamodb-attributevalue`: `amazonka-dynamodb`and `amazonka-dynamodb-streams` now share a common `AttributeValue` type, removing the need to manually convert between them. Each SDK re-exports it, so no code changes should be necessary, but manual conversion between the "regular" and "streams" `AttributeValue` can be removed. (thanks @dalpd)
2525
[\#992](https://github.com/brendanhay/amazonka/pull/992)
2626
- `amazonka`: Add support for `AWS_SHARED_CREDENTIALS_FILE` and `AWS_CONFIG_FILE` environment variables to override the

lib/amazonka/src/Amazonka/Env/Hooks.hs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,22 @@ data Hooks = Hooks
235235
-- is configured. This is always the first hook that runs, and
236236
-- argument is usually a request record type like @amazonka-s3@'s
237237
-- @GetObjectRequest@.
238-
request :: forall a. (AWSRequest a, Typeable a) => Hook a,
238+
request :: forall a. (AWSRequest a) => Hook a,
239239
-- | Called after the request has been configured into an abstract
240240
-- HTTP request, but before it is converted to a signed
241241
-- @Network.HTTP.Client.'Network.HTTP.Client.Request'@.
242242
--
243243
-- If you want to add additional headers (e.g., a
244244
-- [Trace ID for AWS X-Ray](https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader)),
245245
-- do it with this hook.
246-
configuredRequest :: forall a. (AWSRequest a, Typeable a) => Hook (Request a),
246+
configuredRequest :: forall a. (AWSRequest a) => Hook (Request a),
247247
-- | Called at the start of waiter processing, just after the
248248
-- request is configured.
249-
wait :: forall a. (AWSRequest a, Typeable a) => Hook (Wait a),
249+
wait :: forall a. (AWSRequest a) => Hook (Wait a),
250250
-- | Called just after a request is signed, containing signature
251251
-- metadata and a
252252
-- @Network.HTTP.Client.'Network.HTTP.Client.Request'@.
253-
signedRequest :: forall a. (AWSRequest a, Typeable a) => Hook_ (Signed a),
253+
signedRequest :: forall a. (AWSRequest a) => Hook_ (Signed a),
254254
-- | Called on a
255255
-- @Network.HTTP.Client.'Network.HTTP.Client.Request'@, just
256256
-- before it is sent. While you can retrieve a 'ClientRequest'
@@ -266,7 +266,7 @@ data Hooks = Hooks
266266
-- with @()@ to prevent its accidental consumption by hooks.
267267
clientResponse ::
268268
forall a.
269-
(AWSRequest a, Typeable a) =>
269+
(AWSRequest a) =>
270270
Hook_ (Request a, ClientResponse ()),
271271
-- | Called on the raw response body, after it has been sunk from
272272
-- the @Network.HTTP.Client.'Network.HTTP.Client.Response'@.
@@ -278,20 +278,20 @@ data Hooks = Hooks
278278
-- like @Amazonka.S3.Types.defaultService@.
279279
requestRetry ::
280280
forall a.
281-
(AWSRequest a, Typeable a) =>
281+
(AWSRequest a) =>
282282
Hook_ (Request a, Text, Retry.RetryStatus),
283283
-- | Called when Amazonka decides to retry a request while
284284
-- resolving an 'Amazonka.await' operation.
285285
awaitRetry ::
286286
forall a.
287-
(AWSRequest a, Typeable a) =>
287+
(AWSRequest a) =>
288288
Hook_ (Request a, Wait a, Accept, Retry.RetryStatus),
289289
-- | Called when a response from AWS is successfully
290290
-- deserialised. Because the 'AWSResponse' type family is not
291291
-- injective, we include the original request.
292292
response ::
293293
forall a.
294-
(AWSRequest a, Typeable a) =>
294+
(AWSRequest a) =>
295295
Hook_ (Request a, ClientResponse (AWSResponse a)),
296296
-- | Called whenever an AWS request returns an 'Error', even when
297297
-- the corresponding request is retried.
@@ -301,13 +301,13 @@ data Hooks = Hooks
301301
-- behavior may change in a future version.
302302
error ::
303303
forall a.
304-
(AWSRequest a, Typeable a) =>
304+
(AWSRequest a) =>
305305
Hook_ (Finality, Request a, Error)
306306
}
307307

308308
{-# INLINE requestHook #-}
309309
requestHook ::
310-
(forall a. (AWSRequest a, Typeable a) => Hook a -> Hook a) ->
310+
(forall a. (AWSRequest a) => Hook a -> Hook a) ->
311311
Hooks ->
312312
Hooks
313313
requestHook f hooks@Hooks {request} =
@@ -442,13 +442,13 @@ noHook_ _ _ _ = pure ()
442442
-- | Unconditionally add a @'Hook' a@ to the chain of hooks. If you
443443
-- need to do something with specific request types, you want
444444
-- 'addHookFor', instead.
445-
addHook :: (Typeable a) => Hook a -> Hook a -> Hook a
445+
addHook :: Hook a -> Hook a -> Hook a
446446
addHook newHook oldHook env = oldHook env >=> newHook env
447447

448448
-- | Unconditionally add a @'Hook_' a@ to the chain of hooks. If you
449449
-- need to do something with specific request types, you want
450450
-- 'addHookFor_', instead.
451-
addHook_ :: (Typeable a) => Hook_ a -> Hook_ a -> Hook_ a
451+
addHook_ :: Hook_ a -> Hook_ a -> Hook_ a
452452
addHook_ newHook oldHook env a = oldHook env a *> newHook env a
453453

454454
-- | Like 'addHook', adds an unconditional hook, but it also captures

lib/amazonka/src/Amazonka/HTTP.hs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,12 @@ import Control.Monad.Trans.Resource (liftResourceT, transResourceT)
2828
import qualified Control.Retry as Retry
2929
import Data.Foldable (traverse_)
3030
import qualified Data.Time as Time
31-
import Data.Typeable (Typeable)
3231
import qualified Network.HTTP.Conduit as Client.Conduit
3332

3433
retryRequest ::
3534
forall m a withAuth.
3635
( MonadResource m,
3736
AWSRequest a,
38-
Typeable a,
39-
Typeable (AWSResponse a),
4037
Foldable withAuth
4138
) =>
4239
Env' withAuth ->
@@ -75,7 +72,6 @@ retryRequest env@Env {hooks} rq = do
7572
awaitRequest ::
7673
( MonadResource m,
7774
AWSRequest a,
78-
Typeable a,
7975
Foldable withAuth
8076
) =>
8177
Env' withAuth ->
@@ -110,7 +106,6 @@ awaitRequest env@Env {hooks} w rq = do
110106
httpRequest ::
111107
( MonadResource m,
112108
AWSRequest a,
113-
Typeable a,
114109
Foldable withAuth
115110
) =>
116111
Env' withAuth ->
@@ -156,7 +151,7 @@ httpRequest env@Env {hooks, manager, region} cfgRq =
156151
-- service overrides from `env` and running hooks on the configured
157152
-- (Request a).
158153
configureRequest ::
159-
(AWSRequest a, Typeable a, MonadIO m) => Env' withAuth -> a -> m (Request a)
154+
(AWSRequest a, MonadIO m) => Env' withAuth -> a -> m (Request a)
160155
configureRequest env@Env {overrides, hooks} =
161156
liftIO
162157
. Hooks.configuredRequest hooks env

0 commit comments

Comments
 (0)