haskellvectorhmatrix

Haskell - Type incompatibility after qualified import


I'm using hMatrix and the first lines of my code are:

import Numeric.LinearAlgebra
import qualified Data.Vector as V

The problem is that in my code the vector type is V.Vector, but some methods defined by hMatrix have type Vector -> ... and GHC does not understand when I try to use these methods, saying that they are not defined for the type V.Vector. How can I solve this problem?

Update:

From the documentation of hMatrix:

The Vector type is a Storable vector from Roman Leshchinskiy’s vector package, so all array processing tools provided by this library are directly available.

However, some basic operators like (++) (which is present in Data.Vector.Storable) are not included in hMatrix. Is it impossible to use these from hMatrix or is there some simple way to tell the compiler that these types are the same?


Solution

  • You could add an explicit import for the Vector type:

    import Numeric.LinearAlgebra
    import qualified Data.Vector as V
    import Data.Vector (Vector)
    

    Though, I didn't know external modules could break depending on how you import modules they depend on.