Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
MonadState without the function dependency m -> s
.
- class HasState s m where
- getState :: m s
- modifyState :: (s -> s) -> m ()
Documentation
class HasState s m where Source
This class allows you to access bits of the State by type, without knowing exactly what the overall state type is. For example:
typeGraphEdges :: (DsMonad m, MonadReader TypeGraph m, HasState (Set TGV) m, HasState (Map Type (E Type)) m) => ...
This will work as long as the two HasState instances exist for whatever the actual State type is. It still can't reach down into nested StateT monads, you may need to use lift for that.
modifyState :: (s -> s) -> m () Source