Importing a newtype constructor can break typechecking
Summary
Having a newtype constructor in scope can cause a reduction stack overflow when the program would otherwise typecheck.
Steps to reproduce
The following comes from this StackOverflow answer by @kabuhr.
-- HyperFunction.hs
module HyperFunction where
newtype Hyper a b = Hyper { invoke :: Hyper b a -> b }
-- HyperCoerce.hs
module HyperCoerce where
import HyperFunction (Hyper)
-- The next line breaks it
-- import HyperFunction (Hyper (..))
import Data.Coerce
(#.) :: (Coercible c b) => q b c -> Hyper a b -> Hyper a c
(#.) _ = coerce
Compiling this as is works. Adding the commented line gives a reduction stack overflow.
Expected behavior
The modules compile.
Environment
- GHC version used: 8.6.3
Optional:
- Operating System:
- System Architecture: