I'm stumped on this overlapping instances error message. Sorry this is a nontrivial project, but the error should be local to the type signatures.
First, I declare f to be of a certain type,
let f = undefined :: (CompNode Int)
Then, I try to call my function pshow :: PrettyShow a => a -> String
on it. I get this error message.
> pshow f
<interactive>:1:1:
Overlapping instances for PrettyShow (CompNode Int)
arising from a use of `pshow'
Matching instances:
instance (G.Graph g, PrettyShow (G.Vertex g)) => PrettyShow g
-- Defined at Graph.hs:61:10-57
instance (PrettyShow a, Show a) => PrettyShow (CompNode a)
-- Defined at Interpreter.hs:61:10-58
The problem is that CompNode Int
is not a graph, so I don't think the first matching instance should be triggering. (The second one is the one I want to execute.) Indeed, if I write a function that requires its argument to be a graph,
> :{
| let g :: G.Graph a => a -> a
| g = id
| :}
and then call it on f, I get the expected no instance error message,
> g f
<interactive>:1:1:
No instance for (G.Graph (CompNode Int))
Thanks in advance, sorry to crowdsource. I'm using GHC 7.0.4.