【问题标题】:Data.Map type declarationData.Map 类型声明
【发布时间】:2012-02-24 08:37:56
【问题描述】:
import Data.Map as Map

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

错误:

`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 作为参数传递?

【问题讨论】:

    标签: haskell


    【解决方案1】:

    你必须说出它是什么地图

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

    您的键是Ints,您存储的值也是Ints,因此您的地图类型为Map Int Int

    如果键是Strings,值是Bools,则映射的类型为Map String Bool

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-25
      • 2022-08-12
      • 1970-01-01
      • 2020-05-12
      • 2013-10-12
      相关资源
      最近更新 更多