[Haskell-cafe] how to avoid overlapping instance error?
simonpj at microsoft.com
Sun Feb 27 22:01:54 EST 2005
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) you won't
get overlap. Only if you ask for Show (table item), where the type
checker still doesn't know what type 'table' is going to be, do you get
| -----Original Message-----
| From: haskell-cafe-bounces at haskell.org
[mailto:haskell-cafe-bounces at haskell.org] On Behalf Of S.
| Alexander Jacobson
| Sent: 25 February 2005 17:09
| To: haskell-cafe at haskell.org
| Subject: [Haskell-cafe] how to avoid overlapping instance error?
| Currently, the HAppS.DBMS lib requires the user to provide a Show
| instance for their table types. An example might be:
| instance (Show item) => Show (MyTable item) where
| showsPrec d table = showsPrec d $ Set.toList $ myTableSet
| But the Table class itself defines a toSet function so I think I
| should be able to do this once for all Table instances:
| instance (Show item,Ord item, Table table item p) => Show (table
| showsPrec d table = showsPrec d $ Set.toList $ toSet table
| But I get an error telling me I am overlapping with Show [a].
| Since  is not an instance of Table, I don't see why there should be
| an overlap.
| S. Alexander Jacobson tel:917-770-6565 http://alexjacobson.com
| Haskell-Cafe mailing list
| Haskell-Cafe at haskell.org
More information about the Haskell-Cafe