
3 Jul
2010
3 Jul
'10
7:35 p.m.
begin Andrew Coppin quotation:
Roman Cheplyaka wrote:
See above: -- Dynamic components may be retrieved with 'get', static components -- with 'ask'.
So you use ask to get some configuration variable (reader monad is used for configuration in xmonad) and get/put/modify to deal with dynamic state of application. You use liftIO (abbreviated to 'io') to run IO computations.
In other words, somebody has written a combinatorial explosion of class instances to automate some of the lifting.
Well then you need to automate writing the instances too :) The GeneralizedNewtypeDeriving extension can be used to get instances for Monad, MonadReader XConf, MonadState XState, and MonadIO automatically for a newtype like X that should suffice in most cases. -md