
#16319: unexpected difference between newtype and data ----------------------------------------+--------------------------------- Reporter: pjljvdlaar | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.2 Keywords: | Operating System: Windows Architecture: Unknown/Multiple | Type of failure: None/Unknown Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: ----------------------------------------+--------------------------------- The following code compiles fine {{{#!hs -- | A referable class -- An object can only have one reference. -- For example, a function is either referenced by name of by signature but not both. class ( Eq (Ref a) , Ord (Ref a) , Hashable (Ref a) , Show (Ref a) , Read (Ref a) , Data (Ref a) ) => Referable a where type Ref a toRef :: a -> Ref a data Referable a => RefMap a = RefMap { -- | the HashMap toHashMap :: HashMap.Map (Ref a) a } deriving (Eq, Ord, Show, Read, Data) }}} yet following the hlint hint to replace data by the equivalent newtype results in the following issues: {{{ src\TorXakis\Referable.hs:59:43: error: * Could not deduce (Eq (Ref a)) arising from the 'deriving' clause of a data type declaration from the context: Eq a bound by the deriving clause for `Eq (RefMap a)' at src\TorXakis\Referable.hs:59:43-44 Possible fix: use a standalone 'deriving instance' declaration, so you can specify the instance context yourself * When deriving the instance for (Eq (RefMap a)) | 59 | } deriving (Eq, Ord, Show, Read, Data) | ^^ src\TorXakis\Referable.hs:59:47: error: * Could not deduce (Ord (Ref a)) arising from the 'deriving' clause of a data type declaration from the context: Ord a bound by the deriving clause for `Ord (RefMap a)' at src\TorXakis\Referable.hs:59:47-49 Possible fix: use a standalone 'deriving instance' declaration, so you can specify the instance context yourself * When deriving the instance for (Ord (RefMap a)) | 59 | } deriving (Eq, Ord, Show, Read, Data) }}} I assume this is a bug... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/16319 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler