
Ok, so I am heading to a headache...
Daniel Fischer mentioned a solution using Type Families. As I read, those
are meant to replace the FunDeps, I will try this solution...
2010/4/17 Casey McCann
On Sat, Apr 17, 2010 at 4:01 PM, Limestraël
wrote: I would have undestood the error if GameObject was also an instance of Binary (then the two instances would match), but it's not the case...
As Daniel Fischer has mentioned, presumably a Binary instance could later be written for GameObject; even if you have no intention of doing so, GHC considers the possibility. In other words, it's sufficient that such an instance could exist, not that it actually does.
In general: Instance selection and context checking are separate and occur in that order, thus contexts generally can't influence instance selection (except by using OverlappingInstances and strategically confusing instance heads, ensuring that GHC can't make any sense of your code until considering the contexts).
Unfortunately, anything involving extremely generic instances with some constraint tend to be very difficult to construct, because of how this works. This tends to include things like default instances for types not covered by specific ones, making all instances of X also instances of Y, fundep "type predicates" based on class membership, and so on. Type hackery can often get you most of what you want, but it gets awkward fast.
- C.