On 09/11/10 11:53, Neil Brown wrote:
XMLGenerator.lhs:64:16:
    Overlapping instances for EmbedAsChild
                                (IdentityT IO) (XMLGenT m (XML m))
      arising from a use of `asChild' at XMLGenerator.lhs:64:16-22
    Matching instances:
      instance [overlap ok] (XML m ~ x, XMLGen m) => EmbedAsChild m x
        -- Defined at XMLGenerator.lhs:37:11-52
      instance [overlap ok] (EmbedAsChild m c) =>
                            EmbedAsChild m (XMLGenT m c)
        -- Defined at XMLGenerator.lhs:31:11-60

I think I should expand slightly more on this bit, especially since I chopped off the useful line "The choice depends on the instantiation of `m'". The problem is that depending on the choice of m in the instance (the "EmbedAsChild (IdentityT IO) (XMLGenT m (XML m))" part), you may or may not match the second overlapping instance. If you choose m=IdentityT IO then it matches the second instance, if you choose anything else then it won't, so GHC can't tell at this point which instance to choose. Which makes them not just overlapping, but also leaves no clear choice (which is why it prompts you to use IncoherentInstances). When you typed the genElement "foo" part explicitly and gave a type to the monad m, that fixed the ambiguity. So I think it's not even that you needed incoherent instances, you have an unresolvable ambiguity if the type of m is left to be inferred. So I still think the question is why the old instance with the "~" worked fine.

(Does this help, or am I telling you what you've already worked out for yourself?)

Thanks,

Neil.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to