hello everyone I have this function in haskell that let me extract a Repa array from bitmap grayScale
readImageFromBMPa
:: FilePath
-> IO (Either Error (Array U DIM2 ( Word8)))
{-# NOINLINE readImageFromBMPa #-}
readImageFromBMPa filePath
= do ebmp <- readBMP filePath
case ebmp of
Left err -> return $ Left err
Right bmp
-> do arr <- readImageFromBMPPrime bmp
return $ Right arr
I searched on way to extract a vector from this function output I I found toUnboxed Function like this
let a = Prelude.map (\(v) -> toUnboxed (readImageFromBMPa v))(fst ns)
I get the following error • Couldn't match expected type ‘Array U sh0 e’ with actual type ‘IO (Either Error (Array U DIM2)
is there a way I can do the conversion thanks
As the error says, type passed to
toUnboxed
is wrong. TypeArray U DIM2
you want is wrapped byIO a
monad andEither a b
monad. It needs to peel off them in order to deal with the content. This sample is same problem.