https://wiki.haskell.org/api.php?action=feedcontributions&user=ZongSharo&feedformat=atomHaskellWiki - User contributions [en]2020-10-31T08:44:41ZUser contributionsMediaWiki 1.27.4https://wiki.haskell.org/index.php?title=Monad_tutorials_timeline&diff=30773Monad tutorials timeline2009-10-13T19:55:32Z<p>ZongSharo: fix dead link for "monad transformers step by step"</p>
<hr />
<div>[[Category:History]]<br />
[[Category:Monad]]<br />
[[Category:Tutorials]]<br />
<br />
This timeline covers not just monad tutorials, but interesting events in monad tutorial history. Please update this list! Don't worry about getting dates, authors, blurbs unless you really want to. We can fix it later.<br />
<br />
Older tutorials are especially interesting.<br />
<br />
== before 2000 ==<br />
<br />
* 1992-08 [http://homepages.inf.ed.ac.uk/wadler/papers/marktoberdorf/baastad.pdf Monads for Functional Programming] - Phil Wadler<br />
*: "Shall I be pure or impure?" One of the earliest papers on monads by the man hiself. Has been called the "''ne plus ultra'' of approachable, useful introductions to monads". It's pretty hefty (31 pages), which is a good thing!<br />
* 1999-02 [http://www-users.mat.uni.torun.pl/~fly/materialy/fp/haskell-doc/Monads.html What the hell are Monads?] Noel Winstanley<br />
*: Written when 'what is a monad' started becoming an FAQ. Very short and sweet, advertised as more examples than theory. "Once upon a time, people wrote their Haskell programs by sequencing together operations in an ad-hoc way."<br />
* 1999-Spring [http://www.engr.mun.ca/~theo/Misc/haskell_and_monads.htm Monads for the working Haskell Programmer] - Theodore S. Norvell<br />
*: One of the original tutorials, originally written for Gofer and eventually "updated for Haskell98"<br />
<br />
== year 2002 ==<br />
<br />
* 2002 [http://en.wikibooks.org/wiki/Haskell/YAHT Yet Another Haskell Tutorial] - Hal Daumé III<br />
*: The most recommended Haskell tutorial ever. Not a monad tutorial per se, but it does address the topic<br />
<br />
== year 2003 ==<br />
<br />
* 2003-08 [http://www.haskell.org/all_about_monads/html/ All about Monads] - Jeff Newbern<br />
*: A comprehensive introduction to monads, covering also "advanced" topics like monad transformers and use of some common monads. There is an appendix which presents monads as assembly lines.<br />
<br />
== year 2004 ==<br />
<br />
* 2004-07 [http://www.ccs.neu.edu/home/dherman/research/tutorials/monads-for-schemers.txt A Schemer's Introduction to Monads]<br />
*: "This will be an introduction to monads from a Lisp/Scheme perspective, with the assumption that the reader is comfortable with continuations, CPS, accumulators, and accumulator-passing style."<br />
* 2004-07 [[Monads as Containers]] - Cale Gibbard<br />
*: Presents monads as boxes. Uses <hask>fmap</hask> and <hask>join</hask>. "If you will give me a blueberry for each apple I give you <hask>(a -> b)</hask>, and I have a box of apples <hask>(f a)</hask>, then I can get a box of blueberries <hask>(f b)</hask>."<br />
* 2004-08 [http://sleepingsquirrel.org/monads/monads.html Monads in Perl] - Greg Buchholz<br />
*: Written in the spirit of TMTOWTDI<br />
<br />
== year 2005 ==<br />
<br />
* 2005-07 [http://moonbase.rydia.net/mental/writings/programming/monads-in-ruby/00introduction.html Monads in Ruby] - MenTaLguY<br />
*: Presents monads in a friendly language, starting from Identity and building on up<br />
* 2005-11 [http://www.loria.fr/~kow/monads Of monads and space suits] - Eric Kow<br />
*: Functions are space stations, parameters are astronauts and monads are space suits that let us safely travel from one function to another.<br />
<br />
== year 2006 ==<br />
<br />
* 2006-03 [http://en.wikibooks.org/w/index.php?title=Haskell/Understanding_monads&oldid=933545 Understanding Monads] - Eric Kow<br />
*: Monads as nuclear waste containers, an adaptation of monads as space suits with a new metaphor suggested by Paul Johnson<br />
* 2006-07 [[The Monadic Way]] - Andrea Rossato<br />
*: A two-part tutorial. The first part shows you how build a simple evaluator, and the second part shows you how to "take the complexity" out of it by using techniques such as monad transformers<br />
* 2006-08 [http://sigfpe.blogspot.com/2006/08/you-could-have-invented-monads-and.html You could have invented monads! (and maybe you already have)] - Dan Piponi<br />
*: "Writing introductions to monads seems to have developed into an industry," Dan (sigfpe) observes. He argues that monads are not "something esoteric in need of explanation", but walks you through the process of reinventing monads to solve some very basic and practical problems.<br />
* 2006-09 [[Meet Bob The Monadic Lover]] - Andrea Rossato<br />
*: Bob embarks upon a series of romantic conquests... bind bind bind, Paula, Luisa, Antonia<br />
* 2006-10 [http://www.grabmueller.de/martin/www/pub/Transformers.en.html Monad Transformers Step by Step] - Martin Grabmüller<br />
** Monad transformers are rarely covered in introductory tutorials. This "is not a paper about implementing transformers, but about using them to write elegant, clean and powerful programs in Haskell". Available as a 12 page PDF or .lhs file.<br />
* 2006-11 [http://www.haskell.org/pipermail/haskell-cafe/2006-November/019190.html There's a Monster in my Haskell!] Andrew Pimlott<br />
*: This delightful "tutorial" presents monads as monsters which devour values, use them to feed other monsters and regurgitate them when slain.<br />
* 2006-12 [http://blog.tmorris.net/maybe-monad-in-java/ Maybe Monad in Java] - Tony Morris<br />
*: Monads can also be useful in Java!<br />
<br />
== year 2007 ==<br />
<br />
* 2007-01 [http://koweycode.blogspot.com/2007/01/think-of-monad.html Think of a monad] - Don Stewart (reposted on Eric Kow's blog)<br />
*: Don integrates some pre-existing monadic metaphors, shedding light on monads in a truly comprehensive manner (illustration by Eric)<br />
* 2007-02 [http://kawagner.blogspot.com/2007/02/understanding-monads-for-real.html Understanding Monads. For Real] - Karsten Wagner<br />
*: A monad is like a macro<br />
* 2007-04 [http://saxophone.jpberlin.de/MonadTransformer?source=http%3A%2F%2Fwww%2Ehaskell%2Eorg%2Fhaskellwiki%2FCategory%3AMonad&language=English The Real Monad Transformer] - Henning Thielemann<br />
*: Not a tutorial either, but an important aid in demystifying monads<br />
* 2007-03 [http://www.randomhacks.net/articles/2007/03/12/monads-in-15-minutes Monads in 15 Minutes] - Eric Kidd<br />
*: Eric boils monads down to 15 minutes, using backtracking and Maybe as motivating examples. Eric uses <hask>join</hask>, which seems quite rare for monad tutorials (cf Cale's ''Monads as containers'')<br />
* 2007-07 [http://ahamsandwich.wordpress.com/2007/07/26/monads-and-why-monad-tutorials-are-all-awful/ Monads! (and why monad tutorials are all awful)] - Colin Gordon?<br />
*: Csgordon reports that monad tutorials tend to "get horribly botched" and says "[they] either bored me to tears, struck me as completely inane, or simply confused me". He uncovers the early Phil Wadler's paper, ''Monads for Functional Programming'', which not only gives a clear explanation but provides ''non-trivial'' motivating examples<br />
* 2007-08 [[Monads as computation]] - Cale Gibbard<br />
*: A very straightforward presentation of monads. Notable for its "The whole point" section, which conveys why we bother with all this monad business.<br />
* 2007-08 [http://en.wikibooks.org/wiki/Haskell/Understanding%20monads Understanding Monads] (2) - Apfelmus<br />
*: Wikibook rewrite of the original monads tutorial. Less fluff, more pedagogy. [In progress at the time of this writing].<br />
* 2007-08 [[Monad (sans metaphors)]] - Claus Reinke<br />
*: From a discussion about monad tutorials on Haskell Café (the name is due to haskellwiki user 'Green tea').<br />
<br />
== year 2008 ==<br />
* 2008-06 [http://spbhug.folding-maps.org/wiki/Monads Monads] (in Russian) and [http://spbhug.folding-maps.org/wiki/MonadsEn Monads] (in English) - Yet another monad tutorial, by Eugene Kirpichov; fairly advanced but skips monad transformers. Oriented towards a broader understanding of monads than just IO and Maybe.<br />
<br />
== year 2009 ==<br />
* 2009-01 [http://byorgey.wordpress.com/2009/01/12/abstraction-intuition-and-the-monad-tutorial-fallacy/ Abstraction, intuition, and the “monad tutorial fallacy”] Not a monad tutorial itself, but a comment on monad tutorials and why many of them are so unhelpful.</div>ZongSharohttps://wiki.haskell.org/index.php?title=Concurrency&diff=25196Concurrency2008-12-24T03:23:36Z<p>ZongSharo: fixing dead link</p>
<hr />
<div>[[Category:GHC|Concurrency]]<br />
== Concurrent programming in GHC ==<br />
<br />
This page contains notes and information about how to write concurrent programs in GHC.<br />
<br />
Please feel free to add stuff here (Edit page link at the bottom).<br />
<br />
=== Starting points ===<br />
<br />
* '''Basic concurrency: forkIO and MVars'''. Read [http://research.microsoft.com/Users/simonpj/papers/marktoberdorf/marktoberdorf.ps.gz Tackling the awkward squad: monadic input/output, concurrency, exceptions, and foreign-language calls in Haskell].<p>The [http://www.haskell.org/ghc/docs/papers/concurrent-haskell.ps.gz original paper about Concurrent Haskell] contains quite a few examples about how to write concurrent programs. A larger example is [http://www.haskell.org/~simonmar/papers/web-server.ps.gz Writing High-Performance Server Applications in Haskell, Case Study: A Haskell Web Server]<br />
</p><br />
* '''Software Transactional Memory''' (STM) is a new way to coordinate concurrent threads. There's a separate [[Software transactional memory|Wiki page devoted to STM]].<br />
: STM was added to GHC 6.4, and is described in the paper [http://research.microsoft.com/~simonpj/papers/stm/index.htm Composable memory transactions]. The paper [http://research.microsoft.com/~simonpj/papers/stm/lock-free.htm Lock-free data structures using Software Transactional Memory in Haskell] gives further examples of concurrent programming using STM.<br />
<br />
* '''Foreign function interface'''. If you are calling foreign functions in a concurrent program, you need to know about ''bound threads''. They are described in a Haskell workshop paper, [http://research.microsoft.com/~simonpj/Papers/conc-ffi/index.htm Extending the Haskell Foreign Function Interface with Concurrency]. The GHC Commentary [http://darcs.haskell.org/ghc/docs/comm/rts-libs/multi-thread.html Supporting multi-threaded interoperation] contains more detailed explanation of cooperation between FFI calls and multi-threaded runtime.<br />
<br />
* '''Nested Data Parallelism'''. For an approach to exploiting the implicit parallelism in array programs for multiprocessors, see [[GHC/Data Parallel Haskell|Data Parallel Haskell]] (work in progress).<br />
<br />
<br />
=== Using concurrency in GHC ===<br />
<br />
* You get access to concurrency operations by importing the library [http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Concurrent.html Control.Concurrent].<br />
<br />
* The GHC manual gives a few useful flags that control scheduling (not usually necessary) [http://www.haskell.org/ghc/docs/latest/html/users_guide/sec-using-parallel.html#parallel-rts-opts RTS options].<br />
<br />
<br />
=== Multiprocessor GHC ===<br />
<br />
As of version 6.5, GHC supports running programs in parallel on an SMP or multi-core machine. How to do it:<br />
<br />
* You'll need to get a version of GHC that supports SMP. Either download a [http://www.haskell.org/ghc/dist/current/dist nightly snapshot distribution], or [http://hackage.haskell.org/trac/ghc/wiki/GhcDarcs get the sources] from darcs and build it yourself.<br />
<br />
* You need to link your program using the <tt>-threaded</tt> switch. (NOTE: previously it was necessary to compile all code, including libraries, with the <tt>-smp</tt> switch, this is no longer the case. The <tt>-smp</tt> flag is now a synonym for <tt>-threaded</tt>).<br />
<br />
* Run the program with <tt>+RTS -N2</tt> to use 2 threads, for example. You should use a <tt>-N</tt> value equal to the number of CPU cores on your machine (not including Hyper-threading cores).<br />
<br />
* Concurrent threads (<tt>forkIO</tt> and <tt>forkOS</tt>) will run in parallel, and you can also use the <tt>par</tt> combinator and Strategies from the [http://www.haskell.org/ghc/docs/latest/html/libraries/base/Control-Parallel-Strategies.html Control.Parallel.Strategies] module to create parallelism.<br />
<br />
* Use <tt>+RTS -sstderr</tt> for timing stats.<br />
<br />
=== Links to related work on parallel and distributed Haskell (many based on GHC) ===<br />
<br />
* [http://www.macs.hw.ac.uk/~dsg/gph/ Glasgow Parallel Haskell]<br />
* [http://www.macs.hw.ac.uk/~dsg/gdh/ Glasgow Distributed Haskell]<br />
* http://www-i2.informatik.rwth-aachen.de/~stolz/dhs/<br />
* http://www.informatik.uni-kiel.de/~fhu/PUBLICATIONS/1999/ifl.html<br />
* [http://www.mathematik.uni-marburg.de/~eden Eden]<br />
<br />
== Problems with GHC implementation before 6.6.1 ==<br />
<br />
There are critical differences between the description in the paper<br />
"Asynchronous exceptions in Haskell by Simon Marlow, Simon Peyton<br />
Jones, Andy Moran and John Reppy, PLDI'01." the implementation in GHC<br />
6.4 and GHC 6.6 today.<br />
<br />
Some of the bad effects are described here under<br />
[[GHC/Concurrency/Flaws|throwTo & block statements considered<br />
harmful]].<br />
<br />
The versions of GHC from 6.6.1 and up have fixed the problematical difference.<br />
<br />
----</div>ZongSharo