Opened 3 years ago

Closed 2 years ago

Last modified 23 months ago

#10423 closed bug (fixed)

Can't infer Monad n from (Monad m, m ~ n)

Reported by: Feuerbach Owned by:
Priority: normal Milestone: 8.0.1
Component: Compiler (Type checker) Version: 7.11
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case: typecheck/should_compile/T10423
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


This looks like a regression in GHC HEAD.

    Could not deduce (Monad n)
      arising from the superclasses of an instance declaration
    from the context: (Monad m, m ~ n)
      bound by the instance declaration
      at Test/SmallCheck/Property.hs:187:10-52
    Possible fix:
      add (Monad n) to the context of the instance declaration
    In the instance declaration for ‘Testable n (Property m)’

The code is here:

Originally reported here:

Change History (5)

comment:1 Changed 3 years ago by simonpj

This is my fault, fallout from my removal of "silent superclasses". I understand what is happening here. It is clearly a bug. I think that if you replace

instance (Monad m, m ~ n) => Testable n (Property m) where

by putting Monad n in the context, thus

instance (Monad n, m ~ n) => Testable n (Property m) where

it'll probably work. It'll be a couple of weeks before I can actually fix it.

Thanks very much for the report.


comment:2 Changed 2 years ago by Simon Peyton Jones <simonpj@…>

In 1189196ce7f064af408c9d16874a4c0b78f3a006/ghc:

Re-do superclass solving (again); fixes #10423

TcInstDcls.tcSuperClasses was getting increasingly baroque as a
succession of tickets (#10423 being the latest) pointed out that
my cunning plan was not so cunning.

The big issue is how to restrict the evidence that we generate
for superclass constraints in an instance declaration to avoid
superclass loops.  See Note [Recursive superclasses] in TcInstDcls
which explains the plan.

The question is how to implement the plan.  The new implementation is
much neater, and is described in Note [Solving superclass constraints]
in TcInstDcls.

comment:3 Changed 2 years ago by Simon Peyton Jones <simonpj@…>

comment:4 Changed 2 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: typecheck/should_compile/T10423

Fixed, thank you.


comment:5 Changed 23 months ago by thomie

Milestone: 8.0.1
Note: See TracTickets for help on using tickets.