I am having difficulties understanding the issues with implementing certain functions. I have a general data type defined as follow :
import qualified Data.Map.Strict as Map
data Stuff x = Stuff (Map.Map x [x])
When I try to implement a function such as this :
foo :: Ord x => x -> x -> Stuff x -> Stuff x
foo a b (Stuff c) = Stuff (Map.insert (a b c))
I get an error:
Couldn't match expected type ‘Map.Map x [x]’
with actual type ‘a0 -> Map.Map k0 a0 -> Map.Map k0 a0’
However, when I verify the signature in the Haskell docs:
insert :: Ord k => k -> a -> Map k a -> Map k a
If it's returning a "Map k a", can't type "a" be a list? How could I turn "a" into "[a]"?
[a]
is the type of lists, not of arrays. – duplode