Skip to content

Currying constraints on instances results in strange error message

Summary

I was experimenting to see if "curried constraint" syntax worked on instances

data Foo a b = Foo

instance Eq a => Eq b => Eq (Foo a b) where
    _ == _ = True

and got a very strange error message:

weirderror.hs:3:10: error:
    • Class ‘Eq’ does not have a method ‘==’
    • In the instance declaration for ‘Eq (Foo a b)’

Steps to reproduce

Obvious

Expected behavior

Either Just Work or result in some error message about invalid syntax.

Environment

  • GHC version used: GHC 8.6.5

Optional:

  • Operating System: MacOS Mojave
  • System Architecture: x86_64
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information