Re: overlapping instances and constraints

2006-03-11 Thread Claus Reinke
- Haskell would need to be a lot more specific about exactly where context reduction takes place. Consider f xs x = xs == [x] Do we infer the type (Eq a) = [a] - a - Bool? Thereby committing to a particular choice of instance? Or do we (as GHC does) infer the type (Eq [a]) = [a] - a - Bool, so

Re: overlapping instances and constraints

2006-03-08 Thread Claus Reinke
there were a couple of issues Simon raised that I hadn't responded to in my earlier reply. since no-one else has taken them on so far, either, .. - Haskell would need to be a lot more specific about exactly where context reduction takes place. Consider f xs x = xs == [x] Do we infer the type

Re: overlapping instances and constraints

2006-03-01 Thread Ben Rudiak-Gould
Niklas Broberg wrote: Ben Rudiak-Gould wrote: Are there uses of overlapping instances for which this isn't flexible enough? Certainly! Hmm... well, what about at least permitting intra-module overlap in Haskell' (and in GHC without -foverlapping-instances)? It's good enough for many

Re: overlapping instances and constraints

2006-03-01 Thread Ashley Yakeley
Ben Rudiak-Gould wrote: I think all of these problems would go away if overlap was permitted within a module but forbidden across modules. Are there uses of overlapping instances for which this isn't flexible enough? I dislike this on principle. I like the idea that modules can be

Re: overlapping instances and constraints

2006-02-28 Thread Claus Reinke
instance C2 a b | a/=b I was thinking it would be all kinds of useful if we had two predefined classes class Eq a b class NEq a b where Eq has instances exactly when its two types are equal and NEq has instances exactly when its two types are not equal. class Eq a b instance Eq a a

Re: overlapping instances and constraints

2006-02-28 Thread Niklas Broberg
On 2/28/06, Ben Rudiak-Gould [EMAIL PROTECTED] wrote: Simon Peyton-Jones wrote: - A program that type checks can have its meaning changed by adding an instance declaration - Similarly adding import M() can change the meaning of a program (by changing which instances are visible -

Re: overlapping instances and constraints

2006-02-28 Thread Niklas Broberg
Claus Reinke wrote: most of us would be happy if instance contexts would be required to uniquely determine the instance to be chosen, a rather conservative extension of current practice. I'm not so sure about the most of us, as you note yourself the defaulting pattern is quite popular (and

RE: overlapping instances and constraints

2006-02-27 Thread Simon Peyton-Jones
Overlapping instances are undoubtedly useful, but they raise lots of interesting questions. Such as - A program that type checks can have its meaning changed by adding an instance declaration - Similarly adding import M() can change the meaning of a program (by changing which instances are

Re: overlapping instances and constraints

2006-02-27 Thread Claus Reinke
[ I'll only address some of your issues in this message, as they fall nicely under the use of a feature I'd like to see anyway: type disequality constraints ] - A program that type checks can have its meaning changed by adding an instance declaration - Similarly adding import M() can

Re: overlapping instances and constraints

2006-02-27 Thread John Meacham
On Mon, Feb 27, 2006 at 05:09:30PM +0300, Bulat Ziganshin wrote: i had plans to propose the same and even more: instance C2 a b | a/=b I was thinking it would be all kinds of useful if we had two predefined classes class Eq a b class NEq a b where Eq has instances exactly when its two types