<?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>Thu, 24 May 2012 00:08:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: noobgp</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-207</link>
		<dc:creator><![CDATA[noobgp]]></dc:creator>
		<pubDate>Sat, 05 May 2012 00:16:28 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-207</guid>
		<description><![CDATA[PRNG&#039;s seed is also an input, so PRNGs are deterministic. If they weren&#039;t, they wouldn&#039;t be pseudo-random, but just random.

The Fibonacci sequence (with one input, sequence element number) wouldn&#039;t be deterministic when feeded by a single outside-entropy integer?

Am I missing something?]]></description>
		<content:encoded><![CDATA[<p>PRNG&#8217;s seed is also an input, so PRNGs are deterministic. If they weren&#8217;t, they wouldn&#8217;t be pseudo-random, but just random.</p>
<p>The Fibonacci sequence (with one input, sequence element number) wouldn&#8217;t be deterministic when feeded by a single outside-entropy integer?</p>
<p>Am I missing something?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: noobgp</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-206</link>
		<dc:creator><![CDATA[noobgp]]></dc:creator>
		<pubDate>Sat, 05 May 2012 00:14:53 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-206</guid>
		<description><![CDATA[PRNG&#039;s seed is also an input, so PRNGs are deterministic. If they weren&#039;t, they wouldn&#039;t be pseudo-random, but just random.

The Fibonacci sequence wouldn&#039;t be deterministic when feeded by a single outside-entropy integer?

Am I missing something?]]></description>
		<content:encoded><![CDATA[<p>PRNG&#8217;s seed is also an input, so PRNGs are deterministic. If they weren&#8217;t, they wouldn&#8217;t be pseudo-random, but just random.</p>
<p>The Fibonacci sequence wouldn&#8217;t be deterministic when feeded by a single outside-entropy integer?</p>
<p>Am I missing something?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kurt Harriger</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-153</link>
		<dc:creator><![CDATA[Kurt Harriger]]></dc:creator>
		<pubDate>Tue, 21 Dec 2010 17:24:21 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-153</guid>
		<description><![CDATA[I too am interested in the monadic implementation of fib.  Basically my understanding is that a lazy sequence is a continuation monad where the head is the current result and tail represents the future computation.

F# uses sequence monads to construct IEnumerable.  As you pointed out there is some compiler magic that rearranges the statements into monadic expressions (http://blogs.msdn.com/b/dsyme/archive/2007/09/22/some-details-on-f-computation-expressions-aka-monadic-or-workflow-syntax.aspx).  In clojure I would assume one could do this same transformation with a macro.  

So back to the question of why?  Although this seems unnecessary in a clojure where lazy sequences accomplish the same thing. I&#039;m still wondering if lazy-seq may be the bridge between, rather than a replacement for, the monadic representation. 

Here is a web application where the author used fill-queue to convert the web server into a sequence generator rather than a event dispatcher.  http://infolace.blogspot.com/2009/08/simple-webhooks-with-clojure-and-ring.html.  

Using the same technique I could write fib in an imperative style.  
(def fib (fill-queue (fn loop [fill] [a 0 b 1] (fill a) (recur b (+ a b)))))

However the above uses another thread which blocks when the queue is full, in some cases this concurrent computation may be desirable, but it probably isn&#039;t desirable to dedicate a thread to each computation.

In F# events can be composed, filtered and mapped just as a sequence of events rather than traditional event handlers (http://codebetter.com/matthewpodwysocki/2009/08/11/first-class-composable-events-in-f/) which makes the code very expressive.  

Here is a clojure web framework that uses a continuation monad to preserve the state of a web application http://intensivesystems.net/tutorials/cont_m_web.html.  In this case continuations rather than separate threads are used to maintain state.  Could this be implemented as a lazy sequence instead?  In F# asynchronous workflows are also implemented via monads.  Some C# developers are using IEnumerable and linq to develop async workflows (http://tomasp.net/blog/csharp-async.aspx). So I think the answer is yes, but the real question I think is would using a lazy sequence make the code easier or more difficult to understand, write and maintain?  

I think applications might be written as async workflows, and instead of using event handlers they pull a sequence of events and maintain state between events in local variables (sate monad).  This would have the feel of stdin/stdout in unix, but rather than the workflow blocking on output and requiring a dedicated thread a continuation could be used to externalize the choice of threading model.]]></description>
		<content:encoded><![CDATA[<p>I too am interested in the monadic implementation of fib.  Basically my understanding is that a lazy sequence is a continuation monad where the head is the current result and tail represents the future computation.</p>
<p>F# uses sequence monads to construct IEnumerable.  As you pointed out there is some compiler magic that rearranges the statements into monadic expressions (<a href="http://blogs.msdn.com/b/dsyme/archive/2007/09/22/some-details-on-f-computation-expressions-aka-monadic-or-workflow-syntax.aspx" rel="nofollow">http://blogs.msdn.com/b/dsyme/archive/2007/09/22/some-details-on-f-computation-expressions-aka-monadic-or-workflow-syntax.aspx</a>).  In clojure I would assume one could do this same transformation with a macro.  </p>
<p>So back to the question of why?  Although this seems unnecessary in a clojure where lazy sequences accomplish the same thing. I&#8217;m still wondering if lazy-seq may be the bridge between, rather than a replacement for, the monadic representation. </p>
<p>Here is a web application where the author used fill-queue to convert the web server into a sequence generator rather than a event dispatcher.  <a href="http://infolace.blogspot.com/2009/08/simple-webhooks-with-clojure-and-ring.html" rel="nofollow">http://infolace.blogspot.com/2009/08/simple-webhooks-with-clojure-and-ring.html</a>.  </p>
<p>Using the same technique I could write fib in an imperative style.<br />
(def fib (fill-queue (fn loop [fill] [a 0 b 1] (fill a) (recur b (+ a b)))))</p>
<p>However the above uses another thread which blocks when the queue is full, in some cases this concurrent computation may be desirable, but it probably isn&#8217;t desirable to dedicate a thread to each computation.</p>
<p>In F# events can be composed, filtered and mapped just as a sequence of events rather than traditional event handlers (<a href="http://codebetter.com/matthewpodwysocki/2009/08/11/first-class-composable-events-in-f/" rel="nofollow">http://codebetter.com/matthewpodwysocki/2009/08/11/first-class-composable-events-in-f/</a>) which makes the code very expressive.  </p>
<p>Here is a clojure web framework that uses a continuation monad to preserve the state of a web application <a href="http://intensivesystems.net/tutorials/cont_m_web.html" rel="nofollow">http://intensivesystems.net/tutorials/cont_m_web.html</a>.  In this case continuations rather than separate threads are used to maintain state.  Could this be implemented as a lazy sequence instead?  In F# asynchronous workflows are also implemented via monads.  Some C# developers are using IEnumerable and linq to develop async workflows (<a href="http://tomasp.net/blog/csharp-async.aspx" rel="nofollow">http://tomasp.net/blog/csharp-async.aspx</a>). So I think the answer is yes, but the real question I think is would using a lazy sequence make the code easier or more difficult to understand, write and maintain?  </p>
<p>I think applications might be written as async workflows, and instead of using event handlers they pull a sequence of events and maintain state between events in local variables (sate monad).  This would have the feel of stdin/stdout in unix, but rather than the workflow blocking on output and requiring a dedicated thread a continuation could be used to externalize the choice of threading model.</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-139</link>
		<dc:creator><![CDATA[khinsen]]></dc:creator>
		<pubDate>Fri, 29 Oct 2010 12:37:24 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-139</guid>
		<description><![CDATA[The typos are fixed. Thanks for the feedback! Unfortunately all my applications are either throwaway code (not very presentable) or somewhat confidential.]]></description>
		<content:encoded><![CDATA[<p>The typos are fixed. Thanks for the feedback! Unfortunately all my applications are either throwaway code (not very presentable) or somewhat confidential.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacek Laskowski</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-137</link>
		<dc:creator><![CDATA[Jacek Laskowski]]></dc:creator>
		<pubDate>Thu, 28 Oct 2010 10:50:47 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-137</guid>
		<description><![CDATA[Read it again and spot 2 typos:

&lt;i&gt;rest of to the domonad form&lt;/i&gt; should become &lt;i&gt;rest of the domonad form&lt;/i&gt; (&#039;to&#039; removed)

&lt;i&gt;used that is has itself&lt;/i&gt; should become &lt;i&gt;used that has itself&lt;/i&gt; (&#039;is&#039; removed)

Thanks for the article and the others! They&#039;re very mind-blowing and simply awesome. I wish you&#039;d share when/how you used the library so I&#039;d follow along and understand monads better.]]></description>
		<content:encoded><![CDATA[<p>Read it again and spot 2 typos:</p>
<p><i>rest of to the domonad form</i> should become <i>rest of the domonad form</i> (&#8216;to&#8217; removed)</p>
<p><i>used that is has itself</i> should become <i>used that has itself</i> (&#8216;is&#8217; removed)</p>
<p>Thanks for the article and the others! They&#8217;re very mind-blowing and simply awesome. I wish you&#8217;d share when/how you used the library so I&#8217;d follow along and understand monads better.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacek Laskowski</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-136</link>
		<dc:creator><![CDATA[Jacek Laskowski]]></dc:creator>
		<pubDate>Mon, 18 Oct 2010 12:05:18 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-136</guid>
		<description><![CDATA[Just noticed - shouldn&#039;t 

(domonad sequence
  [a (range 5)
   :when (odd? a)]
  (* 2 a))

use sequence-m?]]></description>
		<content:encoded><![CDATA[<p>Just noticed &#8211; shouldn&#8217;t </p>
<p>(domonad sequence<br />
  [a (range 5)<br />
   :when (odd? a)]<br />
  (* 2 a))</p>
<p>use sequence-m?</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-131</link>
		<dc:creator><![CDATA[khinsen]]></dc:creator>
		<pubDate>Thu, 09 Sep 2010 17:07:51 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-131</guid>
		<description><![CDATA[Python implements generators (and thus yield) using a lot of magic going on behind the scenes. Generators should be considered a special control structure in Python. Clojure has different functional control structures that cover most practical situations where Python programmers would use generators. I don&#039;t see any reason why it would be impractical to introduce generators into Clojure, but I don&#039;t see any good reason for doing so either.]]></description>
		<content:encoded><![CDATA[<p>Python implements generators (and thus yield) using a lot of magic going on behind the scenes. Generators should be considered a special control structure in Python. Clojure has different functional control structures that cover most practical situations where Python programmers would use generators. I don&#8217;t see any reason why it would be impractical to introduce generators into Clojure, but I don&#8217;t see any good reason for doing so either.</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-130</link>
		<dc:creator><![CDATA[khinsen]]></dc:creator>
		<pubDate>Thu, 09 Sep 2010 16:58:49 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-130</guid>
		<description><![CDATA[I prefer the similarity that (get s key) has to (assoc s key val), that&#039;s all!]]></description>
		<content:encoded><![CDATA[<p>I prefer the similarity that (get s key) has to (assoc s key val), that&#8217;s all!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jacek Laskowski</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-129</link>
		<dc:creator><![CDATA[Jacek Laskowski]]></dc:creator>
		<pubDate>Thu, 09 Sep 2010 16:27:27 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-129</guid>
		<description><![CDATA[Why do you use (get s key) in set-val not (key s)?]]></description>
		<content:encoded><![CDATA[<p>Why do you use (get s key) in set-val not (key s)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RosenK</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-128</link>
		<dc:creator><![CDATA[RosenK]]></dc:creator>
		<pubDate>Thu, 09 Sep 2010 15:35:27 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-128</guid>
		<description><![CDATA[Why yield is practical in Python but is not practical in Clojure? Why there is any difference?]]></description>
		<content:encoded><![CDATA[<p>Why yield is practical in Python but is not practical in Clojure? Why there is any difference?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

