ceth
ceth

Reputation: 45295

Data.Map type declaration

import Data.Map as Map

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

Error:

`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

How can I declare the function to pass Data.Map as parameter?

Upvotes: 1

Views: 1079

Answers (1)

dave4420
dave4420

Reputation: 47052

You have to say what it is a map of.

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

Your keys are Ints and the values you're storing are also Ints, so your map has type Map Int Int.

If the keys were Strings and the values were Bools, the map would have type Map String Bool.

Upvotes: 8

Related Questions