<?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/"
		>
<channel>
	<title>Comments on: Not all computational effects are monads</title>
	<atom:link href="http://math.andrej.com/2008/11/17/not-all-computational-effects-are-monads/feed/" rel="self" type="application/rss+xml" />
	<link>http://math.andrej.com/2008/11/17/not-all-computational-effects-are-monads/</link>
	<description>Mathematics for computers</description>
	<lastBuildDate>Wed, 18 Aug 2010 12:14:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Martin Escardó</title>
		<link>http://math.andrej.com/2008/11/17/not-all-computational-effects-are-monads/comment-page-1/#comment-10767</link>
		<dc:creator>Martin Escardó</dc:creator>
		<pubDate>Tue, 02 Dec 2008 15:14:24 +0000</pubDate>
		<guid isPermaLink="false">http://math.andrej.com/?p=109#comment-10767</guid>
		<description>Hi Sebastian. Yes, what you wrote is what you would get as the (denotational) metric semantics of the usual factorial program, or as the (operational) chattering semantics I describe in the above paper.</description>
		<content:encoded><![CDATA[<p>Hi Sebastian. Yes, what you wrote is what you would get as the (denotational) metric semantics of the usual factorial program, or as the (operational) chattering semantics I describe in the above paper.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastian Hanowski</title>
		<link>http://math.andrej.com/2008/11/17/not-all-computational-effects-are-monads/comment-page-1/#comment-10702</link>
		<dc:creator>Sebastian Hanowski</dc:creator>
		<pubDate>Tue, 25 Nov 2008 20:18:56 +0000</pubDate>
		<guid isPermaLink="false">http://math.andrej.com/?p=109#comment-10702</guid>
		<description>Hi Martín!

This is a first try of a simple lift of Delay to functions spaces.

timedRecursion :: ((a -&gt; T b) -&gt; (a -&gt; T b)) -&gt; (a -&gt; T b)
timedRecursion f = \ a -&gt; Delay (f (timedRecursion f) a)

rfac :: (Int -&gt; T Int) -&gt; (Int -&gt; T Int)
rfac f 0 = Stop 1
rfac f n = t (n*) (f (n-1))

fac :: Int -&gt; T Int
fac = timedRecursion rfac</description>
		<content:encoded><![CDATA[<p>Hi Martín!</p>
<p>This is a first try of a simple lift of Delay to functions spaces.</p>
<p>timedRecursion :: ((a -&gt; T b) -&gt; (a -&gt; T b)) -&gt; (a -&gt; T b)<br />
timedRecursion f = \ a -&gt; Delay (f (timedRecursion f) a)</p>
<p>rfac :: (Int -&gt; T Int) -&gt; (Int -&gt; T Int)<br />
rfac f 0 = Stop 1<br />
rfac f n = t (n*) (f (n-1))</p>
<p>fac :: Int -&gt; T Int<br />
fac = timedRecursion rfac</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Escardó</title>
		<link>http://math.andrej.com/2008/11/17/not-all-computational-effects-are-monads/comment-page-1/#comment-10629</link>
		<dc:creator>Martin Escardó</dc:creator>
		<pubDate>Wed, 19 Nov 2008 17:24:57 +0000</pubDate>
		<guid isPermaLink="false">http://math.andrej.com/?p=109#comment-10629</guid>
		<description>I wrote a note (in 1998) that considers ticks, and has a monad for that.

http://www.cs.bham.ac.uk/~mhe/papers/metricpcf.pdf

I would define, in Haskell, corresponding to the above note, 

data T a = Stop a &#124; Delay(T a)

instance Monad T where
  return = eta
  xs &gt;&gt;= f = mu(t f xs)

eta :: a -&gt; T a
eta x = Stop x

mu :: T(T a) -&gt; T a
mu(Stop xs) = xs
mu(Delay xss) = Delay(mu xss)

t :: (a -&gt; b) -&gt; (T a -&gt; T b)
t f (Stop x) = Stop(f x)
t f (Delay xs) = Delay(t f xs)

timeout :: Int -&gt; T a -&gt; Maybe a
timeout n (Stop x) = Just x
timeout 0 (Delay xs) = Nothing
timeout (n+1) (Delay xs) = timeout n xs

timeof :: T a -&gt; Int
timeof (Stop x) = 0
timeof (Delay xs) = 1 + timeof xs

timedRecursion :: (T a -&gt; T a) -&gt; T a
timedRecursion f = Delay (f (timedRecursion f))

The last one ticks once for each recursion unfolding. Notice the similarity (and difference) with lazy natural numbers. But, as the paper discusses, it is perhaps more sensible, in a call-by-name language, to tick only at ground types. Then you define, by induction on types, a new delay function (starting with delay=Delay at ground types) pointwise. The paper proves some properties of this. 

Notice that an infinite computation returns, rather than bottom, infty, where

infty = Delay infty.

The output type of timeof can of course (and sensibly) be replaced by the lazy natural numbers.</description>
		<content:encoded><![CDATA[<p>I wrote a note (in 1998) that considers ticks, and has a monad for that.</p>
<p><a href="http://www.cs.bham.ac.uk/~mhe/papers/metricpcf.pdf" rel="nofollow">http://www.cs.bham.ac.uk/~mhe/papers/metricpcf.pdf</a></p>
<p>I would define, in Haskell, corresponding to the above note, </p>
<p>data T a = Stop a | Delay(T a)</p>
<p>instance Monad T where<br />
  return = eta<br />
  xs &gt;&gt;= f = mu(t f xs)</p>
<p>eta :: a -&gt; T a<br />
eta x = Stop x</p>
<p>mu :: T(T a) -&gt; T a<br />
mu(Stop xs) = xs<br />
mu(Delay xss) = Delay(mu xss)</p>
<p>t :: (a -&gt; b) -&gt; (T a -&gt; T b)<br />
t f (Stop x) = Stop(f x)<br />
t f (Delay xs) = Delay(t f xs)</p>
<p>timeout :: Int -&gt; T a -&gt; Maybe a<br />
timeout n (Stop x) = Just x<br />
timeout 0 (Delay xs) = Nothing<br />
timeout (n+1) (Delay xs) = timeout n xs</p>
<p>timeof :: T a -&gt; Int<br />
timeof (Stop x) = 0<br />
timeof (Delay xs) = 1 + timeof xs</p>
<p>timedRecursion :: (T a -&gt; T a) -&gt; T a<br />
timedRecursion f = Delay (f (timedRecursion f))</p>
<p>The last one ticks once for each recursion unfolding. Notice the similarity (and difference) with lazy natural numbers. But, as the paper discusses, it is perhaps more sensible, in a call-by-name language, to tick only at ground types. Then you define, by induction on types, a new delay function (starting with delay=Delay at ground types) pointwise. The paper proves some properties of this. </p>
<p>Notice that an infinite computation returns, rather than bottom, infty, where</p>
<p>infty = Delay infty.</p>
<p>The output type of timeof can of course (and sensibly) be replaced by the lazy natural numbers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrej Bauer</title>
		<link>http://math.andrej.com/2008/11/17/not-all-computational-effects-are-monads/comment-page-1/#comment-10619</link>
		<dc:creator>Andrej Bauer</dc:creator>
		<pubDate>Wed, 19 Nov 2008 01:29:17 +0000</pubDate>
		<guid isPermaLink="false">http://math.andrej.com/?p=109#comment-10619</guid>
		<description>Reply to ccshan: the challenge here is to express catch and timeout in Haskell as is typically done in Haskell. I have failed to do so for catch (because simulating catch with the exception monad is an overkill). I disagree that catch is as easy as state and non-determinism. Show me how easy it is to directly express catch (and only catch) in Haskell as a monad, comonad, or whatever.

Timeout can be presented as a monad, which follows from the general theory of effect that Matija has referred to, but I would still like to see a concrete Haskell implementation that results from Matija&#039;s theory.</description>
		<content:encoded><![CDATA[<p>Reply to ccshan: the challenge here is to express catch and timeout in Haskell as is typically done in Haskell. I have failed to do so for catch (because simulating catch with the exception monad is an overkill). I disagree that catch is as easy as state and non-determinism. Show me how easy it is to directly express catch (and only catch) in Haskell as a monad, comonad, or whatever.</p>
<p>Timeout can be presented as a monad, which follows from the general theory of effect that Matija has referred to, but I would still like to see a concrete Haskell implementation that results from Matija&#8217;s theory.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ccshan</title>
		<link>http://math.andrej.com/2008/11/17/not-all-computational-effects-are-monads/comment-page-1/#comment-10618</link>
		<dc:creator>ccshan</dc:creator>
		<pubDate>Tue, 18 Nov 2008 23:58:26 +0000</pubDate>
		<guid isPermaLink="false">http://math.andrej.com/?p=109#comment-10618</guid>
		<description>What more precisely is the &quot;challenge&quot; you have in mind?  If it is to &quot;break purity&quot; or &quot;breaks beta reduction&quot;, then state and non-determinism are just as hard as your two examples.  If it is to &quot;express&quot; effects as is typically done in Haskell, then your two examples are just as easy as state and non-determinism.</description>
		<content:encoded><![CDATA[<p>What more precisely is the &#8220;challenge&#8221; you have in mind?  If it is to &#8220;break purity&#8221; or &#8220;breaks beta reduction&#8221;, then state and non-determinism are just as hard as your two examples.  If it is to &#8220;express&#8221; effects as is typically done in Haskell, then your two examples are just as easy as state and non-determinism.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
