GHC 抱怨此代码:
{-# LANGUAGE TypeFamilies, MultiParamTypeClasses, ScopedTypeVariables #-}
class Test a b where
data Data a b
data Marker a b
test :: Marker a b -> Bool
work :: (Test a b, Test a2 b2) => Data a b -> Data a2 b2
work =
let (m :: Marker a2 b2) = undefined
in if test m then undefined else undefined
随着消息:
You cannot bind scoped type variables `a2', `b2'
in a pattern binding signature
In the pattern: m :: Marker a2 b2
我不想将函数的实际功能work
移到Test
类中,因为test
谓词在多个函数中使用。