I am trying to make a boardgame score calculator that supports multiple games. I have managed to make a usable UI for a single toy example game, and I am stuck on generalising Main.elm
to work with different Player
records for different games.
The code is here: https://gitlab.com/aidalgol/elm-tabletop-scoreboard/
I tried adding a second Player
module and renaming both to be named after the game (like ToyGame
and AnotherGame
), importing them in Main.elm
without the exposing
part, and defining a Player
type in Main.elm
as type Player = ToyGame.Player | AnotherGame.Player
, but that’s not valid in Elm.
Should I even be trying to generalise my Main
module in this case, or should I approach this by making each game scorer a separate page and refactoring code into common modules as duplicate emerges?