This was a fun kata! I opted for using Array as I never used it before.
type alias Model =
{ board : Board
, currentPlayer : Player
}
type Player
= Blank
| X
| O
type alias Board =
{ rows : Array (Array Player)
}
initBoard : Board
initBoard =
{ rows = Array.repeat 3 (Array.repeat 3 Blank)
}
However, an Array of Arrays is not straightforward to update:
updateBoard : Board -> Int -> Int -> Player -> Board
updateBoard board x y p =
let
newRow =
case Array.get y board.rows of
Just aRow ->
Array.set x p aRow
Nothing ->
Array.repeat 3 Blank
in
{ board | rows = Array.set y newRow board.rows }
Sorry for being OT but I just got feeling.
The Ellie: https://ellie-app.com/5pMrgshVx36a1