Closed BebeSparkelSparkel closed 7 months ago
This is a known GHC limitation: see https://gitlab.haskell.org/ghc/ghc/-/issues/20815.
As a stopgap could be
class Alt' f where
alt :: f a -> f a -> f a
class Alt' f => Alt f where
(<!>) :: f a -> f a -> f a
(<!>) = alt
some ...
many ...
Now newtypes can basically derive it with
newtype WE a b = WE (Either a b) deriving (Alt')
instance Alt (WE a)
@RyanGlScott Looking at the GHC issue it appears that there has not been progress on them lately. Any thoughts on the stopgap?
My personal two cents (@ekmett may have different thoughts): I'm not keen on changing the class hierarchy just for the sake of working around a GHC limitation. In my experience, rearranging class APIs almost invariably inflicts pain upon downstream users by breaking existing code. I'd like to avoid that situation unless there is a consensus that that is the design that a bulk of the users want.
I'm with @RyanGlScott on this one.
Note that https://gitlab.haskell.org/ghc/ghc/-/issues/20815 has been fixed upstream, so it will be possible to derive Alt
using GeneralizedNewtypeDeriving
in a future GHC release.
It would be nice to be able to derive Alt but I get this error