2012-02-24 128 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