This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hi there. I'm currently building a board game (backgammon) with ocaml-vdom, an OCaml implementation of the Elm architecture. Because that's still a very small project, I'm hoping my question might translate here.
I'm trying to figure out how my update function should look when when working with messages that only arise in a given state of the app. For example, say the possible states include:
- Before the game, when users are still choosing which color to play as
- During the game
- After the game, when somebody has won
During the game, one message that can arise looks something like Move (source, destination)
. In states (1) and (3), however, this message should never arise, nor is there any meaningful update that could be applied. So I end up having to write boilerplate where I do nothing (or assert false) if the message is sent in one of these states.
Is there a standard/idiomatic way of handling this type of situation? I'm having trouble even figuring out how I could Google it. One thing that looks possibly applicable is the tutorial section on composing, where I could break up messages into a sum type of BeforeGameMessage
, GameMessage
, etc. But I wanted to make sure I'm on the right track, since this is unfamiliar territory for me.
Any help is appreciated, and thanks in advance.
Subreddit
Post Details
- Posted
- 6 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/elm/comment...