我有一個函數,我想用幾組輸入進行測試。比方說,功能通過兩個輸入列表映射函數
f :: a -> b -> c
現在我已經投入兩個列表:
inputA :: [a]
inputB :: [[b]]
對於inputA !! i
,我想在inputB !! i
列表中的每個元素評估f $ input !! i
。我知道我需要map
的幾個應用程序來做到這一點,但我很難解決問題。
我最近一次嘗試是
map f inputA <$> inputB
它提供了以下錯誤:
Couldn't match expected type
a0 -> b0' with actual type
[b1]'
In the return type of a call ofmap'
map' is applied to too many arguments
Probable cause:
In the first argument of(<$>)', namely
map f inputA'
In the expression: map f inputA inputB
我應該如何去解決這個問題呢?我不一定需要一個完整的解決方案。一個有益的方向推(甚至推)肯定會被讚賞。
更多的想法:
map f inputA :: [b -> c]
我認爲這是正確的方向。現在我需要將每個函數映射到inputB
的每個輸入列表上。
爲了澄清,我想將i
個功能map f inputA
超過投入的i
個列表inputB
映射到得到的結果outputC :: [[c]]
。
如果你還沒有看到它,你可能也有興趣[快速檢查](http://hackage.haskell.org/package/QuickCheck )。 –
@DanielWagner感謝您的鏈接。我已經很快地閱讀了關於QuickCheck的內容,並且在我關於Haskell的事情清單上。 –