Imagine in a game, I have to manage the states of several entities. A typical way of managing one state is to:
data WorldState = WorldState {
temperature :: Double,
season :: Season
}
newtype App a = App {
unApp :: StateT WorldState IO a
} deriving (Functor, Applicative, Monad, MonadState WorldState, MonadIO)
What about when I have to manage several states, ex: I have a character state:
data PersonState = PersonState {
name :: String,
age :: Int,
clothing :: ClothingStyle
}
Do I have to create a wrapped version with newtype for each state? What if all those states inter-connect with each other? How can I update one state according to the information of other states? For example, I want to update a person's clothingstyle according to the world status of temperature.
Or should I just create one gigantique state that includes all possible states together?