<div dir="auto"><div>I see. anyway, my use case is something like this-<div dir="auto"><br></div><div dir="auto">I have two functions</div><div dir="auto">fromFile :: [String] -> [Int]</div><div dir="auto">func :: String -> [Int]</div><div dir="auto"><br></div><div dir="auto">I want to use the "words contents" output and pass each element in it to func and send back [Int] from "fromFile" function (where I originally read the file.)</div><div dir="auto"><br></div><div dir="auto">Could you suggest a better way to do this?</div><div dir="auto"><br></div><div dir="auto">Quoting <span style="font-family:sans-serif">Ian Denhardt</span></div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 27 Mar, 2019, 9:13 AM Ian Denhardt, <<a href="mailto:ian@zenhack.net">ian@zenhack.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It would help to see the complete source file, but I'll hazard a guess<br>
you're doing something like:<br>
<br>
main = do<br>
    contents <- readFile "file.txt"<br>
    words contents<br>
<br>
At the GHCi prompt, each line can be any expression, and GHCi will<br>
evaluate it and then display it. The two lines in your session aren't<br>
really related.<br>
<br>
In contrast, the do block in the source file expects the expression at<br>
the end to be an IO action.<br>
<br>
What do you want your program to do when you get to "words contents"?<br>
display it? (If you want to display it, pass it to `print`).<br>
<br>
Quoting Yugesh Kothari (2019-03-26 23:35:14)<br>
>    Hi,�<br>
>    I am trying to read data from a file.<br>
>    When I do-<br>
>    ghci> contents <- readFile "file.txt"<br>
>    ghci> words contents<br>
>    Then everything works.<br>
>    The same thing when done in a .hs file gives an IO String vs [String]<br>
>    error.<br>
>    Why is that so?<br>
</blockquote></div></div></div>