<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: A monad tutorial for Clojure programmers (part 3)</title>
	<atom:link href="http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/feed/" rel="self" type="application/rss+xml" />
	<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/</link>
	<description>A blog about everything Clojure</description>
	<lastBuildDate>Sat, 06 Mar 2010 22:25:19 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Protecting mutable state in the state monad &#171; On Clojure</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-58</link>
		<dc:creator>Protecting mutable state in the state monad &#171; On Clojure</dc:creator>
		<pubDate>Wed, 24 Jun 2009 16:21:46 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-58</guid>
		<description>[...] mutable state in the state&#160;monad Filed under: Uncategorized &#8212; khinsen @ 4:19 pm   In part 3 of my monad tutorial for Clojure programmers, I explained that the main purpose of the state monad [...]</description>
		<content:encoded><![CDATA[<p>[...] mutable state in the state&nbsp;monad Filed under: Uncategorized &#8212; khinsen @ 4:19 pm   In part 3 of my monad tutorial for Clojure programmers, I explained that the main purpose of the state monad [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Levin</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-56</link>
		<dc:creator>Tim Levin</dc:creator>
		<pubDate>Wed, 17 Jun 2009 19:39:13 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-56</guid>
		<description>I think that ease of understanding monadic code is a key issue, which is distinct from &quot;ease of use&quot; (for the programmer).   For code that MUST be understood in detail by others (e.g., in situations requiring high assurance of security policy enforcement), macros and new language features that make the semantics of monads more explicit, and thus clearer, can be very helpful.  One man&#039;s clutter is another man&#039;s key, I suppose, but in my view, the use of raw monads and related transformers is problematic in high assurance environments, especially when combined with implicit typing.</description>
		<content:encoded><![CDATA[<p>I think that ease of understanding monadic code is a key issue, which is distinct from &#8220;ease of use&#8221; (for the programmer).   For code that MUST be understood in detail by others (e.g., in situations requiring high assurance of security policy enforcement), macros and new language features that make the semantics of monads more explicit, and thus clearer, can be very helpful.  One man&#8217;s clutter is another man&#8217;s key, I suppose, but in my view, the use of raw monads and related transformers is problematic in high assurance environments, especially when combined with implicit typing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: A monad tutorial for Clojure programmers (part 2) &#171; On Clojure</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-32</link>
		<dc:creator>A monad tutorial for Clojure programmers (part 2) &#171; On Clojure</dc:creator>
		<pubDate>Fri, 24 Apr 2009 16:14:37 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-32</guid>
		<description>[...] part 3, I will come back to the :when clause in for loops, and show how it is implemented and generalized [...]</description>
		<content:encoded><![CDATA[<p>[...] part 3, I will come back to the :when clause in for loops, and show how it is implemented and generalized [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Samuel A. Falvo II</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-29</link>
		<dc:creator>Samuel A. Falvo II</dc:creator>
		<pubDate>Thu, 16 Apr 2009 00:24:37 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-29</guid>
		<description>Speaking from experience, and NOT using monad transformers, the ease of use of a state monad is about the same as any other imperative programming language.  The nice thing about using the state monad with Haskell, however, is you get the advantage of its type inferencing/checking, which is a significant plus.  This prevents you from mixing up your monads, which in turn, results in programs where the logic of multiple parts of a program are kept separate _syntactically_ and is compiler-checkable.

Again, introducing monad transformers muddles the water a bit, but once again, it&#039;s statically checkable.  You cannot mix multiple monads without having first declared it first.  This might seem like a big burden; in fact, however, it aids greatly in program cleanliness and modularity.

ONCE you wrap your head around transformers.  ;)</description>
		<content:encoded><![CDATA[<p>Speaking from experience, and NOT using monad transformers, the ease of use of a state monad is about the same as any other imperative programming language.  The nice thing about using the state monad with Haskell, however, is you get the advantage of its type inferencing/checking, which is a significant plus.  This prevents you from mixing up your monads, which in turn, results in programs where the logic of multiple parts of a program are kept separate _syntactically_ and is compiler-checkable.</p>
<p>Again, introducing monad transformers muddles the water a bit, but once again, it&#8217;s statically checkable.  You cannot mix multiple monads without having first declared it first.  This might seem like a big burden; in fact, however, it aids greatly in program cleanliness and modularity.</p>
<p>ONCE you wrap your head around transformers.  <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: khinsen</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-28</link>
		<dc:creator>khinsen</dc:creator>
		<pubDate>Tue, 14 Apr 2009 07:56:20 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-28</guid>
		<description>I don&#039;t think there is a clear yes/no answer to that question. It is possible to write hard-to-read code in any style, including pure functional, and of course also including the state monad.

However, there are a few important differences between programming with mutable state and programming in the state monad. There is no real mutable state in the state monad, so in terms of concurrency state monad code is definitely purely functional. But most importantly, the state monad is just one tool in the functional programer&#039;s toolbox, and it should be used only where it makes the code clearer. This is the case for algorithms where keeping track of a state is required anyway, a classical example being labelling a graph. Programmers who use the state monad as a convenient way to write imperative code in a functional language will most likely produce bad code. As a rule of thumb, I&#039;d say that if you start implementing loop constructs in the state monad, you are probably going too far.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t think there is a clear yes/no answer to that question. It is possible to write hard-to-read code in any style, including pure functional, and of course also including the state monad.</p>
<p>However, there are a few important differences between programming with mutable state and programming in the state monad. There is no real mutable state in the state monad, so in terms of concurrency state monad code is definitely purely functional. But most importantly, the state monad is just one tool in the functional programer&#8217;s toolbox, and it should be used only where it makes the code clearer. This is the case for algorithms where keeping track of a state is required anyway, a classical example being labelling a graph. Programmers who use the state monad as a convenient way to write imperative code in a functional language will most likely produce bad code. As a rule of thumb, I&#8217;d say that if you start implementing loop constructs in the state monad, you are probably going too far.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anand Patil</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-27</link>
		<dc:creator>Anand Patil</dc:creator>
		<pubDate>Mon, 06 Apr 2009 17:58:08 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-27</guid>
		<description>A quote from Rich Hickey that I like is &#039;mutability is the new spaghetti code&#039;: if you can mutate an object, you can produce &#039;action at a distance&#039; that seems convenient at first, but in the end makes your program logic harder to follow. 

I understand that the state monad makes it possible to make your code seem stateful, but keeps it possible to analyze it as a purely functional program. But does that convenience drop you back into &#039;the new spaghetti code&#039;, or are programs with the state monad easier to follow (for human coders) than programs with genuine mutability?</description>
		<content:encoded><![CDATA[<p>A quote from Rich Hickey that I like is &#8216;mutability is the new spaghetti code&#8217;: if you can mutate an object, you can produce &#8216;action at a distance&#8217; that seems convenient at first, but in the end makes your program logic harder to follow. </p>
<p>I understand that the state monad makes it possible to make your code seem stateful, but keeps it possible to analyze it as a purely functional program. But does that convenience drop you back into &#8216;the new spaghetti code&#8217;, or are programs with the state monad easier to follow (for human coders) than programs with genuine mutability?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: khinsen</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-22</link>
		<dc:creator>khinsen</dc:creator>
		<pubDate>Wed, 25 Mar 2009 08:55:16 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-22</guid>
		<description>Combining monads using monad transformers will be the topic of part 4. It is not a general possibilty; you can&#039;t combine any monad with any other one, but it covers a lot of situations that come up in practice.

Of course, nothing prevents you from using one monad within another if that&#039;s what your problem requires. For example, you can well have a &quot;domonad writer-m&quot; and inside one the right-hand-side expressions put a &quot;domonad maybe-m&quot;.

Monad transformers are different in that they produce one monad that combines the aspects of two (or more) individual monads.</description>
		<content:encoded><![CDATA[<p>Combining monads using monad transformers will be the topic of part 4. It is not a general possibilty; you can&#8217;t combine any monad with any other one, but it covers a lot of situations that come up in practice.</p>
<p>Of course, nothing prevents you from using one monad within another if that&#8217;s what your problem requires. For example, you can well have a &#8220;domonad writer-m&#8221; and inside one the right-hand-side expressions put a &#8220;domonad maybe-m&#8221;.</p>
<p>Monad transformers are different in that they produce one monad that combines the aspects of two (or more) individual monads.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Puzzler</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-21</link>
		<dc:creator>Puzzler</dc:creator>
		<pubDate>Tue, 24 Mar 2009 18:23:15 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-21</guid>
		<description>Yes, much clearer.  But now I&#039;m wondering whether it is possible to combine the behavior of two monads in one body of code.  For example, what if you want to be able to &quot;write&quot; some lines, and on other lines get the &quot;maybe&quot; behavior, and on other lines get the &quot;identity&quot; behavior?</description>
		<content:encoded><![CDATA[<p>Yes, much clearer.  But now I&#8217;m wondering whether it is possible to combine the behavior of two monads in one body of code.  For example, what if you want to be able to &#8220;write&#8221; some lines, and on other lines get the &#8220;maybe&#8221; behavior, and on other lines get the &#8220;identity&#8221; behavior?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: khinsen</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-19</link>
		<dc:creator>khinsen</dc:creator>
		<pubDate>Tue, 24 Mar 2009 09:31:29 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-19</guid>
		<description>I have added a concrete example: the Fibonacci function with a tracing system for recursive calls. I hope this makes it clearer!</description>
		<content:encoded><![CDATA[<p>I have added a concrete example: the Fibonacci function with a tracing system for recursive calls. I hope this makes it clearer!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Puzzler</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-18</link>
		<dc:creator>Puzzler</dc:creator>
		<pubDate>Mon, 23 Mar 2009 19:42:01 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-18</guid>
		<description>I&#039;d love to see a concrete example of using the state monad to do logging.  I can&#039;t quite get it from your description without seeing it in action, because it sounds like you can only do a write command in a place where you&#039;d typically do a let, rather than at an arbitrary point in a sequence of statements.</description>
		<content:encoded><![CDATA[<p>I&#8217;d love to see a concrete example of using the state monad to do logging.  I can&#8217;t quite get it from your description without seeing it in action, because it sounds like you can only do a write command in a place where you&#8217;d typically do a let, rather than at an arbitrary point in a sequence of statements.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
