<?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: Another angle on functional future values</title>
	<atom:link href="http://conal.net/blog/posts/another-angle-on-functional-future-values/feed" rel="self" type="application/rss+xml" />
	<link>http://conal.net/blog/posts/another-angle-on-functional-future-values</link>
	<description>Inspirations &#38; experiments, mainly about denotative/functional programming in Haskell</description>
	<lastBuildDate>Sat, 26 Sep 2020 21:06:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1.17</generator>
	<item>
		<title>By: Mike Sperber</title>
		<link>http://conal.net/blog/posts/another-angle-on-functional-future-values#comment-304</link>
		<dc:creator><![CDATA[Mike Sperber]]></dc:creator>
		<pubDate>Thu, 20 Oct 2011 07:22:26 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=73#comment-304</guid>
		<description><![CDATA[&lt;p&gt;Getting back to my previous comment: I think I understand what the issue is now, and it reveals a deeper problem with this approach to future value:&lt;/p&gt;

&lt;p&gt;You start out by saying that all function futures should be created from simple futures, but of course caching futures violate that principle - at least if they themselves are not created from simple futures. And, at some point, you want to hook up actual external-world actions to get some of that reactivity the &quot;R&quot; in FRP is about, and caching futures are an entry obvious entry point.&lt;/p&gt;

&lt;p&gt;Here&#039;s the problem: Caching futures themselves are well-behaved, but caching futures combined with mappend are not: Consider two caching futures &lt;code&gt;f1&lt;/code&gt; and &lt;code&gt;f2&lt;/code&gt;, and  only &lt;code&gt;f1&lt;/code&gt; gets triggered at time &lt;code&gt;t0&lt;/code&gt;.  Mappend them to get future &lt;code&gt;f&lt;/code&gt;. If you ask the (try-future version of) f at time &lt;code&gt;t&#039; &gt; t0&lt;/code&gt;, you get &lt;code&gt;Some&lt;/code&gt; answer. If you ask at &lt;code&gt;MaxBound&lt;/code&gt; (which is greater than &lt;code&gt;t&#039;&lt;/code&gt;), you get no answer, because the system waits for &lt;code&gt;f2&lt;/code&gt;. So monotonicity is violated. That, of course, is also the issue with my version of &lt;code&gt;fToS&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The deeper problem, I think, is the fact that the event occurrences the system talks about really refer to the programmatic event (i.e. the &lt;code&gt;SampleVar&lt;/code&gt; being filled), rather than &lt;em&gt;knowledge&lt;/em&gt; about an external event, which only becomes available after it has actually happened. (How do you mappend two futures knowing that they&#039;ll become known only after the timestamps that will be attached to them?)&lt;/p&gt;

&lt;p&gt;All solutions I&#039;ve come up with for this require going back to some notion of partial time. It can be pushed into a smaller corner than before, but it&#039;s still there.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>Getting back to my previous comment: I think I understand what the issue is now, and it reveals a deeper problem with this approach to future value:</p>

<p>You start out by saying that all function futures should be created from simple futures, but of course caching futures violate that principle &#8211; at least if they themselves are not created from simple futures. And, at some point, you want to hook up actual external-world actions to get some of that reactivity the &#8220;R&#8221; in FRP is about, and caching futures are an entry obvious entry point.</p>

<p>Here&#8217;s the problem: Caching futures themselves are well-behaved, but caching futures combined with mappend are not: Consider two caching futures <code>f1</code> and <code>f2</code>, and  only <code>f1</code> gets triggered at time <code>t0</code>.  Mappend them to get future <code>f</code>. If you ask the (try-future version of) f at time <code>t' &gt; t0</code>, you get <code>Some</code> answer. If you ask at <code>MaxBound</code> (which is greater than <code>t'</code>), you get no answer, because the system waits for <code>f2</code>. So monotonicity is violated. That, of course, is also the issue with my version of <code>fToS</code>.</p>

<p>The deeper problem, I think, is the fact that the event occurrences the system talks about really refer to the programmatic event (i.e. the <code>SampleVar</code> being filled), rather than <em>knowledge</em> about an external event, which only becomes available after it has actually happened. (How do you mappend two futures knowing that they&#8217;ll become known only after the timestamps that will be attached to them?)</p>

<p>All solutions I&#8217;ve come up with for this require going back to some notion of partial time. It can be pushed into a smaller corner than before, but it&#8217;s still there.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Sperber</title>
		<link>http://conal.net/blog/posts/another-angle-on-functional-future-values#comment-303</link>
		<dc:creator><![CDATA[Mike Sperber]]></dc:creator>
		<pubDate>Tue, 12 Jul 2011 09:33:38 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=73#comment-303</guid>
		<description><![CDATA[&lt;p&gt;I&#039;m not sure I understand the comment about fToS not lending itself to implementation.  Can&#039;t you say (rusty Haskell ahead):&lt;/p&gt;

&lt;pre&gt;
fToS f = p (unFuture f maxBound)
  where
   p Nothing -&gt; (maxBound, undefined)
   p (Some sf) -&gt; sf
&lt;/pre&gt;

&lt;p&gt;?&lt;/p&gt;

&lt;p&gt;Sure, you might have to wait, but that&#039;s true in general of F.FutureG, no?&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure I understand the comment about fToS not lending itself to implementation.  Can&#8217;t you say (rusty Haskell ahead):</p>

<pre>
fToS f = p (unFuture f maxBound)
  where
   p Nothing -&gt; (maxBound, undefined)
   p (Some sf) -&gt; sf
</pre>

<p>?</p>

<p>Sure, you might have to wait, but that&#8217;s true in general of F.FutureG, no?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: conal</title>
		<link>http://conal.net/blog/posts/another-angle-on-functional-future-values#comment-302</link>
		<dc:creator><![CDATA[conal]]></dc:creator>
		<pubDate>Wed, 25 Aug 2010 03:15:34 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=73#comment-302</guid>
		<description><![CDATA[&lt;p&gt;Hi Gergely:&lt;/p&gt;

&lt;p&gt;Please note the second paragraph in this post.
What I&#039;m going for here is a simple &amp; precise semantics and a faithful implementation.
If I understand your suggestion, it would be a simple implementation but I doubt it would be faithful to a simple &amp; precise semantics.
Maybe it could be faithful under certain assumptions about single- vs multi-threading, what it means for events to fire (in the imperative substrate), and how the resulting assignments interact with the mechanics of functional evaluation in the Haskell run-time system.
I imagine following this path would require some very complicated reasoning and would yield fairly restrictive results.
If anyone does try to apply rigorous reasoning to your suggestion, I&#039;d be very interested in reading about the results.&lt;/p&gt;

&lt;p&gt;If you ignore the &quot;caching futures&quot; aspect of this post, I hope you can see the answer to your question of sampling into the far future.&lt;/p&gt;

&lt;p&gt;In the caching section, I&#039;m reaching for general principles for extending the laziness machinery that we already know &amp; love, while keeping its semantic purity.
What justifies claiming purely functional semantics in the presence of these side-effects?
In other words, what makes some assignments (semantically) benign and others malignant?
&lt;/p&gt;

&lt;p&gt;In brief, assignment is (semantically) &lt;em&gt;benign&lt;/em&gt; when the new value is semantically equal to the old value.
A benign assignment is &lt;em&gt;beneficial&lt;/em&gt; when it improves some sort of efficiency.
As an example, to implement laziness, the run-time system performs thunk overwriting.
The old thunk and the new value (whnf) are semantically equal.
The benefit is improved speed of access, perhaps at the cost of space.&lt;/p&gt;

&lt;p&gt;I would like to explore the space of beneficial, benign assignments much more thoroughly than this one special case of thunk overwriting.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>Hi Gergely:</p>

<p>Please note the second paragraph in this post.
What I&#8217;m going for here is a simple &amp; precise semantics and a faithful implementation.
If I understand your suggestion, it would be a simple implementation but I doubt it would be faithful to a simple &amp; precise semantics.
Maybe it could be faithful under certain assumptions about single- vs multi-threading, what it means for events to fire (in the imperative substrate), and how the resulting assignments interact with the mechanics of functional evaluation in the Haskell run-time system.
I imagine following this path would require some very complicated reasoning and would yield fairly restrictive results.
If anyone does try to apply rigorous reasoning to your suggestion, I&#8217;d be very interested in reading about the results.</p>

<p>If you ignore the &#8220;caching futures&#8221; aspect of this post, I hope you can see the answer to your question of sampling into the far future.</p>

<p>In the caching section, I&#8217;m reaching for general principles for extending the laziness machinery that we already know &amp; love, while keeping its semantic purity.
What justifies claiming purely functional semantics in the presence of these side-effects?
In other words, what makes some assignments (semantically) benign and others malignant?
</p>

<p>In brief, assignment is (semantically) <em>benign</em> when the new value is semantically equal to the old value.
A benign assignment is <em>beneficial</em> when it improves some sort of efficiency.
As an example, to implement laziness, the run-time system performs thunk overwriting.
The old thunk and the new value (whnf) are semantically equal.
The benefit is improved speed of access, perhaps at the cost of space.</p>

<p>I would like to explore the space of beneficial, benign assignments much more thoroughly than this one special case of thunk overwriting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Conal Elliott &#187; Blog Archive &#187; Exact numeric integration</title>
		<link>http://conal.net/blog/posts/another-angle-on-functional-future-values#comment-301</link>
		<dc:creator><![CDATA[Conal Elliott &#187; Blog Archive &#187; Exact numeric integration]]></dc:creator>
		<pubDate>Mon, 28 Dec 2009 18:26:55 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=73#comment-301</guid>
		<description><![CDATA[&lt;p&gt;[...] This benign-update idea is also explored in Another angle on functional future values. [...]&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>[&#8230;] This benign-update idea is also explored in Another angle on functional future values. [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Patai Gergely</title>
		<link>http://conal.net/blog/posts/another-angle-on-functional-future-values#comment-300</link>
		<dc:creator><![CDATA[Patai Gergely]]></dc:creator>
		<pubDate>Mon, 19 Jan 2009 10:37:24 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=73#comment-300</guid>
		<description><![CDATA[&lt;p&gt;I&#039;ve been looking at this post for a while, but I still can&#039;t see why you need to add all this complexity. Couldn&#039;t you achieve the same thing by simply using an IORef that starts out as Nothing and is assigned exactly once, when the event actually fires?&lt;/p&gt;

&lt;p&gt;What exactly does your code do when you are trying to sample the far future? I don&#039;t understand where the magic future function comes from that can handle this case, but I assume this is what the (imperative?) framework should provide. And again, if we never want to sample with a future time, how is this different from an IORef after all and why is it better?&lt;/p&gt;

&lt;p&gt;Gergely&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>I&#8217;ve been looking at this post for a while, but I still can&#8217;t see why you need to add all this complexity. Couldn&#8217;t you achieve the same thing by simply using an IORef that starts out as Nothing and is assigned exactly once, when the event actually fires?</p>

<p>What exactly does your code do when you are trying to sample the far future? I don&#8217;t understand where the magic future function comes from that can handle this case, but I assume this is what the (imperative?) framework should provide. And again, if we never want to sample with a future time, how is this different from an IORef after all and why is it better?</p>

<p>Gergely</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: conal</title>
		<link>http://conal.net/blog/posts/another-angle-on-functional-future-values#comment-299</link>
		<dc:creator><![CDATA[conal]]></dc:creator>
		<pubDate>Tue, 06 Jan 2009 02:05:38 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=73#comment-299</guid>
		<description><![CDATA[&lt;p&gt;Ryan -- Yes.   See the link where I first mention SampleVar above.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>Ryan &#8212; Yes.   See the link where I first mention SampleVar above.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: conal</title>
		<link>http://conal.net/blog/posts/another-angle-on-functional-future-values#comment-298</link>
		<dc:creator><![CDATA[conal]]></dc:creator>
		<pubDate>Mon, 05 Jan 2009 21:59:35 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=73#comment-298</guid>
		<description><![CDATA[&lt;p&gt;Luke,&lt;/p&gt;

&lt;p&gt;Thanks for the great suggestion!  It also feeds very nicely into relative time:&lt;/p&gt;

&lt;p&gt;&lt;div&gt;
&lt;pre class=&quot;haskell&quot;&gt;order :: Future a -&gt; Future a -&gt; Future &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;a, Future a&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;
order &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;t,a&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt; &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;t&#039;,b&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;
 &#124; t &lt;= t&#039;   = &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;t,  &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;a, &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;t&#039;-t, b&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;
 &#124; &lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:otherwise&quot; rel=&quot;nofollow&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;otherwise&lt;/span&gt;&lt;/a&gt; = &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;t&#039;, &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;b, &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;t-t&#039;, a&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;Then use this &lt;code&gt;order&lt;/code&gt; function to define &lt;code&gt;mappend&lt;/code&gt; on events (temporal interleaving).&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>Luke,</p>

<p>Thanks for the great suggestion!  It also feeds very nicely into relative time:</p>

<p><div>
<pre class="haskell">order :: Future a -&gt; Future a -&gt; Future <span style="color: green;">&#40;</span>a, Future a<span style="color: green;">&#41;</span>
order <span style="color: green;">&#40;</span>t,a<span style="color: green;">&#41;</span> <span style="color: green;">&#40;</span>t',b<span style="color: green;">&#41;</span>
 | t &lt;= t'   = <span style="color: green;">&#40;</span>t,  <span style="color: green;">&#40;</span>a, <span style="color: green;">&#40;</span>t'-t, b<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span>
 | <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:otherwise" rel="nofollow"><span style="font-weight: bold;">otherwise</span></a> = <span style="color: green;">&#40;</span>t', <span style="color: green;">&#40;</span>b, <span style="color: green;">&#40;</span>t-t', a<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span><span style="color: green;">&#41;</span></pre>
</div></p>

<p>Then use this <code>order</code> function to define <code>mappend</code> on events (temporal interleaving).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Ingram</title>
		<link>http://conal.net/blog/posts/another-angle-on-functional-future-values#comment-297</link>
		<dc:creator><![CDATA[Ryan Ingram]]></dc:creator>
		<pubDate>Mon, 05 Jan 2009 21:50:06 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=73#comment-297</guid>
		<description><![CDATA[&lt;p&gt;Is &quot;SampleVar&quot; documented anywhere?  It&#039;s an abstraction I&#039;m unaware of at this moment.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>Is &#8220;SampleVar&#8221; documented anywhere?  It&#8217;s an abstraction I&#8217;m unaware of at this moment.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Luke Palmer</title>
		<link>http://conal.net/blog/posts/another-angle-on-functional-future-values#comment-296</link>
		<dc:creator><![CDATA[Luke Palmer]]></dc:creator>
		<pubDate>Mon, 05 Jan 2009 20:28:58 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=73#comment-296</guid>
		<description><![CDATA[&lt;p&gt;I still claim that you can and should encapsulate your Future representation by the use of the order combinator:&lt;/p&gt;

&lt;pre&gt;
order :: Future a -&gt; Future a -&gt; Future (a, Future a)
order (t,a) (t&#039;,b)
 &#124; t &lt;= t&#039;   = (t,  (a, (t&#039;, b)))
 &#124; otherwise = (t&#039;, (b, (t,  a)))
&lt;/pre&gt;

&lt;p&gt;So that the rest of the reactive code can be independent of your representation.&lt;/p&gt;

&lt;p&gt;Oh, and this looks like a nice lead, by the way.  :-)&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>I still claim that you can and should encapsulate your Future representation by the use of the order combinator:</p>

<pre>
order :: Future a -&gt; Future a -&gt; Future (a, Future a)
order (t,a) (t',b)
 | t &lt;= t'   = (t,  (a, (t', b)))
 | otherwise = (t', (b, (t,  a)))
</pre>

<p>So that the rest of the reactive code can be independent of your representation.</p>

<p>Oh, and this looks like a nice lead, by the way.  <img src="http://conal.net/blog/wp-includes/images/smilies/icon_smile.gif" alt=":-)" class="wp-smiley" /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: conal</title>
		<link>http://conal.net/blog/posts/another-angle-on-functional-future-values#comment-295</link>
		<dc:creator><![CDATA[conal]]></dc:creator>
		<pubDate>Mon, 05 Jan 2009 18:47:38 +0000</pubDate>
		<guid isPermaLink="false">http://conal.net/blog/?p=73#comment-295</guid>
		<description><![CDATA[&lt;p&gt;Hi Creighton.  Thanks for the question.&lt;/p&gt;

&lt;p&gt;I think what makes these futures be absolute time is the use of the &lt;code&gt;Max&lt;/code&gt; monoid.  Switching to the &lt;code&gt;Sum&lt;/code&gt; monoid gives relative time.
Moreover, the definition of &lt;code&gt;until&lt;/code&gt; needs some tweaking.&lt;/p&gt;

&lt;p&gt;Absolute version:&lt;/p&gt;

&lt;p&gt;&lt;div&gt;
&lt;pre class=&quot;haskell&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;b `&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:until&quot; rel=&quot;nofollow&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;until&lt;/span&gt;&lt;/a&gt;` Future &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;t&#039;,b&#039;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt; `at` t = b&#039;&#039; `at` t
 &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;where&lt;/span&gt;
   b&#039;&#039; = &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;if&lt;/span&gt; t &lt;= t&#039; &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;then&lt;/span&gt; b &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;else&lt;/span&gt; b&#039;&lt;/pre&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;The relative version has only a small change:&lt;/p&gt;

&lt;p&gt;&lt;div&gt;
&lt;pre class=&quot;haskell&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;b `&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:until&quot; rel=&quot;nofollow&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;until&lt;/span&gt;&lt;/a&gt;` Future &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;t&#039;,b&#039;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt; `at` t = b&#039;&#039; `at` t
 &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;where&lt;/span&gt;
   b&#039;&#039; = &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;if&lt;/span&gt; t &lt;= t&#039; &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;then&lt;/span&gt; b &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;else&lt;/span&gt; pad t&#039; b&#039;&lt;/pre&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;where the &lt;code&gt;pad&lt;/code&gt; function prepends a segment of &#8869; to a behavior (or any &lt;code&gt;Segment&lt;/code&gt; type).  (For lists, &lt;code&gt;pad n == (repeat n undefined ++)&lt;/code&gt;.)&lt;/p&gt;

&lt;p&gt;Equivalently,&lt;/p&gt;

&lt;p&gt;&lt;div&gt;
&lt;pre class=&quot;haskell&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;b `&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:until&quot; rel=&quot;nofollow&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;until&lt;/span&gt;&lt;/a&gt;` Future &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;t&#039;,b&#039;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt; `at` t
  &#124; t &lt;= t&#039;   = b  `at` t
  &#124; &lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:otherwise&quot; rel=&quot;nofollow&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;otherwise&lt;/span&gt;&lt;/a&gt; = b&#039; `at` &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;t - t&#039;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;Using the ideas in &lt;em&gt;&lt;a href=&quot;http://conal.net/blog/posts/sequences-streams-and-segments/&quot; rel=&quot;nofollow&quot;&gt;Sequences, streams, and segments&lt;/a&gt;&lt;/em&gt; and in &lt;em&gt;&lt;a href=&quot;http://conal.net/blog/posts/sequences-segments-and-signals/&quot; rel=&quot;nofollow&quot;&gt;Sequences, segments, and signals&lt;/a&gt;&lt;/em&gt;, we get a much more elegant definition:&lt;/p&gt;

&lt;p&gt;&lt;div&gt;
&lt;pre class=&quot;haskell&quot;&gt;b `&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:until&quot; rel=&quot;nofollow&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;until&lt;/span&gt;&lt;/a&gt;` Future &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;t&#039;,b&#039;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt; = &lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:take&quot; rel=&quot;nofollow&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;take&lt;/span&gt;&lt;/a&gt; t&#039; b `&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Monoid.html#v:mappend&quot; rel=&quot;nofollow&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;mappend&lt;/span&gt;&lt;/a&gt;` b&#039;&lt;/pre&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;This formulation is what inspired those two blog posts and my renewed interest in relative time FRP.&lt;/p&gt;

&lt;p&gt;With function futures or caching futures, &lt;code&gt;until&lt;/code&gt; would look like the following for absolute time:&lt;/p&gt;

&lt;p&gt;&lt;div&gt;
&lt;pre class=&quot;haskell&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;b `&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:until&quot; rel=&quot;nofollow&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;until&lt;/span&gt;&lt;/a&gt;` u&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt; `at` t = b&#039;&#039; `at` t
 &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;where&lt;/span&gt;
   b&#039;&#039; = &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;case&lt;/span&gt; tryFuture u t &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;of&lt;/span&gt;
           Nothing              -&gt; b
           Just &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;Future &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;_,b&#039;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt; -&gt; b&#039;&lt;/pre&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;For relative time,&lt;/p&gt;

&lt;p&gt;&lt;div&gt;
&lt;pre class=&quot;haskell&quot;&gt;&lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;b `&lt;a href=&quot;http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:until&quot; rel=&quot;nofollow&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;until&lt;/span&gt;&lt;/a&gt;` u&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt; `at` t = b&#039;&#039; `at` t
 &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;where&lt;/span&gt;
   b&#039;&#039; = &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;case&lt;/span&gt; tryFuture u t &lt;span style=&quot;color: #050; font-weight: bold;&quot;&gt;of&lt;/span&gt;
           Nothing               -&gt; b
           Just &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;Future &lt;span style=&quot;color: green;&quot;&gt;&#040;&lt;/span&gt;t&#039;,b&#039;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt;&lt;span style=&quot;color: green;&quot;&gt;&#041;&lt;/span&gt; -&gt; pad t&#039; b&#039;&lt;/pre&gt;
&lt;/div&gt;&lt;/p&gt;

&lt;p&gt;I don&#039;t know how to extend the more elegant &lt;code&gt;take&lt;/code&gt;/&lt;code&gt;mappend&lt;/code&gt; version to use &lt;code&gt;tryFuture&lt;/code&gt;.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>Hi Creighton.  Thanks for the question.</p>

<p>I think what makes these futures be absolute time is the use of the <code>Max</code> monoid.  Switching to the <code>Sum</code> monoid gives relative time.
Moreover, the definition of <code>until</code> needs some tweaking.</p>

<p>Absolute version:</p>

<p><div>
<pre class="haskell"><span style="color: green;">&#40;</span>b `<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:until" rel="nofollow"><span style="font-weight: bold;">until</span></a>` Future <span style="color: green;">&#40;</span>t',b'<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span> `at` t = b'' `at` t
 <span style="color: #050; font-weight: bold;">where</span>
   b'' = <span style="color: #050; font-weight: bold;">if</span> t &lt;= t' <span style="color: #050; font-weight: bold;">then</span> b <span style="color: #050; font-weight: bold;">else</span> b'</pre>
</div></p>

<p>The relative version has only a small change:</p>

<p><div>
<pre class="haskell"><span style="color: green;">&#40;</span>b `<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:until" rel="nofollow"><span style="font-weight: bold;">until</span></a>` Future <span style="color: green;">&#40;</span>t',b'<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span> `at` t = b'' `at` t
 <span style="color: #050; font-weight: bold;">where</span>
   b'' = <span style="color: #050; font-weight: bold;">if</span> t &lt;= t' <span style="color: #050; font-weight: bold;">then</span> b <span style="color: #050; font-weight: bold;">else</span> pad t' b'</pre>
</div></p>

<p>where the <code>pad</code> function prepends a segment of &perp; to a behavior (or any <code>Segment</code> type).  (For lists, <code>pad n == (repeat n undefined ++)</code>.)</p>

<p>Equivalently,</p>

<p><div>
<pre class="haskell"><span style="color: green;">&#40;</span>b `<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:until" rel="nofollow"><span style="font-weight: bold;">until</span></a>` Future <span style="color: green;">&#40;</span>t',b'<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span> `at` t
  | t &lt;= t'   = b  `at` t
  | <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:otherwise" rel="nofollow"><span style="font-weight: bold;">otherwise</span></a> = b' `at` <span style="color: green;">&#40;</span>t - t'<span style="color: green;">&#41;</span></pre>
</div></p>

<p>Using the ideas in <em><a href="http://conal.net/blog/posts/sequences-streams-and-segments/" rel="nofollow">Sequences, streams, and segments</a></em> and in <em><a href="http://conal.net/blog/posts/sequences-segments-and-signals/" rel="nofollow">Sequences, segments, and signals</a></em>, we get a much more elegant definition:</p>

<p><div>
<pre class="haskell">b `<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:until" rel="nofollow"><span style="font-weight: bold;">until</span></a>` Future <span style="color: green;">&#40;</span>t',b'<span style="color: green;">&#41;</span> = <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:take" rel="nofollow"><span style="font-weight: bold;">take</span></a> t' b `<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Data-Monoid.html#v:mappend" rel="nofollow"><span style="font-weight: bold;">mappend</span></a>` b'</pre>
</div></p>

<p>This formulation is what inspired those two blog posts and my renewed interest in relative time FRP.</p>

<p>With function futures or caching futures, <code>until</code> would look like the following for absolute time:</p>

<p><div>
<pre class="haskell"><span style="color: green;">&#40;</span>b `<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:until" rel="nofollow"><span style="font-weight: bold;">until</span></a>` u<span style="color: green;">&#41;</span> `at` t = b'' `at` t
 <span style="color: #050; font-weight: bold;">where</span>
   b'' = <span style="color: #050; font-weight: bold;">case</span> tryFuture u t <span style="color: #050; font-weight: bold;">of</span>
           Nothing              -&gt; b
           Just <span style="color: green;">&#40;</span>Future <span style="color: green;">&#40;</span>_,b'<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span> -&gt; b'</pre>
</div></p>

<p>For relative time,</p>

<p><div>
<pre class="haskell"><span style="color: green;">&#40;</span>b `<a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:until" rel="nofollow"><span style="font-weight: bold;">until</span></a>` u<span style="color: green;">&#41;</span> `at` t = b'' `at` t
 <span style="color: #050; font-weight: bold;">where</span>
   b'' = <span style="color: #050; font-weight: bold;">case</span> tryFuture u t <span style="color: #050; font-weight: bold;">of</span>
           Nothing               -&gt; b
           Just <span style="color: green;">&#40;</span>Future <span style="color: green;">&#40;</span>t',b'<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span> -&gt; pad t' b'</pre>
</div></p>

<p>I don&#8217;t know how to extend the more elegant <code>take</code>/<code>mappend</code> version to use <code>tryFuture</code>.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
