How can I print the outcome with using main.

Try:
| main :: IO ()
| main = do
| msgs <- testParse parse 10 "error.log"
| print msgs
Your plan is good. GHCi handles IO values specially, for convenience,
which blurs the distinction between values which can be fed to `print`
directly, and those in IO, which need to be bound as above.
On 2015-02-24 at 13:48, Roelof Wobben
Hello,
According to the manual of the CIS 194 course I have to do this in GHCI : testParse parse 10 "error.log" This to test my code.
Now my problem is that I cannot use GHCI because I use Fpcomplete. So I thought I will use main for this :
So I tried this :
main :: IO () main = do print $ testParse parse 10 "error.log"
but then I see this error message :
src/LogAnalysis.hs@39:4-39:9 No instance for (Show (IO [LogMessage])) arising from a use of print … In the expression: print In a stmt of a 'do' block: print $ testParse parse 10 "error.log" In the expression: do { print $ testParse parse 10 "error.log" }
The testparse function looks like this :
-- | @testParse p n f@ tests the log file parser @p@ by running it -- on the first @n@ lines of file @f@. testParse :: (String -> [LogMessage]) -> Int -> FilePath -> IO [LogMessage] testParse parse n file = take n . parse <$> readFile file
Roelof
_______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
participants (2)
-
Daniel Bergey
-
Roelof Wobben