CodeAbbey #21 Array Counters
You could use a Map, from the Data.Map module to count occurrences of the numbers:

import qualified Data.Map.Strict as M

count :: [Int] -&gt; M.Map Int Int
count xs = M.fromListWith (+) $ zip xs (repeat 1)


This way you only iterate once through the list of pairs (number, 1) and sum the 1s of each different number.

Since we don't have mutation in Haskell, you can often use a Map as a replacement for a dictionary in imperative languages (or arrays).