Hello everyone , <br>I wanted to do a small program which read a txt with fruit&#39;s name in each line and then print how many fruits I have of each type. something like these:<br>&nbsp; apple<br>&nbsp; apple<br><br>and then <br><br>

[(apple,2)]<br>
<br>I came up whit this<br><pre>import qualified Data.Map as Map<br>import Data.List<br>import System.IO<br><br>main =<br>    do<br>      file &lt;- readFile &quot;fruits.txt&quot;<br>      let answer = proccessFile $ lines file<br>

      putStrLn (show answer)<br><br>proccessFile :: [String] -&gt; [(String,Int)]<br>proccessFile file = Map.toAscList $ parseFile Map.empty  file<br>    where parseFile fruits [] = fruits<br>          parseFile fruits_map (x:xs) = parseFile (Map.insertWith (+) x 1 fruits_map) xs                                   </pre>

&nbsp; <br>It works, but I would like to know how would&nbsp; you do it ?,&nbsp; Share different&nbsp; points of view, different code. Was it a good idea to use a Map&nbsp; ?, Did I separate the code&nbsp; in a proper way, I mean pure - impure ? How can we improve the performance ?<br>

<br>Best Regards for everyone.<br><br><br>Adolfo<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>