<?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, 09 May 2013 14:29:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: khinsen</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-219</link>
		<dc:creator><![CDATA[khinsen]]></dc:creator>
		<pubDate>Thu, 06 Dec 2012 16:08:41 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-219</guid>
		<description><![CDATA[m-plus is indeed different because not every monad has one. The minimal requirement for a monad are m-bind and m-result. The optional add-on package consists of m-zero and m-plus. The reason for defining m-zero and m-plus as part of a monad is that they make sense only if there&#039;s also m-bind and m-result.

There are indeed cases where different useful definitions of m-plus exist for identical m-bind/m-result. The way to handle this in algo.monads is to define different monads. One could try to factor out this aspect, but that would also complicate the monad library. I am not convinced that it would be worth the effort.]]></description>
		<content:encoded><![CDATA[<p>m-plus is indeed different because not every monad has one. The minimal requirement for a monad are m-bind and m-result. The optional add-on package consists of m-zero and m-plus. The reason for defining m-zero and m-plus as part of a monad is that they make sense only if there&#8217;s also m-bind and m-result.</p>
<p>There are indeed cases where different useful definitions of m-plus exist for identical m-bind/m-result. The way to handle this in algo.monads is to define different monads. One could try to factor out this aspect, but that would also complicate the monad library. I am not convinced that it would be worth the effort.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-218</link>
		<dc:creator><![CDATA[Mark]]></dc:creator>
		<pubDate>Thu, 06 Dec 2012 15:17:56 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-218</guid>
		<description><![CDATA[m-bind, m-result, and m-zero all enable some important aspect of the domonad macro.  Does m-plus play any role in domonad?  If not, it really seems like the odd man out and it&#039;s not really clear to me why you&#039;d define it as part of the monad.  Couldn&#039;t there be more than one valid way to chain together multiple data sources, and if so, shouldn&#039;t the chaining function really be defined for the task at hand, rather than as part of the monad itself?]]></description>
		<content:encoded><![CDATA[<p>m-bind, m-result, and m-zero all enable some important aspect of the domonad macro.  Does m-plus play any role in domonad?  If not, it really seems like the odd man out and it&#8217;s not really clear to me why you&#8217;d define it as part of the monad.  Couldn&#8217;t there be more than one valid way to chain together multiple data sources, and if so, shouldn&#8217;t the chaining function really be defined for the task at hand, rather than as part of the monad itself?</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-217</link>
		<dc:creator><![CDATA[khinsen]]></dc:creator>
		<pubDate>Thu, 06 Dec 2012 13:39:43 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-217</guid>
		<description><![CDATA[The classic use-case for m-plus is chaining together multiple data sources, e.g. in parsers (different branches of the grammar being explored) or in backtracking in logic programming (as in core.logic).]]></description>
		<content:encoded><![CDATA[<p>The classic use-case for m-plus is chaining together multiple data sources, e.g. in parsers (different branches of the grammar being explored) or in backtracking in logic programming (as in core.logic).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-216</link>
		<dc:creator><![CDATA[Mark]]></dc:creator>
		<pubDate>Thu, 06 Dec 2012 05:43:39 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-216</guid>
		<description><![CDATA[I&#039;d like to see an example of some interesting use of m-plus.]]></description>
		<content:encoded><![CDATA[<p>I&#8217;d like to see an example of some interesting use of m-plus.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Monad Monad Monad &#8230; &#124; 따라쟁이</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-211</link>
		<dc:creator><![CDATA[Monad Monad Monad &#8230; &#124; 따라쟁이]]></dc:creator>
		<pubDate>Sat, 01 Sep 2012 13:53:03 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-211</guid>
		<description><![CDATA[[...] monad tutorial for Clojure programmers Part 1, Part 2, Part 3, Part [...]]]></description>
		<content:encoded><![CDATA[<p>[...] monad tutorial for Clojure programmers Part 1, Part 2, Part 3, Part [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin Heyes-Jones</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-210</link>
		<dc:creator><![CDATA[Justin Heyes-Jones]]></dc:creator>
		<pubDate>Thu, 23 Aug 2012 03:01:04 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-210</guid>
		<description><![CDATA[That was supposed to be a reply to comment 8.]]></description>
		<content:encoded><![CDATA[<p>That was supposed to be a reply to comment 8.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Justin Heyes-Jones</title>
		<link>http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/#comment-209</link>
		<dc:creator><![CDATA[Justin Heyes-Jones]]></dc:creator>
		<pubDate>Thu, 23 Aug 2012 03:00:04 +0000</pubDate>
		<guid isPermaLink="false">http://onclojure.com/?p=33#comment-209</guid>
		<description><![CDATA[I think it should be yeah.]]></description>
		<content:encoded><![CDATA[<p>I think it should be yeah.</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-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>
</channel>
</rss>
