In the design of Control.Monad.Accum
, I noticed that for a new Monad transformer t
, one typically has to define the instance via LiftingAccum
. However, I believe it would be more straightforward to define an automatic lifting mechanism that traverses the outer Monad transformers.
For instance, consider the following definition:
instance {-# OVERLAPPABLE #-}
(MonadTrans t, Monad m, MonadAccum w m) =>
MonadAccum w (t m) where
accum :: (MonadTrans t, Monad m, MonadAccum w m) => (w -> (a, w)) -> t m a
accum = lift . accum
I think this approach would be more convenient for users who want to adopt a new Monad Transformer (say, LogicT). Is there a reason that precluded the designer of MonadAccum
from adopting this easy implementation?
The implementation was compiled and worked as expected.
user25348842 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.