Hello,<div><br></div><div>So I've been trying to print some information in a file. I have two versions of the same function: one of them doesn't work and I don't understand why.</div><div>Here are the functions:</div>
<div><br></div><div># # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # </div><div><br></div><div>-- This one works as intended when called from ghci</div><div><div>renderTrackInfosToFile :: FilePath -> String -> IO [TrackInfos] -> IO ()</div>
<div>renderTrackInfosToFile filename sep ls = do nls <- ls</div><div> writeFile filename (intercalate "\n" $ map (renderTrackInfo sep) nls)</div>
<div> return ()</div></div><div><br></div><div>-- This one does nothing when called from ghci</div><div><div>renderTrackInfosToFile2 :: FilePath -> String -> [TrackInfos] -> IO ()</div>
<div>renderTrackInfosToFile2 filename sep ls = writeFile filename (intercalate "\n" $ map (renderTrackInfo sep) ls)</div></div><div><br></div><div><br></div><div>renderTrackInfo :: String -> TrackInfos -> String</div>
<div><br></div><div># # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # </div><div><br></div><div>Both functions load in ghci, and the following commands are issued:</div><div><br></div><div>> -- c :: IO [TrackInfos]</div>
<div>> liftM (renderTrackInfosToFile2 "blabla.txt" "|") c -- this command seems to do absolutely nothing</div><div>> renderTrackInfosToFile "blabla.txt" "|" c -- this one works as intended</div>
<div><br></div><div># # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # </div><div><br></div><div>And this is not the first time I have this sort of problem using liftM. I now that I'm missing something important here,</div>
<div>can anyone explain me my mistake?</div><div><br></div><div>Much thanks,</div><div><br></div><div>Guillaume Basse</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div>