【发布时间】:2013-01-06 18:26:06
【问题描述】:
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 谓词用于多个函数。
【问题讨论】:
标签: haskell type-inference typeclass