[Haskell-cafe] Getting an attribute of an object
Dmitri Pissarenko
mailing-lists at dapissarenko.com
Fri Feb 11 14:09:05 EST 2005
Hello!
I could now find the place, where an error occurs.
In my program, I have following statement:
do ...
classifiedImagesWithData <- (readClassifiedImages trainingSet)
readClassifiedImages is defined as follows:
readClassifiedImages :: [ClassifiedImage] -> [IO (ClassifiedImage, Image)]
readClassifiedImages classifiedImages = (map readClassifiedImagesSelector
classifiedImages)
When I load the file with the definition of this function into GHCi and then
type in ":t readClassifiedImages", I get the output
readClassifiedImages :: [ClassifiedImage] -> [IO (ClassifiedImage, Image)]
which is what I want.
However, when in the program I insert the statement
classifiedImagesWithData :: [IO (ClassifiedImage, Image)]
so that it becomes
do ...
classifiedImagesWithData <- (readClassifiedImages trainingSet)
classifiedImagesWithData :: [IO (ClassifiedImage, Image)] -- error line
I get the error
<error>
ExperimentalYaleFaceDb.hs:28:
Couldn't match
`[IO (ClassifiedImage, Image)]'
against
`IO (ClassifiedImage, Image)'
Expected type: [IO (ClassifiedImage, Image)]
Inferred type: IO (ClassifiedImage, Image)
When checking the type signature of the expression:
classifiedImagesWithData :: [IO (ClassifiedImage, Image)]
In a 'do' expression:
classifiedImagesWithData :: [IO (ClassifiedImage, Image)]
</error>
Line 28 is the line marked with "error line" in the code snippet above.
I don't understand why this typing error occurs even though the
readClassifiedImages definition seems to be correct (at least, GHCi loads the
file, where it is located without complaints).
Any hint is highly appreciated.
Best regards
Dmitri Pissarenko
--
Dmitri Pissarenko
Software Engineer
http://dapissarenko.com
More information about the Haskell-Cafe
mailing list