HasLogger wants a Lens, but only needs a Getter?
Blammo's HasLogger requires loggerL :: Lens' env Logger, which implies that it can not only get a Logger from env but that it can also modify the Logger in env. But looking at the source code it seems only view is ever used on loggerL.
So maybe it would be a good idea to change loggerL to loggerL :: Getter env Logger?
This is a backwards-compatible change if I'm not mistaken.
We only use view within the library itself, but we allow modifications through the lens for users of our library to do things we may not have thought of. For example, changing the logger (or something about it) for a block of code under test, using local / over, %~, etc.
Is there a reason restricting it to the less powerful thing is beneficial?
That sounds reasonable.
I'm in a situation where having to provide the full lens adds an extra constraint that is annoying to work with.
I see. If you don't plan to use the setting behavior, I think it'd be fine to supply a no-op, to avoid any additional constraints:
instance HasLogger env where
loggerL = lens yourGetter $ \x _ -> x
Right?
Yeah, although then there's no guarantee somebody else adds code to our codebase that tries to modify the logger.
What I ended up doing is writing custom MonadLogger(IO) instances for our App monad that doesn't use the HasLogger class.