Skip to content

standalone deriving breaks module hiding

Foo.hs:

module Foo ( T, t ) where
data T = T
t = T

Bar.hs:

import Foo
deriving instance Eq T

Then in ghci...

$ ghci Bar.hs -XStandaloneDeriving
[1 of 2] Compiling Bar              ( Bar.hs, interpreted )
[2 of 2] Compiling Main             ( Baz.hs, interpreted )
Ok, modules loaded: Bar, Main.
*Main> t == t
True

There is no way that I could implement that instance Eq T manually in Bar.hs because Foo exports T abstractly.

I see no reason that standalone deriving should have any magic ability that manual instance declarations do not have. Indeed it breaks module abstraction.

Trac metadata
Trac field Value
Version 6.8.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown
Architecture Unknown
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information