矢印とその矢印を説明する文字列を保持するタプルを作成したいと思います。(矢印の代わりに)関数を使用してこれを行うと、次のように機能します。
funTimes10 = (*10)
describe10 = "times 10"
tuple10 :: (Num b) => ((b -> b), String)
tuple10 = (,) funTimes10 describe10
fst
で関数にアクセスでき、関数snd
の説明文字列を取得できます。
ただし、次のように、関数を矢印で交換すると、次のようになります。
aTuple10 :: (Arrow a, Num b) => (a b b, String)
aTuple10 = (,) (arr funTimes10) describe10
fst
まだ動作し、私の矢印を返しますが、- が付いた説明文字列がありません
snd
。
私はこのエラーメッセージだけを受け取りました:
Ambiguous type variable `a0' in the constraint:
(Arrow a0) arising from a use of `aTuple10'
Probable fix: add a type signature that fixes these type variable(s)
In the first argument of `snd', namely `aTuple10'
In the expression: (snd aTuple10)
In an equation for `it': it = (snd aTuple10)
なぜこのエラーが発生するのですか?それを回避するにはどうすればよいですか?