Opened 5 years ago

Last modified 9 months ago

#5392 new feature request

Warnings about impossible MPTCs would be nice

Reported by: pumpkin Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.0.4
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect warning at compile-time Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


In the following class declaration:

{-# LANGUAGE MultiParamTypeClasses #-}

class C a b where
  f :: a -> a

it is possible to declare this class, and to make instances of it, but it will be impossible to ever call f, even with unsafeCoerce and other evil attempted workarounds. It seems fairly easy for GHC to spot this situation, where a method doesn't mention all of the class arguments, and it might save some confusion for newbies. I remember trying pretty hard when I was first learning haskell to tell GHC which instance I wanted there, but obviously failed quite miserably.

Change History (7)

comment:1 Changed 5 years ago by igloo

  • Milestone set to 7.6.1

You may actually be able to call f in the future, when we have ExplicitTypeApplication, but perhaps a warning would be nice anyway.

comment:2 Changed 4 years ago by igloo

  • Milestone changed from 7.6.1 to 7.6.2

comment:3 Changed 2 years ago by thoughtpolice

  • Milestone changed from 7.6.2 to 7.10.1

Moving to 7.10.1.

comment:4 Changed 2 years ago by thomie

  • difficulty set to Unknown
  • Type of failure changed from None/Unknown to Incorrect warning at compile-time

comment:5 Changed 22 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.12.1

Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:6 Changed 14 months ago by thoughtpolice

  • Milestone changed from 7.12.1 to 8.0.1

Milestone renamed

comment:7 Changed 9 months ago by thomie

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