histogram :: [Integer] -> String
histogram xs = (intercalate "\n" $ transpose stars) ++ "\n==========\n0123456789\n"
  where
    stars = map (\i -> replicate (maximum counts - i) ' ' ++ replicate i '*') counts
    counts = map (fromMaybe 0 . flip lookup db) [0..9]
    db = map (\l -> (head l, length l)) $ group $ sort xs
histogram :: [Integer] -> String
histogram xs = (intercalate "\n" $ transpose stars) ++ "\n==========\n0123456789\n"
  where
    stars = map (\i -> replicate (maximum counts - i) ' ' ++ replicate i '*') counts
    counts = map (fromMaybe 0 . flip lookup db) [0..9]
    db = map (\l -> (head l, length l)) $ group $ sort xs
histogram xs = (intercalate "\n" $ transpose stars) ++ "\n==========\n0123456789\n"
  where
    stars = map (\i -> replicate (maximum counts - i) ' ' ++ replicate i '*') counts
    counts = map (fromMaybe 0 . flip lookup db) [0..9]
    db = map (\l -> (head l, length l)) $ group $ sort xs