[Haskell-cafe] Should circular deriving "via" be rejected?

Viktor Dukhovni ietf-dane at dukhovni.org
Fri Nov 12 18:27:27 UTC 2021


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.


More information about the Haskell-Cafe mailing list