I have a monadic function which returns a user id:
do
id <- getUserId
I need to be able to "superimpose", on getUserId, a function which looks up, and returns, an alias to the value returned by getUserId
Clearly I could write a specific function getAlias and rewrite the monad itself:
do
id <- getAlias getUserId
However I feel that this can be done more generally, reusably and invisibly, by hiding getAlias in the bind function of a monad.
Do Monad Transformers perform this function, i.e. composing the bind function of the inner monad with a bind function of the outer monad? Or do I need some other control structure here?
getAlias
is doing? I don't think monad transformers are going to be helpful here, but it's hard to tell exactly what to suggest instead without a bit more information. – Daniel WagnergetUserId
andgetAlias
it will be very helpful, for example. – Chris Taylor