ダミーの例を次に示します。
class Test a b where
witness :: a
f :: Test a b => a
f = witness
Haskell は次のように言います。
Could not deduce (Test a b0) arising from a use of ‘witness’
from the context (Test a b)
bound by the type signature for f :: Test a b => a
at test.hs:8:6-18
The type variable ‘b0’ is ambiguous
Relevant bindings include f :: a (bound at test.hs:9:1)
In the expression: witness
In an equation for ‘f’: f = witness
エラーは、Haskell が型変数を推測できないという事実から発生し、解決策はtypeclass の定義からb0
パラメーターを削除することです。でも、現実には、できません。b
Test
私の質問は次のとおりです。行で指定されたb0
明示的なパラメーターで明示的に識別する方法はありますか?b
f :: Test a b => a
ありがとう。