Marc Poppleton wrote: get :: Int Int (Mat Int) -> Int get 0 _ _= ? <- How can I return nothing or better an error? get x y mat= nth y (nth x mat) You can replace ? by undef or by abort "any string" where you can include a meaningful message in the string, that will be displayed when the program runs into the error case.