brendanhay / amazonka

A comprehensive Amazon Web Services SDK for Haskell.
https://amazonka.brendanhay.nz
Other
599 stars 227 forks source link

Kind of `Env`'s type variable #877

Closed endgame closed 1 year ago

endgame commented 1 year ago
    Seems somewhat arbitrary to the naive reader (ie. me) parameterising over some `f :: Type -> Type` when you could just define:
data EnvF auth = Env {
    ...,
    auth :: auth,
} deriving stock (Functor, ...)

type Env = EnvF (Identity Auth)

And pass parameters as:

retryRequest ::
  forall m a f.
  ( Foldable f
  ) =>
  EnvF (f Auth) ->
  a ->
  m (Either Error (ClientResponse (AWSResponse a)))

_Originally posted by @brendanhay in https://github.com/brendanhay/amazonka/pull/875#discussion_r1064127139_

endgame commented 1 year ago

If we use a type variable of kind Type, we either:

I still think that the Type -> Type parameter is the correct tradeoff, but perhaps it's possible to make the rationale clearer? Note that the non-.hs-boot file has type Env = Env' Identity and type EnvNoAuth = Env' Proxy aliases, each with haddocks.

endgame commented 1 year ago

It's been a couple of months and I still agree with everything I wrote here. Since nobody's felt strongly enough to comment about wanting to do something else, I'm going to close this. We can reopen the discussion if there are strong feelings and a compelling alternative design.