<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><font size="4" class="">Hi,</font><div class=""><font size="4" class=""><br class=""></font></div><div class=""><font size="4" class="">I have this in a .hs file and it works fine. That is I see lines printed to the screen when the .hs file is loaded and run from ghci.</font></div><div class=""><font size="4" class=""><br class=""></font></div><div class=""><font size="4" class="">main = do</font></div><div class=""><font size="4" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>file <- readFile "poem.txt"</font></div><div class=""><font size="4" class=""><span class="Apple-tab-span" style="white-space:pre"> </span>mapM_ putStrLn (lines file)</font></div><div class=""><font size="4" class=""><br class=""></font></div><div class=""><font size="4" class=""><br class=""></font></div><div class=""><font size="4" class="">Experimenting at the ghci command line with</font></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 18px; font-family: Menlo;" class="">let f = readFile “poem.txt” </div></div><div style="margin: 0px; font-size: 18px; font-family: Menlo;" class="">the above is fine.</div><div style="margin: 0px; font-size: 18px; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 18px; font-family: Menlo;" class="">But doing </div><div style="margin: 0px; font-size: 18px; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 18px; font-family: Menlo;" class="">lines f </div><div style="margin: 0px; font-size: 18px; font-family: Menlo;" class=""><br class=""></div><div style="margin: 0px; font-size: 18px; font-family: Menlo;" class="">gives </div><div style="margin: 0px; font-size: 18px; font-family: Menlo;" class=""><div style="margin: 0px;" class=""><interactive>:52:7:</div><div style="margin: 0px;" class=""> Couldn't match type ‘IO String’ with ‘[Char]’</div><div style="margin: 0px;" class=""> Expected type: String</div><div style="margin: 0px;" class=""> Actual type: IO String</div><div style="margin: 0px;" class=""> In the first argument of ‘lines’, namely ‘f’</div><div style="margin: 0px;" class=""> In the expression: lines f</div><div style="margin: 0px;" class=""><br class=""></div><div style="margin: 0px;" class="">In my simplistic beginners way I think this is because when I run main = do …</div><div style="margin: 0px;" class="">everything is or is within an ‘impure’ area but at ghci command line it is not and I’m mixing pure/impure functions.</div><div style="margin: 0px;" class=""><br class=""></div><div style="margin: 0px;" class="">So my questions are </div><div style="margin: 0px;" class="">1. Is this simplistic view any where near correct? </div><div style="margin: 0px;" class="">2. How can I progress at the command line in ghci?</div><div style="margin: 0px;" class=""><br class=""></div><div style="margin: 0px;" class=""><br class=""></div><div style="margin: 0px;" class="">Many thanks</div><div style="margin: 0px;" class=""><br class=""></div><div style="margin: 0px;" class="">Mike</div><div style="margin: 0px;" class=""><br class=""></div><div style="margin: 0px;" class=""><br class=""></div><div style="margin: 0px;" class=""><br class=""></div><div style="margin: 0px;" class=""><br class=""></div></div></body></html>