0

hello guys I am beginner in haskell and I am trying to get a vector from Bmp image and I am using this function bellow

readMatrixfromImage :: FilePath -> IO [Double]
readMatrixfromImage image = do 
       x <- readImageFromBMPa image -- 'x' est alors de type t
       let (Right r) = x
       let a = toUnboxed r
       let b = U.toList a
       let b' = Prelude.map (\v -> (fromIntegral v :: Double)/255.0  - 1)  b
       let c = Prelude.map abs b'
       return c

but I get this following error, this code works fine in different machine. so Im guessing it is about library versions, thank you in advance

    • Couldn't match expected type ‘Vector a’
                  with actual type ‘vector-0.12.1.2:Data.Vector.Unboxed.Base.Vector
                                      Word8’
      NB: ‘vector-0.12.1.2:Data.Vector.Unboxed.Base.Vector’
            is defined in ‘Data.Vector.Unboxed.Base’
                in package ‘vector-0.12.1.2’
          ‘Vector’
            is defined in ‘Data.Vector.Unboxed.Base’
                in package ‘vector-0.12.2.0’
    • In the first argument of ‘U.toList’, namely ‘a’
      In the expression: U.toList a
      In an equation for ‘b’: b = U.toList a
    • Relevant bindings include b :: [a] (bound at Tools.hs:124:12)
    |
124 |        let b = U.toList a
    |                         ^
Winssen
  • 53
  • 5
  • 2
    Huh, weird error to get. What package manager are you using? And could you edit your `.cabal` (or `package.yaml`) file into your question, if you have one? – bradrn Feb 04 '21 at 12:39
  • 1
    Yeah, this clearly looks like you have two mismatching versions of the `vector` package installed. Cabal and Stack normally prevent this from happening, but Cabal isn't always successful. If you explicitly depend on them it should work fine though. – leftaroundabout Feb 04 '21 at 13:20

1 Answers1

0

as leftaroundabout and brad explained it turned out I had two versions of Vector caused by installing repa library first I deleted one and it works just fine.

Winssen
  • 53
  • 5