[Haskell-cafe] How to convert from "IO String" to String

Dmitri Pissarenko mailing-lists at dapissarenko.com
Tue Jan 25 14:20:36 EST 2005


Hello!

Thanks for your answer!

> You probably want something like...
>
> l = [0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0, 255, 255, 255, 255, 0]
> testConvertToList01 = do img <- readImage "../data-test/diagonalImage.pgm"
>                          return $ TestCase $ assertEqual "" l 
> (convertToList img)

When I use this test case definition, I'm getting an error when constructing
the test suite:

tests = TestList [testCommentLine01, testCommentLine02, testConvertToList01]

GHCi writes

TestLik.hs:22:
     Couldn't match `Test' against `IO Test'
         Expected type: Test
         Inferred type: IO Test
     In the list element: testConvertToList01
     In the first argument of `TestList', namely
         `[testCommentLine01, testCommentLine02, testConvertToList01]'

Best regards

Dmitri Pissarenko
--
Dmitri Pissarenko
Software Engineer
http://dapissarenko.com



More information about the Haskell-Cafe mailing list