私のプログラムをData.ArrayからData.Array.Unboxedに変換しようとしています。迅速なサイドノートとしてHaskell配列からボックス化されていない配列に変換すると、書き換えルールが破損する
: いくつかの場所は、しかし、私は配列の両方 種類を混合わけではない、私は私のコード に「UArray」への「アレイ」に変更し、Data.Array.Unboxedのインポートを追加できると述べていますだから Data.Arrayの代わりにData.Array.Unboxedをインポートしただけで十分ですか?
私はスイッチ次の書き換えルールの休憩を作る:
ここ{-# RULES
"applyWindow/applyWindow" forall win1 win2 image.
applyWindow win1
(applyWindow win2
image) =
applyWindow (indexMult win1 win2)
image
#-}
WIN1 WIN2と画像はすべてUArraysする必要があります。しかし、これは以下のエラーでコンパイルに失敗します。
FIPlib/Core.hs:229:99:
Ambiguous type variables `e0', `a0' in the constraint:
(IArray a0 e0) arising from a use of `applyWindow'
Probable fix: add a type signature that fixes these type variable(s)
In the expression: applyWindow (indexMult win1 win2) image
When checking the transformation rule "applyWindow/applyWindow"
FIPlib/Core.hs:229:99:
Ambiguous type variables `e0', `a2' in the constraint:
(IArray a2 e0) arising from a use of `applyWindow'
Probable fix: add a type signature that fixes these type variable(s)
In the expression: applyWindow (indexMult win1 win2) image
When checking the transformation rule "applyWindow/applyWindow"
FIPlib/Core.hs:229:112:
Ambiguous type variables `e0', `a1' in the constraint:
(IArray a1 e0) arising from a use of `indexMult'
Probable fix: add a type signature that fixes these type variable(s)
In the first argument of `applyWindow', namely
`(indexMult win1 win2)'
In the expression: applyWindow (indexMult win1 win2) image
When checking the transformation rule "applyWindow/applyWindow"
なぜこの曖昧さがありますか?なぜこれはData.Arrayで動作するときに壊れますか?
https://gist.github.com/1810229 コードがあります。私はあなたが言っていることを理解していると思いますが、署名を修正する方法を理解しようとしています。 – Toymakerii
'applyWindow'の方法を追加しました。問題はローカルバインディングでしたが、すべての配列を同じ型にすることはおそらく望ましいことです。 –
ホット・ダン!私はこれで2日間これと戦ってきました。多相要素タイプが欲しかったので、FlexibleInstancesとScopedTypedVariablesの周りを何時間も踊っていました。ありがとうございます! – Toymakerii