While working on my little game “Indian Chess” (http://indianchess.co/), I decided to share the Game state using firebase for multi player game.

My GameState looks like..

“board” is a Dict with key being Position and value current state of the Cell at Position. Now the problem is key (Position) is not a simple string or integer it’s a tuple with x, y co-ordinates. Elm slack has been very helpful in solving my queries promptly. But this was a very specific problem and it was difficult to state the problem concisely so I was on my own for this.

After Googling for hours and hours, I realized that I needed to convert Dict to some sort of record to be able to convert to and from Json. So I invented CellWrapper and it’s corresponding JSON.

This is how gameStateDecoder/Encoder looks like

Now comes the all important boardDecoder

The trick was to convert Json CellWrappers to Elm dict and use Decode.map.

The game codebase is available at https://github.com/girishso/indian-chess.

Hope this helps someone!