[Haskell-beginners] Instance but no instance
Brent Yorgey
byorgey at seas.upenn.edu
Mon Oct 18 07:44:30 EDT 2010
On Mon, Oct 18, 2010 at 09:31:31AM +0200, Jeroen van Maanen wrote:
>
> unexpectedly results in an "Overlapping instances for UpdaterIO [...] [...]" compiler error. Where one of the overlapping instance declarations is:
>
> instance (Updater modelType updateType) => UpdaterIO modelType updateType
When doing instance selection, GHC only looks at the part to the right
of the =>. So, the instance above essentially means "every pair of
types are an instance of UpdaterIO, and, oh yes, they had better be an
instance of Updater as well". So the above instance overlaps with
*every* other instance of UpdaterIO.
There are a few solutions I can think of. One is to decide you are OK
with the overlapping instances (in this case I think it ought to work
correctly). Or you can bite the bullet and make a separate instance
of UpdaterIO for all the old instances of Updater.
-Brent
More information about the Beginners
mailing list