Hi, A common way to get different "base" monads is to "newtype" existing monads. Here is an example:
newtype CustomMonad a = CM (StateT Int IO a) deriving (Monad)
instance BaseM CustomMonad CustomMonad where inBase = id
... define some custom operations on CustomMonad...
The "newtype" provides an "abstraction barrier", which hides the implementation of the CustomMonad. If you add more layers on top of "CustomMonad" when you use "inBase" it will only lift up to CustomMonad. This is useful if, for example, CustomMonad needs to perform some IO actions, but for one reason or another it does not allow for the execution of arbitrary IO computations. Note that when you are implementing the operations of CustomMonad, you can use "inBase" again, this time to lift all the way down to IO. Basically, by using "newtypes", you can kind of "punctuate" a tall tower of monads, an use "inBase" to jump from one stack to the next. Hope that this helps, -Iavor On Tue, Apr 20, 2010 at 2:45 PM, Evan Laforge <qdunkan@gmail.com> wrote:
I haven't really been following this discussion, but I use Identity-backed monads all the time. Usually some combination of StateT, WriterT, ErrorT and ReaderT.
Are there any "base" monads other than IO and Identity? _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries