我想將我的程序從使用Data.Array轉換爲Data.Array.Unboxed。Haskell從數組轉換到Unboxed數組中斷重寫規則
作爲一個邊注: 幾個地方指出,我可以在我的代碼 「陣列」更改爲「UArray」,並添加Data.Array.Unboxed的進口,但是我不混合兩種 類型的數組所以 我剛剛導入Data.Array.Unboxed而不是Data.Array,這足夠嗎?
當我做了開關以下重寫規則遊:
{-# 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 2012-02-12 18:54:00
增加了一個'applyWindow'的方法,問題是本地綁定,但讓所有數組具有相同的類型可能是可取的。 – 2012-02-12 20:04:19
熱Dam!我已經打了兩天了,我想要多態元素類型,並且在FlexibleInstances和ScopedTypedVariables上跳舞數小時。謝謝你,先生! – Toymakerii 2012-02-12 20:10:16