[Haskell-cafe] know a workaround for greedy context reduction?

Nicolas Frisby nicolas.frisby at gmail.com
Fri Dec 5 22:23:07 EST 2008

With these three declarations

  {-# LANGUAGE FlexibleInstances #-}
  {-# LANGUAGE UndecidableInstances #-}

  class C a where c :: a
  class C a => D a where d :: a
  instance C a => D a where d = c

ghci exhibits this behavior:

  *> :t d
  d :: (C a) => a

Where I would prefer "d :: (D a) => a". In my actual examples, the
context is much larger and I can't involve overlapping instances. Is
there a known workaround? I didn't find a related bug on the GHC trac,
and I don't know if other compilers behave in the same way.

More information about the Haskell-Cafe mailing list