(灵感来自,无法在具有约束条件的多态元组上进行匹配,并基于我对自己答案的后续评论。)
考虑下面的最小示例:
test :: (Show a, Show b) => (a -> String, b -> String)
test = (show,show)
(resX, resY) = test
Run Code Online (Sandbox Code Playgroud)
这将导致以下错误:
• Ambiguous type variable ‘a0’ arising from a use of ‘test’
prevents the constraint ‘(Show a0)’ from being solved.
Relevant bindings include
resX :: a0 -> String (bound at so.hs:25:2)
Probable fix: use a type annotation to specify what ‘a0’ should be.
These potential instances exist:
instance Show Ordering -- Defined in ‘GHC.Show’ …Run Code Online (Sandbox Code Playgroud)