
#8745: GeneralizedNewtypeDeriving is still not Safe -------------------------------------+------------------------------------ Reporter: goldfire | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 7.8.1-rc1 Resolution: | Keywords: Safe Operating System: Unknown/Multiple | Architecture: Unknown/Multiple Type of failure: None/Unknown | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: -------------------------------------+------------------------------------ Comment (by goldfire): I've found a weird corner case that is very relevant. Consider {{{ class Foo a where ... type role Foo representational data PackFoo a where MkPF :: Foo a => PackFoo a instance Foo Int where ... newtype Age = MkAge Int instance Foo Age where ... incoherent :: PackFoo Age incoherent = coerce (MkPF :: PackFoo Int) useIncoherent = case incoherent of MkPF -> {- here, we two incompatible instances of Foo Age available! -} }}} The problem, as I see it, boils down to the role annotation on `Foo`, which allows users to create incoherence. Should we perhaps disallow role annotations on classes in Safe Haskell? It would be analogous to the restrictions on overlapping instances, I think. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8745#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler