ndmitchell / debug

Haskell library for debugging
BSD 3-Clause "New" or "Revised" License
122 stars 7 forks source link

Ovelapping Show instances for monadic values #8

Open LukaHorvat opened 6 years ago

LukaHorvat commented 6 years ago

Got another one for you.

Try this:

debug [d|
    f :: Int -> m Int
    f _ = undefined
    |]

You get an Overlapping instances for Show (m0 Int) error. This can be "fixed" by adding a instance {-# INCOHERENT #-} Show (m Int) somewhere because the arcane rules of instance selection pick this one.

I'm not really sure what you can really do about this.

ndmitchell commented 6 years ago

Thanks! I think the Show a instance I added is proving actively harmful - it works well in the same module, but is of no use in a different module, where it must live in the Debug library. Or I could inject a Show, but then you probably get other nasty problems.

Perhaps however _ => is enough to have GHC infer whatever Show instances it needs? Will try that tonight - Show (m Int) would be ideal.

ndmitchell commented 6 years ago

I went with _ => and it's vastly simpler - great news!

ndmitchell commented 6 years ago

I had to comment out the type2 example, so that still needs work.