RE: [Haskell-cafe] how to avoid overlapping instance error?

2005-02-28 Thread Simon Peyton-Jones
| Or I suppose, one could rephrase this question as why not | simplify instance declarations to be: | |instance ToSet where | toSet = Set.fromList | | And let the typechecker take care of figuring out what instance is | being specified here? That might be possible, but Haskell forces y

RE: [Haskell-cafe] how to avoid overlapping instance error?

2005-02-28 Thread S. Alexander Jacobson
If you are not using them to prevent overlapping instances, then why require instance decls at all? For example, why does GHC require an instance decl here: instance (Ord x)=>ToSet [] x where toSet = Set.fromList But not here: listToSet x = Set.fromList x Or I suppose, one could rephrase th

RE: [Haskell-cafe] how to avoid overlapping instance error?

2005-02-27 Thread Simon Peyton-Jones
Unfortunately, the context of an instance decl is not taken into account when matching instance decls. Yes, it would make sense to do so, but it'd make the system yet more complicated. So Show (table item) overlaps with Show ([] item) Overlap is checked lazily, so if you look for Show (MyTable t