I think it would be good to raise an issue on the GHC GitLab. It would obviously be a nice feature, and the GHC devs are best positioned to figure out if it's worth the time and trouble. Any such check will surely be imprecise, since deriving via instances can take lots of forms, but it'd be nice to catch simple cases. Presumably it'd be a warning and not an error.
GHC accepts:
{-# LANGUAGE DerivingStrategies, DerivingVia #-}
newtype Foo = Foo Int deriving (Show, Eq) via (Bar)
newtype Bar = Bar Int deriving (Show, Eq) via (Foo)
should there be any effort to avoid circular definitions?
Of course one could always implement an explicit `show` method that
diverges, so perhaps this is no worse, but on the other hand, statically
deciding divergence looks potentially easier in this case... On the
other hand actual definitions like this seem unlikely in practice, so
perhaps not worth burning precious compiler cycles to detect them?
--
Viktor.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.