在GHC 8中设置类型族的约束

时间:2016-10-06 08:00:20

标签: haskell type-constraints type-families

假设我有以下代码:

class Eq (Foo a) => Bar a where
    type Foo a :: *

doSmth:: Proxy a -> Foo a -> Bool
doSmth _ a = a == a

在GHC 7中它工作正常,但GHC 8抱怨:

• No instance for (Eq (Foo a)) arising from a use of ‘==’
• In the expression: a == a
  In an equation for ‘doSmth’: doSmth _ a = a == a

如何说Foo a始终是Eq的实例?

0 个答案:

没有答案