#7256: Missing dataCast1 and dataCast2 methods in Data.Data instances ---------------------------------+------------------------------------------ Reporter: dreixel | Owner: dreixel Type: bug | Status: infoneeded Priority: normal | Milestone: Component: Compiler | Version: 7.6.1 Keywords: | Os: Unknown/Multiple Architecture: Unknown/Multiple | Failure: None/Unknown Difficulty: Unknown | Testcase: Blockedby: | Blocking: Related: | ---------------------------------+------------------------------------------ Changes (by dreixel):
* status: new => infoneeded Comment: Here's the fix: {{{ diff --git a/Data/Data.hs b/Data/Data.hs index 0a29668..cb2d894 100644 --- a/Data/Data.hs +++ b/Data/Data.hs @@ -1275,27 +1275,27 @@ instance (Data a, Data b, Data c, Data d, Data e, Data f ------------------------------------------------------------------------------ -instance Typeable a => Data (Ptr a) where +instance (Data a, Typeable a) => Data (Ptr a) where toConstr _ = error "Data.Data.toConstr(Ptr)" gunfold _ _ = error "Data.Data.gunfold(Ptr)" dataTypeOf _ = mkNoRepType "GHC.Ptr.Ptr" - + dataCast1 x = gcast1 x ------------------------------------------------------------------------------ -instance Typeable a => Data (ForeignPtr a) where +instance (Data a, Typeable a) => Data (ForeignPtr a) where toConstr _ = error "Data.Data.toConstr(ForeignPtr)" gunfold _ _ = error "Data.Data.gunfold(ForeignPtr)" dataTypeOf _ = mkNoRepType "GHC.ForeignPtr.ForeignPtr" - + dataCast1 x = gcast1 x ------------------------------------------------------------------------------ -- The Data instance for Array preserves data abstraction at the cost of -- inefficiency. We omit reflection services for the sake of data abstraction. -instance (Typeable a, Data b, Ix a) => Data (Array a b) +instance (Typeable a, Data a, Data b, Ix a) => Data (Array a b) where gfoldl f z a = z (listArray (bounds a)) `f` (elems a) toConstr _ = error "Data.Data.toConstr(Array)" gunfold _ _ = error "Data.Data.gunfold(Array)" dataTypeOf _ = mkNoRepType "Data.Array.Array" - + dataCast2 x = gcast2 x }}} Note however that this requires adding additional `Data` constraints to these instances; perhaps this is the reason why these methods were omitted in the first place. So fixing this might break client code that uses these instances. Nonetheless, they are required for the correct behavior of SYB's `ext/1/2` functions. Shall I go ahead and push the patch? -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7256#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs