[Haskell-cafe] Getting an attribute of an object

Dmitri Pissarenko mailing-lists at dapissarenko.com
Sun Feb 13 04:16:16 EST 2005


Hello!

Thanks for your answer!

> Perhaps try:
>
> do ...
>    ciwd <- sequence classifiedImagesWithData
>    let allImages = (getImages ciwd)
>    ...
>
> as it seems like you're trying to gave getImages act on a value of
> type [IO (ClassifiedImage, Image)]. Applying sequence to
> classifiedImagesWithData will turn it into an IO [(ClassifiedImage,
> Image)] by doing the natural thing, from which you can pull out the
> list to apply getImages to.

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).
--
Dmitri Pissarenko
Software Engineer
http://dapissarenko.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ExperimentalYaleFaceDb.hs
Type: text/x-haskell
Size: 2785 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20050213/eb678bae/ExperimentalYaleFaceDb.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Lik.hs
Type: text/x-haskell
Size: 3666 bytes
Desc: not available
Url : http://www.haskell.org//pipermail/haskell-cafe/attachments/20050213/eb678bae/Lik.bin


More information about the Haskell-Cafe mailing list