GHCi shows result of (IO a) only if (a) is in class Show

I wrote a parser and it took me a while to realize why GHCi suddenly did not show any result nor an error message anymore. My parsing function has type (IO Expression), Expression is in class Show. After changing the parser to (IO Declaration), it did not show anything anymore, because Declaration was not in class Show. When I typed (parseFile "input.txt" >>= print), I got the error message and understood what was going on. But for I while I was really confused what's happening. Just wanted to share this. Best, Daniel

If something can't be shown (converted to a string), then it can't be
printed (as a string).
On 25 April 2015 at 17:51, Daniel van den Eijkel
I wrote a parser and it took me a while to realize why GHCi suddenly did not show any result nor an error message anymore.
My parsing function has type (IO Expression), Expression is in class Show.
After changing the parser to (IO Declaration), it did not show anything anymore, because Declaration was not in class Show.
When I typed (parseFile "input.txt" >>= print), I got the error message and understood what was going on. But for I while I was really confused what's happening.
Just wanted to share this.
Best, Daniel _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
-- Regards Sumit Sahrawat
participants (2)
-
Daniel van den Eijkel
-
Sumit Sahrawat, Maths & Computing, IIT (BHU)