<?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: Seemingly impossible functional programs</title>
	<atom:link href="http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/feed/" rel="self" type="application/rss+xml" />
	<link>http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/</link>
	<description>Mathematics for computers</description>
	<lastBuildDate>Mon, 30 Jan 2012 07:14:48 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2-beta2-18055</generator>
	<item>
		<title>By: Andrej Bauer</title>
		<link>http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/comment-page-1/#comment-18856</link>
		<dc:creator>Andrej Bauer</dc:creator>
		<pubDate>Sat, 28 Jan 2012 07:14:55 +0000</pubDate>
		<guid isPermaLink="false">http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/#comment-18856</guid>
		<description>@Martin: my talk about faster functionals using effects is &lt;a href=&quot;http://math.andrej.com/2011/12/06/how-to-make-the-impossible-functionals-run-even-faster/&quot; rel=&quot;nofollow&quot;&gt;on line&lt;/a&gt;.</description>
		<content:encoded><![CDATA[<p>@Martin: my talk about faster functionals using effects is <a href="http://math.andrej.com/2011/12/06/how-to-make-the-impossible-functionals-run-even-faster/" rel="nofollow">on line</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ralph Loader</title>
		<link>http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/comment-page-1/#comment-18852</link>
		<dc:creator>Ralph Loader</dc:creator>
		<pubDate>Sat, 28 Jan 2012 01:28:47 +0000</pubDate>
		<guid isPermaLink="false">http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/#comment-18852</guid>
		<description>It turns out that you can give a sensible, negative, answer to my question.  find can be parametrized with a monad pretty easily e.g., [conflating Bit and Bool to save typing].
[sourcecode gutter=&quot;false&quot;]
module MFind where
import Control.Monad.State

findM :: Ord i =&gt; Monad m =&gt; ((i -&gt; m Bool) -&gt; m Bool) -&gt; (i -&gt; m Bool)
findM p n = do { x &lt;- q (findM q) ; return (not x) }  where
   q a = p (\i -&gt; if i == n then return False else
                 if i &lt; n then findM p i else a i)

-- Make a dummy call to (c x), where x increments by 1 each time we&#039;re called.
-- Then return (c 5).
fifthWithDummy :: (Integer -&gt; State Integer Bool) -&gt; State Integer Bool
fifthWithDummy c = do
  x &lt;- get
  put (x + 1)
  b &lt;- c x
  if b then c 5 else c 5

-- Now compare
--   findM ($ 5) 0
-- with
--   runState (findM (fifthWithDummy) 0) 0
[/sourcecode]
never returns.</description>
		<content:encoded><![CDATA[<p>It turns out that you can give a sensible, negative, answer to my question.  find can be parametrized with a monad pretty easily e.g., [conflating Bit and Bool to save typing].</p>
<pre class="brush: plain; gutter: false; title: ;">
module MFind where
import Control.Monad.State

findM :: Ord i =&gt; Monad m =&gt; ((i -&gt; m Bool) -&gt; m Bool) -&gt; (i -&gt; m Bool)
findM p n = do { x &lt;- q (findM q) ; return (not x) }  where
   q a = p (\i -&gt; if i == n then return False else
                 if i &lt; n then findM p i else a i)

-- Make a dummy call to (c x), where x increments by 1 each time we're called.
-- Then return (c 5).
fifthWithDummy :: (Integer -&gt; State Integer Bool) -&gt; State Integer Bool
fifthWithDummy c = do
  x &lt;- get
  put (x + 1)
  b &lt;- c x
  if b then c 5 else c 5

-- Now compare
--   findM ($ 5) 0
-- with
--   runState (findM (fifthWithDummy) 0) 0
</pre>
<p>never returns.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Escardo</title>
		<link>http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/comment-page-1/#comment-18834</link>
		<dc:creator>Martin Escardo</dc:creator>
		<pubDate>Thu, 26 Jan 2012 10:22:06 +0000</pubDate>
		<guid isPermaLink="false">http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/#comment-18834</guid>
		<description>Yes, everything here is extensional and total, as Andrej says, and there are no effects. But Andrej gave a nice talk in MAP&#039;2011 in the Lorentz Center showing how to do it faster with effects. But in this case, as you say, it is difficult to treat extensionality rigorously.</description>
		<content:encoded><![CDATA[<p>Yes, everything here is extensional and total, as Andrej says, and there are no effects. But Andrej gave a nice talk in MAP&#8217;2011 in the Lorentz Center showing how to do it faster with effects. But in this case, as you say, it is difficult to treat extensionality rigorously.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrej Bauer</title>
		<link>http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/comment-page-1/#comment-18832</link>
		<dc:creator>Andrej Bauer</dc:creator>
		<pubDate>Thu, 26 Jan 2012 07:11:42 +0000</pubDate>
		<guid isPermaLink="false">http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/#comment-18832</guid>
		<description>@Ralph: This post is written in the context of purely functional programs, i.e., no state, and all functionals are presumed to be (hereditarily) total. With state things are more complicated (global state, local state, what does it mean for an extensional functional to use state?).</description>
		<content:encoded><![CDATA[<p>@Ralph: This post is written in the context of purely functional programs, i.e., no state, and all functionals are presumed to be (hereditarily) total. With state things are more complicated (global state, local state, what does it mean for an extensional functional to use state?).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ralph Loader</title>
		<link>http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/comment-page-1/#comment-18831</link>
		<dc:creator>Ralph Loader</dc:creator>
		<pubDate>Thu, 26 Jan 2012 03:05:04 +0000</pubDate>
		<guid isPermaLink="false">http://math.andrej.com/2007/09/28/seemingly-impossible-functional-programs/#comment-18831</guid>
		<description>Do these work for functions that have state?  To state precisely what&#039;s wanted one would have to be careful about extensionality (although you glossed over it, just as you need to be careful about totality in the pure functional setting).

[Even if the particular programs above don&#039;t work with stateful functions, the Kreisel-Lacombe-Shoenfield theorem makes one think that it is possible to do the same thing for stateful functions.]</description>
		<content:encoded><![CDATA[<p>Do these work for functions that have state?  To state precisely what&#8217;s wanted one would have to be careful about extensionality (although you glossed over it, just as you need to be careful about totality in the pure functional setting).</p>
<p>[Even if the particular programs above don't work with stateful functions, the Kreisel-Lacombe-Shoenfield theorem makes one think that it is possible to do the same thing for stateful functions.]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

