[Haskell-cafe] Getting an attribute of an object
Jules Bean
jules at jellybean.co.uk
Fri Feb 11 14:47:28 EST 2005
On 11 Feb 2005, at 19:09, Dmitri Pissarenko wrote:
> 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
> Inferred type: IO (ClassifiedImage, Image)
>
Well, can you explain why you are using do notation at all?
In do notation, the <- form, informally speaking, 'strips off' a Monad.
Because the type of readClassifiedImages is a list, then haskell knows
you are using the list Monad, so the effect is to work within the list
Monad.
It may be you'd profit from reading some of the Monad tutorials out
there.
Jules
More information about the Haskell-Cafe
mailing list