Failed to match expected type `Int 'with actual type` m0 Int'

I am currently trying to learn Haskell. Next function:

findPivot :: [[Double]] -> Int
findPivot matrixA =
    do
        let firstCol = (transpose(matrixA)!!0)
        let maxColValue = maximum firstCol
        let pivotIndex = elemIndex maxColValue firstCol
        return (fromJust(pivotIndex))

It is intended to take a 2D doubling list, representing the matrix, and determine which row has the maximum value in the first column. I know that there are some inefficient parts, for example, using a list to represent the matrix and using transpose, but the problem I am facing is related to the following compiler error:

Couldn't match expected type `Int' with actual type `m0 Int'
In the return type of a call of `return'
In a stmt of a 'do' block: return (fromJust (pivotIndex))
In the expression:
  do { let firstCol = (transpose (matrixA) !! 0);
       let maxColValue = maximum firstCol;
       let pivotIndex = elemIndex maxColValue firstCol;
       return (fromJust (pivotIndex)) }

I'm not sure what it means m0, but I guess it means monadic. So, I think this means that the function returns a monadic int. Any help in understanding this problem and solving it will be greatly appreciated.

Thank.

+4
1

do return . , , .

. , . .

let do, sytax

findPivot matrixA = 
            let 
                firstCol = (transpose(matrixA)!!0)
                maxColValue = maximum firstCol
                pivotIndex = elemIndex maxColValue firstCol
            in fromJust(pivotIndex)
+6

All Articles