title: Anatomy of a monad transformer
body: <p>I'm trying to learn monad transformers, based on the standard Haskell libraries (mtl?  transformers?  not sure which one came with my download of the Haskell platform - 7.4.1).</p>
  
  <p>What I believe I've noticed is a common structure for each monad transformer definition:</p>
  
  <ol>
  <li><p>base type ('Base')</p>
  
  <ul>
  <li>Monad instance</li>
  </ul></li>
  <li><p>transformer type ('BaseT')</p>
  
  <ul>
  <li><p>Monad instance</p></li>
  <li><p>MonadTrans instance</p></li>
  <li><p>MonadIO instance</p></li>
  </ul></li>
  <li><p>transformer class ('MonadBase')</p>
  
  <ul>
  <li><p>some operations</p></li>
  <li><p>instances for other 'BaseT's</p></li>
  </ul></li>
  </ol>
  
  <p>So for example, for the Writer monad, there'd be:</p>
  
  <ul>
  <li>a Writer datatype/newtype/type, with a Monad instance</li>
  <li>a WriterT datatype/newtype/type, with Monad, MonadTrans, and MonadIO instances</li>
  <li>a MonadWriter class, and instances of this class for StateT, ReaderT, IdentityT, ...</li>
  </ul>
  
  <p>Is this how monad transformers are organized?  Am I missing anything/do I have any incorrect details?</p>
  
  <p>The motivation for this question is figuring out:</p>
  
  <ol>
  <li>what the relationships and differences are between the "BaseT"s and the corresponding "MonadBase"s and "Base"s</li>
  <li>whether all three are required</li>
  <li>how MonadTrans is related and what its purpose is</li>
  </ol>