I'm digging deeper into Yesod's monads, and have encountered MonadBaseControl
.
I took a look at the hackage doc, and got lost. Could someone tell me the problem it is trying to solve?
It comes from the package monad-control, and is one of a pair of type classes (the other one being MonadTransControl) that enhance MonadBase (resp. MonadTrans) by supporting an alternative As the package documentation states, this enhancement, along with the rest of the contents of these type classes, allow you to lift functions like As a result, the set of monads (resp. monad transformers) that can be used with MonadBaseControl (resp. MonadTransControl) is a strict subset of the set of monads that can be used with MonadBase (resp. MonadTrans), but the former groups are much more powerful than the latter for the same reason. |
||||
|
Michael Snoyman actually wrote a small tutorial on monad-control: http://www.yesodweb.com/book/monad-control The gist of that article might be the following: Imagine you have this piece of code:
You can apply
|
||||
|
IO
-based functions. For example, usingMonadBaseControl
you can write a piece of code that runs inside a complexIO
-based monad stack, and callfork
inside that stack, transferring whatever context the monad has into the forked thread as well. – Petr Pudlák May 13 '14 at 19:26