I am writing a board game in PureScript that involves a matrix of exact size 2x7 (in certain variations it can be 4x7). The package I’m using has a Matrix.getRow
function that returns a Maybe (Array a)
.
What is the best approach to not have to deal with Maybe
returns when I know for sure that Matrix.getRow 0
is always going to return the first row (because the matrix is of fixed size 2x7)?
Currently I have ugly code to deal with Maybes which is obviously not very desirable:
notPossible :: Array Cell
notPossible = [99, 99, 99, 99, 99, 99, 99] -- never used
row n = fromMaybe notPossible $ Matrix.getRow n state.cells