tweak transformers
[lambda.git] / monad_transformers.mdwn
index d6a2298..53a1689 100644 (file)
@@ -1,6 +1,7 @@
 [[!toc]]
 
-##Multi-layered monadic boxes##
+Multi-layered monadic boxes
+===========================
 
 So far, we've defined monads as single-layered boxes. Though in the Groenendijk, Stokhof, and Veltman homework, we had to figure out how to combine Reader, State, and Set monads in an ad-hoc way. In practice, one often wants to combine the abilities of several monads. Corresponding to each monad like Reader, there's a corresponding ReaderT **monad transformer**. That takes an existing monad M and wraps Readerish monad packaging around it. The way these are defined parallels the way the single-layer versions are defined. For example, here's the Reader monad:
 
@@ -116,6 +117,15 @@ As best we know, figuring out how a monad transformer should be defined is still
 
 Apart from whose interface is outermost, the behavior of a StateT(Maybe) and a MaybeT(State) will partly coincide. But in certain crucial respects they will diverge, and you need to think carefully about which behavior you want and what the appropriate layering is for your needs. (MORE...)
 
+
+Further Reading
+---------------
+
+*      This is excellent, everyone should read: [Monad Transformers Step by Step](http://www.grabmueller.de/martin/www/pub/Transformers.pdf)
+
+*      Read Part III of [All About Monads](http://web.archive.org/web/20071106232016/haskell.org/all_about_monads/html/introIII.html). This link is to an archived version, the main link to haskell.org seems to be broken. Some but not all of this site has been [absorbed into the Haskell wikibook](http://en.wikibooks.org/wiki/Haskell/Monad_transformers).
+
+
 Tree Monads
 ===========
 
@@ -195,18 +205,10 @@ You have to instead say something like this:
        - : ('_a, int) Tree_monad.m = <abstr>
 
 
-Further Reading
----------------
-
-*      This is excellent, everyone should read: [Monad Transformers Step by Step](http://www.grabmueller.de/martin/www/pub/Transformers.pdf)
-
-*      Read Part III of [All About Monads](http://web.archive.org/web/20071106232016/haskell.org/all_about_monads/html/introIII.html). This link is to an archived version, the main link to haskell.org seems to be broken. Some but not all of this site has been [absorbed into the Haskell wikibook](http://en.wikibooks.org/wiki/Haskell/Monad_transformers).
-
 
 How is all this related to our tree\_monadize function?
 -------------------------------------------------------
 
-
 Recall our earlier definition of `tree_monadize`, specialized for the Reader monad:
 
        let rec tree_monadize (f : 'a -> 'b reader) (t : 'a tree) : 'b tree reader =