Background: I'm creating a game with a stateful monad for reading and writing changes to the global state of the game.
I would like to divide my game into components, such as "Characters", providing a domain specific way for these components to interact with the global state. Ideally this might be define specific actions of the form MonadState Character m => m a
that I could use, but each such m a
would enact changes on the parent (global state).
I've searched around for converting between state monads, or providing an interface from one state monad to another, but the specific language for this is beyond my scope of knowledge. I am also already using Lenses, and I'm wondering if I can do something with them.
EDIT:
I'd like to be able to do something like
moveCharacter :: MonadState Character m => Int -> Int -> m ()
and have that perform move :: MonadState World m => Int -> Int -> m ()
inside. Basically, abstracting the world specifics away from the character.
Thanks!