Closed bucklereed closed 3 years ago
We should definitely add instances for AccumT
and SelectT
.
As far as how AccumT
's instances should work, I'm not sure. @fizruk had proposed in #32 that we introduce a new type class for things that can support AccumT
's operations (MonadAccum
?), but it's not clear to me what its relationship with MonadWriter
/MonadState
would be.
I think there are enough design questions here that it would be beneficial to draft up a sketch of how this would work and propose it to the Haskell libraries mailing list for feedback.
I think that AccumT
should propagate MonadReader
, MonadWriter
and MonadState
to inner monad and that we should introduce MonadAccum
. This would be consistent with how other classes and transformers work.
@fizruk, that sounds reasonable to me. But the design of these Monad-
classes are usually more involved than one would initially believe (at least in my experience), so I think it would help to come up with a concrete design and propose it to the mailing list. If the community likes it, I'll accept a PR which implements it.
I'm also leaning towards adding MonadAccum and the like.
I just got bitten by the lack of a MonadError
instance for AccumT
.
See also #38
This is resolved in master, pending 2.3 release
Control.Monad.Trans.Accum was added in transformers 0.5.3.0, but currently it's slightly painful to use because it doesn't have the usual MonadState, MonadReader, etc instances yet.
Whether it should get a MonadWriter instance that lifts the operations to the inner monad or handles them itself is a question.
SelectT was also added in transformers 0.5.3.0 and similarly lacks instances.