GHC 6.6 Data.Tuple incompatibility

Hello, I had this code that worked in GHC 6.4: type CommandHandler = FTPServer -> String -> IO Bool type Command = (String, (CommandHandler, (String, String))) instance Eq Command where x == y = (fst x) == (fst y) instance Ord Command where compare x y = compare (fst x) (fst y) I am compiling with overlapping instances set. In GHC 6.6, this gives an error that Eq Command is a duplicate instance of one defined in Data.Tuple. Commenting out that instance causes the Ord Command instance to fail because there is no Eq instance for CommandHandler. After discussing it with Ian Lynagh, his conclusion was that the problem is that Data.Tuple was not compiled with overlapping instances support, and that it probably ought to be. He asked me to post here to see if everyone else felt the same way. Thanks, -- John

Hello John, Thursday, October 19, 2006, 11:21:37 PM, you wrote:
I had this code that worked in GHC 6.4:
type CommandHandler = FTPServer -> String -> IO Bool type Command = (String, (CommandHandler, (String, String)))
isnt' it better in such cases use the new datatype? data Command = Command String CommandHandler String String
After discussing it with Ian Lynagh, his conclusion was that the problem is that Data.Tuple was not compiled with overlapping instances support, and that it probably ought to be. He asked me to post here to see if everyone else felt the same way.
the problem will arrive with any 'base' type constructor used in such way - [], maybe, either -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

Why are you not using a proper type?
Define
data Command = Cmd String (CommandHandler, (String, String))
and there will be no problem making that an instance of Eq and Ord in
the way you described.
On 19/10/06, John Goerzen
Hello,
I had this code that worked in GHC 6.4:
type CommandHandler = FTPServer -> String -> IO Bool type Command = (String, (CommandHandler, (String, String)))
instance Eq Command where x == y = (fst x) == (fst y) instance Ord Command where compare x y = compare (fst x) (fst y)
I am compiling with overlapping instances set.
In GHC 6.6, this gives an error that Eq Command is a duplicate instance of one defined in Data.Tuple. Commenting out that instance causes the Ord Command instance to fail because there is no Eq instance for CommandHandler.
After discussing it with Ian Lynagh, his conclusion was that the problem is that Data.Tuple was not compiled with overlapping instances support, and that it probably ought to be. He asked me to post here to see if everyone else felt the same way.
Thanks,
-- John _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries

On Thu, Oct 19, 2006 at 05:21:47PM -0400, Cale Gibbard wrote:
Why are you not using a proper type?
Define data Command = Cmd String (CommandHandler, (String, String)) and there will be no problem making that an instance of Eq and Ord in the way you described.
Because Data.List.lookup worked easier with a tuple. I know that I can do this, and in fact already checked in such a thing to my darcs repo, but this is a regression from GHC 6.4. -- John

On Thu, Oct 19, 2006 at 02:21:37PM -0500, John Goerzen wrote:
I had this code that worked in GHC 6.4:
type CommandHandler = FTPServer -> String -> IO Bool type Command = (String, (CommandHandler, (String, String)))
instance Eq Command where x == y = (fst x) == (fst y) instance Ord Command where compare x y = compare (fst x) (fst y)
I am compiling with overlapping instances set.
In GHC 6.6, this gives an error that Eq Command is a duplicate instance of one defined in Data.Tuple.
On Thu, Oct 19, 2006 at 04:27:57PM -0500, John Goerzen wrote:
[...], but this is a regression from GHC 6.4.
It's a change, but that's a risk one takes when using experimental features. Personally, I think it's an improvement: no longer can standard instances change because I've imported a module that happens to use overlapping instances.

John Goerzen wrote:
On Thu, Oct 19, 2006 at 05:21:47PM -0400, Cale Gibbard wrote:
Why are you not using a proper type?
Define data Command = Cmd String (CommandHandler, (String, String)) and there will be no problem making that an instance of Eq and Ord in the way you described.
Because Data.List.lookup worked easier with a tuple.
Well, if you need the tuple, you could do newtype Command = Cmd (String, (CommandHandler, (String, String))) I agree with Cale and Ross: you should be using your own type if you want your own instance. This isn't a particularly compelling example for reverting to the 6.4 behaviour. -- Ashley Yakeley

| After discussing it with Ian Lynagh, his conclusion was that the problem | is that Data.Tuple was not compiled with overlapping instances support, | and that it probably ought to be. He asked me to post here to see if | everyone else felt the same way. Another possibility is to loosen the rules, so that you must have -fallow-overlapping instances when compiling the module with the *more specific* instance, but not for the less-specific one. That would make it easy to override library definitions... but it would make it impossible to make an instance that you did not want overridden. I'm open to suggestions here. The issue is what we want; the implementation is straightforward now that the machinery is there. Simon
participants (6)
-
Ashley Yakeley
-
Bulat Ziganshin
-
Cale Gibbard
-
John Goerzen
-
Ross Paterson
-
Simon Peyton-Jones