From Rabhi's & Lapalme's  book 'Algorithms - A Functional Programming Approach' 1999, I'm getting a non-exhaustive pattern match

weight x y g = w where (Just w) = g!(x,y)

I can't figure out why