
On 10/26/2011 03:29 PM, Daniel Fischer wrote:
On Wednesday 26 October 2011, 16:23:20, Hugo Ferreira wrote:
Hello,
Apologies for this newbie question. I have a test function:
testLearnRules train = do h<- IO.openFile train IO.ReadMode c<- IO.hGetContents h let proposedRules = instRules $ words c let rs = take 10 $ M.assocs proposedRules let _ = show rs -- let _ = length rs return ()
I realize that nothing is executed due to Haskell's lazy evaluation. How can I force show to print something to the screen?
You can't force show to rpint something, since show is a pure function not involving IO. However, testLearnRules does involve IO, so instead of
let _ = show rs
you could simply print it out,
print rs
-- equivalently, putStrLn (show rs)
Thank you, Hugo F.
Appreciate any pointers,
TIA, Hugo F.