2012-02-24 177 views
1
import Data.Map as Map 

test :: Int -> Int -> Map -> Map 
test key value cache = Map.insert key value cache 

錯誤:Data.Map類型聲明

`Map' is not applied to enough type arguments 
Expected kind `??', but `Map' has kind `* -> * -> *' 
In the type signature for `test': test :: Int -> Int -> Map -> Map 

我如何可以聲明傳遞Data.Map作爲參數的函數?

回答

6

你必須說什麼是地圖

test :: Int -> Int -> Map Int Int -> Map Int Int 
test key value cache = Map.insert key value cache 

你的密鑰是Int S和要存儲的值也Int S,所以你的地圖有型Map Int Int

如果密鑰爲String s且值爲Bool s,則該映射的類型爲Map String Bool