[Haskell] [Fwd: undecidable & overlapping instances: a bug?]

Jorge Marques Pelizzoni jpeliz at icmc.usp.br
Tue Oct 16 21:32:46 EDT 2007

Hi, all! It's been a while since I sent the message below to the GHC list,
which I believe is its rightful forum, but I've had no reply so far. So I
am giving the haskell list a try.

Thanks in advance. Cheers,


--------------------------- Mensagem Original ----------------------------
Assunto: undecidable & overlapping instances: a bug?
De:      "Jorge Marques Pelizzoni" <jpeliz at icmc.usp.br>
Data:    Sab, Outubro 13, 2007 5:59 am
Para:    "GHC users" <glasgow-haskell-users at haskell.org>

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:

    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:

    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,


-------------- 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/haskell/attachments/20071016/1f6a6fe3/FooModule.obj

More information about the Haskell mailing list