[Haskell-beginners] Infinite type ... or 'not enough type arguments'...
Sean Charles
sean at objitsu.com
Thu Jun 9 13:57:47 CEST 2011
Further to my recent attempts to scan a CSV file and build a map, I now
have a foldl calling this with an empty map:
--forwardRoutes :: M.Map String [String] -> Record -> M.Map
forwardRoutes map row =
case lookup map (row!!0) of
Nothing -> M.insert (row!!0) [(row !! 1)] map
Just routes -> M.insert (row!!0) (row!!1):routes map
With the type declaration commented out I get this:
scread.hs:102:46:
Occurs check: cannot construct the infinite type:
a = M.Map [(a, b)] [[(a, b)]]
Expected type: M.Map [(a, b)] [[(a, b)]]
Inferred type: a
In the third argument of `M.insert', namely `map'
In the expression: M.insert (row !! 0) [(row !! 1)] map
and with it 'in#' i get this error instead...
scread.hs:99:52:
`M.Map' is not applied to enough type arguments
Expected kind `?', but `M.Map' has kind `* -> * -> *'
In the type signature for `forwardRoutes':
forwardRoutes :: M.Map String [String] -> Record -> M.Map
Can anybody help me to understand both problems. I thought I had
declared the type signature of forwardRoutes correctly but obv. not! LOL
I have seen information that says the "infinite error" message can be
cured by supplying types so I did......
Thanks again.
Sean
More information about the Beginners
mailing list