Map is a parameterized data type (also called an abstract data type ). Only when you specify a type for keys and a type for values do you get a fully defined type.
For example, a map that allows you to search for String on Integer is of type Map Integer String .
Also, it looks like you imported the map (as you should). Because of this, you must use Map.Map instead of Map in the signature.
So your function should have a signature like
serialExpansion :: Int -> Map.Map Key Value
where Key is the key data type and Value is the data type of the value. In your case, if I were to guess, maybe you want Int for Key and Value . To be precise: you want Key to be the same as the type of the items in the listOfSimpleDividers num list, and Value to be the same as the type of the items in the powers num list. (This can help verify a signature like Map.fromList , if that is unclear).
Now you may ask: "but if you could specify the correct return type serialExpansion , why can't the compiler be?" It can. That is why your first example worked. Since you omitted the type signature, the compiler took it out of context. As you just experienced, writing signature types can be a good way to make sure you fully understand your code (instead of relying on type inference).
gspr
source share