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.

 - Cale

On Sat, 12 Feb 2005 21:10:31 +0100, Dmitri Pissarenko
<[EMAIL PROTECTED]> wrote:
> Hello!
> 
> Sorry that I bother you again with my problem.
> 
> > It may be you'd profit from reading some of the Monad tutorials out there.
> 
> I followed your advice and read the "All about monads" tutorial. After I've
> done
> that I could fix one problem.
> 
> But now there is another one.
> 
> In the main program, there is following piece of code
> 
> <code-snippet>
> let classifiedImagesWithData = ((return trainingSet) >>= readClassifiedImages)
> 
> let allImages = (getImages classifiedImagesWithData)
> </code-snippet>
> 
> Signatures of readClassifiedImages and getImages are
> 
> readClassifiedImages :: [ClassifiedImage] -> [IO (ClassifiedImage, Image)]
> getImages :: [(ClassifiedImage, Image)] -> [Image]
> 
> readClassifiedImages does some file I/O, so it is OK when its result is in the
> IO monad.
> 
> getImages does not do any IO related stuff, so I declared it without the IO
> monad.
> 
> The line
> 
> let allImages = (getImages classifiedImagesWithData)
> 
> of the above code snippet leads to following error:
> 
> <error>
> ExperimentalYaleFaceDb.hs:43:
>      Couldn't match
>          `(ClassifiedImage, Image)' against `IO (ClassifiedImage, Image)'
>          Expected type: [(ClassifiedImage, Image)]
>          Inferred type: [IO (ClassifiedImage, Image)]
>      In the first argument of `getImages', namely
>          `classifiedImagesWithData'
>      In the definition of `allImages':
>          allImages = (getImages classifiedImagesWithData)
> Failed, modules loaded: TestLik, Lik, HUnit, HUnitText, HUnitBase, HUnitLang.
> </error>
> 
> Is there a way to fix this problem apart from changing signature of getImage?
> 
> Thanks in advance
> 
> Dmitri Pissarenko
> --
> Dmitri Pissarenko
> Software Engineer
> http://dapissarenko.com
> 
> _______________________________________________
> Haskell-Cafe mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to