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