Skip to content

ConstraintKinds require UndecidableInstances when it doesn't need it

Using ConstraintKinds to alias a bunch of class constraints fails to compile without UndecidableInstances. The same code that manually spells out class constraints without ConstraintKinds compiles just fine though.

Test case below

-------------------------------------

{-# LANGUAGE ConstraintKinds #-}

{-# LANGUAGE MultiParamTypeClasses #-}

class DifferentTypes a b

type DifferentTypes3 a b c = (DifferentTypes a b, DifferentTypes b c, DifferentTypes a c)

class Foo a

class Bar a

-- Buggy instance requires UndecidableInstances to compile

instance (DifferentTypes3 a b c, Bar a, Bar b, Bar c) => Foo (a, b, c)

-- Equivalent instance compiles when manually expanding constraint type

instance (DifferentTypes a b, DifferentTypes b c, DifferentTypes a c, Bar a, Bar b, Bar c) => Foo (a, b, c)
Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information