On 06/17/2011 10:00 AM, Dmitri O.Kondratiev wrote:
Hi,
I try to parse csv file with Text.CSV, like this:

import Text.CSV
import System

main = do
     [inpFileName] <- getArgs
     putStrLn ("Parsing "++inpFileName++"...")
     let result = parseCSVFromFile inpFileName
     print result


=== As a result I get:

 No instance for (Show
                    (IO (Either Text.Parsec.Error.ParseError CSV)))
   arising from a use of `print'
 Possible fix:
   add an instance declaration for
   (Show (IO (Either Text.Parsec.Error.ParseError CSV)))

=== Question:
How to add a Show instance for "(IO (Either Text.Parsec.Error.ParseError 
CSV)))" ?
Hi Dmitri,

you don't add a show instance for IO, but you "unwrap" the IO Monad first and then show the result.

let result = parseCSVFromFile inpFileName

should be:

result <- parseCSVFromFile inpFileName

--
Vincent

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to