generic-lens
generic-lens copied to clipboard
Reflexive instances for AsType?
There appears to be reflexive instances for AsSubtype and HasType, but not for AsType.
Consider:
data SomethingError = OhNo
deriving (Generic)
doSomething :: (AsType SomethingError e, MonadError e m) => m ()
In 2.2.1.0 we can write
data AppError = AESomething SomethingError | AEOther Text
deriving (Generic)
app :: ExceptT AppError IO ()
app = do
...
doSomething
...
But
app :: ExceptT SomethingError IO ()
app = do
...
doSomething
...
gives an error like The type SomethingError does not contain a constructor whose field is of type SomethingError
.
Is there a good reason why we can't add instance AsType a a
? Or is there a different way to achieve this kind of behaviour?
Originally posted by @lrworth in https://github.com/kcsongor/generic-lens/issues/85#issuecomment-1056024535