undecidable & overlapping instances: a bug?

Jorge Marques Pelizzoni jpeliz at icmc.usp.br
Sat Oct 13 03:59:35 EDT 2007


Hi, all!

I am quite intrigued at the behaviour examplified in the attached module.
It's true I am a newbie and probably don't quite get the whole consequence
spectrum of -fallow-undecidable-instances, but why providing that dummy
instance (commented out) get the thing to compile?

By the way, I'm using GHC 6.6 on WinXP (actually, latest Visual Haskell
with MS Visual Studio 2005) and the error message I get is:

FooModule.hs:13:9:
    Could not deduce (Show a) from the context (Concrete a b)
      arising from use of `bar' at FooModule.hs:13:9-13
    Possible fix: add (Show a) to the class or instance method `foo'
    In the expression: bar x
    In the definition of `foo': foo x = bar x
    In the definition for method `foo'

A second question: which kinds of overlapping are covered by
-fallow-overlapping-instances? It seems that the following (also in the
attached module) is not allowed:

instance (Show a, Abstract a b) => Concrete a b where
	foo x = show x

instance (Abstract a b) => Concrete a b

which gives me the message:

FooModule.hs:17:0:
    Duplicate instance declarations:
      instance [overlap ok] (Show a, Abstract a b) => Concrete a b
        -- Defined at FooModule.hs:17:0
      instance [overlap ok] (Abstract a b) => Concrete a b
        -- Defined at FooModule.hs:30:0

Thanks in advance for any pointers. Cheers,

Jorge.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: FooModule.hs
Type: application/octet-stream
Size: 685 bytes
Desc: not available
Url : http://www.haskell.org/pipermail/glasgow-haskell-users/attachments/20071013/adb9b5ab/FooModule.obj


More information about the Glasgow-haskell-users mailing list