How to fool the divergence checker in ghc 9

Michael Sperber sperber at deinprogramm.de
Fri Jan 20 09:35:36 UTC 2023


I'm trying to port Conal Elliott's ConCat plugin from ghc 8 to 9, and
the divergence checker foils me.

Background: The plugin works by transforming calls to a pseudo-function
toCcc' defined like so:

-- | Pseudo function to trigger rewriting to TOCCC form.
toCcc' :: forall k a b. (a -> b) -> (a `k` b)
toCcc' _ = oops "toCcc' called"
{-# NOINLINE toCcc' #-}

For ghc 8, oops was defined like so:

module ConCat.Misc where

-- | Pseudo function to fool GHC's divergence checker.
oops :: String -> b
oops str = errorWithStackTrace ("Oops: "++str)
{-# NOINLINE oops #-}

... but unfortunately, ghc 9 is not so easily fooled and reports <A>x
for toCcc'.  Is there any way to prevent this that works for ghc 9?

Help would be much appreciated!

-- 
Regards,
Mike


More information about the Glasgow-haskell-users mailing list