[Haskell-beginners] Expected / Inferred mis-match and confused!

Sean Charles sean at objitsu.com
Thu Jun 9 20:01:49 CEST 2011


Thanks every, Daniel, the list at large... I have finally solved my 
issue and moved on... for the record my function now looks like this:

forwardRoutes :: M.Map String [String]
                  -> Record
                  -> M.Map String [String]
forwardRoutes map row =
   let key = row !! 0 in
   let val = row !! 1 in
   case M.lookup key map of
     Nothing     -> M.insert key [val] map
     Just routes -> M.insert key (nub (val:routes)) map

and does just what I want!
The thing I ha failed to see was using Prelude.lookup instead of 
M.lookup and some errant ().

I know nub is 'potentially inefficient' but the source data set is 
reasonably small and the script only has to run three to four times a 
year so "So what!"

Just one thing: IF the error message had printed out the Prelude.lookup 
in the error message, that would have been incredibly useful! Is that a 
command line switch I haven't come across perhaps ?

Thanks again.
Sean.





More information about the Beginners mailing list