[Haskell-cafe] Getting an attribute of an object

Daniel Fischer daniel.is.fischer at web.de
Sun Feb 13 09:16:16 EST 2005


Am Sonntag, 13. Februar 2005 10:16 schrieb Dmitri Pissarenko:
> Hello!
>
> Thanks for your answer!
>
> I've tried that and wrote
>
> <code-snippet>
> do...
> let classifiedImagesWithData = ((return trainingSet) >>=
> readClassifiedImages) ciwd <- (sequence classifiedImagesWithData)
> let allImages = (getImages ciwd)
> </code-snippet>
>
> Now, I get the error
>
> <error>
> Compiling ExperimentalYaleDb ( ExperimentalYaleFaceDb.hs, interpreted )
>
> ExperimentalYaleFaceDb.hs:41:
>      Couldn't match `[]' against `IO'
>          Expected type: [[a]]
>          Inferred type: [IO (ClassifiedImage, Image)]
>      In the first argument of `sequence', namely
>          `classifiedImagesWithData'
>      In a 'do' expression: ciwd <- (sequence classifiedImagesWithData)
> Failed, modules loaded: TestLik, Lik, HUnit, HUnitText, HUnitBase,
> HUnitLang. </error>
>
> at line
>
> ciwd <- (sequence classifiedImagesWithData)
>
> Are there any other options?
>
> Thanks in advance
>
> Dmitri Pissarenko
>
> PS: Maybe the error is rooted in code parts other than those given here. In
> the attachment there is the code of the main program
> (ExperimentalYaleFaceDb.hs) and the function definitions (Lik.hs).

The error is in the code line above, you can't write
trainingSet :: [ClassifiedImage]
by itself in a do statement.

With -fglasgow-exts, you could write
let (trainingSet :: [ClassifiedImage]) = ...,
though there's no need for this type signature.

Thus, ghci had no more complaints.
> --
> Dmitri Pissarenko
> Software Engineer
> http://dapissarenko.com

HTH,
Daniel



More information about the Haskell-Cafe mailing list