Here's my first significant Haskell program - it presents a count of each word seen on stdin. Any comments are welcome.import Data.MapemptyMap = empty :: Map String IntegercountWord m s = alter (\x -> case x of                               Nothing -> Just 1                               Just n -> Just (n+1)) s mmapPairs m = concat [ k ++ :  ++ (show v) ++ \n | (k,v) <- toList m ]mapTotal = sum . elemsmapOutput m = (mapPairs m) ++ Total words:  ++ (show (mapTotal m)) ++ \nwc = interact $ mapOutput . (foldl countWord emptyMap) . wordsSome of the questions I have are:Am I using Map efficiently here? (I realize there are other solutions which do not use a Map - the main point of this exercise was to learn how to use Data.Map.) How can I make sure that emptyMap, countWord and mapTotal all use the same integral type (Int vs. Integer)? For instance, the type of mapTotal is Map a Integer -> Integer, and so I'll get a type error if I change the definition of emptyMap to empty :: Map String Int. Ideally I'd like to make the choice between Int and Integer in one place for all three definitions.
My Haskell word count program
haskell